<!--#include file="Conn.asp"--><%Checklogin("信息管理")%><!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=utf-8" />
<title>管理区域</title>
<link rel="stylesheet" href="css/common.css" type="text/css" />
<script language="javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/js.js"></script>
<script type="text/javascript" src="xheditor-1.1.9/xheditor-1.1.9-zh-cn.min.js"></script>
<script>
$(document).ready(function(){

//var allPlugin={addproduct:{c:'tools_pro',t:'插入产品模板',e:function(){var _this=this;var jTest=$('<div>插入产品模块</div><div><textarea id="xheTestInput" style="width:260px;height:100px;display:none"><h1 class="p1_title"><!--产品名称--></h1><div class="p1_img"><a href="<!--图片地址-->" title="<!--产品名称-->" class="p1_showimg"><img src="<!--图片地址-->" alt="<!--产品名称-->" /></a><span>点击上图查看大图和更多...</span></div><dl class="p1_dl"><dt>型 号：</dt><dd>输入型号</dd></dl><dl class="p1_dl"><dt>品 牌：</dt><dd>输入品牌</dd></dl><dl class="p1_dl"><dt>产 地：</dt><dd>输入产地</dd></dl><dl class="p1_dl"><dt>产品简介：</dt><dd>输入简介</dd></dl><h2 class="p1_title1">产品介绍</h2><div class="p1_content">输入介绍</div><div class="p1_copyright">该<!--产品名称-->产品信息由Taber公司独家提供，严禁转载。</div></textarea></div><div style="text-align:right;"><input type="button" id="xheSave" value="确定" /></div>');var jTestInput=$('#xheTestInput',jTest),jSave=$('#xheSave',jTest);jSave.click(function(){var infotitle = document.getElementById("infotitle").value,infoimgurl=document.getElementById("infoimgurl").value;if(infotitle==''){alert('请先填写信息标题');return false;}if(infoimgurl==''){alert('请上传缩略图');return false;}_this.loadBookmark();var insertval = jTestInput.val().replace(/<!--产品名称-->/g,document.getElementById("infotitle").value).replace(/<!--图片地址-->/g,document.getElementById("infoimgurl").value);_this.pasteHTML(insertval);_this.hidePanel();return false;});_this.saveBookmark();_this.showDialog(jTest);}}}
$('#infocontent').xheditor({
tools:'full',hoverExecDelay:-1,urlBase:'system/',//urlType:'root',//plugins:allPlugin,
upLinkUrl:"upload.asp",upLinkExt:"zip,rar,txt,pdf",
upImgUrl:"upload.asp",upImgExt:"jpg,jpeg,gif,png",
upFlashUrl:"upload.asp",upFlashExt:"swf",
upMediaUrl:"upload.asp",upMediaExt:"wmv,avi,wma,mp3,mid",loadCSS:'css/edit.css'
});
});
</script>
</head>

<body>
<div id="man_zone">
<%
Act = Request.QueryString("act")
If act = "save" Then

Set reg=New Regexp
reg.Ignorecase=True
reg.Global=True

function sitelink_replace(byval t0,byval t1,byval t2,byval t3)
	If t0="" Or IsNull(t0) Then Exit Function
	dim t4:t4=t0

	reg.pattern="(\<a[^<>]+\>.+?\<\/a\>)|(\<img[^<>]+\>)|(\<h[1-6]+[\s]*\>.+?\<\/h[1-6]+\>)"
	set matches=reg.execute(t4)
	dim i:i=0
	dim myarray()
	if matches.count>0 then
		for each match in matches
			redim preserve myarray(i)
			myarray(i)=mid(match.value,1,len(match.value))
			t4=replace(t4,match.value,"["&i&"]",1,t3)
			i=i+1
		next
	end if
	if i=0 Then
		t0=replace(t0,t1,t2,1,t3)
		sitelink_replace=t0
		'Set reg=Nothing
		exit function
	end if
	t4=replace(t4,t1,t2,1,t3)
	for i=0 to ubound(myarray)
		t4=replace(t4,"["&i&"]",myarray(i),1,t3)
	next
	sitelink_replace=t4
