Advertisement
YeiZeta

Barquisimeto Unexpo.edu hacking error Data by yei zeta

Mar 20th, 2012
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.53 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. * Set tabs to 4 for best viewing.
  5. *
  6. * Latest version is available at http://php.weblogs.com
  7. *
  8. * This is the main include file for ADOdb.
  9. * Database specific drivers are stored in the adodb/drivers/adodb-*.inc.php
  10. *
  11. * The ADOdb files are formatted so that doxygen can be used to generate documentation.
  12. * Doxygen is a documentation generation tool and can be downloaded from http://doxygen.org/
  13. */
  14.  
  15. /**
  16. \mainpage
  17.  
  18. @version V3.40 7 April 2003 (c) 2000-2003 John Lim (jlim\@natsoft.com.my). All rights reserved.
  19.  
  20. Released under both BSD license and Lesser GPL library license.
  21. Whenever there is any discrepancy between the two licenses,
  22. the BSD license will take precedence.
  23.  
  24. PHP's database access functions are not standardised. This creates a need for a database
  25. class library to hide the differences between the different database API's (encapsulate
  26. the differences) so we can easily switch databases.
  27.  
  28. We currently support MySQL, Oracle, Microsoft SQL Server, Sybase, Sybase SQL Anywhere,
  29. Informix, PostgreSQL, FrontBase, Interbase (Firebird and Borland variants), Foxpro, Access,
  30. ADO and ODBC. We have had successful reports of connecting to Progress and DB2 via ODBC.
  31. We hope more people will contribute drivers to support other databases.
  32.  
  33. Latest Download at http://php.weblogs.com/adodb<br>
  34. Manual is at http://php.weblogs.com/adodb_manual
  35.  
  36. */
  37.  
  38. if (!defined('_ADODB_LAYER')) {
  39. define('_ADODB_LAYER',1);
  40.  
  41. //==============================================================================================
  42. // CONSTANT DEFINITIONS
  43. //==============================================================================================
  44.  
  45. define('ADODB_BAD_RS','<p>Bad $rs in %s. Connection or SQL invalid. Try using $connection->debug=true;</p>');
  46.  
  47. define('ADODB_FETCH_DEFAULT',0);
  48. define('ADODB_FETCH_NUM',1);
  49. define('ADODB_FETCH_ASSOC',2);
  50. define('ADODB_FETCH_BOTH',3);
  51.  
  52. /*
  53. Controls ADODB_FETCH_ASSOC field-name case. Default is 2, use native case-names.
  54. This currently works only with mssql, odbc, oci8po and ibase derived drivers.
  55.  
  56. 0 = assoc lowercase field names. $rs->fields['orderid']
  57. 1 = assoc uppercase field names. $rs->fields['ORDERID']
  58. 2 = use native-case field names. $rs->fields['OrderID']
  59. */
  60. if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2);
  61.  
  62. // allow [ ] @ ` and . in table names
  63. define('ADODB_TABLE_REGEX','([]0-9a-z_\`\.\@\[-]*)');
  64.  
  65.  
  66. if (!defined('ADODB_PREFETCH_ROWS')) define('ADODB_PREFETCH_ROWS',10);
  67.  
  68. /**
  69. * Set ADODB_DIR to the directory where this file resides...
  70. * This constant was formerly called $ADODB_RootPath
  71. */
  72. if (!defined('ADODB_DIR')) define('ADODB_DIR',dirname(__FILE__));
  73.  
  74. define('TIMESTAMP_FIRST_YEAR',100);
  75.  
  76. //==============================================================================================
  77. // GLOBAL VARIABLES
  78. //==============================================================================================
  79.  
  80. GLOBAL
  81. $ADODB_vers, // database version
  82. $ADODB_Database, // last database driver used
  83. $ADODB_COUNTRECS, // count number of records returned - slows down query
  84. $ADODB_CACHE_DIR, // directory to cache recordsets
  85. $ADODB_EXTENSION, // ADODB extension installed
  86. $ADODB_COMPAT_PATCH, // If $ADODB_COUNTRECS and this is true, $rs->fields is available on EOF
  87. $ADODB_FETCH_MODE; // DEFAULT, NUM, ASSOC or BOTH. Default follows native driver default...
  88.  
  89. //==============================================================================================
  90. // GLOBAL SETUP
  91. //==============================================================================================
  92.  
  93. if (strnatcmp(PHP_VERSION,'4.3.0')>=0) {
  94. define('ADODB_PHPVER',0x4300);
  95. } else if (strnatcmp(PHP_VERSION,'4.2.0')>=0) {
  96. define('ADODB_PHPVER',0x4200);
  97. } else if (strnatcmp(PHP_VERSION,'4.0.5')>=0) {
  98. define('ADODB_PHPVER',0x4050);
  99. } else {
  100. define('ADODB_PHPVER',0x4000);
  101. }
  102. $ADODB_EXTENSION = defined('ADODB_EXTENSION');
  103. //if (extension_loaded('dbx')) define('ADODB_DBX',1);
  104.  
  105. /**
  106. Accepts $src and $dest arrays, replacing string $data
  107. */
  108. function ADODB_str_replace($src, $dest, $data)
  109. {
  110. if (ADODB_PHPVER >= 0x4050) return str_replace($src,$dest,$data);
  111.  
  112. $s = reset($src);
  113. $d = reset($dest);
  114. while ($s !== false) {
  115. $data = str_replace($s,$d,$data);
  116. $s = next($src);
  117. $d = next($dest);
  118. }
  119. return $data;
  120. }
  121.  
  122. function ADODB_Setup()
  123. {
  124. GLOBAL
  125. $ADODB_vers, // database version
  126. $ADODB_Database, // last database driver used
  127. $ADODB_COUNTRECS, // count number of records returned - slows down query
  128. $ADODB_CACHE_DIR, // directory to cache recordsets
  129. $ADODB_FETCH_MODE;
  130.  
  131. $ADODB_FETCH_MODE = ADODB_FETCH_DEFAULT;
  132.  
  133. if (!isset($ADODB_CACHE_DIR)) {
  134. $ADODB_CACHE_DIR = '/tmp';
  135. } else {
  136. // do not accept url based paths, eg. http:/ or ftp:/
  137. if (strpos($ADODB_CACHE_DIR,'://') !== false)
  138. die("Illegal path http:// or ftp://");
  139. }
  140.  
  141.  
  142. // Initialize random number generator for randomizing cache flushes
  143. srand(((double)microtime())*1000000);
  144.  
  145. /**
  146. * Name of last database driver loaded into memory. Set by ADOLoadCode().
  147. */
  148. $ADODB_Database = '';
  149.  
  150. /**
  151. * ADODB version as a string.
  152. */
  153. $ADODB_vers = 'V3.40 7 April 2003 (c) 2000-2003 John Lim ([email protected]). All rights reserved. Released BSD & LGPL.';
  154.  
  155. /**
  156. * Determines whether recordset->RecordCount() is used.
  157. * Set to false for highest performance -- RecordCount() will always return -1 then
  158. * for databases that provide "virtual" recordcounts...
  159. */
  160. $ADODB_COUNTRECS = true;
  161. }
  162.  
  163.  
  164. //==============================================================================================
  165. // CHANGE NOTHING BELOW UNLESS YOU ARE CODING
  166. //==============================================================================================
  167.  
  168. ADODB_Setup();
  169.  
  170. //==============================================================================================
  171. // CLASS ADOFieldObject
  172. //==============================================================================================
  173. /**
  174. * Helper class for FetchFields -- holds info on a column
  175. */
  176. class ADOFieldObject {
  177. var $name = '';
  178. var $max_length=0;
  179. var $type="";
  180.  
  181. // additional fields by dannym... ([email protected])
  182. var $not_null = false;
  183. // actually, this has already been built-in in the postgres, fbsql AND mysql module? ^-^
  184. // so we can as well make not_null standard (leaving it at "false" does not harm anyways)
  185.  
  186. var $has_default = false; // this one I have done only in mysql and postgres for now ...
  187. // others to come (dannym)
  188. var $default_value; // default, if any, and supported. Check has_default first.
  189. }
  190.  
  191.  
  192. //==============================================================================================
  193. // CLASS ADOConnection
  194. //==============================================================================================
  195.  
  196. include_once(ADODB_DIR.'/adodb-connection.inc.php');
  197.  
  198.  
  199.  
  200. //==============================================================================================
  201. // CLASS ADOFetchObj
  202. //==============================================================================================
  203.  
  204. /**
  205. * Internal placeholder for record objects. Used by ADORecordSet->FetchObj().
  206. */
  207. class ADOFetchObj {
  208. };
  209.  
  210. //==============================================================================================
  211. // CLASS ADORecordSet_empty
  212. //==============================================================================================
  213.  
  214. /**
  215. * Lightweight recordset when there are no records to be returned
  216. */
  217. class ADORecordSet_empty
  218. {
  219. var $dataProvider = 'empty';
  220. var $databaseType = false;
  221. var $EOF = true;
  222. var $_numOfRows = 0;
  223. var $fields = false;
  224. var $connection = false;
  225. function RowCount() {return 0;}
  226. function RecordCount() {return 0;}
  227. function PO_RecordCount(){return 0;}
  228. function Close(){return true;}
  229. function FetchRow() {return false;}
  230. function FieldCount(){ return 0;}
  231. }
  232.  
  233. //==============================================================================================
  234. // DATE AND TIME FUNCTIONS
  235. //==============================================================================================
  236. include_once(ADODB_DIR.'/adodb-time.inc.php');
  237.  
  238. //==============================================================================================
  239. // CLASS ADORecordSet
  240. //==============================================================================================
  241. include_once(ADODB_DIR.'/adodb-recordset.inc.php');
  242.  
  243. //==============================================================================================
  244. // CLASS ADORecordSet_array
  245. //==============================================================================================
  246.  
  247. /**
  248. * This class encapsulates the concept of a recordset created in memory
  249. * as an array. This is useful for the creation of cached recordsets.
  250. *
  251. * Note that the constructor is different from the standard ADORecordSet
  252. */
  253.  
  254. class ADORecordSet_array extends ADORecordSet
  255. {
  256. var $databaseType = 'array';
  257.  
  258. var $_array; // holds the 2-dimensional data array
  259. var $_types; // the array of types of each column (C B I L M)
  260. var $_colnames; // names of each column in array
  261. var $_skiprow1; // skip 1st row because it holds column names
  262. var $_fieldarr; // holds array of field objects
  263. var $canSeek = true;
  264. var $affectedrows = false;
  265. var $insertid = false;
  266. var $sql = '';
  267. var $compat = false;
  268. /**
  269. * Constructor
  270. *
  271. */
  272. function ADORecordSet_array($fakeid=1)
  273. {
  274. global $ADODB_FETCH_MODE,$ADODB_COMPAT_FETCH;
  275.  
  276. // fetch() on EOF does not delete $this->fields
  277. $this->compat = !empty($ADODB_COMPAT_FETCH);
  278. $this->ADORecordSet($fakeid); // fake queryID
  279. $this->fetchMode = $ADODB_FETCH_MODE;
  280. }
  281.  
  282.  
  283. /**
  284. * Setup the Array. Later we will have XML-Data and CSV handlers
  285. *
  286. * @param array is a 2-dimensional array holding the data.
  287. * The first row should hold the column names
  288. * unless paramter $colnames is used.
  289. * @param typearr holds an array of types. These are the same types
  290. * used in MetaTypes (C,B,L,I,N).
  291. * @param [colnames] array of column names. If set, then the first row of
  292. * $array should not hold the column names.
  293. */
  294. function InitArray($array,$typearr,$colnames=false)
  295. {
  296. $this->_array = $array;
  297. $this->_types = $typearr;
  298. if ($colnames) {
  299. $this->_skiprow1 = false;
  300. $this->_colnames = $colnames;
  301. } else $this->_colnames = $array[0];
  302.  
  303. $this->Init();
  304. }
  305. /**
  306. * Setup the Array and datatype file objects
  307. *
  308. * @param array is a 2-dimensional array holding the data.
  309. * The first row should hold the column names
  310. * unless paramter $colnames is used.
  311. * @param fieldarr holds an array of ADOFieldObject's.
  312. */
  313. function InitArrayFields($array,$fieldarr)
  314. {
  315. $this->_array = $array;
  316. $this->_skiprow1= false;
  317. if ($fieldarr) {
  318. $this->_fieldobjects = $fieldarr;
  319. }
  320. $this->Init();
  321. }
  322.  
  323. function GetArray($nRows=-1)
  324. {
  325. if ($nRows == -1 && $this->_currentRow <= 0 && !$this->_skiprow1) {
  326. return $this->_array;
  327. } else {
  328. return ADORecordSet::GetArray($nRows);
  329. }
  330. }
  331.  
  332. function _initrs()
  333. {
  334. $this->_numOfRows = sizeof($this->_array);
  335. if ($this->_skiprow1) $this->_numOfRows -= 1;
  336.  
  337. $this->_numOfFields =(isset($this->_fieldobjects)) ?
  338. sizeof($this->_fieldobjects):sizeof($this->_types);
  339. }
  340.  
  341. /* Use associative array to get fields array */
  342. function Fields($colname)
  343. {
  344. if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname];
  345.  
  346. if (!$this->bind) {
  347. $this->bind = array();
  348. for ($i=0; $i < $this->_numOfFields; $i++) {
  349. $o = $this->FetchField($i);
  350. $this->bind[strtoupper($o->name)] = $i;
  351. }
  352. }
  353. return $this->fields[$this->bind[strtoupper($colname)]];
  354. }
  355.  
  356. function &FetchField($fieldOffset = -1)
  357. {
  358. if (isset($this->_fieldobjects)) {
  359. return $this->_fieldobjects[$fieldOffset];
  360. }
  361. $o = new ADOFieldObject();
  362. $o->name = $this->_colnames[$fieldOffset];
  363. $o->type = $this->_types[$fieldOffset];
  364. $o->max_length = -1; // length not known
  365.  
  366. return $o;
  367. }
  368.  
  369. function _seek($row)
  370. {
  371. if (sizeof($this->_array) && $row < $this->_numOfRows) {
  372. $this->fields = $this->_array[$row];
  373. return true;
  374. }
  375. return false;
  376. }
  377.  
  378. function MoveNext()
  379. {
  380. if (!$this->EOF) {
  381. $this->_currentRow++;
  382.  
  383. $pos = $this->_currentRow;
  384. if ($this->_skiprow1) $pos += 1;
  385.  
  386. if ($this->_numOfRows <= $pos) {
  387. if (!$this->compat) $this->fields = false;
  388. } else {
  389. $this->fields = $this->_array[$pos];
  390. return true;
  391. }
  392. $this->EOF = true;
  393. }
  394.  
  395. return false;
  396. }
  397.  
  398. function _fetch()
  399. {
  400. $pos = $this->_currentRow;
  401. if ($this->_skiprow1) $pos += 1;
  402.  
  403. if ($this->_numOfRows <= $pos) {
  404. if (!$this->compat) $this->fields = false;
  405. return false;
  406. }
  407.  
  408. $this->fields = $this->_array[$pos];
  409. return true;
  410. }
  411.  
  412. function _close()
  413. {
  414. return true;
  415. }
  416.  
  417. } // ADORecordSet_array
  418.  
  419. //==============================================================================================
  420. // HELPER FUNCTIONS
  421. //==============================================================================================
  422.  
  423. /**
  424. * Synonym for ADOLoadCode.
  425. *
  426. * @deprecated
  427. */
  428. function ADOLoadDB($dbType)
  429. {
  430. return ADOLoadCode($dbType);
  431. }
  432.  
  433. /**
  434. * Load the code for a specific database driver
  435. */
  436. function ADOLoadCode($dbType)
  437. {
  438. GLOBAL $ADODB_Database;
  439.  
  440. if (!$dbType) return false;
  441. $ADODB_Database = strtolower($dbType);
  442. switch ($ADODB_Database) {
  443. case 'maxsql': $ADODB_Database = 'mysqlt'; break;
  444. case 'postgres':
  445. case 'pgsql': $ADODB_Database = 'postgres7'; break;
  446. }
  447. // Karsten Kraus <[email protected]>
  448. return @include_once(ADODB_DIR."/drivers/adodb-".$ADODB_Database.".inc.php");
  449. }
  450.  
  451. /**
  452. * synonym for ADONewConnection for people like me who cannot remember the correct name
  453. */
  454. function &NewADOConnection($db='')
  455. {
  456. return ADONewConnection($db);
  457. }
  458.  
  459. /**
  460. * Instantiate a new Connection class for a specific database driver.
  461. *
  462. * @param [db] is the database Connection object to create. If undefined,
  463. * use the last database driver that was loaded by ADOLoadCode().
  464. *
  465. * @return the freshly created instance of the Connection class.
  466. */
  467. function &ADONewConnection($db='')
  468. {
  469. GLOBAL $ADODB_Database;
  470.  
  471. $rez = true;
  472. if ($db) {
  473. if ($ADODB_Database != $db) ADOLoadCode($db);
  474. } else {
  475. if (!empty($ADODB_Database)) {
  476. ADOLoadCode($ADODB_Database);
  477. } else {
  478. $rez = false;
  479. }
  480. }
  481.  
  482. $errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false;
  483. if (!$rez) {
  484. if ($errorfn) {
  485. // raise an error
  486. $errorfn('ADONewConnection', 'ADONewConnection', -998,
  487. "could not load the database driver for '$db",
  488. $dbtype);
  489. } else
  490. ADOConnection::outp( "<p>ADONewConnection: Unable to load database driver '$db'</p>",false);
  491.  
  492. return false;
  493. }
  494.  
  495. $cls = 'ADODB_'.$ADODB_Database;
  496. $obj = new $cls();
  497. if ($errorfn) {
  498. $obj->raiseErrorFn = $errorfn;
  499. }
  500. return $obj;
  501. }
  502.  
  503. function &NewDataDictionary(&$conn)
  504. {
  505. $provider = $conn->dataProvider;
  506. if ($provider !== 'native' && $provider != 'odbc' && $provider != 'ado')
  507. $drivername = $conn->dataProvider;
  508. else {
  509. $drivername = $conn->databaseType;
  510. if (substr($drivername,0,5) == 'odbc_') $drivername = substr($drivername,5);
  511. else if (substr($drivername,0,4) == 'ado_') $drivername = substr($drivername,4);
  512. else if ($drivername == 'oracle') $drivername = 'oci8';
  513. }
  514. include_once(ADODB_DIR.'/adodb-lib.inc.php');
  515. include_once(ADODB_DIR.'/adodb-datadict.inc.php');
  516. $path = ADODB_DIR."/datadict/datadict-$drivername.inc.php";
  517.  
  518. if (!file_exists($path)) {
  519. ADOConnection::outp("Database driver '$path' not available");
  520. return false;
  521. }
  522. include_once($path);
  523. $class = "ADODB2_$drivername";
  524. $dict = new $class();
  525. $dict->connection = &$conn;
  526. $dict->upperName = strtoupper($drivername);
  527. if (is_resource($conn->_connectionID))
  528. $dict->serverInfo = $conn->ServerInfo();
  529.  
  530. return $dict;
  531. }
  532.  
  533.  
  534. /**
  535. * Save a file $filename and its $contents (normally for caching) with file locking
  536. */
  537. function adodb_write_file($filename, $contents,$debug=false)
  538. {
  539. # http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows
  540. # So to simulate locking, we assume that rename is an atomic operation.
  541. # First we delete $filename, then we create a $tempfile write to it and
  542. # rename to the desired $filename. If the rename works, then we successfully
  543. # modified the file exclusively.
  544. # What a stupid need - having to simulate locking.
  545. # Risks:
  546. # 1. $tempfile name is not unique -- very very low
  547. # 2. unlink($filename) fails -- ok, rename will fail
  548. # 3. adodb reads stale file because unlink fails -- ok, $rs timeout occurs
  549. # 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated
  550. if (strpos(strtoupper(PHP_OS),'WIN') !== false) {
  551. // skip the decimal place
  552. $mtime = substr(str_replace(' ','_',microtime()),2);
  553. // unlink will let some latencies develop, so uniqid() is more random
  554. @unlink($filename);
  555. // getmypid() actually returns 0 on Win98 - never mind!
  556. $tmpname = $filename.uniqid($mtime).getmypid();
  557. if (!($fd = fopen($tmpname,'a'))) return false;
  558. $ok = ftruncate($fd,0);
  559. if (!fwrite($fd,$contents)) $ok = false;
  560. fclose($fd);
  561. chmod($tmpname,0644);
  562. if (!@rename($tmpname,$filename)) {
  563. unlink($tmpname);
  564. $ok = false;
  565. }
  566. if (!$ok) {
  567. if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed'));
  568. }
  569. return $ok;
  570. }
  571. if (!($fd = fopen($filename, 'a'))) return false;
  572. if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) {
  573. $ok = fwrite( $fd, $contents );
  574. fclose($fd);
  575. chmod($filename,0644);
  576. }else {
  577. fclose($fd);
  578. if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename<br>\n");
  579. $ok = false;
  580. }
  581.  
  582. return $ok;
  583. }
  584.  
  585.  
  586. function adodb_backtrace($print=true)
  587. {
  588. $s = '';
  589. if (PHPVERSION() >= 4.3) {
  590.  
  591. $MAXSTRLEN = 64;
  592.  
  593. $s = '<pre align=left>';
  594. $traceArr = debug_backtrace();
  595. array_shift($traceArr);
  596. $tabs = sizeof($traceArr)-1;
  597. foreach ($traceArr as $arr) {
  598. for ($i=0; $i < $tabs; $i++) $s .= ' &nbsp; ';
  599. $tabs -= 1;
  600. $s .= '<font face="Courier New,Courier">';
  601. if (isset($arr['class'])) $s .= $arr['class'].'.';
  602. foreach($arr['args'] as $v) {
  603. if (is_null($v)) $args[] = 'null';
  604. else if (is_array($v)) $args[] = 'Array['.sizeof($v).']';
  605. else if (is_object($v)) $args[] = 'Object:'.get_class($v);
  606. else if (is_bool($v)) $args[] = $v ? 'true' : 'false';
  607. else {
  608. $v = (string) @$v;
  609. $str = htmlspecialchars(substr($v,0,$MAXSTRLEN));
  610. if (strlen($v) > $MAXSTRLEN) $str .= '...';
  611. $args[] = $str;
  612. }
  613. }
  614.  
  615. $s .= $arr['function'].'('.implode(', ',$args).')';
  616. $s .= sprintf("</font><font color=#808080 size=-1> # line %4d, file: <a href=\"file:/%s\">%s</a></font>",
  617. $arr['line'],$arr['file'],$arr['file']);
  618. $s .= "\n";
  619. }
  620. $s .= '</pre>';
  621. if ($print) print $s;
  622. }
  623. return $s;
  624. }
  625.  
  626. } // defined
  627. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement