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
6ef4a5b3
Commit
6ef4a5b3
authored
3 years ago
by
Stein Magne Bjorklund
Browse files
Options
Downloads
Patches
Plain Diff
Reformat index.php to PSR-12 standard
parent
ac49ea17
No related branches found
No related tags found
1 merge request
!14
Resolve "Fully introduce namespace"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
index.php
+57
-57
57 additions, 57 deletions
index.php
with
57 additions
and
57 deletions
index.php
+
57
−
57
View file @
6ef4a5b3
...
...
@@ -10,34 +10,34 @@ use uib\ub\loadspeakr\Utils;
require_once
__DIR__
.
'/vendor/autoload.php'
;
//Import
if
(
isset
(
$_GET
[
'q'
])
&&
$_GET
[
'q'
]
==
'import'
){
include_once
(
'classes/Importer.php'
);
$imp
=
new
Importer
();
$imp
->
run
();
exit
(
0
);
if
(
isset
(
$_GET
[
'q'
])
&&
$_GET
[
'q'
]
==
'import'
)
{
include_once
(
'classes/Importer.php'
);
$imp
=
new
Importer
();
$imp
->
run
();
exit
(
0
);
}
//Test if LODSPeaKr is configured
if
(
!
file_exists
(
'settings.inc.php'
)){
echo
'Need to configure lodspeakr first. Please run "install.sh". Alternatively, you can <a href="import">import an existing application</a>'
;
exit
(
0
);
if
(
!
file_exists
(
'settings.inc.php'
))
{
echo
'Need to configure lodspeakr first. Please run "install.sh". Alternatively, you can <a href="import">import an existing application</a>'
;
exit
(
0
);
}
include_once
(
'common.inc.php'
);
//Debug output
$conf
[
'logfile'
]
=
null
;
if
(
$conf
[
'debug'
]){
include_once
(
'classes/Logging.php'
);
if
(
isset
(
$_GET
[
'q'
])
&&
$_GET
[
'q'
]
==
'logs'
){
Logging
::
init
();
exit
(
0
);
}
else
{
$conf
[
'logfile'
]
=
Logging
::
createLogFile
(
$_GET
[
'q'
]);
//error_reporting(E_ALL);
}
}
else
{
error_reporting
(
E_ERROR
);
if
(
$conf
[
'debug'
])
{
include_once
(
'classes/Logging.php'
);
if
(
isset
(
$_GET
[
'q'
])
&&
$_GET
[
'q'
]
==
'logs'
)
{
Logging
::
init
();
exit
(
0
);
}
else
{
$conf
[
'logfile'
]
=
Logging
::
createLogFile
(
$_GET
[
'q'
]);
//error_reporting(E_ALL);
}
}
else
{
error_reporting
(
E_ERROR
);
}
include_once
(
'classes/HTTPStatus.php'
);
...
...
@@ -55,60 +55,60 @@ $extension = Utils::getExtension($acceptContentType, $conf['http_accept']);
//Check content type is supported by LODSPeaKr
if
(
$acceptContentType
==
NULL
)
{
HTTPStatus
::
send406
(
$uri
);
if
(
$acceptContentType
==
null
)
{
HTTPStatus
::
send406
(
$uri
);
}
//Export
if
(
$conf
[
'export'
]
&&
$_GET
[
'q'
]
==
'export'
){
include_once
(
'settings.inc.php'
);
include_once
(
'classes/Exporter.php'
);
$exp
=
new
Exporter
();
header
(
'Content-Type: text/plain'
);
$exp
->
run
();
exit
(
0
);
if
(
$conf
[
'export'
]
&&
$_GET
[
'q'
]
==
'export'
)
{
include_once
(
'settings.inc.php'
);
include_once
(
'classes/Exporter.php'
);
$exp
=
new
Exporter
();
header
(
'Content-Type: text/plain'
);
$exp
->
run
();
exit
(
0
);
}
//Redirect to root URL if necessary
$uri
=
$conf
[
'basedir'
]
.
$_GET
[
'q'
];
$uri
=
$conf
[
'basedir'
]
.
$_GET
[
'q'
];
$localUri
=
$uri
;
if
(
$uri
==
$conf
[
'basedir'
]){
header
(
'Location: '
.
$conf
[
'root'
]);
exit
(
0
);
if
(
$uri
==
$conf
[
'basedir'
])
{
header
(
'Location: '
.
$conf
[
'root'
]);
exit
(
0
);
}
//Configure external URIs if necessary
$localUri
=
$conf
[
'basedir'
]
.
$_GET
[
'q'
];
$localUri
=
$conf
[
'basedir'
]
.
$_GET
[
'q'
];
$uri
=
Utils
::
getMirroredUri
(
$localUri
);
//Load Loadspeakr modules.
foreach
(
$conf
[
'modules'
][
'available'
]
as
$i
)
{
$className
=
$i
.
'Module'
;
$currentModule
=
$conf
[
'modules'
][
'directory'
]
.
$className
.
'.php'
;
if
(
!
is_file
(
$currentModule
))
{
HTTPStatus
::
send500
(
'<br/>Can\'t load or error in module <pre>'
.
$currentModule
.
'</pre>'
);
exit
(
1
);
}
require_once
(
$currentModule
);
$namespacedClassName
=
'uib\ub\loadspeakr\modules\\'
.
ucfirst
(
$className
);
$module
=
new
$namespacedClassName
();
$matching
=
$module
->
match
(
$uri
);
if
(
$matching
!=
FALSE
)
{
$module
->
execute
(
$matching
);
if
(
$conf
[
'logfile'
]
!=
null
)
{
fwrite
(
$conf
[
'logfile'
],
"]}"
);
fclose
(
$conf
[
'logfile'
]);
}
exit
(
0
);
}
foreach
(
$conf
[
'modules'
][
'available'
]
as
$i
)
{
$className
=
$i
.
'Module'
;
$currentModule
=
$conf
[
'modules'
][
'directory'
]
.
$className
.
'.php'
;
if
(
!
is_file
(
$currentModule
))
{
HTTPStatus
::
send500
(
'<br/>Can\'t load or error in module <pre>'
.
$currentModule
.
'</pre>'
);
exit
(
1
);
}
require_once
(
$currentModule
);
$namespacedClassName
=
'uib\ub\loadspeakr\modules\\'
.
ucfirst
(
$className
);
$module
=
new
$namespacedClassName
();
$matching
=
$module
->
match
(
$uri
);
if
(
$matching
!=
false
)
{
$module
->
execute
(
$matching
);
if
(
$conf
[
'logfile'
]
!=
null
)
{
fwrite
(
$conf
[
'logfile'
],
"]}"
);
fclose
(
$conf
[
'logfile'
]);
}
exit
(
0
);
}
}
HTTPStatus
::
send404
(
$uri
);
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