知道用户刷新页面,网络统计 [英] knowing user refresh the page, web stats
本文介绍了知道用户刷新页面,网络统计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
远足......我又一次堆叠......
hiks ... im stack again ...
我尝试制作一个简单的访问者统计信息,但遇到了问题.
I try to make a simple visitor statistic, and i have a problem.
如果用户刷新页面,如何使统计信息不更新?
How to make the statistic don't update if user refresh the page ?
这里是我的片段
public function saveData($sid)
{
global $database;
$reff = parse_url($_SERVER['HTTP_REFERER']);
$referrer = isset($reff['host']) ? $reff['host'] : 'direct';
$own = $_SERVER['HTTP_HOST'];
if($referrer!=$own){
$ip = ip2long($_SERVER['REMOTE_ADDR']);
$time = time();
$page = $_SERVER['REQUEST_URI'];
$add = $database->tableAdd("eu_shop_pageview", "shop_id, ip, timestamp, page, referrer", "'$sid', '$ip', '$time', '$page', '$referrer'");
}
}
谢谢:)
问候,斯泰西
推荐答案
就个人而言,当我进行视图跟踪时,我有以下列:
Personally, when I do view tracking, I have the following columns:
`id`
`identifier` : this is either the person's username or if they don't have an account, their IP
`date` : inserted using CURDATE()
`page_url`
在添加到该表之前,我运行以下查询,如果没有返回任何行,则插入该表以向该页面添加视图:
Before adding to this table, I run the following query and if there are no rows returned, then I insert into that table to add a view to that page:
SELECT id FROM views WHERE identifier = '$user_id' AND date = CURDATE() AND page_url = '$url' LIMIT 1
如果您希望多于/少于一天的时间范围来决定计算新的观看次数,则需要更改选择日期的方式.
You would want to change how you select the date if you want more/less than a day's timeframe for deciding to count new views.
这篇关于知道用户刷新页面,网络统计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文