ÿØÿà JFIF ÿÛ „ ( %"1"%)+...383,7(-.-
![]() Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20 System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64 User : apache ( 48) PHP Version : 7.4.20 Disable Function : NONE Directory : /var/www/html/thietkewebvumi.com/lib/ |
<?php class db_driver { var $obj = array ( "sql_database" => "", "sql_user" => "", "sql_pass" => "", "sql_host" => "", "sql_port" => "", "sql_tbl_prefix" => "", 'debug' => 0 ); var $query_id = ""; var $connection_id = ""; var $record_row = array(); var $return_die = 0; var $error = ""; var $mysql_version = ""; var $failed = 0; // Connect to the database /*========================================================================*/ function connect() { global $INFO,$CORE; $this->obj['sql_database'] = $INFO['sql_database']; $this->obj['sql_user'] = $INFO['sql_user']; $this->obj['sql_pass'] = $INFO['sql_pass']; $this->obj['sql_host'] = $INFO['sql_host']; $this->obj['sql_tbl_prefix'] = $INFO['sql_tbl_prefix']; $this->connection_id = mysqli_connect($this->obj['sql_host'] ,$this->obj['sql_user'] ,$this->obj['sql_pass'], $this->obj['sql_database']); if (mysqli_connect_errno()) { echo "Failed to connect to Database: " . mysqli_connect_error(); exit(); } mysqli_set_charset($this->connection_id,"utf8mb4"); //setting website $ret = $this->compile_query("conf_key,conf_value","NNCCMS_settings",'',''); while ($row_info = $this->fetch_row($ret)) { $CORE->vars[$row_info['conf_key']] = $row_info['conf_value']; } } // Process a query /*========================================================================*/ function query($the_query) { if ($this->obj['sql_tbl_prefix'] != "NNCCMS_"){ $the_query = preg_replace("/NNCCMS_(\S+?)([\s\.,]|$)/", $this->obj['sql_tbl_prefix']."\\1\\2", $the_query); } $this->query_id = mysqli_query($this->connection_id,$the_query); if (!$this->query_id) { echo("Error description: " . mysqli_error($this->connection_id)); exit(); } return $this->query_id; } // Fetch a row based on the last query /*========================================================================*/ function fetch_row($query_id = "") { if ($query_id == ""){ $query_id = $this->query_id; } $this->record_row = mysqli_fetch_array($query_id, MYSQLI_ASSOC); return $this->record_row; } /*========================================================================*/ function get_num_rows() { $res = mysqli_num_rows($this->query_id); if($res>0){ return $res; }else{ return 0; } } function insert($table,$insData){ $columns = implode(", ",array_keys($insData)); $values = implode(", ",array_values($insData)); $this->query_id = mysqli_query("INSERT INTO $table ($columns) VALUES ($values);"); if (!$this->query_id) { echo("Error description: " . mysqli_error($this->connection_id)); exit(); } return $this->insert_id(); } function update($table, $id, $fields) { $set = ''; $x = 1; foreach($fields as $name => $value) { $set .= "{$name} = \"{$value}\""; if($x < count($fields)) { $set .= ','; } $x++; } $sql = "UPDATE {$table} SET {$set} WHERE id = {$id}"; $this->query_id = mysqli_query($sql); if (!$this->query_id) { echo("Error description: " . mysqli_error($this->connection_id)); exit(); } return $id; } function insert_id(){ return mysqli_insert_id($this->connection_id); } function get_colum_tb($table){ $arr = array(); $q_colum = $this->query("SHOW COLUMNS FROM ".$table); while ($r_colum = $this->fetch_row($q_colum)){ $arr[$r_colum['Field']] = ''; } return $arr; } function compile_query($field_name,$table_name,$condition="",$order_by=""){ if ($order_by !=""){ $ret=$this->query("Select $field_name From $table_name $condition Order By $order_by"); }else{ $ret=$this->query("Select $field_name From $table_name $condition"); } return $ret; } function get_version(){ return mysqli_get_server_info($this->connection_id); } function free_result() { if($this->query_id and is_object($this->query_id)) { mysqli_free_result($this->query_id); } } function close_db() { return mysqli_close($this->connection_id); } } ?>