Ver Mensaje Individual
  #2 (permalink)  
Antiguo 07/03/2004, 13:53
Avatar de polecat
polecat
 
Fecha de Ingreso: diciembre-2003
Ubicación: Argentina
Mensajes: 391
Antigüedad: 21 años, 5 meses
Puntos: 0

'Get the users IP address
strIPAddress = Request.ServerVariables("REMOTE_ADDR")


'Get if the user wants to be shown in the active users list
If Request.Cookies("Forum")("Hide") = "True" Then
blnHideActiveUser = 1
Else
blnHideActiveUser = 0
End If

'Calculate the active users ID number
lngActiveUsersID = lngLoggedInUserID


'Initialise the SQL variable with an SQL statement to get the active users details
If strDatabaseType = "SQLServer" Then
strSQL = "EXECUTE " & strDbProc & "ActiveUsersWhereIPis @strIPAddress = '" & strIPAddress & "'"
Else
strSQL = "SELECT " & strDbTable & "ActiveUser.* From " & strDbTable & "ActiveUser WHERE IP='" & strIPAddress & "';"
End If

'Query the database
rsCommon.Open strSQL, adoCon

'If there are no records for this user then add them to the datatbase
If rsCommon.EOF Then

'Get the uesrs web browser
'strBrowserUserType = BrowserType()

'Get the OS type
'strOS = OSType()

'If the user is not in the active users list then write them to it
'Initilse sql statement
If strDatabaseType = "SQLServer" Then
strSQL = "EXECUTE " & strDbProc & "AddNewActiveUser @strIPAddress = '" & strIPAddress & "', @lngActiveUsersID = '" & lngActiveUsersID & "', @strOS = '" & strOS & "', @strBrowserUserType = '" & strBrowserUserType & "', @blnHideActiveUser = '" & blnHideActiveUser & "'"
Else
strSQL = "INSERT INTO " & strDbTable & "ActiveUser (IP, Author_ID, OS, Browser, Hide) VALUES ('" & strIPAddress & "','" & lngActiveUsersID & "','" & strOS & "','" & strBrowserUserType & "','" & blnHideActiveUser & "');"
End If

'Write to database
adoCon.Execute(strSQL)

'Else if there's records returned then update them
Else
'The user is already in the db so just update the recordset
'Initilse sql statement
If strDatabaseType = "SQLServer" Then
strSQL = "EXECUTE " & strDbProc & "UpdateActiveUser @lngActiveUsersID = '" & lngActiveUsersID & "', @blnHideActiveUser = '" & blnHideActiveUser & "', @strIPAddress = '" & strIPAddress & "'"
Else
strSQL = "UPDATE " & strDbTable & "ActiveUser SET " & strDbTable & "ActiveUser.Author_ID=" & lngActiveUsersID & ", " & strDbTable & "ActiveUser.Active=Now(), " & strDbTable & "ActiveUser.Hide=" & blnHideActiveUser & " WHERE IP='" & strIPAddress & "';"
End If

'Write to database
adoCon.Execute(strSQL)


'Clean up old users
'Initilse sql statement
If strDatabaseType = "SQLServer" Then
strSQL = "EXECUTE " & strDbProc & "DeleteActiveUser"
Else
strSQL = "DELETE FROM " & strDbTable & "ActiveUser WHERE " & strDbTable & "ActiveUser.Active < Now() - 0.0070;"
End If

'Detlete from database
adoCon.Execute(strSQL)


'Delete older second entries if the user has returned in under 10 minutes with a new IP
If lngActiveUsersID <> 2 Then
If strDatabaseType = "SQLServer" Then
strSQL = "EXECUTE " & strDbProc & "DeleteActiveUserDoubleEntry @lngActiveUsersID = " & lngActiveUsersID & ", @strIPAddress = '" & strIPAddress & "'"
Else
strSQL = "DELETE FROM " & strDbTable & "ActiveUser WHERE " & strDbTable & "ActiveUser.Author_ID=" & lngActiveUsersID & " AND " & strDbTable & "ActiveUser.IP <> '" & strIPAddress & "';"
End If

'Detlete from database
adoCon.Execute(strSQL)
End If
__________________
Juan Manuel
Diseño web/Gráfico & Ilustración
E-mail: [email protected] / Skype: jmbosi
Portfolio: www.facebook.com/hacelobiendesign