2
我现在正在学习php,现在我正在开发一些使用php include的简单网站来简化页面创建过程。 我搜索了这个网站,以确保它的安全,但作为一个小白,我总是害怕搞砸。Php包括安全性 - 使用数组和名称前缀
<?php
$siteArticles = array('instalacoes','galeria','regiao-e-historia','precos','contactos');
if(isset($_GET['page'])){
if(in_array($_GET['page'], $siteArticles, true) && file_exists('pt/'.'rbs-article-'.$_GET['page'].'.php')){
include('pt/'.'rbs-article-'.$_GET['page'].'.php');
}
}else{
include('pt/rbs-article-home.php');
}
?>
如您所见,它首先检查页面是否允许通过数组,然后向名称文件中添加前缀。
我的问题是,这有多安全?
谢谢你的时间。
只是因为我是偏执狂,我仍然使用'array_search'并使用索引而不是使用'$ _GET ['page']来获取页面名称' – MarcDefiant 2013-02-15 12:20:41