带有 include 的 PHP 安全性

问题描述 投票:0回答:1

你说这有多安全?

$pages = array("about", "help", "login");
$pagesWithId = array("shownews", "showuser", "showfile");

if (in_array($_GET['page'], $pages)) {
    include('includes/'.$_GET['page'].'.php');
    include('templates/'.$_GET['page'].'.html');
}

foreach ($pagesWithId as $page) {
    if (ctype_digit($_GET[$page])) {
        include('includes/'.$page.'.php');
        include('templates/'.$page.'.html');
    }
}

你看到任何潜在的威胁吗?

php security
1个回答
3
投票

很安全

不安全的是允许某人构建一个您随后包含的任意 URL。

在这里,您将可能的替换限制为几个已知数量之一,因此它是安全的。

© www.soinside.com 2019 - 2024. All rights reserved.