JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
fix more paths (s/code/inc/)
[wfpl-cms.git] / admin_files.php
index 56db7ca..ba0e507 100644 (file)
@@ -13,7 +13,7 @@
 # To save results to a database, you'll need to create the files table
 # (the file admin_files.sql should help with this), and create the file
 # 'code/db_connect.php' which calls db_connect() see:
-# code/wfpl/examples/db_connect.php
+# inc/wfpl/examples/db_connect.php
 #
 # if you rename any of the database fields, you'll need to update this:
 
@@ -27,9 +27,9 @@ $GLOBALS['upload_directory'] = 'files/';
 $GLOBALS['filename_file_name'] = uniqid() . getmypid() . '.txt';
 
 
-require_once('code/wfpl/format.php');
-require_once('code/wfpl/email.php');
-require_once('code/wfpl/upload.php');
+require_once('inc/wfpl/format.php');
+require_once('inc/wfpl/email.php');
+require_once('inc/wfpl/upload.php');
 
 function admin_files_get_fields() {
        $data = array();
@@ -93,8 +93,14 @@ function admin_files_main() {
 }
 
 function admin_files_main_delete($id) {
-       db_delete('files', 'where id=%i', $id);
-       message('File deleted.');
+       $fn = db_get_value('files', 'filename', 'where id=%i', $id);
+       if ($fn) {
+               unlink($fn);
+               db_delete('files', 'where id=%i', $id);
+               message('File deleted.');
+       } else {
+               message("Couldn't find file to delete. Maybe it's already been deleted?");
+       }
        return './admin_files';
 }