function AJeditSiteMaintenance() { global $user; $id = getContinuationVar('id'); $data = processSiteMaintenanceInput(); $olddata = getMaintItems($id); $start = datetimeToUnix($olddata[$id]['start']); if (!deleteMaintenanceFile($start) || !writeMaintenanceFile($data['startts'], $data['endts'], $data['usermessage'])) { print "alert('Failed to modify maintenance file on web server.\\n"; print "Please have sysadmin check permissions on maintenance directory.');\n"; print "dijit.byId('confirmDialog').hide();"; $data['err'] = 1; } if ($data['err']) { $data = array('id' => $id, 'update' => 1); $cont = addContinuationsEntry('AJeditSiteMaintenance', $data, SECINDAY, 1, 0); print "dojo.byId('submitcont').value = '{$cont}';"; return; } $reason = mysql_real_escape_string($data['reason']); $usermessage = mysql_real_escape_string($data['usermessage']); $query = "UPDATE sitemaintenance " . "SET start = '{$data['startdt']}', " . "end = '{$data['enddt']}', " . "ownerid = {$user['id']}, " . "created = NOW(), " . "reason = '{$reason}', " . "usermessage = '{$usermessage}', " . "informhoursahead = {$data['hoursahead']}, " . "allowreservations = {$data['allowreservations']} " . "WHERE id = {$id}"; doQuery($query, 101); $_SESSION['usersessiondata'] = array(); print "window.location.href = '" . BASEURL . SCRIPT . "?mode=siteMaintenance';"; #print "clearEdit();"; #siteMaintenance(); }
function maintenanceNotice() { $items = getMaintItems(); foreach ($items as $item) { $start = datetimeToUnix($item['start']); $file = date('YmdHi', $start); $secahead = $item['informhoursahead'] * 3600; if ($start - $secahead < time()) { $reg = "|" . SCRIPT . "\$|"; $search = preg_replace($reg, '', $_SERVER['SCRIPT_FILENAME']); $search .= "/.ht-inc/maintenance/{$file}"; $files = glob("{$search}"); if (empty($files)) { $_SESSION['usersessiondata'] = array(); return; } $nicestart = strftime('%A, %x, %l:%M %P', $start); $niceend = strftime('%A, %x, %l:%M %P', datetimeToUnix($item['end'])); print "<div id=\"maintenancenotice\">\n"; print "<strong>" . i("NOTICE:") . "</strong> "; print i("This site will be down for maintenance during the following times:") . "<br><br>\n"; print i("Start:") . " {$nicestart}<br>\n"; print i("End:") . " {$niceend}.<br><br>\n"; if ($item['allowreservations']) { print i("You will be able to access your reserved machines during this maintenance. However, you will not be able to access information on how to connect to them.") . "<br>\n"; } else { print i("You will not be able to access any of your reservations during this maintenance.") . "<br>\n"; } print "</div>\n"; return; } } }