Changed upload logic.

This commit is contained in:
Maxim Stewart 2018-04-18 16:25:51 -05:00
parent 39c64b4516
commit e0097e173e
3 changed files with 14 additions and 11 deletions

View File

@ -1,5 +1,6 @@
<?php
$MPLAYER_WH = " -xy 1600 -geometry 50%:50% ";
$MEDIAPLAYER = "mplayer";
$MUSICPLAYER = "/opt/deadbeef/bin/deadbeef";
$IMGVIEWER = "mirage";

View File

@ -5,7 +5,7 @@ function openFile($FILE) {
$EXTNSN = strtolower(pathinfo($FILE, PATHINFO_EXTENSION));
if (preg_match('(mkv|avi|flv|mov|m4v|mpg|wmv|mpeg)', $EXTNSN) === 1) {
shell_exec($MEDIAPLAYER . " \"" . $FILE . "\" > /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) {

View File

@ -15,8 +15,13 @@ function uploadFiles($targetDir) {
// Check if file already exists
$targetFile = $targetDir . $fileName;
if (file_exists($targetFile)) {
unlink($targetFile);
echo "<span class='warnning'>Server: [Warnning] --> This file already exists. Overwriting it.</span>";
if (is_file($targetFile)) {
unlink($targetFile);
echo "<span class='warnning'>Server: [Warnning] --> This file already exists. Overwriting it.</span>";
} else {
echo "<span class='warnning'>Server: [Warnning] --> This file might be a directory. Or, no files were submitted for uploading.</span>";
$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 "<span class='error'>Server: [Error] --> Your file " . $fileName . " was not uploaded.</span>";
// if everything is ok, try to upload file
} else {
if ($uploadOk !== 0) {
if (move_uploaded_file($fileTmpName, $targetFile)) {
echo "<span class='success'>Server: [Success] --> The file " . $fileName . " has been uploaded.</span>";
} else {
echo "<span class='error'>Server: [Error] --> File not uploaded for the above reason(s).</span>";
}
} else {
echo "<span class='error'>Server: [Error] --> Your file " . $fileName . " was not uploaded.</span>";
}
}
echo "</body></html>";
// 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 "<span style='color:rgb(255, 0, 0);'>Server: [Error] --> Incorrect access attempt!</span>";