diff --git a/common.inc.php b/common.inc.php index 98993d8a79aa6f63c478884628a7d6661fcd77e0..5579e1a7b535677fc8a3b043147a65079391046c 100644 --- a/common.inc.php +++ b/common.inc.php @@ -49,7 +49,7 @@ $conf['debug'] = false; //using the modules in the following order $conf['modules'] = array(); $conf['modules']['directory'] = 'modules/'; -$conf['modules']['available'] = array('class', 'service'); +$conf['modules']['available'] = array('static','class', 'service'); include_once('settings.inc.php'); $conf['view']['standard']['baseUrl'] = $conf['basedir']; diff --git a/index.php b/index.php index 35dfcb904ffab1b37e14d20af6fdd266a3d89f09..7bd8b7fc1fcb446a7347d0fa4b3a20fa89138cbe 100755 --- a/index.php +++ b/index.php @@ -22,8 +22,6 @@ if($conf['debug']){ error_reporting(E_ERROR); } - - include_once('classes/Utils.php'); include_once('classes/Queries.php'); include_once('classes/Endpoint.php'); @@ -36,13 +34,13 @@ $endpoints['local'] = new Endpoint($conf['endpoint']['local'], $conf['endpointPa $acceptContentType = Utils::getBestContentType($_SERVER['HTTP_ACCEPT']); $extension = Utils::getExtension($acceptContentType); + +//Check content type is supported by LODSPeaKr if($acceptContentType == NULL){ Utils::send406($uri); } -if(sizeof($_GET['q'])>0 && file_exists($conf['static']['directory'].$_GET['q'])){ - echo file_get_contents($conf['static']['directory'].$_GET['q']); - exit(0); -} + +//Export if($conf['export'] && $_GET['q'] == 'export'){ include_once('settings.inc.php'); include_once('classes/Exporter.php'); @@ -52,7 +50,7 @@ if($conf['export'] && $_GET['q'] == 'export'){ exit(0); } - +//Redirect to root URL if necessary $uri = $conf['basedir'].$_GET['q']; $localUri = $uri; if($uri == $conf['basedir']){ @@ -60,11 +58,14 @@ if($uri == $conf['basedir']){ exit(0); } +//Configure external URIs if necessary if($conf['mirror_external_uris']){ $uri = $conf['ns']['local'].$_GET['q']; $localUri = $conf['basedir'].$_GET['q']; } + +//Modules foreach($conf['modules']['available'] as $i){ $className = $i.'Module'; $currentModule = $conf['modules']['directory'].$className.'.php'; @@ -81,22 +82,5 @@ foreach($conf['modules']['available'] as $i){ } } -//Service module -if(preg_match("|^".$conf['basedir'].$conf['special']['uri']."|", $uri)){ - include_once($conf['special']['class']); - $context = array(); - $context['contentType'] = $acceptContentType; - $context['endpoints'] = $endpoints; - $sp = new SpecialFunction(); - $sp->execute($uri, $context); - exit(0); -} -//End of Service module - - - - - Utils::send404($uri); -//end of Class module ?> diff --git a/modules/staticModule.php b/modules/staticModule.php new file mode 100644 index 0000000000000000000000000000000000000000..520085176b0bbe61ee1c705630f473637d56dd50 --- /dev/null +++ b/modules/staticModule.php @@ -0,0 +1,31 @@ +<? +require_once('abstractModule.php'); +class StaticModule extends abstractModule{ + //Static module + + public function match($uri){ + global $conf; + global $localUri; + global $uri; + global $acceptContentType; + global $endpoints; + global $base; + $q = preg_replace('|^'.$conf['basedir'].'|', '', $uri); + if(sizeof($q)>0 && file_exists($conf['home'].$conf['static']['directory'].$q)){ + return $q; + } + return FALSE; + } + + public function execute($file){ + global $conf; + global $localUri; + global $uri; + global $acceptContentType; + global $endpoints; + global $base; + echo file_get_contents($conf['static']['directory'].$file); + } + +} +?>