end function


	Set Rs = Server.CreateObject("ADODB.RecordSet")
	setlinkname=""
	setlinktemplate=""
	setlinkreplace=""
	Rs.Open "Select sname,stitle,surl,sreplace,starget From setlink Where sstate>0 Order By sord Desc,id Desc",Conn,1,1
	Do While Not Rs.Bof And Not Rs.Eof
		sname=Rs("sname"):stitle=Rs("stitle"):surl=Rs("surl"):sreplace=Rs("sreplace"):starget=Rs("starget")
		setlinkname=setlinkname & sname &"<|>"
		If starget=0 Then
			setlinktemplate = setlinktemplate & "<a href="""&surl&""" title="""&stitle&""">"&sname&"</a>" & "<|>"
		Else
			setlinktemplate = setlinktemplate & "<a href="""&surl&""" title="""&stitle&""" target=""_blank"">"&sname&"</a>" & "<|>"
		End If
		If sreplace<=0 Then
			setlinkreplace=setlinkreplace & "-1<|>"
		Else
			setlinkreplace=setlinkreplace & sreplace &"<|>"
		End If
	Rs.MoveNext
	Loop	
	Rs.Close

	setlinknameArr=split(setlinkname,"<|>")
	setlinktemplateArr=split(setlinktemplate,"<|>")
	setlinkreplaceArr=split(setlinkreplace,"<|>")



isedit = False
id = Request.Form("id")
If id<>"" And IsNumeric(id) Then isedit = True
classid = Request.Form("classid")
If classid="" Or Not IsNumeric(classid) Then classid=0
infotitle = TextEnCode(Request.Form("infotitle"))
infokeywords = TextEnCode(Request.Form("infokeywords"))
infodescription = TextEnCode(Request.Form("infodescription"))
infoaddtime = Request.Form("infoaddtime")
infovisitor = Request.Form("infovisitor")
infoord = Request.Form("infoord")
infoimgurl = TextEnCode(Request.Form("infoimgurl"))
infocontent = Request.Form("infocontent")

infocontentsetlink = infocontent

	For i=0 To Ubound(setlinknameArr)-1
		infocontentsetlink = sitelink_replace(infocontentsetlink,setlinknameArr(i),setlinktemplateArr(i),setlinkreplaceArr(i))			
	Next
infocontentsetlink=HTMLEnCode(infocontentsetlink)

infocontent = HTMLEnCode(infocontent)
indexshow = Request.Form("indexshow")
If indexshow="" Or Not IsNumeric(indexshow) Then indexshow=0
If indexshow<>1 Then indexshow=0

If isedit Then
	Rs.Open "Select classid,infotitle,infokeywords,infodescription,infoaddtime,infovisitor,infoord,infoimgurl,infocontent,infostate,indexshow,infocontentsetlink From info Where id="&id,Conn,1,3
	If Not Rs.Bof And Not Rs.Eof Then
		Rs(0) = classid
		Rs(1) = infotitle:Rs(2) = infokeywords:Rs(3) = infodescription
		If infoaddtime<>"" And IsDate(infoaddtime) Then Rs(4) = infoaddtime
		If infovisitor<>"" And IsNumeric(infovisitor) Then Rs(5) = infovisitor
		If infoord<>"" And IsNumeric(infoord) Then Rs(6) = infoord
		Rs(7) = infoimgurl:Rs(8) = infocontent
		Rs("indexshow")=indexshow
		Rs("infocontentsetlink")=infocontentsetlink
	Else
		Rs.AddNew
		Rs(0) = classid
		Rs(1) = infotitle:Rs(2) = infokeywords:Rs(3) = infodescription
		If infoaddtime<>"" And IsDate(infoaddtime) Then Rs(4) = infoaddtime Else Rs(4) = Now()
		If infovisitor<>"" And IsNumeric(infovisitor) Then Rs(5) = infovisitor Else Rs(5) = 0
		If infoord<>"" And IsNumeric(infoord) Then Rs(6) = infoord Else Rs(6) = 0
		Rs("indexshow")=indexshow
		Rs(7) = infoimgurl:Rs(8) = infocontent:Rs(9)=1
		Rs("infocontentsetlink")=infocontentsetlink
	End If
	Rs.Update:Rs.Close:Set Rs=Nothing:Conn.Close:Set Conn=Nothing
	Page = Request.QueryString("Page")
	Keys=Server.UrlEnCode(Request.QueryString("Keys"))
	Ord=Server.UrlEnCode(Request.QueryString("Ord"))
	Response.Redirect "?keys="&Keys&"&Ord="&Ord&"&Page="&Page
Else
	If infoaddtime="" Or Not IsDate(infoaddtime) Then infoaddtime = Now()
	If infovisitor="" Or Not IsNumeric(infovisitor) Then infovisitor = 0
	If infoord="" Or Not IsNumeric(infoord) Then infoord = 0
	Conn.Execute("Insert into info(classid,infotitle,infokeywords,infodescription,infoaddtime,infovisitor,infoord,infoimgurl,infocontent,infostate,indexshow,infocontentsetlink) values("&classid&",'"&infotitle&"','"&infokeywords&"','"&infodescription&"','"&infoaddtime&"','"&infovisitor&"','"&infoord&"','"&infoimgurl&"','"&infocontent&"',1,"&indexshow&",'"& infocontentsetlink &"')")
	Conn.Close:Set Conn=Nothing:Response.Redirect "?"
End If
Conn.Close:Set Conn=Nothing

Response.End
End If 'end save


If Act = "add" Or Act = "edit" Then
id = Request.QueryString("id")
isedit = False
If id<>"" And IsNumeric(id) Then isedit=True
If isedit Then
	Set Rs = Server.CreateObject("ADODB.RecordSet")
	Rs.Open "Select classid,infotitle,infokeywords,infodescription,infocontent,infoaddtime,infovisitor,infoord,infoimgurl,indexshow From info Where id="&id,Conn,1,1
	If Not Rs.Bof And Not Rs.Eof Then
		classid=Rs(0):infotitle=Rs(1):infokeywords=Rs(2):infodescription=Rs(3):infocontent=Rs(4):infoaddtime=Rs(5):infovisitor=Rs(6):infoord=Rs(7):infoimgurl=Rs(8):indexshow=Rs("indexshow")
	Else
		isedit = False
	End If
	Rs.Close:Set Rs=Nothing
End If

Page = Request.QueryString("Page")
Keys=Server.UrlEnCode(Request.QueryString("Keys"))
Ord=Server.UrlEnCode(Request.QueryString("Ord"))
hrefstr = "?keys="&Keys&"&Ord="&Ord&"&Page="&Page
%>
	<form name="form1" method="post" action="<%=hrefstr%>&act=save">
	<table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
		<tbody>
			<tr>
				<th width="8%">标题</th>
				<td><input type="text" id="infotitle" name="infotitle" value="<%=infotitle%>" class="txt1" /><input type="hidden" name="id" value="<%=id%>" /></td>
			</tr>
			<tr>
				<th width="8%">所属分类</th>
				<td>
					<select name="classid">
						<option value="0">请选择所属分类</option><%

Set Rs1 = Server.CreateObject("ADODB.RecordSet")
Rs1.Open "Select id,classname From class Order By classord Desc,id",Conn,1,1
Do While Not Rs1.Bof And Not Rs1.Eof
%><option value="<%=Rs1(0)%>"<%If classid=Rs1(0) Then Response.Write " Selected=""Selected"""%>><%=Rs1(1)%></option><%
Rs1.MoveNext
Loop
Rs1.Close
Set Rs1=Nothing:Set Rs2=Nothing
Conn.Close:Set Conn=Nothing
%>

					</select>
				</td>
			</tr>
			<tr>
				<th width="8%">关键词</th>
				<td><input type="text" id="infokeywords" name="infokeywords" value="<%=infokeywords%>" class="txt1" /></td>
			</tr>
			<tr>
				<th width="8%">描述</th>
				<td><input type="text" id="infodescription" name="infodescription" value="<%=infodescription%>" class="txt1" /></td>
			</tr>
			<tr>
				<th width="8%">发布时间</th>
				<td><input type="text" id="infoaddtime" name="infoaddtime" value="<%=infoaddtime%>" class="txt1" /></td>
			</tr>
			<tr>
				<th width="8%">阅读次数</th>
				<td><input type="text" id="infovisitor" name="infovisitor" value="<%=infovisitor%>" class="txt1" /></td>
			</tr>
			<tr>
				<th width="8%">排序</th>
				<td><input type="text" id="infoord" name="infoord" value="<%=infoord%>" class="txt1" /></td>
			</tr>
			<tr>
				<th width="8%">缩略图</th>
				<td><input type="text" id="infoimgurl" name="infoimgurl" value="<%=infoimgurl%>" class="txt1" style="width:<%If isedit Then Response.Write "330" Else Response.Write "390"%>px;float:left;" /><iframe src="uploadfile.asp" frameborder="0" scrolling="no" style="width:400px;height:22px;float:left;margin-left:10px;"></iframe><%If isedit Then%><input type="button" value="图组" class="btn1" onClick="location.href='pic.asp<%=hrefstr%>&infoid=<%=id%>'" style="float:left;margin-left:10px" /><%End If%></td>
			</tr>
			<tr>
				<th width="8%">在首页显示</th>
				<td><label><input type="radio" name="indexshow" value="1"<%If indexshow=1 Then Response.Write " checked=""checked"""%> />显示</label> <label><input type="radio" name="indexshow" value="0"<%If indexshow<>1 Then Response.Write " checked=""checked"""%> />不显示</label></td>
			</tr>
			<tr>
				<th>内容</th>
				<td><textarea id="infocontent" name="infocontent" class="txt2"><%=infocontent%></textarea></td>
			</tr>
			<tr>
				<th></th>
				<td><input type="submit" name="save" id="save" value="确定" class="btn1" /> <input type="reset" name="save" id="save" value="重置" class="btn1" /> <input type="button" value="返回" class="btn1" onClick="location.href='<%=hrefstr%>'" /></td>
			</tr>
		</tbody>
	</table>
	</form>
