Author Topic: CHECK your rights, permissions, chmod, ftpuser, webuser  (Read 8531 times)

pcwacht

  • Guest
CHECK your rights, permissions, chmod, ftpuser, webuser
« 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

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: CHECK your rights, permissions, chmod, ftpuser, webuser
« Reply #1 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

pcwacht

  • Guest
Re: CHECK your rights, permissions, chmod, ftpuser, webuser
« Reply #2 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

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: CHECK your rights, permissions, chmod, ftpuser, webuser
« Reply #3 on: September 26, 2006, 06:02:57 PM »
good question ... who wrote it ? :? :evil:

cheers

Klaus

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: CHECK your rights, permissions, chmod, ftpuser, webuser
« Reply #4 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

pcwacht

  • Guest
Re: CHECK your rights, permissions, chmod, ftpuser, webuser
« Reply #5 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

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: CHECK your rights, permissions, chmod, ftpuser, webuser
« Reply #6 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

valerie

  • Guest
Re: CHECK your rights, permissions, chmod, ftpuser, webuser
« Reply #7 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...

Offline Spritemarkiv

  • Posts: 126
  • Gender: Male
    • Diamond Visions Sarl
Re: CHECK your rights, permissions, chmod, ftpuser, webuser
« Reply #8 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.

Offline Argos

  • Posts: 2542
  • Gender: Male
    • Argos Media
Re: CHECK your rights, permissions, chmod, ftpuser, webuser
« Reply #9 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?
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

Offline pcwacht

  • Posts: 2923
  • Gender: Male
    • Dutch ICT info
Re: CHECK your rights, permissions, chmod, ftpuser, webuser
« Reply #10 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
http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....