We often encounter some problems such as directory permissions being inaccessible. At this time, there may be hundreds or thousands of files or file directories. Below I wrote an example of using PHP to batch change directory permissions.
The code is as follows |
Copy code |
//Get the file directory list, this method returns an array
function getDir($dir=”) {
$dir=empty($dir) ? getcwd() : $dir;
$dirArray[]=NULL;
If (false != ($handle = opendir ( $dir ))) {
$i=0;
While ( false !== ($file = readdir ( $handle )) ) {
//Remove ".", ".." and files with ".xxx" suffix
If ($file != “.” && $file != “..”&&!strpos($file,”.”)) {
$dirArray[$i]=$file;
$i++;
}
}
//Close handle
closedir ( $handle );
}
Return $dirArray;
}
?>
Batch directory permission settings
if(empty($_POST)){
?>
}else{
$directorys=@$_POST['directory'];
$Perm=trim(@$_POST['Perm']);
$User=trim(@$_POST['User']);
?>
<br>
@echo off<br>
<?php<br />$BASE_DIR=getcwd();<br />
if(is_array($directorys)){<br />
foreach($directorys as $directory ){<br />
echo <<<EOF<br />
echo Y|cacls {$BASE_DIR}{$directory} /T /E /C /G {$User}:{$Perm} <br/><br>
EOF;<br>
}<br>
}<br>
?><br>
pause<br>
}
?>
|
http://www.bkjia.com/PHPjc/632813.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632813.htmlTechArticleWe often encounter some problems such as directory permissions being inaccessible. At this time, there may be hundreds or thousands of File or file directory, below I wrote a method that uses php to batch change directory permissions...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn