20201112解決php new PHP Parse error: $class =& new $className()

出自金門農工維基III
跳至導覽 跳至搜尋

REF

/var/log/php-fpm/www-error.log

(1) # cat /var/log/php-fpm/www-error.log
:
[12-Nov-2020 07:38:58 UTC] PHP Parse error:  syntax error, unexpected 'new' (T_N                             EW) in /var/www/html/lf/class/database/pdb/drivers/pdbdriverbase.class.php on li                             ne 235
:
[12-Nov-2020 07:49:44 UTC] PHP Warning:  Declaration of PDbMySQLDriver::getDriverDataDictionary() should be compatible with & PDbDriverBase::getDriverDataDictionary($driverName) in /var/www/html/lf/class/database/pdb/drivers/pdbmysqldriver.class.php on line 155
[12-Nov-2020 07:49:44 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_pconnect() in /var/www/html/lf/class/database/pdb/drivers/pdbmysqldriver.class.php:103

[root@localhost ~]# cat /var/log/php-fpm/www-error.log
:
  thrown in /var/www/html/lf/class/database/pdb/drivers/pdbmysqldriver.class.php on line 103
[12-Nov-2020 08:02:45 UTC] PHP Parse error:  syntax error, unexpected '=' in /var/www/html/lf/class/database/pdb/drivers/pdbdriverbase.class.php on line 238
[12-Nov-2020 08:04:17 UTC] PHP Parse error:  syntax error, unexpected '=' in /var/www/html/lf/class/database/pdb/drivers/pdbdriverbase.class.php on line 238
[12-Nov-2020 08:04:19 UTC] PHP Parse error:  syntax error, unexpected '=' in /var/www/html/lf/class/database/pdb/drivers/pdbdriverbase.class.php on line 238
[12-Nov-2020 08:06:57 UTC] PHP Parse error:  syntax error, unexpected '=' in /var/www/html/lf/class/database/pdb/drivers/pdbdriverbase.class.php on line 238

[13-Nov-2020 03:44:11 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_query() in /var/www/html/lf/class/database/pdb/drivers/pdbmysqldriver.class.php:111

[13-Nov-2020 05:33:27 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_select_db() in /var/www/html/lf/class/database/pdb/drivers/pdbmysqldriver.class.php:117

[13-Nov-2020 05:39:57 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_select_db() in /var/www/html/lf/class/database/pdb/drivers/pdbmysqldriver.class.php:52

[13-Nov-2020 05:43:05 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_query() in /var/www/html/lf/class/database/pdb/drivers/pdbmysqldriver.class.php:57

[13-Nov-2020 05:47:06 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_fetch_assoc() in /var/www/html/lf/class/database/pdb/drivers/pdbmysqlrecordset.class.php:28

[13-Nov-2020 05:52:42 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_free_result() in /var/www/html/lf/class/database/pdb/drivers/pdbmysqlrecordset.class.php:44

[13-Nov-2020 05:55:44 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function set_magic_quotes_runtime() in /var/www/html/lf/class/cache/Cache_Lite/Lite.php:717

[15-Nov-2020 00:11:35 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function set_magic_quotes_runtime() in /var/www/html/lf/class/cache/Cache_Lite/Lite.php:727

[15-Nov-2020 00:14:52 UTC] PHP Parse error:  syntax error, unexpected 'new' (T_NEW) in /var/www/html/lf/class/plugin/pluginmanager.class.php on line 248

[15-Nov-2020 00:19:21 UTC] PHP Warning:  Declaration of PDbMySQLDriver::getDriverDataDictionary() should be compatible with & PDbDriverBase::getDriverDataDictionary($driverName) in /var/www/html/lf/class/database/pdb/drivers/pdbmysqldriver.class.php on line 157
[15-Nov-2020 00:19:21 UTC] PHP Warning:  Declaration of PatternLayout::format(&$message) should be compatible with & Layout::format(&$message) in /var/www/html/lf/class/logger/layout/patternlayout.class.php on line 119
[15-Nov-2020 00:19:21 UTC] PHP Warning:  Declaration of UserStatus::getStatusList($includeStatusAll = false) should be compatible with GenericStatusList::getStatusList($prefix, $statusAllId, $includeStatusAll = false) in /var/www/html/lf/class/dao/userstatus.class.php on line 27
[15-Nov-2020 08:19:21 Asia/Taipei] PHP Notice:  Only variables should be passed by reference in /var/www/html/lf/class/data/validator/integervalidator.class.php on line 30
[15-Nov-2020 08:19:21 Asia/Taipei] PHP Fatal error:  Uncaught Error: Call to undefined function eregi() in /var/www/html/lf/class/data/validator/rules/regexprule.class.php:82

[15-Nov-2020 12:21:38 Asia/Taipei] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_num_rows() in /var/www/html/lf/class/database/pdb/drivers/pdbmysqlrecordset.class.php:36

[15-Nov-2020 12:26:34 Asia/Taipei] PHP Notice:  Only variables should be passed by reference in /var/www/html/lf/class/data/validator/usernamevalidator.class.php on line 38
[15-Nov-2020 12:26:34 Asia/Taipei] PHP Warning:  Declaration of Template::display() should be compatible with Smarty::display($resource_name, $cache_id = NULL, $compile_id = NULL) in /var/www/html/lf/class/template/template.class.php on line 226
[15-Nov-2020 12:26:34 Asia/Taipei] PHP Warning:  Declaration of Template::fetch() should be compatible with Smarty::fetch($resource_name, $cache_id = NULL, $compile_id = NULL, $display = false) in /var/www/html/lf/class/template/template.class.php on line 215
[15-Nov-2020 12:26:34 Asia/Taipei] PHP Notice:  Only variables should be passed by reference in /var/www/html/lf/class/data/validator/integervalidator.class.php on line 30
[15-Nov-2020 12:26:34 Asia/Taipei] PHP Warning:  preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/html/lf/class/data/inputfilter.class.php on line 267
[15-Nov-2020 12:26:34 Asia/Taipei] PHP Warning:  preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/html/lf/class/data/inputfilter.class.php on line 269
[15-Nov-2020 12:26:34 Asia/Taipei] PHP Warning:  Declaration of CachedTemplate::fetch($cacheId) should be compatible with Template::fetch() in /var/www/html/lf/class/template/cachedtemplate.class.php on line 41
[15-Nov-2020 12:26:34 Asia/Taipei] PHP Warning:  Declaration of CachedTemplate::display($cacheId) should be compatible with Template::display() in /var/www/html/lf/class/template/cachedtemplate.class.php on line 75

[18-Nov-2020 11:12:37 Asia/Taipei] PHP Notice:  Only variables should be passed by reference in /var/www/html/lf/class/data/validator/domainvalidator.class.php on line 31
[18-Nov-2020 11:12:37 Asia/Taipei] PHP Warning:  Declaration of BlogStatus::getStatusList($includeStatusAll = false) should be compatible with GenericStatusList::getStatusList($prefix, $statusAllId, $includeStatusAll = false) in /var/www/html/lf/class/dao/blogstatus.class.php on line 27
[18-Nov-2020 11:12:37 Asia/Taipei] PHP Parse error:  syntax error, unexpected '$source' (T_VARIABLE) in /var/www/html/lf/class/data/inputfilter.class.php on line 270


[18-Nov-2020 03:22:54 UTC] PHP Warning:  Declaration of PDbMySQLDriver::getDriverDataDictionary() should be compatible with & PDbDriverBase::getDriverDataDictionary($driverName) in /var/www/html/lf/class/database/pdb/drivers/pdbmysqldriver.class.php on line 157
[18-Nov-2020 03:22:54 UTC] PHP Warning:  Declaration of PatternLayout::format(&$message) should be compatible with & Layout::format(&$message) in /var/www/html/lf/class/logger/layout/patternlayout.class.php on line 119
[18-Nov-2020 03:22:54 UTC] PHP Warning:  Declaration of UserStatus::getStatusList($includeStatusAll = false) should be compatible with GenericStatusList::getStatusList($prefix, $statusAllId, $includeStatusAll = false) in /var/www/html/lf/class/dao/userstatus.class.php on line 27
[18-Nov-2020 11:22:54 Asia/Taipei] PHP Notice:  Only variables should be passed by reference in /var/www/html/lf/class/data/validator/integervalidator.class.php on line 30
[18-Nov-2020 11:22:54 Asia/Taipei] PHP Notice:  Only variables should be passed by reference in /var/www/html/lf/class/data/validator/integervalidator.class.php on line 30
[18-Nov-2020 11:22:54 Asia/Taipei] PHP Notice:  Only variables should be passed by reference in /var/www/html/lf/class/data/validator/blognamevalidator.class.php on line 27
[18-Nov-2020 11:22:54 Asia/Taipei] PHP Notice:  Only variables should be passed by reference in /var/www/html/lf/class/data/validator/blognamevalidator.class.php on line 28
[18-Nov-2020 11:22:54 Asia/Taipei] PHP Notice:  Only variables should be passed by reference in /var/www/html/lf/class/data/validator/blognamevalidator.class.php on line 34
[18-Nov-2020 11:22:54 Asia/Taipei] PHP Notice:  Only variables should be passed by reference in /var/www/html/lf/class/data/validator/usernamevalidator.class.php on line 32
[18-Nov-2020 11:22:54 Asia/Taipei] PHP Notice:  Only variables should be passed by reference in /var/www/html/lf/class/data/validator/usernamevalidator.class.php on line 33
[18-Nov-2020 11:22:54 Asia/Taipei] PHP Notice:  Only variables should be passed by reference in /var/www/html/lf/class/data/validator/usernamevalidator.class.php on line 34
[18-Nov-2020 11:22:54 Asia/Taipei] PHP Notice:  Only variables should be passed by reference in /var/www/html/lf/class/data/validator/usernamevalidator.class.php on line 38
[18-Nov-2020 11:22:54 Asia/Taipei] PHP Notice:  Only variables should be passed by reference in /var/www/html/lf/class/data/validator/domainvalidator.class.php on line 26
[18-Nov-2020 11:22:54 Asia/Taipei] PHP Notice:  Only variables should be passed by reference in /var/www/html/lf/class/data/validator/domainvalidator.class.php on line 27
[18-Nov-2020 11:22:54 Asia/Taipei] PHP Notice:  Only variables should be passed by reference in /var/www/html/lf/class/data/validator/domainvalidator.class.php on line 31
[18-Nov-2020 11:22:54 Asia/Taipei] PHP Warning:  Declaration of BlogStatus::getStatusList($includeStatusAll = false) should be compatible with GenericStatusList::getStatusList($prefix, $statusAllId, $includeStatusAll = false) in /var/www/html/lf/class/dao/blogstatus.class.php on line 27
[18-Nov-2020 11:22:54 Asia/Taipei] PHP Notice:  Only variables should be passed by reference in /var/www/html/lf/class/data/validator/integervalidator.class.php on line 30
[18-Nov-2020 11:22:54 Asia/Taipei] PHP Notice:  Only variables should be passed by reference in /var/www/html/lf/class/data/validator/httpurlvalidator.class.php on line 17
[18-Nov-2020 11:22:54 Asia/Taipei] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_affected_rows() in /var/www/html/lf/class/database/pdb/drivers/pdbmysqldriver.class.php:151

(2)# date -u
Thu 12 Nov 2020 07:51:27 AM UTC

修改PHP -CODE

(3) 將第235行的 =& 改為  =
# vi  /var/www/html/lf/class/database/pdb/drivers/pdbdriverbase.class.php

            $class = new $className(); //$class =& new $className();

(4) # vi /var/www/html/lf/class/database/pdb/drivers/pdbmysqldriver.class.php
:
     mysqli_select_db($this->_res, $this->_dbname); 
     //line 52: mysql_select_db( $this->_dbname, $this->_res );

     $result = mysqli_query($this->_res,$query);  
     //57: $result = mysql_query( $query, $this->_res );
    

      // $this->_res = mysql_pconnect( $host, $username, $password );                 //103
      $this->_res = mysqli_connect( $host, $username, $password, $dbname  );                  //103

      return( mysqli_select_db( $this->_res,$dbname )); 
      //line 117 return( mysql_select_db( $dbname, $this->_res ));


:
 mysqli_query( $this->_res, "SET NAMES ".$dbcharset);        
// line 111 mysql_query( "SET NAMES ".$dbcharset, $this->_res );


        function getDriverDataDictionary()  //line 155
        {
            return( PDbDriverBase::getDriverDataDictionary( 'mysql' ));
        }
:

 return( mysql_select_db( $dbname, $this->_res ));


(5) # vi /var/www/html/lf/class/database/pdb/drivers/pdbmysqlrecordset.class.php
[root@localhost ~]#
:
     return( mysqli_fetch_array( $this->_dbRes,MYSQLI_ASSOC )); 
     // line 28 return( mysql_fetch_assoc( $this->_dbRes ));
                  return( mysql_free_result( $this->_dbRes ));

              return( mysqli_free_result( $this->_dbRes )); 
              //line 44 return( mysql_free_result( $this->_dbRes ));

(6) # vi /var/www/html/lf/class/cache/Cache_Lite/Lite.php:717
:
ini_set("magic_quotes_runtime", 0);  // line 717 : magic_quotes_runtime()

ini_set("magic_quotes_runtime", $mqr); // line 727: set_magic_quotes_runtime($mqr);


(7)# vi /var/www/html/lf/class/plugin/pluginmanager.class.php
:
$classInstance = new $className( $this->_source ); //line :248 $classInstance =& new $className( $this->_source ); //line :248

(8)# vi /var/www/html/lf/class/data/validator/integervalidator.class.php
:
 $this->addRule( new UIntRule());  //line :30

(9) vi  /var/www/html/lf/class/data/validator/rules/regexprule.class.php
:
            // else if (!$this->_caseSensitive && eregi($this->_regExp, $value)) //line:82 preg_match('/ab/i',$value);
            else if (!$this->_caseSensitive && preg_match('/'. $this->_regExp .'/i',$value) ) //line:82

(10) # vi /var/www/html/lf/class/database/pdb/drivers/pdbmysqlrecordset.class.php
:
 return( mysqli_num_rows( $this->_dbRes ));
//line:36 return( mysql_num_rows( $this->_dbRes ));

(11) # vi /var/www/html/lf/class/data/inputfilter.class.php
:
:
//              $source = html_entity_decode($source, ENT_QUOTES, "ISO-8859-1");
// convert decimal :    $source = preg_replace('/&#(\d+);/me',"chr(\\1)", $source); // line 267: decimal notation
$source = preg_replace_callback('/&#(\d+);/m', function ($m) { return chr($m[1]);}, $source);
// convert hex:         $source = preg_replace('/&#x([a-f0-9]+);/mei',"chr(0x\\1)", $source);   //line 269: hex notation
$source = preg_replace_callback('/&#x([a-f0-9]+);/mi', function ($m) { return chr(hexdec('0x'.$m[1])); }, $source);
:

<?php
$url= "123";
echo "t0:url=$url<br>\n";
// convert decimal :
// $source = preg_replace('/&#(\d+);/me',"chr(\\1)", $source); // line 267: decimal notation
$urlb = preg_replace_callback('/&#(\d+);/m', function ($m) { return strtoupper(chr($m[1]));}, $url);
echo "t1:urlb=$urlb<br>\n";

$url= "0xabcf09";
echo "t2:url=$url<br>\n";
// convert hex:
// $source = preg_replace('/&#x([a-f0-9]+);/mei',"chr(0x\\1)", $source);   //line 269: hex notation
$urlc = preg_replace_callback('/&#x([a-f0-9]+);/mi', function ($m) { return strtoupper(chr(hexdec('0x'.$m[1]))); }, $url);
echo "t3:urlc=$urlc<br>\n";
$input = "Bet you want a BMW.";
echo preg_replace_callback(
    "/([a-z]*)/",
    function($matches){
        foreach($matches as $match){
            return strtoupper($match);
        }
    },
    $input
);


?>