本文整理汇总了PHP中Navigation::redirect_site方法的典型用法代码示例。如果您正苦于以下问题:PHP Navigation::redirect_site方法的具体用法?PHP Navigation::redirect_site怎么用?PHP Navigation::redirect_site使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Navigation
的用法示例。
在下文中一共展示了Navigation::redirect_site方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: choose_page
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");
}
}
}
示例2: initialize_user
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;
}
}
示例3:
<?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";