"TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/adodb/adodb/server.php Source File", "datetime" => "Sat Dec 2 19:22:26 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

server.php

00001 <?php
00002 
00010 /* Documentation on usage is at http://php.weblogs.com/adodb_csv
00011  *
00012  * Legal query string parameters:
00013  * 
00014  * sql = holds sql string
00015  * nrows = number of rows to return 
00016  * offset = skip offset rows of data
00017  * fetch = $ADODB_FETCH_MODE
00018  * 
00019  * example:
00020  *
00021  * http://localhost/php/server.php?select+*+from+table&nrows=10&offset=2
00022  */
00023 
00024 
00025 /* 
00026  * Define the IP address you want to accept requests from 
00027  * as a security measure. If blank we accept anyone promisciously!
00028  */
00029 $ACCEPTIP = '127.0.0.1';
00030 
00031 /*
00032  * Connection parameters
00033  */
00034 $driver = 'mysql';
00035 $host = 'localhost'; // DSN for odbc
00036 $uid = 'root';
00037 $pwd = 'garbase-it-is';
00038 $database = 'test';
00039 
00040 /*============================ DO NOT MODIFY BELOW HERE =================================*/
00041 // $sep must match csv2rs() in adodb.inc.php
00042 $sep = ' :::: ';
00043 
00044 include('./adodb.inc.php');
00045 include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
00046 
00047 function err($s)
00048 {
00049         die('**** '.$s.' ');
00050 }
00051 
00052 // undo stupid magic quotes
00053 function undomq(&$m) 
00054 {
00055         if (get_magic_quotes_gpc()) {
00056                 // undo the damage
00057                 $m = str_replace('\\\\','\\',$m);
00058                 $m = str_replace('\"','"',$m);
00059                 $m = str_replace('\\\'','\'',$m);
00060                 
00061         }
00062         return $m;
00063 }
00064 
00066 
00067 
00068 $remote = $_SERVER["REMOTE_ADDR"]; 
00069  
00070 
00071 if (!empty($ACCEPTIP))
00072  if ($remote != '127.0.0.1' && $remote != $ACCEPTIP) 
00073         err("Unauthorised client: '$remote'");
00074         
00075         
00076 if (empty($_REQUEST['sql'])) err('No SQL');
00077 
00078 
00079 $conn = &ADONewConnection($driver);
00080 
00081 if (!$conn->Connect($host,$uid,$pwd,$database)) err($conn->ErrorNo(). $sep . $conn->ErrorMsg());
00082 $sql = undomq($_REQUEST['sql']);
00083 
00084 if (isset($_REQUEST['fetch']))
00085         $ADODB_FETCH_MODE = $_REQUEST['fetch'];
00086         
00087 if (isset($_REQUEST['nrows'])) {
00088         $nrows = $_REQUEST['nrows'];
00089         $offset = isset($_REQUEST['offset']) ? $_REQUEST['offset'] : -1;
00090         $rs = $conn->SelectLimit($sql,$nrows,$offset);
00091 } else 
00092         $rs = $conn->Execute($sql);
00093 if ($rs){ 
00094         //$rs->timeToLive = 1;
00095         echo _rs2serialize($rs,$conn,$sql);
00096         $rs->Close();
00097 } else
00098         err($conn->ErrorNo(). $sep .$conn->ErrorMsg());
00099 
00100 ?>