<%
Class clscommon
'检测提交内容
Private Rs
	Private SQL
	Public TrueValue
	Public ExecuteTotal,QueryTotal
	Public T_SQL_List	
 Private aRs 
   Private a_Page,a_SmallID,a_SID,a_P,aFileName
   Private aStartTag,aEndTag
   Private alStr,aSpecial,aC,aI,aV
   Private aUrl,aN,aCityID,aCity

	Public Sub Close_DB()
		If Rs.State = 1 Then Rs.Close
		Set Rs=Nothing
	End Sub
   Private Sub Class_Initialize()
     If ConnTypeStr < 1 Then
       ConnTime = "Now()"
     Else
       ConnTime = "GetDate()"
     End If
	 	ExecuteTotal=0
		QueryTotal=0
		T_SQL_List = ""

		Select Case iDataBaseType
		Case 0
			TrueValue="-1"
		Case 1,2
			TrueValue="1"
		End Select
	 '以下信息请不要修改，否则可能会显示不正常
	 Server_Url = "http://localhost/"
     Cversion = "txsky article system for asp 2.0"
     versionType = 0
	
   End Sub
   Private Sub Class_Terminate()
     Set aRs = Nothing
   End Sub
   '表单对应 Str：表单值 StrDB：数据库值 Num：0为 select(selected), 1为 radio(checked)和checkbox(checked)
   Function GetCheckVer(Str, StrDB, Num)
     Select Case Num
       Case 0
         If Str = StrDB Then GetCheckVer = " selected" Else GetCheckVer = ""
       Case 1
         If Str = StrDB Then GetCheckVer = " checked" Else GetCheckVer = ""
     End Select
   End Function
   '组件支持检测
   Function GetDll(DllSort)
     Dim WM_ObJ
     On Error Resume Next
     Set WM_ObJ = Server.CreateObject(DllSort)
     If Err Then GetDll = "×" Else GetDll = "√"
     Set WM_ObJ = Nothing
   End Function
   '获取页面执行时间
   Function ExecuteTime()
     eEndTime = Timer()
     ExecuteTime = GetFormatNumber((eEndTime - eStarTime),5) & " 秒"
   End Function
   function topictitle(str,num)
   if num=0 then 
   topictitle=str
   else
   topictitle=left(str,num)
   end if 
   end function 
Function CheckStr(Strer,Num)
        Dim Shield,w
	    If Strer = "" Or IsNull(Strer) Then Exit Function
	    Select Case Num
		  Case 0 '一般
			Strer = Trim(Strer)
			Strer = Replace(Strer,CHR(39),"&#39;")     '单引号
            Strer = Replace(Strer,CHR(34),"&quot;")    '双引号
            Strer = Replace(Strer,CHR(32),"&nbsp;")    '空格
            Strer = Replace(Strer,CHR(60),"&lt;")      '<
            Strer = Replace(Strer,CHR(62),"&gt;")      '>
            Strer = Replace(Strer,vbCrLf,"<br>")       
		  Case 1 '数字
	        If IsNumeric(Strer) = 0 Then
	          Response.Write "呀！系统已经完全崩溃了！！！！"
		      Response.End
	        End If
			Strer = Int(Strer)
		  Case 2'文本域提交
			Strer = Replace(Strer,CHR(39),"&#39;")     '单引号
            Strer = Replace(Strer,CHR(34),"&quot;")    '双引号
            Strer = Replace(Strer,CHR(32),"&nbsp;")    '空格
            Strer = Replace(Strer,CHR(60),"&lt;")      '<
            Strer = Replace(Strer,CHR(62),"&gt;")      '>
            Strer = Replace(Strer,vbCrLf,"<br>")       
		  Case 3'文本域显示
			Strer = Replace(Strer,"&#39;",CHR(39))     '单引号
            Strer = Replace(Strer,"&quot;",CHR(34))    '双引号
            Strer = Replace(Strer,"&nbsp;",CHR(32))    '空格
            Strer = Replace(Strer,"&lt;",CHR(60))      '<
            Strer = Replace(Strer,"&gt;",CHR(62))      '>
            Strer = Replace(Strer,"<br>",vbCrLf)
          Case 4
            Strer = Replace(Strer, WR_UpLoad(0), "{$SiteUpDir}")
          Case 5
            Strer = Replace(Strer, "{$SiteUpDir}", WR_UpLoad(0))
          Case 6 '支持HTML
            Strer = Replace(Strer, Chr(39), "&#39;")   '单引号
            Strer = Replace(Strer, vbCrLf, "<br>")
          Case 7
            Strer = Replace(Strer, "<br>", vbCrLf)
            Strer = Replace(Strer, "&#39;", Chr(39))   '单引号
		  Case 8 '数字,支持小数
	        If IsNumeric(Strer) = 0 Then
	          Response.Write "操作错误"
		      Response.End
	        End If
			Strer = Abs(Strer)
		End Select
	  '  Shield = Split(WR_Setting(11),vbCrLf)
	   ' For w=0 To Ubound(Shield)
		'  If Shield(w) <> "" Then
        '    Strer=Replace(Strer,Split(Shield(w),"=")(0),Split(Shield(w),"=")(1))
		'  End If
	   ' Next
	    CheckStr = Strer
   End Function
 Function db_query()

 End Function 
 '=======================================================================
 '*******************************************************************
	Public Function Execute(sSQL)
		On Error Resume Next
		Err.Clear 
		
		Conn.Execute(sSQL)
		
		ExecuteTotal=ExecuteTotal+1
		T_SQL_List = T_SQL_List & sSQL & "<br />"
		
		If Err Then 
			If ifsqlerr="1" Then
				ErrMsg="在执行以下语句：<br>"
				ErrMsg=ErrMsg&"&nbsp;&nbsp;<font color=800000>"&sSQL&"</font><br>"
				ErrMsg=ErrMsg&"时，发生以下错误：<br>"
				ErrMsg=ErrMsg&"&nbsp;&nbsp;<font color=800000>"&Err.Description&"</font>"
			Else
				ErrMsg="查询数据的时候发现错误。系统已关闭"
			End If
			 message errmsg,1
		Else
			Execute=0
		End If
	End Function
