<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta name="robots" content="noindex,nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link  href="img/style.css" rel="stylesheet" type="text/css" />
<title>高级工具</title>
<script src="js/common.js" type="text/javascript"></script>
<script src="js/main.js" type="text/javascript"></script>
</head>
<body>
<!--当前导航-->
<script type="text/JavaScript">if(parent.$('admincpnav')) parent.$('admincpnav').innerHTML='后台首页&nbsp;&raquo;&nbsp;工具&nbsp;&raquo;&nbsp;计划任务 ';</script>
<div class="r_main">
  <div class="r_content">
    <div class="r_content_1">
<table border="0" cellpadding="0" cellspacing="0" align="center" class="tb" id="tips">
        <tr class="thead">
          <th>重要提示</th>
        </tr>
        <tr>
          <td class="tipsblock">
		  <div style="padding: 10px;border: 0;border-radius: 4px;font-size: 12px;background-color: #eef5f4;">
&nbsp;*&nbsp;&nbsp;本功能为定时任务自动版，访客访问前台页面时即可自动触发，不需要打开后台管理。<br>
&nbsp;*&nbsp;&nbsp;请谨慎使用本功能，合理设置执行间隔时间，延长PHP脚本执行时间，以免造成服务器崩溃。<br>
&nbsp;*&nbsp;&nbsp;网站前台模板必须调用js/common.js和js/function.js两个系统js文件才可以正常执行。<br>
&nbsp;*&nbsp;&nbsp;默认只生成首页/新闻首页/24小时有更新的内容和列表，修改/include/crons/automakehtml.php可配置更多项目。					
			</div></td>
        </tr>
</table>
      <?php
