WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: pcwacht on September 25, 2006, 10:18:32 PM

Title: CHECK your rights, permissions, chmod, ftpuser, webuser
Post by: pcwacht on September 25, 2006, 10:18:32 PM
Just make a code section paste the code and call the page where it is in

Code: [Select]
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
Title: Re: CHECK your rights, permissions, chmod, ftpuser, webuser
Post by: kweitzel on September 26, 2006, 10:30:57 AM
Great Script ... works fine on my production host (Linux). On XAMPP it gives errors. Buit I think we can forget about them :-)

cheers

Klaus
Title: Re: CHECK your rights, permissions, chmod, ftpuser, webuser
Post by: pcwacht on September 26, 2006, 02:18:54 PM
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
Title: Re: CHECK your rights, permissions, chmod, ftpuser, webuser
Post by: kweitzel on September 26, 2006, 06:02:57 PM
good question ... who wrote it ? :? :evil:

cheers

Klaus
Title: Re: CHECK your rights, permissions, chmod, ftpuser, webuser
Post by: kweitzel on September 28, 2006, 08:41:53 PM
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
Title: Re: CHECK your rights, permissions, chmod, ftpuser, webuser
Post by: pcwacht on September 28, 2006, 08:56:52 PM
Code: [Select]
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:
Code: [Select]
$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
Title: Re: CHECK your rights, permissions, chmod, ftpuser, webuser
Post by: kweitzel on September 28, 2006, 09:57:25 PM
Quote
Many servers can't handle php inside html pages

OK ... fair comment ... removed it.

Quote
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

added that info as well ...

cheers and thanks for the corrections

Klaus
Title: Re: CHECK your rights, permissions, chmod, ftpuser, webuser
Post by: valerie on September 29, 2006, 07:28:42 PM
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...
Title: Re: CHECK your rights, permissions, chmod, ftpuser, webuser
Post by: Spritemarkiv on August 08, 2008, 04:54:59 PM
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.
Title: Re: CHECK your rights, permissions, chmod, ftpuser, webuser
Post by: Argos on August 23, 2008, 12:04:38 PM
I made some changes in the visual aspects:
Code: [Select]
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?
Title: Re: CHECK your rights, permissions, chmod, ftpuser, webuser
Post by: pcwacht on August 23, 2008, 12:14:03 PM
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