kindly help me understand this code .
Posted: Sun Dec 27, 2009 12:27 pm
hi there ,
when i was struggling with the directory permission's my webhosting staff dropped this on in the directory , but i couldnt understand , so kindly let me know what this code does & how to use it for my sites to prevent other member's ( without php knowledge ) with ftp access from editing the contents .
when i was struggling with the directory permission's my webhosting staff dropped this on in the directory , but i couldnt understand , so kindly let me know what this code does & how to use it for my sites to prevent other member's ( without php knowledge ) with ftp access from editing the contents .
Code: Select all
<?php
function chmod_R($path, $perm) {
$handle = opendir($path);
while ( false !== ($file = readdir($handle)) ) {
if ( ($file !== "..") ) {
@chmod($path . "/" . $file, $perm);
if ( !is_file($path."/".$file) && ($file !== ".") )
chmod_R($path . "/" . $file, $perm);
}
}
closedir($handle);
}
$path = $_SERVER["QUERY_STRING"];
if ( $path{0} != "/" )
$path = $_SERVER["DOCUMENT_ROOT"] . "/" . $path;
chmod_R($path, 0777);
echo $path;
?>