+++ /dev/null
-<?php\r
-\r
-/** \r
- * @version V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.\r
- * Released under both BSD license and Lesser GPL library license. \r
- Whenever there is any discrepancy between the two licenses, \r
- the BSD license will take precedence. \r
- */\r
- \r
-/* Documentation on usage is at http://php.weblogs.com/adodb_csv\r
- *\r
- * Legal query string parameters:\r
- * \r
- * sql = holds sql string\r
- * nrows = number of rows to return \r
- * offset = skip offset rows of data\r
- * fetch = $ADODB_FETCH_MODE\r
- * \r
- * example:\r
- *\r
- * http://localhost/php/server.php?select+*+from+table&nrows=10&offset=2\r
- */\r
-\r
-\r
-/* \r
- * Define the IP address you want to accept requests from \r
- * as a security measure. If blank we accept anyone promisciously!\r
- */\r
-$ACCEPTIP = '';\r
-\r
-/*\r
- * Connection parameters\r
- */\r
-$driver = 'mysql';\r
-$host = 'localhost'; // DSN for odbc\r
-$uid = 'root';\r
-$pwd = '';\r
-$database = 'test';\r
-\r
-/*============================ DO NOT MODIFY BELOW HERE =================================*/\r
-// $sep must match csv2rs() in adodb.inc.php\r
-$sep = ' :::: ';\r
-\r
-include('./adodb.inc.php');\r
-include_once(ADODB_DIR.'/adodb-csvlib.inc.php');\r
-\r
-function err($s)\r
-{\r
- die('**** '.$s.' ');\r
-}\r
-\r
-// undo stupid magic quotes\r
-function undomq(&$m) \r
-{\r
- if (get_magic_quotes_gpc()) {\r
- // undo the damage\r
- $m = str_replace('\\\\','\\',$m);\r
- $m = str_replace('\"','"',$m);\r
- $m = str_replace('\\\'','\'',$m);\r
- \r
- }\r
- return $m;\r
-}\r
-\r
-///////////////////////////////////////// DEFINITIONS\r
-\r
-\r
-$remote = $_SERVER["REMOTE_ADDR"]; \r
- \r
-if (empty($_GET['sql'])) err('No SQL');\r
-\r
-if (!empty($ACCEPTIP))\r
- if ($remote != '127.0.0.1' && $remote != $ACCEPTIP) \r
- err("Unauthorised client: '$remote'");\r
-\r
-\r
-$conn = &ADONewConnection($driver);\r
-\r
-if (!$conn->Connect($host,$uid,$pwd,$database)) err($conn->ErrorNo(). $sep . $conn->ErrorMsg());\r
-$sql = undomq($_GET['sql']);\r
-\r
-if (isset($_GET['fetch']))\r
- $ADODB_FETCH_MODE = $_GET['fetch'];\r
- \r
-if (isset($_GET['nrows'])) {\r
- $nrows = $_GET['nrows'];\r
- $offset = isset($_GET['offset']) ? $_GET['offset'] : -1;\r
- $rs = $conn->SelectLimit($sql,$nrows,$offset);\r
-} else \r
- $rs = $conn->Execute($sql);\r
-if ($rs){ \r
- //$rs->timeToLive = 1;\r
- echo _rs2serialize($rs,$conn,$sql);\r
- $rs->Close();\r
-} else\r
- err($conn->ErrorNo(). $sep .$conn->ErrorMsg());\r
-\r
-?>
\ No newline at end of file