<%
'定义全局变量
dim sitename,siteurl,siteemail,adminname,logourl,bannerurl
dim SMTPserver,EmailSuport,SiteTitle
set rs=conn.execute("select * from config")
sitename=rs("sitename")     '系统名称
siteUrl=rs("siteurl")   '系统网址
SiteTitle=rs("SiteTitle")  ' 网站标题
SiteEmail=rs("siteemail")     '管理员邮件
adminname=rs("adminname")   '管理员名称s
logourl=rs("logourl")       'Logo地址
bannerurl=rs("bannerurl")   'Banner地址
SMTPserver=rs("SMTPserver")  '邮件服务器地址
EmailSuport=rs("EmailSuport")  '邮件组件支持

rs.close:set rs=nothing



Sub ShowFlash(ClassID,Num,Order)
 dim rst,i:i=1
 if classid="" or not isnumeric(classid) then
  exit sub
 end if
 
 if order="" then
    order="id"
 end if
 
 if not isnumeric(num) then
   num=10
 end if

 response.write "<table border=0 width=100% cellspacing=0 cellpadding=0>"
 set rst=conn.execute("select top "&num&" id,hits,dateandtime,flashname,username from flash where bigclassid="&ClassID&" order by "&order&" desc")
 if rst.bof and rst.eof then
   response.write "<tr><td height=22>&nbsp;<img src='images/dot3.gif' border=0>&nbsp;暂无更新</td></tr>"
 else
  do until rst.eof or i>num
   response.write "<tr><td height=22>&nbsp;<img src='images/dot3.gif' border=0>&nbsp;<A href='html/"&rst("id")&".htm' target=_blank title='作品名称："&rst("flashname")&"<br>作品上传："&rst("username")&"<br>上传日期："&rst("dateandtime")&"'>"&rst("flashname")&"</A>&nbsp;"&month(rst("dateandtime"))&"-"&day(rst("dateandtime"))&" | <FONT color=#FF3000>"&rst("hits")&"</FONT></td></tr>"
  rst.movenext
  i=i+1
  loop
 end if
 
 set rst=nothing
  '补充
 set rsg=conn.execute("select smallclassid from smallclass where bigclassid="&ClassID&"")
 '结束

 response.write "<tr><td height=22><P align=right><A href='showflash.asp?smallclassid="&rsg("smallclassid")&"'><img src='images/more.gif' border=0></A>　&nbsp;</P></td></tr>"
 response.write "</table>"
set rsg=nothing
End Sub

Function ShowBigClassName(ClassID)
 dim rss
 if not isnumeric(classid) then
   exit Function
 end if
 
 set rss=conn.execute("select bigclassname from bigclass where bigclassid="&classid)
 if rss.bof and rss.eof then
   ShowBigClassName="不详"
 else
   ShowBigClassName=rss(0)
 end if
 rss.close
 set rss=nothing
End Function

Function ShowSmallClassName(SmallClassID)
 dim rss
 if not isnumeric(SmallClassid) then
   exit Function
 end if
 
 set rss=conn.execute("select smallclassname from smallclass where smallclassid="&smallclassid)
 if rss.bof and rss.eof then
   ShowSmallClassName="不详"
 else
   ShowSmallClassName=rss(0)
 end if
 rss.close
 set rss=nothing
End Function

Sub FlashHot(num)
 dim strTemp,rsh,t
 t=1
 if not isnumeric(num) then
   num=10
 end if
 
 set rsh=conn.execute("select top 20 id,flashname,hits from flash order by hits desc")
 do until rsh.eof or t>num
   response.write t&".<A href='html/"&rsh("id")&".htm' target=_blank title='"&rsh("flashname")&"'>"&rsh("flashname")&"</A> … <FONT color=#FF3000>"&rsh("hits")&"</FONT><BR>" 
 rsh.movenext
 t=t+1
 loop
 rsh.close
 set rsh=nothing
 
End Sub

Sub Flashgood(num)
 dim strTemp,rsh,a
 a=1
 if not isnumeric(num) then
   num=10
 end if
 
 set rsh=conn.execute("select top 20 id,flashname,hits from flash where isgood=true order by id desc")
 do until rsh.eof or a>num
   response.write a&".<A href='html/"&rsh("id")&".htm' target=_blank title='"&rsh("flashname")&"'>"&rsh("flashname")&"</A> … <FONT color=#FF3000>"&rsh("hits")&"</FONT><BR>" 
 rsh.movenext
 a=a+1
 loop
 rsh.close
 set rsh=nothing
 
End Sub

