diff --git a/lib/_autoload.php b/lib/_autoload.php new file mode 100644 index 0000000000000000000000000000000000000000..b05ee4569eafad75341c2ec156a8b66dce57a569 --- /dev/null +++ b/lib/_autoload.php @@ -0,0 +1,39 @@ +<?php + +/** + * This file implements a autoloader for simpleSAMLphp. This autoloader + * will search for files under the simpleSAMLphp directory. + * + * @author Olav Morken, UNINETT AS. + * @package simpleSAMLphp + * @version $Id$ + */ + + +/** + * Autoload function for simpleSAMLphp. + * + * It will autoload all classes stored in the lib-directory. + * + * @param $className The name of the class. + */ +function SimpleSAML_autoload($className) { + + $libDir = dirname(__FILE__) . '/'; + + /* Special handling for xmlseclibs.php. */ + if(in_array($className, array('XMLSecurityKey', 'XMLSecurityDSig', 'XMLSecEnc'), TRUE)) { + require_once($libDir . 'xmlseclibs.php'); + return; + } + + $file = $libDir . str_replace('_', '/', $className) . '.php'; + if(file_exists($file)) { + require_once($file); + } +} + +/* Register autload function for simpleSAMLphp. */ +spl_autoload_register('SimpleSAML_autoload'); + +?> \ No newline at end of file diff --git a/www/_include.php b/www/_include.php index b804e3f26ba4efd369c3d719a0b99ec38f91bceb..4fc9c697f6f708f010e8b0b28536802488a1645c 100644 --- a/www/_include.php +++ b/www/_include.php @@ -18,6 +18,10 @@ if(get_magic_quotes_gpc()) { } } + +/* Initialize the autoloader. */ +require_once(dirname(dirname(__FILE__)) . '/lib/_autoload.php'); + $path_extra = dirname(dirname(__FILE__)) . '/lib';