Menu

delete files

2008-01-21
2013-04-22
  • Scott Szretter

    Scott Szretter - 2008-01-21

    It would be nice to add a simple file delete option -- for example by using the unlink command.  I know this is dangerous, but just default it to disable in the config area.   I would imagine it would be useful when clicking on a  thumbnail, and have a link there to click to delete the image you are viewing then maybe go to the next image in the folder.
    It would make it easy to view a bunch of images, and clean out ones you do not like.

     
    • Ivan Voras

      Ivan Voras - 2008-01-21

      This would require the following modifications to isaac3:

      - adding an authentication system (so only admins can delete files)
      - tying the authentication system with server-side permissions (web server account would need to have control of the files)

      These are not going to happen without some significant funding :)

       
    • Scott Szretter

      Scott Szretter - 2008-01-21

      Well, I went ahead and put in my own delete link code.  It of course requires that php has permissions to delete the files in the directory you are navigating.  I did not put in a preference, that would be easy enough, and the only problem I see so far is when you delete an image, I auto-redirect to the next image in the directory, and it still displays the previous image link to the now deleted image.  That could be fixed with a little work I am sure.  Here is what I did (code changes in two places):

      1.
              // add this code to bottom of the send_navigation() function to add a 'delete' link
              // move the last echo line below and change as shown below to display the $delurl var
             
              if ($idx < count($filelist)-1)   
                     {
                  $nexti=make_url($filelist[$idx+1]['de']);
                  }
              else
                  {
                  $nexti=make_url($filelist[0]['de']); // go back to the beginning if we are at the end?
                  }
                 
              $delurl="<a href=\"".make_url($filelist[$idx]['de'])."?what=del&nexti=".$nexti."\">delete</a>";
              echo "</tr><tr><td colspan=2>".$delurl."</td></tr></table>\n<br>\n";

      2.

             case 'del' :  // add this case statement block to: switch (strtolower($_GET['what'])) {   (before the default: case) 
                 unlink($rootdir_fs.$viewfile_fs); // delete the file
                 //now redirect to the next image
                 $url=$_SERVER['HTTP_HOST'].$_GET['nexti'];
                  header("Location: http://$url");
                  break;

      Crude, basic, but it works for me.

       
    • Scott Szretter

      Scott Szretter - 2008-01-21

      Oh, another note, I use this simple drop in page to protect a directory -- again, you need permissions on an apache server with .htaccess ability:
      http://www.krizleebear.de/phpaccess/dynamisch/

      There is code in there to do a simple log-in without htaccess, you could borrow that and stick it in to isaac3...

      I do not think there needs to be a complex groups/login concept, if you want a log-in just let them define a password to do the login by editing the config vars at the top of the script, another flag for the delete delete function that defaults to off, set a session var that times out after a while, simply check that the session var is set before it deletes...

      I do not need this myself, so i am not bothering, but just a suggestion...

       

Log in to post a comment.