function main()
{
    global $db, $template, $cache;
    $loginname = getCookie("adminname");
    $keyword = be("all", "keyword");
    $stype = be("all", "stype");
    $area = be("all", "area");
    $topic = be("all", "topic");
    $level = be("all", "level");
    $from = be("all", "from");
    $sserver = be("all", "sserver");
    $sstate = be("all", "sstate");
    $repeat = be("all", "repeat");
    $repeatlen = be("all", "repeatlen");
    $order = be("all", "order");
    $pagenum = be("all", "page");
    $sort = be("all", "sort");
    $spic = be("all", "spic");
    $hide = be("all", "hide");
    $d_status = be("all", "d_status");
    $douban_score = be("all", "douban_score");
    $ipadpic = be("all", "ipadpic");
    $d_douban_id = be("all", "d_douban_id");
    $can_search_device = be("all", "can_search_device");
    if (!isNum($level)) {
        $level = 0;
    } else {
        $level = intval($level);
    }
    if (!isNum($sstate)) {
        $sstate = 0;
    } else {
        $sstate = intval($sstate);
    }
    if (!isNum($stype)) {
        $stype = 0;
    } else {
        $stype = intval($stype);
    }
    if (!isNum($area)) {
        $area = 0;
    } else {
        $area = intval($area);
    }
    if (!isNum($topic)) {
        $topic = 0;
    } else {
        $topic = intval($topic);
    }
    if (!isNum($spic)) {
        $spic = 0;
    } else {
        $spic = intval($spic);
    }
    if (!isNum($ipadpic)) {
        $ipadpic = 0;
    } else {
        $ipadpic = intval($ipadpic);
    }
    if (!isNum($hide)) {
        $hide = -1;
    } else {
        $hide = intval($hide);
    }
    if (!isNum($douban_score)) {
        $douban_score = 0;
    } else {
        $douban_score = intval($douban_score);
    }
    if (!isNum($repeatlen)) {
        $repeatlen = 0;
    }
    if (!isNum($d_status)) {
        $d_status = -1;
    } else {
        $d_status = intval($d_status);
    }
    if (isNum($d_douban_id)) {
        $d_douban_id = intval($d_douban_id);
    }
    if (!isNum($pagenum)) {
        $pagenum = 1;
    } else {
        $pagenum = intval($pagenum);
    }
    if ($pagenum < 1) {
        $pagenum = 1;
    }
    $where = " d_type in (1,2,3,131) ";
    $keyword_col = be("all", "keyword_col");
    if (!isN($keyword)) {
        $keyword = trim($keyword);
        if (isN($keyword_col)) {
            $where .= " AND ( d_directed like '%" . $keyword . "%' or d_starring like '%" . $keyword . "%' or d_name like '%" . $keyword . "%' or d_enname like '%" . $keyword . "%'   ) ";
        } else {
            $where .= " AND " . $keyword_col . " like '%" . $keyword . "%' ";
        }
    }
    if ($stype > 0) {
        $typearr = getValueByArray($cache[0], "t_id", $stype);
        if (is_array($typearr)) {
            $where = $where . " and d_type in (" . $typearr["childids"] . ")";
        } else {
            $where .= " AND d_type=" . $stype . " ";
        }
    }
    if ($stype == -1) {
        $where .= " AND d_type=0 ";
    }
    if ($area > 0) {
        $where .= " AND d_area = " . $area . " ";
    }
    if ($topic > 0) {
        $where .= " AND d_topic = " . $topic . " ";
    }
    if ($level > 0) {
        $where .= " AND d_level = " . $level . " ";
    }
    if ($sstate == 1) {
        $where .= " AND d_state>0 ";
    } else {
        if ($sstate == 2) {
            $where .= " AND d_state=0 ";
        }
    }
    if ($hide != -1) {
        $where .= " AND d_hide=" . $hide . " ";
    }
    if ($d_douban_id == -1) {
        $where .= " AND d_douban_id=" . $d_douban_id . " ";
    } else {
        if ($d_douban_id == 1) {
            $where .= " AND d_douban_id >0 ";
        } else {
            if ($d_douban_id == 2) {
                $where .= " AND d_douban_id =0 ";
            }
        }
    }
    if ($d_status != -1) {
        $where .= " AND d_status=" . $d_status . " ";
    }
    if ($douban_score == 1) {
        $where .= " AND d_score >0 ";
    }
    if ($douban_score == 2) {
        $where .= " AND d_score <=0 ";
    }
    if ($stype == 1 || $stype == 2) {
        $douban_scoreT = "block";
    } else {
        $douban_scoreT = "none";
    }
    if (!isN($can_search_device)) {
        //    	if($can_search_device ==='TV'){
        //    		$where .= " AND can_search_device like '%TV%' ";
        //    	}else {
        //    		$where .= " AND (can_search_device like '".$can_search_device."' or can_search_device is null or can_search_device ='' ) ";
        //    	}
        $where .= " AND (can_search_device like '" . $can_search_device . "' or can_search_device is null or can_search_device ='' ) ";
    }
    if ($repeat == "ok") {
        $repeatSearch = " d_name ";
        if ($repeatlen > 0) {
            $repeatSearch = " substring(d_name,1," . $repeatlen . ") ";
        }
        $repeatsql = " , (SELECT " . $repeatSearch . " as d_name1 FROM {pre}vod GROUP BY d_name1 HAVING COUNT(*)>1) as `t2` ";
        $where .= " AND `{pre}vod`.`d_name`=`t2`.`d_name1` ";
        if (isN($order)) {
            $order = "d_name,d_addtime";
        }
    }
    $douban_comment = be("all", "douban_comment");
    if (!isNum($douban_comment)) {
        $douban_comment = 0;
    } else {
        $douban_comment = intval($douban_comment);
    }
    if ($douban_comment == 1) {
        $where .= " and d_id in (SELECT DISTINCT content_id FROM tbl_comments WHERE author_id IS NULL AND thread_id IS NULL) ";
    }
    if ($douban_comment == 2) {
        $where .= " and d_id not in (SELECT DISTINCT content_id FROM tbl_comments WHERE author_id IS NULL AND thread_id IS NULL) ";
    }
    if (isN($order)) {
        $orders = "d_time desc ";
    } else {
        if (!isN($sort)) {
            $orders = $order . ' ' . $sort;
        }
    }
    if (!isN($sserver)) {
        $where .= " AND d_playserver like '%" . $sserver . "%' ";
    }
    if (!isN($from)) {
        $where .= " and d_playfrom like  '%" . $from . "%' ";
    }
    if ($spic == 1) {
        $where .= " AND d_pic = '' ";
    } else {
        if ($spic == 2) {
            $where .= " and  d_pic not like '%joyplus%' and d_pic!=''  ";
        }
    }
    if ($ipadpic == 1) {
        $where .= " AND (d_pic_ipad = ''  or d_pic_ipad is null )";
    } else {
        if ($ipadpic == 2) {
            $where .= " AND d_pic_ipad not like '%joyplus%' and d_pic_ipad != '' ";
        }
    }
    $select_weburl = be("all", "select_weburl");
    $select_videourl = be("all", "select_videourl");
    $select_videourl_play = be("all", "select_videourl_play");
    if (!isNum($select_videourl_play)) {
        $select_videourl_play = -1;
    } else {
        $select_videourl_play = intval($select_videourl_play);
    }
    if ($select_videourl_play == 0) {
        $where .= " AND d_play_check = 0 ";
    }
    if ($select_videourl_play == 2) {
        $where .= " AND d_play_check = 2 ";
    }
    if ($select_videourl_play == 1) {
        $where .= " AND d_play_check = 1 ";
    }
    if ($select_weburl == 1) {
        $where .= " AND webUrls is not null and webUrls !='' ";
    }
    if ($select_weburl == 2) {
        $where .= " AND (webUrls is null or  webUrls ='') ";
    }
    if ($select_videourl == 1) {
        $where .= " AND d_downurl is not null and d_downurl !='' ";
    }
    if ($select_videourl == 2) {
        $where .= " AND (d_downurl is null or d_downurl ='') ";
    }
    $sql = "SELECT count(*) FROM {pre}vod " . $repeatsql . " where " . $where;
    $nums = $db->getOne($sql);
    $pagecount = ceil($nums / app_pagenum);
    //$sql = "SELECT d_year,d_id, d_name, d_enname, d_play_num,d_type,d_state,d_topic, d_level, d_hits, d_time,d_remarks,d_playfrom,d_hide,p.id as popular_id FROM {pre}vod ".$repeatsql." left join {pre}vod_popular as p on p.vod_id=d_id  WHERE" . $where . " ORDER BY " . $orders . "  limit ".(app_pagenum * ($pagenum-1)) .",".app_pagenum;
    $sql = "SELECT d_year,d_id, d_name, d_enname, d_play_num,d_type,d_state,d_topic, d_level, d_hits, d_time,d_remarks,d_playfrom,d_hide FROM {pre}vod " . $repeatsql . "  WHERE" . $where . " ORDER BY " . $orders . "  limit " . app_pagenum * ($pagenum - 1) . "," . app_pagenum;
    // var_dump($sql);
    $rs = $db->query($sql);
    ?>


<script type="text/javascript" src="./resource/thickbox-compressed.js"></script>
<script type="text/javascript" src="./resource/thickbox.js"></script>
<link href="./resource/thickbox.css" rel="stylesheet" type="text/css" />
<script language="javascript">
$(document).ready(function(){
	$("#form1").validate({
		rules:{
			repeatlen:{
				number:true,
				max:10
			}
		}
	});
	
	$("#btnrepeat").click(function(){
		var repeatlen = $("#repeatlen").val();
		var reg = /^\d+$/;
		var re = repeatlen.match(reg);
		if (!re){ repeatlen=0; }
		if (repeatlen >20){ alert("长度最大20");$("#repeatlen").focus();return;}
		var url = "admin_vod.php?repeat=ok&repeatlen=" + repeatlen;
		window.location.href=url;
	});
	$("#btnDel").click(function(){
			if(confirm('确定要删除吗')){
				$("#form1").attr("action","admin_vod.php?action=del");
				$("#form1").submit();
			}
			else{return false}
	});
	$("#plsc").click(function(){
		var ids="",rc=false;
		$("input[name='d_id']").each(function() {
			if(this.checked){
				if(rc)ids+=",";
				ids =  ids + this.value;
				rc=true;
			}
        });
		$("#form1").attr("action","admin_makehtml.php?acton=viewpl&flag=vod&d_id="+ids);
		$("#form1").submit();
	});
});
function filter(){
	var stype=$("#stype").val();
	var order=$("#order").val();
	var from=$("#from").val();
	var sort=$("#sort").val();
	var keyword=$("#keyword").val();
	var keyword_col=$("#keyword_col").val();
	var can_search_device=$("#can_search_device").val();
	var url = "admin_online_subscribe.php?can_search_device="+can_search_device+"&keyword_col="+keyword_col+"&sort="+sort+"&keyword="+encodeURI(keyword)+"&stype="+stype+"&order="+order+"&from="+from; //ipadpic
	window.location.href=url;
}


function prepareWeiboText(type,id,name){
	   document.getElementById( "weiboText").value= name; 
	   document.getElementById( "notify_msg_prod_id").value= id; 
	   document.getElementById( "notify_msg_prod_type").value= type; 
	   $('#SendWeiboMsg').empty();
}


function sendWeiboText(){

	
	var weibotxt= document.getElementById( "weiboText").value;
	var notify_msg_prod_id= document.getElementById( "notify_msg_prod_id").value;
	var notify_msg_prod_type= document.getElementById( "notify_msg_prod_type").value;
	var urlT='admin_vod.php?action=notifyMsg&prod_type='+notify_msg_prod_type+'&prod_id='+notify_msg_prod_id+'&content=' +encodeURIComponent(weibotxt) ;
	var channels= document.getElementById( "channel[]");
	alert(channels);
	for(var i = 0; i < channels.length; i++){
		 if (channels[i].checked == true) {
			  urlT = urlT +'&channels='+channels[i].value;				 		 
		  }
	}
		 $.post(urlT, {Action:"post"}, function (data, textStatus){     
			  if(textStatus == "success"){   
	          //alert(data);
				  $('#SendWeiboMsg').empty().append(data);
	           }else{
	        	   $('#SendWeiboMsg').empty().append('发送失败。');
	           }
	       });
	
    // alert(urlT);
	 
}

</script>
<table class="admin_online_subscribe tb">
	<tr>
	<td>
	<table width="96%" border="0" align="center" cellpadding="3" cellspacing="1">
	<tr>
	<td colspan="2">
	过滤条件:<select id="stype" name="stype" onchange="javascript:{var typeid= this.options[this.selectedIndex].value; if(typeid=='1' ||  typeid=='2'){document.getElementById('btnsearchs').style.display='block';  document.getElementById('btnsearchsThumbs').style.display='block';document.getElementById('btnsearchsComment').style.display='block';}else {document.getElementById('btnsearchs').style.display='none'; document.getElementById('btnsearchsThumbs').style.display='none';document.getElementById('btnsearchsComment').style.display='none';}}">
	<option value="0">视频栏目</option>
	<option value="-1" <?php 
    if ($stype == -1) {
        echo "selected";
    }
    ?>
>没有栏目</option>
	<?php 
    echo makeSelectAll("{pre}vod_type", "t_id", "t_name", "t_pid", "t_sort", 0, "", "&nbsp;|&nbsp;&nbsp;", $stype);
    ?>
	</select>
	&nbsp;
	
	<select id="order" name="order">
	<option value="d_time">视频排序</option>
	<option value="d_id" <?php 
    if ($order == "d_id") {
        echo "selected";
    }
    ?>
>视频编号</option>
	<option value="d_name" <?php 
    if ($order == "d_name") {
        echo "selected";
    }
    ?>
>视频名称</option>
	<option value="d_play_num" <?php 
    if ($order == "d_play_num") {
        echo "selected";
    }
    ?>
>播放次数</option>
	<option value="d_year" <?php 
    if ($order == "d_year") {
        echo "selected";
    }
    ?>
>上映日期</option>
	</select>
	&nbsp;<select id="sort" name="sort">
	<option value="desc" <?php 
    if ($sort == "desc") {
        echo "selected";
    }
    ?>
>视频排序 降序序</option>
	<option value="asc" <?php 
    if ($sort == "asc") {
        echo "selected";
    }
    ?>
>视频排序  升序</option>
	</select>
	
	
	&nbsp;
	<select id="from" name="from">
	<option value="">视频播放器</option>
	<?php 
    echo makeSelectPlayer($from);
    ?>
	</select>
	
	 <select   id="can_search_device" name="can_search_device">
	    <option value="" >投放设备</option>
		<option value="TV" <?php 
    if ($can_search_device === 'TV') {
        echo "selected";
    }
    ?>
>TV版</option>
		<option value="iPad" <?php 
    if ($can_search_device === 'iPad') {
        echo "selected";
    }
    ?>
>iPad版</option>
		<option value="iphone" <?php 
    if ($can_search_device === 'iphone') {
        echo "selected";
    }
    ?>
>iphone版</option>
		<option value="apad" <?php 
    if ($can_search_device === 'apad') {
        echo "selected";
    }
    ?>
>Android-Pad版</option>
		<option value="aphone" <?php 
    if ($can_search_device === 'aphone') {
        echo "selected";
    }
    ?>
>Android-Phone版</option>
		<option value="web" <?php 
    if ($can_search_device === 'web') {
        echo "selected";
    }
    ?>
>网站版</option>
	</select> 
	
	</td>
	</tr>
	<tr>
	<td colspan="4">
	关键字:<input id="keyword" size="40" name="keyword" value="<?php 
    echo $keyword;
    ?>
">&nbsp;
	<select id="keyword_col" name="keyword_col">
	<option value="">关键字的匹配列</option>
	<option value="d_name" <?php 
    if ($keyword_col == "d_name") {
        echo "selected";
    }
    ?>
>视频名称</option>
	<option value="d_starring" <?php 
    if ($keyword_col == "d_starring") {
        echo "selected";
    }
    ?>
>演员</option>
	<option value="d_directed" <?php 
    if ($keyword_col == "d_directed") {
        echo "selected";
    }
    ?>
>导演</option>
	</select>
	<input class="input" type="button" value="搜索" id="btnsearch" onClick="filter();">
	
	</td>
	
	</tr>
	</table>
	</td>
	</tr>
</table>

<form id="form1" name="form1" method="post">
<table class="tb">
	<tr>
	<td width="10%">编号</td>
	<td width="25%">名称</td>
	<td width="10%">播放次数</td>
	<td width="10%">上映日期</td>
	<td width="5%">分类</td>
	<td width="20%">时间</td>
	<td width="20%">操作</td>
	</tr>
	<?php 
    if ($nums == 0) {
        ?>
	<tr><td align="center" colspan="12">没有任何记录!</td></tr>
	<?php 
    } else {
        while ($row = $db->fetch_array($rs)) {
            $d_id = $row["d_id"];
            $tname = "未知";
            $tenname = "";
            $typearr = getValueByArray($cache[0], "t_id", $row["d_type"]);
            if (is_array($typearr)) {
                $tname = $typearr["t_name"];
                $tenname = $typearr["t_enname"];
            }
            ?>
    <tr>
	<td><?php 
            echo $d_id;
            ?>
</td>
	<td><?php 
            echo substring($row["d_name"], 20);
            ?>
	<?php 
            if ($row["d_state"] > 0) {
                echo "<font color=\"red\">[" . $row["d_state"] . "]</font>";
            }
            ?>
	<?php 
            if (!isN($row["d_remarks"])) {
                echo "<font color=\"red\">[" . $row["d_remarks"] . "]</font>";
            }
            ?>
	<?php 
            if ($row["d_hide"] == 1) {
                echo "<font color=\"red\">[隐藏]</font>";
            }
            ?>
	</td>
	<td><?php 
            echo $row["d_play_num"];
            ?>
</td>
	<td><?php 
            echo $row["d_year"];
            ?>
</td>
	<td><?php 
            echo $tname;
            ?>
</td>
	<td><?php 
            echo isToday($row["d_time"]);
            ?>
</td>
	<td><a href="admin_vod_topic.php?action=info&id=<?php 
            echo $d_id;
            ?>
">所在榜单</a> |
	<a class="thickbox" href="#TB_inline?height=400&width=600&inlineId=myOnPageContent" onclick="javascript:{prepareWeiboText('<?php 
            echo $row["d_type"];
            ?>
','<?php 
            echo $d_id;
            ?>
','<?php 
            echo substring($row["d_name"], 20);
            ?>
');}" > 消息推送</a>	 </td>
    </tr>
	<?php 
        }
    }
    ?>
<!--	<tr>-->
<!--	<td colspan="12">-->
<!--	全选<input name="chkall" type="checkbox" id="chkall" value="1" onClick="checkAll(this.checked,'d_id[]');"/>&nbsp;-->
<!--    批量操作:<input type="button" id="btnDel" value="删除" class="input">-->
<!--	<input type="button" id="pltj" value="推荐" onClick="plset('pltj','vod')" class="input">-->
<!--	<input type="button" id="plfl" value="分类" onClick="plset('plfl','vod')" class="input">-->
<!--	<input type="button" id="plzt" value="专题" onClick="plset('plzt','vod')" class="input">-->
<!--	<input type="button" id="plluobo" value="轮播图" onClick="plsetLuobo()" class="input">-->
<!--	<input type="button" id="plbd" value="视频悦单" onClick="plsetBD('plbd','vod','1')" class="input">-->
<!--	<input type="button" id="plbd" value="视频悦榜" onClick="plsetBD('plbd','vod','2')" class="input">-->
<!--	<input type="button" id="plrq" value="人气" onClick="plset('plrq','vod')" class="input">-->
<!--	<input type="button" id="plsc" value="生成" class="input">-->
<!--	<input type="button" id="plyc" value="显隐" onClick="plset('plyc','vod')" class="input">-->
<!--	<span id="plmsg" name="plmsg"></span>-->
<!--	</td>-->
<!--	</tr>-->
	<tr class="formlast">
	<td align="center" colspan="12">
	<?php 
    echo pagelist_manage($pagecount, $pagenum, $nums, app_pagenum, "admin_online_subscribe.php?page={p}&can_search_device=" . $can_search_device . "&keyword=" . urlencode($keyword) . "&keyword_col=" . $keyword_col . "&sort=" . $sort . "&order=" . $order . "&stype=" . $stype . "&from=" . $from);
    ?>
	</td>
	</tr>
</table>

</form>
<div id="myOnPageContent" style="display:none">
<script language="javascript">

$('#form2').form({
	success:function(data){
		$('#SendWeiboMsg').empty().append(data);
		$("#btnEdit").attr("disabled",false); 		
    }
});

$("#btnEdit").click(function(){
	if(confirm('确定要推送消息吗')){
		$("#form2").attr("action","?action=notifyMsg");
		var weibotxt= $("#weiboText").val();
		$("#btnEdit").attr("disabled",true); 
		if(weibotxt ==''){
          alert("发送内容不能为空。");
          $("#btnEdit").attr("disabled",false); 
          return;
		}

		if(weibotxt.length>=110){
	          alert("你发送的内容太长,不能超过110个字符。");
	          $("#btnEdit").attr("disabled",false); 
	          return;
		}
		var prod_id= $("#notify_msg_prod_id").val();
		
		var prod_type= $("#notify_msg_prod_type").val();
		 $('#SendWeiboMsg').empty().append('正在推送消息.....<br/>');
		var urlT='admin_online_subscribe.php?action=notifyMsg&notify_msg_prod_type='+prod_type+'&notify_msg_prod_id='+prod_id+'&content=' +encodeURIComponent(weibotxt) ;
		var channels=document.getElementsByName("channel[]");
		var channelFlag=true;
		var index=0;
		var indexSelect=0;
		for(var i = 0; i < channels.length; i++){
			 if (channels[i].checked == true) {
				  channelFlag=false;
				  indexSelect++;
				  urlTs = urlT +'&channel='+channels[i].value;	
				 // alert(channels[i].value);	
				  $.post(urlTs, {Action:"post"}, function (data, textStatus){     
					  if(textStatus == "success"){ 
						  index++;  
			          //alert(data);
						  $('#SendWeiboMsg').append(data).append('<br/>');
			           }else{
			        	   index++;  
			        	   $('#SendWeiboMsg').append('发送失败。').append('<br/>');
			           }
					  if( index==indexSelect){			  
						     $("#btnEdit").attr("disabled",false); 
						     $('#SendWeiboMsg').append('推送消息完成。').append('<br/>');
				      }
			       });	 		 
			  }
		}
		if(channelFlag){
			alert('你必须要选择一个频道发送');
	    }
	   
	    
		//$("#form2").submit();
		
	}
});
</script>
<form id="form2"  name="form1" method="post">
<table class="table" cellpadding="0" cellspacing="0" width="100%" border="0">

                <thead class="tb-tit-bg">
<!--                   <tr>-->
<!--                        <td > <h3 class="title">    发送设备:<select name="device_type" id="device_type" >                       -->
<!--                             <option value="" >所有设备</option>-->
<!--                             <option value="ios" >IOS</option>-->
<!--                             <option value="android" >Android</option>                          -->
<!--                        </select> -->
<!--                        </h3></td>    -->
<!--                      -->
<!--                    </tr>-->
                    <tr>
                        <td colspan="2"><span><h3>发送信息</h3></span></td>    
                       
                    </tr>
                    <input type="hidden" name="notify_msg_prod_id" id="notify_msg_prod_id" value="">
                    <input type="hidden" name="notify_msg_prod_type" id="notify_msg_prod_type" value="">
                      
                      <tr>
                        <td colspan="2" align="center"><textarea name="wbText" id="weiboText" rows="10" cols="90"></textarea></td>
                    </tr>
                     <tr>
                        <td align="left"> <br/>
                            Parse 云推送<br/>
	                        &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id='channel[]' name="channel[]" value="CHANNEL_ANDROID"   />悦视频 Android版<br/>
<!--						    &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id='channel[]' name="channel[]" value="CHANNEL_TV"  />悦视频 TV版<br/>-->
						    &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id='channel[]' name="channel[]" value="CHANNEL_IOS"  />悦视频 IOS版<br/>
						    &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id='channel[]' name="channel[]" value="CHANNEL_IPHONE"  />今晚剧场iphone版<br/>
						    &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id='channel[]' name="channel[]" value="CHANNEL_IPAD"  />今晚剧场IPAD版<br/>
                        </td>
                         <td align="left"> <br/>
                                                                         百度云推送<br/>
	                        &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id='channel[]' name="channel[]" value="CHANNEL_ANDROID_BAIDU"   />悦视频 Android版<br/>
<!--						    &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id='channel[]' name="channel[]" value="CHANNEL_TV_BAIDU"  />悦视频 TV版<br/>-->
						    &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id='channel[]' name="channel[]" value="CHANNEL_IOS_BAIDU"  />悦视频 IOS版<br/>
						    &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id='channel[]' name="channel[]" value="CHANNEL_IPHONE_BAIDU"  />今晚剧场iphone版<br/>
						    &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id='channel[]' name="channel[]" value="CHANNEL_IPAD_BAIDU"  />今晚剧场IPAD版<br/>
                        </td>
                    </tr>
                      <tr>
                         <td align="center" colspan="2"><input type="button" value="发送消息" id="btnEdit"  class="input"  /></td>
                      </tr>
                        <tr>
                        <td align="left" colspan="2">  <font color=red><span id="SendWeiboMsg"></span></font></td>    
                       
                    </tr> 
                    
                </thead>
            </table>
</form>
</div>
<?php 
    if ($pagenum == 1 && $where == " 1=1 ") {
        echo "<script>showpic();</script>";
    }
    unset($rs);
}
function cjView($strlink, $num)
{
    global $starringarr, $titlearr, $picarr, $strListUrl, $p_playspecialtype, $p_playtype, $p_videocodeType, $p_videocodeApiUrl, $p_id, $p_videocodeApiUrlParamstart, $p_videocodeApiUrlParamend, $p_videourlstart, $p_videourlend, $playcodeApiUrl, $playcodeApiUrlParamstart, $p_playcodeApiUrlParamend, $playcodeApiUrltype, $db, $strListUrl, $p_titletype, $starringarr, $titlearr, $picarr, $p_id, $p_titlestart, $p_titleend, $p_lzstart, $p_lzend, $p_hitsstart, $p_hitsend, $p_starringtype, $p_starringstart, $p_starringend, $p_picstart, $p_picend, $p_typestart, $p_typeend, $p_pictype, $p_classtype, $p_collect_type, $p_timestart, $p_timeend, $p_areastart, $p_areaend, $p_contentstart, $p_contentend, $p_playcodestart, $p_playcodeend, $p_playlinkstart, $p_playlinkend, $p_playurlstart, $p_playurlend, $p_playcodetype, $p_playlinktype, $p_playtype, $p_coding, $p_lzstart, $p_lzend, $p_lzcodetype, $p_lzcodestart, $p_lzcodeend, $p_languagestart, $p_languageend, $p_remarksstart, $p_remarksend, $p_script, $p_showtype, $p_savefiles, $strdstate, $p_server, $p_setnametype, $p_setnamestart, $p_setnameend, $p_directedstart, $p_directedend, $cache;
    $androidUrl = "";
    //var_dump($strlink);var_dump($strListUrl);
    try {
        $pos = strpos($strlink, "href=\"");
        if ($pos !== false) {
            $strlink = substr($strlink, $pos + 6);
        }
        $pos = strpos($strlink, "\"");
        if ($pos !== false) {
            $strlink = substr($strlink, 0, $pos);
        }
    } catch (Exception $e) {
    }
    $strlink = definiteUrl($strlink, $strListUrl);
    writetofile("crawel_auto_info.log", $p_id . '{=====}' . $strlink . "{=====}View===start");
    $strViewCode = getPage($strlink, $p_coding);
    if ($strViewCode == false) {
        $strdstate = "true";
        writetofile("crawel_auto_error.log", $p_id . '{=====}' . $strlink . '{=====}' . $strListUrl);
        $sb = $sb + 1;
        return;
    } else {
        //节目名称,来自列表或者来自内容页
        if ($p_titletype == 1) {
            $titlecode = $titlearr[$num];
        } else {
            $titlecode = getBody($strViewCode, $p_titlestart, $p_titleend);
        }
        //		var_dump($titlearr[$num]);
        $titlecode = filterScript($titlecode, $p_script);
        $titlecode = replaceFilters($titlecode, $p_id, 1, 0);
        $titlecode = replaceStr(replaceStr(replaceStr($titlecode, ",", " "), "'", ""), "\"\"", "");
        $titlecode = trim($titlecode);
        //		$sql="select count(*) as cc from {pre}cj_vod where m_name='".$titlecode."' and m_playfrom='".$p_playtype."'";
        //		$row=$db->getOne($sql);
        //		//var_dump($row);var_dump($titlecode);
        //		$rowcount = $row;
        //先缩小范围
        if ($p_lzcodetype == 1) {
            //连载范围
            $lzfwcode = getBody($strViewCode, $p_lzcodestart, $p_lzcodeend);
            //连载编码
            $lzcode = getBody($lzfwcode, $p_lzstart, $p_lzend);
            $lzcode = replaceStr($lzcode, "false", "0");
            $lzcode = trim($lzcode);
            $lzcode = intval($lzcode);
        } else {
            $lzcode = getBody($strViewCode, $p_lzstart, $p_lzend);
            $lzcode = replaceStr($lzcode, "false", "0");
            $lzcode = trim($lzcode);
            $lzcode = intval($lzcode);
        }
        //		if ($p_playcodetype !=2 &&($lzcode == 0) && ($rowcount>0)) {
        //			$strdstate = "true";
        //			echo "<tr><td colspan=\"2\">遇到重复电影数据跳过采集!</TD></TR>";
        //			return;
        //		}
        if (isN($p_hitsstart) || !isnum($p_hitsstart)) {
            $p_hitsstart = 0;
        }
        if (isN($p_hitsend) || !isnum($p_hitsend)) {
            $p_hitsend = 0;
        }
        if ($p_hitsstart == 0 && $p_hitsend == 0) {
            $m_hits = 0;
        } else {
            $m_hits = rand($p_hitsend, $p_hitsstart);
        }
        if ($p_starringtype == 1) {
            $starringcode = $starringarr[$num];
        } else {
            $starringcode = getBody($strViewCode, $p_starringstart, $p_starringend);
        }
        //演员
        $starringcode = filterScriptStar($starringcode, $p_script);
        $starringcode = replaceStr(replaceStr(replaceStr($starringcode, ",", " "), "'", ""), "\"\"", "");
        $starringcode = trim($starringcode);
        if ($p_pictype == 1) {
            $piccode = $picarr[$num];
        } else {
            $piccode = getBody($strViewCode, $p_picstart, $p_picend);
        }
        //图片
        $piccode = trim($piccode);
        $piccode = getHrefFromImg(definiteUrl($piccode, $strListUrl));
        //栏目设置
        if ($p_classtype == 1) {
            $typecode = filterScript(getBody($strViewCode, $p_typestart, $p_typeend), $p_script);
            $typecode = trim($typecode);
            $m_typeid = changeId($typecode, $p_id, 0, 0);
        } else {
            $typecode = $p_collect_type;
            $typecode = trim($typecode);
            $m_typeid = $p_collect_type;
            $typearr = getValueByArray($cache[0], "t_id", $typecode);
            $typecode = $typearr["t_name"];
        }
        if ($m_typeid == 0) {
            $m_typeid = $p_collect_type;
        }
        $typecode = filterScript($typecode, $p_script);
        //导演
        $directedcode = filterScriptStar(getBody($strViewCode, $p_directedstart, $p_directedend), $p_script);
        $directedcode = replaceStr($directedcode, "false", "");
        $directedcode = replaceStr($directedcode, "'", "");
        $directedcode = trim($directedcode);
        //备注
        $remarkscode = filterScript(getBody($strViewCode, $p_remarksstart, $p_remarksend), $p_script);
        $remarkscode = replaceStr($remarkscode, "false", "");
        $remarkscode = trim($remarkscode);
        //语音
        $languagecode = filterScript(getBody($strViewCode, $p_languagestart, $p_languageend), $p_script);
        $languagecode = replaceStr($languagecode, "false", "未知");
        $languagecode = trim($languagecode);
        //时间
        $timecode = filterScript(getBody($strViewCode, $p_timestart, $p_timeend), $p_script);
        if ($timecode == false) {
            $timecode == "未知";
        }
        $timecode = trim($timecode);
        //地区
        $areacode = filterScript(getBody($strViewCode, $p_areastart, $p_areaend), $p_script);
        if ($areacode == false) {
            $areacode = "未知";
        }
        $areacode = trim($areacode);
        //内容
        $contentcode = filterScript(getBody($strViewCode, $p_contentstart, $p_contentend), $p_script);
        if ($contentcode == false) {
            $contentcode = "未知";
        }
        $contentcode = filterScript(replaceFilters($contentcode, $p_id, 2, 0), $p_script);
        $contentcode = replaceStr(replaceStr(replaceStr($contentcode, ",", " "), "'", ""), "\"\"", "");
        $contentcode = trim($contentcode);
        $m_area = $areacode;
        $m_languageid = $languagecode;
        //播放列表,缩小
        if ($p_playcodetype == 1) {
            $playcode = getBody($strViewCode, $p_playcodestart, $p_playcodeend);
            //获取地址设置
            if ($p_playlinktype > 0) {
                //播放链接
                $weburl = getArray($playcode, $p_playlinkstart, $p_playlinkend);
            } else {
                //内容页直接获取地址, 地址开始
                $weburl = getArray($playcode, $p_playurlstart, $p_playurlend);
            }
            if ($p_setnametype == 3) {
                $setnames = getArray($playcode, $p_setnamestart, $p_setnameend);
            }
        } else {
            if ($p_playcodetype == 2) {
                //from api
                //		writetofile("d:\\s.txt",$linkcode) ;
                //		echo $p_playcodeApiUrlParamend .'=='.$playcodeApiUrlParamstart;
                //		echo $playcodeApiUrlParamstart .'\n' .$p_playcodeApiUrlParamend .'  = '.$playcodeApiUrltype;
                if ($playcodeApiUrltype == 0) {
                    $paracode = getBody($strViewCode, $playcodeApiUrlParamstart, $p_playcodeApiUrlParamend);
                } else {
                    $paracode = getBody($UrlTestMoive, $playcodeApiUrlParamstart, $p_playcodeApiUrlParamend);
                }
                //		echo $paracode;
                $p_apibatchurl = replaceStr($playcodeApiUrl, "{PROD_ID}", $paracode);
                $p_apibatchurls = replaceStr($p_apibatchurl, "{PAGE_NO}", 1);
                $playcode = getFormatPage($p_apibatchurls, $p_coding);
                $weburl = getArray($playcode, $p_playlinkstart, $p_playlinkend);
                $page_num = 2;
                //		echo "page 1 :".$weburl .'\n';
                $flag = true;
                while ($flag && $page_num < 15 && strpos($playcodeApiUrl, "{PAGE_NO}") !== false) {
                    $p_apibatchurls = replaceStr($p_apibatchurl, "{PAGE_NO}", $page_num);
                    //			echo $p_apibatchurls .'\n';
                    $playcode = getFormatPage($p_apibatchurls, $p_coding);
                    $weburls = getArray($playcode, $p_playlinkstart, $p_playlinkend);
                    //		    echo "page ".$page_num." :".$weburls .'\n';
                    if ($weburls) {
                        $weburl = $weburl . "{Array}" . $weburls;
                        $page_num = $page_num + 1;
                    } else {
                        $flag = false;
                    }
                }
                //		var_dump($weburl);
                //		if ($p_playlinktype >0) {
                //			$weburl = getArray($playcode,$p_playlinkstart,$p_playlinkend);
                //		}
                //		else{
                //			$weburl = getArray($playcode,$p_playurlstart,$p_playurlend);
                //		//	var_dump($playcode);
                //		}
                //		if ($p_setnametype == 3) {
                //			$setnames = getArray($playcode,$p_setnamestart,$p_setnameend);
                //		}
            } else {
                if ($p_playlinktype > 0) {
                    $weburl = getArray($strViewCode, $p_playlinkstart, $p_playlinkend);
                    //				var_dump($weburl);
                } else {
                    $weburl = getArray($strViewCode, $p_playurlstart, $p_playurlend);
                    $androidUrl = ContentProviderFactory::getContentProvider($p_playtype)->parseAndroidVideoUrlByContent($strViewCode, $p_coding, $p_script);
                    $videoAddressUrl = ContentProviderFactory::getContentProvider($p_playtype)->parseIOSVideoUrlByContent($strViewCode, $p_coding, $p_script);
                    writetofile("android_log.txt", $strlink . '{===}' . $androidUrl . '{===}' . $videoAddressUrl);
                }
                if ($p_setnametype == 3) {
                    $setnames = getArray($strViewCode, $p_setnamestart, $p_setnameend);
                }
            }
        }
        if ($p_showtype == 1) {
            if ($p_savefiles == 1) {
                $filename = time() . $num;
                if (strpos($piccode, ".jpg") || strpos($piccode, ".bmp") || strpos($piccode, ".png") || strpos($piccode, ".gif")) {
                    $extName = substring($piccode, 4, strlen($piccode) - 4);
                } else {
                    $extName = ".jpg";
                }
                $picpath = "upload/vod/" . getSavePicPath() . "/";
                $picfile = $filename . $extName;
                //echo "<tr><td width=\"20%\" >自动下载图片:</td><td><iframe border=\"0\" valign=\"bottom\" vspace=\"0\" hspace=\"0\" marginwidth=\"0\" marginheight=\"0\" framespacing=\"0\" frameborder=\"0\" scrolling=\"no\" width=\"400\" height=\"15\" src=\"../admin_pic.php?action=downpic&wjs=1&path=../".$picpath."&file=".$picfile."&url=".$piccode."\"></iframe></td></tr>";
                $piccode = $picpath . $picfile;
            }
        } else {
            //		echo "<tr><td colspan=\"2\" align=\"center\">第".($num+1)."条数据采集结果</td></tr><tr><td width=\"20%\" >来源:</td><td >".$strlink."</td></tr><tr><td width=\"20%\" >名称:</td><td >".$titlecode." 连载:".$lzcode." 备注:".$remarkscode."</td></tr>";
        }
        if ($weburl == false) {
            //			echo "<tr><td colspan=\"2\">在获取播放列表链接时出错 ".$strlink." / '.$strListUrl.'</TD></TR>";
            writetofile("crawel_auto_error.log", $p_id . '{=====}' . $strlink . '{=====}' . $strListUrl);
            //			$sb=$sb+1;
            return;
        } else {
            $sql = "select m_id,m_name,m_type,m_area,m_playfrom,m_starring,m_directed,m_pic,m_content,m_year,m_addtime,m_urltest,m_zt,m_pid,m_typeid,m_hits,m_playserver,m_state from {pre}cj_vod where  m_pid='" . $p_id . "' and m_name='" . $titlecode . "'  order by m_id desc";
            $rowvod = $db->getRow($sql);
            if ($rowvod) {
                $cg = $cg + 1;
                $movieid = $rowvod["m_id"];
                if (isN($titlecode)) {
                    $titlecode = $rowvod["m_name"];
                }
                if (isN($starringcode)) {
                    $starringcode = $rowvod["m_starring"];
                }
                if (isN($piccode)) {
                    $piccode = $rowvod["m_pic"];
                }
                $sql = "update {pre}cj_vod set m_pic='" . $piccode . "', m_type='" . $typecode . "',m_area='" . $areacode . "',m_urltest='" . $strlink . "',m_name='" . $titlecode . "',m_starring='" . $starringcode . "',m_directed='" . $directedcode . "',m_year='" . $timecode . "',m_playfrom='" . $p_playtype . "',m_content='" . $contentcode . "',m_addtime='" . date('Y-m-d H:i:s', time()) . "',m_zt='0',m_pid='" . $p_id . "',m_typeid='" . $m_typeid . "',m_playserver='" . $p_server . "',m_state='" . $lzcode . "',m_language='" . $languagecode . "',m_remarks='" . $remarkscode . "' where m_id=" . $rowvod["m_id"];
                writetofile("sql.txt", $sql);
                $db->query($sql);
                //			$sql="delete from {pre}cj_vod_url where u_movieid=".$rowvod["m_id"];
                //			writetofile("sql.txt", $sql);
                //			$db->query($sql);
            } else {
                $cg = $cg + 1;
                $sql = "insert {pre}cj_vod (m_name,m_type,m_area,m_playfrom,m_starring,m_directed,m_pic,m_content,m_year,m_urltest,m_zt,m_pid,m_typeid,m_hits,m_playserver,m_state,m_addtime,m_language,m_remarks) values('" . $titlecode . "','" . $typecode . "','" . $areacode . "','" . $p_playtype . "','" . $starringcode . "','" . $directedcode . "','" . $piccode . "','" . $contentcode . "','" . $timecode . "','" . $strlink . "','0','" . $p_id . "','" . $m_typeid . "','" . $m_hits . "','" . $p_server . "','" . $lzcode . "','" . date('Y-m-d H:i:s', time()) . "','" . $languagecode . "','" . $remarkscode . "')";
                writetofile("sql.txt", $sql);
                $db->query($sql);
                $movieid = $db->insert_id();
            }
            $webArray = explode("{Array}", $weburl);
            $setnamesArray = explode("{Array}", $setnames);
            $webArraTemp = array();
            $index = 0;
            $webUrls = '';
            for ($i = 0; $i < count($webArray); $i++) {
                $UrlTemp = $webArray[$i];
                if (strpos($webUrls, $UrlTemp . '<array>') === false) {
                    $webArraTemp[$index] = $UrlTemp;
                    $webUrls = $webUrls . $UrlTemp . '<array>';
                    $index++;
                }
            }
            //	    writetofile("d:\\ssssss.txt","p_videocodeType:".$p_videocodeType);
            $webArray = $webArraTemp;
            //http://www.youku.com/show_episode/id_zc16d0492e81411e196ac.html?dt=json&divid=reload_1&__rt=1&__ro=reload_1
            for ($i = 0; $i < count($webArray); $i++) {
                $WebTestx = $webArray[$i];
                if ($p_playspecialtype == 1 && strpos("," . $p_playspecialrrul, "[变量]")) {
                    $Keyurl = explode("[变量]", $p_playspecialrrul);
                    $urli = getBody($UrlTest, $Keyurl[0], $Keyurl[1]);
                    if ($urli == false) {
                        break;
                    }
                    $WebTestx = replaceStr($p_playspecialrerul, "[变量]", $urli);
                }
                if ($p_playspecialtype == 2) {
                    $urArray = explode("/", $strlink);
                    $ur = "";
                    for ($k = 0; $k < count($urArray) - 1; $k++) {
                        $ur = $ur . $urArray[$k] . "/";
                    }
                    $WebTestx = $ur . $WebTestx . ".html";
                }
                writetofile("crawel_auto_info.log", $p_id . '{=====}' . $WebTestx . "{=====}ViewList===start");
                if ($p_playlinktype == 1) {
                    //播放页获取地址
                    $WebTestx = getHrefFromLink($WebTestx);
                    $WebTestx = definiteUrl($WebTestx, $strListUrl);
                    $playCode = getPage($WebTestx, $p_coding);
                    $androidUrl = ContentProviderFactory::getContentProvider($p_playtype)->parseAndroidVideoUrlByContent($playCode, $p_coding, $p_script);
                    $videoAddressUrl = ContentProviderFactory::getContentProvider($p_playtype)->parseIOSVideoUrlByContent($playCode, $p_coding, $p_script);
                    writetofile("android_log.txt", $strlink . '{===}' . $androidUrl . '{===}' . $videoAddressUrl);
                    $url = getBody($playCode, $p_playurlstart, $p_playurlend);
                    $url = replaceLine($url);
                } else {
                    if ($p_playlinktype == 2) {
                        //播放链接中获取地址
                        $WebTestx = getHrefFromLink($WebTestx);
                        if (isN($p_playurlend)) {
                            $tmpA = strpos($WebTestx, $p_playurlstart);
                            $url = substr($WebTestx, strlen($WebTestx) - $tmpA - strlen($p_playurlstart) + 1);
                        } else {
                            $url = getBody($WebTestx, $p_playurlstart, $p_playurlend);
                        }
                    } else {
                        if ($p_playlinktype == 3) {
                            //单播放页获取所有播放地址
                            $WebTestx = getHrefFromLink($WebTestx);
                            $playCode = getPage($WebTestx, $p_coding);
                            $tmpB = getArray($webCode, $p_playurlstart, $p_playurlend);
                            $tmpC = explode("{$Array}\$", $tmpB);
                            foreach ($tmpC as $tmpD) {
                                $sql = "SELECT {pre}vod_url.u_url FROM ({pre}vod_url INNER JOIN {pre}vod ON {pre}vod_url.u_movieid = {pre}vod.m_id)  where {pre}vod_url.u_url='" . $tmpD . "' and {pre}vod.m_pid=" . $p_id;
                                $row = $db->getRow($sql);
                                if (!$row) {
                                    $strTempUrl = $strTempUrl . $tmpD . "<br>";
                                    $db->query("insert into {pre}vod_url(u_url,u_movieid) values('" . $tmpD . "','" . $movieid . "')");
                                }
                            }
                            break;
                        } else {
                            $url = $WebTestx;
                            $url = replaceLine($url);
                        }
                    }
                }
                $url = replaceFilters($url, $p_id, 3, 0);
                if ($p_setnametype == 1) {
                    $setname = getBody($url, $p_setnamestart, $p_setnameend);
                    //					$url = $setname . "$" . $url;
                } else {
                    if ($p_setnametype == 2 && $p_playlinktype == 1) {
                        $setname = getBody($playCode, $p_setnamestart, $p_setnameend);
                        //					$url = $setname ."$" .$url;
                    } else {
                        if ($p_setnametype == 3) {
                            $setname = $setnamesArray[$i];
                        }
                    }
                }
                $sql = "SELECT {pre}cj_vod_url.u_url FROM ({pre}cj_vod_url INNER JOIN {pre}cj_vod ON {pre}cj_vod_url.u_movieid = {pre}cj_vod.m_id)  where {pre}cj_vod_url.u_url='" . $url . "' and {pre}cj_vod.m_pid=" . $p_id . " and {pre}cj_vod.m_id=" . $movieid;
                $rowurl = $db->getRow($sql);
                //     		   writetofile("d:\\sql.txt",$rowurl);
                if (!$rowurl) {
                    if ($p_playlinktype == 1) {
                        $strTempUrl .= $url . "<br>";
                        $url = replaceStr($url, "'", "''");
                        writetofile("sql.txt", "insert into {pre}cj_vod_url(u_url,u_movieid,u_weburl,iso_video_url,name,android_vedio_url) values('" . $url . "','" . $movieid . "','" . getHrefFromLink($WebTestx) . "','" . getHrefFromLink($videoAddressUrl) . "','" . filterScriptStar($setname, $p_script) . "' ,'" . $androidUrl . "' )");
                        $db->query("insert into {pre}cj_vod_url(u_url,u_movieid,u_weburl,iso_video_url,name,android_vedio_url) values('" . $url . "','" . $movieid . "','" . getHrefFromLink($WebTestx) . "','" . getHrefFromLink($videoAddressUrl) . "','" . filterScriptStar($setname, $p_script) . "' ,'" . $androidUrl . "' )");
                    } else {
                        $strTempUrl .= $url . "<br>";
                        writetofile("sql.txt", "insert into {pre}cj_vod_url(u_url,u_movieid,iso_video_url,u_weburl,android_vedio_url) values('" . $url . "','" . $movieid . "','" . getHrefFromLink($videoAddressUrl) . "','" . getHrefFromLink($strlink) . "', '" . $androidUrl . "')");
                        $db->query("insert into {pre}cj_vod_url(u_url,u_movieid,iso_video_url,u_weburl,android_vedio_url) values('" . $url . "','" . $movieid . "','" . getHrefFromLink($videoAddressUrl) . "','" . getHrefFromLink($strlink) . "', '" . $androidUrl . "')");
                    }
                }
            }
        }
    }
    $cg = $cg + 1;
}
function main()
{
    global $db, $cache;
    $pagenum = be("get", "page");
    if (isN($pagenum) || !isNum($pagenum)) {
        $pagenum = 1;
    }
    if ($pagenum < 1) {
        $pagenum = 1;
    }
    $pagenum = intval($pagenum);
    $sql = "select * from {pre}cj_vod_projects ";
    $rscount = $db->query($sql);
    $nums = $db->num_rows($rscount);
    //总记录数
    $pagecount = ceil($nums / app_pagenum);
    //总页数
    $sql = $sql . "limit " . app_pagenum * ($pagenum - 1) . "," . app_pagenum;
    $rs = $db->query($sql);
    ?>
<table border="0" cellpadding="3" cellspacing="1">
	<tr>
	<td>
		菜单:<a href="collect_vod_manage.php?action=add">添加采集规则</a> | <a href="collect_vod_manage.php?action=upexp">导入采集规则</a>
	</td>
	</tr>
</table>
<form action="" method="post" name="form1">
<table class="collect_vod_manage tb">
    <tr>
	  <td width="5%">&nbsp;</td>
      <td width="10%">项目名称</td>
      <td width="10%">播放类型</td>
      <td width="10%">入库分类</td>
      <td width="20%">上次采集</td>
      <td width="45%">操作</td>
    </tr>
	<?php 
    if (!$rs) {
        ?>
    <tr><td align="center" colspan="7" >没有任何记录!</td></tr>
    <?php 
    } else {
        while ($row = $db->fetch_array($rs)) {
            ?>
    <tr>
	  <td><input name="p_id[]" type="checkbox" id="p_id" value="<?php 
            echo $row["p_id"];
            ?>
" /></td>
      <td><a href="?action=edit&p_id=<?php 
            echo $row["p_id"];
            ?>
"><?php 
            echo $row["p_name"];
            ?>
</a></td>
      
	  <td><?php 
            echo $row["p_playtype"];
            ?>
</td>
	  <td>
	  <?php 
            if ($row["p_classtype"] == 1) {
                echo "<font color=red>自定义分类</font>";
            } else {
                $typearr = getValueByArray($cache[0], "t_id", $row["p_collect_type"]);
                echo $typearr["t_name"];
            }
            ?>
	  </td>
      <td><?php 
            echo isToDay($row['p_time']);
            ?>
</td>
 	  <td>
 	  <A href="collect_vod_cj.php?ignoreExistM=true&p_id=<?php 
            echo $row["p_id"];
            ?>
">采集</A>|
 	   <A href="collect_vod_cj.php?p_id=<?php 
            echo $row["p_id"];
            ?>
">采集(包括已经采集过)</A>|
 	  <A href="?action=collectSimple&p_id=<?php 
            echo $row["p_id"];
            ?>
&p_name=<?php 
            echo $row["p_name"];
            ?>
">采集单个视频</A>|
 	  <A href="?action=collectVideo&p_id=<?php 
            echo $row["p_id"];
            ?>
&p_name=<?php 
            echo $row["p_name"];
            ?>
">采集视频地址</A>|
 	  <A href="?action=edit&p_id=<?php 
            echo $row["p_id"];
            ?>
">设置</A>|
 	  <A href="?action=copy&p_id=<?php 
            echo $row["p_id"];
            ?>
">复制</A>|
 	  <A href="?action=export&p_id=<?php 
            echo $row["p_id"];
            ?>
">导出</A>|
 	  <A href="?action=del&p_id=<?php 
            echo $row["p_id"];
            ?>
">删除</A>
 	  
 	  </td>
    </tr>
	<?php 
        }
    }
    ?>
	<tr class="formlast">
	<td  colspan="6">
	<input name="chkall" type="checkbox" id="chkall" value="1" onClick="checkAll(this.checked,'p_id[]');"/> 全选
	<input type="submit" value="批量删除" onClick="if(confirm('确定要删除吗')){form1.action='?action=delall';}else{return false}"  class="input"/>
	
	</td>
	</tr>
    <tr align="center" class="formlast">
      <td colspan="7">
        <?php 
    echo pagelist_manage($pagecount, $pagenum, $nums, app_pagenum, "collect_vod_manage.php?page={p}");
    ?>
      </td>
    </tr>
</table>
</form>
<?php 
}
function main()
{
    global $db, $cache;
    $keyword = be("all", "keyword");
    $t_flag = be("all", "t_flag");
    $t_userid = be("all", "t_userid");
    $t_type = be("all", "t_type");
    $t_bdtype = be("all", "t_bdtype");
    $can_search_device = be("all", "can_search_device");
    if (!isNum($t_userid)) {
        $t_userid = -1;
    } else {
        $t_userid = intval($t_userid);
    }
    if (!isNum($t_bdtype)) {
        $t_bdtype = -1;
    } else {
        $t_bdtype = intval($t_bdtype);
    }
    if (!isNum($t_flag)) {
        $t_flag = -1;
    } else {
        $t_flag = intval($t_flag);
    }
    if (!isNum($t_type)) {
        $t_type = -1;
    } else {
        $t_type = intval($t_type);
    }
    $where = " t_id>4 ";
    if (!isN($keyword)) {
        $where .= " AND t_name LIKE '%" . $keyword . "%' ";
    }
    if ($t_type > 0) {
        $typearr = getValueByArray($cache[0], "t_id", $t_type);
        if (is_array($typearr)) {
            $where = $where . " and t_type in (" . $typearr["childids"] . ")";
        } else {
            $where .= " AND t_type=" . $t_type . " ";
        }
    }
    if (!isN($can_search_device)) {
        //if($can_search_device ==='TV'){
        //	$where .= " AND can_search_device like '%TV%' ";
        //}else {
        $where .= " AND (can_search_device like '" . $can_search_device . "' or can_search_device is null or can_search_device ='' ) ";
        //}
    }
    if ($t_flag == 1) {
        $where .= " AND t_flag =1 ";
    }
    if ($t_bdtype != -1) {
        $where .= " AND t_bdtype=" . $t_bdtype;
    }
    if ($t_flag == 0) {
        $where .= " AND t_flag =0 ";
    }
    if ($t_userid == 1) {
        $where .= " AND t_userid >0 ";
    }
    if ($t_userid == 0) {
        $where .= " AND t_userid =0 ";
    }
    $pagenum = be("all", "page");
    if (!isNum($pagenum)) {
        $pagenum = 1;
    } else {
        $pagenum = intval($pagenum);
    }
    if ($pagenum < 1) {
        $pagenum = 1;
    }
    $sql = "SELECT count(*) FROM {pre}vod_topic" . " where " . $where;
    $nums = $db->getOne($sql);
    $pagecount = ceil($nums / app_pagenum);
    $sql = "SELECT * FROM {pre}vod_topic  where " . $where . " ORDER BY t_sort desc,t_id ASC limit " . app_pagenum * ($pagenum - 1) . "," . app_pagenum;
    $rs = $db->query($sql);
    ?>
<script language="javascript">
function filter(){
	var t_userid=$("#t_userid").val();
	var t_flag=$("#t_flag").val();
	var t_type=$("#t_type").val();
	var keyword=$("#keyword").val();
	var t_bdtype=$("#t_bdtype").val();
	 
	var can_search_device=$("#can_search_device").val();
	var url = "admin_vod_topic.php?can_search_device="+can_search_device+"&keyword="+encodeURI(keyword)+"&t_userid="+t_userid+"&t_flag="+t_flag+"&t_type="+t_type+"&t_bdtype="+t_bdtype;
	window.location.href=url;
}

$(document).ready(function(){
	$("#form2").validate({
		rules:{
			t_name:{
				required:true,
//				stringCheck:true,
				maxlength:64
			},
//			t_enname:{
//				required:true,
////				stringCheck:true,
//				maxlength:128
//			},
//			t_template:{
//				required:true,
//				maxlength:128
//			},
			t_pic:{
				maxlength:254
			},
			t_sort:{
				number:true
			},
			t_des:{
				required:true,
				maxlength:254
			}
		}
	});
	$('#form1').form({
		onSubmit:function(){
			if(!$("#form1").valid()) {return false;}
		},
	    success:function(data){
	        $.messager.alert('系统提示', data, 'info',function(){
	        	location.href=location.href;
	        });
	    }
	});
	$('#form2').form({
		onSubmit:function(){
			if(!$("#form2").valid()) {return false;}
		},
	    success:function(data){
	        $.messager.alert('系统提示', data, 'info');
	    }
	});
	$("#btnDel").click(function(){
			if(confirm('确定要删除吗')){
				$("#form1").attr("action","admin_ajax.php?action=del&flag=batch&tab={pre}vod_topic");
				$("#form1").submit();
			}
			else{return false}
	});

	$("#btnAddLunBo").click(function(){
		var ids = "",tid="";
		tid= "t_id[]";
		$("input[name='"+tid+"']").each(function() {
			if(this.checked){ ids =  ids + this.value + ","; }
		});
		if (ids != ""){
			if(confirm('确定要添加到轮播图吗')){
				$("#form1").attr("action","admin_ajax.php?action=lunboForTopic&flag=batch&tab={pre}vod_popular");
				$("#form1").submit();
			}else{return false;}
			}else{
				alert("请至少选择一个数据!");
				}
});

	
	$("#btnEdit").click(function(){
		$("#form1").attr("action","?action=editall");
		$("#form1").submit();
	});
	$("#btnAdd").click(function(){
		$('#form2').form('clear');
		$("#flag").val("add");
		$('#win1').window('open');
		
	});
	$("#btnCancel").click(function(){
		location.href= location.href;
	});
});
function edit(id)
{
	$('#form2').form('clear');
	$("#flag").val("edit");
	$('#win1').window('open');
	$('#form2').form('load','admin_ajax.php?action=getinfo&tab={pre}vod_topic&col=t_id&val='+id);
}
</script>

<table class="admin_vod_topic_1 tb">
	<tr>
	<td>
	<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
	<tr>
	<td colspan="2">
	过滤条件:<select id="t_type" name="t_type">
	<option value="0">视频栏目</option>
	<option value="-1" <?php 
    if ($t_type == -1) {
        echo "selected";
    }
    ?>
>没有栏目</option>
	<?php 
    echo makeSelectAll("{pre}vod_type", "t_id", "t_name", "t_pid", "t_sort", 0, "", "&nbsp;|&nbsp;&nbsp;", $t_type);
    ?>
	</select>
	
	<select id="t_bdtype" name="t_bdtype">
	<option value="-1">榜单类型</option>
	<option value="1" <?php 
    if ($t_bdtype == 1) {
        echo "selected";
    }
    ?>
>悦单</option>
	<option value="2" <?php 
    if ($t_bdtype == 2) {
        echo "selected";
    }
    ?>
>悦榜</option>
	</select>
	
	&nbsp;
	<select id="t_flag" name="t_flag">
	<option value="-1">显示到APP</option>
	<option value="1" <?php 
    if ($t_flag == 1) {
        echo "selected";
    }
    ?>
>显示</option>
	<option value="0" <?php 
    if ($t_flag == 0) {
        echo "selected";
    }
    ?>
>隐藏</option>
	</select>
	<select id="t_userid" name="t_userid">
	<option value="-1">系统/用户创建</option><?php 
    echo $t_userid;
    ?>
	<option value="0" <?php 
    if ($t_userid == 0) {
        echo "selected";
    }
    ?>
>系统创建</option>
	<option value="1" <?php 
    if ($t_userid > 0) {
        echo "selected";
    }
    ?>
>用户创建</option>
	</select>
	
	 <select   id="can_search_device" name="can_search_device">
	    <option value="" >投放设备</option>
		<option value="TV" <?php 
    if ($can_search_device === 'TV') {
        echo "selected";
    }
    ?>
>TV版</option>
		<option value="iPad" <?php 
    if ($can_search_device === 'iPad') {
        echo "selected";
    }
    ?>
>iPad版</option>
		<option value="iphone" <?php 
    if ($can_search_device === 'iphone') {
        echo "selected";
    }
    ?>
>iphone版</option>
		<option value="apad" <?php 
    if ($can_search_device === 'apad') {
        echo "selected";
    }
    ?>
>Android-Pad版</option>
		<option value="aphone" <?php 
    if ($can_search_device === 'aphone') {
        echo "selected";
    }
    ?>
>Android-Phone版</option>
		<option value="web" <?php 
    if ($can_search_device === 'web') {
        echo "selected";
    }
    ?>
>网站版</option>
	</select>
	
	</td>
	</tr>
	<tr>
	<td colspan="6">
	关键字:<input id="keyword" size="40" name="keyword" value="<?php 
    echo $keyword;
    ?>
">
	<input class="input" type="button" value="搜索" id="btnsearch" onClick="filter();">	
	</td>
	<td width="150px">
		
	</td>
	</tr>
	</table>
	</td>
	</tr>
</table>

<table class="admin_vod_topic tb">
<form action="" method="post" id="form1" name="form1">
	<tr>
	<td width="5%">&nbsp;</td>
	<td width="5%">编号</td>
	<td>名称</td>
	<td>关注度</td>
	<td width="3%">类别</td>
	<td width="10%">视频栏目</td>
	<td width="8%">投放设备</td>
	<td width="5%">图片</td>
	<td width="5%">排序</td>
	<td width="10%">显示到App</td>
	<td width="30%">操作</td>
	</tr>
	<?php 
    if ($nums == 0) {
        ?>
    <tr><td align="center" colspan="7">没有任何记录!</td></tr>
    <?php 
    } else {
        while ($row = $db->fetch_array($rs)) {
            $t_id = $row["t_id"];
            ?>
    <tr>
	  <td>
	  <input name="t_id[]" type="checkbox" id="t_id" value="<?php 
            echo $t_id;
            ?>
" /></td>
      <td><?php 
            echo $t_id;
            ?>
</td>
      <td>
      <input type="text" name="t_name<?php 
            echo $t_id;
            ?>
" value="<?php 
            echo $row["t_name"];
            ?>
" size="20"/></td>
	  <td>
	   <select id="t_toptype<?php 
            echo $t_id;
            ?>
" name="t_toptype<?php 
            echo $t_id;
            ?>
">
	<option value="-1">关注度</option>
	<option value="1" <?php 
            if ($row["t_toptype"] == 1) {
                echo "selected";
            }
            ?>
>热门</option>
	<option value="0" <?php 
            if ($row["t_toptype"] == 0) {
                echo "selected";
            }
            ?>
>非热门</option>
	</select>
	  </td>
	  <td>
	 
	  <select id="t_type<?php 
            echo $t_id;
            ?>
" name="t_type<?php 
            echo $t_id;
            ?>
">
	<option value="0" <?php 
            if ($row["t_type"] == 0) {
                echo "selected";
            }
            ?>
>没有栏目</option>
	<?php 
            echo makeSelectAll("{pre}vod_type", "t_id", "t_name", "t_pid", "t_sort", 0, "", "&nbsp;|&nbsp;&nbsp;", $row["t_type"]);
            ?>
	</select>
	  </td>
       <td>
	 <select id="t_bdtype<?php 
            echo $t_id;
            ?>
" name="t_bdtype<?php 
            echo $t_id;
            ?>
">
	<option value="-1">榜单类型</option>
	<option value="1" <?php 
            if ($row["t_bdtype"] == 1) {
                echo "selected";
            }
            ?>
>悦单</option>
	<option value="2" <?php 
            if ($row["t_bdtype"] == 2) {
                echo "selected";
            }
            ?>
>悦榜</option>
	</select></td>
	<td width="20%"><?php 
            if (isN($row["can_search_device"])) {
                echo 'TV,iPad,iphone,apad,aphone,web';
            } else {
                echo $row["can_search_device"];
            }
            ?>
	</td>
      <td>
      <input type="text" name="t_pic<?php 
            echo $t_id;
            ?>
" value="<?php 
            echo $row["t_pic"];
            ?>
" size="20"/></td>
	  <td>
	  <input name="t_sort<?php 
            echo $t_id;
            ?>
" type="text" value="<?php 
            echo $row["t_sort"];
            ?>
"  size="5"/></td>
	  <td>
	 
	  <select id="t_flag<?php 
            echo $t_id;
            ?>
" name="t_flag<?php 
            echo $t_id;
            ?>
">
	<option value="0" <?php 
            if ($row["t_flag"] == 0) {
                echo "selected";
            }
            ?>
>不显示</option>
	<option value="1" <?php 
            if ($row["t_flag"] == 1) {
                echo "selected";
            }
            ?>
>显示</option>
	</select>
	  </td>
	  
	  
	  
      <td>
	  <a href="javascript:void(0)" onclick="edit('<?php 
            echo $t_id;
            ?>
');return false;">修改</a> | 
	  <a href="admin_vod_topic_items.php?topic_id=<?php 
            echo $t_id;
            ?>
">显示视频列表</a> |
<!--	  <a href="admin_ajax.php?action=del&tab={pre}vod_topic&t_id=<?php 
            echo $t_id;
            ?>
" onClick="return confirm('确定要删除吗?');">删除</a> |-->
	  <a href="admin_ajax.php?action=lunboForTopic&tab={pre}vod_popular&t_id=<?php 
            echo $t_id;
            ?>
" onClick="return confirm('确定要添加到轮播图吗?');">添加到轮播图</a>
	  </td>
    </tr>
	<?php 
        }
    }
    ?>
	<tr class="formlast">
	<td  colspan="12">全选<input type="checkbox" name="chkall" id="chkall" class="checkbox" onClick="checkAll(this.checked,'t_id[]')" />
<!--	<input type="button" value="批量删除" id="btnDel" class="input"  />-->
	&nbsp;<input type="button" value="批量修改" id="btnEdit" class="input" />
	&nbsp;<input type="button" value="添加" id="btnAdd" class="input" />
	&nbsp;<input type="button" value="添加到轮播图" id="btnAddLunBo" class="input"  />
	</td></tr>
    <tr align="center" class="formlast">
	<td colspan="12">
		<?php 
    echo pagelist_manage($pagecount, $pagenum, $nums, app_pagenum, "admin_vod_topic.php?page={p}&can_search_device=" . $can_search_device . "&keyword=" . urlencode($keyword) . "&t_type=" . $t_type . "&t_flag=" . $t_flag . "&t_userid=" . $t_userid . "&t_bdtype=" . $t_bdtype);
    ?>
	</td>
    </tr>
</table>
</form>

<div id="win1" class="easyui-window" title="窗口" style="padding:5px;width:450px;" closed="true" closable="false" minimizable="false" maximizable="false">
<form action="admin_ajax.php?action=save&tab={pre}vod_topic" method="post" name="form2" id="form2">
<table class="tb">
	<input id="t_id" name="t_id" type="hidden" value="">
	<input id="flag" name="flag" type="hidden" value="">
	<tr>
	<td width="30%">专题名称:</td>
	<td><input id="t_name" size=40 value="" name="t_name">
	</td>
	</tr>
	<tr>
	<td>关注度:</td>
	<td>  <select id="t_toptype" name="t_toptype">
	<option value="0" >非热门</option>
	<option value="1">热门</option>
	</select>
	</td>
    </tr>
	<tr>
	<td>节目类别:</td>
	<td><select id="t_type" name="t_type">
	<option value="0" >没有栏目</option>
	<?php 
    echo makeSelectAll("{pre}vod_type", "t_id", "t_name", "t_pid", "t_sort", 0, "", "&nbsp;|&nbsp;&nbsp;", 0);
    ?>
	</select>
	</td>
	</tr>
	<tr>
     <td>专题图片:</td>
      <td><input id="t_pic" size=40 value="" name="t_pic" >
	  </td>
    </tr>
    
    <tr>
     <td>显示到App:</td>
      <td><select id="t_flag" name="t_flag">
	   <option value="0" selected>不显示</option>
	   <option value="1" >显示</option>
	</select>
	  </td>
    </tr>
    
     <tr>
     <td>榜单类型</td>
      <td> <select  id="t_bdtype" name="t_bdtype">
	<option value="1" selected>悦单</option>
	<option value="2">悦榜</option>
	</select>
	  </td>
    </tr>
    
    <tr id="can_search_device">
     <td>投放设备(可以多选)</td>
      <td><input type="checkbox" name="can_search_device[]" value="TV"
		<?php 
    if (strpos($can_search_device, "TV") != false) {
        echo "checked";
    }
    ?>
 />TV版
		<input type="checkbox" name="can_search_device[]" value="iPad"
		<?php 
    if (strpos($can_search_device, "iPad") != false) {
        echo "checked";
    }
    ?>
 />iPad版
		<input type="checkbox" name="can_search_device[]" value="iphone"
		<?php 
    if (strpos($can_search_device, "iphone") != false) {
        echo "checked";
    }
    ?>
 />iphone版
		<input type="checkbox" name="can_search_device[]" value="apad"
		<?php 
    if (strpos($can_search_device, "apad") != false) {
        echo "checked";
    }
    ?>
 />Android-Pad版
		<input type="checkbox" name="can_search_device[]" value="aphone"
		<?php 
    if (strpos($can_search_device, "aphone") != false) {
        echo "checked";
    }
    ?>
 />Android-phone版
		<input type="checkbox" name="can_search_device[]" value="web"
		<?php 
    if (strpos($can_search_device, "web") != false) {
        echo "checked";
    }
    ?>
 />网站版
<!--<input type="checkbox" id="can_search_device[]" name="can_search_device[]" value="TV"  />TV版-->
<!--    <input type="checkbox" id="can_search_device[]" name="can_search_device[]" value="Pad"  />Pad版-->
<!--    <input type="checkbox"  id="can_search_device[]" name="can_search_device[]" value="Mobile" />Mobile版-->
<!--    <input type="checkbox"  name="can_search_device[]" value="Web" />网站版-->
	  </td>
    </tr>
    
    
    
	<!--    <tr>-->
	<!--     <td>榜单归档,Tag:</td>-->
	<!--      <td>-->
	<!--      <TEXTAREA id="t_tag_name" NAME="t_tag_name" ROWS="1" style="width:300px;table-layout:fixed; word-wrap:break-word;"></TEXTAREA>-->
	<!--	  </td>-->
	<!--    </tr>-->
	<!--   -->
    
	<tr>
     <td>排序:</td>
		<td><input id="t_sort" size=10 value="" name="t_sort"></td>
    </tr>
	<tr>
     <td>描述信息:</td>
		<td><TEXTAREA id="t_des" NAME="t_des" ROWS="2"
			style="width: 300px; table-layout: fixed; word-wrap: break-word;"></TEXTAREA>
	  </td>
    </tr>
    <tr align="center" >
		<td colspan="2"><input class="input" type="submit" value="保存"
			id="btnSave"> <input class="input" type="button" value="返回"
			id="btnCancel"></td>
    </tr>
</table>
</form>
</div>
</body>
</html>
<?php 
    unset($rs);
}
function main()
{
    global $db, $cache;
    $pagenum = be("get", "page");
    if (isN($pagenum) || !isNum($pagenum)) {
        $pagenum = 1;
    }
    if ($pagenum < 1) {
        $pagenum = 1;
    }
    $pagenum = intval($pagenum);
    $keyword = be("get", "keyword");
    $from = be("get", "playfrom");
    $project = be("get", "cj_vod_projects");
    $zt = be("get", "zt");
    $sql = "Select a.*,b.p_name as p_name from {pre}cj_vod a,{pre}cj_vod_projects b where a.m_pid=b.p_id and m_playfrom not in ('tudou','kankan','cntv','wasu') ";
    if ($zt != "") {
        $sql = $sql . " and m_zt = " . $zt;
    }
    if ($keyword != "") {
        $keyword = trim($keyword);
        $sql = $sql . " and m_name like '%" . $keyword . "%' ";
    }
    if ($project != "") {
        $sql = $sql . " and a.m_pid = " . $project;
    }
    if ($from != "") {
        $sql = $sql . " and a.m_playfrom ='" . $from . "' ";
    }
    $sql = $sql . " order by  m_zt asc, m_addtime desc,m_name desc ";
    $rscount = $db->query($sql);
    $nums = $db->num_rows($rscount);
    //总记录数
    $pagecount = ceil($nums / app_pagenum);
    //总页数
    $sql = $sql . " limit " . app_pagenum * ($pagenum - 1) . "," . app_pagenum;
    $rs = $db->query($sql);
    ?>
    <script language="javascript">
        $(document).ready(function () {
            $("#btnDel").click(function () {
                if (confirm('确定要删除吗')) {
                    $("#form1").attr("action", "?action=delpl");
                    $("#form1").submit();
                }
            });
            $("#btnDelall").click(function () {
                if (confirm('确定要删除吗')) {
                    $("#form1").attr("action", "?action=delall");
                    $("#form1").submit();
                }
            });
            $("#btnSelin").click(function () {
                if (confirm('确定入库您所选择的数据吗')) {
                    $("#form1").attr("action", "?action=IDInflow");
                    $("#form1").submit();
                }
            });

            $("#btnSelinZhuiju").click(function () {
                if (confirm('确定添加您所选择的数据到自动采集/自动入库吗')) {
                    $("#form1").attr("action", "?action=IDInflowZhuiJu");
                    $("#form1").submit();
                }
            });

            $("#btnAllin").click(function () {
                if (confirm('全部入库你所采集的数据吗')) {
                    $("#form1").attr("action", "?action=AllInflow");
                    $("#form1").submit();
                }
            });
            $("#btnNoin").click(function () {
                if (confirm('确定入库所有未入库的数据吗')) {
                    $("#form1").attr("action", "?action=noInflow");
                    $("#form1").submit();
                }
            });

            $("#noInflowProject").click(function () {
                var keyword = $("#keyword").val();
                var playfrom = $("#playfrom").val();
                var project = $("#cj_vod_projects").val();
                if (confirm('确定所搜视频入库未入库吗')) {
                    $("#form1").attr("action", "?action=noInflowProject&keyword=" + keyword + "&playfrom=" + playfrom + "&cj_vod_projects=" + project);
                    $("#form1").submit();
                }
            });


            $("#AllInflowProject").click(function () {
                var keyword = $("#keyword").val();
                var playfrom = $("#playfrom").val();
                var project = $("#cj_vod_projects").val();
                if (confirm('确定所搜视频全部入库吗')) {
                    $("#form1").attr("action", "?action=AllInflowProject&keyword=" + keyword + "&playfrom=" + playfrom + "&cj_vod_projects=" + project);
                    $("#form1").submit();
                }
            });


            $("#btnType").click(function () {
                if (confirm('确定更新所选数据的分类吗')) {
                    $("#form1").attr("action", "?action=editype");
                    $("#form1").submit();
                }
            });
        });

    </script>
    <TABLE width="96%" border=0 align=center cellpadding=0 cellSpacing=0
           class=tbtitle>
        <TBODY>
        <tr>
            <td>
                <form action="collect_vod.php" method="get"><strong>搜索影片:</strong> <input
                        type="hidden" name="action" value="main"> <input id=keyword size=40
                                                                         name=keyword value="<?php 
    echo $keyword;
    ?>
">
                    <select id="playfrom"
                            name=playfrom>
                        <option value="">视频播放器</option>
                        <?php 
    echo makeSelectPlayer($from);
    ?>
                    </select> <select id="cj_vod_projects" name="cj_vod_projects">
                        <option value="">全部采集项目</option>
                        <?php 
    echo makeSelect("{pre}cj_vod_projects", "p_id", "p_name", "", "", "&nbsp;|&nbsp;&nbsp;", $project);
    ?>
                    </select> <INPUT class=inputbut type=submit value=搜索 name=submit></form>
            </td>
        </tr>
        </TBODY>
    </TABLE>

    <form action="" method="post" name="form1" id="form1">
        <table class="collect_vod tb">
            <tr>
                <td width="4%">&nbsp;</td>
                <td>影片名称</td>
                <td width="7%">状态</td>
                <td width="7%">播放器</td>
                <td width="10%">栏目分类</td>
                <td width="10%">地区</td>
                <td width="10%">上映日期</td>
                <td width="15%">所属采集项目</td>
                <td width="13%">更新时间</td>
                <td width="8%">操作</td>
            </tr>
            <?php 
    if (!$rs) {
        ?>
                <tr>
                    <td align="center" colspan="9">没有任何记录!</td>
                </tr>
            <?php 
    } else {
        $i = 0;
        while ($row = $db->fetch_array($rs)) {
            ?>
                    <tr>
                        <td><input name="m_id[]" type="checkbox" id="m_id"
                                   value="<?php 
            echo $row["m_id"];
            ?>
"/></td>
                        <td><?php 
            echo $row["m_name"];
            ?>
 (连载:<?php 
            echo $row["m_state"];
            ?>
)</td>
                        <td><?php 
            if ($row["m_zt"] == 1) {
                echo "<font color=\"#FF0000\">已入库</font>";
            } else {
                echo "未入库";
            }
            ?>
</td>
                        <td><?php 
            echo $row["m_playfrom"];
            ?>
</td>
                        <td><?php 
            if ($row["m_typeid"] == 0) {
                ?>
 <font color="#FF0000">没找到对应分类请配置</font> <?php 
            } else {
                $typearr = getValueByArray($cache[0], "t_id", $row["m_typeid"]);
                echo $typearr["t_name"];
            }
            ?>
</td>
                        <td><?php 
            echo $row["m_area"];
            ?>
</td>
                        <td><?php 
            echo $row["m_year"];
            ?>
</td>
                        <td><?php 
            echo $row["p_name"];
            ?>
</td>
                        <td><?php 
            echo isToDay($row['m_addtime']);
            ?>
</td>
                        <td><A href="?action=edit&m_id=<?php 
            echo $row["m_id"];
            ?>
">修改</A>|<A
                                href="?action=del&m_id=<?php 
            echo $row["m_id"];
            ?>
">删除</A></td>
                    </tr>
                <?php 
        }
    }
    ?>
            <tr class="formlast">
                <td colspan="9"><input name="chkall" type="checkbox" id="chkall"
                                       value="1" onClick="checkAll(this.checked,'m_id[]');"/> 全选 <input
                        type="button" id="btnDel" value="批量删除" class="btn"/>
                    <!--	&nbsp;<input type="button" id="btnDelall" value="删除所有" class="btn"  />-->
                    &nbsp;<input type="button" id="btnSelin" class="btn" name="Submit"
                                 value="入库所选"> &nbsp;<input type="button" id="btnSelinZhuiju"
                                                            class="btn" name="Submit" value="添加到自动采集入库">
                    <!--	&nbsp;<input type="button" id="btnAllin" class="btn" name="Submit" value="全部入库" >-->
                    <!--    &nbsp;<input type="button" id="btnNoin" class="btn" name="Submit" value="入库未入库" >-->
                    &nbsp;<input type="button" id="AllInflowProject" class="btn"
                                 name="Submit" value="所搜视频全部入库"> &nbsp;<input type="button"
                                                                              id="noInflowProject" class="btn"
                                                                              name="Submit" value="所搜视频入库未入库"> <font
                        color="#FF0000">&nbsp; </font></td>
            </tr>
            <tr class="formlast">
                <td colspan="9">入库同名处理: <input type="radio" name="CCTV" value="0"
                                               checked>自动处理 <input type="radio" name="CCTV" value="1">始终新增数据 <input
                        type="radio" name="CCTV" value="2">新增播放器组 <input type="radio"
                                                                         name="CCTV" value="3">不处理 <br/>
                    强制覆盖数据: <input type="checkbox" name="CCTV1" value="1">年份 <input
                        type="checkbox" name="CCTV2" value="2">地区 <input type="checkbox"
                                                                         name="CCTV3" value="3">演员 <input
                        type="checkbox" name="CCTV4"
                        value="4">图片 <input type="checkbox" name="CCTV5" value="5">简介 <input
                        type="checkbox" name="CCTV6" value="6">语言 <input type="checkbox"
                                                                         name="CCTV7" value="7">备注 <input
                        type="checkbox" name="CCTV8"
                        value="8">导演 <input type="checkbox" name="CCTV9" value="9">影片长度 <br/>
                    <font color="#FF0000">注意 :自动判断播放来源,如遇到相同来源则更新数据。</font></td>
            </tr>
            <tr align="center" class="formlast">
                <td colspan="9"><?php 
    echo pagelist_manage($pagecount, $pagenum, $nums, app_pagenum, "collect_vod.php?action=main&page={p}&cj_vod_projects=" . $project . "&keyword=" . $keyword . "&playfrom=" . $from);
    ?>
</td>
            </tr>
        </table>
    </form>
<?php 
}
 function loadlist($flag, $typearr)
 {
     global $mac, $cache;
     if (!is_array($typearr)) {
         showMsg("找不到此数据", "../");
     }
     if ($flag == "art") {
         $this->page_id = $mac["arttypeid"];
         $typeLink = $this->getArtTypeLink($this->page_id, $typearr["t_name"], $typearr["t_enname"], true);
         $viewtype = app_artlistviewtype;
     } else {
         $this->page_id = $mac["vodtypeid"];
         $typeLink = $this->getVodTypeLink($this->page_id, $typearr["t_name"], $typearr["t_enname"], true);
         $viewtype = app_vodlistviewtype;
     }
     $this->page_name = $typearr["t_name"];
     $this->page_enname = $typearr["t_enname"];
     $t_pid = $typearr["t_pid"];
     $t_key = $typearr["t_key"];
     $t_des = $typearr["t_des"];
     $t_template = $typearr["t_template"];
     $this->page_typearr = $typearr;
     $this->page = $mac["page"];
     if ($viewtype != 2) {
         attemptCacheFile($flag . "list", "list" . $this->page_id . $mac["page"] . urlencode($mac["area"]) . $mac["year"] . $mac["order"] . $mac["by"]);
     }
     $cacheName = $flag . "list_" . $this->page_id;
     $cachetemplatename = "template_" . $flag . "list_" . $this->page_id;
     $templatepath = root . "template/" . app_templatedir . "/" . app_htmldir . "/" . $t_template;
     if (chkCache($cacheName)) {
         $this->html = getCache($cacheName);
     } else {
         if ($t_pid !== '0') {
             $typearr = getValueByArray($cache[0], "t_id", $t_pid);
             $tempName = $typearr['t_name'] . '>>' . $this->page_name;
         } else {
             $tempName = $this->page_name;
         }
         $this->html = getFileByCache($cachetemplatename, $templatepath);
         $this->html = replaceStr($this->html, "{typepage:id}", $this->page_id);
         $this->html = replaceStr($this->html, "{typepage:name}", $tempName);
         $this->html = replaceStr($this->html, "{typepage:enname}", $this->page_enname);
         $this->html = replaceStr($this->html, "{typepage:pid}", $t_pid);
         $this->html = replaceStr($this->html, "{typepage:key}", $t_key);
         $this->html = replaceStr($this->html, "{typepage:des}", $t_des);
         $this->html = replaceStr($this->html, "{typepage:link}", $typeLink);
         $this->html = replaceStr($this->html, "{typepage:textlink}", $this->getTypeText($this->page_id, $t_pid, $this->page_name, $typeLink, $flag));
         $this->mark();
         setCache($cacheName, $this->html, 0);
     }
     $this->html = replaceStr($this->html, "{typepage:page}", $this->page);
     $this->html = replaceStr($this->html, "{typepage:order}", $mac["order"]);
     $this->html = replaceStr($this->html, "{typepage:by}", $mac["by"]);
     $this->html = replaceStr($this->html, "{typepage:area}", $mac["area"]);
     $this->html = replaceStr($this->html, "{typepage:year}", $mac["year"]);
     if ($flag == "art") {
         $this->artpagelist();
     } else {
         $vlink = $this->getVodTypeLink($this->page_id, $typearr["t_name"], $typearr["t_enname"], false);
         switch (app_vodlistviewtype) {
             case 0:
             case 3:
                 $str = "-1" . "-{area}-{year}-" . $mac["order"] . "-" . $mac["by"] . "." . app_vodsuffix;
                 break;
             case 1:
                 $str = "&page=1&area={area}&year={year}&order=" . $mac["order"] . "&by=" . $mac["by"];
                 break;
             default:
                 $str = "." . app_vodsuffix;
                 break;
         }
         $alink = $vlink . $str;
         $linkyear = replaceStr($alink, "{area}", urlencode($mac["area"]));
         $linkyear = replaceStr($linkyear, "{year}", "");
         $this->html = replaceStr($this->html, "{typepage:linkyear}", $linkyear);
         $linkarea = replaceStr($alink, "{year}", $mac["year"]);
         $linkarea = replaceStr($linkarea, "{area}", "");
         $this->html = replaceStr($this->html, "{typepage:linkarea}", $linkarea);
         if ($typearr["t_pid"] == 0) {
             $linkid = $typearr["t_id"];
         } else {
             $linkid = $typearr["t_pid"];
         }
         $vlink = $this->getVodTypeLink($linkid, $typearr["t_name"], $typearr["t_enname"], false);
         $blink = $vlink . $str;
         $linktype = replaceStr($blink, "{year}", $mac["year"]);
         $linktype = replaceStr($linktype, "{area}", urlencode($mac["area"]));
         $this->html = replaceStr($this->html, "{typepage:linktype}", $linktype);
         $this->vodpagelist();
     }
     $this->pageshow();
     $this->ifEx();
     if ($viewtype != 2) {
         setCacheFile($flag . "list", "list" . $this->page_id . $mac["page"] . urlencode($mac["area"]) . $mac["year"] . $mac["order"] . $mac["by"], $this->html);
     }
     $this->run();
 }
