From: Roland Häder Date: Thu, 31 Mar 2016 09:18:52 +0000 (+0200) Subject: Renaming (hide/unhide) of files rewritten so failures can be caught. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=simple-upload.git Renaming (hide/unhide) of files rewritten so failures can be caught. --- diff --git a/index.php b/index.php index 3971ac1..5ba2e26 100644 --- a/index.php +++ b/index.php @@ -232,14 +232,21 @@ 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; }