Fonsi-Heizer
Mitglied
Hallo zusammen,
wir verwenden in einer Wordpress Installation ein Child-Theme. In diesem befindet sich im Ordner /themes/betheme-child/lib/ eine Datei namens class.db.php mit folgendem Inhalt:
In der debug.log erhalten wir folgende Meldung:
Die Fehlermeldung deutet ja auf einen "veralteten" Aufbau der Class hin. Kann mir jemand helfen diesen Fehler zu beheben? Danke.
wir verwenden in einer Wordpress Installation ein Child-Theme. In diesem befindet sich im Ordner /themes/betheme-child/lib/ eine Datei namens class.db.php mit folgendem Inhalt:
PHP:
<?php
class db
{
var $__host, $__user, $__pass, $__db;
var $__link;
var $__paging;
var $__fields;
var $__debug=false;
var $__use_random=0;
public $__buffer = array();
var $__logselect_info=array();
var $__exist_db_loggingn=1; // if this value set to 0 not make LOG.
var $__make_log=0;
var $__make_expert_log=0;
var $__make_expert_log_obj;
public function db($host, $user, $pass, $database)
{
$this->__host = $host;
$this->__user = $user;
$this->__pass = $pass;
$this->__db = $database;
$this->__link = mysqli_connect($host, $user, $pass);
mysqli_select_db($this->__link,$database);
$this->PREFIX = '';
$this->MODULE_RIGHTS = $this->PREFIX.'module_rights';
$this->RIGHTS_LEVELS = $this->PREFIX.'module_rights_levels';
$this->MODULE_ACTION_RIGHTS = $this->PREFIX.'module_action_rights';
/* INIT TABLES */
$this->MODULE_ORDER = $this->PREFIX.'module_priority'; //module menu ordering and clicks
$this->SETTINGS = $this->PREFIX.'settings'; //settings
$this->HELPTEXT =$this->PREFIX.'helptext';
$this->LANG =$this->PREFIX.'lang';
$this->LANG_NAMES =$this->PREFIX.'lang_names';
$this->LANG_FRONTEND =$this->PREFIX.'lang_frontend';
//$this->GALLERY_SETTINGS =$this->PREFIX.'cms_settings';
$this->CUSTOM_ANREDE =$this->PREFIX.'custom_anrede';
$this->CUSTOM_TITLE =$this->PREFIX.'custom_title';
$this->EXT_PANEL_STATES =$this->PREFIX.'ext_panel_states';
$this->MEDIAPOOL_FILES =$this->PREFIX.'mediapool_files';
$this->MEDIAPOOL_FILES_MULTILANG=$this->PREFIX.'mediapool_files_multilang';
$this->MEDIAPOOL_FOLDERS =$this->PREFIX.'mediapool_folders';
}
public function getLink(){
$this->__link;
}
public function __wakeup()
{
$this->__link = mysqli_connect($this->__host, $this->__user, $this->__pass);
mysqli_select_db($this->__link,$this->__db);
}
public function set_debug($debug=false)
{
$this->__debug=$debug;
}
public function set_random($r=0)
{
$this->__use_random=$r;
}
public function delete($table, $conds, $limit = 1)
{
$Q = "DELETE FROM {$table} ".
"WHERE {$conds} ".
($limit?"LIMIT {$limit} ":'');
$this->raw($Q, false);
return mysqli_affected_rows($this->__link);
}
public function insert($table, $fields = null, $values = null, $delayed = false)
{
if ($fields == null)
$fields = array_keys($_POST);
if ($values == null)
$values = array_values($_POST);
if (is_array($fields))
$fields = implode(', ', $fields);
if (is_array($values))
{
//Alpar
if(get_magic_quotes_gpc() || ini_get('magic_quotes_sybase'))
{
foreach($values as &$values2)
{
$values2=str_replace('\r\n',chr(13).chr(10),$values2);
$values2=str_replace('\n',chr(13).chr(10),$values2);
}
$values=array_map('addslashes',$values);
//End Alpar
}
$values = "'".implode("', '", $values)."'";
}
else
{
if(get_magic_quotes_gpc() || ini_get('magic_quotes_sybase'))
{
//Alpar
$values=str_replace('\r\n',chr(13).chr(10),$values);
$values=str_replace('\n',chr(13).chr(10),$values);
$values=addslashes($values);
//End Alpar
}
}
$Q =
"INSERT ".($delayed?'DELAYED ':'')."INTO {$table} ({$fields}) ".
"VALUES ({$values}) ";
$this->raw($Q, false);
return mysqli_insert_id($this->__link);
}
public function decode($what = 'post',$variable_name='')
{
global $site_name_admin,$site_name,$db_variable_new_admin,$db_variable__decode_path, $db_host,$db_user,$db_pass,$db_dBase;
switch ($what)
{
case 'get':
$var = (get_magic_quotes_gpc()?array_map('stripslashes_deep',$_GET):$_GET);
break;
case 'post':
$var = (get_magic_quotes_gpc()?array_map('stripslashes_deep',$_POST):$_POST);
break;
case 'request':
$var = (get_magic_quotes_gpc()?array_map('stripslashes_deep',$_REQUEST):$_REQUEST);
break;
case 'cookie':
$var = (get_magic_quotes_gpc()?array_map('stripslashes_deep',$_COOKIE):$_COOKIE);
break;
case 'session':
if ($db_variable_new_admin==1){
include_once(BASE_PATH.'/config/dbconfig.inc.php');
if ($db_variable__decode_path==0){
$var = $_SESSION[$site_name_admin];
if ($variable_name=='db'){
}
}else{
$var = $_SESSION[$site_name];
}
}else{
$var = $_SESSION;
}
break;
}
$tmp_link = mysqli_connect($db_host, $db_user, $db_pass);
if ($variable_name!=''){
if (isset($var[$variable_name])){
return (is_object($var[$variable_name])?$var[$variable_name]:(is_array($var[$variable_name])?array_map('addslashes',$var[$variable_name]):
mysqli_real_escape_string($tmp_link, $var[$variable_name])));
}else{
return '';
}
}else{
foreach ($var as $k=>$v)
{
//var_pump($var);
$k=str_replace('-','_',$k);
if (!is_array($v))
{
eval("global \${$k}; \${$k} = addslashes( \$v );");
}
else
{
//array_map('stripslashes',$row)
eval("global \${$k}; \${$k} = array_map('addslashes',\$v);");
//eval("global \${$k}; \${$k} = \$v;");
}
}
}
}
public function raw($Q, $res = true)
{
$this->__Q = $Q;
//echo $Q."<br>";
$this->__res = mysqli_query($this->__link, $Q) or die($Q.' '.mysqli_error($this->__link));
if ($res==true)
{
if ($this->__fields!='')
{
$count=mysqli_num_fields($this->__res);
$this->__fields="";
$aux='';
for ($i=0;$i<$count;$i++)
{
//$aux = $aux . mysql_field_name($this->__res, $i) . "::";
$finfo = mysqli_fetch_field_direct($this->__res, $i);
$aux = $aux . $finfo->name . "::";
}
$this->__field_names=$aux;
}
}
return $res?$this->resArr():$res;
}
public function select($fields, $table, $conds = '', $limit = '', $order = '', $group = '', $having = '', $buffer = false)
{
//echo $order.' '.$limit.' '.$this->__last_limit."<br>";
if (strlen($order))
{
$order = ' '.$order;
}
if ($this->__use_random) {$order='RAND()';$limit=$this->__use_random;}
//echo 'Elotte:'.$limit.' '.$this->__last_limit[0]."<br>";
$this->__last_limit[0]=$limit;
//echo 'Utana:'.$limit.' Last:'.$this->__last_limit."<br>";
$Q = "SELECT {$fields} ".
"FROM {$table} ".
(strlen($conds)?"WHERE {$conds} ":'').
(strlen($group)?"GROUP BY {$group} ":'').
(strlen($having)?"HAVING {$having} ":'').
(strlen($order)?"ORDER BY {$order} ":'').
(strlen($limit)?"LIMIT {$limit} ":'');
if ($this->__debug) echo $Q;
$this->__fields=$fields;
if ($buffer)
{
if (!isset($this->__buffer[$Q]))
$this->__buffer[$Q] = $this->raw($Q);
$this->__arr = $this->__buffer[$Q];
return $this->__buffer[$Q];
}
return $this->raw($Q);
}
public function statistics($field, $table, $conds)
{
$res = db::select($field.", count(*) C", $table, $conds, 9999, '', $field);
$stat = array();
foreach ($res as $arr)
$stat[$arr[$field]] = $arr['C'];
return $stat;
}
public function statistics_2($field, $table, $conds,$group)
{
return $this->statistics($field, " ( SELECT ".$field.", count(*) C FROM ".$table.' WHERE '.$conds.' GROUP BY '.$group.' ) T', "");
}
public function getOne($field, $table, $conds = '')
{
$Q = "SELECT {$field} ".
"FROM {$table} ".
(strlen($conds)?"WHERE {$conds} ":'').' LIMIT 1';
$res = $this->raw($Q);
//echo $Q;
if (!count($res))
return '';
//Alpar
/*if(get_magic_quotes_gpc() || ini_get('magic_quotes_sybase')){
$res[0]=array_map('stripslashes',$res[0]);
}*/
return array_pop($res[0]);
//return array_pop($res[0]);
}
public function insertId($table, $field, $val, $indexField = '')
{
if ($indexField == '')
$indexField = $this->getIndexField($table);
$c = $this->getOne($indexField, $table, "`{$field}` = '{$val}'");
if ($c !== false)
return $c;
else
{
return $this->insert($table, $field, array($val));
}
}
public function getIndexField($table)
{
if (!isset($this->__primary[$table]))
{
$res = $this->raw("SHOW INDEX FROM {$table}");
foreach ($res as $f)
{
if ($f['Key_name'] == 'PRIMARY')
{
$this->__primary[$table] = $f['Column_name'];
break 1;
}
}
if (!isset($this->__primary[$table]))
$this->__primary[$table] = '0';
}
return $this->__primary[$table];
}
public function update($fields, $vals, $table, $conds)
{
if (!is_array($fields))
$fields = array_map('trim', explode(',', $fields));
if($this->__exist_db_loggingn==1 && ($this->__make_log==1 || $this->__make_expert_log==1)){
$this->__logselect_info['old']=$this->select(implode(',',$fields),$table, $conds);
$this->__logselect_info['new']=array();
foreach($fields as $ii => $f_value){
$this->__logselect_info['new'][$f_value]=$vals[$ii];
}
}
if (!is_array($vals))
$vals = array($vals); //this is bad
if (get_magic_quotes_gpc() || ini_get('magic_quotes_sybase'))
{
$vals=str_replace('\r\n',chr(13).chr(10),$vals);
$vals=str_replace('\n',chr(13).chr(10),$vals);
$vals = array_map('addslashes',$vals);
}
//$vals = array_map('mysql_real_escape_string', array_map('stripslashes', $vals));
$Q = "UPDATE `{$table}` SET ";
foreach ($fields as $k=>$f)
$fields[$k] = "`{$f}` = '".$vals[$k]."'";
$Q .= implode(', ', $fields)." WHERE {$conds}";
$this->raw($Q, false);
mysqli_affected_rows($this->__link);
$saveaffected_rows=mysqli_affected_rows($this->__link);
if($this->__make_expert_log==1){
$this->__make_expert_log_obj->add2LogFieldsUpdate($this->__logselect_info);
$this->clearLog();
}
return $saveaffected_rows;
}
public function isTable($tbl)
{
//var_pump($this->raw('SHOW TABLES'));
//var_pump(db::shallow($this->raw("SHOW TABLES like '".$tbl."'")));
//echo ' '.in_array($tbl, db::shallow($this->raw("SHOW TABLES like '".$tbl."'")))."<br>";
return in_array($tbl, db::shallow($this->raw("SHOW TABLES like '".$tbl."'")));
//list($result)=$this->raw('check table '.$tbl);
//return ($result['Msg_text']!='OK'?0:1);
}
function resArr() {
if (isset($this->__res))
{
$this->__arr = array();
while ($row = mysqli_fetch_assoc($this->__res))
{
if(get_magic_quotes_gpc() || ini_get('magic_quotes_sybase'))
{
//$this->__arr[] = ($row);
//$row = array_map('stripslashes_deep',$row);
//(preg_replace('/\r\n/','\n',addslashes($res[0]['article_title'])))
//$this->__arr[] = array_map('preg_replace',array('/\r\n/'),array('\n'),$row);
$row=array_map('stripslashes',$row);
/*
foreach($row as &$row2){
$row2=preg_replace('/\r\n/','\n',($row2));
}*/
}
$this->__arr[] = $row;
}
return $this->__arr;
}
return false;
}
function shallow($arr)
{
$arr2 = array();
foreach ($arr as $v)
$arr2[] = array_pop($v);
return $arr2;
}
function slallow($arr)
{
$arr2 = array();
foreach ($arr as $v)
$arr2[] = array_shift($v);
return $arr2;
}
function numRows()
{
if (isset($this->__res))
return mysqli_num_rows($this->__res);
return false;
}
public function truncate($table)
{
mysqli_query($this->__link,'TRUNCATE TABLE `'.$table.'`');
}
public function optimize($table)
{
mysqli_query($this->__link,'OPTIMIZE TABLE `'.$table.'`');
}
public function dispose()
{
mysqli_close($this->__link);
}
public function getEmptyArrayOfFields()
{
$ret=explode("::",$this->__field_names);
$arr=array();
foreach ($ret as $r) if ($r!="") $arr[$r]="";
return $arr;
}
public function makeLog($make=1){
$this->__make_log=$make;
$this->__make_expert_log=0;
}
public function makeExpertLog($obj_log){
$this->__make_expert_log=1;
$this->__make_log=0;
$this->__make_expert_log_obj=$obj_log;
}
public function clearLog(){
$this->__make_expert_log=0;
$this->__make_log=0;
}
public function returnLogBeforeAfterUpdate($make=0){
$this->__make_log=$make;
return $this->__logselect_info;
}
public function executeDumpFile($filepath)
{
if (is_file($filepath))
{
$command="mysql --user=".$this->__user." --password=".$this->__pass." --host=".$this->__host." ".$this->__db." < ".$filepath; //echo $command;
exec($command);
}
}
}
if (!function_exists('var_pump')) {
function var_pump($arr, $w = 0)
{
echo "<pre>";
if ($w == 1)
var_dump($arr);
else if ($w == 2)
var_export($arr);
else
print_r($arr);
echo "</pre>";
}
}
?>
In der debug.log erhalten wir folgende Meldung:
Code:
PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; db has a deprecated constructor in /var/www/vhosts/xxx.com/xxx/wp-content/themes/betheme-child/lib/class.db.php on line 3
Die Fehlermeldung deutet ja auf einen "veralteten" Aufbau der Class hin. Kann mir jemand helfen diesen Fehler zu beheben? Danke.