ElggHMACCache::load PHP Method

load() public method

Load a key
public load ( string $key, integer $offset, integer $limit = null ) : string
$key string Name
$offset integer Offset
$limit integer Limit
return string
    public function load($key, $offset = 0, $limit = null)
    {
        $dbprefix = elgg_get_config('dbprefix');
        $key = sanitise_string($key);
        $row = get_data_row("SELECT * from {$dbprefix}hmac_cache where hmac='{$key}'");
        if ($row) {
            return $row->hmac;
        }
        return false;
    }

Usage Example

Beispiel #1
0
/**
 * This function will do two things. Firstly it verifies that a HMAC signature
 * hasn't been seen before, and secondly it will add the given hmac to the cache.
 *
 * @param string $hmac The hmac string.
 *
 * @return bool True if replay detected, false if not.
 * @access private
 */
function cache_hmac_check_replay($hmac)
{
    // cache lifetime is 25 hours (this should be related to the time drift
    // allowed in get_and_validate_headers
    $cache = new ElggHMACCache(90000);
    if (!$cache->load($hmac)) {
        $cache->save($hmac, $hmac);
        return false;
    }
    return true;
}
All Usage Examples Of ElggHMACCache::load