前一个问题:get_magic_quotes_gpc() returns undefined in my code
那么..。
我解决了以下问题:
Fatal error: Cannot declare class CI_Log, because the name is already in use in D:\xampp\htdocs\system\libraries\Log.php on line 27 (line 27) class CI_Log {
以这种方式:
/**
* Error Logging Interface
*
* We use this as a simple mechanism to access the logging
* class and send messages to be logged.
*
* @access public
* @return void
*/
if ( ! function_exists('log_message'))
{
function log_message($level = 'error', $message, $php_error = FALSE)
{
static $_log;
if (config_item('log_threshold') == 1)
{
return;
}
$_log =& load_class('Log');
$_log->write_log($level, $message, $php_error);
}
}
我改变了
"if (config_item ('log_threshold') == 0)"
至
"if (config_item ('log_threshold') == 1)"
在Common.php文件中
在……里面
D:\xampp\htdocs\system\core\Common.php
但现在出现了新的错误..。
Fatal error: Uncaught TypeError: filter_var(): Argument #3 ($options) must be of type array|int, string given in
D:\xampp\htdocs\system\core\Input.php:391
Stack trace:
_______________________________________________________________________________
#0 D:\xampp\htdocs\system\core\Input.php(391): filter_var('127.0.0.1', 275, '')
// First check if filter_var is available
if (is_callable('filter_var'))
{
switch ($which) {
case 'ipv4':
$flag = FILTER_FLAG_IPV4;
break;
case 'ipv6':
$flag = FILTER_FLAG_IPV6;
break;
default:
$flag = '';
break;
}
return (bool) filter_var($ip, FILTER_VALIDATE_IP, $flag);
}
_______________________________________________________________________________
#1 D:\xampp\htdocs\system\core\Input.php(354): CI_Input->valid_ip('127.0.0.1')
if ( ! $this->valid_ip($this->ip_address))
_______________________________________________________________________________
#2 D:\xampp\htdocs\application\models\cms_model.php(32): CI_Input->ip_address()
if(!$this->input->is_ajax_request() && !isset($_GET['is_json_ajax']))
{
$this->db->query("INSERT INTO visitor_log(`date`, `ip`) VALUES(?, ?)", array(date("Y-m-d"), $this->input->ip_address()));
}
_______________________________________________________________________________
#3 D:\xampp\htdocs\application\models\cms_model.php(24): Cms_model->logVisit()
$this->logVisit();
_______________________________________________________________________________
#4 D:\xampp\htdocs\system\core\Loader.php(303): Cms_model->__construct()
$CI->$name = new $model();
_______________________________________________________________________________
#5 D:\xampp\htdocs\application\third_party\MX\Loader.php(192): CI_Loader->model('Cms_model', 'cms_model', false)
/* check application & packages */
parent::model($model, $object_name, $connect);
_______________________________________________________________________________
#6 D:\xampp\htdocs\application\libraries\realms.php(42): MX_Loader->model('cms_model')
// Get the realms
$this->CI->load->model('cms_model');
_______________________________________________________________________________
#7 D:\xampp\htdocs\system\core\Loader.php(1099): Realms->__construct()
{
$CI->$classvar = new $name;
}
_______________________________________________________________________________
#8 D:\xampp\htdocs\system\core\Loader.php(975): CI_Loader->_ci_init_class('realms', '', NULL, NULL)
return $this->_ci_init_class($class, '', $params, $object_name);
_______________________________________________________________________________
#9 D:\xampp\htdocs\application\third_party\MX\Loader.php(155): CI_Loader->_ci_load_class('Realms', NULL, NULL)
$this->_ci_load_class($library, $params, $object_name);
_______________________________________________________________________________
#10 D:\xampp\htdocs\system\core\Loader.php(1178): MX_Loader->library('realms')
{
$this->library($item);
}
_______________________________________________________________________________
#11 D:\xampp\htdocs\system\core\Loader.php(152): CI_Loader->_ci_autoloader()
/**
* Initialize the Loader
*
* This method is called once in CI_Controller.
*
* @param array
* @return object
*/
public function initialize()
{
$this->_ci_classes = array();
$this->_ci_loaded_files = array();
$this->_ci_models = array();
$this->_base_classes =& is_loaded();
$this->_ci_autoloader();
return $this;
}
_______________________________________________________________________________
#12 D:\xampp\htdocs\application\third_party\MX\Loader.php(59): CI_Loader->initialize()
/** Initialize the loader variables **/
public function initialize($controller = NULL) {
if (is_a($controller, 'MX_Controller')) {
/* reference to the module controller */
$this->controller = $controller;
/* references to ci loader variables */
foreach (get_class_vars('CI_Loader') as $var => $val) {
if ($var != '_ci_ob_level') {
$this->$var =& CI::$APP->load->$var;
}
}
} else {
parent::initialize();
}
_______________________________________________________________________________
#13 D:\xampp\htdocs\system\core\Controller.php(51): MX_Loader->initialize()
public function __construct()
{
self::$instance =& $this;
// Assign all the class objects that were instantiated by the
// bootstrap file (CodeIgniter.php) to local class variables
// so that CI can run as one big super object.
foreach (is_loaded() as $var => $class)
{
$this->$var =& load_class($class);
}
$this->load =& load_class('Loader', 'core');
$this->load->initialize();
log_message('debug', "Controller Class Initialized");
}
_______________________________________________________________________________
#14 D:\xampp\htdocs\application\third_party\MX\Base.php(55): CI_Controller->__construct()
class CI extends CI_Controller
{
public static $APP;
public function __construct() {
/* assign the application instance */
self::$APP = $this;
global $LANG, $CFG;
/* re-assign language and config for modules */
if ( ! is_a($LANG, 'MX_Lang')) $LANG = new MX_Lang;
if ( ! is_a($CFG, 'MX_Config')) $CFG = new MX_Config;
parent::__construct();
}
}
_______________________________________________________________________________
#15 D:\xampp\htdocs\application\third_party\MX\Base.php(60): CI->__construct()
/* create the application object */
new CI;
_______________________________________________________________________________
#16 D:\xampp\htdocs\application\third_party\MX\Controller.php(4): require('D:\\xampp\\htdocs...')
/** load the CI class for Modular Extensions **/
require dirname(__FILE__).'/Base.php';
_______________________________________________________________________________
#17 D:\xampp\htdocs\application\third_party\MX\Modules.php(119): include_once('D:\\xampp\\htdocs...')
/* autoload Modular Extensions MX core classes */
if (strstr($class, 'MX_') AND is_file($location = dirname(__FILE__).'/'.substr($class, 3).EXT)) {
include_once $location;
return;
}
_______________________________________________________________________________
#18 D:\xampp\htdocs\application\modules\news\controllers\news.php(3): Modules::autoload('MX_Controller')
class News extends MX_Controller
_______________________________________________________________________________
#19 D:\xampp\htdocs\system\core\CodeIgniter.php(249): include('D:\\xampp\\htdocs...')
include(APPPATH.'controllers/'.$RTR->directory.$RTR->class.'.php');
_______________________________________________________________________________
#20 D:\xampp\htdocs\index.php(228): require_once('D:\\xampp\\htdocs...')
require_once BASEPATH.'core/CodeIgniter.php';
_______________________________________________________________________________
#21 {main} thrown in D:\xampp\htdocs\system\core\Input.php on line 391
我不是一个有经验的程序员,我是个新手。
我用直觉修正了一些东西,因为直觉是我的主要技能,但是直觉可以帮助我达到某种程度,我需要那些比我了解得更多的人的经验和知识,不仅是为了解决这个问题,也是为了提高我自己,如果有人能帮助我走出这个洪流来恢复我的网站,我将非常感激。
发布于 2021-01-15 19:02:23
将开关语句的默认部分更改为以下部分应解决此问题:
switch ($which) {
case 'ipv4':
$flag = FILTER_FLAG_IPV4;
break;
case 'ipv6':
$flag = FILTER_FLAG_IPV6;
break;
default:
$flag = FILTER_DEFAULT;
break;
}
似乎它一定是旧版本的CodeIgniter中的一个bug。在开关语句的“默认”情况下,它将一个空字符串作为第三个参数传递给filter_var
,但它必须接收一个array
或int
。
它可能只是开始对PHP8造成致命错误,因为8引入了对混合类型的类型提示:https://www.php.net/manual/en/language.types.declarations.php
混合类型等价于联合类型数组\可调用的\{e76f}\可从PHP 8.0.0获得。
您可以使用以下工具查看不同版本的PHP所发生的情况:https://3v4l.org/Sd6oS
编辑-,它可能不会修复所有的错误,但最好先克服这个错误,看看剩下的是什么。
https://stackoverflow.com/questions/65643612
复制