Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
marcus-lodspeakr
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
uib-ub
Spesialsamlingene
marcus-lodspeakr
Commits
bf61fc58
Commit
bf61fc58
authored
13 years ago
by
alangrafu
Browse files
Options
Downloads
Patches
Plain Diff
Adding static module
parent
dedf6ac0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
common.inc.php
+1
-1
1 addition, 1 deletion
common.inc.php
index.php
+8
-24
8 additions, 24 deletions
index.php
modules/staticModule.php
+31
-0
31 additions, 0 deletions
modules/staticModule.php
with
40 additions
and
25 deletions
common.inc.php
+
1
−
1
View file @
bf61fc58
...
...
@@ -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'
];
...
...
This diff is collapsed.
Click to expand it.
index.php
+
8
−
24
View file @
bf61fc58
...
...
@@ -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
?>
This diff is collapsed.
Click to expand it.
modules/staticModule.php
0 → 100644
+
31
−
0
View file @
bf61fc58
<?
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
);
}
}
?>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment