home *** CD-ROM | disk | FTP | other *** search
/ 221.214.14.186 / 221.214.14.186.tar / 221.214.14.186 / zb / Notepad-zb / conn.asp < prev    next >
Text File  |  2005-12-26  |  4KB  |  167 lines

  1. <%@language=vbscript codepage=936 LCID=2052 %>
  2. <%
  3. option explicit
  4. response.buffer=true
  5.  
  6. dim conn,connstr
  7. dim master
  8. dim i
  9. dim objET
  10. set objET=new clsExeTime
  11.  
  12. Set Conn=Server.CreateObject("ADODB.Connection")
  13. 'Connstr="DBQ="+server.mappath("public/ly.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;ImplicitCommitSync=Yes;MaxBufferSize=512;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UserCommitSync=Yes;"
  14. 'connstr="DBQ=" & server.mapPath("public/global.asa") & ";DRIVER={Microsoft Access Driver (*.mdb)};"
  15. connstr ="Provider = Microsoft.Jet.OLEDB.4.0; Data Source ="& Server.MapPath("db/global.mdb")
  16. Conn.Open connstr
  17.  
  18. master=getMaster
  19.  
  20. dim theUser
  21. set theUser=new users
  22.  
  23. sub connclose
  24.     conn.close
  25.     set conn=nothing
  26. end sub
  27.  
  28. sub rsclose
  29.     rs.close
  30.     set rs=nothing
  31. end sub
  32.  
  33. function encodestr(str)
  34.     str=trim(str)
  35.     str=replace(str,"<","<")
  36.     str=replace(str,">",">")
  37.     str=replace(str,"'","""")
  38.     str=replace(str,vbCrLf&vbCrlf,"</p><p>")
  39.     str=replace(str,vbCrLf,"<br>")
  40.     str=Replace(str,"&#","&#")
  41.     encodestr=replace(str,"  ","íí")
  42. end function
  43.  
  44. function validEmail(email)
  45.     dim length, atIndex, dotIndex
  46.     length=len(email)
  47.     atIndex=instr(email,"@")
  48.     dotIndex=instrrev(email,".")
  49.     if length<6 then
  50.         validEmail=false
  51.         exit function
  52.     end if
  53.     if atIndex<0 or dotIndex<0 or length-dotIndex<2 or dotIndex-atIndex<3 then
  54.         validEmail=false
  55.         exit function
  56.     end if
  57.     validEmail=true
  58. end function
  59.  
  60. function getMaster()
  61.     dim rs, sql,str,LF
  62.     LF=chr(10)
  63.     sql="select username from [user] where gbuserClass>0"
  64.     set rs=conn.execute(sql)
  65.     if not (rs.eof and rs.bof ) then
  66.         str=rs(0)
  67.         rs.movenext
  68.         do until rs.eof
  69.             str=str & LF & rs(0)
  70.             rs.movenext
  71.         loop
  72.     end if
  73.     getMaster=split(str,LF)
  74.     'response.write str
  75. end function
  76.  
  77. function isMaster(name)
  78.     isMaster=false
  79.     for i=0 to ubound(master)
  80.         if master(i)=name then
  81.             isMaster=true
  82.             exit function
  83.         end if
  84.     next
  85. end function
  86.  
  87. function isLikeMasterName(name)
  88.     isLikeMasterName=false
  89.     for i=0 to ubound(master)
  90.         if instr(name,master(i))>0 then
  91.             isLikeMasterName=true
  92.             exit function
  93.         end if
  94.     next
  95. end function
  96.  
  97. class users
  98.     dim id, name,pass,reged,master,male,face,email,qq,url,icq,msn,admin
  99.  
  100.     private sub class_initialize()
  101.         dim rs,sql
  102.         name=request.cookies("gbook")("username")
  103.         if name<>"" then
  104.             name=replace(vbunescape(name),"'","")
  105.         end if
  106.         pass=replace(request.cookies("gbook")("password"),"'","")
  107.         reged=false
  108.         master=false
  109.         admin=false
  110.         male=true
  111.         id=0
  112.         if name<>"" and pass<>"" then
  113.             sql="select top 1 userid, username,userpassword,useremail,sex,GBface,oicq,icq,msn,homepage,gbuserclass from [user] where username='"&name&"' "
  114.             set rs=conn.execute(sql)
  115.             if (not rs.eof) then
  116.                 if pass=rs("userpassword") then
  117.                     reged=true
  118.                     id=rs("userid")
  119.                     if rs("sex")="1" then
  120.                         male=true
  121.                     else
  122.                         male=false
  123.                     end if
  124.                     face=rs("GBface")
  125.                     email=rs("useremail")
  126.                     qq=rs("oicq")
  127.                     icq=rs("icq")
  128.                     msn=rs("msn")
  129.                     url=rs("homepage")
  130.                     if rs("gbuserclass")>0 then
  131.                         master=true
  132.                         if rs("gbuserclass")=2 then
  133.                             admin=true
  134.                         else
  135.                             admin=false
  136.                         end if
  137.                     else
  138.                         master=false
  139.                         admin=false
  140.                     end if
  141.                 end if
  142.             end if
  143.             rs.close
  144.         end if
  145.     end sub
  146. end class
  147.  
  148. class clsExeTime
  149.     dim t1,t2
  150.     private sub class_initialize()
  151.         t1=timer
  152.     end sub
  153.     public function read()
  154.         t2=timer
  155.         read=formatnumber((t2-t1)*1000,2,-1)
  156.     end function
  157. end class
  158.  
  159.  
  160. %>
  161. <script language=javascript runat=server>
  162. function vbunescape(s)
  163. {return unescape(s);}
  164. function vbescape(s)
  165. {return escape(s);}
  166. </script>
  167.