Initial commit.
This commit is contained in:
52
lib/php/monica/unauth.inc.php
Normal file
52
lib/php/monica/unauth.inc.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
// File name: unauth.inc.php
|
||||
// Description: PHP subroutines to handle authentication failures
|
||||
// Date: 2004-03-24
|
||||
// Author: imacat <imacat@pristine.com.tw>
|
||||
// Copyright: Copyright (C) 2004-2008 Pristine Communications
|
||||
|
||||
// Set the include path
|
||||
if (!defined("INCPATH_SET")) {
|
||||
require_once dirname(__FILE__) . "/incpath.inc.php";
|
||||
}
|
||||
// Referenced subroutines
|
||||
require_once "monica/cgiemu.inc.php";
|
||||
require_once "monica/formfunc.inc.php";
|
||||
require_once "monica/http.inc.php";
|
||||
require_once "monica/login.inc.php";
|
||||
require_once "monica/requri.inc.php";
|
||||
require_once "monica/userhome.inc.php";
|
||||
|
||||
// unauth: User is not authorized
|
||||
function unauth($msg = null)
|
||||
{
|
||||
// Not logged in yet -- log in
|
||||
if (is_null(get_login_sn())) {
|
||||
$url = userhome();
|
||||
$args = array();
|
||||
// Referer not needed for users' home pages
|
||||
if (!in_array(REQUEST_PATH, array(ADMIN_HOME, NONADMIN_HOME))) {
|
||||
$args[] = "referer=" . urlencode(REQUEST_FULLURI);
|
||||
// Referer not recorded -- keep the status message
|
||||
} else {
|
||||
$FORM =& get_or_post();
|
||||
if (array_key_exists("statid", $FORM)) {
|
||||
$args[] = "statid=" . urlencode($FORM["statid"]);
|
||||
}
|
||||
}
|
||||
if (count($args) > 0) {
|
||||
$url .= "?" . implode("&", $args);
|
||||
}
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
http_303($url);
|
||||
} else {
|
||||
http_307($url);
|
||||
}
|
||||
|
||||
// Logged in but privilege not enough
|
||||
} else {
|
||||
http_403($msg);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user