
关于积分推广的思路最终效果:
形如 http://www.a6118.cn/?u=295
当有人点击的时候 ID为295的用户积分就会 +1
制作过程:
一、数据库的制作:
新建字段 tuiguang
id 自动编号
uid 用户名字段对应的userid 类型: txt
time1 首次点击时间 类型:时间
time2 再次点击时间
Hits 点击次数 类型:数字
ip 来路ip 类型:文本
pv 浏览pv 类型文本
二、推广代码详解:重点都做了注释
新建 tui.asp
代码如下:
<%
u=request("u") '字段uid 需为 txt型,不能数字
Ip=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If Ip = "" Then Ip = Request.ServerVariables("REMOTE_ADDR")
Ly=Request.ServerVariables("Http_REFERER")
set rs=server.createobject("adodb.recordset")if request("u")<>"" then
sql="select * from tuiguang where uid='"&u&"' and ip='"&ip&"'" '必须设置ip!!!否则可以互刷!
rs.open sql,conn,1,3
if rs.bof and rs.eof then
rs.addnew
call newdata()
rs.update
end if
if rs("ip")=ip and (now()-rs("time2"))<1 then 'ip相同,时间在同一天内,不加点击,只加个pv ,测试通过
call addpv()
rs.update
end if
if rs("ip")=ip and (now()-rs("time2"))>1 then 'ip相同,但是时间相差1天,则加一个点击.
call newdata()
rs.update
end if
if rs("ip")<>ip then
call newdata()
rs.update
end if
rs.close
set rs=nothing
end if
sub newdata
rs("uid")=u
rs("time1")=now()
rs("time2")=now()
rs("hits")=1
rs("ip")=ip
rs("pv")=0 '由于前面判断,eof ,ip判断的时候肯定要加个pv,故设置pv=0
end subsub addhits
rs("time2")=now()
rs("hits")=rs("hits")+1
rs("ip")=ip
rs("pv")=rs("pv")+1
end subsub addpv
rs("time2")=now()
rs("pv")=rs("pv")+1
end sub
%>
标签: 代码