復制代碼 代碼如下:
<?php
$file = $_GET['file']; // "../../etc/passwd/0"
if (file_exists('/home/wwwrun/'.$file.'.php')) {
// file_exists will return true as the file /home/wwwrun/../../etc/passwd exists
include '/home/wwwrun/'.$file.'.php';
// the file /etc/passwd will be included
}
?>
復制代碼 代碼如下:
<?php
$file = $_GET['file'];
// 對字符串進行白名單檢查
switch ($file) {
case 'main':
case 'foo':
case 'bar':
include '/home/wwwrun/include/'.$file.'.php';
break;
default:
include '/home/wwwrun/include/main.php';
}
?>
新聞熱點
疑難解答