Created
November 14, 2013 04:41
-
-
Save carlos-sanchez/7461456 to your computer and use it in GitHub Desktop.
Cambiar permisos a 777
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
<?php | |
// Script que cambia de forma recursiva los permisos de directorios y ficheros del directorio desde donde se ejecuta | |
$file_mod = "666"; | |
$dir_mod = "777"; | |
function chmodr($path, $filemode, $dirmode){ | |
$thisfile = $_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']; | |
if (!is_dir($path)){ | |
exec("chmod ".$filemode." ".$path); | |
} else { | |
exec("chmod ".$dirmode." ".$path); | |
$dh = opendir($path); | |
while (($file = readdir($dh)) !== false) { | |
if($file != '.' && $file != '..') { | |
$fullpath = $path.'/'.$file; | |
if (!is_link($fullpath) && ($fullpath!=$thisfile)){ | |
if (is_dir($fullpath)){ | |
echo "Cambiando permisos directorio: ".$fullpath."<br />"; | |
exec("chmod ".$dirmode." ".$fullpath); | |
chmodr($fullpath, $filemode, $dirmode); | |
} else { | |
echo "Cambiando permisos fichero: ".$fullpath."<br />"; | |
exec("chmod ".$filemode." ".$fullpath); | |
} | |
} | |
} | |
} | |
closedir($dh); | |
} | |
} | |
chmodr(getcwd(),$file_mod,$dir_mod); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment