<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Session_OnStart()
Dim SiteName
If Instr(Request.ServerVariables("HTTP_HOST"),"taxzone") Then
SiteName = "taxzone"
Else
SiteName = "Cndl"
End If
Dim Str_Now
Dim Str_REMOTE_ADDR
Dim Str_REMOTE_HOST
Str_Now = Now()
Str_REMOTE_ADDR = Request.ServerVariables("REMOTE_ADDR")
Str_REMOTE_HOST = Request.ServerVariables("REMOTE_HOST")
Dim Conn_New_Visitor
Set Conn_New_Visitor = Server.CreateObject("adodb.connection")
Conn_New_Visitor.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("\db\Cndl.mdb") & ";"
Conn_New_Visitor.BeginTrans
Dim Member_Id
Member_Id = Request.Cookies(SiteName)("Member_Id")
If Member_Id>"" Then
Dim Rs_ChackExist
Set Rs_ChackExist = Server.CreateObject("Adodb.Recordset")
Rs_ChackExist.ActiveConnection = Conn_New_Visitor
Sql = "SELECT FName From Members WHERE Member_Id = "& Member_Id
Rs_ChackExist.Open SQL
If Rs_ChackExist.EOF Then
Member_Id=""
End If
Sql = NULL
Rs_ChackExist.Close
Set Rs_ChackExist = Nothing
End If
If Member_Id>"" Then
Sql = "Insert Into Visitors"
Sql = Sql & "(Member_ID,"
Sql = Sql & "Time_In,"
Sql = Sql & "Str_REMOTE_ADDR,"
Sql = Sql & "Str_REMOTE_HOST,"
Sql = Sql & "Str_HTTP_HOST,"
Sql = Sql & "Str_HTTP_ACCEPT_LANGUAGE,"
Sql = Sql & "Str_HTTP_USER_AGENT)"
Sql = Sql & "Values("& Member_Id &", "
Sql = Sql & "'"& Str_Now &"', "
Sql = Sql & "'"& Str_REMOTE_ADDR &"', "
Sql = Sql & "'"& Str_REMOTE_HOST &"', "
Sql = Sql & "'"& Request.ServerVariables("HTTP_HOST") &"', "
Sql = Sql & "'"& Request.ServerVariables("HTTP_ACCEPT_LANGUAGE") &"', "
Sql = Sql & "'"& Request.ServerVariables("HTTP_USER_AGENT") &"')"
Conn_New_Visitor.Execute Sql
Sql = Null
Else
Sql = "Insert Into Visitors"
Sql = Sql & "(Member_ID,"
Sql = Sql & "Time_In,"
Sql = Sql & "Str_REMOTE_ADDR,"
Sql = Sql & "Str_REMOTE_HOST,"
Sql = Sql & "Str_HTTP_HOST,"
Sql = Sql & "Str_HTTP_ACCEPT_LANGUAGE,"
Sql = Sql & "Str_HTTP_USER_AGENT)"
Sql = Sql & "Values(-1, " ' פירושו של הסימן מינוס אחד הוא שהמשתמש לא רשום
Sql = Sql & "'"& Str_Now &"', "
Sql = Sql & "'"& Str_REMOTE_ADDR &"', "
Sql = Sql & "'"& Str_REMOTE_HOST &"', "
Sql = Sql & "'"& Request.ServerVariables("HTTP_HOST") &"', "
Sql = Sql & "'"& Request.ServerVariables("HTTP_ACCEPT_LANGUAGE") &"', "
Sql = Sql & "'"& Request.ServerVariables("HTTP_USER_AGENT") &"')"
Conn_New_Visitor.Execute Sql
Sql = Null
End If
'*** - החלק הזה בפונקציה שולף, את המספר שהמשתמש קיבל במסד נתונים
'*** - השליפה מתבצעת על פי הזמן שהמשתמש נכנס, והאי.פי שלו
'*** - ובצורה זו לא יכול להתבצע כפל משתמשים
Dim Rs_VisitNum
Set Rs_VisitNum = Server.CreateObject("Adodb.RecordSet")
Rs_VisitNum.ActiveConnection = Conn_New_Visitor
Sql = "SELECT Visit_Num From Visitors "
Sql = Sql & "WHERE Time_In = '"& Str_Now &"' AND "
Sql = Sql & "Str_REMOTE_ADDR = '"& Str_REMOTE_ADDR &"' AND "
Sql = Sql & "Str_REMOTE_HOST = '"& Str_REMOTE_HOST &"'"
Rs_VisitNum.Open Sql
If Not (Rs_VisitNum.EOF and Rs_VisitNum.BOF) Then
Session("Visit_Counter") = Rs_VisitNum("Visit_Num")
Else
Session("Visit_Counter") = "-1" ' משמע שאין שורה מתאימה במסד נתונים - שגיאה
End If
Rs_VisitNum.Close
Set Rs_VisitNum = NoThing
'***
Conn_New_Visitor.CommitTrans
Conn_New_Visitor.Close
Set Conn_New_Visitor = Nothing
End Sub
'You can add special event handlers in this file that will get run automatically when
'special Active Server Pages events occur. To create these handlers, just create a
'subroutine with a name from the list below that corresponds to the event you want to
'use. For example, to create an event handler for Session_OnStart, you would put the
'following code into this file (without the comments):
'Sub Session_OnStart
'**Put your code here **
'End Sub
'EventName Description
'Session_OnStart Runs the first time a user runs any page in your application
'Session_OnEnd Runs when a user's session times out or quits your application
'Application_OnStart Runs once when the first page of your application is run for the first time by any user
'Application_OnEnd Runs once when the web server shuts down
</SCRIPT>
Michal Lev
Zephyr Web Works
T: +972-(0)3-9030898
M: +972-(0)50-8283982
F: +972-(0)77-6622562
E:
W: www.zephyrww.co.il
P Something in green.