<%
'-------share dim -----------
dim dbfilename
dbfilename="mdb.mdb" '此为数据库文件名
dim connstr
dim conn
server.scripttimeout=1
set conn=server.createobject("adodb.connection")
conn.connectionstring="provider=microsoft.jet.oledb.4.0;data source="&server.mappath("data/"&dbfilename)
conn.open

'-------share dim end -------
%>
<%
'#checkerr
sub checkerr
	if conn.errors.count > 0 then
		response.write "data error!<br><br>"
		for i=0 to conn.errors.count-1
			response.write conn.errors(i).description&"<br>"
		next
	response.end
	end if
end sub
%>
<%
'#opendb
sub opendb
	'connstr="dbq="+server.mappath("data/23798drlkkj345#$%#%")+";defaultdir=;driver={microsoft access driver (*.mdb)}"
	'set conn=server.createobject("adodb.connection")
	'conn.open connstr
end sub
%>
<%
'#closedb
sub closedb
	conn.close
	set conn=nothing
end sub
%>
<%
'#addusersn
sub addusersn
	sql="select * from userinfo where uid='"&uid&"'"
	set rs=server.createobject("adodb.recordset")
	'opendb
	rs.open sql, conn, 1, 3
	if rs.eof then 
		'response.redirect "error.asp?emsg=data error, no such user!"
		'response.end
	else
	sn=rs("sn")
	rs("sn")=sn+1
	rs.update
	end if
	rs.close
	set rs=nothing
	'closedb
end sub
%>
<%
'#adduserpos
sub adduserpos
	sql="select * from userinfo where uid='"&uid&"'"
	'opendb
	on error resume next
	set rs=server.createobject("adodb.recordset")
	rs.open sql, conn , 1,3
	pos=rs("pos")
	rs("pos")=pos+1
	rs.update
	rs.close
	checkerr
	set rs=nothing
	'closedb
end sub
%>


<%
function eml(str)
	'on error resume next
	str=lcase(str)
	'response.write "<font color=GREEN>*</font>"
	dim onechr
	dim emlhead
	dim emlnum
	dim found
	found=false
	for i=1 to len(str)
		onechr=mid(str,i,1)
		'response.write onechr
		if onechr="[" then
			emlhead=mid(str,i,7)
			if left(emlhead,4)="[:em" then
				'response.write "<font color=RED>"&i&"</font>"
				if mid(emlhead,5,1)<>"" then
					emlnum=mid(emlhead,5,2)
					'response.write emlnum
					eml=left(str,i-1)&"<img src='em/em"&emlnum&".gif'>"&eml(mid(str,i+7))
					found=true
					exit for
				end if
			end if
		end if
	next
	if found=false then
		eml=str
	end if
end function
%>