86 lines
2.7 KiB
PHP
86 lines
2.7 KiB
PHP
<?php
|
|
//
|
|
// Handle scheduled shutdown
|
|
//
|
|
|
|
// No Maintenance, so just return
|
|
return;
|
|
|
|
//
|
|
// Maintenance Processing
|
|
//
|
|
$currentURL = str_replace("www.","",strtolower($_SERVER['HTTP_HOST']));
|
|
if ($currentURL == 'demo.hotlunches.net') return;
|
|
if ($currentURL == 'dev.hotlunches.net') return;
|
|
|
|
date_default_timezone_set("America/Vancouver");
|
|
|
|
// startLog("maintenance.php");
|
|
|
|
//
|
|
// Time for shutdown and planned duration of shutdown in minutes
|
|
//
|
|
$shutdownDateTime = "2026-08-03 23:00:00";
|
|
$shutdownDuration = 120;
|
|
|
|
|
|
|
|
|
|
$shutdownTime = strtotime($shutdownDateTime);
|
|
$now = time();
|
|
|
|
if (isset($school_record) && is_array($school_record)) date_default_timezone_set($school_record['timezone']);
|
|
// writeLog("timezone: ".$school_record['timezone']);
|
|
|
|
|
|
$sTime = date("g:i a",$shutdownTime);
|
|
$completionTime = date("g:i a",$shutdownTime + abs($shutdownDuration) * 60);
|
|
// writeLog("completionTime: $completionTime");
|
|
|
|
$totalSeconds = $shutdownTime - $now;
|
|
$totalMinutes = intval($totalSeconds / 60);
|
|
|
|
|
|
// Restore system automatically after specified minutes
|
|
if ($totalMinutes <= (-1 * $shutdownDuration)) return;
|
|
|
|
if ($totalSeconds <= 0) {
|
|
?>
|
|
<p><b>Shutdown Time: <?php echo($sTime) ?></b></p>
|
|
<p><b>Time Now: <?php echo(date("g:i:s a",time())) ?></b></p>
|
|
<p><b>Planned Completion Time: <?php echo($completionTime) ?></b></p>
|
|
<p><b>We are performing an application upgrade and will be down for a short while.</b></p>
|
|
|
|
<p><b>Please check back soon.</b></p>
|
|
<p><?php echo($school_num) ?></p>
|
|
<?php
|
|
exit;
|
|
}
|
|
else {
|
|
if ($totalMinutes > 60) {
|
|
$hours = intval($totalMinutes / 60);
|
|
$minutes = sprintf("%02d",($totalMinutes % 60));
|
|
$totalMinutes = "$hours hours and $minutes";
|
|
}
|
|
|
|
if ($totalMinutes > 1) {
|
|
if ($totalMinutes > 5) {
|
|
$style = "color: black; background-color:#ff9933; font-weight: bold; width: 100%; padding: 15px 0 15px 0;";
|
|
$maintenance_message = "We will be shutting down the application for an application update in $totalMinutes minutes at $sTime";
|
|
}
|
|
else {
|
|
$style = "color: white; background-color:#ff5500; font-weight: bold; width: 100%; padding: 15px 0 15px 0;";
|
|
$maintenance_message = "We will be shutting down the application for an application update in $totalMinutes minutes at $sTime";
|
|
}
|
|
}
|
|
else {
|
|
$style = "color: white; background-color:#ff0000; font-weight: bold; width: 100%; padding: 15px 0 15px 0;";
|
|
$maintenance_message = "We will be shutting down the application for an application update in $totalMinutes minutes at $sTime";
|
|
}
|
|
|
|
$maintenance_message .= "<br>Planned Completion Time: $completionTime";
|
|
$maintenance_message = "<p style='$style'>$maintenance_message</p><p>$school_num</p>";
|
|
}
|
|
|
|
?>
|