I have this PHP code:
Code:
<?php
$filename = "configuration.php";
if (file_exists($filename)) {
echo "The file $filename exists<br />";
} else {
echo "The file $filename does not exist<br />";
}
$perms = fileperms($filename);
echo "ENTERING 1<br />";
if ($perms !== FALSE)
echo "IFCHECK 1<br />";
if (@chmod($file, $perms ^ 0001)) {
echo "IFCHECK 2<br />";
@chmod($file, $perms);
return TRUE;
} // if
echo "FAILED";
return FALSE;
?>
Generates this output:
Quote:
The file configuration.php exists
ENTERING 1
IFCHECK 1
FAILED
|
So chmod failed. But the user is able to chmod this file via SSH and FTP. Why is it failing here?
[EDIT] More tests:
Code:
<?php
$filename = "testconfig.php";
if (file_exists($filename)) {
echo "The file $filename exists<br />";
} else {
echo "The file $filename does not exist<br />";
}
$perms = fileperms($filename);
echo "ENTERING 1<br />";
if ($perms !== FALSE)
echo "IFCHECK 1<br />";
//if (@chmod($file, $perms ^ 0001)) {
echo "IFCHECK 2<br />";
chmod($file, $perms);
return TRUE;
//} // if
echo "FAILED";
return FALSE;
Quote:
The file testconfig.php exists
ENTERING 1
IFCHECK 1
IFCHECK 2
Warning: chmod() [function.chmod]: No such file or directory in /home/protect/public_html/data/test.php on line 14
|
Why is chmod not seeing the file?