Exemplo n.º 1
0
function choose_page($page)
{
    if ($page !== "" && $page[0] === "~") {
        $xpage = Navigation::path_component(0, true);
        Navigation::set_path("/" . $page . Navigation::path_suffix(1));
        $page = Navigation::set_page($xpage ?: "index");
    }
    $i = strlen($page) - 4;
    if ($i > 0 && substr($page, $i) === ".php") {
        $page = substr($page, 0, $i);
    }
    if ($page === "index") {
        return null;
    }
    if (is_readable($page . ".php") && strpos($page, "/") === false) {
        return $page . ".php";
    } else {
        if (preg_match(',\\A(?:images|scripts|stylesheets)\\z,', $page)) {
            $_REQUEST["file"] = $page . Navigation::path();
            return "cacheable.php";
        } else {
            Navigation::redirect_site("index");
        }
    }
}
Exemplo n.º 2
0
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;
    }
}
Exemplo n.º 3
0
<?php

// index.php -- HotCRP home page
// HotCRP is Copyright (c) 2006-2016 Eddie Kohler and Regents of the UC
// Distributed under an MIT-like license; see LICENSE
require_once "lib/navigation.php";
if (Navigation::page() !== "index") {
    $page = Navigation::page();
    if (is_readable("{$page}.php") && strpos($page, "/") === false) {
        include "{$page}.php";
        exit;
    } else {
        if ($page == "images" || $page == "scripts" || $page == "stylesheets") {
            $_REQUEST["file"] = $page . Navigation::path();
            include "cacheable.php";
            exit;
        } else {
            Navigation::redirect_site("index");
        }
    }
}
require_once "pages/home.php";