<%
Class q_zone


'Public Function JaKillStr(cs_txt)
        'JaKillStr =cs_txt
'End Function

Public Function JaKillStr(Str) 
If IsNull(Str) Or IsEmpty(Str) Then
			Str	= ""
		End If
		JaKillStr	= Replace(Str,";","")
		JaKillStr	= Replace(JaKillStr,"'","")
		JaKillStr	= Replace(JaKillStr,"&","")
		JaKillStr	= Replace(JaKillStr," ","")
		JaKillStr	= Replace(JaKillStr,"　","")
		JaKillStr	= Replace(JaKillStr,"%20","")
		JaKillStr	= Replace(JaKillStr,"--","")
		JaKillStr	= Replace(JaKillStr,"==","")
		JaKillStr	= Replace(JaKillStr,"<","")
		JaKillStr	= Replace(JaKillStr,">","")
		JaKillStr	= Replace(JaKillStr,"%","")
End function


Public Function GetHeadElement(select_list,num,table_source,order_expression)
dim sql,str,rs,i
sql="select "&select_list&" from "&table_source&" where JaUid='"&num&"' "&order_expression
str=""
set rs=server.createobject("ADODB.recordset")
rs.open sql,conn,1,1
For i = 0 To rs.Fields.Count - 1
	if i<> rs.Fields.Count - 1 then
			str=str&rs(i)&"<><><>"
	else
			str=str&rs(i)
	end if
Next
rs.close
set rs=nothing
GetHeadElement=str
End Function

public function JaSelect(table,sql)
dim tmpsql,rs,str,i
tmpsql="select * from "&table&" where "&sql
str=""
set rs=server.createobject("ADODB.recordset")
rs.open tmpsql,conn,1,1
For i = 0 To rs.Fields.Count - 1
	if i<> rs.Fields.Count - 1 then
			str=str&rs(i)&"<><><>"
	else
			str=str&rs(i)
	end if
Next
rs.close
set rs=nothing
JaSelect=str
end function

Public Function GetRsElement(select_list,num,table_source,order_expression)
dim rs,sql,MyArray()
sql="select "&select_list&" from "&table_source&" where JaUid='"&B&"' "&order_expression
set rs=server.createobject("ADODB.recordset")
rs.open sql,conn,1,1
redim  MyArray(rs.Fields.Count-1,rs.recordcount-1)
i=0
 do while not rs.eof
  for j=0 to rs.Fields.Count-1
  MyArray(j,i)=rs(j)
  next
 i=i+1
 rs.movenext
 loop
GetRsElement=MyArray
End Function


Public Function GetBlogRe(select_list,table_source,condition)
dim sql,rs,i,j
sql="select "&select_list&" from "&table_source&" where "&condition
set rs=server.createobject("ADODB.recordset")
rs.open sql,conn,1,1
if not rs.eof then
  redim  MyArray(rs.Fields.Count-1,rs.recordcount-1)
  i=0
  do while not rs.eof
      for j=0 to rs.Fields.Count-1
      MyArray(j,i)=rs(j)
      next
    i=i+1
    rs.movenext
  loop
GetBlogRe=MyArray
else
GetBlogRe=false
end if
End Function


Public Function GetCount(count_expression,table_source,order_expression)
Dim rs
rs=conn.execute("select "&count_expression&" from "&table_source&" "&order_expression)(0)
GetCount=rs
End Function


Public Function JaZoneL(num)
dim list,money
money=conn.execute("select JaMonery from JaUser where JaUid='"&num&"'")(0)
list=conn.execute("select count(JaUid) from JaUser where JaMonery>"&money)(0)
JaZoneL = list+1
End Function


Public Function JaIsUser(num)
if session("vicnum")=num Then
'response.Write SESSION("VicNum")
'response.end
JaIsUser="yes"
else
'response.end
JaIsUser="no"
end if
End Function


public function JaIsRegUser(num)
	if isempty(session("vicnum")) or isnull(session("vicnum")) or session("vicnum")="" then
		JaIsRegUser="no"
	else
		JaIsRegUser="yes"
	end if 

end function

Public Function JaVicRecord(LoginUserName,VicNum,JaUid)

