<%@language=vbscript codepage=936 %>
<%
Option Explicit
Const PurviewLevel = 1
%>
<%
'|----------------------------------------------------------------------------|
'|---------飞越失效图片清理器v3.0 for 动易网站管理系统2005/2006 --------------|
'|--------------------- 作者:科技创造自由  QQ:330950407 ----------------------|
'|-------------------- 飞越快乐家园  http://www.fy66.net/ --------------------|
'|------- 转载请保留版权信息,手下留情,留下的是对别人的尊重,谢谢! -------------|
'|----------------------------------------------------------------------------|
%>
<!--#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_CheckFailPhoto.asp?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 CheckForm(){
  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_CheckFailArticle.asp">动易失效文章清理器</a> | <a href="Admin_Fy_CheckFailSoft.asp">动易失效下载清理器</a> | <a href="Admin_Fy_CheckFailPhoto.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=0
if Act="" or Act="Act0" then
	Call Act1
Elseif Act="Act1" then
	Call Act2
Elseif Act="Del" then
End if

Sub Act1()
%>
<br>
<form method="post" name="myform" onSubmit="return CheckForm();" action="Admin_Fy_CheckFailPhoto.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:65%;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 type="text" id="Pagesize" name="Pagesize" value=""> 最多检查几个项目,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>
			<Input name='searchtype' type='radio' id='searchtype' value='0' checked> 仅检测本地文件是否有效<br>
			<Input name='searchtype' type='radio' id='searchtype' value='1'> 检测本地和远程文件是否有效(扩展模式,速度可能很慢!)<br>
		</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='Module' value='<%=Module%>'>
			<input type='hidden' name='Action' value='Act1'>
			<input type='hidden' name='ChannelID' value='<%=sChannelID%>'>
			<input type="submit" name="Submit" value="开始查找">
		</td>
	</tr>
</table>
</form>
<%
End Sub
%>

