Advertisement
2_2002-2004 Coding Standards #129113

Determine if the remote computer has a local or internet IP address

if you have to determine if the remote computer visitor is local or external of your site and according to the case, for exemple redirect the user to the correct page...

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>
<BODY>
<%
dim ArrayIPLocalStart(2)
dim ArrayIPLocalEnd(2)
Dim ArrayIPClient
Dim IPClient 
dim blnLocal
Ipclient = Request.ServerVariables("REMOTE_ADDR")
Response.Write "Your IP is " & ipclient & "<BR>"
blnLocal = false
' These IP address are constant IP of a LAN
ArrayIPLocalStart(0) = "010.000.000.000" '"10.0.0.0"
ArrayIPLocalEnd(0) = "010.255.255.255" '"10.255.255.255"
ArrayIPLocalStart(1) = "172.016.000.000" '"172.16.0.0"
ArrayIPLocalEnd(1) = "172.031.255.255" '"172.31.255.255"
ArrayIPLocalStart(2) = "192.168.000.000" '"192.168.0.0"
ArrayIPLocalEnd(2) = "192.168.255.255" '"192.168.255.255"
ArrayIPClient = split(Ipclient,".")
' format the remote IP like constant LAN IP
for i = lbound(ArrayIPClient) to ubound(ArrayIPClient)
	ArrayIPClient(i) = string(3-len(ArrayIPClient(i) ),"0") & ArrayIPClient(i)
next
IPClient = join(ArrayIPClient,"")
if trim(ipclient) <> "" then
	for i = lbound(ArrayIPLocalStart) to ubound(ArrayIPLocalStart)
		ArrayIPLocalStart(i) = replace(ArrayIPLocalStart(i),".","")
		ArrayIPLocalEnd(i) = replace(ArrayIPLocalEnd(i),".","")
		if IPClient >= ArrayIPLocalStart(i) and IPClient =< ArrayIPLocalEnd(i) then
			blnLocal = true
			exit for
		End if
	next
end if
if blnLocal then
	Response.Write " And your computer has a local IP"
else
	Response.Write " And your computer has a internet IP"
End if
%>
</BODY>
</HTML>
ความคิดเห็นดั้งเดิม (3)
กู้คืนจาก Wayback Machine