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 &');
} else if (preg_match('(psf|mp3|ogg|flac)', $EXTNSN) === 1) {
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) {
shell_exec($TEXTVIEWER . ' "' . $FILE . '" > /dev/null &');
} else if (preg_match('(pdf)', $EXTNSN) === 1) {
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
// Retrieve data
// Retrieve data
function dirListing($PATH) {
if (is_dir($PATH)) {
$GeneratedXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><DIR_LIST>"

View File

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

View File

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

View File