Sub ShowBigClass()
  dim rss
  set rss=conn.execute("select * from bigclass order by b_order")
  do until rss.eof
    response.write "<a href='showsmall.asp?classid="&rss("bigclassid")&"' title='"&rss("bigclassname")&"'>"&rss("bigclassname")&"</a>&nbsp;&nbsp;"
  rss.movenext
  loop
  rss.close
  set rss=nothing
End Sub

Sub Showlink(ltype)
  dim rsl,strTemp,l
  l=1
  if not isinteger(ltype) then
    ltype=0
  end if
  set rsl=conn.execute("select * from link where ltype="&ltype&" and passed=true")
  strTemp="<table border='0' cellspacing='0' cellpadding='0'><tr>"
  
  do until rsl.eof
    if ltype>0 then
     strTemp=strTemp&"<td width='100' align=center height=40><a href='"&rsl("siteurl")&"' title='网站名称："&rsl("sitename")&"<br>加入日期："&rsl("dateandtime")&"<br>网站简介："&rsl("remark")&"' target=_blank><img src='"&rsl("logourl")&"' alt='网站名称："&rsl("sitename")&"<br>加入日期："&rsl("dateandtime")&"<br>网站简介："&rsl("remark")&"' border=0 height=31 width=88></a></td>"
	else
	 strTemp=strTemp&"<td width='100' height=25>&nbsp;<a href='"&rsl("siteurl")&"' title='网站名称："&rsl("sitename")&"<br>加入日期："&rsl("dateandtime")&"<br>网站简介："&rsl("remark")&"' target=_blank>"&rsl("sitename")&"</a></td>"
	end if
	 if l mod 7 =0 then
	   strTemp=strTemp&"</tr><tr>"
	 end if
  rsl.movenext
  l=l+1
  loop
  rsl.close
  set rsl=nothing
  strTemp=strTemp&"</tr></table>"
  response.write strTemp
End Sub 

sub mb(byval txt,byval url,byval go)
  response.write "<script language=Javascript>alert('"&txt&"');"
  if go<>1 then
    response.write "history.go(-1);"
  else
    response.write "document.location.href='"&url&"';"
  end if
  response.write "</script>"
  response.end
end sub

Rem 过滤HTML代码
function HTMLEncode(fString)
if not isnull(fString) then
    fString = replace(fString, ">", "&gt;")
    fString = replace(fString, "<", "&lt;")

    fString = Replace(fString, CHR(32), "&nbsp;")
    fString = Replace(fString, CHR(9), "&nbsp;")
    fString = Replace(fString, CHR(34), "&quot;")
    fString = Replace(fString, CHR(39), "&#39;")
    fString = Replace(fString, CHR(13), "")
    fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
    fString = Replace(fString, CHR(10), "<BR> ")

    'fString=ChkBadWords(fString)
    HTMLEncode = fString
else
   HTMLEncode=fstring
end if
end function

Rem 过滤表单字符
function HTMLcode(fString)
if not isnull(fString) then
    fString = Replace(fString, CHR(13), "")
    fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
    fString = Replace(fString, CHR(10), "<BR>")
    HTMLcode = fString
end if
end function

Rem 判断发言是否来自外部
function ChkPost()
	dim server_v1,server_v2
	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

Rem 过滤SQL非法字符
function checkStr(str)
	if isnull(str) then
		checkStr = ""
		exit function 
	end if
	checkStr=replace(str,"'","''")
end function


Rem 判断数字是否整形
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

rem 判断EMAIL参数
function IsEmail(email)

dim names, name, i, c

'Check for valid syntax in an email address.

IsEmail = true
names = Split(email, "@")
if UBound(names) <> 1 then
   IsEmail = false
   exit function
end if
for each name in names
   if Len(name) <= 0 then
     IsEmail = false
     exit function
   end if
   for i = 1 to Len(name)
     c = Lcase(Mid(name, i, 1))
     if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
       IsEmail = false
       exit function
     end if
   next
   if Left(name, 1) = "." or Right(name, 1) = "." then
      IsEmail = false
      exit function
   end if
next
if InStr(names(1), ".") <= 0 then
   IsEmail = false
   exit function
end if
i = Len(names(1)) - InStrRev(names(1), ".")
if i <> 2 and i <> 3 then
   IsEmail = false
   exit function
end if
if InStr(email, "..") > 0 then
   IsEmail = false
end if

end function

rem 判断字符串长度
function strLength(str)
       ON ERROR RESUME NEXT
       dim WINNT_CHINESE
       WINNT_CHINESE    = (len("天泉网络工作室")=7)
       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

rem 取字符串
function cutStr(str,strlen)
	dim l,t,c
	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
	cutStr=replace(cutStr,chr(10),"")
end function