</div>
</body>
</html>
<%
Response.End
End If 'End add


If Act="postchk" Then

Keys = Server.UrlEnCode(Request.QueryString("Keys"))
Ord = Server.UrlEnCode(Request.QueryString("Ord"))
Page = Request.QueryString("Page")
chkact = Request.Form("chkact")
SqlStr = ""
For i = 1 To Request.Form("chkbox").Count
	If SqlStr<>"" Then
		SqlStr = SqlStr & " Or id="&Request.Form("chkbox")(i)
	Else
		SqlStr = " Where id="&Request.Form("chkbox")(i)
	End If
Next

Select Case chkact
Case "0":SqlStr = "Update info Set infostate="&chkact&SqlStr
Case "1":SqlStr = "Update info Set infostate="&chkact&SqlStr
Case Else:SqlStr = "Delete From info"&SqlStr
End Select

Conn.Execute(SqlStr):Conn.Close:Set Conn=Nothing
Response.Redirect "?Keys="&Keys&"&Ord="&Ord&"&Page="&Page
Response.End
End If	'End postchk


Keys=Request.QueryString("Keys")
Keyscode=TextEnCode(Keys)
Ord=Request.QueryString("Ord")
Page = Request.QueryString("Page")
If Ord<>"" Then
	OrdStr=Ord&","
