<%
'//关闭数据库
sub connClose()
conn.close:set conn=nothing
end sub

sub Chkhttp()
server_vv=len(Request.ServerVariables("SERVER_NAME"))
server_v1=left(Cstr(Request.ServerVariables("HTTP_REFERER")),server_vv)
server_v2=left(Cstr("http://"&Request.ServerVariables("SERVER_NAME")),server_vv)
if server_v1<>server_v2 or server_v1="" or server_v1="" then
response.Charset="gb2312"
response.write("<script>alert('错误：禁止从站点外部提交数据！')</script>")
response.end
end if
end sub

'函数：操作提示
function ErrMsg(tmp)
connClose()
p3t "<script>alert('对不起，"&tmp&"！');</script>"
p3t_end
end function

'//限制文本内容
function leftStr(content,leftNum)
dim tmp
	if len(content)>leftNum then
		tmp=left(content,leftNum)&".."
	else
		tmp=content
	end if
leftStr=tmp
end function

'//自定义sql
function connExecute(sql,num)
dim tmp
	set rs_sql=conn.execute(sql)
	if not rs_sql.eof then
		tmp=rs_sql(num)
	else
		tmp=""
	end if
	set rs_sql=nothing
connExecute=tmp
end function

'//输出
function p3t(txt):response.Write(txt):end function
'//停止
function p3t_end():response.end:end function


'//分页
function getPages(Rs,NowPage,PageSize,PageList,LinkFile)
dim tmp
	if LinkFile<>"?" then LinkFile=LinkFile&"&"
	tmp=tmp&"<div class=""pager_total"">共计 <strong>"&Rs.RecordCount&"</strong> 条记录，当前第 <strong>"&NowPage&"</strong> 页，共 <strong>"&Rs.PageCount&"</strong> 页</div>"
	tmp=tmp&"<div class=""pager_ctrl"">"
	if NowPage>1 then
		tmp=tmp&" <a href="""&LinkFile&"page=1"">第一页</a> <a href="""&LinkFile&"page="&NowPage-1&""">上一页</a>"
	else
		tmp=tmp&" <a class=""disabled"">首页</a> <a class=""disabled"">上一页</a>"
	end if
	if NowPage<Rs.PageCount then 
		tmp=tmp&" <a href="""&LinkFile&"page="&NowPage+1&""">下一页</a> <a href="""&LinkFile&"page="&Rs.PageCount&""">尾页</a>"
	else
		tmp=tmp&" <a class=""disabled"">下一页</a> <a class=""disabled"">尾页</a>"
	end if
	tmp=tmp&" 转到第 <input id=""pages"" type=""text"" maxlength=""3"" onkeyup=""this.value=this.value.replace(/[^\d]/g,'')"" /> 页 <a href=""javascript:;"" onclick=""if(pages.value!='')location.href='"&LinkFile&"page='+pages.value;"">GO</a>"
	tmp=tmp&"</div>"
	tmp=tmp&"<div class=""clearfix""></div>"
getPages=tmp
end function

'//日期格式化
Public Function FormatDate(DateAndTime, para)
On Error Resume Next
Dim y, m, d, h, mi, s, strDateTime
FormatDate = DateAndTime
If Not IsNumeric(para) Then Exit Function
If Not IsDate(DateAndTime) Then Exit Function
y = CStr(Year(DateAndTime))
m = CStr(Month(DateAndTime))
If Len(m) = 1 Then m = "0" & m
d = CStr(Day(DateAndTime))
If Len(d) = 1 Then d = "0" & d
h = CStr(Hour(DateAndTime))
If Len(h) = 1 Then h = "0" & h
mi = CStr(Minute(DateAndTime))
If Len(mi) = 1 Then mi = "0" & mi
s = CStr(Second(DateAndTime))
If Len(s) = 1 Then s = "0" & s
Select Case para
Case "1"
'显示格式：09年07月06日 13:44 
strDateTime = y & "-" & m & "-" & d & " " & h & ":" & mi & ":" & s
Case "2"
'显示格式：2009-07-06
strDateTime = y & "-" & m & "-" & d
Case "3"
'显示格式：2009-07-06 13:45
strDateTime = y & "-" & m & "-" & d & " " & h & ":" & mi
Case "4"
'显示格式：2009年07月06日
strDateTime = y & "年" & m & "月" & d & "日"
Case "5"
'显示格式：07-06 13:45
strDateTime = m & "-" & d & " " & h & ":" & mi
Case "6"
'显示格式：07/06
strDateTime = m & "/" & d
Case "7"
'显示格式：07月06日
strDateTime = m & "月" & d & "日"
Case "8"
'显示格式：2009年07月
strDateTime = y & "年" & m & "月"
Case "9"
'显示格式：2009-07
strDateTime = y & "-" & m
Case "10"
'显示格式：2009/07
strDateTime = y & "/" & m
Case "11"
'显示格式：09年07月06日 13:45
strDateTime = right(y,2) & "年" &m & "月" & d & "日 " & h & ":" & mi
Case "12"
'显示格式：09-07-06
strDateTime = right(y,2) & "-" &m & "-" & d
Case "13"
'显示格式：07-06
strDateTime = m & "-" & d
Case "14"
'显示格式：13:45
strDateTime = h & ":" & m
Case Else
strDateTime = DateAndTime
End Select
FormatDate = strDateTime
End Function

Function IsObjInstalled(strClassString)
On Error Resume Next
IsObjInstalled = False
Err = 0
Dim xTestObj
Set xTestObj = Server.CreateObject(strClassString)
If 0 = Err Then IsObjInstalled = True
Set xTestObj = Nothing
Err = 0
End Function

sub header(title)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="images/index.css" rel="stylesheet">
<title>网站后台管理系统</title>
</head>
<body>
<div class="main_title">
	<p><%=title%></p>
</div>
<%
end sub
sub footer()
%>
<div style="height:40px;"></div>
<iframe name="yukiiak" id="yukiiak" style="display:none"></iframe>
</body>
</html>
<%
end sub
%>