Skip to content
Snippets Groups Projects
Commit 93163fa2 authored by Olav Morken's avatar Olav Morken
Browse files

cron: Translations & web display of output.

Patch by pitbulk@gmail.com.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2011 44740490-163a-0410-bde0-09ae8108e29a
parent 7a137b21
No related branches found
No related tags found
No related merge requests found
<?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
<?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');
?>
<?php <?php
$this->data['header'] = 'Cron information page'; $this->data['header'] = $this->t('cron_header');
$this->includeAtTemplateBase('includes/header.php'); $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><?php echo $this->t('cron_info') ?></p>
<p>Here is a suggestion for a crontab file:</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 <pre style="font-size: x-small; color: #444; padding: 1em; border: 1px solid #eee; margin: .4em "><code><?php
foreach ($this->data['urls'] AS $url ) { 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"; echo "" . $url['int'] . " curl --silent \"" . $url['href'] . "\" > /dev/null 2>&1\n";
} }
?> ?>
</code></pre> </code></pre>
<p>Click here to run the cron jobs: <br><p><?php echo $this->t('cron_execution') ?></p>
<ul> <ul>
<?php <?php
foreach ($this->data['urls'] AS $url ) { foreach ($this->data['urls'] AS $url ) {
echo '<li><a href="' . $url['href'] . '">' . $url['title'] . '</a></li>'; echo '<li><a href="' . $url['href'] . '&amp;output=xhtml">' . $run_text. ' [' .$url['tag']. ']' . '</a></li>';
} }
?> ?>
</ul> </ul>
</div> </div>
<?php <?php
......
...@@ -9,8 +9,6 @@ if (!is_null($cronconfig->getValue('key'))) { ...@@ -9,8 +9,6 @@ if (!is_null($cronconfig->getValue('key'))) {
exit; exit;
} }
} }
#print_r($_REQUEST['tag']) ; exit;
if (!is_null($cronconfig->getValue('allowed_tags'))) { if (!is_null($cronconfig->getValue('allowed_tags'))) {
if (!in_array($_REQUEST['tag'], $cronconfig->getValue('allowed_tags'))) { if (!in_array($_REQUEST['tag'], $cronconfig->getValue('allowed_tags'))) {
SimpleSAML_Logger::error('Cron - Illegal tag [' . $_REQUEST['tag'] . '].'); SimpleSAML_Logger::error('Cron - Illegal tag [' . $_REQUEST['tag'] . '].');
...@@ -19,12 +17,14 @@ if (!is_null($cronconfig->getValue('allowed_tags'))) { ...@@ -19,12 +17,14 @@ if (!is_null($cronconfig->getValue('allowed_tags'))) {
} }
$summary = array(); $summary = array();
$croninfo = array( $croninfo = array(
'summary' => &$summary, 'summary' => &$summary,
'tag' => $_REQUEST['tag'], 'tag' => $_REQUEST['tag'],
); );
$url = SimpleSAML_Utilities::selfURL();
$time = date(DATE_RFC822);
SimpleSAML_Module::callHooks('cron', $croninfo); SimpleSAML_Module::callHooks('cron', $croninfo);
foreach ($summary AS $s) { foreach ($summary AS $s) {
...@@ -33,14 +33,13 @@ foreach ($summary AS $s) { ...@@ -33,14 +33,13 @@ foreach ($summary AS $s) {
if ($cronconfig->getValue('sendemail', TRUE) && count($summary) > 0) { 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 ' . $time . '</p>' .
'<p>URL: <tt>' . $url . '</tt></p>' .
$message = '<h1>Cron report</h1><p>Cron ran at ' . date(DATE_RFC822) . '</p>' . '<p>Tag: ' . $croninfo['tag'] . "</p>\n\n" .
'<p>URL: <tt>' . SimpleSAML_Utilities::selfURL() . '</tt></p>' . '<ul><li>' . join('</li><li>', $summary) . '</li></ul>';
'<p>Tag: ' . $_REQUEST['tag'] . "</p>\n\n" . $statustext;
$toaddress = $config->getString('technicalcontact_email', 'na@example.org'); $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.'); SimpleSAML_Logger::error('Cron - Could not send email. [technicalcontact_email] not set in config.');
} else { } else {
$email = new SimpleSAML_XHTML_EMail($toaddress, 'simpleSAMLphp cron report', 'no-reply@simplesamlphp.com'); $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) { ...@@ -50,8 +49,13 @@ if ($cronconfig->getValue('sendemail', TRUE) && count($summary) > 0) {
} }
#$t = new SimpleSAML_XHTML_Template($config, 'modinfo:modlist.php'); if (isset($_REQUEST['output']) && $_REQUEST['output'] == "xhtml") {
#$t->data['modules'] = $modinfo; $t = new SimpleSAML_XHTML_Template($config, 'cron:croninfo-result.php','cron:cron');
#$t->show(); $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
...@@ -29,14 +29,14 @@ $urls = array(); ...@@ -29,14 +29,14 @@ $urls = array();
foreach ($tags AS $tag) { foreach ($tags AS $tag) {
$urls[] = array( $urls[] = array(
'href' => SimpleSAML_Module::getModuleURL('cron/cron.php?key=' . $key . '&amp;tag=' . $tag), 'href' => SimpleSAML_Module::getModuleURL('cron/cron.php?key=' . $key . '&amp;tag=' . $tag),
'title' => 'Run cron [' . $tag . ']', 'tag' => $tag,
'int' => (array_key_exists($tag, $def) ? $def[$tag] : $def['default']), '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->data['urls'] = $urls;
$t->show(); $t->show();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment