コード例 #1
0
function api_keys_fetch_site_key()
{
    $ttl = $GLOBALS['cfg']['api_site_keys_ttl'];
    $key = api_keys_get_site_key();
    $now = time();
    # TO DO: error handling/reporting...
    if (!$key) {
        $rsp = api_keys_create_site_key();
        $key = $rsp['ok'] ? $rsp['key'] : null;
    } else {
        if ($now >= $key['created'] + $ttl) {
            $delete_rsp = api_keys_delete_site_key($key);
            $create_rsp = api_keys_create_site_key();
            $key = $create_rsp['ok'] ? $create_rsp['key'] : null;
        } else {
        }
    }
    return $key;
}
コード例 #2
0
function api_keys_fetch_site_key()
{
    $ttl = $GLOBALS['cfg']['api_site_keys_ttl'];
    $key = api_keys_get_site_key();
    # $key['debug'] = 'FETCH';
    $now = time();
    # TO DO: error handling/reporting...
    if (!$key) {
        $rsp = api_keys_create_site_key();
        $key = $rsp['ok'] ? $rsp['key'] : null;
    } else {
        if (!$key['expires']) {
            $delete_rsp = api_keys_delete_site_key($key);
            $create_rsp = api_keys_create_site_key();
            $key = $create_rsp['ok'] ? $create_rsp['key'] : null;
        } else {
            if ($key['expires'] <= $now) {
                $delete_rsp = api_keys_delete_site_key($key);
                $create_rsp = api_keys_create_site_key();
                $key = $create_rsp['ok'] ? $create_rsp['key'] : null;
            } else {
            }
        }
    }
    return $key;
}