]> git.mxchange.org Git - simple-upload.git/commitdiff
Renaming (hide/unhide) of files rewritten so failures can be caught. master
authorRoland Häder <roland@mxchange.org>
Thu, 31 Mar 2016 09:18:52 +0000 (11:18 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 31 Mar 2016 09:18:52 +0000 (11:18 +0200)
index.php

index 3971ac17942fd3d1ef2bc7d8ced3d5569c5d1faf..5ba2e262ee543659e0bd328a63ef6d7984d52a6b 100644 (file)
--- a/index.php
+++ b/index.php
                global $data;
 
                if (in_array(substr($file, 1), $_SESSION['upload_user_files']) || in_array($file, $_SESSION['upload_user_files'])) {
-                       $fqfn = $data['uploaddir'] . DIRECTORY_SEPARATOR . $file;
-                       if (!in_array($file, $data['ignores']) && isReadableFile($fqfn)) {
+                       $sourceFile = $data['uploaddir'] . DIRECTORY_SEPARATOR . $file;
+                       if (!in_array($file, $data['ignores']) && isReadableFile($sourceFile)) {
                                if (substr($file, 0, 1) === '.') {
-                                       rename($fqfn, substr($fqfn, 1));
-                                       echo 'File has been made visible';
+                                       $targetFile = $data['uploaddir'] . DIRECTORY_SEPARATOR . substr($file, 1);
+                                       $successMessage = 'File has been made public';
+                                       $failedMessage = 'File has NOT been made public';
+                               } else {
+                                       $targetFile = $data['uploaddir'] . DIRECTORY_SEPARATOR . '.' . $file;
+                                       $successMessage = 'File has been hidden';
+                                       $failedMessage = 'File has NOT been hidden';
+                               }
+                               if (rename($sourceFile, $targetFile)) {
+                                       echo $successMessage;
                                } else {
-                                       rename($fqfn, $data['uploaddir'] . DIRECTORY_SEPARATOR . '.' . $file);
-                                       echo 'File has been hidden';
+                                       echo $failedMessage;
                                }
                                exit;
                        }