Advertisement
Guest User

PHP permission test

a guest
Dec 24th, 2015
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. <h1>Start test</h1>
  2. <hr>
  3. <?php
  4.  
  5. permitted($_SERVER['DOCUMENT_ROOT']);
  6.  
  7. function permitted($dir) {
  8.   foreach (scandir($dir) as $file) {
  9.  
  10.     if (substr($file, 0, 1) !== '.') {
  11.  
  12.       if (is_writable($file)) {
  13.         print $file.' [PERMS: '.fileperms($file).']<br />';
  14.       } else {
  15.         print '<span style="color:red;">'.$file.'</span><br />';
  16.       }
  17.  
  18.       if (is_dir($file)) {
  19.         print '<h4>DIR:'.$file.'</h4><div style="margin:0 0 12px 12px;">';
  20.         permitted($file);
  21.         print '</div>';
  22.       }
  23.     }
  24.  
  25.   }
  26. }
  27.  
  28. ?>
  29. <hr>
  30. <h1>The end</h1>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement