system/lib-security.php
branchHEAD
changeset 7400 37fcd14cdee2
parent 7362 aaa5a1f1850e
child 7413 5db714583481
     1.1 --- a/system/lib-security.php	Sun Oct 04 19:56:54 2009 +0200
     1.2 +++ b/system/lib-security.php	Thu Oct 29 18:09:46 2009 +0100
     1.3 @@ -1178,6 +1178,33 @@
     1.4  }
     1.5  
     1.6  /**
     1.7 +* Get a token's expiry time
     1.8 +*
     1.9 +* @param    string  $token  the token we're looking for
    1.10 +* @return   int             UNIX timestamp of the expiry time or 0
    1.11 +*
    1.12 +*/
    1.13 +function SEC_getTokenExpiryTime($token)
    1.14 +{
    1.15 +    global $_TABLES, $_USER;
    1.16 +
    1.17 +    $retval = 0;
    1.18 +
    1.19 +    if (!COM_isAnonUser()) {
    1.20 +
    1.21 +        $sql['mysql'] = "SELECT UNIX_TIMESTAMP(DATE_ADD(created, INTERVAL ttl SECOND)) AS expirytime FROM {$_TABLES['tokens']} WHERE (token = '$token') AND (owner_id = '{$_USER['uid']}') AND (ttl > 0)";
    1.22 +        $sql['mssql'] = "SELECT UNIX_TIMESTAMP(DATEADD(ss, ttl, created)) AS expirytime FROM {$_TABLES['tokens']} WHERE (token = '$token') AND (owner_id = '{$_USER['uid']}') AND (ttl > 0)";
    1.23 +
    1.24 +        $result = DB_query($sql);
    1.25 +        if (DB_numRows($result) == 1) {
    1.26 +            list($retval) = DB_fetchArray($result);
    1.27 +        }
    1.28 +    }
    1.29 +
    1.30 +    return $retval;
    1.31 +}
    1.32 +
    1.33 +/**
    1.34  * Set a cookie using the HttpOnly flag
    1.35  *
    1.36  * Use this function to set "important" cookies (session, password, ...).