示例#1
0
         *
         * See PHP bug: https://bugs.php.net/bug.php?id=47987
         */
        return false;
    }
    if ($errno & SimpleSAML_Utilities::$logMask || !($errno & error_reporting())) {
        // masked error
        return false;
    }
    static $limit = 5;
    $limit -= 1;
    if ($limit < 0) {
        // we have reached the limit in the number of backtraces we will log
        return false;
    }
    // show an error with a full backtrace
    $e = new SimpleSAML_Error_Exception('Error ' . $errno . ' - ' . $errstr);
    $e->logError();
    // resume normal error processing
    return false;
}
set_error_handler('SimpleSAML_error_handler');
$configdir = SimpleSAML\Utils\Config::getConfigDir();
if (!file_exists($configdir . '/config.php')) {
    header('Content-Type: text/plain');
    echo "You have not yet created the simpleSAMLphp configuration files.\n";
    echo "See: https://simplesamlphp.org/docs/devel/simplesamlphp-install-repo\n";
    exit(1);
}
// set the timezone
SimpleSAML\Utils\Time::initTimezone();
示例#2
0
 /**
  * Load a configuration file from a configuration set.
  *
  * This function will return a configuration object even if the file does not exist.
  *
  * @param string $filename The name of the configuration file.
  * @param string $configSet The configuration set. Optional, defaults to 'simplesaml'.
  *
  * @return SimpleSAML_Configuration A configuration object.
  * @throws Exception If the configuration set is not initialized.
  */
 public static function getOptionalConfig($filename = 'config.php', $configSet = 'simplesaml')
 {
     assert('is_string($filename)');
     assert('is_string($configSet)');
     if (!array_key_exists($configSet, self::$configDirs)) {
         if ($configSet !== 'simplesaml') {
             throw new Exception('Configuration set \'' . $configSet . '\' not initialized.');
         } else {
             self::$configDirs['simplesaml'] = SimpleSAML\Utils\Config::getConfigDir();
         }
     }
     $dir = self::$configDirs[$configSet];
     $filePath = $dir . '/' . $filename;
     return self::loadFromFile($filePath, false);
 }
#!/usr/bin/env php
<?php 
$baseDir = dirname(dirname(__FILE__));
require_once $baseDir . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . '_autoload.php';
require_once SimpleSAML\Utils\Config::getConfigDir() . DIRECTORY_SEPARATOR . 'config.php';
# Iterate through configured metadata sources and ensure
# that a PDO source exists.
foreach ($config['metadata.sources'] as $s) {
    # If pdo is configured, create the new handler and add in the metadata sets.
    if ($s['type'] === "pdo") {
        $mdshp = new SimpleSAML_Metadata_MetaDataStorageHandlerPdo($s);
        $mdshp->initDatabase();
        foreach (glob("metadata/*.php") as $filename) {
            $metadata = array();
            require_once $filename;
            $set = basename($filename, ".php");
            echo "importing set '{$set}'..." . PHP_EOL;
            foreach ($metadata as $k => $v) {
                echo "\t{$k}" . PHP_EOL;
                $mdshp->addEntry($k, $set, $v);
            }
        }
    }
}