<%
sub jyWriteJs(Str)
	response.write "<html><head><meta http-equiv=Content-Type content=text/html; charset=gb2312><title>提示</title><meta http-equiv=pragma content=no-cache><SCRIPT language=JavaScript>"&Str&"</SCRIPT></head><body></body></html>"
	If IsObject(Conn) Then Conn.Close:Set Conn = Nothing
	response.end
end sub

sub setAlert(AlertText)
	jyWriteJs("alert('"&AlertText&"');javascript:history.go(-1)")
end sub

sub PageTo(AlertText,ToPage)
	jyWriteJs("alert('"&AlertText&"');location.href='"&ToPage&"';")
end sub

sub setAlert2(AlertText)
	jyWriteJs("alert('"&AlertText&"');javascript:history.go(-2)")
end sub

sub closeWin(AlertText)
	jyWriteJs("alert('"&AlertText&"');window.close();")
end sub

sub pageBack(AlertText)
	Dim Comeurl,tmpStr
	If Request.ServerVariables("HTTP_REFERER")<>"" Then 
		tmpStr=split(Request.ServerVariables("HTTP_REFERER"),"/")
		Comeurl=tmpStr(UBound(tmpStr))
	Else
		Comeurl="/"
	End If
	jyWriteJs("<SCRIPT language=JavaScript>alert('"&AlertText&"');location.href='"&Comeurl&"';</SCRIPT>")
end sub

function checkStr(Str)
	if Str="" then exit function
	Str=replace(Str,"'","''")
	checkStr=Str
end function

function vipStr(Str,vip)
	if Str="" then exit function
	if vip<>"" then
		Str=replace(Str,vip,"<font color=#FF0000>"&vip&"</font>")
	end if
	vipStr=Str
end function

Function formattitle(String,thelong)
dim Temp
	Temp=String
	if len(Temp)>thelong then
		Temp=left(Temp,thelong-1)&".."
	end if
formattitle=Temp
End Function

function formathtml(Str)
	on error resume next
	Str=Replace(Str,"<","&lt;")
	Str=Replace(Str,">","&gt;")
	Str=Replace(Str,"'","''")
	Str=Replace(Str,CHR(10),"<br>")
	Str=Replace(Str,CHR(32)&CHR(32),"<p>")
	formathtml=Str			
End Function

function showdate(Str)
	on error resume next
	showdate=year(Str)&"-"&month(Str)&"-"&day(Str)
End Function

function rndfilename()
	Randomize
	rndfilename=year(date)&doublenum(month(date))&doublenum(day(date))&doublenum(hour(time))&doublenum(minute(time))&doublenum(second(time))&cint(1000*rnd())
end function

function doublenum(fNum)
	if fNum > 9 then 
		doublenum = fNum 
	else 
		doublenum = "0" & fNum
	end if
end function

function getfile(thefile)
	Dim Fso,objTxtFile
	Set Fso=Server.CreateObject("Scripting.FileSystemObject")
	If Fso.FileExists(Server.MapPath(thefile)) = True Then
		Set objTxtFile=Fso.OpenTextFile(Server.MapPath(thefile),1,True)
		getfile=objTxtFile.ReadAll
	else
		getfile=""
	end if
end function

sub writefile(thefile,Str)
	Dim fso,tf
	Set fso = CreateObject("Scripting.FileSystemObject")
	Set tf = fso.CreateTextFile(Server.MapPath(thefile),True)
	tf.Write(Str)
	tf.Close
end sub

function getcode(num,lei)
	dim thetext,temp,i
	select case lei
	case 1
		thetext=split("0|1|2|3|4|5|6|7|8|9","|")
	case 2
		thetext=split("0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z","|")
	end select
	
	temp=""
	Randomize
	for i = 1 to num
		temp=temp&thetext(cint(ubound(thetext)*rnd()))
	next
	getcode=temp
end function

'添加修改字段通用函数
Sub AddColumn(TableName,ColumnName,ColumnType)
	On Error Resume Next
	Dim Conn
	Set conn = Server.CreateObject("ADODB.Connection")
	conn.open ConnStr
	Conn.Execute("Alter Table "&TableName&" Add "&ColumnName&" "&ColumnType&"")
	If Err Then
		Response.Write TableTop & "新建 "&TableName&" 表中字段<font color=blue>错误</font>，请手动将数据库中 <B>"&ColumnName&"</B> 字段建立，属性为 <B>"&ColumnType&"</B>，原因" & Err.Description & "<BR>" & TableEnd
		Err.Clear
		Response.Flush
	Else
		Response.Write TableTop & "新建 "&TableName&" 表中字段 "&ColumnName&" 成功 <BR>" & TableEnd
		Response.Flush
	End If
End Sub
Sub upColumn(TableName,ColumnName,Value)
	On Error Resume Next
	Dim Conn
	Set conn = Server.CreateObject("ADODB.Connection")
	conn.open ConnStr
	Conn.Execute("update "&TableName&" set  "&ColumnName&"="&Value&"")
End Sub
%>