gpt4 book ai didi

PHP 安全与包含

转载 作者:行者123 更新时间:2023-12-04 07:09:50 26 4
gpt4 key购买 nike

你说这有多安全?

$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');
}
}

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

谢谢

最佳答案

它是安全的。

不安全的是允许某人构建一个任意 URL,然后您将其包含在内。

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

关于PHP 安全与包含,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/552023/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com