diff --git a/modules/cron/dictionaries/cron.php b/modules/cron/dictionaries/cron.php new file mode 100644 index 0000000000000000000000000000000000000000..d2ea93691179bac851fb535c2f2f709f8d5c306c --- /dev/null +++ b/modules/cron/dictionaries/cron.php @@ -0,0 +1,56 @@ +<?php + +$lang = array( + + 'cron_header' => array ( + 'da' => 'Cron resultat side', + 'en' => 'Cron result page', + 'es' => 'Página de resultado del cron', + ), + + 'cron_result_title' => array ( + 'da' => 'Her er resultatet for opgaven udførelse:', + 'en' => 'Here are the result for the cron job execution:', + 'es' => 'Aqui están los resultados de las tareas en la ejecución del cron:', + ), + + 'cron_info' => array ( + 'da' => 'Cron er en måde at køre tingene regelmæssigt på UNIX-systemer.', + 'en' => 'Cron is a way to run things regularly on unix systems.', + 'es' => 'Cron es una forma de ejecutar tareas periodicas en los sistemas UNIX.', + ), + + 'cron_suggestion' => array ( + 'da' => 'Her er et forslag til en crontab fil:', + 'en' => 'Here is a suggestion for a crontab file:', + 'es' => 'He aquà una sugerencia de un archivo crontab:', + ), + + 'cron_execution' => array ( + 'da' => 'Klik her for at køre cron job:', + 'en' => 'Click here to run the cron jobs:', + 'es' => 'Haga clic aquà para ejecutar las tareas de cron:', + ), + + 'run_text' => array ( + 'da' => 'Run cron:', + 'en' => 'Run cron:', + 'es' => 'Ejecutar cron:', + ), + + 'ran_text' => array ( + 'da' => 'Cron løb på', + 'en' => 'Cron ran at', + 'es' => 'Cron ejecutado el', + ), + + 'cron_report_title' => array ( + 'da' => 'Cron rapport', + 'en' => 'Cron report', + 'es' => 'Informe del cron', + ), + +); + + +?> \ No newline at end of file diff --git a/modules/cron/templates/croninfo-result.php b/modules/cron/templates/croninfo-result.php new file mode 100644 index 0000000000000000000000000000000000000000..89f9d5d297da8d384122a2624aabfb3eb0e92751 --- /dev/null +++ b/modules/cron/templates/croninfo-result.php @@ -0,0 +1,20 @@ +<?php + +$this->data['header'] = $this->t('cron_header'); +$this->includeAtTemplateBase('includes/header.php'); +?> + <p><?php echo $this->t('cron_result_title') ?></p> + <pre style="color: #444; padding: 1em; border: 1px solid #eee; margin: .4em "><code> + <?php + echo '<h1>' .$this->t('cron_report_title'). '</h1><p>' .$this->t('ran_text'). ' ' .$this->data['time'] . '</p>' . + '<p>URL: <tt>' . $this->data['url'] . '</tt></p>' . + '<p>Tag: ' . $this->data['tag'] . "</p>\n\n" . + '<ul><li>' . join('</li><li>', $this->data['summary']) . '</li></ul>'; + ?> + </code> + </pre> +</div> + +<?php +$this->includeAtTemplateBase('includes/footer.php'); +?> diff --git a/modules/cron/templates/croninfo-tpl.php b/modules/cron/templates/croninfo-tpl.php index 41843c12258631da0469821b392d49848926ccd8..c10c7830223cafd96de632d619cfec58b25caa0c 100644 --- a/modules/cron/templates/croninfo-tpl.php +++ b/modules/cron/templates/croninfo-tpl.php @@ -1,36 +1,36 @@ <?php -$this->data['header'] = 'Cron information page'; +$this->data['header'] = $this->t('cron_header'); $this->includeAtTemplateBase('includes/header.php'); +$run_text = $this->t('run_text'); ?> - <p>Cron is a way to run things regularly on unix systems.</p> - - <p>Here is a suggestion for a crontab file:</p> + <p><?php echo $this->t('cron_info') ?></p> + + <p><?php echo $this->t('cron_suggestion') ?></p> <pre style="font-size: x-small; color: #444; padding: 1em; border: 1px solid #eee; margin: .4em "><code><?php foreach ($this->data['urls'] AS $url ) { - echo "# " . $url['title'] . "\n"; + echo "# " . $run_text. ' [' .$url['tag']. ']' . "\n"; echo "" . $url['int'] . " curl --silent \"" . $url['href'] . "\" > /dev/null 2>&1\n"; } ?> </code></pre> - - <p>Click here to run the cron jobs: + + <br><p><?php echo $this->t('cron_execution') ?></p> <ul> <?php - + foreach ($this->data['urls'] AS $url ) { - echo '<li><a href="' . $url['href'] . '">' . $url['title'] . '</a></li>'; + echo '<li><a href="' . $url['href'] . '&output=xhtml">' . $run_text. ' [' .$url['tag']. ']' . '</a></li>'; } - + ?> </ul> - </div> <?php diff --git a/modules/cron/www/cron.php b/modules/cron/www/cron.php index 052757a136681dce64fdf771e5b3824189681cd9..0306e85cb7f1f0eb682f6d88afa18bb36ced2202 100644 --- a/modules/cron/www/cron.php +++ b/modules/cron/www/cron.php @@ -9,8 +9,6 @@ if (!is_null($cronconfig->getValue('key'))) { exit; } } -#print_r($_REQUEST['tag']) ; exit; - if (!is_null($cronconfig->getValue('allowed_tags'))) { if (!in_array($_REQUEST['tag'], $cronconfig->getValue('allowed_tags'))) { SimpleSAML_Logger::error('Cron - Illegal tag [' . $_REQUEST['tag'] . '].'); @@ -19,12 +17,14 @@ if (!is_null($cronconfig->getValue('allowed_tags'))) { } - $summary = array(); $croninfo = array( 'summary' => &$summary, 'tag' => $_REQUEST['tag'], ); +$url = SimpleSAML_Utilities::selfURL(); +$time = date(DATE_RFC822); + SimpleSAML_Module::callHooks('cron', $croninfo); foreach ($summary AS $s) { @@ -33,14 +33,13 @@ foreach ($summary AS $s) { if ($cronconfig->getValue('sendemail', TRUE) && count($summary) > 0) { - $statustext = '<ul><li>' . join('</li><li>', $summary) . '</li></ul>'; - - $message = '<h1>Cron report</h1><p>Cron ran at ' . date(DATE_RFC822) . '</p>' . - '<p>URL: <tt>' . SimpleSAML_Utilities::selfURL() . '</tt></p>' . - '<p>Tag: ' . $_REQUEST['tag'] . "</p>\n\n" . $statustext; + $message = '<h1>Cron report</h1><p>Cron ran at ' . $time . '</p>' . + '<p>URL: <tt>' . $url . '</tt></p>' . + '<p>Tag: ' . $croninfo['tag'] . "</p>\n\n" . + '<ul><li>' . join('</li><li>', $summary) . '</li></ul>'; $toaddress = $config->getString('technicalcontact_email', 'na@example.org'); - if($toaddress == 'na@example.org') { + if($toaddress == 'na@example.org') { SimpleSAML_Logger::error('Cron - Could not send email. [technicalcontact_email] not set in config.'); } else { $email = new SimpleSAML_XHTML_EMail($toaddress, 'simpleSAMLphp cron report', 'no-reply@simplesamlphp.com'); @@ -50,8 +49,13 @@ if ($cronconfig->getValue('sendemail', TRUE) && count($summary) > 0) { } -#$t = new SimpleSAML_XHTML_Template($config, 'modinfo:modlist.php'); -#$t->data['modules'] = $modinfo; -#$t->show(); +if (isset($_REQUEST['output']) && $_REQUEST['output'] == "xhtml") { + $t = new SimpleSAML_XHTML_Template($config, 'cron:croninfo-result.php','cron:cron'); + $t->data['tag'] = $croninfo['tag']; + $t->data['time'] = $time; + $t->data['url'] = $url; + $t->data['summary'] = $summary; + $t->show(); +} ?> \ No newline at end of file diff --git a/modules/cron/www/croninfo.php b/modules/cron/www/croninfo.php index 44a3a1ab9f13d356f87477aba94b853a2e3a9772..1c1458eb163f3fd262ec4e2b0ce2ee2f2986d4b9 100644 --- a/modules/cron/www/croninfo.php +++ b/modules/cron/www/croninfo.php @@ -29,14 +29,14 @@ $urls = array(); foreach ($tags AS $tag) { $urls[] = array( 'href' => SimpleSAML_Module::getModuleURL('cron/cron.php?key=' . $key . '&tag=' . $tag), - 'title' => 'Run cron [' . $tag . ']', + 'tag' => $tag, 'int' => (array_key_exists($tag, $def) ? $def[$tag] : $def['default']), ); } -$t = new SimpleSAML_XHTML_Template($config, 'cron:croninfo-tpl.php'); +$t = new SimpleSAML_XHTML_Template($config, 'cron:croninfo-tpl.php', 'cron:cron'); $t->data['urls'] = $urls; $t->show();