【问题标题】:Upgrading from PHP 5.6 to 7.4 [duplicate]从 PHP 5.6 升级到 7.4 [重复]
【发布时间】:2020-01-18 17:17:19
【问题描述】:

这里是新手。我正在从 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() 并转到登录页面时,它只是空白。

【问题讨论】:

  • 欢迎使用 StackOverflow!我猜标题有错误,PHP 7.6 不存在。
  • 您应该阅读 PHP 7.0 发行说明以了解 PHP 5 和 PHP 7 之间的所有更改。有许多不兼容的更改。

标签: php upgrade deprecation-warning php-7.4


【解决方案1】:

在 PHP 5.6 之前,魔术引号被认为是一个安全问题,最终被删除。

您共享的代码有效地模拟了魔术引号如果魔术引号设置已关闭。

因此,要使您的代码像以前一样工作,您所要做的就是删除 if (!get_magic_quotes_gpc()) 并确保此块中的代码始终运行。

但是,由于它使用相关的安全漏洞来模拟此功能,因此强烈表明您的来源存在问题。您永远不应该依赖此功能,您应该查看所有与数据库查询相关的代码,或者实际上是您的源代码中依赖字符串转义的所有代码,并一一验证它们。不要依赖这些骇人听闻的安全方法。

【讨论】:

    猜你喜欢
    • 2021-10-12
    • 2021-09-29
    • 2021-06-08
    • 1970-01-01
    • 2015-05-30
    • 2021-01-29
    • 2019-03-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多