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
7db5081f
Commit
7db5081f
authored
12 years ago
by
alvaro
Browse files
Options
Downloads
Patches
Plain Diff
Added session
parent
7dd5c0c6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
classes/HTTPStatus.php
+6
-0
6 additions, 0 deletions
classes/HTTPStatus.php
classes/modules/sessionModule.php
+83
-0
83 additions, 0 deletions
classes/modules/sessionModule.php
common.inc.php
+11
-0
11 additions, 0 deletions
common.inc.php
with
100 additions
and
0 deletions
classes/HTTPStatus.php
+
6
−
0
View file @
7db5081f
...
...
@@ -9,6 +9,12 @@ class HTTPStatus{
echo
$uri
.
"
\n\n
"
;
exit
(
0
);
}
public
static
function
send401
(
$msg
){
header
(
"HTTP/1.0 401 Forbidden"
);
echo
$msg
;
exit
(
0
);
}
public
static
function
send404
(
$uri
){
header
(
"HTTP/1.0 404 Not Found"
);
...
...
This diff is collapsed.
Click to expand it.
classes/modules/sessionModule.php
0 → 100644
+
83
−
0
View file @
7db5081f
<?
require_once
(
'abstractModule.php'
);
class
SessionModule
extends
abstractModule
{
//Session module
private
$sessionUri
=
"session"
;
public
function
match
(
$uri
){
global
$conf
;
global
$localUri
;
global
$lodspk
;
$method
=
ucwords
(
$_SERVER
[
'REQUEST_METHOD'
]);
$uriSegment
=
str_replace
(
$conf
[
'basedir'
],
''
,
$localUri
);
//Check if looking for session validation
if
(
$uriSegment
===
$this
->
sessionUri
){
//GET will return the form
if
(
$method
==
"GET"
){
$this
->
showSessionForm
();
return
true
;
}
//POST will take the data and validate it
if
(
$method
==
"POST"
){
if
(
$this
->
validateAuthentication
(
$_POST
)){
session_start
();
$_SESSION
[
'lodspk'
]
=
1
;
Utils
::
send303
(
$conf
[
'basedir'
],
''
);
}
else
{
Utils
::
send401
(
"Authentication not valid."
);
return
true
;
}
}
}
else
{
session_start
();
if
(
isset
(
$_SESSION
[
'lodspk'
])){
return
false
;
}
else
{
Utils
::
send303
(
$conf
[
'basedir'
]
.
$this
->
sessionUri
,
''
);
return
true
;
}
}
}
public
function
execute
(
$uri
){
global
$conf
;
global
$localUri
;
global
$uri
;
global
$acceptContentType
;
global
$endpoints
;
global
$lodspk
;
global
$firstResults
;
return
true
;
}
private
function
showSessionForm
(){
echo
"<html>
<head>
<title>Login</title>
</head>
<body>
<form action='"
.
$this
->
sessionUri
.
"' method='POST'>
<input name='user' type='text' />
<input name='password' type='password' /><br/>
<input name='submit' type='submit' />
</form>
</body>
</html>"
;
exit
(
0
);
}
private
function
validateAuthentication
(
$data
){
global
$conf
;
if
(
isset
(
$conf
[
'session'
][
'user'
])
&&
isset
(
$conf
[
'session'
][
'password'
])){
if
(
$data
[
'user'
]
==
$conf
[
'session'
][
'user'
]
&&
$data
[
'password'
]
==
$conf
[
'session'
][
'password'
]){
return
true
;
}
return
false
;
}
return
false
;
}
}
?>
This diff is collapsed.
Click to expand it.
common.inc.php
+
11
−
0
View file @
7db5081f
...
...
@@ -48,11 +48,22 @@ $conf['type']['priorities']['rdfs:Resource'] = -1;
//Debug
$conf
[
'debug'
]
=
false
;
//Session module
//First version: really simple user/pass
$conf
[
'session'
][
'user'
]
=
'admin'
;
$conf
[
'session'
][
'password'
]
=
'admin'
;
//Modules: LODSPeaKr will try to match the requested URI
//using the modules in the following order
$conf
[
'modules'
]
=
array
();
$conf
[
'modules'
][
'directory'
]
=
'classes/modules/'
;
$conf
[
'modules'
][
'available'
]
=
array
(
'static'
,
'uri'
,
'type'
,
'service'
);
//Uncomment next line to enable sessions
//$conf['modules']['available'] = array('session', 'static','uri', 'type', 'service');
global
$lodspk
;
include_once
(
'settings.inc.php'
);
$conf
[
'view'
][
'standard'
][
'baseUrl'
]
=
$conf
[
'basedir'
];
...
...
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