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 (preg_match("/CMD_FILE_MANAGER/", $command) && $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.

 
config/prevent_delete.txt · Last modified: 2010/02/22 01:44 by muscardin
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki