Advertisement
VanGans

Cmod All Files

Mar 29th, 2019
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 KB | None | 0 0
  1. <?php
  2. function fixPermissions($path, $filemode = 0644, $dirmode = 0755)
  3. {
  4.     $dir = new DirectoryIterator($path);
  5.     foreach ($dir as $item) {
  6.         if (!$item->isDot() && !$item->isLink()) {
  7.             if ($item->isFile()) {
  8.                 if (chmod($item->getPathname(), $filemode)) {
  9.                     echo "CHMOD file ".$item->getPathname()." to ".decoct($filemode)." successful\r\n<br>";
  10.                 } else {
  11.                     echo "CHMOD file ".$item->getPathname()." to ".decoct($filemode)." FAILED\r\n<br>";
  12.                 }
  13.             }
  14.             if ($item->isDir()) {
  15.                 if (chmod($item->getPathname(), $dirmode)) {
  16.                     echo "CHMOD directory ".$item->getPathname()." to ".decoct($dirmode)." successful\r\n<br>";
  17.                 } else {
  18.                     echo "CHMOD directory ".$item->getPathname()." to ".decoct($dirmode)." FAILED\r\n<br>";
  19.                 }
  20.                 fixPermissions($item->getPathname(), $filemode, $dirmode);
  21.             }
  22.         }
  23.     }
  24. }
  25.  
  26. if(isset($_GET['process'])){
  27.     if($_GET['process'] === 'true'){
  28.         fixPermissions('./', 0755, 0755);
  29.         exit;
  30.     }
  31. }
  32.  
  33. ?>
  34.  
  35. <!DOCTYPE html>
  36. <html>
  37. <head>
  38.     <title>Chmod By VanGans</title>
  39. </head>
  40. <body>
  41.     <p>chmod ke semua file yang ada di direktori <?= getcwd() ?></p>
  42.     <a href="<?= $_SERVER['PHP_SELF'] ?>?process=true">Proses</a>
  43. </body>
  44. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement