對於會議安排,我想要爲任何給定的房間設置動態頁面。用戶可以在config文件夾中編輯名爲「schedules.conf」的文件。目前,它看起來像這樣:Smarty從PHP中的.conf文件讀取配置值
[rooms]
room = 5022
room = 5082
我能正常加載它,它體現在我的網頁2個鏈接:
{config_load file="schedules.conf" section="rooms"}
......
......
......
{foreach from=#room# item=r}
<li><span><span><a href="{$smarty.const.SITE_URL}/admin/schedules.list.php?room={$r}">Schedules {$r}</a></span></span></li>
{/foreach}
所以它鏈接到處理PHP文件,現在在PHP文件我要檢查的天氣房在配置文件中,因此,如果有人手動更改GET值房,在地址欄中我能有機會來處理:
if(!isset($_GET["room"]))
{
header('location: '.SITE_URL.'/admin/index.php');
}
else
{
$validRooms = $smarty->getConfigDir();
//How to check id the $_GET["room"] value exist in the config file
}
這我知道,但我想嚴格檢查在我的PHP文件,並在房間號碼不僅存在,那麼我從數據庫中提取數據。 –