<% Const Sys_db = "./access_db/#mydownrecord.mdb" '数据库路径 Const Sys_CookiesDomain = "lymagdown" '全局变量标识,任意字符 '************************************* 'conn 对象 '************************************* Function myConn() If session(Sys_CookiesDomain & "_oConn")="" Then On Error Resume Next Dim sConnstr,oConn sConnstr = "DBQ=" + server.mappath(Sys_db) + ";"&_ "DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};" set oConn=server.createobject("ADODB.connECTION") oConn.open sConnstr if err then err.clear set oConn=nothing response.write "Database connection error!" Response.End Else session(Sys_CookiesDomain & "_oConn") = oConn end If Set oConn = Nothing End If myConn = session(Sys_CookiesDomain & "_oConn") End Function '************************************* '获取客户端IP '************************************* Function getIP() Dim strIP, IP_Ary, strIP_list strIP_list = Replace(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "'", "") If InStr(strIP_list, ",")<>0 Then IP_Ary = Split(strIP_list, ",") strIP = IP_Ary(0) Else strIP = strIP_list End If If strIP = Empty Then strIP = Replace(Request.ServerVariables("REMOTE_ADDR"), "'", "") getIP = strIP End Function Function ShowDownCount() Conn = myConn set rs=server.createobject("adodb.recordset") t_sql="select * from downinfo where ID=1" rs.open t_sql,Conn,1,2 IF NOT rs.eof Then file_path = rs("Path") rs("Count") = rs("Count") + 1 rs.update end if rs.close set rs = nothing End Function Function IncreaeCountAndRedirect() Dim file_path file_path="" file_id = request.QueryString("ID") client_ip = getIP() if Len(file_id) <= 0 Then Server.Transfer("default.asp") End if req_count = request.QueryString("Count") if Len(req_count) > 0 Then Conn = myConn set rs=server.createobject("adodb.recordset") t_sql="select * from downinfo where ID=" + file_id rs.open t_sql,Conn,1,2 IF NOT rs.eof Then downCount = rs("Count") end if rs.close set rs = nothing Response.write(downCount) Exit Function End if Conn = myConn set rs=server.createobject("adodb.recordset") t_sql="select * from downinfo where ID=" + file_id rs.open t_sql,Conn,1,2 IF NOT rs.eof Then file_path = rs("Path") rs("Count") = rs("Count") + 1 rs.update end if rs.close set rs = nothing if Len(file_path) > 0 Then response.Redirect(file_path) Else Server.Transfer("default.asp") End if IncreaeCountAndRedirect = "" End Function dowork = IncreaeCountAndRedirect() %>