<%
Sub Act2
	Dim rrs,rsql,sClassID,Px2,bkhsz,pltype,Pagei,tempstr,urltemp,urltemp1,urli,urlerr,tmpFSO,iii,GetChannelDirstr,Pagesize,znum,searchtype,Module,bt,min,max,mintemp
	Set rrs=server.createobject("adodb.recordset")
	sClassID=replace(Trim(Request("ClassID"))," ","")
	pltype= Trim(Request("pltype"))
	bkhsz = Trim(Request("bkhsz"))
	Module = Trim(Request("Module"))
	searchtype = Trim(Request("searchtype"))
	Pagesize=Trim(Request("Pagesize"))
	if Pagesize="" then Pagesize=0
	Pagesize=clng(Pagesize)
	Const PageNum=1'第几页
	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

	bt="Photo"
	Px2=""
	if bkhsz<>"1" then
		Px2=" and Deleted=0 "
	end if
	if pltype="1" then
		Px2=Px2&" Order by PhotoID desc "
	end if
	if max<>0 or min<>0 then Px2=" and PhotoID<="&max&" and PhotoID>="&min&" "&Px2

	GetChannelDirstr=GetChannelDir(sChannelID)

	rsql="select * from PE_Photo where ClassID in ("&sClassID&") "&Px2
	rrs.open rsql,Conn,1,1
	rrs.Pagesize=1
	if Pagesize=0 or rrs.PageCount<Pagesize then
		znum=rrs.PageCount
	Else
		znum=Pagesize
	End if
	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_Photo.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='30' align='center'><b>ID</b></td><td align='center'><b>项目名称</b></td><td align='center'><b>下载地址列表</b></td><td width='50' align='center'><b>已审核</b></td><td width='70' align='center'><b>常规操作</b></td></tr>"
	if rrs.bof then
	else
		Do Until rrs.eof
			tempstr=""
			urlerr=""
			tempstr=tempstr&"<tr class='tdbg' onmouseout=""this.style.backgroundColor=''"" onmouseover=""this.style.backgroundColor='#BFDFFF'"">"
			tempstr=tempstr&"<td align='center'><input name='PhotoID' type='checkbox' id='PhotoID' value='"&rrs("PhotoID")&"'></td>"
			tempstr=tempstr&"<td align='center'>"&rrs("PhotoID")&"</td>"
			tempstr=tempstr&"<td align='center'><a title='"
			tempstr=tempstr&"作&nbsp;&nbsp;&nbsp;&nbsp;者：" & rrs("Author") & vbCrLf
			tempstr=tempstr&"更新时间：" & rrs("Updatetime") & vbCrLf
			tempstr=tempstr&"下载次数：" & rrs("Hits") & vbCrLf
			tempstr=tempstr&"关 键 字：" & rrs("Keyword") & vbCrLf
			if Edition=2006 then
				tempstr=tempstr&"察看点数：" & rrs("InfoPoint") 
			else
				tempstr=tempstr&"察看点数：" & rrs("PhotoPoint") 
			End if
			
			
			tempstr=tempstr&"' target=_blank href='Admin_Photo.asp?ChannelID="&sChannelID&"&Action=Show&PhotoID="&rrs("PhotoID")&"'>"&rrs("PhotoName")&"</a></td>"
			tempstr=tempstr&"<td align='left'>"
			
			urltemp=split(rrs("PhotoUrl"),"$$$")
			for urli=0 to Ubound(urltemp)
				tempstr=tempstr&urltemp(urli)
				urltemp1=Split(urltemp(urli),"|")
				if InStr(urltemp1(1), "://") <= 0 then
					Set tmpFSO = CreateObject("Scripting.FileSystemObject")
					If tmpFSO.FileExists(server.MapPath(GetChannelDirstr&urltemp1(1)))=false Then
						tempstr=tempstr&" <font color=red>错</font>"
						urlerr=True
					End If
					Set tmpFSO = Nothing
				elseif searchtype="1" then
					If IsValidUrl(urltemp1(1)) Then
					Else
						tempstr=tempstr&" <font color=red>错</font>"
						urlerr=True
					End If	
				End if
				tempstr=tempstr&"<br>"
			Next
			
			tempstr=tempstr&"</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_Photo.asp?ChannelID="&sChannelID&"&Action=Modify&PhotoID="&rrs("PhotoID")&"'>修改</a> <a target=_blank href='Admin_Photo.asp?ChannelID="&sChannelID&"&Action="
			if Edition=2006 then
				tempstr=tempstr&"MoveToClass&"
			else
				tempstr=tempstr&"Move&"
			End if
			tempstr=tempstr&"PhotoID="&rrs("PhotoID")&"'>移动</a></td></tr>"
			if urlerr=True then
				iii=iii+1
				Response.write "<script>OK1.innerHTML="""&iii&"""</script>"
				Response.write tempstr
			end if

			
			
			Pagei=Pagei+1
			Response.write "<script>isOK.innerHTML="""&Pagei&"""</script>" & vbCrLf
			'……………………………………………… 
			If Response.IsClientConnected Then 
				Response.Flush 
			Else 
				Response.End 
			End If
			'………………………………………………
			if Pagesize<>0 and Pagei>= Pagesize then Exit Do
			
			rrs.MoveNext
		Loop
	End if
	if iii=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,'PhotoID')"" 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>"
	rrs.close
	set rrs=nothing

%>
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="border" >
  <tr>
   <td colspan='2' height="20" align="center"><font color=#0099FF>注：删除文章后如回到本插件初试设置页面,说明删除成功<br>一些类似showsoftdown.asp?softid=30的地址可能会误确认为错误地址,请手动验证.</font></td>
  </tr>
</table>
<%
End Sub
'显示频道列表
Sub ShowChannelList(ID)
	Dim rs,sql,ii
	set rs=server.createobject("adodb.recordset")
	sql="select * from PE_Channel where 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")
			sChannelID=rs("ChannelID")
		Elseif clng(ID)=0 and ii<>1 then
			ii=1
			Response.write "selected"
			Module=rs("ModuleType")
			sChannelShortName=rs("ChannelShortName")
			sChannelID=rs("ChannelID")
		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

'获取频道上传目录
'参数 ChannelID
Function GetChannelDir(ChannelID)
	dim rrs,rsql
	set rrs=server.createobject("adodb.recordset")
	rsql="select UploadDir,ChannelDir from PE_Channel where ChannelID="&ChannelID&""
	rrs.open rsql,Conn,1,1
	GetChannelDir="/"&rrs("ChannelDir")&"/"&rrs("UploadDir")
	rrs.close
	set rrs=nothing
End Function
'判断是否有效
Function IsValidUrl(url)
Dim xl
		On Error Resume Next
        Set xl = Server.CreateObject("Microsoft.XMLHTTP")
        xl.Open "HEAD",url,False
        xl.Send
        IsValidUrl = (xl.status=200)
End Function
%>
<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> 