新手在这里。我正在从PHP 5.6升级到7.6
在我的登录页面上,无法登录,出现以下错误:
已弃用:函数get_magic_quotes_gpc()在第49行的/home/domain/library/config.php中已弃用
这是config.php文件的代码:
<?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();
?>
当我删除不赞成使用的get_magic_quotes_gpc()并转到登录页面时,它只是空白。
答案 0 :(得分:5)
早在PHP 5.6之前,魔术引号就被认为是一个安全问题,最终将其删除。
您共享的代码有效地模拟了魔术引号如果魔术引号设置已关闭。
因此,要使您的代码像以前一样工作,您要做的就是删除if (!get_magic_quotes_gpc())
并确保此代码块中的代码始终运行。
但是,由于它使用相关的安全漏洞来模拟此功能,因此有很强的迹象表明您的来源有问题。您永远都不应依赖此功能,并且应该查看所有对数据库查询有任何作用的代码,或者实际上是源代码中所有依赖字符串转义的代码,并逐一进行验证。不要依赖这些骇人听闻的方法来实现安全性。