Permalink
Browse files

#620 - Added http status codes to various events

  • Loading branch information...
1 parent 700b11c commit 543eaa00a4a9101cfa34f86f3660b36cfc0d1772 @oldskool oldskool committed Apr 13, 2012
View
@@ -15,7 +15,7 @@
if ($pun_user['g_id'] != PUN_ADMIN && ($pun_user['g_moderator'] != '1' || $pun_user['g_mod_ban_users'] == '0'))
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// Load the admin_bans.php language file
require PUN_ROOT.'lang/'.$admin_language.'/admin_bans.php';
@@ -15,7 +15,7 @@
if ($pun_user['g_id'] != PUN_ADMIN)
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// Load the admin_categories.php language file
require PUN_ROOT.'lang/'.$admin_language.'/admin_categories.php';
View
@@ -15,7 +15,7 @@
if ($pun_user['g_id'] != PUN_ADMIN)
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// Load the admin_censoring.php language file
require PUN_ROOT.'lang/'.$admin_language.'/admin_censoring.php';
View
@@ -15,7 +15,7 @@
if ($pun_user['g_id'] != PUN_ADMIN)
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// Load the admin_forums.php language file
require PUN_ROOT.'lang/'.$admin_language.'/admin_forums.php';
View
@@ -15,7 +15,7 @@
if ($pun_user['g_id'] != PUN_ADMIN)
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// Load the admin_censoring.php language file
require PUN_ROOT.'lang/'.$admin_language.'/admin_groups.php';
View
@@ -15,7 +15,7 @@
if (!$pun_user['is_admmod'])
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// Load the admin_index.php language file
require PUN_ROOT.'lang/'.$admin_language.'/admin_index.php';
View
@@ -15,7 +15,7 @@
if (!$pun_user['is_admmod'])
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// The plugin to load should be supplied via GET
$plugin = isset($_GET['plugin']) ? $_GET['plugin'] : '';
@@ -25,7 +25,7 @@
// AP_ == Admins only, AMP_ == admins and moderators
$prefix = substr($plugin, 0, strpos($plugin, '_'));
if ($pun_user['g_moderator'] == '1' && $prefix == 'AP')
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// Make sure the file actually exists
if (!file_exists(PUN_ROOT.'plugins/'.$plugin))
@@ -17,7 +17,7 @@
if ($pun_user['g_id'] != PUN_ADMIN)
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// Load the admin_maintenance.php language file
require PUN_ROOT.'lang/'.$admin_language.'/admin_maintenance.php';
View
@@ -15,7 +15,7 @@
if ($pun_user['g_id'] != PUN_ADMIN)
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// Load the admin_options.php language file
require PUN_ROOT.'lang/'.$admin_language.'/admin_options.php';
@@ -15,7 +15,7 @@
if ($pun_user['g_id'] != PUN_ADMIN)
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// Load the admin_permissions.php language file
require PUN_ROOT.'lang/'.$admin_language.'/admin_permissions.php';
View
@@ -15,7 +15,7 @@
if ($pun_user['g_id'] != PUN_ADMIN)
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// Load the admin_ranks.php language file
require PUN_ROOT.'lang/'.$admin_language.'/admin_ranks.php';
View
@@ -15,7 +15,7 @@
if (!$pun_user['is_admmod'])
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// Load the admin_reports.php language file
require PUN_ROOT.'lang/'.$admin_language.'/admin_reports.php';
View
@@ -15,7 +15,7 @@
if (!$pun_user['is_admmod'])
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// Load the admin_users.php language file
require PUN_ROOT.'lang/'.$admin_language.'/admin_users.php';
@@ -257,7 +257,7 @@
else if (isset($_POST['move_users']) || isset($_POST['move_users_comply']))
{
if ($pun_user['g_id'] > PUN_ADMIN)
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
confirm_referrer('admin_users.php');
@@ -383,7 +383,7 @@
else if (isset($_POST['delete_users']) || isset($_POST['delete_users_comply']))
{
if ($pun_user['g_id'] > PUN_ADMIN)
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
confirm_referrer('admin_users.php');
@@ -532,7 +532,7 @@
else if (isset($_POST['ban_users']) || isset($_POST['ban_users_comply']))
{
if ($pun_user['g_id'] != PUN_ADMIN && ($pun_user['g_moderator'] != '1' || $pun_user['g_mod_ban_users'] == '0'))
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
confirm_referrer('admin_users.php');
View
@@ -11,17 +11,17 @@
if ($pun_user['g_read_board'] == '0')
- message($lang_common['No view']);
+ message($lang_common['No view'], false, '403 Forbidden');
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if ($id < 1)
- message($lang_common['Bad request']);
+ message($lang_common['Bad request'], false, '404 Not Found');
// Fetch some info about the post, the topic and the forum
$result = $db->query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.first_post_id, t.closed, p.posted, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
if (!$db->num_rows($result))
- message($lang_common['Bad request']);
+ message($lang_common['Bad request'], false, '404 Not Found');
$cur_post = $db->fetch_assoc($result);
@@ -40,7 +40,7 @@
$cur_post['poster_id'] != $pun_user['id'] ||
$cur_post['closed'] == '1') &&
!$is_admmod)
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// Load the delete.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/delete.php';
View
@@ -11,17 +11,17 @@
if ($pun_user['g_read_board'] == '0')
- message($lang_common['No view']);
+ message($lang_common['No view'], false, '403 Forbidden');
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if ($id < 1)
- message($lang_common['Bad request']);
+ message($lang_common['Bad request'], false, '404 Not Found');
// Fetch some info about the post, the topic and the forum
$result = $db->query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.posted, t.first_post_id, t.sticky, t.closed, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
if (!$db->num_rows($result))
- message($lang_common['Bad request']);
+ message($lang_common['Bad request'], false, '404 Not Found');
$cur_post = $db->fetch_assoc($result);
@@ -42,7 +42,7 @@
$cur_post['poster_id'] != $pun_user['id'] ||
$cur_post['closed'] == '1') &&
!$is_admmod)
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// Load the post.php/edit.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/post.php';
View
@@ -14,7 +14,7 @@
if ($pun_user['g_read_board'] == '0')
- message($lang_common['No view']);
+ message($lang_common['No view'], false, '403 Forbidden');
// Load the help.php language file
@@ -923,10 +923,15 @@ function paginate($num_pages, $cur_page, $link)
//
// Display a message
//
-function message($message, $no_back_link = false)
+function message($message, $no_back_link = false, $http_status = null)
{
global $db, $lang_common, $pun_config, $pun_start, $tpl_main, $pun_user;
+ // Did we receive a custom header?
+ if(!is_null($http_status)) {
+ header('HTTP/1.1 ' . $http_status);
+ }
+
if (!defined('PUN_HEADER'))
{
$page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_common['Info']);
View
@@ -11,7 +11,7 @@
if ($pun_user['g_read_board'] == '0')
- message($lang_common['No view']);
+ message($lang_common['No view'], false, '403 Forbidden');
// Load the index.php language file
View
@@ -49,7 +49,7 @@
else if ($action == 'markread')
{
if ($pun_user['is_guest'])
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
$db->query('UPDATE '.$db->prefix.'users SET last_visit='.$pun_user['logged'].' WHERE id='.$pun_user['id']) or error('Unable to update user last visit data', __FILE__, __LINE__, $db->error());
@@ -64,7 +64,7 @@
else if ($action == 'markforumread')
{
if ($pun_user['is_guest'])
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
$fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0;
if ($fid < 1)
@@ -81,7 +81,7 @@
else if (isset($_GET['email']))
{
if ($pun_user['is_guest'] || $pun_user['g_send_email'] == '0')
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
$recipient_id = intval($_GET['email']);
if ($recipient_id < 2)
View
@@ -15,7 +15,7 @@
if (isset($_GET['get_host']))
{
if (!$pun_user['is_admmod'])
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// Is get_host an IP address or a post ID?
if (@preg_match('%^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$%', $_GET['get_host']) || @preg_match('%^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$%', $_GET['get_host']))
@@ -28,7 +28,7 @@
$result = $db->query('SELECT poster_ip FROM '.$db->prefix.'posts WHERE id='.$get_host) or error('Unable to fetch post IP address', __FILE__, __LINE__, $db->error());
if (!$db->num_rows($result))
- message($lang_common['Bad request']);
+ message($lang_common['Bad request'], false, '404 Not Found');
$ip = $db->result($result);
}
@@ -43,15 +43,15 @@
// All other functions require moderator/admin access
$fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0;
if ($fid < 1)
- message($lang_common['Bad request']);
+ message($lang_common['Bad request'], false, '404 Not Found');
$result = $db->query('SELECT moderators FROM '.$db->prefix.'forums WHERE id='.$fid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
$moderators = $db->result($result);
$mods_array = ($moderators != '') ? unserialize($moderators) : array();
if ($pun_user['g_id'] != PUN_ADMIN && ($pun_user['g_moderator'] == '0' || !array_key_exists($pun_user['username'], $mods_array)))
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// Get topic/forum tracking data
if (!$pun_user['is_guest'])
@@ -66,12 +66,12 @@
{
$tid = intval($_GET['tid']);
if ($tid < 1)
- message($lang_common['Bad request']);
+ message($lang_common['Bad request'], false, '404 Not Found');
// Fetch some info about the topic
$result = $db->query('SELECT t.subject, t.num_replies, t.first_post_id, f.id AS forum_id, forum_name FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.id='.$fid.' AND t.id='.$tid.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
if (!$db->num_rows($result))
- message($lang_common['Bad request']);
+ message($lang_common['Bad request'], false, '404 Not Found');
$cur_topic = $db->fetch_assoc($result);
@@ -794,7 +794,7 @@
// Fetch some info about the forum
$result = $db->query('SELECT f.forum_name, f.redirect_url, f.num_topics, f.sort_by FROM '.$db->prefix.'forums AS f LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.id='.$fid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
if (!$db->num_rows($result))
- message($lang_common['Bad request']);
+ message($lang_common['Bad request'], false, '404 Not Found');
$cur_forum = $db->fetch_assoc($result);
View
@@ -11,13 +11,13 @@
if ($pun_user['g_read_board'] == '0')
- message($lang_common['No view']);
+ message($lang_common['No view'], false, '403 Forbidden');
$tid = isset($_GET['tid']) ? intval($_GET['tid']) : 0;
$fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0;
if ($tid < 1 && $fid < 1 || $tid > 0 && $fid > 0)
- message($lang_common['Bad request']);
+ message($lang_common['Bad request'], false, '404 Not Found');
// Fetch some info about the topic and/or the forum
if ($tid)
@@ -26,7 +26,7 @@
$result = $db->query('SELECT f.id, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics FROM '.$db->prefix.'forums AS f LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.id='.$fid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
if (!$db->num_rows($result))
- message($lang_common['Bad request']);
+ message($lang_common['Bad request'], false, '404 Not Found');
$cur_posting = $db->fetch_assoc($result);
$is_subscribed = $tid && $cur_posting['is_subscribed'];
@@ -47,7 +47,7 @@
($fid && (($cur_posting['post_topics'] == '' && $pun_user['g_post_topics'] == '0') || $cur_posting['post_topics'] == '0')) ||
(isset($cur_posting['closed']) && $cur_posting['closed'] == '1')) &&
!$is_admmod)
- message($lang_common['No permission']);
+ message($lang_common['No permission'], false, '403 Forbidden');
// Load the post.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/post.php';
@@ -439,11 +439,11 @@
{
$qid = intval($_GET['qid']);
if ($qid < 1)
- message($lang_common['Bad request']);
+ message($lang_common['Bad request'], false, '404 Not Found');
$result = $db->query('SELECT poster, message FROM '.$db->prefix.'posts WHERE id='.$qid.' AND topic_id='.$tid) or error('Unable to fetch quote info', __FILE__, __LINE__, $db->error());
if (!$db->num_rows($result))
- message($lang_common['Bad request']);
+ message($lang_common['Bad request'], false, '404 Not Found');
list($q_poster, $q_message) = $db->fetch_row($result);
Oops, something went wrong. Retry.

0 comments on commit 543eaa0

Please sign in to comment.