Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function fixPermissions($path, $filemode = 0644, $dirmode = 0755)
- {
- $dir = new DirectoryIterator($path);
- foreach ($dir as $item) {
- if (!$item->isDot() && !$item->isLink()) {
- if ($item->isFile()) {
- if (chmod($item->getPathname(), $filemode)) {
- echo "CHMOD file ".$item->getPathname()." to ".decoct($filemode)." successful\r\n<br>";
- } else {
- echo "CHMOD file ".$item->getPathname()." to ".decoct($filemode)." FAILED\r\n<br>";
- }
- }
- if ($item->isDir()) {
- if (chmod($item->getPathname(), $dirmode)) {
- echo "CHMOD directory ".$item->getPathname()." to ".decoct($dirmode)." successful\r\n<br>";
- } else {
- echo "CHMOD directory ".$item->getPathname()." to ".decoct($dirmode)." FAILED\r\n<br>";
- }
- fixPermissions($item->getPathname(), $filemode, $dirmode);
- }
- }
- }
- }
- if(isset($_GET['process'])){
- if($_GET['process'] === 'true'){
- fixPermissions('./', 0755, 0755);
- exit;
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Chmod By VanGans</title>
- </head>
- <body>
- <p>chmod ke semua file yang ada di direktori <?= getcwd() ?></p>
- <a href="<?= $_SERVER['PHP_SELF'] ?>?process=true">Proses</a>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement