static function fail_message($errors)
 {
     global $Conf, $Me, $Opt;
     if (is_string($errors)) {
         $errors = array($errors);
     }
     if (@$Opt["maintenance"]) {
         $errors = array("The site is down for maintenance. " . (is_string($Opt["maintenance"]) ? $Opt["maintenance"] : "Please check back later."));
     }
     if (PHP_SAPI == "cli") {
         fwrite(STDERR, join("\n", $errors) . "\n");
         exit(1);
     } else {
         if (@$_REQUEST["ajax"]) {
             header("Content-Type: " . (@$_REQUEST["jsontext"] ? "text/plain" : "application/json"));
             if (@$Opt["maintenance"]) {
                 echo "{\"error\":\"maintenance\"}\n";
             } else {
                 echo "{\"error\":\"unconfigured installation\"}\n";
             }
         } else {
             if (!$Conf) {
                 $Conf = Conf::$g = new Conf(false);
             }
             if ($Opt["shortName"] == "__invalid__") {
                 $Opt["shortName"] = "HotCRP";
             }
             $Me = null;
             header("HTTP/1.1 404 Not Found");
             $Conf->header("HotCRP Error", "", false);
             foreach ($errors as $i => &$e) {
                 $e = ($i ? "<div class=\"hint\">" : "<p>") . htmlspecialchars($e) . ($i ? "</div>" : "</p>");
             }
             echo join("", $errors);
             $Conf->footer();
         }
     }
     exit;
 }
示例#2
0
    }
}
if (!get($Opt, "loaded") || get($Opt, "missing")) {
    Multiconference::fail_bad_options();
}
if (get($Opt, "dbLogQueries")) {
    Dbl::log_queries($Opt["dbLogQueries"]);
}
// Allow lots of memory
function set_memory_limit()
{
    global $Opt;
    if (!get($Opt, "memoryLimit")) {
        $suf = array("" => 1, "k" => 1 << 10, "m" => 1 << 20, "g" => 1 << 30);
        if (preg_match(',\\A(\\d+)\\s*([kmg]?)\\z,', strtolower(ini_get("memory_limit")), $m) && $m[1] * $suf[$m[2]] < 128 << 20) {
            $Opt["memoryLimit"] = "128M";
        }
    }
    if (get($Opt, "memoryLimit")) {
        ini_set("memory_limit", $Opt["memoryLimit"]);
    }
}
set_memory_limit();
// Create the conference
global $Conf;
if (!$Conf) {
    $Conf = Conf::$g = new Conf(Dbl::make_dsn($Opt));
}
if (!$Conf->dblink) {
    Multiconference::fail_bad_database();
}
示例#3
0
    Multiconference::fail_bad_options();
}
if (get($Opt, "dbLogQueries")) {
    Dbl::log_queries($Opt["dbLogQueries"]);
}
// Allow lots of memory
if (!get($Opt, "memoryLimit") && ini_get_bytes("memory_limit") < 128 << 20) {
    $Opt["memoryLimit"] = "128M";
}
if (get($Opt, "memoryLimit")) {
    ini_set("memory_limit", $Opt["memoryLimit"]);
}
// Create the conference
global $Conf;
if (!$Conf) {
    $Conf = Conf::$g = new Conf($Opt, true);
}
if (!$Conf->dblink) {
    Multiconference::fail_bad_database();
}
// Extract problem set information
function psets_json_data($exclude_overrides)
{
    global $Conf;
    $datamap = array();
    $fnames = expand_includes($Conf->opt("psetsConfig"), ["CONFID" => $Conf->opt("confid") ?: $Conf->dbname, "HOSTTYPE" => $Conf->opt("hostType", "")]);
    foreach ($fnames as $fname) {
        $datamap[$fname] = @file_get_contents($fname);
    }
    if (!$exclude_overrides && ($override_data = $Conf->setting_data("psets_override"))) {
        $datamap["<overrides>"] = $override_data;