Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
fb64ec5a
Commit
fb64ec5a
authored
4 years ago
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helper functions for HTTP errors
parent
af4c8fbb
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
9 deletions
+44
-9
tag.php
qa-include/pages/tag.php
+1
-1
qa-base.php
qa-include/qa-base.php
+35
-0
qa-blob.php
qa-include/qa-blob.php
+2
-2
qa-feed.php
qa-include/qa-feed.php
+2
-2
qa-image.php
qa-include/qa-image.php
+1
-1
qa-page-not-found.php
qa-include/qa-page-not-found.php
+1
-1
ExceptionHandler.php
qa-src/Exceptions/ExceptionHandler.php
+2
-2
No files found.
qa-include/pages/tag.php
View file @
fb64ec5a
...
...
@@ -57,7 +57,7 @@ if (count($questions) > 0) {
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'main/questions_tagged_x'
,
qa_html
(
$tag
));
}
else
{
$qa_content
[
'title'
]
=
qa_lang_html
(
'main/no_questions_found'
);
header
(
'HTTP/1.0 404 Not Found'
);
qa_404
(
);
}
if
(
isset
(
$userid
)
&&
isset
(
$tagword
))
{
...
...
This diff is collapsed.
Click to expand it.
qa-include/qa-base.php
View file @
fb64ec5a
...
...
@@ -1313,6 +1313,41 @@ function convert_to_bytes($unit, $value)
/**
* Issue a HTTP status code header.
* @param int $code
* @param string $message
* @return void
*/
function
qa_http_error
(
$code
,
$message
)
{
$protocol
=
isset
(
$_SERVER
[
'SERVER_PROTOCOL'
])
?
$_SERVER
[
'SERVER_PROTOCOL'
]
:
'HTTP/1.1'
;
$code
=
(
int
)
$code
;
header
(
"
$protocol
$code
$message
"
);
}
/**
* Issue a HTTP 404 header.
* @return void
*/
function
qa_404
()
{
qa_http_error
(
'404'
,
'Not Found'
);
}
/**
* Issue a HTTP 500 header.
* @return void
*/
function
qa_500
()
{
qa_http_error
(
'500'
,
'Internal Server Error'
);
}
/**
* Return true if we are responding to an HTTP GET request
* @return bool True if the request is GET
*/
...
...
This diff is collapsed.
Click to expand it.
qa-include/qa-blob.php
View file @
fb64ec5a
...
...
@@ -26,7 +26,7 @@
function
qa_blob_db_fail_handler
()
{
header
(
'HTTP/1.1 500 Internal Server Error'
);
qa_500
(
);
qa_exit
(
'error'
);
}
...
...
@@ -89,7 +89,7 @@ if (isset($blob) && isset($blob['content'])) {
echo
$blob
[
'content'
];
}
else
{
header
(
'HTTP/1.0 404 Not Found'
);
qa_404
(
);
}
$qa_db
->
disconnect
();
This diff is collapsed.
Click to expand it.
qa-include/qa-feed.php
View file @
fb64ec5a
...
...
@@ -42,7 +42,7 @@ require_once QA_INCLUDE_DIR . 'app/options.php';
*/
function
qa_feed_db_fail_handler
(
$type
,
$errno
=
null
,
$error
=
null
,
$query
=
null
)
{
header
(
'HTTP/1.1 500 Internal Server Error'
);
qa_500
(
);
echo
qa_lang_html
(
'main/general_error'
);
qa_exit
(
'error'
);
}
...
...
@@ -53,7 +53,7 @@ function qa_feed_db_fail_handler($type, $errno = null, $error = null, $query = n
*/
function
qa_feed_not_found
()
{
header
(
'HTTP/1.0 404 Not Found'
);
qa_404
(
);
echo
qa_lang_html
(
'misc/feed_not_found'
);
qa_exit
();
}
...
...
This diff is collapsed.
Click to expand it.
qa-include/qa-image.php
View file @
fb64ec5a
...
...
@@ -26,7 +26,7 @@
function
qa_image_db_fail_handler
()
{
header
(
'HTTP/1.1 500 Internal Server Error'
);
qa_500
(
);
qa_exit
(
'error'
);
}
...
...
This diff is collapsed.
Click to expand it.
qa-include/qa-page-not-found.php
View file @
fb64ec5a
...
...
@@ -27,7 +27,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
header
(
'HTTP/1.0 404 Not Found'
);
qa_404
(
);
qa_set_template
(
'not-found'
);
...
...
This diff is collapsed.
Click to expand it.
qa-src/Exceptions/ExceptionHandler.php
View file @
fb64ec5a
...
...
@@ -51,7 +51,7 @@ class ExceptionHandler
private
function
handlePageNotFoundException
(
PageNotFoundException
$exception
)
{
header
(
'HTTP/1.1 404 Not Found'
);
qa_404
(
);
$qa_content
=
$this
->
handleErrorMessageException
(
$exception
);
$qa_content
[
'suggest_next'
]
=
qa_html_suggest_qs_tags
(
qa_using_tags
());
...
...
@@ -61,7 +61,7 @@ class ExceptionHandler
private
function
handleMethodNotAllowedException
(
MethodNotAllowedException
$exception
)
{
header
(
'HTTP/1.1 405
Method Not Allowed'
);
qa_http_error
(
'405'
,
'
Method Not Allowed'
);
$qa_content
=
$this
->
handleErrorMessageException
(
$exception
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment