Source for file server.php
Documentation is available at server.php
* @version V4.93 10 Oct 2006 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
/* Documentation on usage is at http://php.weblogs.com/adodb_csv
* Legal query string parameters:
* nrows = number of rows to return
* offset = skip offset rows of data
* fetch = $ADODB_FETCH_MODE
* http://localhost/php/server.php?select+*+from+table&nrows=10&offset=2
* Define the IP address you want to accept requests from
* as a security measure. If blank we accept anyone promisciously!
$host =
'localhost'; // DSN for odbc
/*============================ DO NOT MODIFY BELOW HERE =================================*/
// $sep must match csv2rs() in adodb.inc.php
include('./adodb.inc.php');
include_once(ADODB_DIR.
'/adodb-csvlib.inc.php');
// undo stupid magic quotes
///////////////////////////////////////// DEFINITIONS
$remote =
$_SERVER["REMOTE_ADDR"];
if ($remote !=
'127.0.0.1' &&
$remote !=
$ACCEPTIP)
err("Unauthorised client: '$remote'");
if (empty($_REQUEST['sql'])) err('No SQL');
$conn =
ADONewConnection($driver);
if (!$conn->Connect($host,$uid,$pwd,$database)) err($conn->ErrorNo().
$sep .
$conn->ErrorMsg());
$sql =
undomq($_REQUEST['sql']);
if (isset
($_REQUEST['fetch']))
$ADODB_FETCH_MODE =
$_REQUEST['fetch'];
if (isset
($_REQUEST['nrows'])) {
$nrows =
$_REQUEST['nrows'];
$offset = isset
($_REQUEST['offset']) ?
$_REQUEST['offset'] : -
1;
$rs =
$conn->SelectLimit($sql,$nrows,$offset);
$rs =
$conn->Execute($sql);
echo
_rs2serialize($rs,$conn,$sql);
err($conn->ErrorNo().
$sep .
$conn->ErrorMsg());
Documentation generated on Sun, 09 Mar 2008 23:53:01 -0300 by phpDocumentor 1.4.0