dim rs
if LoginUserName<>"" and VicNum<>"" and JaUid<>"" then
conn.execute("DELETE FROM [JaVicList] where datediff(s,JaVicDate,'"&now&"')>3")
set rs=conn.execute("select * from JaVicList where JaVicName='"&LoginUserName&"' and JaVicNum='"&VicNum&"' and JaUid='"&JaUid&"'")

   if rs.eof then
   conn.execute("insert into JaVicList(JaVicName,JaVicNum,JaUid) VALUES ('"&LoginUserName&"','"&VicNum&"','"&JaUid&"')")
   else
   conn.execute("update JaVicList set JaVicDate='"&now&"' where JaVicName='"&LoginUserName&"' and JaVicNum='"&VicNum&"' and JaUid='"&JaUid&"'")
   end if
      
end if
End Function

Public Function JaInsert(table_source,JaInSQL)
conn.execute("insert into "&table_source&JaInSQL)
End Function

Public Function JaDelete(table_source,JaInSQL)
conn.execute("delete from "&table_source&" where "&JaInSQL)
End Function

Public Function strLen(txt)
strLen=len(txt)
End Function

Public Function HTMLEncode(txt)
HTMLEncode=Server.HTMLEncode(txt)
End Function

Public Function JaVicBlog(sqlc,table_source,condition)
Conn.ExeCute("Update ["&table_source&"] SET "&sqlc&" WHERE "&condition)
End Function

Public Function JaCheckLogin(Logna,LogPwd)
dim Clogin

set Clogin = Conn.ExeCute("SELECT * FROM [JaUser] WHERE JaUname='"&Logna&"' and JaPass='"&LogPwd&"'")
'response.write "SELECT * FROM [JaUser] WHERE JaUname='"&Logna&"' and JaPass='"&LogPwd&"'"
'response.end
If Clogin.eof then
JaCheckLogin=0
else
JaCheckLogin=1
session("vicnum")=cstr(Clogin("JaUid"))
SESSION("LoginUserName")=Clogin("JaUname")
end if
End Function

Public Function JaUserID()
dim rs,sql
Set rs = conn.execute("select top 1 JaUid,JaExpdata from JaUser order by JaExpdata desc")
JaUserID=int(rs("JaUid"))+1
IF JaUserID="" THEN JaUserID=1
End Function

Public Function JaUserAdd(JaUID,Jauserna,Japwd,Jazonena,JaAge,JaBorn,Jasex,Jainter,Jaxue,Jaxin,Jamemo,JaSheng,JaShi,JaYou)
Dim JaFace
if Jasex="男" then
JaFace="face/00.gif"
else
JaFace="face/01.gif"
end if
conn.execute("insert into JaUser(JaUID,JaUname,JaPass,JaZoneName,JaAge,JaBorn,JaSex,JaInter,JaXue,JaXin,JaMemo,JaFace,province,city,JaYou) VALUES ('"&JaUID&"','"&Jauserna&"','"&Japwd&"','"&Jazonena&"',"&JaAge&",'"&JaBorn&"','"&Jasex&"','"&Jainter&"','"&Jaxue&"','"&Jaxin&"','"&Jamemo&"','"&JaFace&"','"&jasheng&"','"&Jashi&"','"&JaYou&"')")
session("vicnum")=cstr(JaUID)
SESSION("LoginUserName")=Jauserna

End Function
end class

'限制长度截取左边的字符串
'参数txt 为原始字符串
'参数length 为新字符串的长度，汉字算两个字符，英文字母算一个字符

Function InterceptString(txt,length)
	dim x,y,ii
	txt=trim(txt)
	x = len(txt)
	y = 0
	if x >= 1 then
		for ii = 1 to x
			if asc(mid(txt,ii,1)) < 0 or asc(mid(txt,ii,1)) >255 then '如果是汉字
				y = y + 2
			else
				y = y + 1
			end if
			if clng(y)>=clng(length) then
				txt = left(trim(txt),ii) '字符串限长
				InterceptString = txt &"..."
				exit for
			else
				InterceptString = txt
			end if
		next
		
	else
		InterceptString = ""
	end if
End Function


%>