<%@language=vbscript codepage=936 %>
<%
Option Explicit
Const PurviewLevel = 1
%>
<%
'|----------------------------------------------------------------------------|
'|---------飞越数据库同名内容清理器v1.0 for 动易网站管理系统2005/2006 --------|
'|--------------------- 作者:科技创造自由  QQ:330950407 ----------------------|
'|-------------------- 飞越快乐家园  http://www.fy66.net/ --------------------|
'|------- 转载请保留版权信息,手下留情,留下的是对别人的尊重,谢谢! -------------|
'|----------------------------------------------------------------------------|
Server.ScriptTimeOut=999999999
%>
<!--#include file="../conn.asp"-->
<!--#include file="../inc/Function.asp"-->
<!--#include file="Admin_Fy_Config.asp"-->
<!--#include file="Admin_ChkPurview.asp"-->
<html>
<head>
<title>动易数据库同名内容清除程序</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="admin_STYLE.CSS" rel="stylesheet" type="text/css">
<script language = "JavaScript">
function changedb(){
	if (document.myform.Channel.value==''){}
    else
    {
    	location.href="Admin_Fy_CheckRepetition.asp?Action=Act0&ChannelID="+document.myform.Channel.value;
    }
}
function SelectAll(){
  for(var i=0;i<document.myform.ClassID.length;i++){
    document.myform.ClassID.options[i].selected=true;}
}
function UnSelectAll(){
  for(var i=0;i<document.myform.ClassID.length;i++){
    document.myform.ClassID.options[i].selected=false;}
}
function CheckAll(form,aa){
  for (var i=0;i<form.elements.length;i++){
    var e = form.elements[i];
    if (e.Name != 'chkAll'&&e.disabled==false&&e.id==aa)
       e.checked = form.chkAll.checked;
    }
  }
function CheckAll1(form,aa){
  for (var i=0;i<form.elements.length;i++){
    var e = form.elements[i];
    if (e.Name != 'chkAll1'&&e.disabled==false&&e.id==aa)
       e.checked = form.chkAll1.checked;
    }
  }
function CheckForm(){
  if (document.myform.ChannelID.value==''){
    alert('请先选择频道！');
    document.myform.TableName.focus();
    return false;
  }
  if (document.myform.ClassID.value==''){
    alert('请选择要查找的所属栏目！');
    //document.myform.ColumnName.focus();
    return false;
  }
  return true;  
}
</script>
</head>
<body>
<table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>
	<tr class='topbg'> 
		<td height='22' colspan='10'><table width='100%'><tr class='topbg'><td align='center'><b>数据库同名内容清理器</b></td><td width='60' align='right'></td></tr></table></td>
	</tr>
	<tr class='tdbg'>
		<td width='80' height='30' ><strong>管理导航：</strong></td><td colspan='5'><a href="Admin_Fy_CheckRepetition.asp">数据库同名内容清理器</a></td>
	</tr>
</table>
<%
Dim Act,sType,sChannelID,Module,sChannelShortName
Act=Trim(Request("Action"))
sType=Trim(Request("Type"))
sChannelID=Trim(Request("ChannelID"))
if sChannelID="" then sChannelID=1
if Act="" or Act="Act0" then
	'Response.write "<script language='javascript'>setTimeout('self.close()',0)</script>"
	'Response.end
'Elseif Act="Act0" then
	Call Act1
Elseif Act="Act1" then
	Call Act2
Elseif Act="Del" then
	Response.write Trim(Request.form("SoftID"))&"--"
	response.end
End if

