source: trunk/phpgwapi/inc/adodb/server.php @ 2

Revision 2, 2.3 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2
3/**
4 * @version V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
5 * Released under both BSD license and Lesser GPL library license.
6  Whenever there is any discrepancy between the two licenses,
7  the BSD license will take precedence.
8 */
9 
10/* Documentation on usage is at http://php.weblogs.com/adodb_csv
11 *
12 * Legal query string parameters:
13 *
14 * sql = holds sql string
15 * nrows = number of rows to return
16 * offset = skip offset rows of data
17 * fetch = $ADODB_FETCH_MODE
18 *
19 * example:
20 *
21 * http://localhost/php/server.php?select+*+from+table&nrows=10&offset=2
22 */
23
24
25/*
26 * Define the IP address you want to accept requests from
27 * as a security measure. If blank we accept anyone promisciously!
28 */
29$ACCEPTIP = '';
30
31/*
32 * Connection parameters
33 */
34$driver = 'mysql';
35$host = 'localhost'; // DSN for odbc
36$uid = 'root';
37$pwd = '';
38$database = 'test';
39
40/*============================ DO NOT MODIFY BELOW HERE =================================*/
41// $sep must match csv2rs() in adodb.inc.php
42$sep = ' :::: ';
43
44include('./adodb.inc.php');
45include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
46
47function err($s)
48{
49        die('**** '.$s.' ');
50}
51
52// undo stupid magic quotes
53function undomq(&$m)
54{
55        if (get_magic_quotes_gpc()) {
56                // undo the damage
57                $m = str_replace('\\\\','\\',$m);
58                $m = str_replace('\"','"',$m);
59                $m = str_replace('\\\'','\'',$m);
60               
61        }
62        return $m;
63}
64
65///////////////////////////////////////// DEFINITIONS
66
67
68$remote = $HTTP_SERVER_VARS["REMOTE_ADDR"];
69 
70if (empty($HTTP_GET_VARS['sql'])) err('No SQL');
71
72if (!empty($ACCEPTIP))
73 if ($remote != '127.0.0.1' && $remote != $ACCEPTIP)
74        err("Unauthorised client: '$remote'");
75
76
77$conn = &ADONewConnection($driver);
78
79if (!$conn->Connect($host,$uid,$pwd,$database)) err($conn->ErrorNo(). $sep . $conn->ErrorMsg());
80$sql = undomq($HTTP_GET_VARS['sql']);
81
82if (isset($HTTP_GET_VARS['fetch']))
83        $ADODB_FETCH_MODE = $HTTP_GET_VARS['fetch'];
84       
85if (isset($HTTP_GET_VARS['nrows'])) {
86        $nrows = $HTTP_GET_VARS['nrows'];
87        $offset = isset($HTTP_GET_VARS['offset']) ? $HTTP_GET_VARS['offset'] : -1;
88        $rs = $conn->SelectLimit($sql,$nrows,$offset);
89} else
90        $rs = $conn->Execute($sql);
91if ($rs){
92        //$rs->timeToLive = 1;
93        echo _rs2serialize($rs,$conn,$sql);
94        $rs->Close();
95} else
96        err($conn->ErrorNo(). $sep .$conn->ErrorMsg());
97
98?>
Note: See TracBrowser for help on using the repository browser.