Last active
September 7, 2018 13:14
-
-
Save igamov/357841982ff01b6266e53ff5b12df7ea to your computer and use it in GitHub Desktop.
Скрипт для рекурсивной смены прав на файлы и папки
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// Папка, в которой находятся файлы и папки для изменения прав | |
$PARENT_DIR = '/home/sites/public_html/your_site/modules/'; | |
$FILE_MODE = 0777; // права на файлы | |
$DIR_MODE = 0777; // права на папки | |
function chmodex($file) { | |
global $PARENT_DIR; | |
global $FILE_MODE; | |
global $DIR_MODE; | |
if ( file_exists($file) ) { | |
if ( is_dir($file) ) { | |
if ( !($file==$PARENT_DIR) ) { chmod( $file, $DIR_MODE ); } | |
$handle = opendir( $file ); | |
while( $filename = readdir($handle) ) | |
if ( $filename != "." && $filename != ".." ) chmodex( $file."/".$filename ); | |
closedir($handle); | |
} else { | |
chmod( $file, $FILE_MODE ); | |
} | |
} | |
return true; | |
} | |
if(chmodex($PARENT_DIR)) echo "hello"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment