Advertisement
Guest User

Untitled

a guest
Jun 25th, 2012
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by deZender.Net
  5. * @ deZender (PHP5 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 1.1.5.0
  8. * @ Author : DeZender
  9. * @ Release on : 09.06.2012
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class Database {
  15. var $server = '';
  16. var $user = '';
  17. var $pass = '';
  18. var $database = '';
  19. var $pre = '';
  20. var $error = '';
  21. var $errno = 0;
  22. var $affected_rows = 0;
  23. var $link_id = 0;
  24. var $query_id = 0;
  25.  
  26. function Database($server, $user, $pass, $database, $pre = '') {
  27. $this->server = $server;
  28. $this->user = $user;
  29. $this->pass = $pass;
  30. $this->database = $database;
  31. $this->pre = $pre;
  32. }
  33.  
  34. function connect($new_link = false) {
  35. $this->link_id = @mysql_connect( $this->server, $this->user, $this->pass, $new_link );
  36.  
  37. if (!$this->link_id) {
  38. $this->oops( 'Could not connect to server: <b>' . $this->server . '</b>.' );
  39. }
  40.  
  41.  
  42. if (!@mysql_select_db( $this->database, $this->link_id )) {
  43. $this->oops( 'Could not open database: <b>' . $this->database . '</b>.' );
  44. }
  45.  
  46. $this->server = '';
  47. $this->user = '';
  48. $this->pass = '';
  49. $this->database = '';
  50. }
  51.  
  52. function close() {
  53. if (!@mysql_close( $this->link_id )) {
  54. $this->oops( 'Connection close failed.' );
  55. }
  56.  
  57. }
  58.  
  59. function escape($string) {
  60. if (get_magic_quotes_runtime( )) {
  61. $string = stripslashes( $string );
  62. }
  63.  
  64. return @mysql_real_escape_string( $string, $this->link_id );
  65. }
  66.  
  67. function query($sql) {
  68. $this->query_id = @mysql_query( $sql, $this->link_id );
  69.  
  70. if (!$this->query_id) {
  71. $this->oops( '<b>MySQL Query fail:</b> ' . $sql );
  72. return 0;
  73. }
  74.  
  75. $this->affected_rows = @mysql_affected_rows( $this->link_id );
  76. return $this->query_id;
  77. }
  78.  
  79. function fetch_array($query_id = -1) {
  80. if ($query_id != -1) {
  81. $this->query_id = $query_id;
  82. }
  83.  
  84.  
  85. if (isset( $this->query_id )) {
  86. $record = @mysql_fetch_assoc( $this->query_id );
  87. } else {
  88. $this->oops( 'Invalid query_id: <b>' . $this->query_id . '</b>. Records could not be fetched.' );
  89. }
  90.  
  91. return $record;
  92. }
  93.  
  94. function fetch_all_array($sql) {
  95. $query_id = $this->query( $sql );
  96. $out = array( );
  97.  
  98. if ($row = $this->fetch_array( $query_id )) {
  99. $out[] = $row;
  100. }
  101.  
  102. $this->free_result( $query_id );
  103. return $out;
  104. }
  105.  
  106. function free_result($query_id = -1) {
  107. if ($query_id != -1) {
  108. $this->query_id = $query_id;
  109. }
  110.  
  111.  
  112. if (( $this->query_id != 0 && !@mysql_free_result( $this->query_id ) )) {
  113. $this->oops( 'Result ID: <b>' . $this->query_id . '</b> could not be freed.' );
  114. }
  115.  
  116. }
  117.  
  118. function query_first($query_string) {
  119. $query_id = $this->query( $query_string );
  120. $out = $this->fetch_array( $query_id );
  121. $this->free_result( $query_id );
  122. return $out;
  123. }
  124.  
  125. function query_update($table, $data, $where = '1') {
  126. $q = 'UPDATE `' . $this->pre . $table . '` SET ';
  127. foreach ($data as $key => $val) {
  128. if (strtolower( $val ) == 'null') {
  129. $q .= ( '`' ) . $key . '` = NULL, ';
  130. continue;
  131. }
  132.  
  133.  
  134. if (strtolower( $val ) == 'now()') {
  135. $q .= ( '`' ) . $key . '` = NOW(), ';
  136. continue;
  137. }
  138.  
  139.  
  140. if (preg_match( '/^increment\((\-?\d+)\)$/i', $val, $m )) {
  141. $q .= ( '`' ) . $key . '` = `' . $key . '` + ' . $m[1] . ', ';
  142. continue;
  143. }
  144.  
  145. $q .= ( '`' ) . $key . '`=\'' . $this->escape( $val ) . '\', ';
  146. }
  147.  
  148. $q = rtrim( $q, ', ' ) . ' WHERE ' . $where . ';';
  149. return $this->query( $q );
  150. }
  151. ................................................
  152. ...............................
  153. ............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement