示例#1
0
/**
 * Try to get the user for the app, but don't use the database.
 * @return string The known user, or FALSE if there is none
 */
function pollDarwinUser($allowDB = TRUE)
{
    global $DARWIN__USER;
    if (isset($_SERVER['AP_MAD_UID'])) {
        // Set the user through server variables before trying to get the user ourselves
        $user = $_SERVER['AP_MAD_UID'];
    } else {
        if (isset($_SERVER['PHP_AUTH_USER'])) {
            $user = $_SERVER['PHP_AUTH_USER'];
        } else {
            if (function_exists('getDarwinUser') && $allowDB) {
                $user = getDarwinUser();
            } else {
                if (isset($DARWIN__USER) && $DARWIN__USER !== False) {
                    $user = $DARWIN__USER;
                } else {
                    $user = NULL;
                }
            }
        }
    }
    setDarwinUser($user);
    return $user;
}
示例#2
0
{
    darwinHeader("Bye", "Bye - Logged out");
    echo "<p>You have successfully logged out</p>";
    darwinFooter();
}
$HEADERS = getallheaders();
$accept = $HEADERS["Accept"];
if (strpos($accept, "text/html") === False) {
    $htmloutput = false;
    header("Content-type: text/plain");
} else {
    $htmloutput = true;
}
$MAXTOKENLIFETIME = 1800;
// Tokens remain valid for half hour
$user = getDarwinUser();
if ($user !== NULL) {
    if (isset($_COOKIE[$DARWINCOOKIENAME])) {
        $authtoken = str_replace(" ", "+", $_COOKIE[$DARWINCOOKIENAME]);
    }
    unset($_COOKIE[$DARWINCOOKIENAME]);
    $cookieexpire = 1;
    if (isset($_SERVER['HTTP_HOST'])) {
        $host = $_SERVER['HTTP_HOST'];
        $secure = $host != 'localhost';
        if (!$secure) {
            $host = NULL;
        }
    } else {
        $host = 'darwin.bournemouth.ac.uk';
        $secure = TRUE;