Auth_OpenID_FileStore::useNonce PHP Method

useNonce() public method

Return whether this nonce is present. As a side effect, mark it as no longer present.
public useNonce ( $server_url, $timestamp, $salt ) : boolean
return boolean $present
    function useNonce($server_url, $timestamp, $salt)
    {
        global $Auth_OpenID_SKEW;
        if (!$this->active) {
            trigger_error("FileStore no longer active", E_USER_ERROR);
            return null;
        }
        if (abs($timestamp - time()) > $Auth_OpenID_SKEW) {
            return false;
        }
        if ($server_url) {
            list($proto, $rest) = explode('://', $server_url, 2);
        } else {
            $proto = '';
            $rest = '';
        }
        $parts = explode('/', $rest, 2);
        $domain = $this->_filenameEscape($parts[0]);
        $url_hash = $this->_safe64($server_url);
        $salt_hash = $this->_safe64($salt);
        $filename = sprintf('%08x-%s-%s-%s-%s', $timestamp, $proto, $domain, $url_hash, $salt_hash);
        $filename = $this->nonce_dir . DIRECTORY_SEPARATOR . $filename;
        $result = @fopen($filename, 'x');
        if ($result === false) {
            return false;
        } else {
            fclose($result);
            return true;
        }
    }