| 因?yàn)榻粨Q機(jī)的緣故,內(nèi)網(wǎng)(辦公室)用戶使用域名訪問(wèn)網(wǎng)站,在IIS的日志中記錄的是10.10.1.1(因?yàn)槔@了一個(gè)圈子從內(nèi)網(wǎng)到外網(wǎng)再到服務(wù)器,經(jīng)過(guò)了防火墻).上次就是出了這樣的事故,無(wú)法追蹤訪客信息. 現(xiàn)在的方案是:內(nèi)網(wǎng)用戶訪問(wèn)時(shí),不允許使用公網(wǎng)IP或者域名訪問(wèn),必須使用內(nèi)網(wǎng)的ip(10.10.3.3)訪問(wèn)服務(wù)器。而非內(nèi)網(wǎng)用戶則通過(guò)公網(wǎng)IP和域名訪問(wèn)網(wǎng)站。這樣IIS日志所記錄的信息全部真實(shí) 網(wǎng)上好多關(guān)于JS獲取IP,獲取URL的文章.都說(shuō)需要裝控件,需要客戶端使用較低的安全策略,而ASP/PHP/JSP就不用那么麻煩,可以輕松實(shí)現(xiàn).而這次改版的網(wǎng)站是全靜態(tài)生成頁(yè)面,格式是shtml,里面不能放ASP程序.必須靠JS來(lái)調(diào)用. 找了一下午資料,也沒(méi)如意,后來(lái)突然想起前幾天做的旺閣的新聞?wù){(diào)用,就直接調(diào)用的ASP文件,也不用非要是JS文件啊, <script language="javascript" type="text/javascript" src="ip.ASP"></script> 那么這樣做以后,就不用麻煩去寫(xiě)ip.js文件,而就只需要寫(xiě)IP.ASP就可以了,用 document.write("..");輸入就對(duì)了哦。 ASP CODE:  程序代碼 ‘--內(nèi)網(wǎng)用戶重定向------------------ ip = Request.ServerVariables("REMOTE_ADDR") if (left(ip,5)="10.10") and Request.ServerVariables("HTTP_HOST")<>"10.10.3.3" then response.Redirect("http://10.10.3.3/") end if ‘---------------------------------- JS輸出:  程序代碼 <% ip =  Request.ServerVariables("REMOTE_ADDR") if (left(ip,5)="10.10") and Request.ServerVariables("HTTP_HOST")<>"10.10.3.3" then %> document.write("<SCRIPT>document.location.href=‘http://10.10.3.3/v2006‘;</SCRIPT>"); <% end if %> 再結(jié)合西方亮的404智能跳轉(zhuǎn)JS,就可以完美實(shí)現(xiàn)內(nèi)網(wǎng)的訪問(wèn)用戶地址控制了.。  程序代碼 <% ip =  Request.ServerVariables("REMOTE_ADDR") if (left(ip,5)="10.10") and Request.ServerVariables("HTTP_HOST")<>"10.10.3.3" then %> document.write("<script language=‘javascript‘> var newdomain=‘10.10.3.3‘; //內(nèi)外用戶訪問(wèn)地址 var stoptime=0; //頁(yè)面停留時(shí)間,以秒為單位 var My_Url=document.location.href; godomain(); function godomain() { var str=My_Url; stag=str.indexOf(‘//‘)+1; str=str.substring(stag+1,str.length) stag=str.indexOf(‘/‘); rstr=str.substring(0,stag); olddomain=rstr; My_Url=My_Url.replace(olddomain,newdomain); setTimeout(‘gourl()‘,stoptime*1000); } function gourl() {window.location=My_Url;} </script>"); <% end if %> 汗,不知道哪兒出了問(wèn)題,直接在document.write里面寫(xiě)js內(nèi)容,居然不行,又試了好幾個(gè)小時(shí),換寫(xiě)SRC的路徑就對(duì)了. ------------------------------------------------------------------------------------------------- 1:文件:ip.asp  程序代碼 <% ip =  Request.ServerVariables("REMOTE_ADDR") if (left(ip,5)="10.10") and Request.ServerVariables("HTTP_HOST")<>"10.10.3.3" then %> document.write("<script language=javascript src=‘/v2006/ip.js‘></script>"); <% end if %> 2.文件ip.js  程序代碼 var newdomain=‘10.10.3.3‘;                //內(nèi)外用戶訪問(wèn)地址  var stoptime=0; //頁(yè)面停留時(shí)間,以秒為單位 var My_Url=document.location.href; godomain(); function godomain() { var str=My_Url; stag=str.indexOf(‘//‘)+1; str=str.substring(stag+1,str.length) stag=str.indexOf(‘/‘); rstr=str.substring(0,stag); olddomain=rstr; My_Url=My_Url.replace(olddomain,newdomain); setTimeout(‘gourl()‘,stoptime*1000); } function gourl() {window.location=My_Url;} 文件3:top.shtml  程序代碼 <script language="javascript" type="text/javascript" src="/v2006/ip.asp"></script> | 
|  | 
來(lái)自: looline > 《javascript》