Last active
April 25, 2020 14:06
-
-
Save geomago/86ccd7c85ecf2629b1f258ad818abb10 to your computer and use it in GitHub Desktop.
getupdates function - js and html files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Changes to javascript functions are contained in .js files in the "$sync_path" folder | |
$updjs = []; // each element contains a set of synctactically correct javascript statements | |
$maxtime = $lastupd; // save the most recent update sent | |
// List all .js files updated later than $lastupd"); | |
foreach (scandir($sync_path) as $file) { | |
if (is_dir($file) || pathinfo($file,PATHINFO_EXTENSION)!='js') continue; | |
$filetime = date('Y-m-d H:i:s',filemtime("$sync_path/$file")); | |
if ($filetime>$lastupd) { | |
$updjs[] = file_get_contents("$sync_path/$file"); | |
if ($maxtime<$filetime) $maxTime = $filetime; | |
} | |
} | |
// Changes to an HTML template are made by placing an equally-named file in the "$sync_path" folder | |
$updhtml = []; // each item will contain a file name and content | |
foreach (scandir($sync_path) as $file) { | |
if (is_dir($file) || pathinfo($file,PATHINFO_EXTENSION)!='html') continue; | |
$filetime = date('Y-m-d H:i:s',filemtime("$sync_path/$file")); | |
if ($filetime>$lastupd) { | |
$updhtml[] = ["name" => $file, | |
"content" => file_get_contents("$sync_path/$file") | |
]; | |
if ($maxtime <$filetime) $maxtime = $filetime; | |
} | |
} | |
// Now $updjs, $updhtml and $maxtime are ready to be returned to caller |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment