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

Adding a separate page to load metadata, and verify output in logs...

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1971 44740490-163a-0410-bde0-09ae8108e29a
parent f13176c4
No related branches found
No related tags found
No related merge requests found
<?php
/**
* Hook to add links to the frontpage.
*
* @param array &$links The links on the frontpage, split into sections.
*/
function metarefresh_hook_frontpage(&$links) {
assert('is_array($links)');
assert('array_key_exists("links", $links)');
$links['federation'][] = array(
'href' => SimpleSAML_Module::getModuleURL('metarefresh/fetch.php'),
'text' => array('en' => 'Metarefresh: fetch metadata'),
);
}
?>
\ No newline at end of file
<?php
$this->data['header'] = $this->t('{aggregator:dict:aggregator_header}');
$this->includeAtTemplateBase('includes/header.php');
echo('<h1>Metarefresh fetch</h1>');
if (!empty($this->data['logentries'])) {
echo '<pre style="border: 1px solid #aaa; padding: .5em; overflow: scroll">';
foreach($this->data['logentries'] AS $l) {
echo $l . "\n";
}
echo '</pre>';
} else {
echo 'No output from metarefresh.';
}
$this->includeAtTemplateBase('includes/footer.php');
?>
\ No newline at end of file
<?php
$config = SimpleSAML_Configuration::getInstance();
$mconfig = SimpleSAML_Configuration::getConfig('config-metarefresh.php');
SimpleSAML_Utilities::requireAdmin();
SimpleSAML_Logger::setCaptureLog(TRUE);
$sets = $mconfig->getConfigList('sets');
foreach ($sets AS $setkey => $set) {
SimpleSAML_Logger::info('[metarefresh]: Executing set [' . $setkey . ']');
$expireAfter = $set->getInteger('expireAfter', NULL);
if ($expireAfter !== NULL) {
$expire = time() + $expireAfter;
} else {
$expire = NULL;
}
$metaloader = new sspmod_metarefresh_MetaLoader($expire);
foreach($set->getArray('sources') AS $source) {
SimpleSAML_Logger::debug('[metarefresh]: In set [' . $setkey . '] loading source [' . $source['src'] . ']');
$metaloader->loadSource($source);
}
$outputDir = $set->getString('outputDir');
$outputDir = $config->resolvePath($outputDir);
$outputFormat = $set->getValueValidate('outputFormat', array('flatfile', 'serialize'), 'flatfile');
switch ($outputFormat) {
case 'flatfile':
$metaloader->writeMetadataFiles($outputDir);
break;
case 'serialize':
$metaloader->writeMetadataSerialize($outputDir);
break;
}
}
$logentries = SimpleSAML_Logger::getCapturedLog();
$t = new SimpleSAML_XHTML_Template($config, 'metarefresh:fetch.tpl.php');
$t->data['logentries'] = $logentries;
$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