static function init() { global $Opt; $confid = @$Opt["confid"]; if (!$confid && PHP_SAPI == "cli") { $cliopt = getopt("n:", array("name:")); if (@$cliopt["n"]) { $confid = $cliopt["n"]; } else { if (@$cliopt["name"]) { $confid = $cliopt["name"]; } } } else { if (!$confid) { $base = Navigation::site_absolute(true); if ($multis = @$Opt["multiconferenceAnalyzer"]) { foreach (is_array($multis) ? $multis : array($multis) as $multi) { list($match, $replace) = explode(" ", $multi); if (preg_match("`\\A{$match}`", $base, $m)) { $confid = $replace; for ($i = 1; $i < count($m); ++$i) { $confid = str_replace("\${$i}", $m[$i], $confid); } break; } } } else { if (preg_match(',/([^/]+)/\\z,', $base, $m)) { $confid = $m[1]; } } } } if (!@$confid) { $confid = "__nonexistent__"; } else { if (!preg_match(',\\A[-a-zA-Z0-9_][-a-zA-Z0-9_.]*\\z,', $confid)) { $confid = "__invalid__"; } } foreach (array("dbName", "dbUser", "dbPassword", "dsn") as $k) { if (isset($Opt[$k]) && is_string($Opt[$k])) { $Opt[$k] = preg_replace(',\\*|\\$\\{conf(?:id|name)\\}|\\$conf(?:id|name)\\b,', $confid, $Opt[$k]); } } if (!@$Opt["dbName"] && !@$Opt["dsn"]) { $Opt["dbName"] = $confid; } $Opt["confid"] = $confid; }
static function init() { global $Opt; assert(self::$original_opt === null); self::$original_opt = $Opt; $confid = get($Opt, "confid"); if (!$confid && PHP_SAPI == "cli") { $cliopt = getopt("n:", array("name:")); if (get($cliopt, "n")) { $confid = $cliopt["n"]; } else { if (get($cliopt, "name")) { $confid = $cliopt["name"]; } } } else { if (!$confid) { $base = Navigation::site_absolute(true); if ($multis = get($Opt, "multiconferenceAnalyzer")) { foreach (is_array($multis) ? $multis : array($multis) as $multi) { list($match, $replace) = explode(" ", $multi); if (preg_match("`\\A{$match}`", $base, $m)) { $confid = $replace; for ($i = 1; $i < count($m); ++$i) { $confid = str_replace("\${$i}", $m[$i], $confid); } break; } } } else { if (preg_match(',/([^/]+)/\\z,', $base, $m)) { $confid = $m[1]; } } } } if (!$confid) { $confid = "__nonexistent__"; } else { if (!preg_match(',\\A[-a-zA-Z0-9_][-a-zA-Z0-9_.]*\\z,', $confid)) { $confid = "__invalid__"; } } self::assign_confid($Opt, $confid); }
private function crosscheck_options() { global $Opt, $ConfSitePATH; // set longName, downloadPrefix, etc. $confid = $Opt["confid"]; if ((!isset($Opt["longName"]) || $Opt["longName"] == "") && (!isset($Opt["shortName"]) || $Opt["shortName"] == "")) { $Opt["shortNameDefaulted"] = true; $Opt["longName"] = $Opt["shortName"] = $confid; } else { if (!isset($Opt["longName"]) || $Opt["longName"] == "") { $Opt["longName"] = $Opt["shortName"]; } else { if (!isset($Opt["shortName"]) || $Opt["shortName"] == "") { $Opt["shortName"] = $Opt["longName"]; } } } if (!isset($Opt["downloadPrefix"]) || $Opt["downloadPrefix"] == "") { $Opt["downloadPrefix"] = $confid . "-"; } self::$gShortName = $Opt["shortName"]; self::$gLongName = $Opt["longName"]; // expand ${confid}, ${confshortname} foreach (array("sessionName", "downloadPrefix", "conferenceSite", "paperSite", "defaultPaperSite", "contactName", "contactEmail", "docstore") as $k) { if (isset($Opt[$k]) && is_string($Opt[$k]) && strpos($Opt[$k], "\$") !== false) { $Opt[$k] = preg_replace(',\\$\\{confid\\}|\\$confid\\b,', $confid, $Opt[$k]); $Opt[$k] = preg_replace(',\\$\\{confshortname\\}|\\$confshortname\\b,', $Opt["shortName"], $Opt[$k]); } } foreach (array("emailFrom", "emailSender", "emailCc", "emailReplyTo") as $k) { if (isset($Opt[$k]) && is_string($Opt[$k]) && strpos($Opt[$k], "\$") !== false) { $Opt[$k] = preg_replace(',\\$\\{confid\\}|\\$confid\\b,', $confid, $Opt[$k]); if (strpos($Opt[$k], "confshortname") !== false) { $v = rfc2822_words_quote($Opt["shortName"]); if ($v[0] === "\"" && strpos($Opt[$k], "\"") !== false) { $v = substr($v, 1, strlen($v) - 2); } $Opt[$k] = preg_replace(',\\$\\{confshortname\\}|\\$confshortname\\b,', $v, $Opt[$k]); } } } // remove final slash from $Opt["paperSite"] if (!isset($Opt["paperSite"]) || $Opt["paperSite"] == "") { $Opt["paperSite"] = Navigation::site_absolute(); } if ($Opt["paperSite"] == "" && isset($Opt["defaultPaperSite"])) { $Opt["paperSite"] = $Opt["defaultPaperSite"]; } $Opt["paperSite"] = preg_replace('|/+\\z|', "", $Opt["paperSite"]); // option name updates (backwards compatibility) foreach (array("assetsURL" => "assetsUrl", "jqueryURL" => "jqueryUrl", "jqueryCDN" => "jqueryCdn", "disableCSV" => "disableCsv") as $kold => $knew) { if (isset($Opt[$kold]) && !isset($Opt[$knew])) { $Opt[$knew] = $Opt[$kold]; } } // set assetsUrl and scriptAssetsUrl if (!isset($Opt["scriptAssetsUrl"]) && isset($_SERVER["HTTP_USER_AGENT"]) && strpos($_SERVER["HTTP_USER_AGENT"], "MSIE") !== false) { $Opt["scriptAssetsUrl"] = Navigation::siteurl(); } if (!isset($Opt["assetsUrl"])) { $Opt["assetsUrl"] = Navigation::siteurl(); } if ($Opt["assetsUrl"] !== "" && !str_ends_with($Opt["assetsUrl"], "/")) { $Opt["assetsUrl"] .= "/"; } if (!isset($Opt["scriptAssetsUrl"])) { $Opt["scriptAssetsUrl"] = $Opt["assetsUrl"]; } Ht::$img_base = $Opt["assetsUrl"] . "images/"; // set docstore if (get($Opt, "docstore") === true) { $Opt["docstore"] = "docs"; } else { if (!get($Opt, "docstore") && get($Opt, "filestore")) { // backwards compat if (($Opt["docstore"] = $Opt["filestore"]) === true) { $Opt["docstore"] = "filestore"; } $Opt["docstoreSubdir"] = get($Opt, "filestoreSubdir"); } } if (get($Opt, "docstore") && $Opt["docstore"][0] !== "/") { $Opt["docstore"] = $ConfSitePATH . "/" . $Opt["docstore"]; } // handle timezone if (function_exists("date_default_timezone_set")) { if (isset($Opt["timezone"])) { if (!date_default_timezone_set($Opt["timezone"])) { self::msg_error("Timezone option “" . htmlspecialchars($Opt["timezone"]) . "” is invalid; falling back to “America/New_York”."); date_default_timezone_set("America/New_York"); } } else { if (!ini_get("date.timezone") && !getenv("TZ")) { date_default_timezone_set("America/New_York"); } } } // set safePasswords if (!get($Opt, "safePasswords") || is_int($Opt["safePasswords"]) && $Opt["safePasswords"] < 1) { $Opt["safePasswords"] = 0; } else { if ($Opt["safePasswords"] === true) { $Opt["safePasswords"] = 1; } } if (!isset($Opt["contactdb_safePasswords"])) { $Opt["contactdb_safePasswords"] = $Opt["safePasswords"]; } // set defaultFormat self::$gDefaultFormat = (int) get($Opt, "defaultFormat"); self::$gFormatInfo = null; }
static function contact_tracker_comet($pids = null) { global $Opt, $Now; $comet_dir = get($Opt, "trackerCometUpdateDirectory"); $comet_url = get($Opt, "trackerCometSite"); if (!$comet_dir && !$comet_url) { return; } // calculate status $conference = Navigation::site_absolute(); $tracker = self::lookup(); // first drop notification json in trackerCometUpdateDirectory if ($comet_dir) { $j = array("ok" => true, "conference" => $conference, "tracker_status" => self::tracker_status($tracker), "tracker_status_at" => $tracker->position_at); if ($pids) { $j["pulse"] = true; } if (!str_ends_with($comet_dir, "/")) { $comet_dir .= "/"; } $suffix = ""; $count = 0; while (($f = @fopen($comet_dir . $Now . $suffix, "x")) === false && $count < 20) { $suffix = "x" . mt_rand(0, 65535); ++$count; } if ($f !== false) { fwrite($f, json_encode($j)); fclose($f); return; } else { trigger_error("{$comet_dir} not writable", E_USER_WARNING); } } // second contact trackerCometSite if (!$comet_url) { return; } if (!preg_match(',\\Ahttps?:,', $comet_url)) { preg_match(',\\A(.*:)(//[^/]*),', $conference, $m); if ($comet_url[0] !== "/") { $comet_url = "/" . $comet_url; } if (preg_match(',\\A//,', $comet_url)) { $comet_url = $m[1] . $comet_url; } else { $comet_url = $m[1] . $m[2] . $comet_url; } } if (!str_ends_with($comet_url, "/")) { $comet_url .= "/"; } $context = stream_context_create(array("http" => array("method" => "GET", "ignore_errors" => true, "content" => "", "timeout" => 1.0))); $comet_url .= "update?conference=" . urlencode($conference) . "&tracker_status=" . urlencode(self::tracker_status($tracker)) . "&tracker_status_at=" . $tracker->position_at; if ($pids) { $comet_url .= "&pulse=1"; } $stream = @fopen($comet_url, "r", false, $context); if (!$stream) { $e = error_get_last(); error_log($comet_url . ": " . $e["message"]); return false; } if (!($data = stream_get_contents($stream)) || !($data = json_decode($data))) { error_log($comet_url . ": read failure"); } fclose($stream); }
private function crosscheck_options() { global $Opt, $ConfSiteBase; // set longName, downloadPrefix, etc. $confid = $Opt["confid"]; if ((!isset($Opt["longName"]) || $Opt["longName"] == "") && (!isset($Opt["shortName"]) || $Opt["shortName"] == "")) { $Opt["shortNameDefaulted"] = true; $Opt["longName"] = $Opt["shortName"] = $confid; } else { if (!isset($Opt["longName"]) || $Opt["longName"] == "") { $Opt["longName"] = $Opt["shortName"]; } else { if (!isset($Opt["shortName"]) || $Opt["shortName"] == "") { $Opt["shortName"] = $Opt["longName"]; } } } if (!isset($Opt["downloadPrefix"]) || $Opt["downloadPrefix"] == "") { $Opt["downloadPrefix"] = $confid . "-"; } // expand ${confid}, ${confshortname} foreach (array("sessionName", "downloadPrefix", "conferenceSite", "paperSite", "defaultPaperSite", "contactName", "contactEmail", "emailFrom", "emailSender", "emailCc", "emailReplyTo") as $k) { if (isset($Opt[$k]) && is_string($Opt[$k]) && strpos($Opt[$k], "\$") !== false) { $Opt[$k] = preg_replace(',\\$\\{confid\\}|\\$confid\\b,', $confid, $Opt[$k]); $Opt[$k] = preg_replace(',\\$\\{confshortname\\}|\\$confshortname\\b,', $Opt["shortName"], $Opt[$k]); } } // remove final slash from $Opt["paperSite"] if (!isset($Opt["paperSite"]) || $Opt["paperSite"] == "") { $Opt["paperSite"] = Navigation::site_absolute(); } if ($Opt["paperSite"] == "" && isset($Opt["defaultPaperSite"])) { $Opt["paperSite"] = $Opt["defaultPaperSite"]; } $Opt["paperSite"] = preg_replace('|/+\\z|', "", $Opt["paperSite"]); // set assetsUrl and scriptAssetsUrl if (!isset($Opt["scriptAssetsUrl"]) && isset($_SERVER["HTTP_USER_AGENT"]) && strpos($_SERVER["HTTP_USER_AGENT"], "MSIE") !== false) { $Opt["scriptAssetsUrl"] = $ConfSiteBase; } if (!isset($Opt["assetsUrl"])) { $Opt["assetsUrl"] = $ConfSiteBase; } if ($Opt["assetsUrl"] !== "" && !str_ends_with($Opt["assetsUrl"], "/")) { $Opt["assetsUrl"] .= "/"; } if (!isset($Opt["scriptAssetsUrl"])) { $Opt["scriptAssetsUrl"] = $Opt["assetsUrl"]; } Ht::$img_base = $Opt["assetsUrl"] . "images/"; // set docstore from filestore if (@$Opt["docstore"] === true) { $Opt["docstore"] = "docs"; } else { if (!@$Opt["docstore"] && @$Opt["filestore"]) { if (($Opt["docstore"] = $Opt["filestore"]) === true) { $Opt["docstore"] = "filestore"; } $Opt["docstoreSubdir"] = @$Opt["filestoreSubdir"]; } } // handle timezone if (function_exists("date_default_timezone_set")) { if (isset($Opt["timezone"])) { if (!date_default_timezone_set($Opt["timezone"])) { $this->errorMsg("Timezone option “" . htmlspecialchars($Opt["timezone"]) . "” is invalid; falling back to “America/New_York”."); date_default_timezone_set("America/New_York"); } } else { if (!ini_get("date.timezone") && !getenv("TZ")) { date_default_timezone_set("America/New_York"); } } } // set safePasswords if (!@$Opt["safePasswords"] || is_int($Opt["safePasswords"]) && $Opt["safePasswords"] < 1) { $Opt["safePasswords"] = 0; } else { if ($Opt["safePasswords"] === true) { $Opt["safePasswords"] = 1; } } }