Kalimat paling sederhana adalah menggunakan yang berikut:
ip = request.serverVariable ("remote_addr")
response.write (ip)
Namun, metode ini tidak akurat bagi server proxy untuk mengakses Internet, jadi metode yang lebih komprehensif adalah menggunakan metode berikut:
Salinan kode adalah sebagai berikut:
<%PrivateFunctionGetip ()
Dimstripaddr
IfRequest.serverVariable ("http_x_forwarded_for") = "" orinstr (request.serverVariables ("http_x_forwarded_for"), "tidak diketahui")> 0then
stripaddr = request.serverVariable ("remote_addr")
Elseifinstr (request.serverVariable ("http_x_forwarded_for"), ",", ")> 0then
stripaddr = mid (request.serverVariable ("http_x_forwarded_for"), 1, instr (request.serverVariables ("http_x_forwarded_for"), ",")-1)
Elseifinstr (request.serverVariable ("http_x_forwarded_for"), ";")> 0then
stripaddr = mid (request.serverVariables ("http_x_forwarded_for"), 1, instr (request.serverVariables ("http_x_forwarded_for"), ";")-1)
Kalau tidak
stripaddr = request.serverVariables ("http_x_forwarded_for")
Endif
getip = trim (mid (stripaddr, 1,30))
Fungsi endfungsi
ip = getip ()
response.write (ip)
%>