Just make a code section paste the code and call the page where it is in
function check_dir($path) {
echo "<h1>checking: ".$path."</h1>";
$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
if ($file<>'.' && $file<>'..') {
if (is_dir($path.'/'.$file)) {
check_dir($path.'/'.$file);
} else {
if (is_writable($path.'/'.$file)) {
echo 'Green :'.$file.'<br>';
} else {
echo '#### Not ok! :'.$file.'<br>';
}
}
}
}
closedir($dh);
}
check_dir('../temp');
check_dir('../templates');
check_dir('../pages');
check_dir('../languages');
check_dir('../media');
Works on Linux, not confirmed on windows
Have fun,
John
Great Script ... works fine on my production host (Linux). On XAMPP it gives errors. Buit I think we can forget about them :-)
cheers
Klaus
Windows - Xampp users hardly ever have persmission problems ;)
This script just check to see if the WEB user has permissions to write/create/delete files
I like it allso, it is short, fast and easy enough to understand... ;)
Oh did I mention I wrote it?
:P
:P
John
good question ... who wrote it ? :? :evil:
cheers
Klaus
Hi John,
put an initial Page with this script into the WIKI: http://projects.WebsiteBaker.org/websitebaker2/wiki/Docs-EN-Advanced-Howtos-Filepermissions
Would you please chek and eventually correct me? Thanks
cheers
Klaus
If you use it on a HTML Page you need to wrap ....
Many servers can't handle php inside html pages,
they can inside php pages... ;)
This script will only work at a defualt installation (the pages dir for example) and only when the code is put in a firstlevel page
If not the path (../) might be changed to ../../ (if the page wich hold the code is on the irst sublevel)
Maybe note this somewhere
Or change last bit to:
$path = '../'; // first level page with code
check_dir($path.'temp');
check_dir($path.'templates');
check_dir($path.'pages'); // default pages dir!
check_dir($path.'languages');
check_dir($path.'media');
Thanks for porting the info btw... I like those wikis wich explain stuff ;)
John
QuoteMany servers can't handle php inside html pages
OK ... fair comment ... removed it.
QuoteThis script will only work at a defualt installation (the pages dir for example) and only when the code is put in a firstlevel page
added that info as well ...
cheers and thanks for the corrections
Klaus
What should you do when it comes back with a list of around 60 items that are "not ok!"?
I've been having trouble with different permissions on some files/folders in wb so based on woudloper's advice I asked my host to change all permissions. But if I understand correctly, this means that now they don't have the permissions wb needs. I'm not sure what to do...
The part about placing the page in the first level should be on the Knowledge Base. Took me a long time to get it to work. :-( Now working after digging around and finding this topic.
I made some changes in the visual aspects:
echo "<h1>Checking permissions</h1>";
function check_dir($path) {
echo "<h4>".$path."</h1>";
$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
if ($file<>'.' && $file<>'..') {
if (is_dir($path.'/'.$file)) {
check_dir($path.'/'.$file);
} else {
if (is_writable($path.'/'.$file)) {
echo '<font color="green">'.$file.'</font><br>';
} else {
echo '<font color="red">'.$file.'</font><br>';
}
}
}
}
closedir($dh);
}
check_dir('../temp');
check_dir('../templates');
check_dir('../pages');
check_dir('../languages');
check_dir('../media');
However, I don't understand what's the purpose of this thingy. It seems files only get approved if they are writable, but that's not needed for many files, is it?
Nope, not needed
But on some directories they really are needed,
temp, templates, modules etc etc
This thingy just checks php rights on them, thus testing apache rights
John