實(shí)現(xiàn)Web中的@虛擬域名系統(tǒng)(原理篇)(2)_Windows教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
下面是庫中的url表結(jié)構(gòu):
字段名 字段類型 字段默認(rèn)值 //功能注釋
id int 自增 關(guān)鍵字 1 不用user做關(guān)鍵字是怕其中有中文字符
user 字符型 null 如BBS或GUESTBOOK的值
url 字符型 null 轉(zhuǎn)向的網(wǎng)址
click int 0 訪問量
表里的字段很少,只有4個(gè),網(wǎng)友可以根據(jù)需要再增加一些功能字段,如是否有彈出窗口廣告,訪問量分析等。不過必要的就是user字段和url字段,因?yàn)槲覀儽仨氁玫絬ser的值,再根據(jù)它得到其轉(zhuǎn)向url網(wǎng)址,再在gourl.asp中實(shí)現(xiàn)轉(zhuǎn)向就行了。
下面是gourl.asp中實(shí)現(xiàn)轉(zhuǎn)向的全部程序(我會(huì)在程序中寫下注釋):
dim conn,dbs //定義變量
Set conn=Server.CreateObject("ADODB.Connection") //建立連接對象
dbs=server.mappath("url.mdb") //定義要連接的數(shù)據(jù)庫路徑
conn.open "driver={microsoft access driver (*.mdb)};dbq="&dbs //打開并實(shí)現(xiàn)其數(shù)據(jù)庫源的鏈接
user=trim(request.querystring("user")) //得到default.html文件中得到的在瀏覽器中輸入的網(wǎng)址
if user<>"" then //當(dāng)user值不為空時(shí)
user=replace(user,"http://","") //將"http://"字符串從user值刪去
at=instr(user,"@") //將user值中"@"所在位置賦給變量at
else
response.write "信息出錯(cuò),請聯(lián)系moon!" //當(dāng)user值為空時(shí)則告訴網(wǎng)友有錯(cuò)
end if
if at>0 then
user=left(user,at-1) //當(dāng)user值中"@"所在的位置大于0時(shí),將其中的部分重賦給user,如"BBS"或" GUESTBOOK"等值
else
response.redirect "def.htm" //如果沒有得到其中的值,如打http://www.luyu.net時(shí),就返回def.htm文件中。
response.end //停止輸出
end if
if user<>"" then
set rs=conn.execute("select url from dns where user='"&user&"'") //當(dāng)user值不為空時(shí),連接數(shù)據(jù)庫,將進(jìn)行搜索
if not rs.eof then
conn.execute("update url set click=click+! Where user='"&user&"'")//當(dāng)記錄不為空時(shí),將此網(wǎng)站的訪問量加1
response.redirect rs("url") //再轉(zhuǎn)向其網(wǎng)站
else
response.write "抱歉,沒有這個(gè)網(wǎng)站!" //記錄為空時(shí),警告網(wǎng)友沒有此網(wǎng)站
end if
set rs=nothing
else
response.write"抱歉,沒有這個(gè)域名!" //當(dāng)user的值為空時(shí),則警告網(wǎng)友沒有此域名
end if
set conn=nothing //關(guān)閉數(shù)據(jù)庫連接
如果想在訪問虛擬域名時(shí)做個(gè)彈出窗口,以幫自己做個(gè)廣告的話,可以在將上面的代碼改成:
<script>
window.open("http://luyu.net","網(wǎng)絡(luò)隨筆","width=350,height=450");
this.location = "gourl.asp?user=" + this.location.href;
</script>
好了,這樣一個(gè)域名訪問系統(tǒng)就簡單的做好了。如果和PHP或是JSP等來實(shí)現(xiàn)的話,原理也是一樣的,我相信大家看了這篇文章都可以做出來了。只是把gourl.asp文件改一下便可。
字段名 字段類型 字段默認(rèn)值 //功能注釋
id int 自增 關(guān)鍵字 1 不用user做關(guān)鍵字是怕其中有中文字符
user 字符型 null 如BBS或GUESTBOOK的值
url 字符型 null 轉(zhuǎn)向的網(wǎng)址
click int 0 訪問量
表里的字段很少,只有4個(gè),網(wǎng)友可以根據(jù)需要再增加一些功能字段,如是否有彈出窗口廣告,訪問量分析等。不過必要的就是user字段和url字段,因?yàn)槲覀儽仨氁玫絬ser的值,再根據(jù)它得到其轉(zhuǎn)向url網(wǎng)址,再在gourl.asp中實(shí)現(xiàn)轉(zhuǎn)向就行了。
下面是gourl.asp中實(shí)現(xiàn)轉(zhuǎn)向的全部程序(我會(huì)在程序中寫下注釋):
dim conn,dbs //定義變量
Set conn=Server.CreateObject("ADODB.Connection") //建立連接對象
dbs=server.mappath("url.mdb") //定義要連接的數(shù)據(jù)庫路徑
conn.open "driver={microsoft access driver (*.mdb)};dbq="&dbs //打開并實(shí)現(xiàn)其數(shù)據(jù)庫源的鏈接
user=trim(request.querystring("user")) //得到default.html文件中得到的在瀏覽器中輸入的網(wǎng)址
if user<>"" then //當(dāng)user值不為空時(shí)
user=replace(user,"http://","") //將"http://"字符串從user值刪去
at=instr(user,"@") //將user值中"@"所在位置賦給變量at
else
response.write "信息出錯(cuò),請聯(lián)系moon!" //當(dāng)user值為空時(shí)則告訴網(wǎng)友有錯(cuò)
end if
if at>0 then
user=left(user,at-1) //當(dāng)user值中"@"所在的位置大于0時(shí),將其中的部分重賦給user,如"BBS"或" GUESTBOOK"等值
else
response.redirect "def.htm" //如果沒有得到其中的值,如打http://www.luyu.net時(shí),就返回def.htm文件中。
response.end //停止輸出
end if
if user<>"" then
set rs=conn.execute("select url from dns where user='"&user&"'") //當(dāng)user值不為空時(shí),連接數(shù)據(jù)庫,將進(jìn)行搜索
if not rs.eof then
conn.execute("update url set click=click+! Where user='"&user&"'")//當(dāng)記錄不為空時(shí),將此網(wǎng)站的訪問量加1
response.redirect rs("url") //再轉(zhuǎn)向其網(wǎng)站
else
response.write "抱歉,沒有這個(gè)網(wǎng)站!" //記錄為空時(shí),警告網(wǎng)友沒有此網(wǎng)站
end if
set rs=nothing
else
response.write"抱歉,沒有這個(gè)域名!" //當(dāng)user的值為空時(shí),則警告網(wǎng)友沒有此域名
end if
set conn=nothing //關(guān)閉數(shù)據(jù)庫連接
如果想在訪問虛擬域名時(shí)做個(gè)彈出窗口,以幫自己做個(gè)廣告的話,可以在將上面的代碼改成:
<script>
window.open("http://luyu.net","網(wǎng)絡(luò)隨筆","width=350,height=450");
this.location = "gourl.asp?user=" + this.location.href;
</script>
好了,這樣一個(gè)域名訪問系統(tǒng)就簡單的做好了。如果和PHP或是JSP等來實(shí)現(xiàn)的話,原理也是一樣的,我相信大家看了這篇文章都可以做出來了。只是把gourl.asp文件改一下便可。
相關(guān)Windows教程:
Windows教程Rss訂閱服務(wù)器教程搜索
Windows教程推薦
猜你也喜歡看這些
- Linux系統(tǒng)中memcache和memcached安裝方法
- iisapp.vbs iis pid了解對應(yīng)的網(wǎng)站或應(yīng)用池
- 偽靜態(tài)在iis下的規(guī)則和設(shè)置方法
- Windows 2003的Web服務(wù)器配置方法
- 什么是HTTP協(xié)議?
- 利用數(shù)據(jù)綁定和模板創(chuàng)建Atlas應(yīng)用程序
- 以Apache 2.2為例:Mod_Layout模塊安裝和使用
- 推薦!各類建站程序偽靜態(tài)規(guī)則代碼
- 詳細(xì)的DedeCMS(織夢)目錄權(quán)限安全設(shè)置教程
- 技巧:服務(wù)器端異步 Web 方法
- 相關(guān)鏈接:
- 教程說明:
Windows教程-實(shí)現(xiàn)Web中的@虛擬域名系統(tǒng)(原理篇)(2)。