Is there a way to check what a file is currently CHMODed to? I need to store that in a variable, so after I chmod the file to make it writable, I can chmod it back to what it was. Can this be done?
Hi pyro ! I've found the way to come here ;-)
something like that should do it:
<? $myFile = "file.php"; $chmod = decoct(fileperms($myFile)); echo $chmod; ?>
Hello Swon...Great to see you here! I'll give it a try and let you know...
To mode it:
<? chmod ($myFile, 0777); // sets the new mode; clearstatcache(); $chmod = decoct(fileperms($myFile)); // proof the new chmod echo $chmod; ?>
I think I will use something like this...
<? $myFile = "file.php"; $chmod = decoct(fileperms($myFile)); $substring = substr($chmod,strlen($chmod)-4,strlen($chmod)); echo $substring; ?>
Otherwise it returned 100666...
looks good!
Yeah, the only other thing I added was a die statement, because it seems all servers don't support the chmod command. That's going to make it a pain...Ah well... Two out of three servers I tried to chmod on didn't work! nuts...
some kind of servers like MS are shxx to set any chmod, doesn't work..
One of the servers it didn't work on was a Linux box with an Apache server, and the other is a Linux box, but I don't know what server software is. I contacted the Administrator of the first host and he said he is working on it...The second I don't care too much about, except that I want this script to be able to be distributed, so I need it to work on everything... For now, I have it return an error message saying that they need to manually chmod to 666.