Wednesday, March 19, 2008

How to prevent users from deleting certain files using the File Manager

Since Users often delete things they shouldn't, it may be wise to prevent them from deleting things they shouldn't.
In this example, we'll block them from deleting their /public_html symbolic link using the filemanager.

First, edit the following script which will be doing the work for us:
/usr/local/directadmin/scripts/custom/all_pre.sh

Inside this new script, add the code:

#!/usr/local/bin/php
$command = getenv("command");
$button = getenv("button");
if (($command == "/CMD_FILE_MANAGER/" || $command == "/CMD_FILE_MANAGER") && $button == "delete")
{
foreach ($_ENV as $path)
{
if ($path == "/public_html")
{
echo "You cannot delete your public_html link!\n";
exit(1);
}
}
}
exit(0);
?>

save the changed. Chmod the all_pre.sh to 755 and test it out.

You can all more paths for them not to delete, by adding another if statement after the check for public_html.

No comments: