function initialize_user() { global $Conf, $Me; // load current user $Me = null; $trueuser = get($_SESSION, "trueuser"); if ($trueuser && $trueuser->email) { $Me = $Conf->user_by_email($trueuser->email); } if (!$Me) { $Me = new Contact($trueuser); } $Me = $Me->activate(); // redirect if disabled if ($Me->disabled) { if (Navigation::page() === "api") { json_exit(["ok" => false, "error" => "Your account is disabled."]); } else { if (Navigation::page() !== "index") { Navigation::redirect_site(hoturl_site_relative("index")); } } } // if bounced through login, add post data if (isset($_SESSION["login_bounce"]) && !$Me->is_empty()) { $lb = $_SESSION["login_bounce"]; if ($lb[0] == $Conf->dsn && $lb[2] !== "index" && $lb[2] == Navigation::page()) { foreach ($lb[3] as $k => $v) { if (!isset($_REQUEST[$k])) { $_REQUEST[$k] = $_GET[$k] = $v; } } $_REQUEST["after_login"] = 1; } unset($_SESSION["login_bounce"]); } // set $_SESSION["addrs"] if ($_SERVER["REMOTE_ADDR"] && (!is_array(get($_SESSION, "addrs")) || get($_SESSION["addrs"], 0) !== $_SERVER["REMOTE_ADDR"])) { $as = array($_SERVER["REMOTE_ADDR"]); if (is_array(get($_SESSION, "addrs"))) { foreach ($_SESSION["addrs"] as $a) { if ($a !== $_SERVER["REMOTE_ADDR"] && count($as) < 5) { $as[] = $a; } } } $_SESSION["addrs"] = $as; } }
function selfHref($extra = array(), $options = null) { global $Opt; // clean parameters from pathinfo URLs foreach (array("paperId" => "p", "pap" => "p", "reviewId" => "r", "commentId" => "c") as $k => $v) { if (isset($_REQUEST[$k]) && !isset($_REQUEST[$v])) { $_REQUEST[$v] = $_REQUEST[$k]; } } $param = ""; foreach (array("p", "r", "c", "m", "u", "g", "fx", "fy", "mode", "forceShow", "validator", "ls", "list", "t", "q", "qa", "qo", "qx", "qt", "tab", "atab", "group", "sort", "monreq", "noedit", "contact", "reviewer") as $what) { if (isset($_REQUEST[$what]) && !array_key_exists($what, $extra) && !is_array($_REQUEST[$what])) { $param .= "&{$what}=" . urlencode($_REQUEST[$what]); } } foreach ($extra as $key => $value) { if ($key != "anchor" && $value !== null) { $param .= "&{$key}=" . urlencode($value); } } if (!isset($_REQUEST["ls"]) && !array_key_exists("ls", $extra) && ($list = SessionList::active())) { $param .= "&ls=" . $list->listno; } $param = $param ? substr($param, 1) : ""; if (!$options || !@$options["site_relative"]) { $uri = hoturl(Navigation::page(), $param); } else { $uri = hoturl_site_relative(Navigation::page(), $param); } if (isset($extra["anchor"])) { $uri .= "#" . $extra["anchor"]; } $uri = str_replace("&", "&", $uri); if (!$options || @$options["raw"]) { return $uri; } else { return htmlspecialchars($uri); } }