Beispiel #1
0
 function createToken($usernameFromAuth, $clientname)
 {
     $badToken = true;
     $token = false;
     $this->username = $usernameFromAuth;
     while ($badToken) {
         $proposedTokenNumber = rand(1, 999999) + NODE_TOKEN_PREFIX;
         $checkToken = new NodeToken();
         if ($checkToken->retrieveToken($proposedTokenNumber) == false) {
             $this->tokenNumber = $proposedTokenNumber;
             $badToken = false;
         } else {
             $proposedTokenNumber = 0;
             $badToken = true;
         }
         unset($checkToken);
     }
     if (!ctype_alnum($clientname)) {
         $clientname = "default";
     }
     $this->clientname = $clientname;
     $this->expire = time() + TOKEN_LIFE;
     $this->uid = $this->uidFromUsername($this->username);
     if ($this->uid > 0) {
         $this->destroyUserClientTokens($this->uid, $this->clientname);
         $insertQuery = "INSERT INTO tokens (token, uid, expire, clientname) ";
         $insertQuery = $insertQuery . "VALUES ('{$this->tokenNumber}', {$this->uid}, {$this->expire}, '{$this->clientname}')";
         $this->dbh->query($insertQuery);
         $this->valid = true;
     } else {
         $this->valid = false;
     }
     return $this->valid;
 }
Beispiel #2
0
function userLastLoginTimeGet($params)
{
    $loginTime = 0;
    $argToken =& $params[0];
    $argUsernameToGet =& $params[1];
    $tokenObject = new NodeToken();
    $tokenObject->retrieveToken($argToken);
    if ($tokenObject->valid && $argUsernameToGet != null) {
        $targetUser = User::factory($argUsernameToGet);
        $loginTime = $targetUser->getLastLogin();
        statusCode(200);
    } else {
        statusCode(401);
        $loginTime = 0;
    }
    return $loginTime;
}
Beispiel #3
0
function xmlrpc_clientUsersWhois($method_name, $params)
{
    $argToken =& $params[0];
    $tokenObject = new NodeToken();
    $tokenObject->retrieveToken($argToken);
    $whoisList = array();
    if ($tokenObject->valid) {
        $databaseConnection =& Planworld::_connect();
        $queryUsers = "SELECT DISTINCT users.username FROM users";
        $queryResultUsers = $databaseConnection->query($queryUsers);
        $userRow = $queryResultUsers->fetchRow();
        while ($userRow) {
            $whoisList[] = $userRow['username'];
            $userRow = $queryResultUsers->fetchRow();
        }
    } else {
        $whoList[] = false;
    }
    return $whoisList;
}