Skip to content
Snippets Groups Projects
Commit bf61fc58 authored by alangrafu's avatar alangrafu
Browse files

Adding static module

parent dedf6ac0
No related branches found
No related tags found
No related merge requests found
......@@ -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'];
......
......@@ -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
?>
<?
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);
}
}
?>
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