扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
我写的PHP代码如下:testfile.php
<?php
$writeok = array("uploads/", "cache/", "templates_c/", "mainfile.php");
$title = "test file php";
$content = "<table align='center'><tr><td align='left'>\n";
$error = false;
foreach ($writeok as $wok) {
echo "<br />"."../".$wok."<br />";
echo fileowner("../".$wok)."<br />";
echo filegroup("../".$wok)."<br />";
echo fileowner("../".$wok)."<br />";
echo substr(sprintf('%o', fileperms("../".$wok)), -4)."<br />";
echo filetype("../".$wok)."<br />";
if (!is_dir("../".$wok)) {
if ( file_exists("../".$wok) ) {
@chgrp("../".$wok, fileowner("../".$wok));
@chmod("../".$wok, 0666);
if (is_writeable("../".$wok)==false) {
$content .= "file ".$wok." is not writeable"."<br />";
$error = true;
}else{
$content .= "file ".$wok." is writeable"."<br />";
}
if (!is_readable("../".$wok)) {
$content .= "file ".$wok." is not readable"."<br />";
$error = true;
}else{
$content .= "file ".$wok." is readable"."<br />";
}
}
} else {
@chgrp("../".$wok, fileowner("../".$wok));
@chmod("../".$wok, 0777);
if (!is_writeable("../".$wok)) {
$content .= "dir ".$wok." is not writeable"."<br />";
$error = true;
}else{
$content .= "dir ".$wok."is writeable"."<br />";
}
if (!is_readable("../".$wok)) {
$content .= "dir ".$wok." is not readable"."<br />";
$error = true;
}else{
$content .= "dir ".$wok." is readable"."<br />";
}
}
}
$content .= "</td></tr></table>\n";
if(! $error) {
$content .= "<p>"."not error"."</p>";
}else{
$content .= "<p>"." error "."</p>";
}
echo $content;
?>
可是执行结果非常奇怪:
../uploads/
0
0
0
0777
dir
../cache/
0
0
0
0777
dir
../templates_c/
0
0
0
0777
dir
../mainfile.php
0
0
0
0666
file
dir uploads/ is not writeable dir uploads/ is readable dir cache/ is not writeable dir cache/ is readable dir templates_c/ is not writeable dir templates_c/ is readable file mainfile.php is not writeable file mainfile.php is readable |
error
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者