Else
	OrdStr=""
End If
Set Rs=Server.CreateObject("ADODB.RecordSet")
Rs.Open "Select id,classid,infotitle,infoaddtime,infostate,infoord From info Where infotitle like '%"&Keyscode&"%' Order By "&OrdStr&"Id Desc",Conn,1,1
Keys=Server.UrlEnCode(Keys)
Ord=Server.UrlEnCode(Ord)
hrefstr = "?keys="&Keys
%>	
	<form id="form1" method="post" action="?act=postchk&Keys=<%=keys%>&Ord=<%=Ord%>&Page=<%=Page%>" onSubmit="return false" />
	<table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
		<thead>
			<tr>
				<th width="4%"><input type="checkbox" name="chkall" id="chkall" onClick="chkboxall(this,'chkbox')" /></th>
				<th width="6%">序号</th>
				<th width="15%"><a href="<%=hrefstr%><%If ord="classid" Then Response.Write "&ord=classid+Desc" Else Response.Write "&ord=classid"%>">所属分类<%If Ord="classid" Then Response.Write "↓" Else If Ord="classid+Desc" Then Response.Write "↑"%></a></th>
				<th width="35%"><a href="<%=hrefstr%><%If ord="infotitle" Then Response.Write "&ord=infotitle+Desc" Else Response.Write "&ord=infotitle"%>">信息标题<%If Ord="infotitle" Then Response.Write "↓" Else If Ord="infotitle+Desc" Then Response.Write "↑"%></a></th>
				<th width="16%"><a href="<%=hrefstr%><%If ord="infoaddtime" Then Response.Write "&ord=infoaddtime+Desc" Else Response.Write "&ord=infoaddtime"%>">发布时间<%If Ord="infoaddtime" Then Response.Write "↓" Else If Ord="infoaddtime+Desc" Then Response.Write "↑"%></a></th>
				<th width="8%"><a href="<%=hrefstr%><%If ord="infostate" Then Response.Write "&ord=infostate+Desc" Else Response.Write "&ord=infostate"%>">状态<%If Ord="infostate" Then Response.Write "↓" Else If Ord="infostate+Desc" Then Response.Write "↑"%></a></th>
				<th width="8%"><a href="<%=hrefstr%><%If ord="infoord" Then Response.Write "&ord=infoord+Desc" Else Response.Write "&ord=infoord"%>">排序<%If Ord="infoord" Then Response.Write "↓" Else If Ord="infoord+Desc" Then Response.Write "↑"%></a></th>
				<th width="8%">操作</th>
			</tr>
		</thead>
		<tbody>

