Skip to content

Commit

Permalink
修改定时器
Browse files Browse the repository at this point in the history
  • Loading branch information
wenchaojun committed Oct 12, 2019
1 parent 094aebe commit f9f2b39
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 2 deletions.
43 changes: 41 additions & 2 deletions module/cron/control.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ public function delete($cronID, $confirm = 'no')
$this->dao->delete()->from(TABLE_CRON)->where('id')->eq($cronID)->exec();
die(js::reload('parent'));
}

/**
* snoopy客户端
* @var Snoopy
*/
var $agent=false;
/**
* Ajax exec cron.
*
Expand Down Expand Up @@ -209,11 +213,46 @@ public function ajaxExec($restart = false)
exec($cron['command'], $output, $return);
if($output) $output = join("\n", $output);
}
elseif(isset($crons[$id]) and $crons[$id]->type == 'get')
{
//新增get请求
if(!$this->agent){
//只有当全局变量没初始化,才loadClass
$this->agent = $this->app->loadClass('snoopy');
}
//get方式获得网站内容
$return = $this->agent->fetch($cron['command']);
//请求成功
if($return){
//获取返回值
$output = $this->agent->results;
}else{
$output="get 访问失败";
}
}
elseif(isset($crons[$id]) and $crons[$id]->type == 'post')
{
//新增post请求
if(!$this->agent){
//只有当全局变量没初始化,才loadClass
$this->agent = $this->app->loadClass('snoopy');
}
//post方式获得网站内容
$return = $this->agent->submit($cron['command'],$cron['data']);
//请求成功
if($return){
//获取返回值
$output = $this->agent->results;
}else{
$output="post 访问失败";
}
}

/* Save log. */
$log = '';
$time = $now->format('G:i:s');
$log = "$time task " . $id . " executed,\ncommand: $cron[command].\nreturn : $return.\noutput : $output\n";
//$log = "$time task " . $id . " executed,\ncommand: $cron[command].\nreturn : $return.\noutput : $output\n";
$log = sprintf("%s task %d executed,\ncommand : %s\nreturn : %s\noutput : %s\n",$time,$id,$cron['command'],$return,$output);
$this->cron->logCron($log);
unset($log);
}
Expand Down
3 changes: 3 additions & 0 deletions module/cron/lang/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
$lang->cron->type = 'Typ';
$lang->cron->remark = 'Bemerkung';
$lang->cron->lastTime = 'Letze Ausführung';
$lang->cron->data = 'Data';

$lang->cron->turnonList['1'] = 'On';
$lang->cron->turnonList['0'] = 'Shutdown';
Expand All @@ -31,6 +32,8 @@

$lang->cron->typeList['zentao'] = 'Selbstaufruf';
$lang->cron->typeList['system'] = 'System Kommando';
$lang->cron->typeList['get'] = 'http(s) get';
$lang->cron->typeList['post'] = 'http(s) post';

$lang->cron->toggleList['start'] = 'Aktivieren';
$lang->cron->toggleList['stop'] = 'Deaktivieren';
Expand Down
3 changes: 3 additions & 0 deletions module/cron/lang/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
$lang->cron->type = 'Type';
$lang->cron->remark = 'Comment';
$lang->cron->lastTime = 'Last Run';
$lang->cron->data = 'Data';

$lang->cron->turnonList['1'] = 'On';
$lang->cron->turnonList['0'] = 'Off';
Expand All @@ -31,6 +32,8 @@

$lang->cron->typeList['zentao'] = 'Self Call';
$lang->cron->typeList['system'] = 'System Command';
$lang->cron->typeList['get'] = 'http(s) get';
$lang->cron->typeList['post'] = 'http(s) post';

$lang->cron->toggleList['start'] = 'Activate';
$lang->cron->toggleList['stop'] = 'Deactivate';
Expand Down
3 changes: 3 additions & 0 deletions module/cron/lang/zh-cn.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
$lang->cron->type = '任务类型';
$lang->cron->remark = '备注';
$lang->cron->lastTime = '最后执行';
$lang->cron->data = 'Post数据';

$lang->cron->turnonList['1'] = '打开';
$lang->cron->turnonList['0'] = '关闭';
Expand All @@ -31,6 +32,8 @@

$lang->cron->typeList['zentao'] = '禅道自调用';
$lang->cron->typeList['system'] = '操作系统命令';
$lang->cron->typeList['get'] = 'get请求';
$lang->cron->typeList['post'] = 'post请求';

$lang->cron->toggleList['start'] = '激活';
$lang->cron->toggleList['stop'] = '禁用';
Expand Down
3 changes: 3 additions & 0 deletions module/cron/lang/zh-tw.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
$lang->cron->type = '任務類型';
$lang->cron->remark = '備註';
$lang->cron->lastTime = '最後執行';
$lang->cron->data = 'Post数据';

$lang->cron->turnonList['1'] = '打開';
$lang->cron->turnonList['0'] = '關閉';
Expand All @@ -31,6 +32,8 @@

$lang->cron->typeList['zentao'] = '禪道自調用';
$lang->cron->typeList['system'] = '操作系統命令';
$lang->cron->typeList['get'] = 'get请求';
$lang->cron->typeList['post'] = 'post请求';

$lang->cron->toggleList['start'] = '激活';
$lang->cron->toggleList['stop'] = '禁用';
Expand Down
4 changes: 4 additions & 0 deletions module/cron/view/create.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
<th><?php echo $lang->cron->type;?></th>
<td><?php echo html::select('type', $lang->cron->typeList, 'system', "class='form-control'")?></td>
</tr>
<tr>
<th><?php echo $lang->cron->data;?></th>
<td colspan='2'><?php echo html::input('data', '', "class='form-control'")?></td><td></td>
</tr>
<tr>
<td colspan='3' class='text-center'><?php echo html::submitButton()?></td>
</tr>
Expand Down
4 changes: 4 additions & 0 deletions module/cron/view/edit.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
<th><?php echo $lang->cron->type;?></th>
<td><?php echo html::select('type', $lang->cron->typeList, $cron->type, "class='form-control'")?></td>
</tr>
<tr>
<th><?php echo $lang->cron->data;?></th>
<td colspan='2'><?php echo html::input('data', $cron->data, "class='form-control'")?></td><td></td>
</tr>
<tr>
<td colspan='3' class='text-center'><?php echo html::submitButton();?></td>
</tr>
Expand Down

0 comments on commit f9f2b39

Please sign in to comment.