日期:2011-12-20  浏览次数:20956 次

<%
'作者:爱易学习网
'网址:http://www.aiyiweb.com
'说明:欢迎使用本源码程序,敬请保持本信息.
'24小时同1IP只弹一次
'直接输入网址来的不弹
'弹过一次后,在打开其它有弹窗代码的页面就不要弹了
'最好是用JS引用,这样你静态页面也可以用
Dim viewhistory,Referer,usercookie
Dim mydomain,reurl,oldip,oldtime
Dim opentime,adstr
opentime = 24  '设定同一IP弹窗周期,单位:小时
mydomain = "aiyiweb.com" '网站域名
adstr = "<script language=""javascript"" src=""http://aiyiweb.com/indexgg.js""></script>"  '广告联盟弹窗代码,<script>...</script>类似的弹窗代码,注意单双引号的写法

Referer = CStr(Request.ServerVariables("HTTP_REFERER"))  '取得访问来源
If(Referer="") Then  '如果为空判断是直接访问,否则为通过搜索引擎或其它网站进入
 reurl=mydomain
Else
 If InStr(Referer,mydomain) > 0 Then
 reurl=mydomain
 Else
 reurl="search"
 End If
End If
If reurl = "search" Then '如果用户是通过外部链接进到本站时就判断是否超过24小时后弹窗
 If Trim(Request.Cookies("isopen")("user"))="" then  '如果用户第一次访问弹窗
  Call writecookie()  '记录Cookie并弹窗操作过程
 Else
  usercookie = Trim(Request.Cookies("isopen")("user"))
  If InStr(Trim(Request.Cookies("isopen")("user")),"|")>0 Then '如果有cookie内容就判断格式是否正确,否则转入弹窗
   oldip = Split(usercookie,"|")(0) 'cookie里的上次弹窗的IP记录
   oldtime = Split(usercookie,"|")(1) 'cookie里的上次弹窗的时间记录
   If Trim(oldip) = Trim(userip()) Then '如同上次弹窗IP与现IP一样就判断时间差
    if DateDiff("h",oldtime,Now())>opentime then  '如果时间超过24小时就弹窗
    Call writecookie()  '记录Cookie并弹窗操作过程
    Else
    '时间没超过弹窗周期不操作
    End if
   Else '新IP访问弹窗
    Call writecookie()  '记录Cookie并弹窗操作过程
   End If
  Else
   Call writecookie()
  End If
 End If
End If

Sub writecookie()
 Response.Cookies("isopen").Expires=now+1
 Response.Cookies("isopen")("user") = UserIP()&"|"&Now()
 Response.Write "document.write('"&adstr&"');"
End Sub

Function UserIP()
Dim GetClientIP
GetClientIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If GetClientIP = "" or isnull(GetClientIP) or isempty(GetClientIP) Then
GetClientIP = Request.ServerVariables("REMOTE_ADDR")
end if
Userip = GetClientIP
End Function
%>

引用方式: <script src="以上代码文件名aiyiweb.com.asp"></script>