
<?php
// When possible read files instead of shell_exec or exec for efficiency

$tzpath = realpath("/etc/localtime");
if(substr($tzpath, 0, 20) == '/usr/share/zoneinfo/') {
    $tz = substr($tzpath, 20);
    date_default_timezone_set($tz);
}

$datetm =  date("D M d  H:i:s T Y");

echo ' ' . $datetm . '<br><br>';


$filename = "/mnt/tmpfs/liveview.txt";

if (file_exists($filename)) {
    $contents = file_get_contents($filename);

    $separator = chr(30);
    $items = explode($separator, $contents);
    //print_r($items);

    //echo nl2br($contents); // Preserve line breaks in HTML output
   //$link = "/reports/custom/mscale/_mscalelive.php";
    //echo 'name [' . $items[0] . ']<br><br>';
    //echo 'path [' . rtrim($items[1]) . ']<br><br>';
    echo "<button onclick=\"window.location.href='" . rtrim($items[1]) . "'\">";
    echo $items[0];
    echo '</button>';

    //echo '<br><br>';

    //echo '<a href="' . rtrim($items[1]) . '" class=\"button-link\">' . $items[0]. '</a>';


} else {
    echo "Live View is not currently available. To access Live View an app with Live View support must be currently running and have Live View enabled.";
}

?>


