Ejemplo n.º 1
0
$authed = '';
$semid = '';
$semislocked = '';
unset($GLOBALS['php_errormsg']);
$cache['nodes'] = array();
$cache['unityids'] = array();
$cache['nodeprivs']['resources'] = array();
$docreaders = array();
$shibauthed = 0;
$locale = '';
require_once ".ht-inc/states.php";
require_once '.ht-inc/errors.php';
require_once '.ht-inc/utils.php';
maintenanceCheck();
dbConnect();
setVCLLocale();
initGlobals();
$modes = array_keys($actions['mode']);
$args = array_keys($actions['args']);
$hasArg = 0;
if (in_array($mode, $modes)) {
    $actionFunction = $actions['mode'][$mode];
    if (in_array($mode, $args)) {
        $hasArg = 1;
        $arg = $actions['args'][$mode];
    }
} else {
    $actionFunction = "main";
}
checkAccess();
sendHeaders();
Ejemplo n.º 2
0
function maintenanceCheck()
{
    global $authed, $mode, $user;
    $now = time();
    $reg = "|" . SCRIPT . "\$|";
    $search = preg_replace($reg, '', $_SERVER['SCRIPT_FILENAME']);
    $search .= "/.ht-inc/maintenance/";
    $files = glob("{$search}[0-9]*");
    if (!is_array($files)) {
        return;
    }
    if (empty($files)) {
        dbConnect();
        $query = "SELECT id " . "FROM sitemaintenance " . "WHERE start <= NOW() AND " . "end > NOW()";
        $qh = doQuery($query);
        $ids = array();
        while ($row = mysql_fetch_assoc($qh)) {
            $ids[] = $row['id'];
        }
        if (empty($ids)) {
            dbDisconnect();
            return;
        }
        $allids = implode(',', $ids);
        $query = "UPDATE sitemaintenance " . "SET end = NOW() " . "WHERE id IN ({$allids})";
        doQuery($query, 101, 'vcl', 1);
        dbDisconnect();
        return;
    }
    $inmaintenance = 0;
    foreach ($files as $file) {
        if (!preg_match("|^{$search}([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})\$|", $file, $matches)) {
            continue;
        }
        #YYYYMMDDHHMM
        $tmp = "{$matches[1]}-{$matches[2]}-{$matches[3]} {$matches[4]}:{$matches[5]}:00";
        $start = datetimeToUnix($tmp);
        if ($start < $now) {
            # check to see if end time has been reached
            $fh = fopen($file, 'r');
            $msg = '';
            while ($line = fgetss($fh)) {
                if (preg_match("/^END=([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})\$/", $line, $matches)) {
                    $tmp = "{$matches[1]}-{$matches[2]}-{$matches[3]} {$matches[4]}:{$matches[5]}:00";
                    $end = datetimeToUnix($tmp);
                    if ($end < $now) {
                        fclose($fh);
                        unlink($file);
                        $_SESSION['usersessiondata'] = array();
                        return;
                    } else {
                        $inmaintenance = 1;
                    }
                } else {
                    $msg .= $line;
                }
            }
            fclose($fh);
            if ($inmaintenance) {
                break;
            }
        }
    }
    if ($inmaintenance) {
        $authed = 0;
        $mode = 'inmaintenance';
        $user = array();
        if (array_key_exists('VCLSKIN', $_COOKIE)) {
            $skin = strtolower($_COOKIE['VCLSKIN']);
        } else {
            $skin = DEFAULTTHEME;
        }
        setVCLLocale();
        require_once "themes/{$skin}/page.php";
        printHTMLHeader();
        print "<h2>" . i("Site Currently Under Maintenance") . "</h2>\n";
        if (!empty($msg)) {
            $msg = htmlentities($msg);
            $msg = preg_replace("/\n/", "<br>\n", $msg);
            print "{$msg}<br>\n";
        } else {
            print i("This site is currently in maintenance.") . "<br>\n";
        }
        $niceend = strftime('%A, %x, %l:%M %P', $end);
        printf(i("The maintenance is scheduled to end <strong>%s</strong>.") . "<br><br><br>\n", $niceend);
        printHTMLFooter();
        exit;
    }
}