我在 php 中有一个网站,它确实 include() 将内容嵌入到模板中。要加载的页面在 get 参数中给出,我将“.php”添加到参数的末尾并包含该页面。我需要做一些安全检查以避免 XSS 或其他东西(不是 mysql 注入,因为我们没有数据库)。我想出的是以下内容。
$page = $_GET['page'];
if(!strpos(strtolower($page), 'http') || !strpos($page, '/') ||
!strpos($page, '\\') || !strpos($page, '..')) {
//append ".php" to $page and include the page
我还能做些什么来进一步清理我的输入吗?