View Full Version : chmod() question
Revan
01-29-2005, 06:23 PM
What would have to be done to allow chmod() to work prop?
My host took off open_basedir restrictions for my user, but it still would not work...
Im writing a script to run on this host and this host alone, so it would be good if the files could be made writable and back again on demand.
Host is running php4/a linux distro/apache1.3
TIA :)
//peace
Zachery
01-29-2005, 07:36 PM
What would have to be done to allow chmod() to work prop?
My host took off open_basedir restrictions for my user, but it still would not work...
Im writing a script to run on this host and this host alone, so it would be good if the files could be made writable and back again on demand.
Host is running php4/a linux distro/apache1.3
TIA :)
//peace
where are you trying chmod to, and what are you putting in the function?
Revan
01-29-2005, 08:13 PM
<?php
if (!is_writable('test.txt'))
{
if (!chmod('test.txt', 0777))
{
echo "owned";
}
else
{
echo "yay";
}
}
?>
Getting "operation not permitted" error.
And yes, the text file does exist and it is currently chmod()'ed to 644 (default).
did you tried also with full patch of file ?
like
$mydir = getcwd();
chmod($mydir."/test.txt", 0777)
Revan
01-29-2005, 11:41 PM
Yup, now that is tried too.
Warning: chmod(): Operation not permitted in /public_html/test.php on line 5
Bastard php :p
heh,
well maybe the host dosent allow chmod change at all
can you change chmod via ftp or ssh cilent ?
Revan
01-30-2005, 09:12 AM
Yes I can, that's not the problem. I want the script to be able to change chmod on command, since it will be writing to a config file which only needs to be writable while writing.
Host tried to enable chmod in php, but didn't know how to do it.
I also looked through php.ini and theres nothing about "chmod" in there...
Jolten
01-30-2005, 12:33 PM
Sometimes the public_html folder is an alias of a www folder (ASO does this). IF this is the case.. change your path to /www/test.php to use the actual file directory and not an alias directory.
can you give more info about your host ?
like php version and Os
also please check if php is under safe_mode
cuse some function dosent work with safe mode
to check use this script
<?php
// Check for safe mode
if( ini_get('safe_mode') ){
echo "Safe mode is on";
}else{
echo "Safe mode is off";
}
?>
if safe mode is on turn it off and try again
and please report.
edit :
YEP i was right chmod is disabled on safe mode
you can find all of functions that dosent work with safe mode
here (http://il.php.net/manual/en/features.safe-mode.functions.php)
lets hope this is the problem.
Revan
01-30-2005, 06:11 PM
can you give more info about your host ?
like php version and Os
Host is running php4/a linux distro/apache1.3
And no, safe mode is off... :ermm:
Thanks for the effort :)
ok, im running or idea's :(
maybe install newest version of php might help :(
sorry mate.
can you test this 1
$file = "test.txt";
$mode = "0777";
chmod($file , intval($mode, 8));
tell me if worked out...
Revan
01-31-2005, 02:07 PM
Nope :P
What's the risk of a website having its content files chmodded as 0777 then?
I mean can there be "hax0rz on y0ur pC?" that messes up the files?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.