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
Merge requests
!15
Resolve "Clean up class HTTPStatus"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Clean up class HTTPStatus"
17-clean-up-class-httpstatus
into
master
Overview
0
Commits
2
Pipelines
0
Changes
1
Merged
Stein Magne Bjorklund
requested to merge
17-clean-up-class-httpstatus
into
master
3 years ago
Overview
0
Commits
2
Pipelines
0
Changes
1
Expand
Closes #17
Edited
3 years ago
by
Stein Magne Bjorklund
0
0
Merge request reports
Compare
master
version 1
7e486edd
3 years ago
master (base)
and
latest version
latest version
bc29fc6e
2 commits,
3 years ago
version 1
7e486edd
1 commit,
3 years ago
1 file
+
16
−
20
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
classes/HTTPStatus.php
+
16
−
20
Options
<?php
<?php
declare
(
strict_types
=
1
);
namespace
uib\ub\loadspeakr
;
use
stdClass
;
class
HTTPStatus
final
class
HTTPStatus
{
public
static
function
send303
(
$uri
,
$ext
)
public
static
function
send303
(
$uri
,
$ext
)
:
void
{
header
(
"HTTP/1.0 303 See Other"
);
header
(
"Location: "
.
$uri
);
header
(
"Content-type: "
.
$ext
);
echo
HTTPStatus
::
_
getContent
(
"303"
,
$uri
);
echo
self
::
getContent
(
"303"
,
$uri
);
exit
(
0
);
}
public
static
function
send401
(
$uri
)
public
static
function
send401
(
$uri
)
:
void
{
header
(
"HTTP/1.0 401 Forbidden"
);
echo
HTTPStatus
::
_
getContent
(
"401"
,
$uri
);
echo
self
::
getContent
(
"401"
,
$uri
);
exit
(
0
);
}
public
static
function
send404
(
$uri
)
public
static
function
send404
(
$uri
)
:
void
{
header
(
"HTTP/1.0 404 Not Found"
);
$alt
=
"LODSPeaKr couldn't find the resource "
.
$uri
;
echo
HTTPStatus
::
_
getContent
(
"404"
,
$alt
);
echo
self
::
getContent
(
"404"
,
$alt
);
exit
(
0
);
}
public
static
function
send406
(
$uri
)
public
static
function
send406
(
$uri
)
:
void
{
header
(
"HTTP/1.0 406 Not Acceptable"
);
$alt
=
"LODSPeaKr can't return content acceptable according to the Accept headers sent in the request for "
.
$uri
;
echo
HTTPStatus
::
_
getContent
(
"406"
,
$alt
);
echo
self
::
getContent
(
"406"
,
$alt
);
exit
(
0
);
}
public
static
function
send500
(
$uri
)
public
static
function
send500
(
$uri
)
:
void
{
header
(
"HTTP/1.0 500 Internal Server Error"
);
$alt
=
"There was an internal error when processing "
.
$uri
;
echo
HTTPStatus
::
_
getContent
(
"500"
,
$alt
);
echo
self
::
getContent
(
"500"
,
$alt
);
exit
(
0
);
}
private
static
function
_
getContent
(
$n
,
$alt
)
private
static
function
getContent
(
$n
,
$alt
)
:
string
{
global
$conf
;
global
$lodspk
;
@@ -54,17 +54,13 @@ class HTTPStatus
$lodspk
[
'home'
]
=
$conf
[
'basedir'
];
$lodspk
[
'baseUrl'
]
=
$conf
[
'basedir'
];
$lodspk
[
'ns'
]
=
$conf
[
'ns'
];
$lodspk
[
'this'
][
'value'
]
=
$uri
;
$lodspk
[
'this'
][
'curie'
]
=
Utils
::
uri2curie
(
$uri
);
$lodspk
[
'this'
][
'local'
]
=
$localUri
;
$file
=
$conf
[
'httpStatus'
][
'directory'
]
.
"/"
.
$n
.
".template"
;
if
(
file_exists
(
$conf
[
'home'
]
.
$file
))
{
require_once
(
"Utils.php"
);
Utils
::
showView
(
$lodspk
,
new
stdClass
(),
$file
);
}
else
{
return
$alt
.
"
\n\n
"
;
return
''
;
}
return
$alt
.
"
\n\n
"
;
}
}
Loading