Figured out php sessions...

This commit is contained in:
Maxim Stewart 2018-04-21 19:49:17 -05:00
parent 7d9d110d16
commit 2b1b7feda6
5 changed files with 14 additions and 15 deletions

View File

@ -10,13 +10,12 @@ function openFile($FILE) {
shell_exec($IMGVIEWER . ' "' . $FILE . '" > /dev/null &'); shell_exec($IMGVIEWER . ' "' . $FILE . '" > /dev/null &');
} else if (preg_match('(psf|mp3|ogg|flac)', $EXTNSN) === 1) { } else if (preg_match('(psf|mp3|ogg|flac)', $EXTNSN) === 1) {
shell_exec($MUSICPLAYER . ' "' . $FILE . '" > /dev/null &'); shell_exec($MUSICPLAYER . ' "' . $FILE . '" > /dev/null &');
} else if (preg_match('(odt|doc|docx|rtf)', $EXTNSN) === 1) {
shell_exec($OFFICEPROG . ' "' . $FILE . '" > /dev/null &');
} else if (preg_match('(txt)', $EXTNSN) === 1) { } else if (preg_match('(txt)', $EXTNSN) === 1) {
shell_exec($TEXTVIEWER . ' "' . $FILE . '" > /dev/null &'); shell_exec($TEXTVIEWER . ' "' . $FILE . '" > /dev/null &');
} else if (preg_match('(pdf)', $EXTNSN) === 1) { } else if (preg_match('(pdf)', $EXTNSN) === 1) {
shell_exec($PDFVIEWER . ' "' . $FILE . '" > /dev/null &'); shell_exec($PDFVIEWER . ' "' . $FILE . '" > /dev/null &');
// Has to be below b/c pdf somehow regesters as an office app.... wtf....
} else if (preg_match('(odt|doc|docx|rtf)', $EXTNSN) === 1) {
shell_exec($OFFICEPROG . ' "' . $FILE . '" > /dev/null &');
} }
} }

View File

@ -1,5 +1,5 @@
<?php <?php
// Retrieve data // Retrieve data
function dirListing($PATH) { function dirListing($PATH) {
if (is_dir($PATH)) { if (is_dir($PATH)) {
$GeneratedXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><DIR_LIST>" $GeneratedXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><DIR_LIST>"

View File

@ -1,14 +1,15 @@
<?php <?php
// Prompt an update clint side when sse checks that there is updateListing. // Start the session
$myfile = fopen("../vars.txt", "r"); session_start();
$state = fgets($myfile);
fclose($myfile);
$myfile = fopen("../vars.txt", "w"); if ($_SESSION["state"] != null || $_SESSION["state"] == "undefined") {
fclose($myfile); $state = $_SESSION["state"];
}
header('Content-Type: text/event-stream'); header('Content-Type: text/event-stream');
header('Cache-Control: no-cache'); header('Cache-Control: no-cache');
echo "data:" . $state . "\n\n"; echo "data:" . $state . "\n\n";
$_SESSION["state"] = "none";
flush(); flush();
?> ?>

View File

@ -1,4 +1,7 @@
<?php <?php
session_start();
function uploadFiles($targetDir) { function uploadFiles($targetDir) {
echo "<!DOCTYPE html>" echo "<!DOCTYPE html>"
. "<head>" . "<head>"
@ -56,11 +59,7 @@ function uploadFiles($targetDir) {
} }
echo "</body></html>"; echo "</body></html>";
// Prompt an update clint side when sse checks that there is updateListing. $_SESSION["state"] = "updateListing";
$myfile = fopen("resources/vars.txt", "w+");
$txt = "updateListing";
fwrite($myfile, $txt);
fclose($myfile);
} }
// Check access type. // Check access type.

View File