Sub Act1()
%>
<br>
<form method="post" name="myform" onSubmit="return CheckForm();" action="Admin_Fy_CheckRepetition.asp" target="_self">
<table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>
	<tr class='title'><td height='22' colspan='3' align='center'><strong>数据库同名内容清理器</strong></td></tr>	
	<tr class='tdbg'>
		<td height='40' width='180' rowspan='3' align='center'>
			<select name='Channel' onChange='changedb()'><option value=''>请先选择频道　　　　　　&nbsp;</option><%Call ShowChannelList(sChannelID)%></select>
			<select name='ClassID' size='2' multiple style='height:75%;width:177px;'><%Call ShowClassList(sChannelID)%></select>
			<input type='button' name='Submit' value='  选定所有栏目  ' onclick='SelectAll()'><br>
			<input type='button' name='Submit' value='取消选定所有栏目' onclick='UnSelectAll()'>
		</td>
		<td height='40' width='70' align='right'>查找选项：</td>
		<td height='40'>
			<Input name='SearchNum' type='text' id='SearchNum' value='0' checked> 最多检查几个项目,0或留空为不限<br>
			查找<%=sChannelShortName%>ID在
			<Input type="text" id="min" name="min" value="0" size='5'> ~ <Input type="text" id="max" name="max" value="0" size='5'> 之间的项目,0或留空为不限<br>
			<%
			if Module=2 then
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='SoftName' checked> "&sChannelShortName&"标题相同<br>"
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='Editor'> "&sChannelShortName&"编辑相同<br>"
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='Author'> "&sChannelShortName&"作者相同<br>"
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='Inputer'> "&sChannelShortName&"录入者相同<br>"
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='Keyword'> "&sChannelShortName&"关键词相同<br>"
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='DownLoadUrl'> "&sChannelShortName&"地址相同<br>"
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='Updatetime'> "&sChannelShortName&"录入时间相同<br>"
			Elseif Module=3 then
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='PhotoName' checked> "&sChannelShortName&"标题相同<br>"
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='Editor'> "&sChannelShortName&"编辑相同<br>"
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='Author'> "&sChannelShortName&"作者相同<br>"
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='Inputer'> "&sChannelShortName&"录入者相同<br>"
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='Keyword'> "&sChannelShortName&"关键词相同<br>"
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='Updatetime'> "&sChannelShortName&"录入时间相同<br>"
			Else
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='Title' checked> "&sChannelShortName&"标题相同<br>"
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='Editor'> "&sChannelShortName&"编辑相同<br>"
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='Author'> "&sChannelShortName&"作者相同<br>"
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='Inputer'> "&sChannelShortName&"录入者相同<br>"
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='Keyword'> "&sChannelShortName&"关键词相同<br>"
				Response.write "<Input name='ppxx' type='radio' id='ppxx' onClick=""mdname.style.display='none'"" value='Updatetime'> "&sChannelShortName&"录入时间相同<br>"
			End if
			%>
			<Input name='ppxx' type='radio' id='ppxx' value='writes' onClick="mdname.style.display=''"> 手动指定字段名<br>
			<Input type="text" id="mdname" name="mdname" value="" style='display:none'>
		</td>
	</tr>
	<tr class='tdbg'>
		<td height='40' align='right'>列表选项：</td>
		<td height='40'>
			<Input name='pltype' type='radio' id='pltype' value='0' checked> 正序排列<br>
			<Input name='pltype' type='radio' id='pltype' value='1'> 倒序排列<br>
			<Input name='bkhsz' type='radio' id='bkhsz' value='0' checked> 不包括已在回收站的项目<br>
			<Input name='bkhsz' type='radio' id='bkhsz' value='1'> 包括已在回收站项目<br>
		</td>
	</tr>
	<tr class='tdbg'>
		<td height='40' align='right'>注意事项：</td>
		<td height='40'>1、请备份您的动易数据库文件。<br>2、本操作的检查时间视您数据的多少以及服务器（或本地机器）的配置决定，如数据很多，检查可能很慢。</td>
	</tr>
	<tr class='tdbg'>
		<td height='40' align='center' colspan='3'>
			<input type='hidden' name='Action' value='Act1'>
			<input type='hidden' name='ChannelID' value='<%=sChannelID%>'>
			<input type='hidden' name='Module' value='<%=Module%>'>
			<input type="submit" name="Submit" value="开始查找">
		</td>
	</tr>
</table>
</form>
<%
End Sub
%>

<%
Sub Act2
%>


