Warning: main(./includes/page_tail2.php): failed to open stream: No such file or directory in /home/tagrace/public_html/forum/modcp.php on line 432
Warning: main(): Failed opening './includes/page_tail2.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/tagrace/public_html/forum/modcp.php on line 432
Warning: main(./includes/page_tail2.php): failed to open stream: No such file or directory in /home/tagrace/public_html/forum/modcp.php on line 933
Warning: main(): Failed opening './includes/page_tail2.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/tagrace/public_html/forum/modcp.php on line 933
I am running
Powered by phpBB 2.0.4 © 2001, 2002 phpBB Group
My current modcp.php looks like this:
<?php
/**
* modcp.php
* -------------------
* begin : July 4, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id: modcp.php,v 1.71.2.18 2003/01/09 00:17:23 psotfx Exp $
*/
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
/**
* Moderator Control Panel
*
* From this 'Control Panel' the moderator of a forum will be able to do
* mass topic operations (locking/unlocking/moving/deleteing), and it will
* provide an interface to do quick locking/unlocking/moving/deleting of
* topics via the moderator operations buttons on all of the viewtopic pages.
*/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
// Obtain initial var settings
if (isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_URL])) {
$forum_id = (isset($HTTP_POST_VARS[POST_FORUM_URL])) ? intval($HTTP_POST_VARS[POST_FORUM_URL]) : intval($HTTP_GET_VARS[POST_FORUM_URL]);
} else {
$forum_id = '';
}
if (isset($HTTP_GET_VARS[POST_POST_URL]) || isset($HTTP_POST_VARS[POST_POST_URL])) {
$post_id = (isset($HTTP_POST_VARS[POST_POST_URL])) ? intval($HTTP_POST_VARS[POST_POST_URL]) : intval($HTTP_GET_VARS[POST_POST_URL]);
} else {
$post_id = '';
}
if (isset($HTTP_GET_VARS[POST_TOPIC_URL]) || isset($HTTP_POST_VARS[POST_TOPIC_URL])) {
$topic_id = (isset($HTTP_POST_VARS[POST_TOPIC_URL])) ? intval($HTTP_POST_VARS[POST_TOPIC_URL]) : intval($HTTP_GET_VARS[POST_TOPIC_URL]);
} else {
$topic_id = '';
}
$confirm = ($HTTP_POST_VARS['confirm']) ? true : 0;
// Continue var definitions
$start = (isset($HTTP_GET_VARS['start'])) ? intval($HTTP_GET_VARS['start']) : 0;
$delete = (isset($HTTP_POST_VARS['delete'])) ? true : false;
$move = (isset($HTTP_POST_VARS['move'])) ? true : false;
$lock = (isset($HTTP_POST_VARS['lock'])) ? true : false;
$unlock = (isset($HTTP_POST_VARS['unlock'])) ? true : false;
if (isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode'])) {
$mode = (isset($HTTP_POST_VARS['mode'])) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
} else {
if ($delete) {
$mode = 'delete';
} else if ($move) {
$mode = 'move';
} else if ($lock) {
$mode = 'lock';
} else if ($unlock) {
$mode = 'unlock';
} else {
$mode = '';
}
}
// session id check
if (!empty($HTTP_POST_VARS['sid']) || !empty($HTTP_GET_VARS['sid'])) {
$sid = (!empty($HTTP_POST_VARS['sid'])) ? $HTTP_POST_VARS['sid'] : $HTTP_GET_VARS['sid'];
} else {
$sid = '';
}
// Obtain relevant data
if (!empty($topic_id)) {
$sql = "SELECT f.forum_id, f.forum_name, f.forum_topics
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
WHERE t.topic_id = " . $topic_id . "
AND f.forum_id = t.forum_id";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
}
$topic_row = $db->sql_fetchrow($result);
$forum_topics = ($topic_row['forum_topics'] == 0) ? 1 : $topic_row['forum_topics'];
$forum_id = $topic_row['forum_id'];
$forum_name = $topic_row['forum_name'];
} else if (!empty($forum_id)) {
$sql = "SELECT forum_name, forum_topics
FROM " . FORUMS_TABLE . "
WHERE forum_id = " . $forum_id;
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_MESSAGE, 'Forum_not_exist');
}
$topic_row = $db->sql_fetchrow($result);
$forum_topics = ($topic_row['forum_topics'] == 0) ? 1 : $topic_row['forum_topics'];
$forum_name = $topic_row['forum_name'];
} else {
message_die(GENERAL_MESSAGE, 'Forum_not_exist');
}
// Start session management
$userdata = session_pagestart($user_ip, $forum_id);
init_userprefs($userdata);
// End session management
// session id check
if ($sid == '' || $sid != $userdata['session_id']) {
message_die(GENERAL_ERROR, 'Invalid_session');
}
// Check if user did or did not confirm
// If they did not, forward them to the last page they were on
if (isset($HTTP_POST_VARS['cancel'])) {
if ($topic_id) {
$redirect = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id";
} else if ($forum_id) {
$redirect = "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id";
} else {
$redirect = "index.$phpEx";
}
redirect(append_sid($redirect, true));
}
// Start auth check
$is_auth = auth(AUTH_ALL, $forum_id, $userdata);
if (!$is_auth['auth_mod']) {
message_die(GENERAL_MESSAGE, $lang['Not_Moderator'], $lang['Not_Authorised']);
}
// End Auth Check
// Do major work ...
switch ($mode) {
case 'delete':
if (!$is_auth['auth_delete']) {
message_die(MESSAGE, sprintf($lang['Sorry_auth_delete'], $is_auth['auth_delete_type']));
}
$page_title = $lang['Mod_CP'];
include($phpbb_root_path . 'includes/page_header.' . $phpEx);
if ($confirm) {
include($phpbb_root_path . 'includes/functions_search.' . $phpEx);
$topics = (isset($HTTP_POST_VARS['topic_id_list'])) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
$topic_id_sql = '';
for($i = 0; $i < count($topics); $i++) {
$topic_id_sql .= (($topic_id_sql != '') ? ', ' : '') . $topics[$i];
}
$sql = "SELECT poster_id, COUNT(post_id) AS posts
FROM " . POSTS_TABLE . "
WHERE topic_id IN ($topic_id_sql)
GROUP BY poster_id";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, 'Could not get poster id information', '', __LINE__, __FILE__, $sql);
}
$count_sql = array();
while ($row = $db->sql_fetchrow($result)) {
$count_sql[] = "UPDATE " . USERS_TABLE . "
SET user_posts = user_posts - " . $row['posts'] . "
WHERE user_id = " . $row['poster_id'];
}
$db->sql_freeresult($result);
if (sizeof($count_sql)) {
for($i = 0; $i < sizeof($count_sql); $i++) {
if (!$db->sql_query($count_sql[$i])) {
message_die(GENERAL_ERROR, 'Could not update user post count information', '', __LINE__, __FILE__, $sql);
}
}
}
$sql = "SELECT post_id
FROM " . POSTS_TABLE . "
WHERE topic_id IN ($topic_id_sql)";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, 'Could not get post id information', '', __LINE__, __FILE__, $sql);
}
$post_id_sql = '';
while ($row = $db->sql_fetchrow($result)) {
$post_id_sql .= (($post_id_sql != '') ? ', ' : '') . $row['post_id'];
}
$db->sql_freeresult($result);
$sql = "SELECT vote_id
FROM " . VOTE_DESC_TABLE . "
WHERE topic_id IN ($topic_id_sql)";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, 'Could not get vote id information', '', __LINE__, __FILE__, $sql);
}
$vote_id_sql = '';
while ($row = $db->sql_fetchrow($result)) {
$vote_id_sql .= (($vote_id_sql != '') ? ', ' : '') . $row['vote_id'];
}
$db->sql_freeresult($result);
// Got all required info so go ahead and start deleting everything
$sql = "DELETE
FROM " . TOPICS_TABLE . "
WHERE topic_id IN ($topic_id_sql)
OR topic_moved_id IN ($topic_id_sql)";
if (!$db->sql_query($sql, BEGIN_TRANSACTION)) {
message_die(GENERAL_ERROR, 'Could not delete topics', '', __LINE__, __FILE__, $sql);
}
if ($post_id_sql != '') {
$sql = "DELETE
FROM " . POSTS_TABLE . "
WHERE post_id IN ($post_id_sql)";
if (!$db->sql_query($sql)) {
message_die(GENERAL_ERROR, 'Could not delete posts', '', __LINE__, __FILE__, $sql);
}
$sql = "DELETE
FROM " . POSTS_TEXT_TABLE . "
WHERE post_id IN ($post_id_sql)";
if (!$db->sql_query($sql)) {
message_die(GENERAL_ERROR, 'Could not delete posts text', '', __LINE__, __FILE__, $sql);
}
remove_search_post($post_id_sql);
delete_attachment(explode(', ', $post_id_sql));
}
if ($vote_id_sql != '') {
$sql = "DELETE
FROM " . VOTE_DESC_TABLE . "
WHERE vote_id IN ($vote_id_sql)";
if (!$db->sql_query($sql)) {
message_die(GENERAL_ERROR, 'Could not delete vote descriptions', '', __LINE__, __FILE__, $sql);
}
$sql = "DELETE
FROM " . VOTE_RESULTS_TABLE . "
WHERE vote_id IN ($vote_id_sql)";
if (!$db->sql_query($sql)) {
message_die(GENERAL_ERROR, 'Could not delete vote results', '', __LINE__, __FILE__, $sql);
}
$sql = "DELETE
FROM " . VOTE_USERS_TABLE . "
WHERE vote_id IN ($vote_id_sql)";
if (!$db->sql_query($sql)) {
message_die(GENERAL_ERROR, 'Could not delete vote users', '', __LINE__, __FILE__, $sql);
}
}
$sql = "DELETE
FROM " . TOPICS_WATCH_TABLE . "
WHERE topic_id IN ($topic_id_sql)";
if (!$db->sql_query($sql, END_TRANSACTION)) {
message_die(GENERAL_ERROR, 'Could not delete watched post list', '', __LINE__, __FILE__, $sql);
}
sync('forum', $forum_id);
if (!empty($topic_id)) {
$redirect_page = "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&sid=" . $userdata['session_id'];
$l_redirect = sprintf($lang['Click_return_forum'], '<a href="' . $redirect_page . '">', '</a>');
} else {
$redirect_page = "modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&sid=" . $userdata['session_id'];
$l_redirect = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
}
$template->assign_vars(array('META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
);
message_die(GENERAL_MESSAGE, $lang['Topics_Removed'] . '<br /><br />' . $l_redirect);
} else {
// Not confirmed, show confirmation message
if (empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id)) {
message_die(GENERAL_MESSAGE, $lang['None_selected']);
}
$hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="mode" value="' . $mode . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';
if (isset($HTTP_POST_VARS['topic_id_list'])) {
$topics = $HTTP_POST_VARS['topic_id_list'];
for($i = 0; $i < count($topics); $i++) {
$hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="' . intval($topics[$i]) . '" />';
}
} else {
$hidden_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />';
}
// Set template files
$template->set_filenames(array('confirm' => 'confirm_body.tpl')
);
$template->assign_vars(array('MESSAGE_TITLE' => $lang['Confirm'],
'MESSAGE_TEXT' => $lang['Confirm_delete_topic'],
'L_YES' => $lang['Yes'],
'L_NO' => $lang['No'],
'S_CONFIRM_ACTION' => append_sid("modcp.$phpEx"),
'S_HIDDEN_FIELDS' => $hidden_fields)
);
$template->pparse('confirm');
include($phpbb_root_path . 'includes/page_tail2.' . $phpEx);
}
break;
case 'move':
$page_title = $lang['Mod_CP'];
include($phpbb_root_path . 'includes/page_header.' . $phpEx);
if ($confirm) {
if (empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id)) {
message_die(GENERAL_MESSAGE, $lang['None_selected']);
}
$new_forum_id = $HTTP_POST_VARS['new_forum'];
$old_forum_id = $forum_id;
if ($new_forum_id != $old_forum_id) {
$topics = (isset($HTTP_POST_VARS['topic_id_list'])) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
$topic_list = '';
for($i = 0; $i < count($topics); $i++) {
$topic_list .= (($topic_list != '') ? ', ' : '') . intval($topics[$i]);
}
$sql = "SELECT *
FROM " . TOPICS_TABLE . "
WHERE topic_id IN ($topic_list)
AND topic_status <> " . TOPIC_MOVED;
if (!($result = $db->sql_query($sql, BEGIN_TRANSACTION))) {
message_die(GENERAL_ERROR, 'Could not select from topic table', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
for($i = 0; $i < count($row); $i++) {
$topic_id = $row[$i]['topic_id'];
if (isset($HTTP_POST_VARS['move_leave_shadow'])) {
// Insert topic in the old forum that indicates that the forum has moved.
$sql = "INSERT INTO " . TOPICS_TABLE . " (forum_id, topic_title, topic_poster, topic_time, topic_status, topic_type, topic_vote, topic_views, topic_replies, topic_first_post_id, topic_last_post_id, topic_moved_id)
VALUES ($old_forum_id, '" . addslashes(str_replace("\'", "''", $row[$i]['topic_title'])) . "', '" . str_replace("\'", "''", $row[$i]['topic_poster']) . "', " . $row[$i]['topic_time'] . ", " . TOPIC_MOVED . ", " . POST_NORMAL . ", " . $row[$i]['topic_vote'] . ", " . $row[$i]['topic_views'] . ", " . $row[$i]['topic_replies'] . ", " . $row[$i]['topic_first_post_id'] . ", " . $row[$i]['topic_last_post_id'] . ", $topic_id)";
if (!$db->sql_query($sql)) {
message_die(GENERAL_ERROR, 'Could not insert shadow topic', '', __LINE__, __FILE__, $sql);
}
}
$sql = "UPDATE " . TOPICS_TABLE . "
SET forum_id = $new_forum_id
WHERE topic_id = $topic_id";
if (!$db->sql_query($sql)) {
message_die(GENERAL_ERROR, 'Could not update old topic', '', __LINE__, __FILE__, $sql);
}
$sql = "UPDATE " . POSTS_TABLE . "
SET forum_id = $new_forum_id
WHERE topic_id = $topic_id";
if (!$db->sql_query($sql)) {
message_die(GENERAL_ERROR, 'Could not update post topic ids', '', __LINE__, __FILE__, $sql);
}
}
// Sync the forum indexes
sync('forum', $new_forum_id);
sync('forum', $old_forum_id);
$message = $lang['Topics_Moved'] . '<br /><br />';
} else {
$message = $lang['No_Topics_Moved'] . '<br /><br />';
}
if (!empty($topic_id)) {
$redirect_page = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&sid=" . $userdata['session_id'];
$message .= sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
} else {
$redirect_page = "modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&sid=" . $userdata['session_id'];
$message .= sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
}
$message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . "viewforum.$phpEx?" . POST_FORUM_URL . "=$old_forum_id&sid=" . $userdata['session_id'] . '">', '</a>');
$template->assign_vars(array('META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
);
message_die(GENERAL_MESSAGE, $message);
} else {
if (empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id)) {
message_die(GENERAL_MESSAGE, $lang['None_selected']);
}
$hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="mode" value="' . $mode . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';
if (isset($HTTP_POST_VARS['topic_id_list'])) {
$topics = $HTTP_POST_VARS['topic_id_list'];
for($i = 0; $i < count($topics); $i++) {
$hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="' . intval($topics[$i]) . '" />';
}
} else {
$hidden_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />';
}
// Set template files
$template->set_filenames(array('movetopic' => 'modcp_move.tpl')
);
$template->assign_vars(array('MESSAGE_TITLE' => $lang['Confirm'],
'MESSAGE_TEXT' => $lang['Confirm_move_topic'],
'L_MOVE_TO_FORUM' => $lang['Move_to_forum'],
'L_LEAVESHADOW' => $lang['Leave_shadow_topic'],
'L_YES' => $lang['Yes'],
'L_NO' => $lang['No'],
'S_FORUM_SELECT' => make_forum_select('new_forum', $forum_id),
'S_MODCP_ACTION' => append_sid("modcp.$phpEx"),
'S_HIDDEN_FIELDS' => $hidden_fields)
);
$template->pparse('movetopic');
include($phpbb_root_path . 'includes/page_tail2.' . $phpEx);
}
break;
case 'lock':
if (empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id)) {
message_die(GENERAL_MESSAGE, $lang['None_selected']);
}
$topics = (isset($HTTP_POST_VARS['topic_id_list'])) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
$topic_id_sql = '';
for($i = 0; $i < count($topics); $i++) {
$topic_id_sql .= (($topic_id_sql != '') ? ', ' : '') . $topics[$i];
}
$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_status = " . TOPIC_LOCKED . "
WHERE topic_id IN ($topic_id_sql)
AND topic_moved_id = 0";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
}
if (!empty($topic_id)) {
$redirect_page = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&sid=" . $userdata['session_id'];
$message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
} else {
$redirect_page = "modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&sid=" . $userdata['session_id'];
$message = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
}
$message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&sid=" . $userdata['session_id'] . '">', '</a>');
$template->assign_vars(array('META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
);
message_die(GENERAL_MESSAGE, $lang['Topics_Locked'] . '<br /><br />' . $message);
break;
case 'unlock':
if (empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id)) {
message_die(GENERAL_MESSAGE, $lang['None_selected']);
}
$topics = (isset($HTTP_POST_VARS['topic_id_list'])) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
$topic_id_sql = '';
for($i = 0; $i < count($topics); $i++) {
$topic_id_sql .= (($topic_id_sql != "") ? ', ' : '') . $topics[$i];
}
$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_status = " . TOPIC_UNLOCKED . "
WHERE topic_id IN ($topic_id_sql)
AND topic_moved_id = 0";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
}
if (!empty($topic_id)) {
$redirect_page = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&sid=" . $userdata['session_id'];
$message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
} else {
$redirect_page = "modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&sid=" . $userdata['session_id'];
$message = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
}
$message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&sid=" . $userdata['session_id'] . '">', '</a>');
$template->assign_vars(array('META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
);
message_die(GENERAL_MESSAGE, $lang['Topics_Unlocked'] . '<br /><br />' . $message);
break;
case 'split':
$page_title = $lang['Mod_CP'];
include($phpbb_root_path . 'includes/page_header.' . $phpEx);
if (isset($HTTP_POST_VARS['split_type_all']) || isset($HTTP_POST_VARS['split_type_beyond'])) {
$posts = $HTTP_POST_VARS['post_id_list'];
$post_id_sql = '';
for ($i = 0; $i < count($posts); $i++) {
$post_id_sql .= (($post_id_sql != '') ? ', ' : '') . intval($posts[$i]);
}
$sql = "SELECT post_id, poster_id, topic_id, post_time
FROM " . POSTS_TABLE . "
WHERE post_id IN ($post_id_sql)
ORDER BY post_time ASC";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, 'Could not get post information', '', __LINE__, __FILE__, $sql);
}
if ($row = $db->sql_fetchrow($result)) {
$first_poster = $row['poster_id'];
$topic_id = $row['topic_id'];
$post_time = $row['post_time'];
$user_id_sql = '';
$post_id_sql = '';
do {
$user_id_sql .= (($user_id_sql != '') ? ', ' : '') . intval($row['poster_id']);
$post_id_sql .= (($post_id_sql != '') ? ', ' : '') . intval($row['post_id']);;
} while ($row = $db->sql_fetchrow($result));
$post_subject = trim(htmlspecialchars($HTTP_POST_VARS['subject']));
if (empty($post_subject)) {
message_die(GENERAL_MESSAGE, $lang['Empty_subject']);
}
$new_forum_id = intval($HTTP_POST_VARS['new_forum_id']);
$topic_time = time();
$sql = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type)
VALUES ('" . str_replace("\'", "''", $post_subject) . "', $first_poster, " . $topic_time . ", $new_forum_id, " . TOPIC_UNLOCKED . ", " . POST_NORMAL . ")";
if (!($db->sql_query($sql, BEGIN_TRANSACTION))) {
message_die(GENERAL_ERROR, 'Could not insert new topic', '', __LINE__, __FILE__, $sql);
}
$new_topic_id = $db->sql_nextid();
// Update topic watch table, switch users whose posts
// have moved, over to watching the new topic
$sql = "UPDATE " . TOPICS_WATCH_TABLE . "
SET topic_id = $new_topic_id
WHERE topic_id = $topic_id
AND user_id IN ($user_id_sql)";
if (!$db->sql_query($sql)) {
message_die(GENERAL_ERROR, 'Could not update topics watch table', '', __LINE__, __FILE__, $sql);
}
$sql_where = (!empty($HTTP_POST_VARS['split_type_beyond'])) ? " post_time >= $post_time AND topic_id = $topic_id" : "post_id IN ($post_id_sql)";
$sql = "UPDATE " . POSTS_TABLE . "
SET topic_id = $new_topic_id, forum_id = $new_forum_id
WHERE $sql_where";
if (!$db->sql_query($sql, END_TRANSACTION)) {
message_die(GENERAL_ERROR, 'Could not update posts table', '', __LINE__, __FILE__, $sql);
}
sync('topic', $new_topic_id);
sync('topic', $topic_id);
sync('forum', $new_forum_id);
sync('forum', $forum_id);
$template->assign_vars(array('META' => '<meta http-equiv="refresh" content="3;url=' . "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&sid=" . $userdata['session_id'] . '">')
);
$message = $lang['Topic_split'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&sid=" . $userdata['session_id'] . '">', '</a>');
message_die(GENERAL_MESSAGE, $message);
}
} else {
// Set template files
$template->set_filenames(array('split_body' => 'modcp_split.tpl')
);
$sql = "SELECT u.username, p.*, pt.post_text, pt.bbcode_uid, pt.post_subject, p.post_username
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
WHERE p.topic_id = $topic_id
AND p.poster_id = u.user_id
AND p.post_id = pt.post_id
ORDER BY p.post_time ASC";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, 'Could not get topic/post information', '', __LINE__, __FILE__, $sql);
}
$s_hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" /><input type="hidden" name="mode" value="split" />';
if (($total_posts = $db->sql_numrows($result)) > 0) {
$postrow = $db->sql_fetchrowset($result);
$template->assign_vars(array('L_SPLIT_TOPIC' => $lang['Split_Topic'],
'L_SPLIT_TOPIC_EXPLAIN' => $lang['Split_Topic_explain'],
'L_AUTHOR' => $lang['Author'],
'L_MESSAGE' => $lang['Message'],
'L_SELECT' => $lang['Select'],
'L_SPLIT_SUBJECT' => $lang['Split_title'],
'L_SPLIT_FORUM' => $lang['Split_forum'],
'L_POSTED' => $lang['Posted'],
'L_SPLIT_POSTS' => $lang['Split_posts'],
'L_SUBMIT' => $lang['Submit'],
'L_SPLIT_AFTER' => $lang['Split_after'],
'L_POST_SUBJECT' => $lang['Post_subject'],
'L_MARK_ALL' => $lang['Mark_all'],
'L_UNMARK_ALL' => $lang['Unmark_all'],
'L_POST' => $lang['Post'],
'FORUM_NAME' => $forum_name,
'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"),
'S_SPLIT_ACTION' => append_sid("modcp.$phpEx"),
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_FORUM_SELECT' => make_forum_select("new_forum_id", false, $forum_id))
);
for($i = 0; $i < $total_posts; $i++) {
$post_id = $postrow[$i]['post_id'];
$poster_id = $postrow[$i]['user_id'];
$poster = $postrow[$i]['username'];
$post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']);
$bbcode_uid = $postrow[$i]['bbcode_uid'];
$message = $postrow[$i]['post_text'];
$post_subject = ($postrow[$i]['post_subject'] != '') ? $postrow[$i]['post_subject'] : $topic_title;
// If the board has HTML off but the post has HTML
// on then we process it, else leave it alone
if (!$board_config['allow_html']) {
if ($postrow[$i]['enable_html']) {
$message = preg_replace('#(<)([\/]?.*?)(>)#is', '<\\2>', $message);
}
}
if ($bbcode_uid != '') {
$message = ($board_config['allow_bbcode']) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
}
// Define censored word matches
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
if (count($orig_word)) {
$post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
$message = preg_replace($orig_word, $replacement_word, $message);
}
$message = make_clickable($message);
if ($board_config['allow_smilies'] && $postrow[$i]['enable_smilies']) {
$message = smilies_pass($message);
}
$message = str_replace("\n", '<br />', $message);
$row_color = (!($i % 2)) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = (!($i % 2)) ? $theme['td_class1'] : $theme['td_class2'];
$checkbox = ($i > 0) ? '<input type="checkbox" name="post_id_list[]" value="' . $post_id . '" />' : ' ';
$template->assign_block_vars('postrow', array('ROW_COLOR' => '#' . $row_color,
'ROW_CLASS' => $row_class,
'POSTER_NAME' => $poster,
'POST_DATE' => $post_date,
'POST_SUBJECT' => $post_subject,
'MESSAGE' => $message,
'POST_ID' => $post_id,
'S_SPLIT_CHECKBOX' => $checkbox)
);
}
$template->pparse('split_body');
}
}
break;
case 'ip':
$page_title = $lang['Mod_CP'];
include($phpbb_root_path . 'includes/page_header.' . $phpEx);
$rdns_ip_num = (isset($HTTP_GET_VARS['rdns'])) ? $HTTP_GET_VARS['rdns'] : "";
if (!$post_id) {
message_die(GENERAL_MESSAGE, $lang['No_such_post']);
}
// Set template files
$template->set_filenames(array('viewip' => 'modcp_viewip.tpl')
);
// Look up relevent data for this post
$sql = "SELECT poster_ip, poster_id
FROM " . POSTS_TABLE . "
WHERE post_id = $post_id";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, 'Could not get poster IP information', '', __LINE__, __FILE__, $sql);
}
if (!($post_row = $db->sql_fetchrow($result))) {
message_die(GENERAL_MESSAGE, $lang['No_such_post']);
}
$ip_this_post = decode_ip($post_row['poster_ip']);
$ip_this_post = ($rdns_ip_num == $ip_this_post) ? gethostbyaddr($ip_this_post) : $ip_this_post;
$poster_id = $post_row['poster_id'];
$template->assign_vars(array('L_IP_INFO' => $lang['IP_info'],
'L_THIS_POST_IP' => $lang['This_posts_IP'],
'L_OTHER_IPS' => $lang['Other_IP_this_user'],
'L_OTHER_USERS' => $lang['Users_this_IP'],
'L_LOOKUP_IP' => $lang['Lookup_IP'],
'L_SEARCH' => $lang['Search'],
'SEARCH_IMG' => $images['icon_search'],
'IP' => $ip_this_post,
'U_LOOKUP_IP' => "modcp.$phpEx?mode=ip&" . POST_POST_URL . "=$post_id&" . POST_TOPIC_URL . "=$topic_id&rdns=$ip_this_post&sid=" . $userdata['session_id'])
);
// Get other IP's this user has posted under
$sql = "SELECT poster_ip, COUNT(*) AS postings
FROM " . POSTS_TABLE . "
WHERE poster_id = $poster_id
GROUP BY poster_ip
ORDER BY " . ((SQL_LAYER == 'msaccess') ? 'COUNT(*)' : 'postings') . " DESC";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, 'Could not get IP information for this user', '', __LINE__, __FILE__, $sql);
}
if ($row = $db->sql_fetchrow($result)) {
$i = 0;
do {
if ($row['poster_ip'] == $post_row['poster_ip']) {
$template->assign_vars(array('POSTS' => $row['postings'] . ' ' . (($row['postings'] == 1) ? $lang['Post'] : $lang['Posts']))
);
continue;
}
$ip = decode_ip($row['poster_ip']);
$ip = ($rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') ? gethostbyaddr($ip) : $ip;
$row_color = (!($i % 2)) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = (!($i % 2)) ? $theme['td_class1'] : $theme['td_class2'];
$template->assign_block_vars('iprow', array('ROW_COLOR' => '#' . $row_color,
'ROW_CLASS' => $row_class,
'IP' => $ip,
'POSTS' => $row['postings'] . ' ' . (($row['postings'] == 1) ? $lang['Post'] : $lang['Posts']),
'U_LOOKUP_IP' => "modcp.$phpEx?mode=ip&" . POST_POST_URL . "=$post_id&" . POST_TOPIC_URL . "=$topic_id&rdns=" . $row['poster_ip'] . "&sid=" . $userdata['session_id'])
);
$i++;
} while ($row = $db->sql_fetchrow($result));
}
// Get other users who've posted under this IP
$sql = "SELECT u.user_id, u.username, COUNT(*) as postings
FROM " . USERS_TABLE . " u, " . POSTS_TABLE . " p
WHERE p.poster_id = u.user_id
AND p.poster_ip = '" . $post_row['poster_ip'] . "'
GROUP BY u.user_id, u.username
ORDER BY " . ((SQL_LAYER == 'msaccess') ? 'COUNT(*)' : 'postings') . " DESC";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, 'Could not get posters information based on IP', '', __LINE__, __FILE__, $sql);
}
if ($row = $db->sql_fetchrow($result)) {
$i = 0;
do {
$id = $row['user_id'];
$username = ($id == ANONYMOUS) ? $lang['Guest'] : $row['username'];
$row_color = (!($i % 2)) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = (!($i % 2)) ? $theme['td_class1'] : $theme['td_class2'];
$template->assign_block_vars('userrow', array('ROW_COLOR' => '#' . $row_color,
'ROW_CLASS' => $row_class,
'USERNAME' => $username,
'POSTS' => $row['postings'] . ' ' . (($row['postings'] == 1) ? $lang['Post'] : $lang['Posts']),
'L_SEARCH_POSTS' => sprintf($lang['Search_user_posts'], $username),
'U_PROFILE' => ($id == ANONYMOUS) ? "modcp.$phpEx?mode=ip&" . POST_POST_URL . "=" . $post_id . "&" . POST_TOPIC_URL . "=" . $topic_id . "&sid=" . $userdata['session_id'] : append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$id"),
'U_SEARCHPOSTS' => append_sid("search.$phpEx?search_author=" . urlencode($username) . "&showresults=topics"))
);
$i++;
} while ($row = $db->sql_fetchrow($result));
}
$template->pparse('viewip');
break;
default:
$page_title = $lang['Mod_CP'];
include($phpbb_root_path . 'includes/page_header.' . $phpEx);
$template->assign_vars(array('FORUM_NAME' => $forum_name,
'L_MOD_CP' => $lang['Mod_CP'],
'L_MOD_CP_EXPLAIN' => $lang['Mod_CP_explain'],
'L_SELECT' => $lang['Select'],
'L_DELETE' => $lang['Delete'],
'L_MOVE' => $lang['Move'],
'L_LOCK' => $lang['Lock'],
'L_UNLOCK' => $lang['Unlock'],
'L_TOPICS' => $lang['Topics'],
'L_REPLIES' => $lang['Replies'],
'L_LASTPOST' => $lang['Last_Post'],
'L_SELECT' => $lang['Select'],
'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"),
'S_HIDDEN_FIELDS' => '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />',
'S_MODCP_ACTION' => append_sid("modcp.$phpEx"))
);
$template->set_filenames(array('body' => 'modcp_body.tpl')
);
make_jumpbox('modcp.' . $phpEx);
// Define censored word matches
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
$sql = "SELECT t.*, u.username, u.user_id, p.post_time
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p
WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id
AND p.post_id = t.topic_last_post_id
ORDER BY t.topic_type DESC, p.post_time DESC
LIMIT $start, " . $board_config['topics_per_page'];
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
} while ($row = $db->sql_fetchrow($result)) {
$topic_title = '';
if ($row['topic_status'] == TOPIC_LOCKED) {
$folder_img = $images['folder_locked'];
$folder_alt = $lang['Topic_locked'];
} else {
// Start add - Global announcement MOD
if ( $row['topic_type'] == POST_GLOBAL_ANNOUNCE )
{
$folder_img = $images['folder_global_announce'];
$folder_alt = $lang['Global_announcement'];
}else
// End add - Global announcement MOD
if ($row['topic_type'] == POST_ANNOUNCE) {
$folder_img = $images['folder_announce'];
$folder_alt = $lang['Topic_Announcement'];
} else if ($row['topic_type'] == POST_STICKY) {
$folder_img = $images['folder_sticky'];
$folder_alt = $lang['Topic_Sticky'];
} else {
$folder_img = $images['folder'];
$folder_alt = $lang['No_new_posts'];
}
}
$topic_id = $row['topic_id'];
$topic_type = $row['topic_type'];
$topic_status = $row['topic_status'];
// Start add - Global announcement MOD
if ( $topic_type == POST_GLOBAL_ANNOUNCE )
{
$topic_type = $lang['Topic_global_announcement'] . ' ';
}else
// End add - Global announcement MOD
if ($topic_type == POST_ANNOUNCE) {
$topic_type = $lang['Topic_Announcement'] . ' ';
} else if ($topic_type == POST_STICKY) {
$topic_type = $lang['Topic_Sticky'] . ' ';
} else if ($topic_status == TOPIC_MOVED) {
$topic_type = $lang['Topic_Moved'] . ' ';
} else {
$topic_type = '';
}
if ($row['topic_vote']) {
$topic_type .= $lang['Topic_Poll'] . ' ';
}
$topic_title = $row['topic_title'];
if (count($orig_word)) {
$topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
}
$u_view_topic = "modcp.$phpEx?mode=split&" . POST_TOPIC_URL . "=$topic_id&sid=" . $userdata['session_id'];
$topic_replies = $row['topic_replies'];
$last_post_time = create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']);
$template->assign_block_vars('topicrow', array('U_VIEW_TOPIC' => $u_view_topic,
'TOPIC_FOLDER_IMG' => $folder_img,
'TOPIC_TYPE' => $topic_type,
'TOPIC_TITLE' => $topic_title,
'REPLIES' => $topic_replies,
'LAST_POST_TIME' => $last_post_time,
'TOPIC_ID' => $topic_id,
'TOPIC_ATTACHMENT_IMG' => topic_attachment_image($row['topic_attachment']),
'L_TOPIC_FOLDER_ALT' => $folder_alt)
);
}
$template->assign_vars(array('PAGINATION' => generate_pagination("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id", $forum_topics, $board_config['topics_per_page'], $start),
'PAGE_NUMBER' => sprintf($lang['Page_of'], (floor($start / $board_config['topics_per_page']) + 1), ceil($forum_topics / $board_config['topics_per_page'])),
'L_GOTO_PAGE' => $lang['Goto_page'])
);
$template->pparse('body');
break;
}
include($phpbb_root_path . 'includes/page_tail2.' . $phpEx);
?>
&&& lastly the one other problem is in the administration panel area.
Parse error: parse error, unexpected T_DOUBLE_ARROW in /home/tagrace/public_html/forum/admin/admin_ug_auth.php on line 79
My admin au auth php file looks like this:
[quote]<?php
/***************************************************************************
* admin_ug_auth.php
* -------------------
* begin : Saturday, Feb 13, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id: admin_ug_auth.php,v 1.13.2.5 2004/03/25 15:57:20 acydburn Exp $
*
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
define('IN_PHPBB', 1);
if( !empty($setmodules) )
{
$filename = basename(__FILE__);
$module['Users']['Permissions'] = $filename . "?mode=user";
$module['Groups']['Permissions'] = $filename . "?mode=group";
return;
}
//
// Load default header
//
$no_page_header = TRUE;
$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);
$params = array('mode' => 'mode', 'user_id' => POST_USERS_URL, 'group_id' => POST_GROUPS_URL, 'adv' => 'adv');
while( list($var, $param) = @each($params) )
{
if ( !empty($HTTP_POST_VARS[$param]) || !empty($HTTP_GET_VARS[$param]) )
{
$$var = ( !empty($HTTP_POST_VARS[$param]) ) ? $HTTP_POST_VARS[$param] : $HTTP_GET_VARS[$param];
}
else
{
$$var = "";
}
}
$user_id = intval($user_id);
$group_id = intval($group_id);
$adv = intval($adv);
$mode = htmlspecialchars($mode);
//
// Start program - define vars
//
$forum_auth_fields = array('auth_view', 'auth_read', 'auth_post', 'auth_reply', 'auth_edit', 'auth_delete', 'auth_sticky', 'auth_announce', 'auth_vote', 'auth_pollcreate', 'auth_globalannounce');
$auth_field_match = array(
'auth_view' => AUTH_VIEW,
'auth_read' => AUTH_READ,
'auth_post' => AUTH_POST,
'auth_reply' => AUTH_REPLY,
'auth_edit' => AUTH_EDIT,
'auth_delete' => AUTH_DELETE,
'auth_sticky' => AUTH_STICKY,
'auth_announce' => AUTH_ANNOUNCE,
// Start add - Global announcement MOD
'auth_globalannounce' => AUTH_GLOBALANNOUNCE);
// End add - Global announcement MOD
'auth_vote' => AUTH_VOTE,
'auth_pollcreate' => AUTH_POLLCREATE);
$field_names = array(
'auth_view' => $lang['View'],
'auth_read' => $lang['Read'],
'auth_post' => $lang['Post'],
'auth_reply' => $lang['Reply'],
'auth_edit' => $lang['Edit'],
'auth_delete' => $lang['Delete'],
'auth_sticky' => $lang['Sticky'],
'auth_announce' => $lang['Announce'],
'auth_vote' => $lang['Vote'],
'auth_pollcreate' => $lang['Pollcreate']);
// ---------------
// Start Functions
//
function check_auth($type, $key, $u_access, $is_admin)
{
$auth_user = 0;
if( count($u_access) )
{
for($j = 0; $j < count($u_access); $j++)
{
$result = 0;
switch($type)
{
case AUTH_ACL:
$result = $u_access[$j][$key];
case AUTH_MOD:
$result = $result || $u_access[$j]['auth_mod'];
case AUTH_ADMIN:
$result = $result || $is_admin;
break;
}
$auth_user = $auth_user || $result;
}
}
else
{
$auth_user = $is_admin;
}
return $auth_user;
}
//
// End Functions
// -------------
if ( isset($HTTP_POST_VARS['submit']) && ( ( $mode == 'user' && $user_id ) || ( $mode == 'group' && $group_id ) ) )
{
$user_level = '';
if ( $mode == 'user' )
{
//
// Get group_id for this user_id
//
$sql = "SELECT g.group_id, u.user_level
FROM " . USER_GROUP_TABLE . " ug, " . USERS_TABLE . " u, " . GROUPS_TABLE . " g
WHERE u.user_id = $user_id
AND ug.user_id = u.user_id
AND g.group_id = ug.group_id
AND g.group_single_user = " . TRUE;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not select info from user/user_group table', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$group_id = $row['group_id'];
$user_level = $row['user_level'];
$db->sql_freeresult($result);
}
//
// Carry out requests
//
if ( $mode == 'user' && $HTTP_POST_VARS['userlevel'] == 'admin' && $user_level != ADMIN )
{
//
// Make user an admin (if already user)
//
if ( $userdata['user_id'] != $user_id )
{
$sql = "UPDATE " . USERS_TABLE . "
SET user_level = " . ADMIN . "
WHERE user_id = $user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
}
$sql = "DELETE FROM " . AUTH_ACCESS_TABLE . "
WHERE group_id = $group_id
AND auth_mod = 0";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't delete auth access info", "", __LINE__, __FILE__, $sql);
}
//
// Delete any entries in auth_access, they are not required if user is becoming an
// admin
//
$sql = "UPDATE " . AUTH_ACCESS_TABLE . "
SET auth_view = 0, auth_read = 0, auth_post = 0, auth_reply = 0, auth_edit = 0, auth_delete = 0, auth_sticky = 0, auth_announce = 0
WHERE group_id = $group_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't update auth access", "", __LINE__, __FILE__, $sql);
}
}
$message = $lang['Auth_updated'] . '<br /><br />' . sprintf($lang['Click_return_userauth'], '<a href="' . append_sid("admin_ug_auth.$phpEx?mode=$mode") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>');
message_die(GENERAL_MESSAGE, $message);
}
else if ( $mode == 'user' && $HTTP_POST_VARS['userlevel'] == 'user' && $user_level == GLOBAL_MOD )
{
//
// Make global mod a user (if already global mod) ... ignore if you're trying
// to change yourself from a global mod to user!
//
if ( $userdata['user_id'] != $user_id )
{
$sql = "UPDATE " . AUTH_ACCESS_TABLE . "
SET auth_view = 0, auth_read = 0, auth_post = 0, auth_reply = 0, auth_edit = 0, auth_delete = 0, auth_sticky = 0, auth_announce = 0
WHERE group_id = $group_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update auth access', '', __LINE__, __FILE__, $sql);
}
//
// Update users level, reset to USER
//
$sql = "UPDATE " . USERS_TABLE . "
SET user_level = " . USER . "
WHERE user_id = $user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
}
}
$message = $lang['Auth_updated'] . '<br /><br />' . sprintf($lang['Click_return_userauth'], '<a href="' . append_sid("admin_ug_auth.$phpEx?mode=$mode") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>');
}
else if ( $mode == 'user' && $HTTP_POST_VARS['userlevel'] == 'global_mod' && $user_level != GLOBAL_MOD )
{
//
// Make user a global mod (if already user)
//
if ( $userdata['user_id'] != $user_id )
{
$sql = "UPDATE " . USERS_TABLE . "
SET user_level = " . GLOBAL_MOD . "
WHERE user_id = $user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
}
$sql = "DELETE FROM " . AUTH_ACCESS_TABLE . "
WHERE group_id = $group_id
AND auth_mod = 0";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't delete auth access info", "", __LINE__, __FILE__, $sql);
}
//
// Delete any entries in auth_access, they are not required if user is becoming a
// global mod
//
$sql = "UPDATE " . AUTH_ACCESS_TABLE . "
SET auth_view = 0, auth_read = 0, auth_post = 0, auth_reply = 0, auth_edit = 0, auth_delete = 0, auth_sticky = 0, auth_announce = 0
WHERE group_id = $group_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't update auth access", "", __LINE__, __FILE__, $sql);
}
}
$message = $lang['Auth_updated'] . '<br /><br />' . sprintf($lang['Click_return_userauth'], '<a href="' . append_sid("admin_ug_auth.$phpEx?mode=$mode") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>');
message_die(GENERAL_MESSAGE, $message);
}
else
{
if ( $mode == 'user' && $HTTP_POST_VARS['userlevel'] == 'user' && $user_level == ADMIN )
{
//
// Make admin a user (if already admin) ... ignore if you're trying
// to change yourself from an admin to user!
//
if ( $userdata['user_id'] != $user_id )
{
$sql = "UPDATE " . AUTH_ACCESS_TABLE . "
SET auth_view = 0, auth_read = 0, auth_post = 0, auth_reply = 0, auth_edit = 0, auth_delete = 0, auth_sticky = 0, auth_announce = 0
WHERE group_id = $group_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update auth access', '', __LINE__, __FILE__, $sql);
}
//
// Update users level, reset to USER
//
$sql = "UPDATE " . USERS_TABLE . "
SET user_level = " . USER . "
WHERE user_id = $user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
}
}
$message = $lang['Auth_updated'] . '<br /><br />' . sprintf($lang['Click_return_userauth'], '<a href="' . append_sid("admin_ug_auth.$phpEx?mode=$mode") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>');
}
else
{
$change_mod_list = ( isset($HTTP_POST_VARS['moderator']) ) ? $HTTP_POST_VARS['moderator'] : false;
if ( empty($adv) )
{
$change_acl_list = ( isset($HTTP_POST_VARS['private']) ) ? $HTTP_POST_VARS['private'] : false;
}
else
{
$change_acl_list = array();
for($j = 0; $j < count($forum_auth_fields); $j++)
{
$auth_field = $forum_auth_fields[$j];
while( list($forum_id, $value) = @each($HTTP_POST_VARS['private_' . $auth_field]) )
{
$change_acl_list[$forum_id][$auth_field] = $value;
}
}
}
$sql = "SELECT *
FROM " . FORUMS_TABLE . " f
ORDER BY forum_order";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't obtain forum information", "", __LINE__, __FILE__, $sql);
}
$forum_access = array();
while( $row = $db->sql_fetchrow($result) )
{
$forum_access[] = $row;
}
$db->sql_freeresult($result);
$sql = ( $mode == 'user' ) ? "SELECT aa.* FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE. " g WHERE ug.user_id = $user_id AND g.group_id = ug.group_id AND aa.group_id = ug.group_id AND g.group_single_user = " . TRUE : "SELECT * FROM " . AUTH_ACCESS_TABLE . " WHERE group_id = $group_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't obtain user/group permissions", "", __LINE__, __FILE__, $sql);
}
$auth_access = array();
while( $row = $db->sql_fetchrow($result) )
{
$auth_access[$row['forum_id']] = $row;
}
$db->sql_freeresult($result);
$forum_auth_action = array();
$update_acl_status = array();
$update_mod_status = array();
for($i = 0; $i < count($forum_access); $i++)
{
$forum_id = $forum_access[$i]['forum_id'];
if (
( isset($auth_access[$forum_id]['auth_mod']) && $change_mod_list[$forum_id]['auth_mod'] != $auth_access[$forum_id]['auth_mod'] ) ||
( !isset($auth_access[$forum_id]['auth_mod']) && !empty($change_mod_list[$forum_id]['auth_mod']) )
)
{
$update_mod_status[$forum_id] = $change_mod_list[$forum_id]['auth_mod'];
if ( !$update_mod_status[$forum_id] )
{
$forum_auth_action[$forum_id] = 'delete';
}
else if ( !isset($auth_access[$forum_id]['auth_mod']) )
{
$forum_auth_action[$forum_id] = 'insert';
}
else
{
$forum_auth_action[$forum_id] = 'update';
}
}
for($j = 0; $j < count($forum_auth_fields); $j++)
{
$auth_field = $forum_auth_fields[$j];
if( $forum_access[$i][$auth_field] == AUTH_ACL && isset($change_acl_list[$forum_id][$auth_field]) )
{
if ( ( empty($auth_access[$forum_id]['auth_mod']) &&
( isset($auth_access[$forum_id][$auth_field]) && $change_acl_list[$forum_id][$auth_field] != $auth_access[$forum_id][$auth_field] ) ||
( !isset($auth_access[$forum_id][$auth_field]) && !empty($change_acl_list[$forum_id][$auth_field]) ) ) ||
!empty($update_mod_status[$forum_id])
)
{
$update_acl_status[$forum_id][$auth_field] = ( !empty($update_mod_status[$forum_id]) ) ? 0 : $change_acl_list[$forum_id][$auth_field];
if ( isset($auth_access[$forum_id][$auth_field]) && empty($update_acl_status[$forum_id][$auth_field]) && $forum_auth_action[$forum_id] != 'insert' && $forum_auth_action[$forum_id] != 'update' )
{
$forum_auth_action[$forum_id] = 'delete';
}
else if ( !isset($auth_access[$forum_id][$auth_field]) && !( $forum_auth_action[$forum_id] == 'delete' && empty($update_acl_status[$forum_id][$auth_field]) ) )
{
$forum_auth_action[$forum_id] = 'insert';
}
else if ( isset($auth_access[$forum_id][$auth_field]) && !empty($update_acl_status[$forum_id][$auth_field]) )
{
$forum_auth_action[$forum_id] = 'update';
}
}
else if ( ( empty($auth_access[$forum_id]['auth_mod']) &&
( isset($auth_access[$forum_id][$auth_field]) && $change_acl_list[$forum_id][$auth_field] == $auth_access[$forum_id][$auth_field] ) ) && $forum_auth_action[$forum_id] == 'delete' )
{
$forum_auth_action[$forum_id] = 'update';
}
}
}
}
//
// Checks complete, make updates to DB
//
$delete_sql = '';
while( list($forum_id, $action) = @each($forum_auth_action) )
{
if ( $action == 'delete' )
{
$delete_sql .= ( ( $delete_sql != '' ) ? ', ' : '' ) . $forum_id;
}
else
{
if ( $action == 'insert' )
{
$sql_field = '';
$sql_value = '';
while ( list($auth_type, $value) = @each($update_acl_status[$forum_id]) )
{
$sql_field .= ( ( $sql_field != '' ) ? ', ' : '' ) . $auth_type;
$sql_value .= ( ( $sql_value != '' ) ? ', ' : '' ) . $value;
}
$sql_field .= ( ( $sql_field != '' ) ? ', ' : '' ) . 'auth_mod';
$sql_value .= ( ( $sql_value != '' ) ? ', ' : '' ) . ( ( !isset($update_mod_status[$forum_id]) ) ? 0 : $update_mod_status[$forum_id]);
$sql = "INSERT INTO " . AUTH_ACCESS_TABLE . " (forum_id, group_id, $sql_field)
VALUES ($forum_id, $group_id, $sql_value)";
}
else
{
$sql_values = '';
while ( list($auth_type, $value) = @each($update_acl_status[$forum_id]) )
{
$sql_values .= ( ( $sql_values != '' ) ? ', ' : '' ) . $auth_type . ' = ' . $value;
}
$sql_values .= ( ( $sql_values != '' ) ? ', ' : '' ) . 'auth_mod = ' . ( ( !isset($update_mod_status[$forum_id]) ) ? 0 : $update_mod_status[$forum_id]);
$sql = "UPDATE " . AUTH_ACCESS_TABLE . "
SET $sql_values
WHERE group_id = $group_id
AND forum_id = $forum_id";
}
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't update private forum permissions", "", __LINE__, __FILE__, $sql);
}
}
}
if ( $delete_sql != '' )
{
$sql = "DELETE FROM " . AUTH_ACCESS_TABLE . "
WHERE group_id = $group_id
AND forum_id IN ($delete_sql)";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't delete permission entries", "", __LINE__, __FILE__, $sql);
}
}
$l_auth_return = ( $mode == 'user' ) ? $lang['Click_return_userauth'] : $lang['Click_return_groupauth'];
$message = $lang['Auth_updated'] . '<br /><br />' . sprintf($l_auth_return, '<a href="' . append_sid("admin_ug_auth.$phpEx?mode=$mode") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>');
}
//
// Update user level to mod for appropriate users
//
$sql = "SELECT u.user_id
FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . USERS_TABLE . " u
WHERE ug.group_id = aa.group_id
AND u.user_id = ug.user_id
AND u.user_level NOT IN (" . MOD . ", " . GLOBAL_MOD . ", " . ADMIN . ")
GROUP BY u.user_id
HAVING SUM(aa.auth_mod) > 0";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't obtain user/group permissions", "", __LINE__, __FILE__, $sql);
}
$set_mod = '';
while( $row = $db->sql_fetchrow($result) )
{
$set_mod .= ( ( $set_mod != '' ) ? ', ' : '' ) . $row['user_id'];
}
$db->sql_freeresult($result);
//
// Update user level to user for appropriate users
//
switch ( SQL_LAYER )
{
case 'postgresql':
$sql = "SELECT u.user_id
FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug, " . AUTH_ACCESS_TABLE . " aa
WHERE ug.user_id = u.user_id
AND aa.group_id = ug.group_id
AND u.user_level NOT IN (" . USER . ", " . GLOBAL_MOD . ", " . ADMIN . ")
GROUP BY u.user_id
HAVING SUM(aa.auth_mod) = 0
UNION (
SELECT u.user_id
FROM " . USERS_TABLE . " u
WHERE NOT EXISTS (
SELECT aa.auth_mod
FROM " . USER_GROUP_TABLE . " ug, " . AUTH_ACCESS_TABLE . " aa
WHERE ug.user_id = u.user_id
AND aa.group_id = ug.group_id
)
AND u.user_level NOT IN (" . USER . ", " . GLOBAL_MOD . ", " . ADMIN . ")
GROUP BY u.user_id
)";
break;
case 'oracle':
$sql = "SELECT u.user_id
FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug, " . AUTH_ACCESS_TABLE . " aa
WHERE ug.user_id = u.user_id(+)
AND aa.group_id = ug.group_id(+)
AND u.user_level NOT IN (" . USER . ", " . GLOBAL_MOD . ", " . ADMIN . ")
GROUP BY u.user_id
HAVING SUM(aa.auth_mod) = 0";
break;
default:
$sql = "SELECT u.user_id
FROM ( ( " . USERS_TABLE . " u
LEFT JOIN " . USER_GROUP_TABLE . " ug ON ug.user_id = u.user_id )
LEFT JOIN " . AUTH_ACCESS_TABLE . " aa ON aa.group_id = ug.group_id )
WHERE u.user_level NOT IN (" . USER . ", " . GLOBAL_MOD . ", " . ADMIN . ")
GROUP BY u.user_id
HAVING SUM(aa.auth_mod) = 0";
break;
}
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't obtain user/group permissi

