PHP函数is_writeable非常奇怪的行为。

cutemouse 2006-08-25 12:43:34
我写的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

到底是什么原因?

...全文
245 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
cutemouse 2006-08-25
  • 打赏
  • 举报
回复
楼上的说法,我也看过,'nobody'或其他的webserver的用户名好像没有.
xuzuning 2006-08-25
  • 打赏
  • 举报
回复
记住 PHP 也许只能以运行 webserver 的用户名(通常为 'nobody')来访问文件。不计入安全模式的限制。

注: 本函数的结果会被缓存。更多信息参见 clearstatcache()。

内容概要:本文介绍了一个基于IMU(惯性测量单元)与GPS数据融合的姿态和位置参考系统,利用卡尔曼滤波器实现高精度的状态估计。通过Matlab代码实现,该系统有效结合了高速传感器数据与全球定位信息,解决了单一传感器在动态环境中存在的噪声大、漂移严重等问题,提升了导航系统的稳定性与准确性。文中详细阐述了传感器数据融合的数学模型、卡尔曼滤波算法的设计流程及其在姿态解算和位置估计中的具体应用,展示了仿真结果以验证方法的有效性与鲁棒性。; 适合人群:具备一定信号处理、控制理论基础,熟悉Matlab编程,从事导航、自动驾驶、无人机或机器人等相关领域研究的研发人员及研究生。; 使用场景及目标:①应用于需要高精度姿态与位置估计的场景,如无人驾驶、飞行器导航、移动机器人定位等;②帮助读者掌握多传感器融合的基本原理与实现方法,深入理解卡尔曼滤波在实际工程中的应用机制;③为相关科研项目提供可复现的算法原型与代码参考。; 阅读建议:建议读者结合Matlab代码逐步调试运行,深入理解状态空间建模与滤波器参数调优过程,同时可扩展学习扩展卡尔曼滤波(EKF)、无迹卡尔曼滤波(UKF)等非线性滤波技术以应对更复杂的实际应用场景。

21,890

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