<%
Dim rrs,rsql,rrs1,rsql1,sChannelID,sClassID,Module,bm,bt,bd,bd1,tempstrid,tempstr,tempstr1,Px1,Px2,znum,ii,ii1,crzf,sfsc,bbb,SearchNum,Searchi,zznum,min,max,mintemp
sChannelID=Trim(Request("ChannelID"))
sClassID=replace(Trim(Request("ClassID"))," ","")
Module=Trim(Request("Module"))
crzf = Trim(Request("pltype"))
sfsc = Trim(Request("bkhsz"))
bt = Trim(Request("ppxx"))
SearchNum = Trim(Request("SearchNum"))
if SearchNum = "" then SearchNum =0
SearchNum=Clng(SearchNum)
min=Trim(Request("min"))
max=Trim(Request("max"))
if min="" then min=0
if max="" then max=0
if max<min then
	mintemp=max
	max=min
	min=mintemp
end if

if bt="writes" then bt=LCase(Trim(Request("mdname")))
if Module=2 then
	bd="SoftID"
	bd1="Soft"
	bbb="SoftName"
elseif Module=3 then
	bd="PhotoID"
	bd1="Photo"
	bbb="PhotoName"
else
	bd="ArticleID"
	bd1="Article"
	bbb="Title"
End if
'Const sfsc=1'是否包括回收站,0为否,1为是
if crzf=1 then
	Px1="<"
	Px2="order by "&bd1&"ID desc"
else
	Px1=">"
	Px2=""
End if
if sfsc=0 then
	Px2=" and Deleted=0 "&Px2
