Beispiel #1
0
/**
 *
 * @return array An array of the groups
 */
function pollDarwinGroups($allowDB = TRUE)
{
    global $DARWIN__GROUPS;
    if (isset($_SERVER['AP_MAD_GIDS'])) {
        $groups = preg_split("/,/", $_SERVER['AP_MAD_GIDS']);
        setDarwinGroups($groups);
    } else {
        if (function_exists('getDarwinGroups') && $allowDB) {
            $groups = getDarwinGroups();
        } else {
            if (isset($DARWIN__GROUPS) && $DARWIN__GROUPS !== FALSE) {
                $groups = $DARWIN__GROUPS;
            } else {
                $groups = array();
            }
        }
    }
    if ($groups == NULL) {
        return array();
    }
    return $groups;
}
Beispiel #2
0
<?php

error_reporting(E_ALL);
error_log(__FILE__ . ": Trying to log in user");
ini_set('display_errors', 'On');
require_once '../lib/common.php';
require_once '../lib/authadmin.php';
$groups = getDarwinGroups();
if (!is_admin()) {
    handleError("You are not an administrator", 403, "FORBIDDEN");
    exit;
}
if (!isset($_REQUEST['newuser'])) {
    handleError("Darwin - Please provide the new user in the newuser parameter", 400, "Bad Request");
    exit;
}
if (isset($HEADERS["Accept"])) {
    $accept = $HEADERS["Accept"];
} else {
    $accept = "";
}
if (strpos($accept, "text/html") === False) {
    $htmloutput = false;
    header("Content-type: text/plain");
} else {
    $htmloutput = true;
}
$MAXTOKENLIFETIME = 86400;
// Tokens remain valid for one day on the client side (becomes invalid after half hour of inactivity on the server)
if ($db = getAuthDb()) {
    $authtoken = getauthtoken($db, $_REQUEST['newuser'], $_SERVER["REMOTE_ADDR"]);