function checknums(byval num1,byval num2)
  checknums=false
  if num1="" or num2="" then
   checknums=false
  elseif isnumeric(num1)=false or isnumeric(num2)=false then
   checknums=false
  elseif num1<=0  then
   checknums=false
  elseif clng(num1)>clng(num2) then
   checknums=false
  else
   checknums=true
  end if
end function

function makepassword(byval maxlen)
 dim strnewpass
 dim whatsnext,upper,lower,intcounter
 
 randomize
for intcounter=1 to maxlen
 whatsnext=int((1-0+1)*rnd+0)
 if whatsnext=0 then
  upper=90
  lower=65
 else
  upper=57
  lower=48
 end if 
   strnewpass=strnewpass&chr(int((upper-lower+1)*rnd+lower))
 next
  makepassword=lcase(strnewpass)
end function

sub checkflag(flag)
 if flag="" then
   response.End()
 end if
 if instr(session("flag"),flag)<1 then
  call mb("对不起，您没有管理该模块的权限！","",0)
  response.end
 end if
 
end sub

'***********************************************
'过程名：showpage
'作  用：显示“上一页 下一页”等信息
'参  数：sfilename  ----链接地址
'       totalnumber ----总数量
'       maxperpage  ----每页数量
'       ShowTotal   ----是否显示总数量
'       ShowAllPages ---是否用下拉列表显示所有页面以供跳转。有某些页面不能使用，否则会出现JS错误。
'       strUnit     ----计数单位
'***********************************************
sub showpage(sfilename,totalnumber,maxperpage,ShowTotal,ShowAllPages,strUnit)
	dim n, i,strTemp,strUrl
	if totalnumber mod maxperpage=0 then
    	n= totalnumber \ maxperpage
  	else
    	n= totalnumber \ maxperpage+1
  	end if
  	strTemp= "<table align='center' ><tr><td>"
	if ShowTotal=true then 
		strTemp=strTemp & "共 <b>" & totalnumber & "</b> " & strUnit & "&nbsp;&nbsp;"
	end if
	strUrl=JoinChar(sfilename)
  	if CurrentPage<2 then
    		strTemp=strTemp & "首页 上一页&nbsp;"
  	else
    		strTemp=strTemp & "<a href='" & strUrl & "page=1'>首页</a>&nbsp;"
    		strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage-1) & "'>上一页</a>&nbsp;"
  	end if

  	if n-currentpage<1 then
    		strTemp=strTemp & "下一页 尾页"
  	else
    		strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage+1) & "'>下一页</a>&nbsp;"
    		strTemp=strTemp & "<a href='" & strUrl & "page=" & n & "'>尾页</a>"
  	end if
   	strTemp=strTemp & "&nbsp;页次：<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
    strTemp=strTemp & "&nbsp;<b>" & maxperpage & "</b>" & strUnit & "/页"
	if ShowAllPages=True then
		strTemp=strTemp & "&nbsp;转到：<select class='input' name='page' size='1' onchange=""javascript:window.location='" & strUrl & "page=" & "'+this.options[this.selectedIndex].value;"">"   
    	for i = 1 to n   
    		strTemp=strTemp & "<option value='" & i & "'"
			if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "
			strTemp=strTemp & ">第" & i & "页</option>"   
	    next
		strTemp=strTemp & "</select>"
	end if
	strTemp=strTemp & "</td></tr></table>"
	response.write strTemp
end sub

'***********************************************
'过程名：showpage
'作  用：显示“上一页 下一页”等信息
'参  数：sfilename  ----链接地址
'       totalnumber ----总数量
'       maxperpage  ----每页数量
'       ShowTotal   ----是否显示总数量
'       ShowAllPages ---是否用下拉列表显示所有页面以供跳转。有某些页面不能使用，否则会出现JS错误。
'       strUnit     ----计数单位
'***********************************************
sub showpage22(sfilename,totalnumber,maxperpage,ShowTotal,ShowAllPages,strUnit)
	dim n, i,strTemp,strUrl
	if totalnumber mod maxperpage=0 then
    	n= totalnumber \ maxperpage
  	else
    	n= totalnumber \ maxperpage+1
  	end if
  	strTemp= "<table align='center'><tr><td>"
	if ShowTotal=true then 
		strTemp=strTemp & "共 <b>" & totalnumber & "</b> " & strUnit & "&nbsp;&nbsp;"
	end if
	strUrl="admin_comment.asp"
  	if CurrentPage<2 then
    		strTemp=strTemp & "首页 上一页&nbsp;"
  	else
    		strTemp=strTemp & "<a href='" & strUrl & "?page=1'>首页</a>&nbsp;"
    		strTemp=strTemp & "<a href='" & strUrl & "?page=" & (CurrentPage-1) & "'>上一页</a>&nbsp;"
  	end if

  	if n-currentpage<1 then
    		strTemp=strTemp & "下一页 尾页"
  	else
    		strTemp=strTemp & "<a href='" & strUrl & "?page=" & (CurrentPage+1) & "'>下一页</a>&nbsp;"
    		strTemp=strTemp & "<a href='" & strUrl & "?page=" & n & "'>尾页</a>"
  	end if
   	strTemp=strTemp & "&nbsp;页次：<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
    strTemp=strTemp & "&nbsp;<b>" & maxperpage & "</b>" & strUnit & "/页"
	if ShowAllPages=True then
		strTemp=strTemp & "&nbsp;转到：<select class='input' name='page' size='1' onchange=""javascript:window.location='" & strUrl & "?page=" & "'+this.options[this.selectedIndex].value;"">"   
    	for i = 1 to n   
    		strTemp=strTemp & "<option value='" & i & "'"
			if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "
			strTemp=strTemp & ">第" & i & "页</option>"   
	    next
		strTemp=strTemp & "</select>"
	end if
	strTemp=strTemp & "</td></tr></table>"
	response.write strTemp
