<%
function strLength(str)
   ON ERROR RESUME NEXT
   dim WINNT_CHINESE
   WINNT_CHINESE    = (len("ͬѧ¼")=3)
   if WINNT_CHINESE then
	  dim l,t,c
	  dim i
	  l=len(str)
	  t=l
	  for i=1 to l
		 c=asc(mid(str,i,1))
		 if c<0 then c=c+65536
		 if c>255 then
			t=t+1
		 end if
	  next
	  strLength=t
   else 
	  strLength=len(str)
   end if
   if err.number<>0 then err.clear
end function 

function isInteger(para)
     on error resume next
     dim str
     dim l,i
     if isNUll(para) then 
        isInteger=false
        exit function
     end if
     str=cstr(para)
     if trim(str)="" then
        isInteger=false
        exit function
     end if
     l=len(str)
     for i=1 to l
         if mid(str,i,1)>"9" or mid(str,i,1)<"0" then
            isInteger=false 
            exit function
         end if
     next
     isInteger=true
     if err.number<>0 then err.clear
end function


function cutStr(str,strlen)
	dim l,t,c,i
	l=len(str)
	t=0
	for i=1 to l
		c=Abs(Asc(Mid(str,i,1)))
		if c>255 then
			t=t+2
		else
			t=t+1
		end if
		if t>=strlen then
			cutStr=left(str,i)&"..."
			exit for
		else
			cutStr=str
		end if
	next
end function

function ChkPost()
	chkpost=false
	server_v1=Cstr(Request.ServerVariables("HTTP_REFERER"))
	server_v2=Cstr(Request.ServerVariables("SERVER_NAME"))
	if mid(server_v1,8,len(server_v2))<>server_v2 then
		chkpost=false
	else
		chkpost=true
	end if
end function


function GetRealname(byval username)
	Dim rSQL,rRs
	GetRealname=""
	if isnull(username) or username="" then exit function
	rSQL = "select realname from student where userid='"&username&"'"
	set rRs=conn.execute(rSQL)
	if not (rRs.eof and rRs.bof) then
		GetRealname=rRs(0)
	else
		GetRealname=""
	end if
	Set rRs=Nothing
end function

Function Checkstr(str)
	str=replace(str,"'","''")
	Checkstr=str
End Function

%>