zoukankan
html css js c++ java
友情链接防刷PV测试代码
没做验证..貌似正确...先记录一下
Code
1
private
static
List
<
string
>
idList
=
new
List
<
string
>
();
2
private
static
List
<
DateTime
>
timeList
=
new
List
<
DateTime
>
();
3
protected
void
Page_Load(
object
sender, EventArgs e)
4
{
5
if
(
!
IsPostBack)
6
{
7
AntiSQLInjection sqli
=
new
AntiSQLInjection();
8
string
aid
=
sqli.ReplaceStr(Request.QueryString[
"
aid
"
]);
9
GetNavigationUrl count
=
new
GetNavigationUrl();
10
if
((idList
==
null
||
idList.Count
==
0
)
&&
(timeList
==
null
||
timeList.Count
==
0
))
11
{
12
idList
=
new
List
<
string
>
();
13
timeList
=
new
List
<
DateTime
>
();
14
idList.Add(aid);
15
timeList.Add(DateTime.Now);
16
count.UrlStat(aid,
true
);
//
进来的PV统计
17
}
18
else
19
{
20
if
(idList.Count
!=
timeList.Count)
21
{
22
idList
=
new
List
<
string
>
();
23
timeList
=
new
List
<
DateTime
>
();
24
idList.Add(aid);
25
timeList.Add(DateTime.Now);
26
count.UrlStat(aid,
true
);
//
进来的PV统计
27
}
28
else
29
{
30
if
(idList.IndexOf(aid)
<
0
)
//
第一次点击
31
{
32
idList.Add(aid);
33
timeList.Add(DateTime.Now);
34
count.UrlStat(aid,
true
);
//
进来的PV统计
35
}
36
else
37
{
38
int
index
=
idList.IndexOf(aid);
39
DateTime oldTime
=
timeList[index];
40
if
(oldTime.AddMinutes(
1
)
<=
DateTime.Now)
//
超时
41
{
42
timeList[index]
=
DateTime.Now;
43
count.UrlStat(aid,
true
);
//
进来的PV统计
44
}
//
1分钟内不算进统计
45
}
46
}
47
}
48
Response.Redirect(
"
XXX
"
);
49
}
50
}
51
}
查看全文
相关阅读:
离开页面时提示用户
返回顶部
【转】 MySQL主从(Master-Slave)复制
判断是否到达指定时间,可以精确到秒
【转】tomcat优化-有改protocol 和 缓存 集群方案
【转】Spring+Websocket实现消息的推送
【转】SpringMVC整合websocket实现消息推送及触发
【转】java即时消息推送
大型网站对图片的下载,存放,及压缩管理
简单的linux压力测试工具webbench
原文地址:https://www.cnblogs.com/Zoya/p/1553498.html
最新文章
day47-线程-锁和死锁
day46-守护线程
day45-多线程(server和多个client通信)
day44-线程
day43-线程概念
day42-进程池
day41-进程-管道
day40-进程-生产者消费者模型进阶
day39-进程-队列
day38-进程-事件
热门文章
172-集群部署与分部署部署有什么区别?
43-springboot集成thymeleaf很有可能将thml页面解析不出来,我们该怎么做?
171-如何引入非maven仓库依赖?
170-数据库的多线程操作?
169-this代表关键自,代表的是当前对象,但是我们再有参构造方法时,还没有创建对象,这个this怎么可能用的?
168-序列化id起到了什么作用?
010-idea常用快捷键
167-do while()与for循环最大的区别?
166-在插入数据的时候返回主键
165-数据库使用链接查询时返回对象的扩展
Copyright © 2011-2022 走看看