Skip to content
Snippets Groups Projects
Commit 71cef95d authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

FIX Execute a dedicated job from its id may results of launching other

jobs too.
parent 9aa6c72a
No related branches found
No related tags found
No related merge requests found
...@@ -43,6 +43,7 @@ $action=GETPOST('action','alpha'); ...@@ -43,6 +43,7 @@ $action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha'); $confirm=GETPOST('confirm','alpha');
$cancel=GETPOST('cancel'); $cancel=GETPOST('cancel');
$backtourl=GETPOST('backtourl','alpha'); $backtourl=GETPOST('backtourl','alpha');
$securitykey = GETPOST('securitykey','alpha');
/* /*
...@@ -99,6 +100,13 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->del ...@@ -99,6 +100,13 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->del
// Execute jobs // Execute jobs
if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute) if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute)
{
if (! empty($conf->global->CRON_KEY) && $conf->global->CRON_KEY != $securitykey)
{
setEventMessages('Security key '.$securitykey.' is wrong', null, 'errors');
$action='';
}
else
{ {
$now = dol_now(); // Date we start $now = dol_now(); // Date we start
...@@ -125,6 +133,7 @@ if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->ex ...@@ -125,6 +133,7 @@ if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->ex
} }
} }
} }
}
if ($action=='add') if ($action=='add')
...@@ -284,7 +293,7 @@ if ($action == 'delete') ...@@ -284,7 +293,7 @@ if ($action == 'delete')
} }
if ($action == 'execute'){ if ($action == 'execute'){
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id.(empty($conf->global->CRON_KEY)?'':'&securitykey='.$conf->global->CRON_KEY),$langs->trans("CronExecute"),$langs->trans("CronConfirmExecute"),"confirm_execute",'','',1); print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id.'&securitykey='.$securitykey,$langs->trans("CronExecute"),$langs->trans("CronConfirmExecute"),"confirm_execute",'','',1);
$action=''; $action='';
} }
......
...@@ -363,6 +363,9 @@ class Cronjob extends CommonObject ...@@ -363,6 +363,9 @@ class Cronjob extends CommonObject
function fetch_all($sortorder='DESC', $sortfield='t.rowid', $limit=0, $offset=0, $status=1, $filter='') function fetch_all($sortorder='DESC', $sortfield='t.rowid', $limit=0, $offset=0, $status=1, $filter='')
{ {
global $langs; global $langs;
$this->lines=array();
$sql = "SELECT"; $sql = "SELECT";
$sql.= " t.rowid,"; $sql.= " t.rowid,";
$sql.= " t.tms,"; $sql.= " t.tms,";
...@@ -399,8 +402,10 @@ class Cronjob extends CommonObject ...@@ -399,8 +402,10 @@ class Cronjob extends CommonObject
if ($status == 2) $sql.= " AND t.status = 2"; if ($status == 2) $sql.= " AND t.status = 2";
//Manage filter //Manage filter
if (is_array($filter) && count($filter)>0) { if (is_array($filter) && count($filter)>0) {
foreach($filter as $key => $value) { foreach($filter as $key => $value)
$sql.= ' AND '.$key.' LIKE \'%'.$value.'%\''; {
if ($key == 't.rowid') $sql.= ' AND '.$key.' = '.$this->db->escape($value);
else $sql.= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\'';
} }
} }
...@@ -427,8 +432,6 @@ class Cronjob extends CommonObject ...@@ -427,8 +432,6 @@ class Cronjob extends CommonObject
if ($num) if ($num)
{ {
$this->lines=array();
while ($i < $num) while ($i < $num)
{ {
......
...@@ -57,6 +57,7 @@ if ($status == '') $status=-2; ...@@ -57,6 +57,7 @@ if ($status == '') $status=-2;
//Search criteria //Search criteria
$search_label=GETPOST("search_label",'alpha'); $search_label=GETPOST("search_label",'alpha');
$securitykey = GETPOST('securitykey','alpha');
if (empty($sortorder)) $sortorder="DESC"; if (empty($sortorder)) $sortorder="DESC";
if (empty($sortfield)) $sortfield="t.status"; if (empty($sortfield)) $sortfield="t.status";
...@@ -98,6 +99,13 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->del ...@@ -98,6 +99,13 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->del
// Execute jobs // Execute jobs
if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute) if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute)
{
if (! empty($conf->global->CRON_KEY) && $conf->global->CRON_KEY != $securitykey)
{
setEventMessages('Security key '.$securitykey.' is wrong', null, 'errors');
$action='';
}
else
{ {
$object = new Cronjob($db); $object = new Cronjob($db);
$job = $object->fetch($id); $job = $object->fetch($id);
...@@ -129,6 +137,7 @@ if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->ex ...@@ -129,6 +137,7 @@ if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->ex
header("Location: ".DOL_URL_ROOT.'/cron/list.php?status=-2'); // Make a call to avoid to run twice job when using back header("Location: ".DOL_URL_ROOT.'/cron/list.php?status=-2'); // Make a call to avoid to run twice job when using back
exit; exit;
} }
}
/* /*
...@@ -166,7 +175,7 @@ if ($action == 'delete') ...@@ -166,7 +175,7 @@ if ($action == 'delete')
if ($action == 'execute') if ($action == 'execute')
{ {
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id.'&status='.$status,$langs->trans("CronExecute"),$langs->trans("CronConfirmExecute"),"confirm_execute",'','',1); print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id.'&status='.$status.'&securitykey='.$securitykey,$langs->trans("CronExecute"),$langs->trans("CronConfirmExecute"),"confirm_execute",'','',1);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment