我正在使用此脚本从我的服务器中删除图片。但同时我想保护我的服务器中的文件。不小心删除,但我注意到,如果我输入文件index.pHp
或index.Php
已从我的服务器中删除。虽然设置它不会删除为什么PHP或此方法不知道小写和大写之间。检测小写字母和大写字母php
什么是不正确的?
<?php
error_reporting (0);
$thefile = $_GET ['filetodel'];
$filename = "$thefile";
//$filename = "picture1.jpg";
/*protect some files*/
if ($thefile=='index.php' or $thefile=='INDEX.PHP' or $thefile=='UPLOADS.ZIP' or $thefile=='uploads.zip' or $thefile=='del.php'or $thefile=='DEL.PHP' or $thefile==NULL or $thefile=='.htaccess' or $thefile=='.HTACCESS')
{
exit("<h2>cannot delete $thefile</h2>");
}
if ($thefile=="$thefile")
{
if (file_exists($filename))
{
unlink ("$thefile");
echo "<h2> file $thefile is delete</h2>";
}
else
{
echo "<h2>The<br>";
echo "$filename<br>";
echo "Does not exist</h2>";
}
}
?>
所以你知道在未来,你的代码必须在第三方服务的问题上进行。 – meagar