| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 | <?phpdefine('EmpireCMSAdmin','1');require("../class/connect.php");require("../class/db_sql.php");require("../class/functions.php");require LoadLang("pub/fun.php");require("../class/delpath.php");require("../class/copypath.php");require("../class/t_functions.php");require("../data/dbcache/class.php");require("../data/dbcache/MemberLevel.php");$link=db_connect();$empire=new mysqlquery();//验证用户$lur=is_login();$logininid=$lur['userid'];$loginin=$lur['username'];$loginrnd=$lur['rnd'];$loginlevel=$lur['groupid'];$loginadminstyleid=$lur['adminstyleid'];//ehash$ecms_hashur=hReturnEcmsHashStrAll();@set_time_limit(0);//加载$incftp=0;if($public_r['phpmode']){	include("../class/ftp.php");	$incftp=1;}//防采集if($public_r['opennotcj']){	@include("../data/dbcache/notcj.php");}//验证是否执行function CheckDoTask($r){	global $logininid;	if($r['userid']&&$r['userid']!=$logininid)//执行用户	{		return false;	}	$time=time();	$date=date("j,w,G,i,Y,m");	$dr=explode(',',$date);	if(','.$r['doday'].','!=',*,'&&$r['doday']!=$dr[0])//日期	{		return false;	}	if(','.$r['doweek'].','!=',*,'&&$r['doweek']!=$dr[1])//星期	{		return false;	}	if(','.$r['dohour'].','!=',*,'&&$r['dohour']!=$dr[2])//小时	{		return false;	}	$min=(int)$dr[3];	if($r['dominute']!=''&&$r['dominute']!=','&&!strstr($r['dominute'],','.$min.','))//分钟	{		return false;	}	if($r['lastdo'])	{		if(!TogTaskTime($r,$dr))		{			return false;		}	}	return $time;}//验证时间function TogTaskTime($r,$dr){	$re['chdate']=$dr[4].'-'.$dr[5].'-';	$re['date']='Y-m-';	if($r['doday'])	{		$re['chdate'].='-'.$dr[0];		$re['date'].='-j';	}	if($r['doweek'])	{		$re['chdate'].='-'.$dr[1];		$re['date'].='-w';	}	if($r['dohour'])	{		$re['chdate'].='-'.$dr[2];		$re['date'].='-G';	}	if($r['dominute'])	{		$re['chdate'].='-'.$dr[3];		$re['date'].='-i';	}	if(date($re['date'],$r['lastdo'])==$re['chdate'])	{		return false;	}	return true;}$retasktime=30;$tasksql="select id,filename,lastdo,doweek,doday,dohour,dominute,userid,taskname from {$dbtbpre}enewstask where isopen=1 and (userid=0 or (userid<>0 and userid='$logininid'))";$ecms=RepPostStr($_GET['ecms'],1);echo"<title>执行计划任务</title><link href='adminstyle/".$loginadminstyleid."/adminstyle.css' rel='stylesheet' type='text/css'>";//执行if($ecms=='dotask'){	$id=(int)$_GET['id'];	if(empty($id))	{		exit();	}	$r=$empire->fetch1("select id,filename,lastdo,doweek,doday,dohour,dominute,userid,taskname from {$dbtbpre}enewstask where id=$id and isopen=1 limit 1");	$file='../tasks/'.$r['filename'];	if(empty($r['id'])||empty($r['filename'])||!file_exists($file))	{		exit();	}	$lasttime=CheckDoTask($r);	if($lasttime)	{		echo"<script>parent.WriteTaskLog('任务 <".$r['taskname']."> 开始执行......');</script>";		include_once($file);		$usql=$empire->query("update {$dbtbpre}enewstask set lastdo='$lasttime' where id=$id");		echo"<script>parent.WriteTaskLog('任务 <".$r['taskname']."> 执行完毕,最后执行时间:".date("Y-m-d H:i:s",$lasttime)."');</script>";	}}//更新elseif($ecms=='retask'){	echo"<meta http-equiv=\"refresh\" content=\"".$retasktime.";url=task.php?ecms=retask".$ecms_hashur['href']."\">";	?>	<script>	function AddTaskDiv(divid,taskid){		if(parent.document.getElementById(divid)!=null)		{			parent.document.getElementById('page'+divid).src='task.php?<?=$ecms_hashur['href']?>&ecms=dotask&id='+taskid;		}		else		{			parent.document.getElementById("alltaskdiv").innerHTML+="<div id='"+divid+"'><iframe frameborder='0' id='page"+divid+"' name='page"+divid+"' scrolling='no' src='task.php?<?=$ecms_hashur['href']?>&ecms=dotask&id="+taskid+"' style='HEIGHT:0;VISIBILITY:inherit;WIDTH:0;Z-INDEX:1'></iframe></div>";		}	}	</script>	<script>	<?php	$sql=$empire->query($tasksql);	while($r=$empire->fetch($sql))	{		if(CheckDoTask($r))		{			echo"AddTaskDiv('taskdiv".$r['id']."','".$r['id']."');";		}	}	?>	</script>	<?php}//运行elseif($ecms=='TodoTask'){	$id=(int)$_GET['id'];	if(empty($id))	{		exit();	}	//验证权限	CheckLevel($logininid,$loginin,$classid,"task");	$r=$empire->fetch1("select id,filename,taskname from {$dbtbpre}enewstask where id=$id limit 1");	$file='../tasks/'.$r['filename'];	if($r['id']&&$r['filename']&&file_exists($file))	{		include_once($file);		$enews=$ecms;		//操作日志		insert_dolog("id=$id&taskname=$r[taskname]&filename=$r[filename]");	}	printerror('TodoTaskSuccess','');}else{	?>	<script>		function WriteTaskLog(str){			document.tasklogform.tasklog.value="  "+str+"\r\n"+document.tasklogform.tasklog.value;		}		function ClearTaskLog(){			document.tasklogform.tasklog.value="";		}	</script>	<IFRAME frameBorder="0" id="retaskfile" name="retaskfile" scrolling="no" src="task.php?ecms=retask<?=$ecms_hashur['href']?>" style="HEIGHT:0;VISIBILITY:inherit;WIDTH:0;Z-INDEX:1"></IFRAME>	<table width='100%' border=0 align=center cellpadding=3 cellspacing=1 class='tableborder'>		<form name="tasklogform" method="post">		<tr class=header><td>任务日志   [<a href="#ecms" onclick="ClearTaskLog();">清除日志内容</a>]</td></tr>		<tr><td bgcolor='#ffffff'>			<textarea name="tasklog" cols="80" rows="30" id="tasklog" style="width:100%">  计划任务开始运行时间:<?=date("Y-m-d H:i:s")?></textarea>		</td></tr>		</form>	</table>	<div id="alltaskdiv">	</div>	<?php}db_close();$empire=null;?>
 |