diff --git a/resources/php/config.php b/resources/php/config.php index 52d581e..e72e5c7 100644 --- a/resources/php/config.php +++ b/resources/php/config.php @@ -1,5 +1,6 @@ /dev/null &"); + shell_exec($MEDIAPLAYER . $MPLAYER_WH . "\"" . $FILE . "\" > /dev/null &"); } else if (preg_match('(png|jpg|jpeg|gif)', $EXTNSN) === 1) { shell_exec($IMGVIEWER . ' "' . $FILE . '" > /dev/null &'); } else if (preg_match('(psf|mp3|ogg|flac)', $EXTNSN) === 1) { diff --git a/resources/php/upload.php b/resources/php/upload.php index 625a917..8cccb20 100755 --- a/resources/php/upload.php +++ b/resources/php/upload.php @@ -15,8 +15,13 @@ function uploadFiles($targetDir) { // Check if file already exists $targetFile = $targetDir . $fileName; if (file_exists($targetFile)) { - unlink($targetFile); - echo "Server: [Warnning] --> This file already exists. Overwriting it."; + if (is_file($targetFile)) { + unlink($targetFile); + echo "Server: [Warnning] --> This file already exists. Overwriting it."; + } else { + echo "Server: [Warnning] --> This file might be a directory. Or, no files were submitted for uploading."; + $uploadOk = 0; + } } // Check file size @@ -40,22 +45,19 @@ function uploadFiles($targetDir) { // $uploadOk = 0; // } - // Check if $uploadOk is set to 0 by an error - if ($uploadOk == 0) { - echo "Server: [Error] --> Your file " . $fileName . " was not uploaded."; // if everything is ok, try to upload file - } else { + if ($uploadOk !== 0) { if (move_uploaded_file($fileTmpName, $targetFile)) { echo "Server: [Success] --> The file " . $fileName . " has been uploaded."; - } else { - echo "Server: [Error] --> File not uploaded for the above reason(s)."; } + } else { + echo "Server: [Error] --> Your file " . $fileName . " was not uploaded."; } } echo ""; // Prompt an update clint side when sse checks that there is updateListing. - $myfile = fopen("../vars.txt", "w+"); + $myfile = fopen("resources/vars.txt", "w+"); $txt = "updateListing"; fwrite($myfile, $txt); fclose($myfile); @@ -63,7 +65,7 @@ function uploadFiles($targetDir) { // Check access type. chdir("../../"); -if(isset($_POST["UploadFiles"])) { +if(isset($_POST["UploadFiles"]) && isset($_POST["DIRPATHUL"])) { uploadFiles($_POST["DIRPATHUL"]); } else { echo "Server: [Error] --> Incorrect access attempt!";