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 >
Wrap
Text File
|
2005-12-26
|
4KB
|
167 lines
<%@language=vbscript codepage=936 LCID=2052 %>
<%
option explicit
response.buffer=true
dim conn,connstr
dim master
dim i
dim objET
set objET=new clsExeTime
Set Conn=Server.CreateObject("ADODB.Connection")
'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;"
'connstr="DBQ=" & server.mapPath("public/global.asa") & ";DRIVER={Microsoft Access Driver (*.mdb)};"
connstr ="Provider = Microsoft.Jet.OLEDB.4.0; Data Source ="& Server.MapPath("db/global.mdb")
Conn.Open connstr
master=getMaster
dim theUser
set theUser=new users
sub connclose
conn.close
set conn=nothing
end sub
sub rsclose
rs.close
set rs=nothing
end sub
function encodestr(str)
str=trim(str)
str=replace(str,"<","<")
str=replace(str,">",">")
str=replace(str,"'","""")
str=replace(str,vbCrLf&vbCrlf,"</p><p>")
str=replace(str,vbCrLf,"<br>")
str=Replace(str,"","&#")
encodestr=replace(str," ","íí")
end function
function validEmail(email)
dim length, atIndex, dotIndex
length=len(email)
atIndex=instr(email,"@")
dotIndex=instrrev(email,".")
if length<6 then
validEmail=false
exit function
end if
if atIndex<0 or dotIndex<0 or length-dotIndex<2 or dotIndex-atIndex<3 then
validEmail=false
exit function
end if
validEmail=true
end function
function getMaster()
dim rs, sql,str,LF
LF=chr(10)
sql="select username from [user] where gbuserClass>0"
set rs=conn.execute(sql)
if not (rs.eof and rs.bof ) then
str=rs(0)
rs.movenext
do until rs.eof
str=str & LF & rs(0)
rs.movenext
loop
end if
getMaster=split(str,LF)
'response.write str
end function
function isMaster(name)
isMaster=false
for i=0 to ubound(master)
if master(i)=name then
isMaster=true
exit function
end if
next
end function
function isLikeMasterName(name)
isLikeMasterName=false
for i=0 to ubound(master)
if instr(name,master(i))>0 then
isLikeMasterName=true
exit function
end if
next
end function
class users
dim id, name,pass,reged,master,male,face,email,qq,url,icq,msn,admin
private sub class_initialize()
dim rs,sql
name=request.cookies("gbook")("username")
if name<>"" then
name=replace(vbunescape(name),"'","")
end if
pass=replace(request.cookies("gbook")("password"),"'","")
reged=false
master=false
admin=false
male=true
id=0
if name<>"" and pass<>"" then
sql="select top 1 userid, username,userpassword,useremail,sex,GBface,oicq,icq,msn,homepage,gbuserclass from [user] where username='"&name&"' "
set rs=conn.execute(sql)
if (not rs.eof) then
if pass=rs("userpassword") then
reged=true
id=rs("userid")
if rs("sex")="1" then
male=true
else
male=false
end if
face=rs("GBface")
email=rs("useremail")
qq=rs("oicq")
icq=rs("icq")
msn=rs("msn")
url=rs("homepage")
if rs("gbuserclass")>0 then
master=true
if rs("gbuserclass")=2 then
admin=true
else
admin=false
end if
else
master=false
admin=false
end if
end if
end if
rs.close
end if
end sub
end class
class clsExeTime
dim t1,t2
private sub class_initialize()
t1=timer
end sub
public function read()
t2=timer
read=formatnumber((t2-t1)*1000,2,-1)
end function
end class
%>
<script language=javascript runat=server>
function vbunescape(s)
{return unescape(s);}
function vbescape(s)
{return escape(s);}
</script>