Advertisement
5_2007-2008 Coding Standards #179252

Get IP ADDRESS

This is usefull program to track people's IP. Visit Count for each visiting IP address. Assume that the table IPAddresses(IPAddress, Count) exists in the DSN yourDSN.

AI

สรุปโดย AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

ซอร์สโค้ด
original-source
<html>
<head>
<title>Visit Counts per ip addresses</title>
</head>
<body>
<% 
'  Get Remote IP Address.
IPAddress = Request.ServerVariables("Remote_Addr")
'  Open database connection. 
Set conn = Server.CreateObject("adodb.connection")
conn.open "yourDsn"
'  Check to see the IP address exits.
'  Inefficient: to be modified.
sql = "select * from IPAddresses" & _
   " where IPAddress = '" & IPAddress & "'"
set result = conn.execute(sql)12:09 AM 8/8/01
if (not result.eof) then ' one result
  Count = Clng(result.fields.item("Count")) + 1
  sql = "update IPAddresses set Count = " & Count & _
     " where IPAddress = '" & IPAddress & "'"
else
  Count = 1
  sql = "insert into IPAddresses values('" & _
     IPAddress & "', " & Count & ")"
end if
conn.execute(sql)
conn.close
'  Print result.
Response.write("IP Address " & IPAddress & " has visited " & _
"this page for " & count & " times.")
%>
</body>
</html>
ความคิดเห็นดั้งเดิม (3)
กู้คืนจาก Wayback Machine