<%
If Not Rs.Bof And Not Rs.Eof Then
	Rs.PageSize = 13
	If Page = "" Then Page = 1
	If Page = "end" Then Page = Rs.PageCount
	If Not IsNumeric(Page) Or Page < 1 Then Page = 1
	Page = Cint(Page)
	If Page > Rs.PageCount Then Page = Rs.PageCount
	Rs.AbsolutePage = Page
	TempNum = Rs.PageSize * (Page - 1)
	
	Set Rs1=Server.CreateObject("ADODB.RecordSet")

	For i=1 To Rs.PageSize
		If Rs.Bof Or Rs.Eof Then Exit For
		TempNum=TempNum+1:classid=Rs(1)
%>
			<tr onMouseOver="this.style.background='#F7FCFF'" onMouseOut="this.style.background='#FFFFFF'">
				<td align="center"><input type="checkbox" name="chkbox" value="<%=Rs(0)%>" /></td>
				<td align="center"><%=TempNum%></td>
				<td align="center"><%
Rs1.Open "Select classname From class Where id=" & classid ,Conn,1,1
If Rs1.Bof Or Rs1.Eof Then
Response.Write "未选择"
Else
Response.Write Rs1(0)
End If
Rs1.Close
%></td>
				<td><%=Rs(2)%></td>
				<td align="center"><%=Rs(3)%></td>
				<td align="center"><%If Rs(4)=1 Then Response.Write "显示" Else Response.Write "隐藏" End If%></td>
				<td align="center"><%=Rs(5)%></td>
				<td align="center"><a href="?Keys=<%=keys%>&Ord=<%=Ord%>&Page=<%=Page%>&act=edit&id=<%=Rs(0)%>" class="ico_edit">修改</a></td>
			</tr>
