PageRenderTime 58ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/concreteOLD/libraries/3rdparty/adodb/server.php

https://bitbucket.org/selfeky/xclusivescardwebsite
PHP | 100 lines | 45 code | 23 blank | 32 comment | 12 complexity | 71e694bb076498e07540ad3218ac1011 MD5 | raw file
  1. <?php
  2. /**
  3. * @version V4.93 10 Oct 2006 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
  4. * Released under both BSD license and Lesser GPL library license.
  5. Whenever there is any discrepancy between the two licenses,
  6. the BSD license will take precedence.
  7. */
  8. /* Documentation on usage is at http://php.weblogs.com/adodb_csv
  9. *
  10. * Legal query string parameters:
  11. *
  12. * sql = holds sql string
  13. * nrows = number of rows to return
  14. * offset = skip offset rows of data
  15. * fetch = $ADODB_FETCH_MODE
  16. *
  17. * example:
  18. *
  19. * http://localhost/php/server.php?select+*+from+table&nrows=10&offset=2
  20. */
  21. /*
  22. * Define the IP address you want to accept requests from
  23. * as a security measure. If blank we accept anyone promisciously!
  24. */
  25. $ACCEPTIP = '127.0.0.1';
  26. /*
  27. * Connection parameters
  28. */
  29. $driver = 'mysql';
  30. $host = 'localhost'; // DSN for odbc
  31. $uid = 'root';
  32. $pwd = 'garbase-it-is';
  33. $database = 'test';
  34. /*============================ DO NOT MODIFY BELOW HERE =================================*/
  35. // $sep must match csv2rs() in adodb.inc.php
  36. $sep = ' :::: ';
  37. include('./adodb.inc.php');
  38. include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
  39. function err($s)
  40. {
  41. die('**** '.$s.' ');
  42. }
  43. // undo stupid magic quotes
  44. function undomq(&$m)
  45. {
  46. if (get_magic_quotes_gpc()) {
  47. // undo the damage
  48. $m = str_replace('\\\\','\\',$m);
  49. $m = str_replace('\"','"',$m);
  50. $m = str_replace('\\\'','\'',$m);
  51. }
  52. return $m;
  53. }
  54. ///////////////////////////////////////// DEFINITIONS
  55. $remote = $_SERVER["REMOTE_ADDR"];
  56. if (!empty($ACCEPTIP))
  57. if ($remote != '127.0.0.1' && $remote != $ACCEPTIP)
  58. err("Unauthorised client: '$remote'");
  59. if (empty($_REQUEST['sql'])) err('No SQL');
  60. $conn = ADONewConnection($driver);
  61. if (!$conn->Connect($host,$uid,$pwd,$database)) err($conn->ErrorNo(). $sep . $conn->ErrorMsg());
  62. $sql = undomq($_REQUEST['sql']);
  63. if (isset($_REQUEST['fetch']))
  64. $ADODB_FETCH_MODE = $_REQUEST['fetch'];
  65. if (isset($_REQUEST['nrows'])) {
  66. $nrows = $_REQUEST['nrows'];
  67. $offset = isset($_REQUEST['offset']) ? $_REQUEST['offset'] : -1;
  68. $rs = $conn->SelectLimit($sql,$nrows,$offset);
  69. } else
  70. $rs = $conn->Execute($sql);
  71. if ($rs){
  72. //$rs->timeToLive = 1;
  73. echo _rs2serialize($rs,$conn,$sql);
  74. $rs->Close();
  75. } else
  76. err($conn->ErrorNo(). $sep .$conn->ErrorMsg());
  77. ?>