Exemple #1
0
function visit_count($vk)
{
    $info = get_visit_info();
    if (isset($info[$vk])) {
        $info[$vk]['cnt']++;
    } else {
        $info[$vk]['cnt'] = 1;
    }
    $info[$vk]['ua'] = $_SERVER['HTTP_USER_AGENT'];
    $info[$vk]['ip'] = ip2long($_SERVER['REMOTE_ADDR']);
    save_info($info);
}
Exemple #2
0
function visit()
{
    $info = get_visit_info();
    $time = time();
    while (true) {
        $Ymd = date('Ymd', $time);
        $f = "runtime/visit-{$Ymd}.json";
        if (is_file($f)) {
            $i = unserialize(file_get_contents($f));
            $table[$Ymd] = ['pv' => array_sum(array_map(function ($e) {
                return $e['cnt'];
            }, $i)), 'uv' => count($i)];
        } else {
            break;
        }
        $time -= 24 * 3600;
    }
    $data = compact('info', 'count', 'errorInfo', 'table');
    render(__DIR__ . '/view/visit.html', $data, LAYOUT);
}