Change permissions via File manager.

This commit is contained in:
usmannasir
2018-07-08 19:09:22 +05:00
parent cecbe40d90
commit 7184373aa9
8 changed files with 578 additions and 53 deletions

View File

@@ -76,10 +76,50 @@ class fileManager
$newFileName = $this->cleanInput($request->newFileName);
$this->renameFileOrFolder($request->basePath,$request->existingName,$newFileName);
break;
case 'changePermissions':
$this->changePermissions($request->basePath, $request->permissionsPath, $request->newPermissions, $request->recursive);
break;
}
}
}
private function changePermissions($basePath, $permissionsPath, $newPermissions, $recursive)
{
try {
$completePath = $basePath . DIRECTORY_SEPARATOR . $permissionsPath;
if($recursive == 1){
$commandToExecute = 'chmod -R ' . $newPermissions . " '". $completePath . "'";
$programOutput = fopen('temp.txt', 'a');
}else{
$commandToExecute = 'chmod ' . $newPermissions . " '". $completePath . "'";
$programOutput = fopen('temp.txt', 'a');
}
exec($commandToExecute, $programOutput);
$json_data = array(
"error_message" => "None",
"permissionsChanged" => 1,
);
$json = json_encode($json_data);
echo $json;
} catch (Exception $e) {
$json_data = array(
"error_message" => $e->getMessage(),
"permissionsChanged" => 0,
);
$json = json_encode($json_data);
echo $json;
}
}
private function listDir($basePath)
{
try {