从PHP5.6升级到7.4
我是新手。我正在从PHP5.6升级到7.6 在我的登录页面上,无法登录,出现以下错误: 不推荐使用:第49行的/home/domain/library/config.php中不推荐使用函数get\u magic\u quotes\u gpc() 下面是config.php文件的代码:从PHP5.6升级到7.4,php,upgrade,deprecation-warning,php-7.4,Php,Upgrade,Deprecation Warning,Php 7.4,我是新手。我正在从PHP5.6升级到7.6 在我的登录页面上,无法登录,出现以下错误: 不推荐使用:第49行的/home/domain/library/config.php中不推荐使用函数get\u magic\u quotes\u gpc() 下面是config.php文件的代码: <?php ini_set('display_errors', 'On'); //ob_start("ob_gzhandler"); error_reporting(E_ALL); // s
<?php
ini_set('display_errors', 'On');
//ob_start("ob_gzhandler");
error_reporting(E_ALL);
// start the session
session_start();
$sid = session_id();
// database connection config
$servername = 'xxx';
$username = 'xxx';
$password = 'xxx';
$dbName = 'xxx';
require_once 'database.php';
require_once 'common.php';
// get the shop configuration ( name, addres, etc ), all page need it
$getSiteConfig = getSiteConfig();
// setting up the web root and server root for
// this shopping cart application
$thisFile = str_replace('\\', '/', __FILE__);
$docRoot = $_SERVER['DOCUMENT_ROOT'];
$webRoot = str_replace(array($docRoot, 'library/config.php'), '', $thisFile);
$srvRoot = str_replace('library/config.php', '', $thisFile);
define('WEB_ROOT', $webRoot);
define('SRV_ROOT', $srvRoot);
define ( "REDIRECT_AFTER_CONFIRMATION", TRUE );
define ( "ADMIN_EMAIL", $getSiteConfig['siteemail'] );
define ( "DOMAIN_NAME", $getSiteConfig['sitename'] );
define ( "USE_SMTP", FALSE );
define ( "SMTP_PORT", "" );
define ( "SMTP_HOST", "" );
define ( "SMTP_USER", "" );
define ( "SMTP_PASS", "" );
define ( "MAIL_IS_HTML", TRUE );
/**
* website title.
*/
if (!get_magic_quotes_gpc()) {
if (isset($_POST)) {
foreach ($_POST as $key => $value) {
$_POST[$key] = trim(addslashes($value));
}
}
if (isset($_GET)) {
foreach ($_GET as $key => $value) {
$_GET[$key] = trim(addslashes($value));
}
}
}
removeInactiveUsers();
?>
早在PHP5.6之前,魔法引号就被认为是一个安全问题,它们最终被删除了
如果禁用了magic quotes设置,您共享的代码将有效地模拟magic quotes
因此,要使代码像以前一样工作,您所要做的就是删除if(!get\u magic\u quotes\u gpc())
,并确保此块中的代码始终运行
然而,由于它模拟了这个特性和相关的安全漏洞,所以很明显您的源代码有问题。您不应该依赖此功能,您应该检查所有处理数据库查询的代码,或者检查源代码中任何依赖字符串转义的代码,并逐一验证它们。不要依赖这些黑客的安全方法。欢迎使用StackOverflow!我猜标题中有个错误,PHP7.6不存在。您应该阅读PHP7.0发行说明,以了解PHP5和PHP7之间的所有更改。存在许多不兼容的更改。