Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by deZender.Net
- * @ deZender (PHP5 Decoder for ionCube Encoder)
- *
- * @ Version : 1.1.5.0
- * @ Author : DeZender
- * @ Release on : 09.06.2012
- * @ Official site : http://DeZender.Net
- *
- */
- class Database {
- var $server = '';
- var $user = '';
- var $pass = '';
- var $database = '';
- var $pre = '';
- var $error = '';
- var $errno = 0;
- var $affected_rows = 0;
- var $link_id = 0;
- var $query_id = 0;
- function Database($server, $user, $pass, $database, $pre = '') {
- $this->server = $server;
- $this->user = $user;
- $this->pass = $pass;
- $this->database = $database;
- $this->pre = $pre;
- }
- function connect($new_link = false) {
- $this->link_id = @mysql_connect( $this->server, $this->user, $this->pass, $new_link );
- if (!$this->link_id) {
- $this->oops( 'Could not connect to server: <b>' . $this->server . '</b>.' );
- }
- if (!@mysql_select_db( $this->database, $this->link_id )) {
- $this->oops( 'Could not open database: <b>' . $this->database . '</b>.' );
- }
- $this->server = '';
- $this->user = '';
- $this->pass = '';
- $this->database = '';
- }
- function close() {
- if (!@mysql_close( $this->link_id )) {
- $this->oops( 'Connection close failed.' );
- }
- }
- function escape($string) {
- if (get_magic_quotes_runtime( )) {
- $string = stripslashes( $string );
- }
- return @mysql_real_escape_string( $string, $this->link_id );
- }
- function query($sql) {
- $this->query_id = @mysql_query( $sql, $this->link_id );
- if (!$this->query_id) {
- $this->oops( '<b>MySQL Query fail:</b> ' . $sql );
- return 0;
- }
- $this->affected_rows = @mysql_affected_rows( $this->link_id );
- return $this->query_id;
- }
- function fetch_array($query_id = -1) {
- if ($query_id != -1) {
- $this->query_id = $query_id;
- }
- if (isset( $this->query_id )) {
- $record = @mysql_fetch_assoc( $this->query_id );
- } else {
- $this->oops( 'Invalid query_id: <b>' . $this->query_id . '</b>. Records could not be fetched.' );
- }
- return $record;
- }
- function fetch_all_array($sql) {
- $query_id = $this->query( $sql );
- $out = array( );
- if ($row = $this->fetch_array( $query_id )) {
- $out[] = $row;
- }
- $this->free_result( $query_id );
- return $out;
- }
- function free_result($query_id = -1) {
- if ($query_id != -1) {
- $this->query_id = $query_id;
- }
- if (( $this->query_id != 0 && !@mysql_free_result( $this->query_id ) )) {
- $this->oops( 'Result ID: <b>' . $this->query_id . '</b> could not be freed.' );
- }
- }
- function query_first($query_string) {
- $query_id = $this->query( $query_string );
- $out = $this->fetch_array( $query_id );
- $this->free_result( $query_id );
- return $out;
- }
- function query_update($table, $data, $where = '1') {
- $q = 'UPDATE `' . $this->pre . $table . '` SET ';
- foreach ($data as $key => $val) {
- if (strtolower( $val ) == 'null') {
- $q .= ( '`' ) . $key . '` = NULL, ';
- continue;
- }
- if (strtolower( $val ) == 'now()') {
- $q .= ( '`' ) . $key . '` = NOW(), ';
- continue;
- }
- if (preg_match( '/^increment\((\-?\d+)\)$/i', $val, $m )) {
- $q .= ( '`' ) . $key . '` = `' . $key . '` + ' . $m[1] . ', ';
- continue;
- }
- $q .= ( '`' ) . $key . '`=\'' . $this->escape( $val ) . '\', ';
- }
- $q = rtrim( $q, ', ' ) . ' WHERE ' . $where . ';';
- return $this->query( $q );
- }
- ................................................
- ...............................
- ............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement