AI智能回复搜索中,请稍后...
1 回答
public function update_views($question_id) { //不统计蜘蛛的记录 if (empty($_SERVER['HTTP_USER_AGENT']) OR preg_match("/(Bot|Crawl|Spider|slurp|sohu-search|lycos|curl|robozilla)/i", $_SERVER['HTTP_USER_AGENT'])) { return false; } $views_session = fetch_ip(); $views_session = !empty($views_session) ? $views_session : session_id(); if (AWS_APP::cache()->get('update_views_question_' . md5($views_session) . '_' . intval($question_id))) { return false; } AWS_APP::cache()->set('update_views_question_' . md5($views_session) . '_' . intval($question_id), time(), get_setting('cache_level_normal')); $this->shutdown_query("UPDATE " . $this->get_table('question') . " SET view_count = view_count + 1 WHERE question_id = " . intval($question_id)); return true; }新的计数逻辑为:先按ip判断浏览次数,如果未获取到ip,则按 session_id 判断 如果你要以 24小时为一个周期,将 get_setting('cache_level_normal') 改为 86400 即可
这家伙很懒,还没有设置简介