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;
}