function makeTopicById($topicid)
{
    global $flag, $db, $mac, $mac, $cache, $template;
    if ($flag == "art") {
        $mac["arttopicid"] = $topicid;
        $typearr = getValueByArray($cache[3], "t_id", $topicid);
        $sql = "select  a_id from {pre}art where a_topic = " . $topicid . "";
    } else {
        $mac["vodtopicid"] = $topicid;
        $typearr = getValueByArray($cache[2], "t_id", $topicid);
        $sql = "select  d_id from {pre}vod where d_topic = " . $topicid . "";
    }
    $psize = $template->getPageListSizeByCache($flag . "page");
    if (isN($psize)) {
        $psize = 10;
    }
    $nums = $db->getOne($sql);
    $pcount = ceil($nums / $psize);
    if ($nums == 0) {
        echo "<font color='red'>ID为 " . $topicid . " 的专题没有数据</font><br>";
        $pcount = 1;
    }
    echo "正在开始生成专题<font color='red'>" . $typearr["t_name"] . "</font>的列表<br>";
    for ($i = 1; $i <= $pcount; $i++) {
        $mac["page"] = $i;
        $template->loadtopic($flag, $typearr);
        $topicLink = $template->getPageLink($i);
        if (app_installdir != "/") {
            $topicLink = replaceStr($topicLink, app_installdir, "../");
        } else {
            $topicLink = ".." . $topicLink;
        }
        $path = dirname($topicLink);
        if (!file_exists($path)) {
            mkdir($path);
        }
        fwrite(fopen($topicLink, "wb"), $template->html);
        echo $typearr["t_name"] . " 生成完毕 <a target='_blank' href='" . $topicLink . "'>" . $topicLink . "&nbsp;&nbsp;<font color=red>浏览</font></a><br>";
    }
}
function cjView($strlink, $num)
{
    global $maxarticleid, $maxPostid, $maxThreadid, $maxUser, $users, $p_hitsend, $db, $strListUrl, $p_titletype, $starringarr, $titlearr, $p_id, $p_titlestart, $p_titleend, $p_hitsstart, $p_hitsend, $p_authortype, $p_authorstart, $p_authorend, $p_typestart, $p_typeend, $p_classtype, $p_collect_type, $p_timestart, $p_timeend, $p_contentstart, $p_contentend, $p_cpagecodestart, $p_cpagecodeend, $p_cpagetype, $p_cpagestart, $p_cpageend, $p_coding, $p_script, $p_showtype, $sb, $cg, $cache;
    $strlink = definiteUrl($strlink, $strListUrl);
    $strViewCode = getPage($strlink, $p_coding);
    if ($strViewCode == False) {
        echo "<tr><td vAlign=center class=\"tdxingmu\" colspan=\"2\">在获取内容页时出错:" . $strlink . " </td></tr>";
        $sb = $sb + 1;
        return;
    } else {
        if ($p_titletype == 1) {
            $titlecode = $titlearr[$num];
        } else {
            $titlecode = getBody($strViewCode, $p_titlestart, $p_titleend);
        }
        $titlecode = filterScript($titlecode, $p_script);
        $titlecode = replaceFilters($titlecode, $p_id, 1, 0);
        //		$sql="select count(*) from {pre}cj_art where m_title='".$titlecode."'";
        //		$rowcount=$db->getOne($sql);
        //		if (intval($rowcount>0)){
        //			echo "<tr><td vAlign=center class=\"tdxingmu\" colspan=\"2\">遇到重复文章数据跳过采集!</td></tr>";
        //			return;
        //		}
        if (isN($p_hitsstart) || !isnum($p_hitsstart)) {
            $p_hitsstart = 0;
        }
        if (isN($p_hitsend) || !isnum($p_hitsend)) {
            $p_hitsend = 0;
        }
        if ($p_hitsstart == 0 && $p_hitsend == 0) {
            $m_hits = 0;
        } else {
            $m_hits = rand($p_hitsend, $p_hitsstart);
        }
        if ($p_authortype == 1) {
            $starringcode = $starringarr[$num];
        } else {
            $starringcode = getBody($strViewCode, $p_authorstart, $p_authorend);
        }
        $starringcode = replaceStr($starringcode, "false", "未知");
        $starringcode = filterScript($starringcode, $p_script);
        if ($p_classtype == 1) {
            $typecode = filterScript(getBody($strViewCode, $p_typestart, $p_typeend), $p_script);
            $typecode = trim($typecode);
            $m_typeid = changeId($typecode, $p_id, 1);
        } else {
            $typecode = $p_collect_type;
            $typecode = trim($typecode);
            $m_typeid = $p_collect_type;
            $typearr = getValueByArray($cache[1], "t_id", $typecode);
            $typecode = $typearr["t_name"];
        }
        $typecode = filterScript($typecode, $p_script);
        $timecode = getBody($strViewCode, $p_timestart, $p_timeend);
        $timecode = replaceStr($timecode, "false", date('Y-m-d', time()));
        $timecode = filterScript($timecode, $p_script);
        $contentcode = getBody($strViewCode, $p_contentstart, $p_contentend);
        $cpagecode = getBody($strViewCode, $p_cpagecodestart, $p_cpagecodeend);
        $contentcode = replaceStr($contentcode, $cpagecode, "");
        if ($p_cpagetype == 1) {
            $cpagelinkarrcode = getArray($cpagecode, $p_cpagestart, $p_cpageend);
            $cpagelinkarr = explode("{Array}", $cpagelinkarrcode);
            for ($i = 0; $i < count($cpagelinkarr); $i++) {
                $cpagelink = $cpagelinkarr[$i];
                if ($cpagelink != "" && $cpagelink != "#") {
                    $cpagelink = definiteUrl($cpagelink, $strListUrl);
                    $cpagelinkcode = getPage($cpagelink, $p_coding);
                    if ($cpagelinkcode != "false") {
                        $cpagecode = getBody($cpagelinkcode, $p_cpagecodestart, $p_cpagecodeend);
                        $cpagelinkcode = getBody($cpagelinkcode, $p_contentstart, $p_contentend);
                        $cpagelinkcode = replaceStr($cpagelinkcode, $cpagecode, "");
                        $contentcode = $contentcode . $cpagelinkcode;
                    }
                }
            }
        }
        $contentcode = replaceFilters($contentcode, $p_id, 2, 0);
        $contentcode = replaceStr($contentcode, "'", "\"");
        //var_dump($contentcode);
        echo "<tr><td colspan=\"2\" align=\"center\">此列表中第" . ($num + 1) . "条数据采集结果</td></tr><tr><td vAlign=center width=\"20%\">来源地址:</td><td class=\"tdback\">" . $strlink . "</td></tr><td>文章标题:</td><td>" . $titlecode . "</td></tr><td>文章作者:</td><td>" . $starringcode . "</td></tr><td>发布时间:</td><td>" . $timecode . "</td></tr><td>分类:</td><td>" . $typecode . "</td></tr> <td>内容:</td><td>" . strlen($contentcode) . "</td></tr>";
        //		$sql="select m_id,m_title,m_type,m_author,m_content,m_addtime,m_urltest,m_zt,m_pid,m_typeid,m_hits from {pre}cj_art where m_urltest='".$strlink."' order by m_id desc";
        //		$rowart=$db->getRow($sql);
        //	    if ($rowart) {
        //			$cg=$cg+1;
        //			$movieid=$rowart["m_id"];
        //			$sql = "update {pre}cj_art set m_type='".$typecode."',m_urltest='".$strlink."',m_title='".$titlecode."',m_author='".$starringcode."',m_content='".$contentcode."',m_addtime='".date('Y-m-d H:i:s',time())."',m_zt='0',m_pid='".$p_id."',m_typeid='".$m_typeid."' where m_id=".$rowart["m_id"];
        //
        //			$db->query($sql);
        //		}
        //		else{
        //			$cg=$cg+1;
        //			$sql="insert {pre}cj_art (m_title,m_type,m_author,m_content,m_urltest,m_zt,m_pid,m_typeid,m_hits,m_addtime) values('".$titlecode."','".$typecode."','".$starringcode."','".$contentcode."','".$strlink."','0','".$p_id."','".$m_typeid."','".$m_hits."','".date('Y-m-d H:i:s',time())."')";
        //			//writetofile("s.txt", $sql);
        // 			$status = $db->query($sql);
        //			$movieid=$db->insert_id();
        //		}
        //$maxaid,$catid,$name,$contents,$summary,$uid,$username
        //	function actionAddArticals($aid,$catid,$name,$content,$summary,$uid,$username){
        ///$name,$content,$maxThreadid,$bbsformid,$maxPostid,$uid,$username
        //	function createThread($name,$content,$tid,$fid,$pid,$uid,$username){
        $userIndex = rand(0, $maxUser);
        $username = $users[$userIndex]['username'];
        $uid = $users[$userIndex]['uid'];
        if (isset($contentcode) && !is_null($contentcode) && strlen(trim($contentcode)) > 0) {
            if ($p_collect_type === '7') {
                $maxPostid++;
                $maxThreadid++;
                createThread($titlecode, $contentcode, $maxThreadid, $p_hitsend, $maxPostid, $uid, $username);
                writetofile("collectForm" . $p_hitsend . ".succ.txt", $titlecode);
            } else {
                if ($p_collect_type === '8') {
                    try {
                        if (strlen($contentcode) > 400) {
                            $summary = substr($contentcode, 0, 400);
                        } else {
                            $summary = $contentcode;
                        }
                        $summary = filterScript($summary, 8191);
                    } catch (Exception $e) {
                        $summary = '';
                    }
                    $maxarticleid++;
                    actionAddArticals($maxarticleid, $p_hitsend, $titlecode, $contentcode, $summary, $uid, $username);
                    writetofile("collectArt" . $p_hitsend . ".succ.txt", $titlecode);
                }
            }
        } else {
            writetofile("collectArt" . $p_hitsend . ".txt", $strlink);
        }
    }
}
function main()
{
    global $db, $template, $cache;
    $keyword = be("all", "keyword");
    $stype = be("all", "stype");
    $order = be("all", "order");
    $topic = be("all", "topic");
    $pagenum = be("all", "page");
    $hide = be("all", "hide");
    $repeat = be("all", "repeat");
    $repeatlen = be("all", "repeatlen");
    if (!isNum($stype)) {
        $stype = 0;
    } else {
        $stype = intval($stype);
    }
    if (!isNum($topic)) {
        $topic = 0;
    } else {
        $topic = intval($topic);
    }
    if (!isNum($repeatlen)) {
        $repeatlen = 0;
    }
    if (!isNum($hide)) {
        $hide = -1;
    } else {
        $hide = intval($hide);
    }
    if (!isNum($pagenum)) {
        $pagenum = 1;
    } else {
        $pagenum = intval($pagenum);
    }
    if ($pagenum < 1) {
        $pagenum = 1;
    }
    $where = " 1=1 ";
    if (!isN($keyword)) {
        $where = $where . " AND a_title LIKE '%" . $keyword . "%' ";
    }
    if ($stype > 0) {
        $typearr = getValueByArray($cache[1], "t_id", $stype);
        if (is_array($typearr)) {
            $where = $where . " and a_type in (" . $typearr["childids"] . ")";
        } else {
            $where .= " AND a_type=" . $stype . " ";
        }
    }
    if ($stype == -1) {
        $where = $where . " AND a_type =0 ";
    }
    if ($topic > 0) {
        $where = $where . " AND a_topic = " . $topic . " ";
    }
    if ($hide > -1) {
        $where .= " AND a_hide=" . $hide . " ";
    }
    if ($repeat == "ok") {
        $repeatSearch = " a_title ";
        if ($repeatlen > 0) {
            $repeatSearch = " substring(a_title,1," . $repeatlen . ") as `a_title1` ";
        }
        $where .= " AND a_title IN (SELECT " . $repeatSearch . " FROM {pre}vod GROUP BY " . $repeatSearch . " HAVING COUNT(*)>1) ";
    }
    if (isN($order)) {
        $order = "a_addtime";
    }
    $sql = "SELECT count(*) FROM {pre}art where " . $where;
    $nums = $db->getOne($sql);
    $pagecount = ceil($nums / app_pagenum);
    $sql = "SELECT a_id, a_title,a_subtitle, a_entitle, a_type,a_topic, a_content, a_author, a_color, a_time, a_hits,a_hide FROM {pre}art WHERE " . $where . " ORDER BY " . $order . " DESC limit " . app_pagenum * ($pagenum - 1) . "," . app_pagenum;
    $rs = $db->query($sql);
    ?>
<script language="javascript">
$(document).ready(function(){
	$("#btnrepeat").click(function(){
		var repeatlen = $("#repeatlen").val();
		var reg = /^\d+$/;
		var re = repeatlen.match(reg);
		if (!re){ alert("请输入数字");$("#repeatlen").focus();return;}
		if (repeatlen >10){ alert("长度最大10");$("#repeatlen").focus();return;}
		var url = "admin_art.php?repeat=ok&repeatlen=" + repeatlen;
		window.location.href=url;
	});
	$("#btnDel").click(function(){
			if(confirm('确定要删除吗')){
				$("#form1").attr("action","admin_ajax.php?action=del&tab={pre}art");
				$("#form1").submit();
			}
			else{return false}
	});
	$("#plsc").click(function(){
		var ids="",rc=false;
		$("input[name='a_id[]']").each(function() {
			if(this.checked){
				if(rc)ids+=",";
				ids =  ids + this.value;
				rc=true;
			}
        });
		$("#form1").attr("action","admin_makehtml.php?action=viewpl&flag=art&d_id="+ids);
		$("#form1").submit();
	});
});

function filter(){
	var stype=$("#stype").val();
	var order=$("#order").val();
	var keyword=$("#keyword").val();
	var topic=$("#topic").val();
	var hide=$("#hide").val();
	var url = "admin_art.php?keyword="+encodeURI(keyword)+"&stype="+stype+"&topic="+topic+"&order="+order+"&hide="+hide;
	window.location.href=url;
}
function gosyncpic(){
	if(confirm('确定要同步下载远程图片吗?数据不可恢复,请做好备份')){
		location.href = 'admin_pic.php?action=syncartpic';
	}
}
</script>
<table class="tb">
    <tr>
	<td>
	<table width="96%" border="0" align="center" cellpadding="3" cellspacing="1">
	<tr>
	<td colspan="2" >
	过滤条件:<select id="stype" name="stype">
	<option value="0">文章栏目</option>
	<option value="-1" <?php 
    if ($stype == -1) {
        echo "selected";
    }
    ?>
>没有栏目</option>
	<?php 
    echo makeSelectAll("{pre}art_type", "t_id", "t_name", "t_pid", "t_sort", 0, "", "&nbsp;|&nbsp;&nbsp;", $stype);
    ?>
	</select>
	&nbsp;
	<select id="topic" name="topic">
	<option value="0">文章专题</option>
	<?php 
    echo makeSelect("{pre}art_topic", "t_id", "t_name", "t_sort", "", "&nbsp;|&nbsp;&nbsp;", $topic);
    ?>
	</select>
	&nbsp;
	<select id="order" name="order">
	<option value="a_time">文章排序</option>
	<option value="a_id" <?php 
    if ($order == "a_id") {
        echo "selected";
    }
    ?>
 >文章编号</option>
	<option value="a_title" <?php 
    if ($order == "a_title") {
        echo "selected";
    }
    ?>
 >文章名称</option>
	<option value="a_hits" <?php 
    if ($order == "a_hits") {
        echo "selected";
    }
    ?>
>文章人气</option>
	</select>
	&nbsp;
	<select id="hide" name="hide">
	<option value="-1">文章显隐</option>
	<option value="0" <?php 
    if ($hide == 1) {
        echo "selected";
    }
    ?>
>显示</option>
	<option value="1" <?php 
    if ($hide == 2) {
        echo "selected";
    }
    ?>
>隐藏</option>
	</select>
	</td>
	</tr>
	<tr>
	<td>
	&nbsp;关键字:<input id="keyword" size="40" name="keyword" value="<?php 
    echo $keyword;
    ?>
">
	<input class="input" type="button" value="搜索" id="btnsearch" onClick="filter();">
	&nbsp; 检测名称长度:<input id="repeatlen" size="2" name="repeatlen" >
	&nbsp;<input class="input" type="button" value="检测重复数据" id="btnrepeat" name="btnrepeat" >
	</td>
	<td width="150px">
	&nbsp;<span>【<a href="###" onclick="javascript:gosyncpic();"><font color="red"><strong>同步下载远程图片</strong></font></a>】</span>
	</td>
	</tr>
	</table>
	</td>
	</tr>
</table>
<form action="" method="post" id="form1" name="form1">
<table class="tb">
	<tr>
	<td width="4%">&nbsp;</td>
	<td>标题</td>
	<td width="9%">分类</td>
	<td width="6%">人气</td>
	<td width="5%">专题</td>
	<td width="5%">浏览</td>
	<td width="15%">时间</td>
	<td width="15%">操作</td>
    </tr>
	<?php 
    if ($nums == 0) {
        ?>
    <tr><td align="center" colspan="7">没有任何记录!</td></tr>
    <?php 
    } else {
        while ($row = $db->fetch_array($rs)) {
            $a_id = $row["a_id"];
            $tname = "未知";
            $tenname = "";
            $typearr = getValueByArray($cache[1], "t_id", $row["a_type"]);
            if (is_array($typearr)) {
                $tname = $typearr["t_name"];
                $tenname = $typearr["t_enname"];
            }
            ?>
    <tr>
	<td><input name="a_id[]" type="checkbox" value="<?php 
            echo $row["a_id"];
            ?>
" /></td>
	<td><?php 
            echo $row["a_title"];
            ?>
		<?php 
            if ($row["a_hide"] == 1) {
                echo "<font color=\"red\">[隐藏]</font>";
            }
            ?>
	</td>
	<td><?php 
            echo $tname;
            ?>
</td>
	<td><?php 
            echo $row["a_hits"];
            ?>
</td>
	<td id="zt<?php 
            echo $row["a_id"];
            ?>
" >
	<?php 
            if ($row["a_topic"] == 0) {
                ?>
	<?php 
                echo "<img src=\"../images/icons/icon_02.gif\" border=\"0\" style=\"cursor: pointer;\" onClick=\"setday('zt','" . $row["a_id"] . "','art')\"/>";
                ?>
	<?php 
            } else {
                ?>
	<?php 
                echo "<img src=\"../images/icons/icon_01.gif\" border=\"0\" style=\"cursor: pointer;\" onClick=\"ajaxdivdel('" . $row["a_id"] . "','zt','art')\"/>";
                ?>
	<?php 
            }
            ?>
	</td>
	<td>
	<?php 
            if ($row["a_type"] == 0) {
                $mlink = "#";
            } else {
                $mlink = "../" . $template->getArtLink($row["a_id"], $row["a_title"], $row["a_entitle"], $row["a_type"], $tname, $tenname, true);
            }
            $mlink = replaceStr($mlink, "../" . app_installdir, "../");
            if (substring($mlink, 1, strlen($mlink) - 1) == "/") {
                $mlink = $mlink . "index." . app_artsuffix;
            }
            if (app_artcontentviewtype == 2) {
                if (file_exists($mlink)) {
                    ?>
		 	<a target="_blank" href="<?php 
                    echo $mlink;
                    ?>
"><Img src="../images/icons/html_ok.gif" border="0" alt='浏览' /></a>
		 	<?php 
                } else {
                    ?>
		 	<a  href="admin_makehtml.php?action=viewpl&flag=art&d_id=<?php 
                    echo $row["a_id"];
                    ?>
"><Img src="../images/icons/html_no.gif" border="0" alt='生成' /></a>
		 	<?php 
                }
            } else {
                ?>
	 <a target="_blank" href="<?php 
                echo $mlink;
                ?>
"><Img src="../images/icons/html_ok.gif" border="0" alt='浏览' /></a>
	 <?php 
            }
            ?>
	</td>
	<td><?php 
            echo isToDay($row["a_time"]);
            ?>
</td>
	<td><A href="admin_art.php?action=edit&a_id=<?php 
            echo $row["a_id"];
            ?>
">修改</a> | <a href="admin_ajax.php?action=del&tab={pre}art&a_id=<?php 
            echo $row["a_id"];
            ?>
" onClick="return confirm('确定要删除吗?');">删除</a></td>
    </tr>
	<?php 
        }
    }
    ?>
	<tr>
	<td colspan="8">
    全选<input name="chkall" type="checkbox" id="chkall" value="1" onClick="checkAll(this.checked,'a_id[]');"/>&nbsp;
	批量操作:<input type="button" id="btnDel" value="删除" class="input" />
	<input type="button" id="plfl" value="分类" onClick="plset('plfl','art')" class="input">
	<input type="button" id="plrq" value="人气" onClick="plset('plrq','art')" class="input">
	<input type="button" id="plzt" value="专题" onClick="plset('plzt','art')" class="input">
	<input type="button" id="plsc" value="生成" class="input">
	<input type="button" id="plyc" value="显隐" onClick="plset('plyc','art')" class="input">
	<span id="plmsg" name="plmsg"></span>
	</td></tr>
	<tr>
	<td align="center" colspan="8">
	<?php 
    echo pagelist_manage($pagecount, $pagenum, $nums, app_pagenum, "admin_art.php?page={p}&keyword=" . urlencode($keyword) . "&order=" . $order . "&stype=" . $stype . "&state=" . $state . "&repeat=" . $repeat . "&repeatlen=" . $repeatlen . "&hide=" . $hide);
    ?>
	</td>
    </tr>
</table>
</form>
<?php 
    unset($rs);
}
function main()
{
    global $db, $template, $cache;
    $loginname = getCookie("adminname");
    $keyword = be("all", "keyword");
    $stype = be("all", "stype");
    $area = be("all", "area");
    $topic = be("all", "topic");
    $level = be("all", "level");
    $from = be("all", "from");
    $sstate = be("all", "sstate");
    $repeat = be("all", "repeat");
    $repeatlen = be("all", "repeatlen");
    $order = be("all", "order");
    $pagenum = be("all", "page");
    $sort = be("all", "sort");
    $spic = be("all", "spic");
    $hide = be("all", "hide");
    $d_status = be("all", "d_status");
    $douban_score = be("all", "douban_score");
    $ipadpic = be("all", "ipadpic");
    $d_douban_id = be("all", "d_douban_id");
    $can_search_device = be("all", "can_search_device");
    if (!isNum($level)) {
        $level = 0;
    } else {
        $level = intval($level);
    }
    if (!isNum($sstate)) {
        $sstate = 0;
    } else {
        $sstate = intval($sstate);
    }
    if (!isNum($stype)) {
        $stype = 0;
    } else {
        $stype = intval($stype);
    }
    if (!isNum($area)) {
        $area = 0;
    } else {
        $area = intval($area);
    }
    if (!isNum($topic)) {
        $topic = 0;
    } else {
        $topic = intval($topic);
    }
    if (!isNum($spic)) {
        $spic = 0;
    } else {
        $spic = intval($spic);
    }
    if (!isNum($ipadpic)) {
        $ipadpic = 0;
    } else {
        $ipadpic = intval($ipadpic);
    }
    if (!isNum($hide)) {
        $hide = -1;
    } else {
        $hide = intval($hide);
    }
    if (!isNum($douban_score)) {
        $douban_score = 0;
    } else {
        $douban_score = intval($douban_score);
    }
    if (!isNum($repeatlen)) {
        $repeatlen = 0;
    }
    if (!isNum($d_status)) {
        $d_status = -1;
    } else {
        $d_status = intval($d_status);
    }
    if (isNum($d_douban_id)) {
        $d_douban_id = intval($d_douban_id);
    }
    if (!isNum($pagenum)) {
        $pagenum = 1;
    } else {
        $pagenum = intval($pagenum);
    }
    if ($pagenum < 1) {
        $pagenum = 1;
    }
    $where = " d_type in (1,2,3,131,5) ";
    $keyword_col = be("all", "keyword_col");
    if (!isN($keyword)) {
        $keyword = trim($keyword);
        if (isN($keyword_col)) {
            $where .= " AND ( d_directed like '%" . $keyword . "%' or d_starring like '%" . $keyword . "%' or d_name like '%" . $keyword . "%' or d_enname like '%" . $keyword . "%'   ) ";
        } else {
            $where .= " AND " . $keyword_col . " like '%" . $keyword . "%' ";
        }
    }
    if ($stype > 0) {
        $typearr = getValueByArray($cache[0], "t_id", $stype);
        if (is_array($typearr)) {
            $where = $where . " and d_type in (" . $typearr["childids"] . ")";
        } else {
            $where .= " AND d_type=" . $stype . " ";
        }
    }
    if ($stype == -1) {
        $where .= " AND d_type=0 ";
    }
    if ($area > 0) {
        $where .= " AND d_area = " . $area . " ";
    }
    if ($topic > 0) {
        $where .= " AND d_topic = " . $topic . " ";
    }
    if ($level > 0) {
        $where .= " AND d_level = " . $level . " ";
    }
    if ($sstate == 1) {
        $where .= " AND d_state>0 ";
    } else {
        if ($sstate == 2) {
            $where .= " AND d_state=0 ";
        }
    }
    if ($hide != -1) {
        $where .= " AND d_hide=" . $hide . " ";
    }
    if ($d_douban_id == -1) {
        $where .= " AND d_douban_id=" . $d_douban_id . " ";
    } else {
        if ($d_douban_id == 1) {
            $where .= " AND d_douban_id >0 ";
        } else {
            if ($d_douban_id == 2) {
                $where .= " AND d_douban_id =0 ";
            }
        }
    }
    if ($d_status != -1) {
        $where .= " AND d_status=" . $d_status . " ";
    }
    if ($douban_score == 1) {
        $where .= " AND d_score >0 ";
    }
    if ($douban_score == 2) {
        $where .= " AND d_score <=0 ";
    }
    if ($stype == 1 || $stype == 2) {
        $douban_scoreT = "block";
    } else {
        $douban_scoreT = "none";
    }
    if (!isN($can_search_device)) {
        $where .= " AND (can_search_device like '%" . $can_search_device . "%' or can_search_device is null or can_search_device ='' ) ";
    }
    if ($repeat == "ok") {
        $repeatSearch = " d_name ";
        if ($repeatlen > 0) {
            $repeatSearch = " substring(d_name,1," . $repeatlen . ") ";
        }
        $repeatsql = " , (SELECT " . $repeatSearch . " as d_name1 FROM {pre}vod GROUP BY d_name1 HAVING COUNT(*)>1) as `t2` ";
        $where .= " AND `{pre}vod`.`d_name`=`t2`.`d_name1` ";
        if (isN($order)) {
            $order = "d_name,d_addtime";
        }
    }
    $douban_comment = be("all", "douban_comment");
    if (!isNum($douban_comment)) {
        $douban_comment = 0;
    } else {
        $douban_comment = intval($douban_comment);
    }
    if ($douban_comment == 1) {
        $where .= " and d_id in (SELECT DISTINCT content_id FROM tbl_comments WHERE author_id IS NULL AND thread_id IS NULL) ";
    }
    if ($douban_comment == 2) {
        $where .= " and d_id not in (SELECT DISTINCT content_id FROM tbl_comments WHERE author_id IS NULL AND thread_id IS NULL) ";
    }
    if (isN($order)) {
        $orders = "d_time desc ";
    } else {
        if (!isN($sort)) {
            $orders = $order . ' ' . $sort;
        }
    }
    if (!isN($from)) {
        $where .= " and d_playfrom like  '%" . $from . "%' ";
    }
    if ($spic == 1) {
        $where .= " AND d_pic = '' ";
    } else {
        if ($spic == 2) {
            $where .= " and  d_pic not like '%joyplus%' and d_pic!=''  ";
        }
    }
    if ($ipadpic == 1) {
        $where .= " AND (d_pic_ipad = ''  or d_pic_ipad is null )";
    } else {
        if ($ipadpic == 2) {
            $where .= " AND d_pic_ipad not like '%joyplus%' and d_pic_ipad != '' ";
        }
    }
    $select_weburl = be("all", "select_weburl");
    $select_videourl = be("all", "select_videourl");
    $select_videourl_play = be("all", "select_videourl_play");
    if (!isNum($select_videourl_play)) {
        $select_videourl_play = -1;
    } else {
        $select_videourl_play = intval($select_videourl_play);
    }
    if ($select_videourl_play == 0) {
        $where .= " AND d_play_check = 0 ";
    }
    if ($select_videourl_play == 2) {
        $where .= " AND d_play_check = 2 ";
    }
    if ($select_videourl_play == 1) {
        $where .= " AND d_play_check = 1 ";
    }
    if ($select_weburl == 1) {
        $where .= " AND webUrls is not null and webUrls !='' ";
    }
    if ($select_weburl == 2) {
        $where .= " AND (webUrls is null or  webUrls ='') ";
    }
    if ($select_videourl == 1) {
        $where .= " AND d_downurl is not null and d_downurl !='' ";
    }
    if ($select_videourl == 2) {
        $where .= " AND (d_downurl is null or d_downurl ='') ";
    }
    $sql = "SELECT count(*) FROM {pre}vod " . $repeatsql . " where " . $where;
    $nums = $db->getOne($sql);
    $pagecount = ceil($nums / app_pagenum);
    //$sql = "SELECT d_year,d_id, d_name, d_enname, d_play_num,d_type,d_state,d_topic, d_level, d_hits, d_time,d_remarks,d_playfrom,d_hide,p.id as popular_id FROM {pre}vod ".$repeatsql." left join {pre}vod_popular as p on p.vod_id=d_id  WHERE" . $where . " ORDER BY " . $orders . "  limit ".(app_pagenum * ($pagenum-1)) .",".app_pagenum;
    $sql = "SELECT d_year,d_id, d_name, d_enname, d_play_num,d_type,d_state,d_topic, d_level, d_hits, d_time,d_remarks,d_playfrom,d_hide FROM {pre}vod " . $repeatsql . "  WHERE" . $where . " ORDER BY " . $orders . "  limit " . app_pagenum * ($pagenum - 1) . "," . app_pagenum;
    //	var_dump($sql);
    $rs = $db->query($sql);
    ?>


<script
	type="text/javascript" src="./resource/thickbox-compressed.js"></script>
<script
	type="text/javascript" src="./resource/thickbox.js"></script>
<link
	href="./resource/thickbox.css" rel="stylesheet" type="text/css" />
<script language="javascript">
$(document).ready(function(){
	$("#form1").validate({
		rules:{
			repeatlen:{
				number:true,
				max:10
			}
		}
	});
	
	$("#btnrepeat").click(function(){
		var repeatlen = $("#repeatlen").val();
		var reg = /^\d+$/;
		var re = repeatlen.match(reg);
		if (!re){ repeatlen=0; }
		if (repeatlen >20){ alert("长度最大20");$("#repeatlen").focus();return;}
		var url = "admin_vod.php?repeat=ok&repeatlen=" + repeatlen;
		window.location.href=url;
	});
	$("#btnDel").click(function(){
			if(confirm('确定要删除吗')){
				$("#form1").attr("action","admin_vod.php?action=del");
				$("#form1").submit();
			}
			else{return false}
	});
	
});
function filter(){
	var stype=$("#stype").val();
	var state=$("#state").val();
	var order=$("#order").val();
	var level=$("#level").val();
	var topic=$("#topic").val();
	var sserver=$("#sserver").val();
	var from=$("#from").val();
	var spic=$("#spic").val();
	var hide=$("#hide").val();
	var ipadpic=$("#ipadpic").val();
	var sort=$("#sort").val();
	
	
	var select_weburl=$("#select_weburl").val();
	var select_videourl=$("#select_videourl").val();
	var douban_score =$("#douban_score").val();
	var douban_comment =$("#douban_comment").val();
	var select_videourl_play=$("#select_videourl_play").val();
	var keyword=$("#keyword").val();	
	var d_status=$("#d_status").val();	
	var d_douban_id=$("#d_douban_id").val();
	var keyword_col=$("#keyword_col").val();
	var can_search_device=$("#can_search_device").val();
	var url = "admin_vod.php?can_search_device="+can_search_device+"&d_douban_id="+d_douban_id+"&keyword_col="+keyword_col+"&d_status="+d_status+"&sort="+sort+"&select_videourl_play="+select_videourl_play+"&douban_comment="+douban_comment+"&keyword="+encodeURI(keyword)+"&stype="+stype+"&topic="+topic+"&select_weburl="+select_weburl+"&select_videourl="+select_videourl+"&level="+level+"&order="+order+"&sserver="+sserver+"&sstate="+state+"&from="+from+"&spic="+spic+"&hide="+hide+"&douban_score="+douban_score+"&ipadpic="+ipadpic; //ipadpic
	window.location.href=url;
}

function doubans(){
	var stype=$("#stype").val();
	var state=$("#state").val();
	var order=$("#order").val();
	var level=$("#level").val();
	var topic=$("#topic").val();
	var sserver=$("#sserver").val();
	var from=$("#from").val();
	var spic=$("#spic").val();
	var hide=$("#hide").val();
	var sort=$("#sort").val();
	var ipadpic=$("#ipadpic").val();
	var douban_score =$("#douban_score").val();
	var select_weburl=$("#select_weburl").val();
	var select_videourl=$("#select_videourl").val();
	var douban_comment =$("#douban_comment").val();
	var select_videourl_play=$("#select_videourl_play").val();
	var keyword=$("#keyword").val();	
	var d_status=$("#d_status").val();
	var keyword_col=$("#keyword_col").val();	
	var d_douban_id=$("#d_douban_id").val();
	var can_search_device=$("#can_search_device").val();
	var url = "admin_vod.php?can_search_device="+can_search_device+"&d_douban_id="+d_douban_id+"&keyword_col="+keyword_col+"&d_status="+d_status+"&sort="+sort+"&select_videourl_play="+select_videourl_play+"&douban_comment="+douban_comment+"&action=doubans&keyword="+encodeURI(keyword)+"&select_weburl="+select_weburl+"&select_videourl="+select_videourl+"&stype="+stype+"&topic="+topic+"&level="+level+"&order="+order+"&sserver="+sserver+"&sstate="+state+"&from="+from+"&spic="+spic+"&hide="+hide+"&douban_score="+douban_score+"&ipadpic="+ipadpic;
	window.location.href=url;
}

function doubansComment(){
	var stype=$("#stype").val();
	var state=$("#state").val();
	var order=$("#order").val();
	var level=$("#level").val();
	var topic=$("#topic").val();
	var sserver=$("#sserver").val();
	var from=$("#from").val();
	var spic=$("#spic").val();
	var hide=$("#hide").val();
	var sort=$("#sort").val();
	var ipadpic=$("#ipadpic").val();
	var douban_score =$("#douban_score").val();
	var select_weburl=$("#select_weburl").val();
	var select_videourl=$("#select_videourl").val();
	var select_videourl_play=$("#select_videourl_play").val();
	var keyword=$("#keyword").val();
	var douban_comment =$("#douban_comment").val();	
	var d_status=$("#d_status").val();
	var keyword_col=$("#keyword_col").val();	
	var d_douban_id=$("#d_douban_id").val();
	var can_search_device=$("#can_search_device").val();
	var url = "admin_vod.php?can_search_device="+can_search_device+"&d_douban_id="+d_douban_id+"&keyword_col="+keyword_col+"&d_status="+d_status+"&sort="+sort+"&select_videourl_play="+select_videourl_play+"&douban_comment="+douban_comment+"&action=doubansComment&keyword="+encodeURI(keyword)+"&select_weburl="+select_weburl+"&select_videourl="+select_videourl+"&stype="+stype+"&topic="+topic+"&level="+level+"&order="+order+"&sserver="+sserver+"&sstate="+state+"&from="+from+"&spic="+spic+"&hide="+hide+"&douban_score="+douban_score+"&ipadpic="+ipadpic;
	window.location.href=url;
}

function doubanThumbs(){
	var stype=$("#stype").val();
	var state=$("#state").val();
	var order=$("#order").val();
	var level=$("#level").val();
	var topic=$("#topic").val();
	var sserver=$("#sserver").val();
	var from=$("#from").val();
	var spic=$("#spic").val();
	var hide=$("#hide").val();
	var sort=$("#sort").val();
	var ipadpic=$("#ipadpic").val();
	var douban_score =$("#douban_score").val();
	var select_weburl=$("#select_weburl").val();
	var select_videourl=$("#select_videourl").val();
	var select_videourl_play=$("#select_videourl_play").val();
	var keyword=$("#keyword").val();
	var douban_comment =$("#douban_comment").val();	
	var d_status=$("#d_status").val();
	var keyword_col=$("#keyword_col").val();	
	var d_douban_id=$("#d_douban_id").val();
	var can_search_device=$("#can_search_device").val();
	var url = "admin_vod.php?can_search_device="+can_search_device+"&d_douban_id="+d_douban_id+"&keyword_col="+keyword_col+"&d_status="+d_status+"&sort="+sort+"&select_videourl_play="+select_videourl_play+"&douban_comment="+douban_comment+"&action=doubanThumbs&keyword="+encodeURI(keyword)+"&select_weburl="+select_weburl+"&select_videourl="+select_videourl+"&stype="+stype+"&topic="+topic+"&level="+level+"&order="+order+"&sserver="+sserver+"&sstate="+state+"&from="+from+"&spic="+spic+"&hide="+hide+"&douban_score="+douban_score+"&ipadpic="+ipadpic;
	window.location.href=url;
}



function showpic(){
	$.get("admin_vod.php?action=chkpic&rnd=" + Math.random(),function(obj){
		if(Number(obj)>0){
			$.messager.show({
			title:'系统提示',
			msg:'发现数据中调用远程图片<br>下载到本地可以提高网页载入速度<br>',
			timeout:5000,
			showType:'slide'
			});
		}
	});
}
function gosyncpic(){
	if(confirm('确定要同步下载远程图片吗?数据不可恢复,请做好备份')){
		location.href = 'admin_pic.php?action=syncpic';
	}
}

function prepareWeiboText(type,id,name){
	   document.getElementById( "weiboText").value= name; 
	   document.getElementById( "notify_msg_prod_id").value= id; 
	   document.getElementById( "notify_msg_prod_type").value= type; 
	   $('#SendWeiboMsg').empty();
}


function sendWeiboText(){

	var device_types= document.getElementById( "device_type");
	
	var weibotxt= document.getElementById( "weiboText").value;
	var notify_msg_prod_id= document.getElementById( "notify_msg_prod_id").value;
	var notify_msg_prod_type= document.getElementById( "notify_msg_prod_type").value;
	var urlT='admin_vod.php?action=notifyMsg&prod_type='+notify_msg_prod_type+'&prod_id='+notify_msg_prod_id+'&content=' +encodeURIComponent(weibotxt) ;
	
	for(var i = 0; i < device_types.options.length; i++){
		  if(device_types.options[i].selected){
			  urlT = urlT +'&device_type='+device_types.options[i].value;				 		 
		  }
	}
		//alert(urlT);
		 $.post(urlT, {Action:"post"}, function (data, textStatus){     
			  if(textStatus == "success"){   
	          //alert(data);
				  $('#SendWeiboMsg').empty().append(data);
	           }else{
	        	   $('#SendWeiboMsg').empty().append('发送失败。');
	           }
	       });
	
    // alert(urlT);
	 
}

function send(e){
	if(e.keyCode==13){
		  filter();
    }
}
 
</script>
<table class="admin_vod_1 tb">
	<tr>
		<td>
		<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
			<tr>
				<td colspan="2">过滤条件:<br /><select id="stype" name="stype"
					onchange="javascript:{var typeid= this.options[this.selectedIndex].value; if(typeid=='1' ||  typeid=='2' ||  typeid=='131'){document.getElementById('btnsearchs').style.display='block';  document.getElementById('btnsearchsThumbs').style.display='block';document.getElementById('btnsearchsComment').style.display='block';}else {document.getElementById('btnsearchs').style.display='none'; document.getElementById('btnsearchsThumbs').style.display='none';document.getElementById('btnsearchsComment').style.display='none';}}">
					<option value="0">视频栏目</option>
					<option value="-1" <?php 
    if ($stype == -1) {
        echo "selected";
    }
    ?>
>没有栏目</option>
					<?php 
    echo makeSelectAll("{pre}vod_type", "t_id", "t_name", "t_pid", "t_sort", 0, "", "&nbsp;|&nbsp;&nbsp;", $stype);
    ?>
				</select><select id="state" name="state">
					<option value="0">视频连载</option>
					<option value="1" <?php 
    if ($sstate == "1") {
        echo "selected";
    }
    ?>
>连载中</option>
					<option value="2" <?php 
    if ($sstate == "2") {
        echo "selected";
    }
    ?>
>未连载</option>
				</select><select id="order" name="order">
					<option value="d_time">视频排序</option>
					<option value="d_id" <?php 
    if ($order == "d_id") {
        echo "selected";
    }
    ?>
>视频编号</option>
					<option value="d_name"
					<?php 
    if ($order == "d_name") {
        echo "selected";
    }
    ?>
>视频名称</option>
					<option value="d_play_num"
					<?php 
    if ($order == "d_play_num") {
        echo "selected";
    }
    ?>
>播放次数</option>
					<option value="d_year"
					<?php 
    if ($order == "d_year") {
        echo "selected";
    }
    ?>
>上映日期</option>
					<option value="d_level"
					<?php 
    if ($order == "d_level") {
        echo "selected";
    }
    ?>
>推荐度</option>
				</select><select id="sort" name="sort">
					<option value="desc" <?php 
    if ($sort == "desc") {
        echo "selected";
    }
    ?>
>视频排序
					降序序</option>
					<option value="asc" <?php 
    if ($sort == "asc") {
        echo "selected";
    }
    ?>
>视频排序
					升序</option>
				</select><select id="level" name="level">
					<option value="0">视频推荐</option>
					<option value="1" <?php 
    if ($level == 1) {
        echo "selected";
    }
    ?>
>推荐1</option>
					<option value="2" <?php 
    if ($level == 2) {
        echo "selected";
    }
    ?>
>推荐2</option>
					<option value="3" <?php 
    if ($level == 3) {
        echo "selected";
    }
    ?>
>推荐3</option>
					<option value="4" <?php 
    if ($level == 4) {
        echo "selected";
    }
    ?>
>推荐4</option>
					<option value="5" <?php 
    if ($level == 5) {
        echo "selected";
    }
    ?>
>推荐5</option>
					<option value="6" <?php 
    if ($level == 6) {
        echo "selected";
    }
    ?>
>推荐6</option>
					<option value="7" <?php 
    if ($level == 7) {
        echo "selected";
    }
    ?>
>推荐7</option>
					<option value="8" <?php 
    if ($level == 8) {
        echo "selected";
    }
    ?>
>推荐8</option>
				</select><select id="from" name="from">
					<option value="">视频播放器</option>
					<?php 
    echo makeSelectPlayer($from);
    ?>
				</select><select id="spic" name="spic">
					<option value="0">视频图片</option>
					<option value="1" <?php 
    if ($spic == 1) {
        echo "selected";
    }
    ?>
>无图片</option>
					<option value="2" <?php 
    if ($spic == 2) {
        echo "selected";
    }
    ?>
>远程图片</option>
				</select><select id="ipadpic" name="ipadpic">
					<option value="0">视频IPAD图片</option>
					<option value="1" <?php 
    if ($ipadpic == 1) {
        echo "selected";
    }
    ?>
>无图片</option>
					<option value="2" <?php 
    if ($ipadpic == 2) {
        echo "selected";
    }
    ?>
>远程图片</option>
				</select><select id="hide" name="hide">
					<option value="-1">视频显隐</option>
					<option value="0" <?php 
    if ($hide == 0) {
        echo "selected";
    }
    ?>
>显示</option>
					<option value="1" <?php 
    if ($hide == 1) {
        echo "selected";
    }
    ?>
>隐藏</option>
					<option value="-100" <?php 
    if ($hide == -100) {
        echo "selected";
    }
    ?>
>视频不能播放</option>
				</select><select id="douban_score" name="douban_score">
					<option value="0">豆瓣评分</option>
					<option value="1" <?php 
    if ($douban_score == 1) {
        echo "selected";
    }
    ?>
>已采集</option>
					<option value="2" <?php 
    if ($douban_score == 2) {
        echo "selected";
    }
    ?>
>未采集</option>
				</select><select id="douban_comment" name="douban_comment">
					<option value="0">豆瓣评论</option>
					<option value="1"
					<?php 
    if ($douban_comment == 1) {
        echo "selected";
    }
    ?>
>已采集</option>
					<option value="2"
					<?php 
    if ($douban_comment == 2) {
        echo "selected";
    }
    ?>
>未采集</option>
				</select><select id="select_weburl" name="select_weburl">
					<option value="0">网页地址</option>
					<option value="1"
					<?php 
    if ($select_weburl == 1) {
        echo "selected";
    }
    ?>
>存在</option>
					<option value="2"
					<?php 
    if ($select_weburl == 2) {
        echo "selected";
    }
    ?>
>不存在</option>
				</select><select id="select_videourl" name="select_videourl">
					<option value="0">视频地址</option>
					<option value="1"
					<?php 
    if ($select_videourl == 1) {
        echo "selected";
    }
    ?>
>存在</option>
					<option value="2"
					<?php 
    if ($select_videourl == 2) {
        echo "selected";
    }
    ?>
>不存在</option>
				</select><select id="d_status" name="d_status">
					<option value="-1">是否已经审核过</option>
					<option value="0" <?php 
    if ($d_status == 0) {
        echo "selected";
    }
    ?>
>未审核</option>
					<option value="1" <?php 
    if ($d_status == 1) {
        echo "selected";
    }
    ?>
>审核并锁定</option>
				</select><select id="d_douban_id" name="d_douban_id">
					<option value="0">能否在豆瓣上找到</option>
					<option value="-1"
					<?php 
    if ($d_douban_id == -1) {
        echo "selected";
    }
    ?>
>不能</option>
					<option value="1" <?php 
    if ($d_douban_id == 1) {
        echo "selected";
    }
    ?>
>能找到</option>
					<option value="2" <?php 
    if ($d_douban_id == 2) {
        echo "selected";
    }
    ?>
>不确定,未搜索</option>
				</select><select id="can_search_device" name="can_search_device">
					<option value="">投放设备</option>
					<option value="TV"
					<?php 
    if ($can_search_device === 'TV') {
        echo "selected";
    }
    ?>
>TV版</option>
					<option value="iPad"
					<?php 
    if ($can_search_device === 'iPad') {
        echo "selected";
    }
    ?>
>iPad版</option>
					<option value="iphone"
					<?php 
    if ($can_search_device === 'iphone') {
        echo "selected";
    }
    ?>
>iphone版</option>
					<option value="apad"
					<?php 
    if ($can_search_device === 'apad') {
        echo "selected";
    }
    ?>
>Android-Pad版</option>
					<option value="aphone"
					<?php 
    if ($can_search_device === 'aphone') {
        echo "selected";
    }
    ?>
>Android-Phone版</option>
					<option value="web"
					<?php 
    if ($can_search_device === 'web') {
        echo "selected";
    }
    ?>
>网站版</option>
					<option value="Vendor"
					<?php 
    if ($can_search_device === 'Vendor') {
        echo "selected";
    }
    ?>
>Vendor版</option>
				</select></td>
			</tr>
			<tr>
				<td colspan="4">关键字:<input id="keyword" size="40" name="keyword"
					value="<?php 
    echo $keyword;
    ?>
" onkeypress="send(event);">&nbsp; <select
					id="keyword_col" name="keyword_col">
					<option value="">关键字的匹配列</option>
					<option value="d_name"
					<?php 
    if ($keyword_col == "d_name") {
        echo "selected";
    }
    ?>
>视频名称</option>
					<option value="d_starring"
					<?php 
    if ($keyword_col == "d_starring") {
        echo "selected";
    }
    ?>
>演员</option>
					<option value="d_directed"
					<?php 
    if ($keyword_col == "d_directed") {
        echo "selected";
    }
    ?>
>导演</option>
				</select> <input class="input" type="button" value="搜索"
					id="btnsearch" onClick="filter();"></td>
				<td align="left"><input style="display:<?php 
    echo $douban_scoreT;
    ?>
" type="button" value="豆瓣评分" id="btnsearchs" onClick="doubans();">
				</td>
				<td align="left"><input style="display:<?php 
    echo $douban_scoreT;
    ?>
" type="button" value="豆瓣影评" id="btnsearchsComment" onClick="doubansComment();">
				</td>
				<td align="left"><input style="display:<?php 
    echo $douban_scoreT;
    ?>
" type="button" value="豆瓣缩略图 " id="btnsearchsThumbs" onClick="doubanThumbs();">
				</td>

			</tr>
		</table>
		</td>
	</tr>
</table>


<form id="form1" name="form1" method="post">
<table class="admin_vod tb">
	<tr>
		<td width="4%"></td>
		<td width="4%">编号</td>
		<td width="15%">名称</td>
		<td width="4%">播放次数</td>
		<td width="3%">上映日期</td>
		<td width="5%">分类</td>
		<td width="5%">来源</td>
		<!--	<td width="3%">人气</td>-->
		<td width="4%">推荐</td>
		<!--	<td width="5%">专题</td>-->
		<!--	<td width="5%">轮播图</td>-->
		<td width="13%" align="center">视频榜单</td>
		<!--	<td width="5%">浏览</td>-->
		<td width="8%">时间</td>
		<td width="25%">操作</td>
	</tr>
	<?php 
    if ($nums == 0) {
        ?>
	<tr>
		<td align="center" colspan="12">没有任何记录!</td>
	</tr>
	<?php 
    } else {
        while ($row = $db->fetch_array($rs)) {
            $d_id = $row["d_id"];
            $tname = "未知";
            $tenname = "";
            $typearr = getValueByArray($cache[0], "t_id", $row["d_type"]);
            if (is_array($typearr)) {
                $tname = $typearr["t_name"];
                $tenname = $typearr["t_enname"];
            }
            ?>
	<tr>
		<td><input name="d_id[]" type="checkbox" value="<?php 
            echo $d_id;
            ?>
"></td>
		<td><?php 
            echo $d_id;
            ?>
</td>
		<td><?php 
            echo substring($row["d_name"], 20);
            ?>
 <?php 
            if ($row["d_state"] > 0) {
                echo "<font color=\"red\">[" . $row["d_state"] . "]</font>";
            }
            ?>
		<?php 
            if (!isN($row["d_remarks"])) {
                echo "<font color=\"red\">[" . $row["d_remarks"] . "]</font>";
            }
            ?>
		<?php 
            if ($row["d_hide"] == 1) {
                echo "<font color=\"red\">[隐藏]</font>";
            }
            ?>
		</td>
		<td><?php 
            echo $row["d_play_num"];
            ?>
</td>
		<td><?php 
            echo $row["d_year"];
            ?>
</td>
		<td><?php 
            echo $tname;
            ?>
</td>
		<td title="<?php 
            echo replaceStr($row["d_playfrom"], "\$\$\$", ",");
            ?>
"><?php 
            echo substring(replaceStr($row["d_playfrom"], "\$\$\$", ","), 15, 0);
            ?>
</td>
		<!--<td><?php 
            echo $row["d_hits"];
            ?>
</td>
	-->
		<td id="tj<?php 
            echo $d_id;
            ?>
"><?php 
            echo "<img src=\"../images/icons/ico" . $row["d_level"] . ".gif\" border=\"0\" style=\"cursor: pointer;\" onClick=\"setday('tj','" . $d_id . "','vod')\"/>";
            ?>
		</td>
		<!--<td id="zt<?php 
            echo $d_id;
            ?>
" >
	<?php 
            if ($row["d_topic"] == 0) {
                ?>
	<?php 
                echo "<img src=\"../images/icons/icon_02.gif\" border=\"0\" style=\"cursor: pointer;\" onClick=\"setday('zt','" . $d_id . "','vod')\"/>";
                ?>
	<?php 
            } else {
                ?>
	<?php 
                echo "<img src=\"../images/icons/icon_01.gif\" border=\"0\" style=\"cursor: pointer;\" onClick=\"ajaxdivdel('" . $d_id . "','zt','vod')\"/>";
                ?>
	<?php 
            }
            ?>
	</td>
	
	-->
		<!--<td id="popular<?php 
            echo $d_id;
            ?>
" >
	<?php 
            if ($row["popular_id"] > 0) {
                ?>
		<?php 
                echo "<img src=\"../images/icons/icon_01.gif\" border=\"0\" style=\"cursor: pointer;\" />";
                ?>
	
	<?php 
            } else {
                ?>
	<?php 
                echo "<img src=\"../images/icons/icon_02.gif\" border=\"0\" style=\"cursor: pointer;\" onClick=\"ajaxsubmit('" . $d_id . "','lunbo','vod');\"/>";
                ?>
	<?php 
            }
            ?>
	</td>
	
	-->
		<td align="center"><span id="bd<?php 
            echo $d_id;
            ?>
"></span> <a href="#"
			onClick="setdayBD('bd','<?php 
            echo $d_id;
            ?>
','vod','1')" /> 添加悦单</a> |
		<a href="#" onClick="setdayBD('bd','<?php 
            echo $d_id;
            ?>
','vod','2')" />
		添加悦榜</a></td>
		<!--<td>
	<?php 
            if (app_playtype == 0) {
                if ($row["d_type"] == 0) {
                    $mlink = "#";
                } else {
                    $mlink = "../" . $template->getVodLink($d_id, $row["d_name"], $row["d_enname"], $row["d_type"], $tname, $tenname);
                }
                $mlink = replaceStr($mlink, "../" . app_installdir, "../");
                $plink = $mlink;
            } else {
                $mlink = "../" . $template->getVodPlayUrl($d_id, $row["d_name"], $row["d_enname"], $row["d_type"], $tname, $tenname, 1, 1);
                $mlink = replaceStr($mlink, "../" . app_installdir, "../");
                $plink = $mlink;
                $mlink = replaceStr($mlink, "javascript:OpenWindow1('", "");
                $mlink = replaceStr($mlink, "',popenW,popenH);", "");
            }
            if (substring($mlink, 1, strlen($mlink) - 1) == "/") {
                $mlink = $mlink . "index." . app_vodsuffix;
            }
            if (app_vodcontentviewtype == 2) {
                if (file_exists($mlink)) {
                    ?>
		 	<a target="_blank" href="<?php 
                    echo $plink;
                    ?>
"><Img src="../images/icons/html_ok.gif" border="0" alt='浏览' /></a>
		 	<?php 
                } else {
                    ?>
		 	<a  href="admin_makehtml.php?action=viewpl&flag=vod&d_id=<?php 
                    echo $d_id;
                    ?>
"><Img src="../images/icons/html_no.gif" border="0" alt='生成' /></a>
		 	<?php 
                }
            } else {
                ?>
	 	<a target="_blank" href="<?php 
                echo $plink;
                ?>
"><Img src="../images/icons/html_ok.gif" border="0" alt='浏览' /></a>
	 <?php 
            }
            ?>
	 </td>
	-->
		<td><?php 
            echo isToday($row["d_time"]);
            ?>
</td>
		<td><a href="admin_vod_topic.php?action=info&id=<?php 
            echo $d_id;
            ?>
">所在榜单</a>
		|<a href="admin_vod.php?action=edit&id=<?php 
            echo $d_id;
            ?>
">修改</a> | <?php 
            if ($row["d_type"] == 1 || $row["d_type"] == 2 || $row["d_type"] == 131) {
                ?>
<a
			href="admin_vod.php?action=douban&id=<?php 
                echo $d_id;
                ?>
">豆瓣评分</a> | <a
			href="admin_vod.php?action=doubanComment&id=<?php 
                echo $d_id;
                ?>
">豆瓣影评</a>
		| <?php 
            }
            ?>
 <a
			href="admin_vod.php?action=doubanPic&id=<?php 
            echo $d_id;
            ?>
">豆瓣图片</a>
		| <a href="admin_vod.php?action=doubanThumb&id=<?php 
            echo $d_id;
            ?>
">豆瓣缩略图</a>
		|<a href="#"
			onClick="if(confirm('确定要添加到追剧列表吗')){ajaxsubmit('<?php 
            echo $d_id;
            ?>
','subscribe_msg_list','vod');}">添加到追剧列表</a>
			<?php 
            if ($loginname === 'dale' || $loginname === 'admin' || $loginname === 'lulu' || $loginname === 'scottliyq' || $loginname === 'zhouyinlong') {
                ?>
		<!--	|--> <!--	 <a class="thickbox" href="#TB_inline?height=200&width=400&inlineId=myOnPageContent" onclick="javascript:{prepareWeiboText('<?php 
                echo $row["d_type"];
                ?>
','<?php 
                echo $d_id;
                ?>
','<?php 
                echo substring($row["d_name"], 20);
                ?>
');}" > 消息推送</a>	  -->
			<?php 
            }
            ?>
 | <A
			href="admin_vod.php?action=del&d_id=<?php 
            echo $d_id;
            ?>
"
			onClick="return confirm('确定要删除吗?');">删除</a></td>
	</tr>
	<?php 
        }
    }
    ?>
	<tr class="formlast">
		<td colspan="11"><input name="chkall" type="checkbox" id="chkall"
			value="1" onClick="checkAll(this.checked,'d_id[]');" /> 全选 &nbsp;批量操作:&nbsp;<input
			type="button" id="btnDel" value="删除" class="input"> <input
			type="button" id="pltj" value="推荐" onClick="plset('pltj','vod')"
			class="input"> <input type="button" id="plfl" value="分类"
			onClick="plset('plfl','vod')" class="input"> <input type="button"
			id="plluobo" value="轮播图" onClick="plsetLuobo()" class="input"> <input
			type="button" id="plbd" value="视频悦单"
			onClick="plsetBD('plbd','vod','1')" class="input"> <input
			type="button" id="plbd" value="视频悦榜"
			onClick="plsetBD('plbd','vod','2')" class="input"> <input
			type="button" id="plyc" value="显隐" onClick="plset('plyc','vod')"
			class="input"> 
			<input type="button" id="plsh" value="批量审核" onClick="plset('plsh','vod')" class="input"> 
			<span id="plmsg" name="plmsg"></span></td>
	</tr>
	<tr class="formlast">
		<td align="center" colspan="12"><?php 
    echo pagelist_manage($pagecount, $pagenum, $nums, app_pagenum, "admin_vod.php?page={p}&can_search_device=" . $can_search_device . "&d_douban_id=" . $d_douban_id . "&keyword=" . urlencode($keyword) . "&d_status=" . $d_status . "&keyword_col=" . $keyword_col . "&sort=" . $sort . "&select_videourl_play=" . $select_videourl_play . "&topic=" . $topic . "&level=" . $level . "&order=" . $order . "&stype=" . $stype . "&sserver=" . $sserver . "&sstate=" . $sstate . "&repeat=" . $repeat . "&repeatlen=" . $repeatlen . "&from=" . $from . "&spic=" . $spic . "&hide=" . $hide . "&douban_comment=" . $douban_comment . "&douban_score=" . $douban_score . "&select_weburl=" . $select_weburl . "&select_videourl=" . $select_videourl . "&ipadpic=" . $ipadpic);
    ?>
		</td>
	</tr>
</table>

<div id="myOnPageContent" style="display: none">

<table class="table" cellpadding="0" cellspacing="0" width="100%"
	border="0">

	<thead class="tb-tit-bg">
		<tr>
			<td>
			<h3 class="title">发送设备:<select name="device_type" id="device_type">
				<option value="">所有设备</option>
				<option value="ios">IOS</option>
				<option value="android">Android</option>
			</select></h3>
			</td>

		</tr>
		<tr>
			<td><span><font color="blue">消息内容 </font></span></td>

		</tr>
		<input type="hidden" name="notify_msg_prod_id" id="notify_msg_prod_id"
			value="">
		<input type="hidden" name="notify_msg_prod_type"
			id="notify_msg_prod_type" value="">

		<tr>
			<td align="center"><textarea name="wbText" id="weiboText" rows="9"
				cols="60" style="border: 1; border-color: blue;"></textarea></td>
		</tr>
		<tr>
			<td align="right"><a href="#" onclick="javascript:sendWeiboText();">发送</a></td>
		</tr>
		<tr>
			<td align="center"><font color=red><span id="SendWeiboMsg"></span></font></td>

		</tr>

	</thead>
</table>

</div>
</form>
	<?php 
    if ($pagenum == 1 && $where == " 1=1 ") {
        echo "<script>showpic();</script>";
    }
    unset($rs);
}
function main()
{
    global $db, $cache;
    $pagenum = be("get", "page");
    if (isN($pagenum) || !isNum($pagenum)) {
        $pagenum = 1;
    }
    if ($pagenum < 1) {
        $pagenum = 1;
    }
    $pagenum = intval($pagenum);
    $sql = "select * from {pre}cj_art_projects ";
    $rscount = $db->query($sql);
    $nums = $db->num_rows($rscount);
    //总记录数
    $pagecount = ceil($nums / app_pagenum);
    //总页数
    $sql = $sql . "limit " . app_pagenum * ($pagenum - 1) . "," . app_pagenum;
    $rs = $db->query($sql);
    ?>
<table width="96%" border="0" align="center" cellpadding="3" cellspacing="1">
	<tr>
	<td>
		菜单:<a href="collect_art_manage.php?action=add">添加采集规则</a> | <a href="collect_art_change.php">分类转换</a> | <a href="collect_art_filters.php">信息过滤</a> 
	</td>
	</tr>
</table>
<form action="" method="post" name="form1">
<table class=tb >
	<tr>
	<td width="4%">&nbsp;</td>
	<td>项目名称</td>
	<td width="25%">入库分类</td>
	<td width="20%">上次采集</td>
	<td width="25%">操作</td>
	</tr>
	<?php 
    if (!$rs) {
        ?>
    <tr><td align="center" colspan="7" >没有任何记录!</td></tr>
    <?php 
    } else {
        while ($row = $db->fetch_array($rs)) {
            ?>
    <tr>
	  <td><input name="p_id[]" type="checkbox" id="p_id" value="<?php 
            echo $row["p_id"];
            ?>
" /></td>
      <td><a href="?action=edit&p_id=<?php 
            echo $row["p_id"];
            ?>
"><?php 
            echo $row["p_name"];
            ?>
</a></td>
	  <td>
	  <?php 
            if ($row["p_classtype"] == 1) {
                echo "<font color=red>自定义分类</font>";
            } else {
                $typearr = getValueByArray($cache[1], "t_id", $row["p_collect_type"]);
                echo $typearr["t_name"];
            }
            ?>
	  </td>
      <td><?php 
            echo isToDay($row['p_time']);
            ?>
</td>
 	  <td>
 	   <A href="collect_art_cj.php?p_id=<?php 
            echo $row["p_id"];
            ?>
">采集</A>|
 	  <A href="?action=edit&p_id=<?php 
            echo $row["p_id"];
            ?>
">修改</A>|
 	  <A href="?action=copy&p_id=<?php 
            echo $row["p_id"];
            ?>
">复制</A>|
 	  <A href="?action=export&p_id=<?php 
            echo $row["p_id"];
            ?>
">导出</A>|
 	  <A href="?action=del&p_id=<?php 
            echo $row["p_id"];
            ?>
">删除</A>
 	  </td>
    </tr>
	<?php 
        }
    }
    ?>
	<tr>
	<td  colspan="7">
	全选<input name="chkall" type="checkbox" id="chkall" value="1" onClick="checkAll(this.checked,'p_id[]');"/>&nbsp;
	<input type="submit" value="批量删除" onClick="if(confirm('确定要删除吗')){form1.action='?action=delall';}else{return false}"  class="input"/>
	<input type="submit" value="批量采集" onClick="if(confirm('确定要批量采集吗')){form1.action='collect_art_cj.php?action=pl';}else{return false}"  class="input"/>
	<input type="button" value="导入规则" onClick="$('#win1').window('open');" class="input"/>
	</td>
	</tr>
    <tr align="center" bgcolor="#f8fbfb">
	<td colspan="7">
	<?php 
    echo pagelist_manage($pagecount, $pagenum, $nums, app_pagenum, "collect_art_manage.php?page={p}");
    ?>
	</td>
	</tr>
</table>
</form>
<div id="win1" class="easyui-window" title="窗口" style="padding:5px;width:400px;" closed="true" closable="true" minimizable="false" maximizable="false">
<form enctype="multipart/form-data" action="?action=upexpsave" method="post">
<table class="tb">
  <tbody>
  	<tr>
  		<td colspan="2" align="center">
  		上传采集规则
         <input type="file" id="file1" name="file1">
		<input type="submit" name="submit" value="开始导入">
		</td>
  	</tr>
</table>
</form>
</div>
<?php 
}
function main()
{
    global $db, $cache;
    $pagenum = be("page", "get");
    if (isN($pagenum) || !isNum($pagenum)) {
        $pagenum = 1;
    }
    if ($pagenum < 1) {
        $pagenum = 1;
    }
    $pagenum = intval($pagenum);
    $keyword = be("get", "keyword");
    $project = be("get", "{pre}cj_art_projects");
    $zt = be("get", "zt");
    $sql = "Select a.*,b.p_name as p_name from {pre}cj_art a,{pre}cj_art_projects b where a.m_pid=b.p_id";
    if ($zt != "") {
        $sql = $sql . " and m_zt = " . $zt;
    }
    if ($keyword != "") {
        $sql = $sql . " and m_title like '%" . $keyword . "%' ";
    }
    if ($project != "") {
        $sql = $sql . " and a.m_pid = " . $project;
    }
    $sql = $sql . " order by m_zt asc,m_addtime desc ";
    $rscount = $db->query($sql);
    $nums = $db->num_rows($rscount);
    //总记录数
    $pagecount = ceil($nums / app_pagenum);
    //总页数
    $sql = $sql . " limit " . app_pagenum * ($pagenum - 1) . "," . app_pagenum;
    $rs = $db->query($sql);
    ?>
<script language="javascript">
$(document).ready(function(){
	$("#btnDel").click(function(){
		if(confirm('确定要删除吗')){
			$("#form1").attr("action","?action=delpl");
			$("#form1").submit();
		}
	});
	$("#btnDelall").click(function(){
		if(confirm('确定要删除吗')){
			$("#form1").attr("action","?action=delall");
			$("#form1").submit();
		}
	});
	$("#btnSelin").click(function(){
		if(confirm('确定入库您所选择的数据吗')){
			$("#form1").attr("action","?action=IDInflow");
			$("#form1").submit();
		}
	});
	$("#btnAllin").click(function(){
		if(confirm('全部入库你所采集的数据吗')){
			$("#form1").attr("action","?action=AllInflow");
			$("#form1").submit();
		}
	});
	$("#btnNoin").click(function(){
		if(confirm('确定入库所有未入库的数据吗')){
			$("#form1").attr("action","?action=noInflow");
			$("#form1").submit();
		}
	});
	 $("#btnType").click(function(){
		if(confirm('确定入库所有未入库的数据吗')){
			$("#form1").attr("action","?action=editype");
			$("#form1").submit();
		}
	});
});
</script>
<TABLE width="96%" border=0 align=center cellpadding=0 cellSpacing=0 class=tbtitle >
  <TBODY>
    <tr>
      <td>
		<form action="collect_art.php" method="get"> 
          <strong>搜索文章:</strong>
          <input id=KeyWord size=40 name=keyword>
		  <INPUT class=inputbut type=submit value=搜索 name=Submit>
        &nbsp; 按项目查看:
        <select onchange=javascript:window.location.href=this.options[this.selectedIndex].value>
        <option value="collect_art.php">全部采集项目</option>
		<?php 
    echo makeSelect("{pre}cj_art_projects", "p_id", "p_name", "", "collect_art.php", "&nbsp;|&nbsp;&nbsp;", "");
    ?>
		  </select>	
          <font color="#FF0000">(没有找到对应栏目,不能入库)</font>
		</form>
        
        </td>
    </tr>
  </TBODY>
</table>

<form action="" method="post" name="form1" id="form1">
<table  class=tb >
	<tr>
	<td width="4%">&nbsp;</td>
	<td>文章名称</td>
	<td width="7%">状态</td>
	<td width="15%">栏目分类</td>
	<td width="15%">采集项目名称</td> 
	<td width="13%">添加时间</td>
	<td width="8%">操作</td>
	</tr>
	<?php 
    if (!$rs) {
        ?>
    <tr><td align="center" colspan="9" >没有任何记录!</td></tr>
    <?php 
    } else {
        $i = 0;
        while ($row = $db->fetch_array($rs)) {
            ?>
	<tr>
		<td><input name="m_id[]" type="checkbox" id="m_id" value="<?php 
            echo $row["m_id"];
            ?>
" /></td>
		<td><?php 
            echo $row["m_title"];
            ?>
 </td>
		<td><?php 
            if ($row["m_zt"] == 1) {
                echo "<font color=\"#FF0000\">已入库</font>";
            } else {
                echo "未入库";
            }
            ?>
</td>
		<td>
	<?php 
            if ($row["m_typeid"] == 0) {
                ?>
		<font color="#FF0000">没找到对应分类请配置</font>
		<?php 
            } else {
                $typearr = getValueByArray($cache[1], "t_id", $row["m_typeid"]);
                echo $typearr["t_name"];
            }
            ?>
      </td>
      <td><?php 
            echo $row["p_name"];
            ?>
</td>
      <td><?php 
            echo isToDay($row['m_addtime']);
            ?>
</td>
      <td><A href="?action=edit&m_id=<?php 
            echo $row["m_id"];
            ?>
">修改</A>|<A href="?action=del&m_id=<?php 
            echo $row["m_id"];
            ?>
">删除</A></td></tr>
	<?php 
        }
    }
    ?>
	<tr>
	<td  colspan="9">
    全选<input name="chkall" type="checkbox" id="chkall" value="1" onClick="checkAll(this.checked,'m_id[]');"/>&nbsp;
    &nbsp;<input type="button" id="btnDel" value="批量删除" class="btn"  />
	&nbsp;<input type="button" id="btnDelall" value="删除所有" class="btn"  />
	&nbsp;<input type="button" id="btnSelin" class="btn" name="Submit" value="入库所选" >
	&nbsp;<input type="button" id="btnAllin" class="btn" name="Submit" value="全部入库" >
    &nbsp;<input type="button" id="btnNoin" class="btn" name="Submit" value="入库未入库" >
        <select name="m_typeid" id="m_typeid"  >
        <option value="">请选择数据分类</option>
            <?php 
    echo makeSelectAll("{pre}art_type", "t_id", "t_name", "t_pid", "t_sort", 0, "", "&nbsp;|&nbsp;&nbsp;", "");
    ?>
        </select>
        <input type="button" id="btnType" class="btn" name="Submit" value="批量分类"><font color="#FF0000">&nbsp; </font></td>
</tr>
 <tr>
    <td colspan="9" >同名处理:  
	<input type="checkbox" name="CCTV1" value="1">覆盖作者:
	<input type="checkbox" name="CCTV2" value="2">覆盖内容:
     </td>
</tr>
	<tr align="center" bgcolor="#f8fbfb">
	<td colspan="8">
	<?php 
    echo pagelist_manage($pagecount, $pagenum, $nums, app_pagenum, "collect_art.php?page={p}&{pre}cj_art_projects=" . $project . "&keyword=" . $keyword);
    ?>
	</td>
    </tr>
</table>
</form>
<?php 
}
function main()
{
    global $db, $cache;
    $pagenum = be("get", "page");
    if (isN($pagenum) || !isNum($pagenum)) {
        $pagenum = 1;
    }
    if ($pagenum < 1) {
        $pagenum = 1;
    }
    $pagenum = intval($pagenum);
    $keyword = be("get", "keyword");
    $from = be("get", "playfrom");
    $project = be("get", "cj_vod_projects");
    $zt = be("get", "zt");
    $sql = "Select a.crontab_desc, a.m_id,a.m_name,a.m_typeid,a.m_urltest,m_playfrom,a.status ,b.p_name from {pre}cj_zhuiju a,{pre}cj_vod_projects b where a.m_pid=b.p_id  ";
    if ($keyword != "") {
        $keyword = trim($keyword);
        $sql = $sql . " and m_name like '%" . $keyword . "%' ";
    }
    if ($project != "") {
        $sql = $sql . " and a.m_pid = " . $project;
    }
    if ($from != "") {
        $sql = $sql . " and a.m_playfrom ='" . $from . "' ";
    }
    //$sql = $sql . " group by m_urltest " ;
    $rscount = $db->query($sql);
    $nums = $db->num_rows($rscount);
    //总记录数
    $pagecount = ceil($nums / app_pagenum);
    //总页数
    $sql = $sql . " limit " . app_pagenum * ($pagenum - 1) . "," . app_pagenum;
    //var_dump($sql);
    $rs = $db->query($sql);
    ?>
<script language="javascript">
$(document).ready(function(){	
	$("#btnDelall").click(function(){
		if(confirm('确定要删除所有的数据 吗')){
			$("#form1").attr("action","?action=delall");
			$("#form1").submit();
		}
	});
	$("#btnDel").click(function(){
		if(confirm('确定要删除所选择的数据吗')){
			$("#form1").attr("action","?action=delpl");
			$("#form1").submit();
		}
	});
	$("#btnEdit").click(function(){
		$("#form1").attr("action","?action=editall");
		$("#form1").submit();
	});
	$('#form1').form({
	    success:function(data){
	        $.messager.alert('系统提示', data, 'info',function(){
	        	location.href=location.href;
	        });
	    }
	});
	
});
</script>
<TABLE border=0 cellpadding=0 cellSpacing=0 class=tbtitle >
  <TBODY>
    <tr>
		<td>
		<form action="collect_vod_zhuiju.php" method="get" > 
			<strong>搜索影片:</strong>
			<input id=keyword size=40 name=keyword value="<?php 
    echo $keyword;
    ?>
">
			
			<select id="playfrom" name=playfrom>
	<option value="">视频播放器</option>
	<?php 
    echo makeSelectPlayer($from);
    ?>
	</select>
			
			<select id="cj_vod_projects" name="cj_vod_projects">
				<option value="">全部采集项目</option>
				<?php 
    echo makeSelect("{pre}cj_vod_projects", "p_id", "p_name", "", "", "&nbsp;|&nbsp;&nbsp;", $project);
    ?>
			</select>	
			<INPUT class=inputbut type=submit value=搜索 name=submit>
			    
		</form>
		</td>
    </tr>
  </TBODY>
</TABLE>

<form action="" method="post" name="form1" id="form1">
<table class=tb >
	<tr>
	  <td width="4%" >&nbsp;</td>
      <td>影片名称</td>
      <td>定时采集时间</td>
      <td>栏目分类</td>
      <td width="15%">所属采集项目</td> 
       <td width="7%">播放器</td>
     
       <td width="8%">操作</td>
    </tr>
	<?php 
    if (!$rs) {
        ?>
    <tr><td align="center" colspan="9" >没有任何记录!</td></tr>
    <?php 
    } else {
        $i = 0;
        while ($row = $db->fetch_array($rs)) {
            $t_id = $row["m_id"];
            ?>
 
    <tr>
	<td><input name="m_id[]" type="checkbox" id="m_id" value="<?php 
            echo $t_id;
            ?>
" /></td>
	<td><a href="collect_vod.php?action=edit&m_id=<?php 
            echo $row["m_id"];
            ?>
"><?php 
            echo $row["m_name"];
            ?>
  (连载:<?php 
            echo $row["status"];
            ?>
)</a></td>
	
	<td>
		
		<input type="checkbox" name="crontab_desc<?php 
            echo $t_id;
            ?>
[]" value="1" <?php 
            if (strpos($row["crontab_desc"], "1") !== false) {
                echo "checked";
            }
            ?>
 />星期一
	    <input type="checkbox" name="crontab_desc<?php 
            echo $t_id;
            ?>
[]" value="2" <?php 
            if (strpos($row["crontab_desc"], "2") !== false) {
                echo "checked";
            }
            ?>
 />星期二
	    <input type="checkbox" name="crontab_desc<?php 
            echo $t_id;
            ?>
[]" value="3" <?php 
            if (strpos($row["crontab_desc"], "3") !== false) {
                echo "checked";
            }
            ?>
/>星期三
	    <input type="checkbox" name="crontab_desc<?php 
            echo $t_id;
            ?>
[]" value="4" <?php 
            if (strpos($row["crontab_desc"], "4") !== false) {
                echo "checked";
            }
            ?>
 />星期四
	    <input type="checkbox" name="crontab_desc<?php 
            echo $t_id;
            ?>
[]" value="5" <?php 
            if (strpos($row["crontab_desc"], "5") !== false) {
                echo "checked";
            }
            ?>
/>星期五
	    <input type="checkbox" name="crontab_desc<?php 
            echo $t_id;
            ?>
[]" value="6" <?php 
            if (strpos($row["crontab_desc"], "6") !== false) {
                echo "checked";
            }
            ?>
/>星期六
	    <input type="checkbox" name="crontab_desc<?php 
            echo $t_id;
            ?>
[]" value="0" <?php 
            if (strpos($row["crontab_desc"], "0") !== false) {
                echo "checked";
            }
            ?>
/>星期天
	
     </td>
	
	<td>
	<?php 
            if ($row["m_typeid"] == 0) {
                ?>
		<font color="#FF0000">没找到对应分类请配置</font>
	<?php 
            } else {
                $typearr = getValueByArray($cache[0], "t_id", $row["m_typeid"]);
                echo $typearr["t_name"];
            }
            ?>
	</td><td><a href="<?php 
            echo $row["m_urltest"];
            ?>
" target='_blank'><?php 
            echo $row["p_name"];
            ?>
</a></td>
	<td><?php 
            echo $row["m_playfrom"];
            ?>
</td>
	
   
      <td><A href="?action=del&m_id=<?php 
            echo $row["m_id"];
            ?>
">删除</A></td>
    </tr>
	<?php 
        }
    }
    ?>
	<tr class="formlast">
	<td colspan="4">
    <input name="chkall" type="checkbox" id="chkall" value="1" onClick="checkAll(this.checked,'m_id[]');"/> 全选
     &nbsp;<input type="button" id="btnDel" value="批量删除" class="btn"  />
     
     &nbsp;<input type="button" value="批量修改" id="btnEdit" class="input" />
	</td>
	</tr>
	
    <tr align="center" class="formlast">
	<td colspan="4">
	<?php 
    echo pagelist_manage($pagecount, $pagenum, $nums, app_pagenum, "collect_vod_zhuiju.php?page={p}&cj_vod_projects=" . $project . "&keyword=" . $keyword . "&playfrom=" . $from);
    ?>
</td>
    </tr>
</table>
</form>
<?php 
}
if (!isNum($hide)) {
    $hide = -1;
} else {
    $hide = intval($hide);
}
if (!isNum($page)) {
    $page = 1;
} else {
    $page = intval($page);
}
if ($page < 1) {
    $page = 1;
}
$where = "where 1=1 ";
if ($stype > 0) {
    $typearr = getValueByArray($cache[0], "t_id", $stype);
    if (is_array($typearr)) {
        $where = $where . " and d_type in (" . $typearr["childids"] . ")";
    } else {
        $where .= " AND d_type=" . $stype . " ";
    }
}
if ($stype == -1) {
    $where .= " AND d_type=0 ";
}
if ($area > 0) {
    $where .= " AND d_area = " . $area . " ";
}
if ($topic > 0) {
    $where .= " AND d_topic = " . $topic . " ";
}