123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
- require_once(dirname(__FILE__).'/../include/common.inc.php');
- require_once(DEDEINC.'/dedetag.class.php');
- if(empty($client)) $client = 'dede';
- if(empty($clientpwd)) $clientpwd = '';
- $cfg_task_pwd = trim($cfg_task_pwd);
- if(!empty($cfg_task_pwd) && $clientpwd != $cfg_task_pwd)
- {
- echo ($client=='js' ? '' : 'notask');
- exit();
- }
- $ntime = time();
- $nformattime = GetDateTimeMk($ntime);
- list($ndate, $ntime) = explode(' ', $nformattime);
- list($y, $m, $d) = explode('-', $ndate);
- list($hh, $mm, $ss) = explode(':', $ntime);
- $daylimit = 24 * 3600;
- $dsql->Execute('me', 'SELECT * FROM `#@__sys_task` WHERE islock=0 ORDER BY id ASC ');
- while($arr = $dsql->GetArray())
- {
- $starttime = $arr['starttime'];
- $endtime = $arr['endtime'];
- $ntime = strtotime("now");
-
- if($arr['lastrun'] > $starttime && $arr['runtype']==1) continue;
-
- if($endtime!=0 && $endtime < $ntime) continue;
-
- if($starttime!=0 && $ntime < $starttime) continue;
-
- $dotime = GetMkTime($ndate.' '.$arr['runtime'].':00');
- $limittime = $daylimit * $arr['freq'];
-
- $isplay = false;
-
- if($arr['freq'] > 1 && $ntime - $arr['lastrun'] > $limittime )
- {
- $isplay = true;
- }
- else
- {
- $ndateInt = intval( str_replace('-', '', $ndate) );
- $rdateInt = intval( str_replace('-', '', GetDateMk($arr['lastrun'])) );
- list($th, $tm) = explode(':', $arr['runtime']);
- if($ndateInt > $rdateInt
- && ($hh > $th || ($hh==$th && $mm >= $tm) ) )
- {
- $isplay = true;
- }
- }
-
- if($isplay)
- {
- $dourl = trim($arr['dourl']);
- if(!file_exists("task/$dourl"))
- {
- echo ($client=='js' ? '' : 'notask');
- exit();
- }
- else
- {
- $getConfigStr = trim($arr['parameter']);
- $getString = '';
- if(preg_match('#t:#', $getConfigStr))
- {
- $getStrings = array();
- $dtp = new DedeTagParse();
- $dtp->SetNameSpace('t', '<', '>');
- $dtp->LoadString($getConfigStr);
- if(is_array($dtp->CTags))
- {
- foreach($dtp->CTags as $k=>$ctag)
- {
- $getString .= ($getString=='' ? '' : '&').$ctag->GetAtt('key').'='.urlencode($ctag->GetAtt('value'));
- }
- }
- }
- $dsql->ExecuteNoneQuery("Update `#@__sys_task` set lastrun='".time()."', sta='运行' where id='{$arr['id']}' ");
- if($getString !='' ) $dourl .= '?'.$getString;
- if($client=='js') header("location:{$cfg_phpurl}/task/{$dourl}");
- else echo "{$cfg_phpurl}/task/{$dourl}";
- exit();
- }
- }
- }
- echo ($client=='js' ? '' : 'notask');
- exit();
|