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

Adding santity check module to simplesamlphp. It checks things and reports if...

Adding santity check module to simplesamlphp. It checks things and reports if things are not working :) also supports using the cron hook

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@993 44740490-163a-0410-bde0-09ae8108e29a
parent 461736bd
No related branches found
No related tags found
No related merge requests found
<?php
/*
* The configuration of simpleSAMLphp sanitycheck package
*/
$config = array (
/*
* Do you want to generate statistics using the cron module? If so, specify which cron tag to use.
* Examples: daily, weekly
* To not run statistics in cron, set value to
* 'cron_tag' => NULL,
*/
'cron_tag' => 'hourly',
);
?>
\ No newline at end of file
<?php
/**
* Hook to run a cron job.
*
* @param array &$croninfo Output
*/
function sanitycheck_hook_cron(&$croninfo) {
assert('is_array($croninfo)');
assert('array_key_exists("summary", $croninfo)');
assert('array_key_exists("tag", $croninfo)');
$config = SimpleSAML_Configuration::getInstance();
$sconfig = $config->copyFromBase('sconfig', 'config-sanitycheck.php');
if (is_null($sconfig->getValue('cron_tag', NULL))) return;
if ($sconfig->getValue('cron_tag', NULL) !== $croninfo['tag']) return;
$info = array();
$errors = array();
$hookinfo = array(
'info' => &$info,
'errors' => &$errors,
);
SimpleSAML_Module::callHooks('sanitycheck', $hookinfo);
if (count($errors) > 0) {
foreach ($errors AS $err) {
$croninfo['summary'][] = 'Sanitycheck error: ' . $err;
}
}
}
?>
\ No newline at end of file
<?php
/**
* Hook to add the modinfo module to the frontpage.
*
* @param array &$links The links on the frontpage, split into sections.
*/
function sanitycheck_hook_frontpage(&$links) {
assert('is_array($links)');
assert('array_key_exists("links", $links)');
$links['links'][] = array(
'href' => SimpleSAML_Module::getModuleURL('sanitycheck/index.php'),
'text' => array('en' => 'Sanity check of your simpleSAMLphp setup'),
);
}
?>
\ No newline at end of file
<?php
/**
* Hook to add the modinfo module to the frontpage.
*
* @param array &$hookinfo hookinfo
*/
function sanitycheck_hook_sanitycheck(&$hookinfo) {
assert('is_array($hookinfo)');
assert('array_key_exists("errors", $hookinfo)');
assert('array_key_exists("info", $hookinfo)');
$hookinfo['info'][] = '[sanitycheck] At least the sanity check it self is working :)';
$hookinfo['errors'][] = '[sanitycheck] At least the sanity check it self is working (NOT) :)';
}
?>
\ No newline at end of file
<?php
$this->data['header'] = 'Sanity check';
$this->includeAtTemplateBase('includes/header.php');
?>
<div id="content">
<h2><?php echo($this->data['header']); ?></h2>
<?php
if (count($this->data['errors']) > 0) {
?>
<div style="border: 1px solid #800; background: #caa; margin: 1em; padding: .5em">
<p><?php echo '<img src="/' . $this->data['baseurlpath'] . 'resources/icons/delete.png" alt="Failed" />'; ?>
These checks failed:</p>
<?php
echo '<ul>';
foreach ($this->data['errors'] AS $err) {
echo '<li>' . $err . '</li>';
}
echo '</ul>';
echo '</div>';
}
?>
<?php
if (count($this->data['info']) > 0) {
?>
<div style="border: 1px solid #ccc; background: #eee; margin: 1em; padding: .5em">
<p><?php echo '<img src="/' . $this->data['baseurlpath'] . 'resources/icons/accept.png" alt="OK" />'; ?>
These checks succeeded:</p>
<?php
echo '<ul>';
foreach ($this->data['info'] AS $i) {
echo '<li>' . $i . '</li>';
}
echo '</ul>';
echo '</div>';
}
?>
</div>
<?php $this->includeAtTemplateBase('includes/footer.php'); ?>
\ No newline at end of file
<?php
$config = SimpleSAML_Configuration::getInstance();
$sconfig = $config->copyFromBase('sconfig', 'config-sanitycheck.php');
$info = array();
$errors = array();
$hookinfo = array(
'info' => &$info,
'errors' => &$errors,
);
SimpleSAML_Module::callHooks('sanitycheck', $hookinfo);
$config = SimpleSAML_Configuration::getInstance();
$t = new SimpleSAML_XHTML_Template($config, 'sanitycheck:check-tpl.php');
$t->data['errors'] = $errors;
$t->data['info'] = $info;
$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