Skip to content
Snippets Groups Projects
Commit ea9c87b9 authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

Adding link to cron information page at frontpage. Cron infomration page requires admin login.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@991 44740490-163a-0410-bde0-09ae8108e29a
parent 6a669dc5
No related branches found
No related tags found
No related merge requests found
<?php
/**
* Hook to add the modinfo module to the frontpage.
*
* @param array &$links The links on the frontpage, split into sections.
*/
function cron_hook_frontpage(&$links) {
assert('is_array($links)');
assert('array_key_exists("links", $links)');
$links['links'][] = array(
'href' => SimpleSAML_Module::getModuleURL('cron/croninfo.php'),
'text' => array('en' => 'Cron module information page'),
);
}
?>
\ No newline at end of file
<?php
$this->data['header'] = 'Cron information page';
$this->includeAtTemplateBase('includes/header.php');
?>
<div id="content">
<p>Cron is a way to run things regularly on unix systems.</p>
<p>Here is a suggestion for a crontab file:</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 "" . $url['int'] . " /usr/bin/lynx -source " . $url['href'] . "\n";
}
?>
</code></pre>
<p>Click here to run the cron jobs:
<ul>
<?php
foreach ($this->data['urls'] AS $url ) {
echo '<li><a href="' . $url['href'] . '">' . $url['title'] . '</a></li>';
}
?>
</ul>
</div>
<?php
$this->includeAtTemplateBase('includes/footer.php');
?>
\ No newline at end of file
<?php
/**
* The _include script registers a autoloader for the simpleSAMLphp libraries. It also
* initializes the simpleSAMLphp config class with the correct path.
*/
require_once('_include.php');
/* Load simpleSAMLphp, configuration and metadata */
$config = SimpleSAML_Configuration::getInstance();
$session = SimpleSAML_Session::getInstance();
if (!isset($session) || !$session->isValid('login-admin') ) {
SimpleSAML_Utilities::redirect('/' . $config->getBaseURL() . 'auth/login-admin.php',
array('RelayState' => SimpleSAML_Utilities::selfURL())
);
}
$cronconfig = $config->copyFromBase('cron', 'module_cron.php');
$key = $cronconfig->getValue('key', '');
$tags = $cronconfig->getValue('allowed_tags');
$def = array(
'weekly' => "22 0 * * 0",
'daily' => "02 0 * * *",
'hourly' => "01 * * * *",
'default' => "XXXXXXXXXX",
);
$urls = array();
foreach ($tags AS $tag) {
$urls[] = array(
'href' => SimpleSAML_Module::getModuleURL('cron/cron.php?key=' . $key . '&amp;tag=' . $tag),
'title' => 'Run cron [' . $tag . ']',
'int' => (array_key_exists($tag, $def) ? $def[$tag] : $def['default']),
);
}
$t = new SimpleSAML_XHTML_Template($config, 'cron:croninfo-tpl.php');
$t->data['urls'] = $urls;
$t->show();
?>
\ No newline at end of file
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