欧美日韩精品在线,国内精品久久久久久久久,一级毛片恃级毛片直播,清纯唯美亚洲综合欧美色

實(shí)現(xiàn)Web中的@虛擬域名系統(tǒng)(原理篇)(2)_Windows教程

編輯Tag賺U幣
教程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文件改一下便可。

來源:網(wǎng)絡(luò)搜集//所屬分類:Windows教程/更新時(shí)間:2012-06-11
相關(guān)Windows教程