end sub

'***********************************************
sub showpage11(sfilename,totalnumber,maxperpage,ShowTotal,ShowAllPages,strUnit)
	dim n, i,strTemp,strUrl
	if totalnumber mod maxperpage=0 then
    	n= totalnumber \ maxperpage
  	else
    	n= totalnumber \ maxperpage+1
  	end if
  	strTemp= "<table align='center' class=""style1""><tr><td>"
	if ShowTotal=true then 
		strTemp=strTemp & "共 <b>" & totalnumber & "</b> " & strUnit & "&nbsp;&nbsp;"
	end if
	strUrl=sfilename
  	if CurrentPage<2 then
    		strTemp=strTemp & "首页 上一页&nbsp;"
  	else
    		strTemp=strTemp & "<a href='" & strUrl & "&page=1'>首页</a>&nbsp;"
    		strTemp=strTemp & "<a href='" & strUrl & "&page=" & (CurrentPage-1) & "'>上一页</a>&nbsp;"
  	end if

  	if n-currentpage<1 then
    		strTemp=strTemp & "下一页 尾页"
  	else
    		strTemp=strTemp & "<a href='" & strUrl & "&page=" & (CurrentPage+1) & "'>下一页</a>&nbsp;"
    		strTemp=strTemp & "<a href='" & strUrl & "&page=" & n & "'>尾页</a>"
  	end if
   	strTemp=strTemp & "&nbsp;页次：<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
    strTemp=strTemp & "&nbsp;<b>" & maxperpage & "</b>" & strUnit & "/页"
	if ShowAllPages=True then
		strTemp=strTemp & "&nbsp;转到：<select class='input' name='page' size='1' onchange=""javascript:window.location='" & strUrl & "&page=" & "'+this.options[this.selectedIndex].value;"">"   
    	for i = 1 to n   
    		strTemp=strTemp & "<option value='" & i & "'"
			if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "
			strTemp=strTemp & ">第" & i & "页</option>"   
	    next
		strTemp=strTemp & "</select>"
	end if
	strTemp=strTemp & "</td></tr></table>"
	response.write strTemp
end sub

'***********************************************
'函数名：JoinChar
'作  用：向地址中加入 ? 或 &
'参  数：strUrl  ----网址
'返回值：加了 ? 或 & 的网址
'***********************************************
function JoinChar(strUrl)
	if strUrl="" then
		JoinChar=""
		exit function
	end if
	if InStr(strUrl,"?")<len(strUrl) then 
		if InStr(strUrl,"?")>1 then
			if InStr(strUrl,"&")<len(strUrl) then 
				JoinChar=strUrl & "&"
			else
				JoinChar=strUrl
			end if
		else
			JoinChar=strUrl & "?"
		end if
	else
		JoinChar=strUrl
	end if
end function 

sub showannounce()
  dim rss,announce_content
  set rss=conn.execute("select top 1 * from announce where isshow=true order by id desc")
  
  if rss.bof and rss.eof then
    response.write "暂无公告！"
  else
    announce_content=rss("announce")
	announce_content=replace(announce_content,chr(13),"<br>")
	announce_content=replace(announce_content," ","&nbsp;")
   response.write announce_content
  end if
 rss.close:set rss=nothing
end sub

Function checkflag(flag)
 if flag="" then
   checkflag=false
   Exit Function
 end if
 if instr(session("flag"),flag)<1 then
  checkflag=false
  exit function
 else
  checkflag=true 
 end if
end Function
%>










