Exemple #1
0
function fs_add_hit__($user_id, $site_id)
{
    if (FS_COMMIT_STRATEGY == FS_COMMIT_IMMEDIATE) {
        return fs_add_hit_immediate__($user_id, $site_id);
    } else {
        if (FS_COMMIT_STRATEGY == FS_COMMIT_MANUAL) {
            return fs_add_hit_delayed__($user_id, $site_id);
        } else {
            return "FireStats: Unknown commit strategy";
        }
    }
}
Exemple #2
0
$fsdb =& fs_get_db_conn();
$pending = fs_pending_date_table();
while (true) {
    $sql = "SELECT COUNT(*) FROM `{$pending}`";
    $c = $fsdb->get_var($sql);
    if ($c === false) {
        die(fs_db_error());
    }
    if ((int) $c === 0) {
        break;
    }
    $sql = "SELECT * FROM `{$pending}` LIMIT 0," . FS_COMMIT_MAX_CHUNK_SIZE;
    $res = $fsdb->get_results($sql);
    if ($res === false) {
        die(fs_db_error());
    }
    foreach ($res as $d) {
        $_SERVER['REMOTE_ADDR'] = $d->ip;
        $_SERVER['HTTP_USER_AGENT'] = $d->useragent;
        $_SERVER['REQUEST_URI'] = $d->url;
        $_SERVER['HTTP_REFERER'] = $d->referer;
        $res = fs_add_hit_immediate__($d->user_id, $d->site_id, $d->timestamp);
        if ($res !== true) {
            die("Error : " . $res);
        }
        $r = $fsdb->query("DELETE FROM `{$pending}` WHERE `id` = '{$d->id}'");
        if ($r === false) {
            die(fs_db_error());
        }
    }
}