if($action=="edit")
{
?>
      <form name="form1" method="post" action="?action=editsave&id=<?php echo $id;?>">
	  <input type="hidden" name="zf" id="zf" value="<?php echo $cron['filename'];?>">
        <table border="0" cellpadding="0" cellspacing="0" align="center" class="tb">
          <tr class="thead">
            <th colspan="15">编辑计划任务 - <?php echo $cron['name'];?></th>
          </tr>
          <tr>
            <td colspan="2">每周:</td>
          </tr>
          <tr>
            <td><select name="weekdaynew">
                <option value="-1">*</option>
                <?php echo $weekdayselect;?>
              </select></td>
            <td>设置星期几执行本任务，"*"为不限制，本设置会覆盖下面的"日"设定</td>
          </tr>
          <tr>
            <td colspan="2">每月:</td>
          </tr>
          <tr>
            <td><select name="daynew">
                <option value="-1">*</option>
                <?php echo $dayselect;?>
              </select></td>
            <td>设置哪一日执行本任务，"*"为不限制</td>
          </tr>
          <tr>
            <td colspan="2">小时:</td>
          </tr>
          <tr>
            <td><select name="hournew">
                <option value="-1">*</option>
                <?php echo $hourselect;?>
              </select></td>
            <td>设置哪一小时执行本任务，"*"为不限制</td>
          </tr>
          <tr>
            <td colspan="2">分钟:</td>
          </tr>
          <tr>
            <td><input name="minutenew" value="<?php echo $cronminute;?>" type="text" class="txt"   /></td>
            <td>设置哪些分钟执行本任务，至多可以设置 12 个分钟值，多个值之间用半角逗号","隔开，留空为不限制</td>
          </tr>
          <?php if(strpos($cron['filename'],'$')>0){       
           	    $filename = $cron['filename'];
                $filenameArr=explode("$",$filename);
                $rid=$filenameArr[1];   ?>
          <tr>
            <td colspan="2">资源来源:</td>
          </tr>
          <tr>
            <td>
			<select name="resourcefrom" id="resourcefrom">
                <?php 
                $sqlz="select * from sea_zyk WHERE ztype !=3 order by zid ASC";
                $rsz=$dsql->getOne($sqlz);
                if(!is_array($rsz))
                {
                	echo "<option value='0'>无资源库接口，请先添加</option>";
                }
                else
                {
                    $dsql->SetQuery($sqlz);
                    $dsql->Execute('resourcefrom');
                    while($row=$dsql->GetArray('resourcefrom'))
                    {
					$skey= '$'.$row[zid].'$';
					if(strpos($cron['filename'],$skey) !==false){$ischeck='selected';}else{$ischeck='';}
                    echo "<option ".$ischeck." value=\"".$row[zid]."#".$row[zapi]."\">".$row[zid].".".$row[zname]."</option>";
                    }
				}
                ?>
                </select>
			</td>
            <td>选择资源库来源(请选择已经绑定好分类的来源，这样可以做到自动入库)</td>
          </tr>
          <?php }elseif(strpos($cron['filename'],'autocollect.php') !==false){
           	    $filename = $cron['filename'];
                $filenameArr=explode("#",$filename);
                $collectID=$filenameArr[1];
                $collectPageNum=$filenameArr[2];
                $autogetconnum=$filenameArr[3];
          ?>
          <tr>
            <td colspan="2">采集ID:</td>
          </tr>
          <tr>
            <td><select name="collectIDa">
                <?php 
                $sql="select tid,tname from sea_co_type where cotype=0";
                $rs=$dsql->getOne($sql);
                if(!is_array($rs))
                {
                	echo "<option value='0'>无自定义采集项目，请先添加</option>";
                }
                else
                {
                    $dsql->SetQuery($sql);
                    $dsql->Execute('getCollectID');
                    while($row=$dsql->GetArray('getCollectID'))
                    {
                    echo "<option value=\"".$row[tid]."\" ".($collectID==$row['tid']?'selected':'').">".$row[tid].".".$row[tname]."</option>";
                    }
				}
                ?>
                </select></td>
            <td>自动采集的ID,不能为空</td>
          </tr>
          <tr>
            <td colspan="2">采集页数:</td>
          </tr>
          <tr>
            <td><input name="collectPageNum" value="<?php echo $collectPageNum;?>" type="text" class="txt" /></td>
            <td>每次自动采集多少列表页,0为不采集,不能为空</td>
          </tr>
          <tr>
            <td colspan="2">采集条数:</td>
          </tr>
          <tr>
            <td><input name="autogetconnum" value="<?php echo $autogetconnum;?>" type="text" class="txt" /></td>
            <td>每次自动采集多少条最新数据,0为不采集,不能为空</td>
          </tr>
          <?php }elseif(strpos($cron['filename'],'autocollectnews.php') !==false){
           	    $filename = $cron['filename'];
                $filenameArr=explode("#",$filename);
                $collectID=$filenameArr[1];
                $collectPageNum=$filenameArr[2];
                $autogetconnum=$filenameArr[3];
          ?>
          <tr>
            <td colspan="2">采集ID:</td>
          </tr>
          <tr>
            <td><select name="collectIDa">
                <?php 
                $sql="select tid,tname from sea_co_type where cotype=1";
                $rs=$dsql->getOne($sql);
                if(!is_array($rs))
                {
                	echo "<option value='0'>无自定义采集项目，请先添加</option>";
                }
                else
                {
                    $dsql->SetQuery($sql);
                    $dsql->Execute('getCollectID');
                    while($row=$dsql->GetArray('getCollectID'))
                    {
                    echo "<option value=\"".$row[tid]."\" ".($collectID==$row['tid']?'selected':'').">".$row[tid].".".$row[tname]."</option>";
                    }
				}
                ?>
                </select></td>
            <td>自动采集的ID,不能为空</td>
          </tr>
          <tr>
            <td colspan="2">采集页数:</td>
          </tr>
          <tr>
            <td><input name="collectPageNum" value="<?php echo $collectPageNum;?>" type="text" class="txt" /></td>
            <td>每次自动采集多少列表页,0为不采集,不能为空</td>
          </tr>
          <tr>
            <td colspan="2">采集条数:</td>
          </tr>
          <tr>
            <td><input name="autogetconnum" value="<?php echo $autogetconnum;?>" type="text" class="txt" /></td>
            <td>每次自动采集多少条最新数据,0为不采集,不能为空</td>
          </tr>
          <?php }else{
           ?>
          <tr>
            <td colspan="2">任务脚本:</td>
          </tr>
          <tr>
            <td><input name="filenamenew" value="<?php echo $cron['filename'];?>" type="text" class="txt"   /></td>
            <td>设置本任务的执行程序文件名，请勿包含路径，程序脚本统一存放于 ./include/crons/ 目录中</td>
          </tr>
          <?php } ?>
          <tr>
            <td colspan="15"><div class="fixsel">
                <input type="submit" class="rb1" name="editsubmit" value="提 交"  />
              </div></td>
          </tr>
        </table>
      </form>
      <?php
}else{
?>
      <form name="form1" method="post" action="?action=update">
        <table border="0" cellpadding="0" cellspacing="0" align="center" class="tb">
          <tr class="thead">
            <th colspan="15">计划任务</th>
          </tr>
          <tr class="header">
            <td>&nbsp;删除</td>
            <td>可用</td>
            <td>名称</td>
            <td>类型</td>
            <td>时间</td>
            <td>上次执行时间</td>
            <td>下次执行时间</td>
            <td></td>
          </tr>
          <?php
if(is_array($showtablerow)){
foreach($showtablerow as $t)
{
echo "<tr><td>".$t[0]."</td><td>".$t[2]."</td><td>".$t[1]."</td><td>".$t[3]."</td><td>".$t[4]."</td><td>".$t[5]."</td><td>".$t[6]."</td><td>".$t[7]."</td></tr>\n";
}
}
?>
          <tr>
            <td ><input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(this.checked,'input','delete[]')" /></td>
            <td><label for="chkall"><span class="fixsel">
                <input type="submit" class="rb1" name="cronssubmit2" value="提 交"  />
                </span></label></td>
            <td colspan="6"></td>
          </tr>
        </table>
      </form>
      <br />
      <form name="form2" id="form2" action="?action=addCron" method="post" >
        <div style="margin:0 18px 18px;border:4px #DEEFFA solid"> <div style="margin:8px">
          新增计划任务
          </div>
          <select style="margin:8px 8px 0px 8px;" on onchange="selecPlan(this.options[this.selectedIndex].value)" name="PlanMode">
            <option value="1">定时生成</option>
            <option value="0">资源库采集</option>
            <option value="2">视频自定义采集</option>
			<option value="4">新闻自定义采集</option>
          </select>
          <div style="margin:8px">
            <input type="text" class="txt" name="newname" value="" size="20"  onchange="this.onkeyup();" onkeyup="this.value=this.value.replace(/$/g,'');"/>
            &nbsp;计划任务名称(<span style="color:#F00">*</span>)</div>
            
          <div style="margin:0 8px;display:none;" id="collectItem">

                <select name="resourcefrom" id="resourcefrom">
                <?php 
                $sqlz="select * from sea_zyk WHERE ztype !=3 order by zid ASC";
                $rsz=$dsql->getOne($sqlz);
                if(!is_array($rsz))
                {
                	echo "<option value='0'>无资源库接口，请先添加</option>";
                }
                else
                {
                    $dsql->SetQuery($sqlz);
                    $dsql->Execute('resourcefrom');
                    while($row=$dsql->GetArray('resourcefrom'))
                    {
                    echo "<option value=\"".$row[zid]."#".$row[zapi]."\">".$row[zid].".".$row[zname]."</option>";
                    }
				}
                ?>
                </select>		    
          </div>
           
          <div style="margin:0 8px;display:none;" id="autocollectItem">
                <select name="collectID">
                <?php 
                $sql="select tid,tname from sea_co_type where cotype=0";
                $rs=$dsql->getOne($sql);
                if(!is_array($rs))
                {
                	echo "<option value='0'>无自定义采集项目，请先添加</option>";
                }
                else
                {
                    $dsql->SetQuery($sql);
                    $dsql->Execute('getCollectID');
                    while($row=$dsql->GetArray('getCollectID'))
                    {
                    echo "<option value=\"".$row[tid]."\">".$row[tid].".".$row[tname]."</option>";
                    }
				}
                ?>
                </select><br>
                <input name="collectPageNum" value="1" type="text" class="txt"   />
                &nbsp;每次自动采集多少列表页,0为不采集,不能为空<br />
   	            <input name="autogetconnum" value="10" type="text" class="txt"   />
                &nbsp;每次自动采集最新的多少条数据,0为不采集,不能为空
          </div>
		  
		   <div style="margin:0 8px;display:none;" id="autocollectItemnews">
                <select name="collectIDnews">
                <?php 
                $sqln="select tid,tname from sea_co_type where cotype=1";
                $rsn=$dsql->getOne($sqln);
                if(!is_array($rsn))
                {
                	echo "<option value='0'>无自定义采集项目，请先添加</option>";
                }
                else
                {
                    $dsql->SetQuery($sqln);
                    $dsql->Execute('getCollectIDnews');
                    while($row=$dsql->GetArray('getCollectIDnews'))
                    {
                    echo "<option value=\"".$row[tid]."\">".$row[tid].".".$row[tname]."</option>";
                    }
				}
                ?>
                </select><br>
                <input name="collectPageNum" value="1" type="text" class="txt"   />
                &nbsp;每次自动采集多少列表页,0为不采集,不能为空<br />
   	            <input name="autogetconnum" value="10" type="text" class="txt"   />
                &nbsp;每次自动采集最新的多少条数据,0为不采集,不能为空
          </div>
          
          <div  style="margin:0 8px">
            <ul>
              <li>
                <select name="weekdaynew">
                  <option value="-1">*</option>
                  <?php echo $weekdayselect;?>
                </select>
                &nbsp;设置星期几执行本任务，"*"为不限制，本设置会覆盖下面的"日"设定</li>
              <li>
                <select name="daynew">
                  <option value="-1">*</option>
                  <?php echo $dayselect;?>
                </select>
                &nbsp;设置哪一日执行本任务，"*"为不限制</li>
              <li>
                <select name="hournew">
                  <option value="-1">*</option>
                  <?php echo $hourselect;?>
                </select>
                &nbsp;设置哪一小时执行本任务，"*"为不限制</li>
            </ul>
          </div>
          <div style="margin:8px">
            <input name="minutenew" value="" type="text" class="txt"   />
            &nbsp; 设置哪些分钟执行本任务，至多可以设置 12 个分钟值，多个值之间用半角逗号","隔开，留空为不限制</div>
          <div style="margin:8px">
            <input type="button" class="rb1" name="cronssubmit" value="新增计划任务" onclick="document.getElementById('form2').submit();" />
          </div>
        </div>
      </form>
      <form name="form3" id="form3" action="?action=addCustomCron" method="post" >
        <div style="margin:0 18px 18px;border:4px #DEEFFA solid">
          <div style="margin:8px">新增自定义计划任务 </div>
          <div style="margin:8px"> 新增:
            <input type="text" class="txt" name="newname" value="" size="20"  onchange="this.onkeyup();" onkeyup="this.value=this.value.replace(/$/g,'');" />
          </div>
          <div style="margin:8px">
            <input type="button" class="rb1" name="cronssubmit" value="新增自定义计划任务" onclick="document.getElementById('form3').submit();" />
          </div>
        </div>
      </form>
     
      <?php
}
?>
    </div>
  </div>
</div>
<?php
viewFoot();
?>
</body>
</html>
