]> git.mxchange.org Git - simple-upload.git/commitdiff
Don't delete or mark/unmark files/directories that are being ignored.
authorRoland Häder <roland@mxchange.org>
Tue, 29 Mar 2016 13:31:54 +0000 (15:31 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 29 Mar 2016 13:31:54 +0000 (15:31 +0200)
index.php

index ee4e6a87e6b8eef22327ac031a106eb8ae909e4f..3c2998b0e56425480d6cb91cc0553fab4a1eba89 100644 (file)
--- a/index.php
+++ b/index.php
 
                if (in_array(substr($file, 1), $_SESSION['upload_user_files']) || in_array($file, $_SESSION['upload_user_files'])) {
                        $fqfn = $data['uploaddir'] . DIRECTORY_SEPARATOR . $file;
-                       if (file_exists($fqfn)) {
+                       if (!in_array($file, $data['ignores']) && file_exists($fqfn)) {
                                unlink($fqfn);
                                echo 'File has been removed';
                                exit;
 
                if (in_array(substr($file, 1), $_SESSION['upload_user_files']) || in_array($file, $_SESSION['upload_user_files'])) {
                        $fqfn = $data['uploaddir'] . DIRECTORY_SEPARATOR . $file;
-                       if (file_exists($fqfn)) {
+                       if (!in_array($file, $data['ignores']) && file_exists($fqfn)) {
                                if (substr($file, 0, 1) === '.') {
                                        rename($fqfn, substr($fqfn, 1));
                                        echo 'File has been made visible';
        }
 
        // List files in a given directory, excluding certain files
-       function createArrayFromPath ($dir, $exclude) {
+       function createArrayFromPath ($dir) {
+               global $data;
+
                $file_array = array();
                $dh = opendir($dir);
                        while ($filename = readdir($dh)) {
                                $fqfn = $dir . DIRECTORY_SEPARATOR . $filename;
-                               if (is_file($fqfn) && !in_array($filename, $exclude))
+                               if (is_file($fqfn) && !in_array($filename, $data['ignores']))
                                        $file_array[filemtime($fqfn)] = $filename;
                        }
 
 
        // Only read files if the feature is enabled
        if ($settings['listfiles']) {
-               $file_array = createArrayFromPath($data['uploaddir'], $data['ignores']);
+               $file_array = createArrayFromPath($data['uploaddir']);
 
                // Removing old files
                if ($settings['remove_old_files'])
                        removeOldFiles($data['uploaddir']);
 
-               $file_array = createArrayFromPath($data['uploaddir'], $data['ignores']);
+               $file_array = createArrayFromPath($data['uploaddir']);
        }
 ?>
 <!DOCTYPE html>