'====================================

'===================================================
Public Function Query(sSQL)
		On Error Resume Next
		Err.Clear 

		Set Rs1=Conn.Execute(sSQL)
		If Not Rs1.EOF And Not Rs1.BOF Then 
			Query=Rs1.GetRows()
		Else
			Query=0
		End If
		Rs1.Close 
		Set rs1=nothing
		QueryTotal=QueryTotal+1
		T_SQL_List = T_SQL_List & sSQL & "<br />"
		
		If Err Then 
			If ifsqlerr="1" Then
				ErrMsg="在执行以下语句：<br>"
				ErrMsg=ErrMsg&"&nbsp;&nbsp;<font color=800000>"&sSQL&"</font><br>"
				ErrMsg=ErrMsg&"时，发生以下错误：<br>"
				ErrMsg=ErrMsg&"&nbsp;&nbsp;<font color=800000>"&Err.Description&"</font>"
			Else
				ErrMsg="·查询数据的时候发现错误。系统已关闭"
			End If
			 message errmsg,1
		End If
	End Function
 '========================================================================
 Function message(str,num)
    Call ClassEnd()
	     Response.Write "<link href="&tx_setting(1)&"/css/admin/admin_Style.css rel=stylesheet type=text/css>"
	     Response.Write "<title>提示信息 - "&tx_Setting(0)&"</title>"
	     Response.Write "<table width='100%' height='100%' border=0 cellspacing=0 cellpadding=0><tr><td>"
	     Response.Write "<table align=center border=0 cellpadding=5 cellspacing=0 width='400' style='border:1px #CCCCCC solid;'>"
	     Response.Write "<tr><td height=22 style='border-bottom:1px #CCCCCC solid;padding:2px;background-color:#EFEFEF'>&nbsp;<b>友情提示：</b></td></tr>"
	     Response.Write "<tr><td height=180>"
	     Response.Write "<table width='80%' height='100%' border=0 cellspacing=0 cellpadding=0 align=center><tr><td>"
	     Response.Write Str
	     Response.Write "<br><br>·<a href=# Onclick=""javascript:history.back()"" style='cursor:pointer'>返回上一页</a>"
	     Response.Write "<br>·<a href=# Onclick=""javascript:window.parent.close()"" style='cursor:pointer'>关闭当前页</a>"
	     Response.Write "<br>·<a href='"&tx_setting(1)&"' target=_blank>Powered By "&tx_setting(0)&"</a>"
	     Response.Write "</td></tr></table>"
	     Response.Write "</table>"
	     Response.Write "</td></tr></table>"
	     Response.End
   End Function
   Function outHTML(str)
  Dim sTemp
  sTemp = str
  outHTML = ""
  If IsNull(sTemp) = True Then
    Exit Function
  End If
  sTemp = Replace(sTemp, "&", "&amp;")
  sTemp = Replace(sTemp, "<", "&lt;")
  sTemp = Replace(sTemp, ">", "&gt;")
  sTemp = Replace(sTemp, Chr(34), "&quot;")
  sTemp = Replace(sTemp, Chr(10), "<br>")
  outHTML = sTemp
End Function

' ============================================
' 去除Html格式，用于从数据库中取出值填入输入框时
' 注意：value="?"这边一定要用双引号
' ============================================
Function inHTML(str)
  Dim sTemp
  sTemp = str
  inHTML = ""
  If IsNull(sTemp) = True Then
    Exit Function
  End If
  sTemp = Replace(sTemp, "&", "&amp;")
  sTemp = Replace(sTemp, "<", "&lt;")
  sTemp = Replace(sTemp, ">", "&gt;")
  sTemp = Replace(sTemp, Chr(34), "&quot;")
  stemp = replace(stemp," ","&nbsp;")
  inHTML = sTemp
End Function
   End Class 
 
   %>