From d7b1179eaee0bde00867de618632559704e09552 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 20 Sep 2018 11:44:09 +0200 Subject: [PATCH] fix PHP Warning: Use of undefined constant account_id - assumed 'account_id' also nicer formatting of data with json and pretty-printed tooltip --- admin/inc/class.admin_asyncservice.inc.php | 59 ++++++++++++---------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/admin/inc/class.admin_asyncservice.inc.php b/admin/inc/class.admin_asyncservice.inc.php index cb19e5fbbf..df66f9c39e 100644 --- a/admin/inc/class.admin_asyncservice.inc.php +++ b/admin/inc/class.admin_asyncservice.inc.php @@ -59,25 +59,25 @@ class admin_asyncservice { if (strpos($GLOBALS['egw_info']['user']['account_email'],'@') === false) { - echo '

'.lang("You have no email address for your user set !!!")."

\n"; + echo '

'.htmlspecialchars(lang("You have no email address for your user set !!!"))."

\n"; } elseif (!$async->set_timer($times,'test','admin.admin_asyncservice.test',$GLOBALS['egw_info']['user']['account_email'])) { - echo '

'.lang("Error setting timer, wrong syntax or maybe there's one already running !!!")."

\n"; + echo '

'.htmlspecialchars(lang("Error setting timer, wrong syntax or maybe there's one already running !!!"))."

\n"; } } if ($_POST['cancel']) { if (!$async->cancel_timer('test')) { - echo '

'.lang("Error canceling timer, maybe there's none set !!!")."

\n"; + echo '

'.htmlspecialchars(lang("Error canceling timer, maybe there's none set !!!"))."

\n"; } } if ($_POST['install'] || $_POST['deinstall']) { if (!($install = $async->install($_POST['install'] ? $times : False))) { - echo '

'.lang('Error: %1 not found or other error !!!',$async->crontab)."

\n"; + echo '

'.htmlspecialchars(lang('Error: %1 not found or other error !!!',$async->crontab))."

\n"; } $_POST['asyncservice'] = $_POST['deinstall'] ? 'fallback' : 'crontab'; } @@ -91,7 +91,8 @@ class admin_asyncservice $last_run = $async->last_check_run(); $lr_date = $last_run['end'] ? Api\DateTime::server2user($last_run['end'],'') : lang('never'); - echo '

'.lang('Async services last executed').': '.$lr_date.' ('.$last_run['run_by'].")

\n
\n"; + echo '

'. htmlspecialchars(lang('Async services last executed')).': '. + $lr_date.' ('.htmlspecialchars($last_run['run_by']).")

\n
\n"; if (isset($_POST['asyncservice']) && $_POST['asyncservice'] != $GLOBALS['egw_info']['server']['asyncservice']) { @@ -107,28 +108,28 @@ class admin_asyncservice } $async_use[''] = lang('fallback (after each pageview)'); $async_use['off'] = lang('disabled (not recomended)'); - echo '

'.lang('Run Asynchronous services').''. + echo '

'.htmlspecialchars(lang('Run Asynchronous services')).''. ' \n"; if (is_array($installed) && isset($installed['cronline'])) { - echo '   \n"; + echo '   \n"; } echo "

\n"; if ($async->only_fallback) { - echo '

'.lang('Under windows you need to install the asyncservice %1manually%2 or use the fallback mode. Fallback means the jobs get only checked after each page-view !!!','','')."

\n"; + echo '

'.htmlspecialchars(lang('Under windows you need to install the asyncservice %1manually%2 or use the fallback mode. Fallback means the jobs get only checked after each page-view !!!','',''))."

\n"; } else { - echo '

'.lang('Installed crontab').": \n"; + echo '

'.htmlspecialchars(lang('Installed crontab')).": \n"; if (is_array($installed) && isset($installed['cronline'])) { @@ -136,34 +137,34 @@ class admin_asyncservice } elseif ($installed === 0) { - echo ''.lang('%1 not found or not executable !!!',$async->crontab)."

\n"; + echo ''.htmlspecialchars(lang('%1 not found or not executable !!!',$async->crontab))."

\n"; } else { - echo ''.lang('asyncservices not yet installed or other error (%1) !!!',$installed['error'])."

\n"; + echo ''.htmlspecialchars(lang('asyncservices not yet installed or other error (%1) !!!',$installed['error']))."

\n"; } - echo '

\n". - lang("for the times below (empty values count as '*', all empty = every minute)")."

\n"; + echo '

\n". + htmlspecialchars(lang("for the times below (empty values count as '*', all empty = every minute)"))."

\n"; } echo "
\n"; foreach ($units as $u => $ulabel) { - echo " \n"; + echo " \n"; } echo "\n '."\n"; + echo ' '."\n"; echo ' \n
$ulabel   $ulabel  
\n"; - echo ' \n". - lang('Enable debug-messages')."
\n"; + htmlspecialchars(lang('Enable debug-messages'))."\n\n"; if ($_POST['send']) { $next = $async->next_run($times,True); - echo "

asyncservice::next_run(";print_r($times);echo")=".($next === False ? 'False':"'$next'=".Api\DateTime::server2user($next,''))."

\n"; + echo "

asyncservice::next_run(". htmlspecialchars(json_encode($times, JSON_UNESCAPED_SLASHES)).")=".($next === False ? 'False':"$next=".Api\DateTime::server2user($next,''))."

\n"; } - echo '

 \n"; - echo '\n"; + echo '


 \n"; + echo '\n"; echo lang('for the times above')."

\n"; echo '

'.lang('The TestJob sends you a mail everytime it is called.')."

\n"; @@ -173,11 +174,17 @@ class admin_asyncservice echo "\n\n\n"; foreach($jobs as $job) { - echo "\n\n"; + echo "\n\n"; + echo "\n"; + echo "\n= 64) + { + echo ' title="'.htmlspecialchars(json_encode($job['data'], JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT)).'"'; + $data = substr($data, 0, 60).'...'; + } + echo ">". htmlspecialchars($data)."\n"; + echo "\n"; } echo "
Id".lang('Next run').''.lang('Times').''.lang('Method').''.lang('Data')."".lang('LoginID')."
$job[id]".Api\DateTime::server2user($job['next'],'').""; - print_r($job['times']); - echo "$job[method]"; - print_r($job['data']); - echo "".$GLOBALS['egw']->accounts->id2name($job[account_id])."
$job[id]".Api\DateTime::server2user($job['next'],'')."".htmlspecialchars(json_encode($job['times'], JSON_UNESCAPED_SLASHES))."".htmlspecialchars(str_replace('EGroupware\\', '', $job['method']))."".htmlspecialchars($GLOBALS['egw']->accounts->id2name($job['account_id']))."
\n"; } @@ -185,7 +192,7 @@ class admin_asyncservice { echo lang('No jobs in the database !!!')."

\n"; } - echo '

'."\n"; + echo '

'."\n"; echo "\n"; echo $GLOBALS['egw']->framework->footer(); }