<%
		Rs.MoveNext
	Next
Else
	If Keys="" Then
%>
			<tr>
				<td align="center" colspan="8">Sorry，当前暂无信息</td>
			</tr>

<%
	Else
%>
			<tr>
				<td align="center" colspan="8"><a href="?">Sorry，没有找到“<%=Keyscode%>”相关的信息，点击返回</a></td>
			</tr>
<%
	End If
End If
%>
		</tbody>
		<tfoot>
			<tr>
				<td colspan="8">
					<div class="showpagebox">
<%
If Rs.PageCount > 1 Then
	PageName="?Keys="&Keys&"&Ord="&Ord&"&"
	Pagelen=3
	If Page>1 Then
		Response.Write "<a href="""&PageName&"Page=1"">首页</a>"
		Response.Write "<a href="""&PageName&"Page="&Page-1&""">上一页</a>"
	End If

	If Pagelen*2+1 >= Rs.PageCount Then
		StartPage=1:EndPage=Rs.PageCount
	Else
		If Page<=Pagelen+1 Then
			StartPage=1
			EndPage=Pagelen*2+1
		Else
			StartPage=Page-Pagelen
			EndPage=Page+Pagelen
		End If
		If Page+Pagelen>Rs.PageCount Then StartPage=Rs.PageCount-Pagelen*2:EndPage=Rs.PageCount
	End If

	For i = StartPage To EndPage
		If i = Page Then
			Response.Write "<a class=""current"">"&i&"</a>"
		Else
			Response.Write "<a href="""&PageName&"Page="&i&""">"&i&"</a>"
		End If
	Next

	If Page<Rs.PageCount Then
		If Rs.PageCount - Page > Pagelen Then Response.Write "<a href="""&PageName&"Page="&Rs.PageCount&""">..."&Rs.PageCount&"</a>"
		Response.Write "<a href="""&PageName&"Page="&Page+1&""">下一页</a>"
		Response.Write "<a href="""&PageName&"Page="&Rs.PageCount&""">尾页</a>"
	End If

	Response.Write "<input type=""text"" id=""Pagego"" value="""&Page&""" onFocus=""if(this.value == '"&Page&"'){this.value='';}"" onBlur=""if(this.value == ''){this.value='"&Page&"';}"" onKeyUp=""this.value=this.value.replace(/\D/g,'')"" onKeyDown=""if(event.keyCode==13){location.href='"&PageName&"Page='+document.getElementById('Pagego').value}"" />"
End If
%>					</div>
					<div class="searchbox"><input type="text" id="keys" value="<%If Keyscode="" Then Response.Write "请输入搜索关键词" Else Response.Write Keyscode%>" onFocus="if(this.value == '<%If Keyscode="" Then Response.Write "请输入搜索关键词" Else Response.Write Keyscode%>'){this.value='';}" onBlur="if(this.value == ''){this.value='<%If Keyscode="" Then Response.Write "请输入搜索关键词" Else Response.Write Keyscode%>';}" onKeyDown="if(event.keyCode==13){location.href='?Keys='+escape(document.getElementById('keys').value)}" /><input type="button" id="searchgo" value="go" onClick="location.href='?Keys='+escape(document.getElementById('keys').value)" /></div>
					<div class="postchkbox">
						<select id="chkact" name="chkact">
							<option value="1">显示</option>
							<option value="0">隐藏</option>
							<option value="-1">删除</option>
						</select>
						<input type="button" value="执行" onClick="postchk(1)" class="btn1" />
						<input type="button" value="新增" onClick="location.href='?act=add'" class="btn1" />
					</div>
				</td>
			</tr>
		</tfoor>
	</table>
	</form>
<%Rs.Close:Set Rs=Nothing:Set Rs1=Nothing:Conn.Close:Set Conn=Nothing%>
</div>
</body>
</html>
