function get_region_city() { if (VIEW_REGION) { return get_locale_mem($_SERVER['REMOTE_ADDR']); } else { return $_SERVER['REMOTE_ADDR']; } }
function update_device_saved($device_saved) { //更新统计信息 if (time() - $device_saved['last_pageview'] > SESSION_INTERVAL_TIME) { $device_saved['start_session'] = time(); $device_saved['session_count'] += 1; $device_saved['session_pv'] = 0; } $device_saved['pageview_count'] += 1; $device_saved['session_pv'] += 1; $device_saved['is_first_pageview'] = $device_saved['pageview_count'] < 2; $device_saved['is_first_session'] = $device_saved['session_count'] < 2; $device_saved['is_first_day'] = time() - $device_saved['first_pageview'] < COOKIE_TIMEOUT_NEW; $device_saved['is_first_session_pv'] = $device_saved['session_pv'] < 2; $device_saved['staytime'] = time() - $device_saved['start_session']; $device_saved['is_registed'] = !empty($device_saved['kword_account_md5']); //获取需要附加的信息 //这些都是会动态改变的字段 $ip_addr = @$_SERVER['REMOTE_ADDR']; $region = get_locale_mem($ip_addr); $lang = get_accept_language(); $ip_changed = isset($device_saved['ip_addr']) ? $device_saved['ip_addr'] != $ip_addr : false; $region_changed = isset($device_saved['region']) ? $device_saved['region'] != $region : false; $lang_changed = isset($device_saved['language']) ? $device_saved['language'] != $lang : false; $device_saved['ip_addr'] = $ip_addr; $device_saved['region'] = $region; $device_saved['language'] = $lang; $device_saved['Visiting'] = @$_SERVER['HTTP_REFERER']; $device_saved['XRequestWith'] = @$_SERVER['HTTP_X_REQUESTED_WITH']; $device_saved['ip_changed'] = $ip_changed; $device_saved['region_changed'] = $region_changed; $device_saved['lang_changed'] = $lang_changed; return $device_saved; }