end if
if max<>0 or min<>0 then Px2=" and "&bd1&"ID<="&max&" and "&bd1&"ID>="&min&" "&Px2
tempstrid=0
Response.Flush()'刷新
Set rrs=server.createobject("adodb.recordset")
Set rrs1=server.createobject("adodb.recordset")
rsql="select * from PE_"&Bd1&" where ClassID in ("&sClassID&") "&Px2
rrs.open rsql,Conn,1,1
rrs.Pagesize=1
znum=rrs.PageCount
if SearchNum<znum and SearchNum<>0 then znum=SearchNum
response.write "<table width='100%' align=center><tr><td align=center>共有<font color='red'>"&znum&"</font>个项目待检查,正在检查第<span id='isOK' style='color:red'>0</span>个,已发现<span id='OK1' style='color:blue'>0</span>组重复项目,请稍候....<span id='OKtext'></span></table>"
Response.Flush()'刷新
response.write "<form name='myform' method='Post' action='Admin_"&bd1&".asp?ChannelID="&sChannelID&"'><table class='border' width='100%' border='0' align='center' cellpadding='0' cellspacing='1'><tr class='title'><td width='30' align='center'><b>选中</b></td><td width='40' align='center'><b>ID</b></td><td align='center'><b>重复内容(蓝色分割线分组,每组项目请至少保留一项)</b></td><td width='90' align='center'><b>录入</b></td><td width='120' align='center'><b>录入时间</b></td><td width='50' align='center'><b>已审核</b></td><td width='70' align='center'><b>常规操作</b></td></tr>"
	Do Until rrs.eof

		'rsql1="select * from PE_"&Bd1&" where not("&bd&" in ("&tempstrid&")) and format(Updatetime,""yyyy-mm-dd hh:mm:ss"") = format("""&rrs(bt)&""",""yyyy-mm-dd hh:mm:ss"") and ClassID in ("&sClassID&")  and "&bd&Px1&rrs(bd)&" "&Px2
		if bt="Updatetime" then
			rsql1="select * from PE_"&Bd1&" where not("&bd&" in ("&tempstrid&")) and Updatetime = format("""&rrs(bt)&""",""yyyy-mm-dd hh:mm:ss"") and ClassID in ("&sClassID&")  and "&bd&Px1&rrs(bd)&" "&Px2
		elseif bt="passed" or bt="hits" or bt="hot" or bt="ontop" or bt="elite" or bt="stars" or bt="deleted" then
			rsql1="select * from PE_"&Bd1&" where not("&bd&" in ("&tempstrid&")) and ClassID in ("&sClassID&") and "&bt&"="&rrs(bt)&" and "&bd&Px1&rrs(bd)&" "&Px2		
		else
			rsql1="select * from PE_"&Bd1&" where not("&bd&" in ("&tempstrid&")) and ClassID in ("&sClassID&") and "&bt&"='"&rrs(bt)&"' and "&bd&Px1&rrs(bd)&" "&Px2		
		end if
		
		rrs1.open rsql1,Conn,1,1
		tempstr=""
		tempstr1=""
		if not(rrs1.eof) then
			tempstr=tempstr&"<tr><td align='center' colspan='7' bgcolor='#449ae8'></td></tr>"
			tempstr=tempstr&"<tr class='tdbg' onmouseout=""this.style.backgroundColor=''"" onmouseover=""this.style.backgroundColor='#BFDFFF'"">"
			tempstr=tempstr&"<td align='center'><input name='"&bd&"' type='checkbox' id='"&bd&"1' value='"&rrs(bd)&"'></td>"
			tempstr=tempstr&"<td align='center'>"&rrs(bd)&"</td>"
			tempstr=tempstr&"<td align='center'><a title='"&rrs(bbb)&"' target=_blank href='Admin_"&bd1&".asp?ChannelID="&sChannelID&"&Action=Show&"&bd&"="&rrs(bd)&"'>"&rrs(bt)&"</a></td>"
			tempstr=tempstr&"<td align='center'>"&rrs("Inputer")&"</td><td align='center'>"&rrs("Updatetime")&"</td><td align='center'>"
			if Edition=2006 then
				if rrs("Status")=3 then
					tempstr=tempstr&"终审通过"
				elseif rrs("Status")=2 then
					tempstr=tempstr&"二审通过"
				elseif rrs("Status")=1 then
					tempstr=tempstr&"初审通过"
				elseif rrs("Status")=0 then
					tempstr=tempstr&"未审核"
				else
					tempstr=tempstr&"草稿"
				end if
			else
				if rrs("Passed")=true then
					tempstr=tempstr&"√"
				else
					tempstr=tempstr&"<font color='red'><b>×</b></font>"
				end if
			end if

			tempstr=tempstr&"</td><td align='center'><a target=_blank href='Admin_"&bd1&".asp?ChannelID="&sChannelID&"&Action=Modify&"&bd&"="&rrs(bd)&"'>修改</a> <a target=_blank href='Admin_"&bd1&".asp?ChannelID="&sChannelID&"&Action="
			if Edition=2006 then
				tempstr=tempstr&"MoveToClass&"
			else
				tempstr=tempstr&"Move&"
			End if
			tempstr=tempstr&bd&"="&rrs(bd)&"'>移动</a></td></tr>"
			ii1=ii1+1
			Response.write "<script>OK1.innerHTML="""&ii1&"""</script>"
		end if
		Do Until rrs1.eof
			tempstrid=tempstrid&","&rrs1(bd)
			tempstr=tempstr&"<tr class='tdbg' onmouseout=""this.style.backgroundColor=''"" onmouseover=""this.style.backgroundColor='#BFDFFF'"">"
			tempstr=tempstr&"<td align='center'><input name='"&bd&"' type='checkbox' id='"&bd&"' value='"&rrs1(bd)&"'></td>"
			tempstr=tempstr&"<td align='center'>"&rrs1(bd)&"</td>"
			tempstr=tempstr&"<td align='center'><a title='"&rrs1(bbb)&"' target=_blank href='Admin_"&bd1&".asp?ChannelID="&sChannelID&"&Action=Show&"&bd&"="&rrs1(bd)&"'>"&rrs1(bt)&"</a></td>"
			tempstr=tempstr&"<td align='center'>"&rrs1("Inputer")&"</td><td align='center'>"&rrs1("Updatetime")&"</td><td align='center'>"
			if Edition=2006 then
				if rrs1("Status")=3 then
					tempstr=tempstr&"终审通过"
				elseif rrs1("Status")=2 then
					tempstr=tempstr&"二审通过"
				elseif rrs1("Status")=1 then
					tempstr=tempstr&"初审通过"
				elseif rrs1("Status")=0 then
					tempstr=tempstr&"未审核"
				else
					tempstr=tempstr&"草稿"
				end if
			else
				if rrs1("Passed")=true then
					tempstr=tempstr&"√"
				else
					tempstr=tempstr&"<font color='red'><b>×</b></font>"
				end if
			end if
			tempstr=tempstr&"</td><td align='center'><a target=_blank href='Admin_"&bd1&".asp?ChannelID="&sChannelID&"&Action=Modify&"&bd&"="&rrs1(bd)&"'>修改</a> <a target=_blank href='Admin_"&bd1&".asp?ChannelID="&sChannelID&"&Action="
			if Edition=2006 then
				tempstr=tempstr&"MoveToClass&"
			else
				tempstr=tempstr&"Move&"
			End if
			tempstr=tempstr&bd&"="&rrs1(bd)&"'>移动</a></td></tr>"
			rrs1.movenext
		Loop
		response.write tempstr
		ii=ii+1
		Response.write "<script>isOK.innerHTML="""&ii&"""</script>" & vbCrLf
		'……………………………………………… 
		If Response.IsClientConnected Then 
			Response.Flush 
		Else 
			Response.End 
		End If
		'………………………………………………
		Searchi=Searchi+1
		rrs1.close
		if SearchNum<>0 and SearchNum<=Searchi then exit do
		rrs.movenext
	Loop
rrs.close
if ii1=0 then Response.write "<tr><td align=center class=tdbg colspan=7>没有找到任何匹配项目</td></tr>"
Response.write "<script>OKtext.innerHTML=""<font color='green'>检查完成!</font>""</script>"
response.write "</table><table width='100%' border='0' cellpadding='0' cellspacing='0'><tr><td width='100%'>&nbsp;<input name='chkAll' type='checkbox' id='chkAll' onclick=""CheckAll(this.form,'"&bd&"1')"" value='checkbox'>选中所有第一项　<input name='chkAll1' type='checkbox' id='chkAll1' onclick=""CheckAll1(this.form,'"&bd&"')"" value='checkbox'>选中所有其他项　　　"
Response.write "<input name='Action' type='hidden' id='Action' value='Del'><input name='submit' type='submit' value='删除选定的下载' onclick=""return confirm('确定要删除选中的下载吗？本操作将把选中的下载移到回收站中。必要时您可从回收站中恢复！')""> <input type='submit' name='Submit3' value='批量设置' onClick=""document.myform.Action.value='Batch'""> <input type='submit' name='Submit4' value='批量移动' onclick=""document.myform.Action.value='"
if Edition=2006 then
	Response.write "MoveToClass"
else
	Response.write "BatchMove"
end if
Response.write "'""></td></tr></table></form><br>"

set rrs=nothing
set rrs1=nothing
%>
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="border" >
  <tr>
   <td colspan='2' height="20" align="center"><font color=#0099FF>注：原文以及和原文重复的内容都会显示在上面的列表中!如要进行删除等相关操作请谨慎进行! <br>删除文章后如回到本插件初试设置页面,说明删除成功</font></td>
  </tr>
</table>
<%
End Sub



'显示频道列表
Sub ShowChannelList(ID)
	Dim rs,sql
	set rs=server.createobject("adodb.recordset")
	sql="select * from PE_Channel where (ModuleType=1 or ModuleType=2 or ModuleType=3) and Disabled=0 order by Orderid"
	rs.open sql,Conn,1,1
	Do Until rs.eof
		Response.write "<option value='"&rs("ChannelID")&"' "
		if rs("ChannelID")=clng(ID) then
			Response.write "selected"
			Module=rs("ModuleType")
			sChannelShortName=rs("ChannelShortName")
		End if
		Response.write ">"&rs("ChannelName")&"</option>"
		rs.MoveNext
	Loop
	rs.close
	set rs=nothing
End Sub

'显示栏目列表
Sub ShowClassList(ID)
	Dim rs,sql
	if ID=0 then
		Response.write "<option value=''>请先选择频道</option>"
	Else	
		set rs=server.createobject("adodb.recordset")
		sql="select * from PE_Class where ChannelID="&ID&""
		rs.open sql,Conn,1,1
		if rs.bof then
			Response.write "<option value=''>请先添加栏目</option>"
		else
			Do Until rs.eof
				Response.write "<option value='"&rs("ClassID")&"'>"&rs("ClassName")&"</option>"
				rs.MoveNext
			Loop
		End if
		rs.close
		set rs=nothing
	End if
End Sub
%>
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="border" >
  <tr>
   <td colspan='2' height="20" align="center"><a href='http://www.fy66.net/' target=_blank style='color:#449AE8'>插件作者:飞越快乐家园-科技创造自由</a></td>
  </tr>
</table> 