diff options
author | Paul S. Owen <psotfx@users.sourceforge.net> | 2003-05-02 15:50:11 +0000 |
---|---|---|
committer | Paul S. Owen <psotfx@users.sourceforge.net> | 2003-05-02 15:50:11 +0000 |
commit | c6888eb18e5862154297a870f348d60a7e608de7 (patch) | |
tree | af1970637400f4ba66085e7d22836301cda3b9e2 /phpBB | |
parent | 9def7a65e39cdd65b0d32e28888801c584917549 (diff) | |
download | forums-c6888eb18e5862154297a870f348d60a7e608de7.tar forums-c6888eb18e5862154297a870f348d60a7e608de7.tar.gz forums-c6888eb18e5862154297a870f348d60a7e608de7.tar.bz2 forums-c6888eb18e5862154297a870f348d60a7e608de7.tar.xz forums-c6888eb18e5862154297a870f348d60a7e608de7.zip |
Various updates, forum links, "improve" forum management, cleanups, blah blah, note the schema changes, note also that forum management may misbehave ... reports on wrong doings are welcome ... seem to be having problems with some mcp functions under apache/win32
git-svn-id: file:///svn/phpbb/trunk@3961 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
35 files changed, 1979 insertions, 1178 deletions
diff --git a/phpBB/adm/admin_ban.php b/phpBB/adm/admin_ban.php index 27143e2749..5afade6ff8 100644 --- a/phpBB/adm/admin_ban.php +++ b/phpBB/adm/admin_ban.php @@ -272,7 +272,7 @@ if (isset($_REQUEST['bansubmit'])) { $sql = "INSERT INTO " . BANLIST_TABLE . " ($type, ban_start, ban_end, ban_exclude, ban_reason) VALUES $sql"; - $result = $db->sql_query($sql); + $db->sql_query($sql); } if (!$ban_exclude) diff --git a/phpBB/adm/admin_board.php b/phpBB/adm/admin_board.php index 670a65a3db..45b3b7f01a 100644 --- a/phpBB/adm/admin_board.php +++ b/phpBB/adm/admin_board.php @@ -439,7 +439,11 @@ switch ($mode) <td class="row2"><input type="radio" name="board_email_form" value="1" <?php echo $board_email_form_yes; ?> /> <?php echo $user->lang['ENABLED']; ?> <input type="radio" name="board_email_form" value="0" <?php echo $board_email_form_no; ?> /> <?php echo $user->lang['DISABLED']; ?></td> </tr> <tr> - <td class="row1" width="50%"><?php echo $user->lang['ADMIN_EMAIL']; ?>: </td> + <td class="row1" width="50%"><?php echo $user->lang['CONTACT_EMAIL']; ?>: <br /><span class="gensmall"><?php echo $user->lang['CONTACT_EMAIL_EXPLAIN']; ?></span></td> + <td class="row2"><input type="text" size="25" maxlength="100" name="board_contact" value="<?php echo $new['board_contact']; ?>" /></td> + </tr> + <tr> + <td class="row1" width="50%"><?php echo $user->lang['ADMIN_EMAIL']; ?>: <br /><span class="gensmall"><?php echo $user->lang['ADMIN_EMAIL_EXPLAIN']; ?></span></td> <td class="row2"><input type="text" size="25" maxlength="100" name="board_email" value="<?php echo $new['board_email']; ?>" /></td> </tr> <tr> @@ -447,10 +451,6 @@ switch ($mode) <td class="row2"><textarea name="board_email_sig" rows="5" cols="30"><?php echo $new['board_email_sig']; ?></textarea></td> </tr> <tr> - <td class="row1" width="50%"><?php echo $user->lang['CONTACT_EMAIL']; ?>: <br /><span class="gensmall"><?php echo $user->lang['CONTACT_EMAIL_EXPLAIN']; ?></span></td> - <td class="row2"><input type="text" size="25" maxlength="100" name="board_contact" value="<?php echo $new['board_contact']; ?>" /></td> - </tr> - <tr> <td class="row1"><?php echo $user->lang['USE_SMTP']; ?>: <br /><span class="gensmall"><?php echo $user->lang['USE_SMTP_EXPLAIN']; ?></span></td> <td class="row2"><input type="radio" name="smtp_delivery" value="1" <?php echo $smtp_yes; ?> /> <?php echo $user->lang['YES']; ?> <input type="radio" name="smtp_delivery" value="0" <?php echo $smtp_no; ?> /> <?php echo $user->lang['NO']; ?></td> </tr> diff --git a/phpBB/adm/admin_forums.php b/phpBB/adm/admin_forums.php index 528c124649..4e4c92fa47 100644 --- a/phpBB/adm/admin_forums.php +++ b/phpBB/adm/admin_forums.php @@ -37,545 +37,454 @@ require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $phpEx); // Get mode -$mode = (isset($_REQUEST['mode'])) ? $_REQUEST['mode'] : ''; +$mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : ''; // Do we have permissions? switch ($mode) { case 'add': - if (!$auth->acl_get('a_forumadd')) - { - trigger_error($user->lang['NO_ADMIN']); - } - case 'del': - if (!$auth->acl_get('a_forumdel')) - { - trigger_error($user->lang['NO_ADMIN']); - } - + $acl = 'a_forumadd'; + break; + case 'delete': + $acl = 'a_forumdel'; + break; default: - if (!$auth->acl_get('a_forum')) - { - trigger_error($user->lang['NO_ADMIN']); - } + $acl = 'a_forum'; } -// Major routines -switch ($mode) +if (!$auth->acl_get($acl)) { - case 'move_up': - case 'move_down': - $show_index = TRUE; - $forum_id = intval($_GET['this_f']); - - $sql = 'SELECT parent_id, left_id, right_id - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql); - - if (!($row = $db->sql_fetchrow($result))) - { - trigger_error($user->lang['NO_FORUM']); - } - $db->sql_freeresult($result); - - extract($row); - - $forum_info = array($forum_id => $row); - - // Get the adjacent forum - $sql = 'SELECT forum_id, left_id, right_id - FROM ' . FORUMS_TABLE . " - WHERE parent_id = $parent_id"; - $sql .= ($mode == 'move_up') ? " AND right_id < $right_id ORDER BY right_id DESC" : " AND left_id > $left_id ORDER BY left_id ASC"; - $result = $db->sql_query_limit($sql, 1); - - if (!($row = $db->sql_fetchrow($result))) - { - // already on top or at bottom - break; - } - $db->sql_freeresult($result); - - if ($mode == 'move_up') - { - $up_id = $forum_id; - $down_id = $row['forum_id']; - } - else - { - $up_id = $row['forum_id']; - $down_id = $forum_id; - } - - $forum_info[$row['forum_id']] = $row; - $diff_up = $forum_info[$up_id]['right_id'] - $forum_info[$up_id]['left_id']; - $diff_down = $forum_info[$down_id]['right_id'] - $forum_info[$down_id]['left_id']; - - $forum_ids = array(); - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE left_id > ' . $forum_info[$up_id]['left_id'] . ' - AND right_id < ' . $forum_info[$up_id]['right_id']; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = $row['forum_id']; - } - $db->sql_freeresult($result); - - // Start transaction - $db->sql_transaction(); - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET left_id = left_id + ' . ($diff_up + 1) . ', right_id = right_id + ' . ($diff_up + 1) . ' - WHERE left_id > ' . $forum_info[$down_id]['left_id'] . ' - AND right_id < ' . $forum_info[$down_id]['right_id']; - $db->sql_query($sql); - - if (count($forum_ids)) - { - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET left_id = left_id - ' . ($diff_down + 1) . ', right_id = right_id - ' . ($diff_down + 1) . ' - WHERE forum_id IN (' . implode(', ', $forum_ids) . ')'; - $db->sql_query($sql); - } - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET left_id = ' . $forum_info[$down_id]['left_id'] . ', right_id = ' . ($forum_info[$down_id]['left_id'] + $diff_up) . ' - WHERE forum_id = ' . $up_id; - $db->sql_query($sql); - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET left_id = ' . ($forum_info[$up_id]['right_id'] - $diff_down) . ', right_id = ' . $forum_info[$up_id]['right_id'] . ' - WHERE forum_id = ' . $down_id; - $db->sql_query($sql); - - $db->sql_transaction('commit'); - break; + trigger_error($user->lang['NO_ADMIN']); +} - case 'create': - if (!trim($_POST['forum_name'])) - { - trigger_error('Cannot create a forum without a name'); // Needs to be a lang string - } - $parent_id = (!empty($_POST['parent_id'])) ? intval($_POST['parent_id']) : 0; +// Major routines +switch ($mode) +{ + case 'add': + case 'edit': - if ($parent_id) + $action = (isset($_POST['action'])) ? htmlspecialchars($_POST['action']) : ''; + $forum_id = (isset($_REQUEST['this_f'])) ? intval($_REQUEST['this_f']) : ((isset($_REQUEST['f'])) ? intval($_REQUEST['f']) : 0); + $parent_id = (isset($_REQUEST['parent_id'])) ? intval($_REQUEST['parent_id']) : 0; + + $forum_type = (isset($_POST['forum_type'])) ? intval($_POST['forum_type']) : FORUM_POST; + $forum_status = (isset($_POST['forum_status'])) ? intval($_POST['forum_status']) : ITEM_UNLOCKED; + $forum_name = (isset($_POST['forum_name'])) ? htmlspecialchars($_POST['forum_name']) : ''; + $forum_link = (isset($_POST['forum_link'])) ? htmlspecialchars($_POST['forum_link']) : ''; + $forum_link_track = (!empty($_POST['forum_link_track'])) ? 1 : 0; + $forum_desc = (isset($_POST['forum_desc'])) ? str_replace("\n", '<br />', $_POST['forum_desc']) : ''; + $forum_image = (isset($_POST['forum_image'])) ? htmlspecialchars($_POST['forum_image']) : ''; + $forum_style = (isset($_POST['forum_style'])) ? intval($_POST['forum_style']) : 0; + $display_on_index = (!empty($_POST['display_on_index'])) ? 1 : 0; + $forum_topics_per_page = (isset($_POST['topics_per_page'])) ? intval($_POST['topics_per_page']) : 0; + $enable_icons = (!empty($_POST['enable_icons'])) ? 1 : 0; + $enable_prune = (!empty($_POST['enable_prune'])) ? 1 : 0; + $prune_days = (isset($_POST['prune_days'])) ? intval($_POST['prune_days']) : 7; + $prune_freq = (isset($_POST['prune_freq'])) ? intval($_POST['prune_freq']) : 1; + $forum_password = (isset($_POST['forum_password'])) ? intval($_POST['forum_password']) : ''; + $forum_password_confirm = (isset($_POST['forum_password_confirm'])) ? intval($_POST['forum_password_confirm']) : ''; + + if (isset($_POST['update'])) { - $sql = 'SELECT left_id, right_id - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $parent_id"; - $result = $db->sql_query($sql); - - if (!($row = $db->sql_fetchrow($result))) + $error = array(); + if (!trim($_POST['forum_name'])) { - trigger_error('Parent does not exist', E_USER_ERROR); + $error[] = $user->lang['FORUM_NAME_EMPTY']; } - $db->sql_freeresult($result); - extract($row); - - $db->sql_query('UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id + 2, right_id = right_id + 2 - WHERE left_id > $right_id"); - - $db->sql_query('UPDATE ' . FORUMS_TABLE . " - SET right_id = right_id + 2 - WHERE $left_id BETWEEN left_id AND right_id"); + if (!empty($password) || !empty($password_confirm)) + { + if ($password != $password_confirm) + { + $error[] = $user->lang['FORUM_PASSWORD_MISMATCH']; + } + } - $left_id = $right_id; - ++$right_id; - } - else - { - $sql = 'SELECT MAX(right_id) AS right_id - FROM ' . FORUMS_TABLE; - $result = $db->sql_query($sql); + if ($prune_days < 0 || $prune_freq < 0) + { + $error[] = $user->lang['FORUM_DATA_NEGATIVE']; + } - $left_id = $db->sql_fetchfield('right_id', 0, $result) + 1; - $db->sql_freeresult($result); + // What are we going to do tonight Brain? The same thing we do everynight, + // try to take over the world ... or decide whether to continue update + // and if so, whether it's a new forum/cat/link or an existing one + if (sizeof($error)) + { + $error = implode('<br />', $error); + } + else if (!$forum_id) + { + if ($parent_id) + { + $sql = 'SELECT left_id, right_id + FROM ' . FORUMS_TABLE . " + WHERE forum_id = $parent_id"; + $result = $db->sql_query($sql); + + if (!($row = $db->sql_fetchrow($result))) + { + trigger_error('Parent does not exist', E_USER_ERROR); + } + $db->sql_freeresult($result); + + extract($row); + unset($row); + + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET left_id = left_id + 2, right_id = right_id + 2 + WHERE left_id > $right_id"; + $db->sql_query($sql); + + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET right_id = right_id + 2 + WHERE $left_id BETWEEN left_id AND right_id"; + $db->sql_query($sql); + + $left_id = $right_id; + ++$right_id; + } + else + { + $sql = 'SELECT MAX(right_id) AS right_id + FROM ' . FORUMS_TABLE; + $result = $db->sql_query($sql); - $right_id = $left_id + 1; - } + $left_id = $db->sql_fetchfield('right_id', 0, $result) + 1; + $db->sql_freeresult($result); - $sql = array( - 'parent_id' => $parent_id, - 'left_id' => $left_id, - 'right_id' => $right_id, - 'forum_status' => intval($_POST['forum_status']), - 'forum_postable' => (!empty($_POST['forum_postable'])) ? 1 : 0, - 'forum_name' => $_POST['forum_name'], - 'forum_desc' => $_POST['forum_desc'], - 'forum_style' => (!empty($_POST['forum_style'])) ? intval($_POST['forum_style']) : 'NULL', - 'enable_icons' => (!empty($_POST['enable_icons'])) ? 1 : 0, - 'enable_prune' => (!empty($_POST['prune_enable'])) ? 1 : 0, - 'prune_days' => intval($_POST['prune_days']), - 'prune_freq' => intval($_POST['prune_freq']) - ); - $db->sql_query('INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql)); - - $forum_id = $db->sql_nextid(); + $right_id = $left_id + 1; + } - // Redirect to permissions - redirect('adm/admin_permissions.' . $phpEx . $SID . '&mode=forums&f=' . $forum_id); + $sql = array( + 'parent_id' => $parent_id, + 'left_id' => $left_id, + 'right_id' => $right_id, + + 'forum_name' => $forum_name, + 'forum_desc' => $forum_desc, + 'forum_type' => $forum_type, + 'forum_status' => $forum_status, + 'forum_link' => $forum_link, + 'forum_link_track' => $forum_link_track, + 'forum_password' => $forum_password, + 'forum_topics_per_page' => $forum_topics_per_page, + 'forum_style' => $forum_style, + 'forum_image' => $forum_image, + 'display_on_index' => $display_on_index, + 'enable_icons' => $enable_icons, + 'enable_prune' => $enable_prune, + 'prune_days' => $prune_days, + 'prune_freq' => $prune_freq, + ); + + $sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql); + $db->sql_query($sql); + + $forum_id = $db->sql_nextid(); + + add_log('admin', 'LOG_FORUM_ADD', $forum_name); + + // Redirect to permissions + $message = $user->lang['FORUM_UPDATED'] . '<br /><br />' . sprintf($user->lang['REDIRECT_ACL'], "<a href=\"admin_permissions.$phpEx$SID&mode=forum&submit_usergroups=true&ug_type=forum&action=usergroups&f[forum][]=$forum_id\">", '</a>'); + trigger_error($message); - break; + } + else + { + $row = get_forum_info($forum_id); - case 'modify': - if (!($forum_id = intval($_POST['f']))) - { - trigger_error('No forum specified'); // lang string - } + if ($row['forum_type'] != $forum_type && $action) + { + if ($action == 'move' && $_POST['to_forum_id']) + { + move_forum_content($forum_id, $_POST['to_forum_id']); + } + elseif ($action == 'delete') + { + delete_forum_content($forum_id); + } + + $sql['forum_posts'] = 0; + $sql['forum_topics'] = 0; + } - $row = get_forum_info($forum_id); - $parent_id = intval($_POST['parent_id']); - $action = (!empty($_POST['action'])) ? $_POST['action'] : ''; + if ($row['parent_id'] != $parent_id) + { + move_forum($forum_id, $parent_id); + } + elseif ($row['forum_name'] != $forum_name) + { + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET forum_parents = '' + WHERE left_id > " . $row['left_id'] . ' + AND right_id < ' . $row['right_id']; + $db->sql_query($sql); + } - if (($row['parent_id'] != $parent_id) && ($parent_id != -1)) - { - move_forum($forum_id, $parent_id); - } - elseif ($row['forum_name'] != $_POST['forum_name']) - { - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET forum_parents = '' - WHERE left_id > " . $row['left_id'] . ' - AND right_id < ' . $row['right_id']; - $db->sql_query($sql); + $sql = array( + 'parent_id' => $parent_id, + + 'forum_name' => $forum_name, + 'forum_desc' => $forum_desc, + 'forum_type' => $forum_type, + 'forum_status' => $forum_status, + 'forum_link' => $forum_link, + 'forum_link_track' => $forum_link_track, + 'forum_topics_per_page' => $forum_topics_per_page, + 'forum_password' => $forum_password, + 'forum_style' => $forum_style, + 'forum_image' => $forum_image, + 'display_on_index' => $display_on_index, + 'enable_icons' => $enable_icons, + 'enable_prune' => $enable_prune, + 'prune_days' => $prune_days, + 'prune_freq' => $prune_freq, + ); + + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql) . " + WHERE forum_id = $forum_id"; + $db->sql_query($sql); + + add_log('admin', 'LOG_FORUM_EDIT', $forum_name); + + trigger_error($user->lang['FORUM_UPDATED']); + } } - $sql = array( - 'parent_id' => $parent_id, - 'forum_name' => (!empty($_POST['forum_name'])) ? $_POST['forum_name'] : $row['forum_name'], - 'forum_desc' => (!empty($_POST['forum_desc'])) ? $_POST['forum_desc'] : $row['forum_desc'], - 'forum_status' => intval($_POST['forum_status']), - 'forum_postable' => (!empty($_POST['is_postable'])) ? 1 : 0, - 'forum_style' => (!empty($_POST['forum_style'])) ? $_POST['forum_style'] : NULL, - 'forum_image' => (!empty($_POST['forum_image'])) ? $_POST['forum_image'] : '', - 'display_on_index' => (!empty($_POST['display_on_index'])) ? 1 : 0, - 'enable_icons' => (!empty($_POST['enable_icons'])) ? 1 : 0, - 'enable_prune' => (!empty($_POST['prune_enable'])) ? 1 : 0, - 'prune_days' => intval($_POST['prune_days']), - 'prune_freq' => intval($_POST['prune_freq']), - ); - - if (!empty($_POST['set_nonpostable']) && $action) + // Show form to create/modify a forum + if ($mode == 'edit') { - if ($action == 'move' && $_POST['to_forum_id']) + $l_title = $user->lang['EDIT_FORUM']; + + $forum_data = get_forum_info($forum_id); + if (!isset($_POST['forum_type'])) { - move_forum_content($forum_id, $_POST['to_forum_id']); + extract($forum_data); } - elseif ($action == 'delete') + else { - delete_forum_content($forum_id); + $old_forum_type = $forum_data['forum_type']; } + unset($forum_data); - $sql['forum_posts'] = 0; - $sql['forum_topics'] = 0; - } - - $db->sql_query('UPDATE ' . FORUMS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql) . " - WHERE forum_id = $forum_id"); - - trigger_error($user->lang['FORUM_UPDATED']); - - break; - - case 'remove': - - $action_subforums = (!empty($_POST['action_subforums'])) ? $_POST['action_subforums'] : ''; - $action_posts = (!empty($_POST['action_posts'])) ? $_POST['action_posts'] : ''; - - $row = get_forum_info(intval($_GET['f'])); - extract($row); - - if ($action_posts == 'delete') - { - delete_forum_content($forum_id); + $parents_list = make_forum_select($parent_id, $forum_id, false, false, false); + $forums_list = make_forum_select($parent_id, $forum_id, false, true, false); + } - elseif ($action_posts == 'move') + else { - if (empty($_POST['posts_to_id'])) - { - trigger_error($user->lang['No_destination_forum']); - } + $l_title = $user->lang['CREATE_FORUM']; - move_forum_content($forum_id, $_POST['posts_to_id']); + $forum_id = $parent_id; + $parents_list = make_forum_select($parent_id); } - if ($action_subforums == 'delete') + $forum_type_options = ''; + $forum_type_ary = array(FORUM_CAT => 'CAT', FORUM_POST => 'FORUM', FORUM_LINK => 'LINK'); + foreach ($forum_type_ary as $value => $lang) { - $forum_ids = array($forum_id); - $rows = get_forum_branch($forum_id, 'children', 'descending', FALSE); + $forum_type_options .= '<option value="' . $value . '"' . (($value == $forum_type) ? ' selected="selected"' : '') . '>' . $user->lang['TYPE_' . $lang] . '</option>'; + } - foreach ($rows as $row) - { - $forum_ids[] = $row['forum_id']; - delete_forum_content($row['forum_id']); - } + $styles_list = style_select($forum_style); - $diff = count($forum_ids) * 2; + $statuslist = '<option value="' . ITEM_UNLOCKED . '"' . (($forum_status == ITEM_UNLOCKED) ? ' selected="selected"' : '') . '>' . $user->lang['UNLOCKED'] . '</option><option value="' . ITEM_LOCKED . '"' . (($forum_status == ITEM_LOCKED) ? ' selected="selected"' : '') . '>' . $user->lang['LOCKED'] . '</option>'; - $sql = 'DELETE FROM ' . FORUMS_TABLE . ' - WHERE forum_id IN (' . implode(', ', $forum_ids) . ')'; - $db->sql_query($sql); - } - elseif ($action_subforums == 'move') - { - if (empty($_POST['subforums_to_id'])) - { - trigger_error($user->lang['No_destination_forum']); - } + $topic_icons_yes = ($enable_icons) ? 'checked="checked"' : ''; + $topic_icons_no = (!$enable_icons) ? 'checked="checked"' : ''; - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . " - WHERE parent_id = $forum_id"; - $result = $db->sql_query($sql); + $display_index_yes = ($display_on_index) ? 'checked="checked"' : ''; + $display_index_no = (!$display_on_index) ? 'checked="checked"' : ''; - while ($row = $db->sql_fetchrow($result)) - { - move_forum($row['forum_id'], $_POST['subforums_to_id']); - } - $db->sql_freeresult($result); + $prune_enable_yes = ($prune_enabled) ? 'checked="checked"' : ''; + $prune_enable_no = (!$prune_enabled) ? 'checked="checked"' : ''; - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET parent_id = ' . $_POST['subforums_to_id'] . " - WHERE parent_id = $forum_id"; - $db->sql_query($sql); + $forum_link_track_yes = ($forum_link_track) ? 'checked="checked"' : ''; + $forum_link_track_no = (!$forum_link_track) ? 'checked="checked"' : ''; - $diff = 2; + $navigation = '<a href="admin_forums.' . $phpEx . $SID . '">' . $user->lang['FORUM_INDEX'] . '</a>'; - $sql = 'DELETE FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - } - else + $forums_nav = get_forum_branch($forum_id, 'parents', 'descending'); + foreach ($forums_nav as $row) { - $diff = 2; - $db->sql_query('DELETE FROM ' . FORUMS_TABLE . " WHERE forum_id = $forum_id"); + $navigation .= ($row['forum_id'] == $forum_id) ? ' -> ' . $row['forum_name'] : ' -> <a href="admin_forums.' . $phpEx . $SID . '&f=' . $row['forum_id'] . '">' . $row['forum_name'] . '</a>'; } - // Resync tree - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET right_id = right_id - $diff - WHERE left_id < $right_id AND right_id > $right_id"; - $db->sql_query($sql); - - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id - $diff, right_id = right_id - $diff - WHERE left_id > $right_id"; - $db->sql_query($sql); - - trigger_error($user->lang['Forum_deleted']); - break; + page_header($l_title); - case 'sync': - sync('forum', 'forum_id', intval($_GET['this_f'])); - break; +?> - case 'add': - case 'edit': - // Show form to create/modify a forum - if ($mode == 'edit') - { - $forum_id = intval($_GET['this_f']); +<p><?php echo $user->lang['FORUM_ADMIN_EXPLAIN'] ?></p> - $row = get_forum_info($forum_id); - extract($row); +<h1><?php echo $l_title ?></h1> - $subforums_id = array(); - $subforums = get_forum_branch($forum_id, 'children'); - foreach ($subforums as $row) - { - $subforums_id[] = $row['forum_id']; - } +<p><?php echo $user->lang['FORUM_EDIT_EXPLAIN'] ?></p> - $parents_list = make_forums_list('all', $parent_id, $subforums_id); +<form method="post" name="edit" action="<?php echo "admin_forums.$phpEx$SID&mode=$mode" . (($forum_id) ? "&f=$forum_id" : ''); ?>"><table width="100%" cellspacing="2" cellpadding="2" border="0" align="center"> + <tr> + <td class="nav"><?php echo $navigation ?></td> + </tr> +</table> - $l_title = $user->lang['Edit_forum']; - $newmode = 'modify'; - $buttonvalue = $user->lang['Update']; - $prune_enabled = ($prune_enable) ? 'checked="checked" ' : ''; +<table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center"> + <tr> + <th colspan="2"><?php echo $user->lang['FORUM_SETTINGS'] ?></th> + </tr> +<?php - $forums_list = make_forums_list('forums', 0, $forum_id); - } - else + if (!empty($error)) { - $parent_id = (!empty($_POST['parent_id'])) ? $_POST['parent_id'] : 0; - $parents_list = make_forums_list('all', $parent_id); - - $l_title = $user->lang['Create_forum']; - $newmode = 'create'; - $buttonvalue = $user->lang['Create_forum']; - $forum_id = $parent_id; - $forum_desc = ''; - $forum_style = ''; - $forum_status = ITEM_UNLOCKED; - $forum_name = (!empty($_POST['forum_name'])) ? htmlspecialchars($_POST['forum_name']) : ''; - - $enable_icons = TRUE; +?> + <tr> + <td class="row3" colspan="2" align="center"><span style="color:red"><?php echo $error; ?></span></td> + </tr> +<?php - $prune_enabled = ''; - $prune_days = 7; - $prune_freq = 1; } - $styles_list = make_styles_list($forum_style); +?> + <tr> + <td class="row1" width="33%"><?php echo $user->lang['FORUM_TYPE'] ?>: </td> + <td class="row2"><select name="forum_type" onchange="this.form.submit();"><?php echo $forum_type_options; ?></select><?php + + if ($old_forum_type == FORUM_POST && $forum_type == FORUM_CAT) + { - $forumlocked = ($forum_status == ITEM_LOCKED) ? ' selected="selected"' : ''; - $forumunlocked = ($forum_status == ITEM_UNLOCKED) ? ' selected="selected"' : ''; +?><br /><input type="radio" name="action" value="delete" checked="checked" /> <?php echo $user->lang['Delete_all_posts'] ?> <input type="radio" name="action" value="move" /> <?php echo $user->lang['Move_posts_to'] ?> <select name="to_forum_id"><?php echo $forums_list ?></select><?php - $postable_checked = ($forum_postable) ? 'checked="checked" ' : ''; - $nonpostable_checked = (!$forum_postable) ? 'checked="checked" ' : ''; + } - $statuslist = '<option value="' . ITEM_UNLOCKED . '"' . $forumunlocked . '>' . $user->lang['Unlocked'] . "</option>\n"; - $statuslist .= '<option value="' . ITEM_LOCKED . '"' . $forumlocked . '>' . $user->lang['Locked'] . "</option>\n"; +?></td> + </tr> +<?php - page_header($l_title); + if ($forum_type == FORUM_POST) + { ?> -<h1><?php echo $l_title ?></h1> - -<p><?php echo $user->lang['Forum_edit_delete_explain'] ?></p> - -<form action="<?php echo "admin_forums.$phpEx$SID" ?>" method="post"><table class="bg" width="100%" cellpadding="4" cellspacing="1" border="0" align="center"> - <tr> - <th colspan="2"><?php echo $user->lang['General_settings'] ?></th> - </tr> - <tr> - <td class="row1"><?php echo $user->lang['Parent'] ?></td> - <td class="row2"><select name="parent_id"><option value="0"><?php echo $user->lang['No_parent'] ?></option><?php echo $parents_list ?></select></td> - </tr> - <tr> - <td class="row1"><?php echo $user->lang['Forum_name']; ?></td> - <td class="row2"><input class="post" type="text" size="25" name="forum_name" value="<?php echo $forum_name ?>" /></td> - </tr> <tr> - <td class="row1"><?php echo $user->lang['Forum_desc'] ?></td> - <td class="row2"><textarea class="post" rows="5" cols="45" wrap="virtual" name="forum_desc"><?php echo $forum_desc ?></textarea></td> + <td class="row1"><?php echo $user->lang['FORUM_STATUS'] ?>: </td> + <td class="row2"><select name="forum_status"><?php echo $statuslist ?></select></td> </tr> <?php - if ($forum_postable && $mode == 'edit') - { + } ?> <tr> - <td class="row1"><?php echo $user->lang['FORUM_TYPE'] ?></td> - <td class="row2"><table width="100%" cellspacing="0" cellpadding="0" border="0"> - <tr> - <td><input type="checkbox" name="set_nonpostable" /> <?php echo $user->lang['SET_NON_POSTABLE'] ?></td> - </tr> - <tr> - <td> <input type="radio" name="action" value="delete" checked="checked" /> <?php echo $user->lang['Delete_all_posts'] ?></td> - </tr> - <tr> - <td> <input type="radio" name="action" value="move" /> <?php echo $user->lang['Move_posts_to'] ?> <select name="to_forum_id"><?php echo $forums_list ?></select></td> - </tr> - </table></td> + <td class="row1" width="40%"><?php echo $user->lang['FORUM_PARENT'] ?>: </td> + <td class="row2"><select name="parent_id"><option value="0"><?php echo $user->lang['NO_PARENT'] ?></option><?php echo $parents_list ?></select></td> </tr> <?php - } - else - { + if ($forum_type == FORUM_LINK) + { ?> <tr> - <td class="row1"><?php echo $user->lang['FORUM_TYPE'] ?></td> - <td class="row2"><input type="radio" name="is_postable" value="1" <?php echo $postable_checked ?>/><?php echo $user->lang['IS_POSTABLE'] ?> <input type="radio" name="is_postable" value="0" <?php echo $nonpostable_checked ?>/><?php echo $user->lang['NOT_POSTABLE'] ?></td> + <td class="row1"><?php echo $user->lang['FORUM_LINK'] ?>: <br /><span class="gensmall"><?php echo $user->lang['FORUM_LINK_EXPLAIN']; ?></span></td> + <td class="row2"><input class="post" type="text" size="25" name="forum_link" value="<?php echo $forum_link; ?>" /></td> + </tr> + <tr> + <td class="row1"><?php echo $user->lang['FORUM_LINK_TRACK'] ?>: <br /><span class="gensmall"><?php echo $user->lang['FORUM_LINK_TRACK_EXPLAIN']; ?></span></td> + <td class="row2"><input type="radio" name="forum_link_track" value="1"<?php echo $forum_link_track_yes; ?> /> <?php echo $user->lang['YES']; ?> <input type="radio" name="forum_link_track" value="0"<?php echo $forum_link_track_no; ?> /> <?php echo $user->lang['NO']; ?></td> </tr> <?php - } + } ?> <tr> - <th colspan="2"><?php echo $user->lang['Forum_settings'] ?></th> + <td class="row1"><?php echo $user->lang['FORUM_NAME']; ?>: </td> + <td class="row2"><input class="post" type="text" size="25" name="forum_name" value="<?php echo $forum_name ?>" /></td> + </tr> + <tr> + <td class="row1"><?php echo $user->lang['FORUM_DESC'] ?>: <br /><span class="gensmall"><?php echo $user->lang['FORUM_DESC_EXPLAIN']; ?></span> </td> + <td class="row2"><textarea class="post" rows="5" cols="45" wrap="virtual" name="forum_desc"><?php echo htmlspecialchars(str_replace('<br />', "\n", $forum_desc)); ?></textarea></td> + </tr> + <tr> + <td class="row1"><?php echo $user->lang['FORUM_IMAGE']; ?>: <br /><span class="gensmall"><?php echo $user->lang['FORUM_IMAGE_EXPLAIN']; ?></span></td> + <td class="row2"><input class="post" type="text" size="25" name="forum_image" value="<?php echo $forum_image ?>" /><br /><?php + + if ($forum_image != '') + { + + echo '<img src="../' . $forum_image . '" alt="" />'; + + } + +?></td> </tr> <?php - if ($forum_postable || $mode == 'add') - { + if ($forum_type == FORUM_POST) + { ?> <tr> - <td class="row1"><?php echo $user->lang['FORUM_STATUS'] ?></td> - <td class="row2"><select name="forum_status"><?php echo $statuslist ?></select></td> + <td class="row1"><?php echo $user->lang['FORUM_STYLE'] ?>: </td> + <td class="row2"><select name="forum_style"><option value="0"><?php echo $user->lang['DEFAULT_STYLE'] ?></option><?php echo $styles_list ?></select></td> </tr> <tr> - <td class="row1"><?php echo $user->lang['FORUM_STYLE'] ?></td> - <td class="row2"><select name="forum_style"><option value="0"><?php echo $user->lang['Default_style'] ?></option><?php echo $styles_list ?></select></td> + <td class="row1"><?php echo $user->lang['ENABLE_TOPIC_ICONS'] ?>: </td> + <td class="row2"><input type="radio" name="enable_icons" value="1"<?php echo $topic_icons_yes; ?> /> <?php echo $user->lang['YES']; ?> <input type="radio" name="enable_icons" value="0"<?php echo $topic_icons_no; ?> /> <?php echo $user->lang['NO']; ?></td> </tr> - <tr> - <td class="row1"><?php echo $user->lang['OPTIONS'] ?></td> - <td class="row2"><table width="100%" cellspacing="0" cellpadding="0" border="0"> - <tr> - <td><input type="checkbox" name="enable_icons"<?php echo ((!empty($enable_icons)) ? 'checked="checked" ' : ' ') ?>/> <?php echo $user->lang['ENABLE_TOPIC_ICONS']; ?></td> - </tr> <?php - if ($mode == 'edit' && $parent_id > 0) - { - // if this forum is a subforum put the "display on index" checkbox - if ($parent_info = get_forum_info($parent_id)) + if ($mode == 'edit' && $parent_id > 0) { - if ($parent_info['parent_id'] > 0 || !$parent_info['forum_postable']) + // if this forum is a subforum put the "display on index" checkbox + if ($parent_info = get_forum_info($parent_id)) { + if ($parent_info['parent_id'] > 0 || $parent_info['forum_type'] == FORUM_CAT) + { ?> - <tr> - <td><input type="checkbox" name="display_on_index"<?php echo ((!empty($display_on_index)) ? 'checked="checked" ' : ' ') ?>/> <?php echo $user->lang['Display_on_index'] ?></td> - </tr> + <tr> + <td class="row1"><?php echo $user->lang['LIST_INDEX'] ?>: <br /><span class="gensmall"><?php echo $user->lang['LIST_INDEX_EXPLAIN']; ?></span></td> + <td class="row2"><input type="radio" name="display_on_index" value="1"<?php echo $display_index_yes; ?> /> <?php echo $user->lang['YES']; ?> <input type="radio" name="display_on_index" value="0"<?php echo $display_index_no; ?> /> <?php echo $user->lang['NO']; ?></td> + </tr> <?php + } } } - } ?> - </td></table> + <tr> + <td class="row1"><?php echo $user->lang['FORUM_AUTO_PRUNE'] ?>: <br /><span class="gensmall"><?php echo $user->lang['FORUM_AUTO_PRUNE_EXPLAIN']; ?></span></td> + <td class="row2"><input type="radio" name="enable_prune" value="1"<?php echo $prune_enable_yes; ?> /> <?php echo $user->lang['YES']; ?> <input type="radio" name="enable_prune" value="0"<?php echo $prune_enable_no; ?> /> <?php echo $user->lang['NO']; ?></td> </tr> <tr> - <td class="row1"><?php echo $user->lang['Forum_pruning'] ?></td> - <td class="row2"><table cellspacing="0" cellpadding="1" border="0"> - <tr> - <td align="right" valign="middle"><?php echo $user->lang['Enabled'] ?></td> - <td align="left" valign="middle"><input type="checkbox" name="prune_enable" value="1" <?php echo $prune_enabled ?>/></td> - </tr> - <tr> - <td align="right" valign="middle"><?php echo $user->lang['prune_days'] ?></td> - <td align="left" valign="middle"> <input class="post" type="text" name="prune_days" value="<?php echo $prune_days ?>" size="5" /> <?php echo $user->lang['Days'] ?></td> - </tr> - <tr> - <td align="right" valign="middle"><?php echo $user->lang['prune_freq'] ?></td> - <td align="left" valign="middle"> <input class="post" type="text" name="prune_freq" value="<?php echo $prune_freq ?>" size="5" /> <?php echo $user->lang['Days'] ?></td> - </tr> - </table></td> + <td class="row1"><?php echo $user->lang['AUTO_PRUNE_FREQ'] ?>: <br /><span class="gensmall"><?php echo $user->lang['AUTO_PRUNE_FREQ_EXPLAIN']; ?></span></td> + <td class="row2"><input class="post" type="text" name="prune_freq" value="<?php echo $prune_freq ?>" size="5" /> <?php echo $user->lang['DAYS']; ?></td> + </tr> + <tr> + <td class="row1"><?php echo $user->lang['AUTO_PRUNE_DAYS'] ?>: <br /><span class="gensmall"><?php echo $user->lang['AUTO_PRUNE_DAYS_EXPLAIN']; ?></span></td> + <td class="row2"><input class="post" type="text" name="prune_days" value="<?php echo $prune_days ?>" size="5" /> <?php echo $user->lang['DAYS']; ?></td> + </tr> + <tr> + <td class="row1"><?php echo $user->lang['FORUM_TOPICS_PAGE'] ?>: <br /><span class="gensmall"><?php echo $user->lang['FORUM_TOPICS_PAGE_EXPLAIN']; ?></span></td> + <td class="row2"><input type="text" name="topics_per_page" value="<?php echo $forum_topics_per_page; ?>" size="3" maxlength="3" /></td> + </tr> + <tr> + <td class="row1"><?php echo $user->lang['FORUM_PASSWORD'] ?>: <br /><span class="gensmall"><?php echo $user->lang['FORUM_PASSWORD_EXPLAIN']; ?></span></td> + <td class="row2"><input type="password" name="forum_password" value="<?php echo $password; ?>" size="25" maxlength="200" /></td> </tr> -<?php - - } - else - { - -?> <tr> - <td class="row1"><?php echo $user->lang['FORUM_IMAGE']; ?></td> - <td class="row2"><input class="post" type="text" size="25" name="forum_image" value="<?php echo $forum_image ?>" /></td> + <td class="row1"><?php echo $user->lang['FORUM_PASSWORD_CONFIRM'] ?>: <br /><span class="gensmall"><?php echo $user->lang['FORUM_PASSWORD_CONFIRM_EXPLAIN']; ?></span></td> + <td class="row2"><input type="password" name="forum_password_confirm" value="<?php echo $password_confirm; ?>" size="25" maxlength="200" /></td> </tr> <?php - } + } ?> <tr> - <td class="cat" colspan="2" align="center"><input type="hidden" name="mode" value="<?php echo $newmode ?>" /><input type="hidden" name="f" value="<?php echo $forum_id ?>" /><input class="mainoption" type="submit" name="submit" value="<?php echo $buttonvalue ?>" /></td> + <td class="cat" colspan="2" align="center"><input class="mainoption" name="update" type="submit" value="<?php echo $user->lang['SUBMIT']; ?>" /> <input class="liteoption" type="reset" value="<?php echo $user->lang['RESET']; ?>" /></td> </tr> </table></form> @@ -584,11 +493,172 @@ switch ($mode) <?php page_footer(); - break; + break; case 'delete': - page_header($user->lang['Forum_delete']); - extract(get_forum_info(intval($_GET['this_f']))); + + $forum_id = (isset($_REQUEST['this_f'])) ? intval($_REQUEST['this_f']) : ((isset($_REQUEST['f'])) ? intval($_REQUEST['f']) : 0); + + if (isset($_POST['update'])) + { + + $action_subforums = (!empty($_POST['action_subforums'])) ? $_POST['action_subforums'] : ''; + $action_posts = (!empty($_POST['action_posts'])) ? $_POST['action_posts'] : ''; + + $row = get_forum_info($forum_id); + extract($row); + + $log_action_posts = $log_action_forums = ''; + if ($action_posts == 'delete') + { + $log_action_posts = 'POSTS'; + delete_forum_content($forum_id); + } + elseif ($action_posts == 'move') + { + if (empty($_POST['posts_to_id'])) + { + trigger_error($user->lang['NO_DESTINATION_FORUM']); + } + + $log_action_posts = 'MOVE_POSTS'; + + $sql = 'SELECT forum_name + FROM ' . FORUMS_TABLE . " + WHERE forum_id = " . intval($_POST['posts_to_id']); + $result = $db->sql_query($sql); + + if (!($row = $db->sql_fetchrow($result))) + { + trigger_error($user->lang['NO_FORUM']); + } + $db->sql_freeresult($result); + + $posts_to_name = $row['forum_name']; + unset($row); + + move_forum_content($forum_id, intval($_POST['posts_to_id'])); + } + + if ($action_subforums == 'delete') + { + $log_action_forums = 'FORUMS'; + + $forum_ids = array($forum_id); + $rows = get_forum_branch($forum_id, 'children', 'descending', FALSE); + + foreach ($rows as $row) + { + $forum_ids[] = $row['forum_id']; + delete_forum_content($row['forum_id']); + } + + $diff = count($forum_ids) * 2; + + $sql = 'DELETE FROM ' . FORUMS_TABLE . ' + WHERE forum_id IN (' . implode(', ', $forum_ids) . ')'; + $db->sql_query($sql); + } + elseif ($action_subforums == 'move') + { + if (empty($_POST['subforums_to_id'])) + { + trigger_error($user->lang['NO_DESTINATION_FORUM']); + } + + $log_action_forums = 'MOVE_FORUMS'; + + $sql = 'SELECT forum_name + FROM ' . FORUMS_TABLE . " + WHERE forum_id = " . intval($_POST['subforums_to_id']); + $result = $db->sql_query($sql); + + if (!($row = $db->sql_fetchrow($result))) + { + trigger_error($user->lang['NO_FORUM']); + } + $db->sql_freeresult($result); + + $subforums_to_name = $row['forum_name']; + unset($row); + + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE . " + WHERE parent_id = $forum_id"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + move_forum($row['forum_id'], intval($_POST['subforums_to_id'])); + } + $db->sql_freeresult($result); + + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET parent_id = ' . $_POST['subforums_to_id'] . " + WHERE parent_id = $forum_id"; + $db->sql_query($sql); + + $diff = 2; + + $sql = 'DELETE FROM ' . FORUMS_TABLE . " + WHERE forum_id = $forum_id"; + $db->sql_query($sql); + } + else + { + $diff = 2; + $sql = 'DELETE FROM ' . FORUMS_TABLE . " + WHERE forum_id = $forum_id"; + $db->sql_query($sql); + } + + // Resync tree + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET right_id = right_id - $diff + WHERE left_id < $right_id AND right_id > $right_id"; + $db->sql_query($sql); + + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET left_id = left_id - $diff, right_id = right_id - $diff + WHERE left_id > $right_id"; + $db->sql_query($sql); + + $log_action = implode('_', array($log_action_posts, $log_action_forums)); + + switch ($log_action) + { + case 'MOVE_POSTS_MOVE_FORUMS': + add_log('admin', 'LOG_FORUM_DEL_MOVE_POSTS_MOVE_FORUMS', $posts_to_name, $subforums_to_name, $forum_name); + break; + case 'MOVE_POSTS_FORUMS': + add_log('admin', 'LOG_FORUM_DEL_MOVE_POSTS_FORUMS', $posts_to_name, $forum_name); + break; + case 'POSTS_MOVE_FORUMS': + add_log('admin', 'LOG_FORUM_DEL_POSTS_MOVE_FORUMS',$subforums_to_name, $forum_name); + break; + case '_MOVE_FORUMS': + add_log('admin', 'LOG_FORUM_DEL_MOVE_FORUMS', $subforums_to_name, $forum_name); + break; + case 'MOVE_POSTS_': + add_log('admin', 'LOG_FORUM_DEL_MOVE_POSTS', $posts_to_name, $forum_name); + break; + case 'POSTS_FORUMS': + add_log('admin', 'LOG_FORUM_DEL_POSTS_FORUMS', $forum_name); + break; + case '_FORUMS': + add_log('admin', 'LOG_FORUM_DEL_FORUMS', $forum_name); + break; + case 'POSTS_': + add_log('admin', 'LOG_FORUM_DEL_POSTS', $forum_name); + break; + } + + trigger_error($user->lang['FORUM_DELETED']); + } + + + page_header($user->lang['MANAGE']); + extract(get_forum_info($forum_id)); $subforums_id = array(); $subforums = get_forum_branch($forum_id, 'children'); @@ -597,35 +667,41 @@ switch ($mode) $subforums_id[] = $row['forum_id']; } - $forums_list = make_forums_list('all', $parent_id, $subforums_id); - $move_posts_list = make_forums_list('forums', $parent_id, $subforums_id); + $forums_list = make_forum_select($parent_id, $subforums_id); + $move_posts_list = make_forum_select($parent_id, $subforums_id); ?> -<h1><?php echo $user->lang['Forum_delete'] ?></h1> -<p><?php echo $user->lang['Forum_delete_explain'] ?></p> +<p><?php echo $user->lang['FORUM_ADMIN_EXPLAIN']; ?></p> + +<h1><?php echo $user->lang['FORUM_DELETE'] ?></h1> -<form action="admin_forums.<?php echo $phpEx . $SID ?>&mode=remove&f=<?php echo $forum_id ?>" method="post"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center"> +<p><?php echo $user->lang['FORUM_DELETE_EXPLAIN'] ?></p> + +<form action="admin_forums.<?php echo $phpEx . $SID ?>&mode=delete&f=<?php echo $forum_id ?>" method="post"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center"> <tr> - <th colspan="2"><?php echo $user->lang['Forum_delete'] ?></th> - </tr> + <th colspan="2"><?php echo $user->lang['FORUM_DELETE'] ?></th> + </tr> <tr> - <td class="row1"><?php echo $user->lang['Forum_name']; ?></td> - <td class="row1"><span class="row1"><?php echo $forum_name ?></span></td> + <td class="row1"><?php echo $user->lang['FORUM_NAME']; ?>: </td> + <td class="row1"><b><?php echo $forum_name ?></b></td> </tr> <?php - if ($forum_postable) + if ($forum_type == FORUM_POST) { ?> <tr> - <td class="row1"><?php echo $user->lang['Action'] ?></td> - <td class="row1"><input type="radio" name="action_posts" value="delete" checked="checked" /> <?php echo $user->lang['Delete_all_posts'] ?></td> - </tr> - <tr> - <td class="row1"></td> - <td class="row1"><input type="radio" name="action_posts" value="move" /> <?php echo $user->lang['Move_posts_to'] ?> <select name="posts_to_id" ?><option value="0"></option><?php echo $move_posts_list ?></select></td> + <td class="row1"><?php echo $user->lang['ACTION'] ?>: </td> + <td class="row1"><table cellspacing="0" cellpadding="2" border="0"> + <tr> + <td><input type="radio" name="action_posts" value="delete" checked="checked" /> <?php echo $user->lang['DELETE_ALL_POSTS'] ?></td> + </tr> + <tr> + <td><input type="radio" name="action_posts" value="move" /> <?php echo $user->lang['MOVE_POSTS_TO'] ?> <select name="posts_to_id" ?><?php echo $move_posts_list ?></select></td> + </tr> + </table></td> </tr> <?php @@ -636,12 +712,15 @@ switch ($mode) ?> <tr> - <td class="row1"><?php echo $user->lang['Action'] ?></td> - <td class="row1"><input type="radio" name="action_subforums" value="delete" checked="checked" /> <?php echo $user->lang['Delete_subforums'] ?></td> - </tr> - <tr> - <td class="row1"></td> - <td class="row1"><input type="radio" name="action_subforums" value="move" /> <?php echo $user->lang['Move_subforums_to'] ?> <select name="subforums_to_id" ?><option value="0"></option><?php echo $forums_list ?></select></td> + <td class="row1"><?php echo $user->lang['ACTION'] ?>:</td> + <td class="row1"><table cellspacing="0" cellpadding="2" border="0"> + <tr> + <td><input type="radio" name="action_subforums" value="delete" checked="checked" /> <?php echo $user->lang['DELETE_SUBFORUMS'] ?></td> + </tr> + <tr> + <td><input type="radio" name="action_subforums" value="move" /> <?php echo $user->lang['MOVE_SUBFORUMS_TO'] ?> <select name="subforums_to_id" ?><?php echo $forums_list ?></select></td> + </tr> + </table></td> </tr> <?php @@ -649,26 +728,148 @@ switch ($mode) ?> <tr> - <td class="cat" colspan="2" align="center"><input type="submit" name="submit" value="<?php echo $user->lang['Move_and_Delete'] ?>" class="mainoption" /></td> + <td class="cat" colspan="2" align="center"><input type="submit" name="update" value="<?php echo $user->lang['SUBMIT'] ?>" class="mainoption" /></td> </tr> - </table> -</form> +</table></form> <?php page_footer(); + break; + + case 'move_up': + case 'move_down': + $forum_id = intval($_GET['this_f']); + + $sql = 'SELECT parent_id, left_id, right_id + FROM ' . FORUMS_TABLE . " + WHERE forum_id = $forum_id"; + $result = $db->sql_query($sql); + + if (!($row = $db->sql_fetchrow($result))) + { + trigger_error($user->lang['NO_FORUM']); + } + $db->sql_freeresult($result); + + extract($row); + + $forum_info = array($forum_id => $row); + + // Get the adjacent forum + $sql = 'SELECT forum_id, forum_name, left_id, right_id + FROM ' . FORUMS_TABLE . " + WHERE parent_id = $parent_id + AND " . (($mode == 'move_up') ? "right_id < $right_id ORDER BY right_id DESC" : "left_id > $left_id ORDER BY left_id ASC"); + $result = $db->sql_query_limit($sql, 1); + + if (!($row = $db->sql_fetchrow($result))) + { + // already on top or at bottom + break; + } + $db->sql_freeresult($result); + + if ($mode == 'move_up') + { + $log_action = 'UP'; + $up_id = $forum_id; + $down_id = $row['forum_id']; + } + else + { + $log_action = 'DOWN'; + $up_id = $row['forum_id']; + $down_id = $forum_id; + } + + $move_forum_name = $row['forum_name']; + $forum_info[$row['forum_id']] = $row; + $diff_up = $forum_info[$up_id]['right_id'] - $forum_info[$up_id]['left_id']; + $diff_down = $forum_info[$down_id]['right_id'] - $forum_info[$down_id]['left_id']; + + $forum_ids = array(); + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE . ' + WHERE left_id > ' . $forum_info[$up_id]['left_id'] . ' + AND right_id < ' . $forum_info[$up_id]['right_id']; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $forum_ids[] = $row['forum_id']; + } + $db->sql_freeresult($result); + + // Start transaction + $db->sql_transaction(); + + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET left_id = left_id + ' . ($diff_up + 1) . ', right_id = right_id + ' . ($diff_up + 1) . ' + WHERE left_id > ' . $forum_info[$down_id]['left_id'] . ' + AND right_id < ' . $forum_info[$down_id]['right_id']; + $db->sql_query($sql); + + if (count($forum_ids)) + { + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET left_id = left_id - ' . ($diff_down + 1) . ', right_id = right_id - ' . ($diff_down + 1) . ' + WHERE forum_id IN (' . implode(', ', $forum_ids) . ')'; + $db->sql_query($sql); + } + + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET left_id = ' . $forum_info[$down_id]['left_id'] . ', right_id = ' . ($forum_info[$down_id]['left_id'] + $diff_up) . ' + WHERE forum_id = ' . $up_id; + $db->sql_query($sql); + + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET left_id = ' . ($forum_info[$up_id]['right_id'] - $diff_down) . ', right_id = ' . $forum_info[$up_id]['right_id'] . ' + WHERE forum_id = ' . $down_id; + $db->sql_query($sql); + + $db->sql_transaction('commit'); + + $forum_data = get_forum_info($forum_id); + add_log('admin', 'LOG_FORUM_MOVE_' . $log_action, $forum_data['forum_name'], $move_forum_name); + unset($forum_data); + break; + + case 'sync': + $forum_id = (isset($_REQUEST['this_f'])) ? intval($_REQUEST['this_f']) : ((isset($_REQUEST['f'])) ? intval($_REQUEST['f']) : 0); + + if (!$forum_id) + { + trigger_error($user->lang['NO_FORUM']); + } + + $sql = "SELECT forum_name + FROM " . FORUMS_TABLE . " + WHERE forum_id = $forum_id"; + $result = $db->sql_query($sql); + + if (!($row = $db->sql_fetchrow($result))) + { + trigger_error($user->lang['NO_FORUM']); + } + $db->sql_freeresult($result); + + add_log('admin', 'LOG_FORUM_SYNC', $row['forum_name']); - break; + sync('forum', 'forum_id', $forum_id); + break; } +// Default management page + $forum_id = (!empty($_GET['f'])) ? intval($_GET['f']) : 0; if (!$forum_id) { - $navigation = $user->lang['INDEX']; + $navigation = $user->lang['FORUM_INDEX']; } else { - $navigation = '<a href="admin_forums.' . $phpEx . $SID . '">' . $user->lang['INDEX'] . '</a>'; + $navigation = '<a href="admin_forums.' . $phpEx . $SID . '">' . $user->lang['FORUM_INDEX'] . '</a>'; $forums_nav = get_forum_branch($forum_id, 'parents', 'descending'); foreach ($forums_nav as $row) @@ -694,60 +895,87 @@ page_header($user->lang['MANAGE']); <h1><?php echo $user->lang['MANAGE']; ?></h1> -<p><?php echo $user->lang['Forum_admin_explain']; ?></p> +<p><?php echo $user->lang['FORUM_ADMIN_EXPLAIN']; ?></p> -<form method="post" action="<?php echo "admin_forums.$phpEx$SID&mode=add" ?>"><table width="100%" cellspacing="2" cellpadding="2" border="0" align="center"> +<form method="post" action="<?php echo "admin_forums.$phpEx$SID" ?>"><table width="100%" cellspacing="2" cellpadding="2" border="0" align="center"> <tr> - <td><?php echo $navigation ?></td> + <td class="nav"><?php echo $navigation ?></td> </tr> </table> -<table class="bg" width="100%" cellspacing="1" cellpadding="3" border="0" align="center"> +<table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center"> <tr> - <th colspan="6"><?php echo $user->lang['Forum_admin'] ?></th> + <th colspan="6"><?php echo $user->lang['FORUM_ADMIN'] ?></th> </tr> <?php -$result = $db->sql_query('SELECT * FROM ' . FORUMS_TABLE . " WHERE parent_id = $forum_id ORDER BY left_id"); +$sql = 'SELECT * + FROM ' . FORUMS_TABLE . " + WHERE parent_id = $forum_id + ORDER BY left_id"; +$result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { - // DEBUG - $parent_id = $row['parent_id']; - $forum_title = $row['forum_name']; - $forum_desc = $row['forum_desc']; + $forum_type = $row['forum_type']; - if ($row['forum_status'] != ITEM_LOCKED) + if ($row['forum_status'] == ITEM_LOCKED) { - if ($row['left_id'] + 1 != $row['right_id']) - { - $folder_image = '<img src="images/icon_subfolder.gif" width="46" height="25" alt="' . $user->lang['SUBFORUM'] . '" alt="' . $user->lang['SUBFORUM'] . '" />'; - } - else - { - $folder_image = '<img src="images/icon_folder.gif" width="46" height="25" alt="' . $user->lang['FOLDER'] . '" alt="' . $user->lang['FOLDER'] . '" />'; - } + $folder_image = '<img src="images/icon_folder_lock.gif" width="46" height="25" alt="' . $user->lang['LOCKED'] . '" alt="' . $user->lang['LOCKED'] . '" />'; } else { - $folder_image = '<img src="images/icon_folder_lock.gif" width="46" height="25" alt="' . $user->lang['LOCKED'] . '" alt="' . $user->lang['LOCKED'] . '" />'; - } + switch ($forum_type) + { + case FORUM_LINK: + $folder_image = '<img src="images/icon_folder_link.gif" width="46" height="25" alt="' . $user->lang['LINK'] . '" alt="' . $user->lang['LINK'] . '" />'; + break; - $url = $phpEx . $SID . '&f=' . $forum_id . '&this_f=' . $row['forum_id']; + default: + $folder_image = ($row['left_id'] + 1 != $row['right_id']) ? '<img src="images/icon_subfolder.gif" width="46" height="25" alt="' . $user->lang['SUBFORUM'] . '" alt="' . $user->lang['SUBFORUM'] . '" />' : '<img src="images/icon_folder.gif" width="46" height="25" alt="' . $user->lang['FOLDER'] . '" alt="' . $user->lang['FOLDER'] . '" />'; + } + } - $forum_title = '<a href="admin_forums.' . $phpEx . $SID . '&f=' . $row['forum_id'] . '">' . $forum_title . '</a>'; + $forum_title = ($forum_type != FORUM_LINK) ? "<a href=\"admin_forums.$phpEx$SID&f=" . $row['forum_id'] . '">' : ''; + $forum_title .= $row['forum_name']; + $forum_title .= ($forum_type != FORUM_LINK) ? '</a>' : ''; + $url = "$phpEx$SID&f=$forum_id&this_f=" . $row['forum_id']; ?> <tr> <td class="row1" width="5%"><?php echo $folder_image; ?></td> - <td class="row2" width="50%"><span class="gen"><?php echo $forum_title ?></span><br /><span class="gensmall"><?php echo $forum_desc ?></span></td> + <td class="row1" width="50%"><table width="100%" cellspacing="0" cellpadding="0" border="0"> + <tr> + <td><span class="forumlink"><?php echo $forum_title ?></span></td><?php - <td class="row1" width="5%" align="center" valign="middle" title="<?php echo $user->lang['TOPICS']; ?>"><span class="gen"><?php echo $row['forum_topics'] ?></span></td> - <td class="row2" width="5%" align="center" valign="middle" title="<?php echo $user->lang['POSTS']; ?>"><span class="gen"><?php echo $row['forum_posts'] ?></span></td> + if ($forum_type == FORUM_POST) + { + +?> + <td class="gensmall" align="right"> <?php echo $user->lang['TOPICS']; ?>: <b><?php echo $row['forum_topics'] ?></b> / <?php echo $user->lang['POSTS']; ?>: <b><?php echo $row['forum_posts'] ?></b></td><?php + + } + +?> + </tr> + </table> + <table cellspacing="5" cellpadding="0" border="0"> + <tr> + <td class="gensmall"><?php echo $row['forum_desc'] ?></td> + </tr> + </table></td> + <td class="row2" width="15%" align="center" valign="middle" nowrap="nowrap"><a href="admin_forums.<?php echo $url ?>&mode=move_up"><?php echo $user->lang['MOVE_UP'] ?></a><br /><a href="admin_forums.<?php echo $url ?>&mode=move_down"><?php echo $user->lang['MOVE_DOWN'] ?></a></td> + <td class="row2" width="20%" align="center" valign="middle" nowrap="nowrap"> <a href="admin_forums.<?php echo $url ?>&mode=edit"><?php echo $user->lang['EDIT'] ?></a> | <a href="admin_forums.<?php echo $url ?>&mode=delete"><?php echo $user->lang['DELETE'] ?></a><?php + + if ($forum_type != FORUM_LINK) + { - <td class="row2" width="15%" align="center" valign="middle" nowrap="nowrap"><span class="gen"><a href="admin_forums.<?php echo $url ?>&mode=move_up"><?php echo $user->lang['MOVE_UP'] ?></a> <br /> <a href="admin_forums.<?php echo $url ?>&mode=move_down"><?php echo $user->lang['MOVE_DOWN'] ?></a></span></td> +?> | <a href="admin_forums.<?php echo $url ?>&mode=sync"><?php echo $user->lang['RESYNC'] ?></a><?php + - <td class="row2" width="20%" align="center" valign="middle" nowrap="nowrap"> <span class="gen"><a href="admin_forums.<?php echo $url ?>&mode=edit"><?php echo $user->lang['EDIT'] ?></a> | <a href="admin_forums.<?php echo $url ?>&mode=delete"><?php echo $user->lang['DELETE'] ?></a> | <a href="admin_forums.<?php echo $url ?>&mode=sync"><?php echo $user->lang['Resync'] ?></a></span> </td> + } + +?> </td> </tr> <?php @@ -755,16 +983,15 @@ while ($row = $db->sql_fetchrow($result)) ?> <tr> - <td width="100%" colspan="6" class="cat"><input type="hidden" name="mode" value="add" /><input type="hidden" name="parent_id" value="<? echo $forum_id ?>" /><input type="text" name="forum_name" /> <input class="liteoption" type="submit" name="submit" value="<?php echo $user->lang['Create_forum'] ?>" /></td> + <td width="100%" colspan="6" class="cat"><input type="hidden" name="mode" value="add" /><input type="hidden" name="parent_id" value="<? echo $forum_id ?>" /><input type="text" name="forum_name" /> <input class="liteoption" type="submit" value="<?php echo $user->lang['CREATE_FORUM'] ?>" /></td> </tr> </table></form> <form method="get" action="admin_forums.<?php echo $phpEx,$SID ?>"><table width="100%" cellpadding="1" cellspacing="1" border="0"> <tr> - <td align="right"><?php echo $user->lang['Select_forum']; ?>: <select name="f" onchange="if(this.options[this.selectedIndex].value != -1){ this.form.submit() }"><?php echo $forum_box; ?></select> <input class="liteoption" type="submit" value="<?php echo $user->lang['Go']; ?>" /><input type="hidden" name="sid" value="<?php echo $user->session_id; ?>" /></td> + <td align="right"><?php echo $user->lang['SELECT_FORUM']; ?>: <select name="f" onchange="if(this.options[this.selectedIndex].value != -1){ this.form.submit(); }"><?php echo $forum_box; ?></select> <input class="liteoption" type="submit" value="<?php echo $user->lang['GO']; ?>" /><input type="hidden" name="sid" value="<?php echo $user->session_id; ?>" /></td> </tr> </table></form> - <?php page_footer(); @@ -773,95 +1000,38 @@ page_footer(); // END // -// ------------------ -// Begin function block -// -function get_forum_info($forum_id) -{ - global $db; - $sql = 'SELECT * - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql); - if (!$row = $db->sql_fetchrow($result)) - { - trigger_error("Forum #$forum_id does not exist", E_USER_ERROR); - } - return $row; -} -function make_forums_list($mode = 'all', $selected_id = 0, $exclude_id = array()) -{ - global $db; - if (!is_array($exclude_id)) - { - $exclude_id = array($exclude_id); - } - $sql = 'SELECT f2.* - FROM ' . FORUMS_TABLE . ' f1, ' . FORUMS_TABLE . ' f2 - WHERE f1.parent_id = 0 - AND f2.left_id BETWEEN f1.left_id AND f1.right_id - ORDER BY f2.left_id'; - $result = $db->sql_query($sql); - $list = ''; - $indent = array(); - $current_indent = 0; - while ($row = $db->sql_fetchrow($result)) - { - if ($row['parent_id'] == 0) - { - $current_indent = 0; - } - elseif (!isset($indent[$row['parent_id']])) - { - ++$current_indent; - $indent[$row['parent_id']] = $current_indent; - } - else - { - $current_indent = $indent[$row['parent_id']]; - } - if (($mode == 'forums' && !$row['forum_postable']) - || ($mode == 'categories' && $row['forum_postable']) - || (in_array($row['forum_id'], $exclude_id))) - { - continue; - } - if ($mode == 'all' && !$row['parent_id']) - { - $list .= "<option value=\"-1\"> </option>\n"; - } - $list .= '<option value="' . $row['forum_id'] . '"'; - $list .= ($row['forum_id'] == $selected_id) ? ' selected="selected">' : '>'; - $list .= str_repeat('--', $current_indent) . (($indent) ? ' ' : '') . $row['forum_name'] . "</option>\n"; - } - return $list; -} +// ------------------ +// Begin function block +// -function make_styles_list($selected_id = 0) +function get_forum_info($forum_id) { global $db; - $list = ''; - $result = $db->sql_query('SELECT style_id, style_name FROM ' . STYLES_TABLE . ' ORDER BY style_name'); + $sql = 'SELECT * + FROM ' . FORUMS_TABLE . " + WHERE forum_id = $forum_id"; + $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + if (!$row = $db->sql_fetchrow($result)) { - $list .= '<option value="' . $row['style_id'] . '"' . (($row['style_id'] == $selected_id) ? ' selected="selected">' : '>') . htmlspecialchars($row['style_name']) . "</option>\n"; + trigger_error("Forum #$forum_id does not exist", E_USER_ERROR); } - return $list; + + return $row; } function move_forum($from_id, $to_id) @@ -922,15 +1092,20 @@ function move_forum($from_id, $to_id) } else { - $result = $db->sql_query('SELECT MAX(right_id) AS right_id FROM ' . FORUMS_TABLE . ' WHERE forum_id NOT IN (' . implode(', ', $moved_ids) . ')'); - $right_id = $db->sql_fetchfield('right_id', 0, $result); + $sql = 'SELECT MAX(right_id) AS right_id + FROM ' . FORUMS_TABLE . ' + WHERE forum_id NOT IN (' . implode(', ', $moved_ids) . ')'; + $result = $db->sql_query($sql); + + $row = $db->sql_fetchtrow($result); + $db->sql_freeresult($result); - $diff = '+ ' . ($right_id - $from_data['left_id'] + 1); + $diff = '+ ' . ($row['right_id'] - $from_data['left_id'] + 1); } $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id $diff, right_id = right_id $diff, forum_parents = '' - WHERE forum_id IN (" . implode(', ', $moved_ids) . ')'; + SET left_id = left_id $diff, right_id = right_id $diff, forum_parents = '' + WHERE forum_id IN (" . implode(', ', $moved_ids) . ')'; $db->sql_query($sql); } @@ -938,86 +1113,154 @@ function move_forum_content($from_id, $to_id) { global $db; - $db->sql_query('UPDATE ' . ACL_GROUPS_TABLE . " SET forum_id = $to_id WHERE forum_id = $from_id"); - $db->sql_query('UPDATE ' . MODERATOR_TABLE . " SET forum_id = $to_id WHERE forum_id = $from_id"); - $db->sql_query('UPDATE ' . LOG_MOD_TABLE . " SET forum_id = $to_id WHERE forum_id = $from_id"); - $db->sql_query('UPDATE ' . POSTS_TABLE . " SET forum_id = $to_id WHERE forum_id = $from_id"); - $db->sql_query('UPDATE ' . TOPICS_TABLE . " SET forum_id = $to_id WHERE forum_id = $from_id"); + $table_ary = array(LOG_MOD_TABLE, POSTS_TABLE, TOPICS_TABLE); + foreach ($sql_ary as $table) + { + $sql = "UPDATE $table + SET forum_id = $to_id + WHERE forum_id = $from_id"; + $db->sql_query($sql); + } + unset($table_ary); - // - // TODO: untested yet - // $sql = 'SELECT t1.topic_id - FROM ' .TOPICS_TABLE . ' t1 - LEFT JOIN ' . TOPICS_TABLE . " t2 ON t1.topic_moved_id = t2.topic_id AND t1.forum_id = t2.forum_id - WHERE t1.forum_id = $to_id"; + FROM ' .TOPICS_TABLE . ' t1, ' . TOPICS_TABLE . " t2 + WHERE t2.forum_id = $to_id + AND t1.topic_moved_id = t2.topic_id + AND t1.forum_id = t2.forum_id"; $result = $db->sql_query($result); - $topic_ids = array(); - while ($row = $db->sql_fetchrow($result)) + if ($row = $db->sql_fetchrow($result)) { - $topic_ids[] = $row['topic_id']; - } - if (count($topic_ids)) - { - $db->sql_query('DELETE FROM ' . TOPICS_TABLE . ' WHERE topic_id IN (' . implode(', ', $topic_ids) . ')'); + $topic_id_ary = array(); + do + { + $topic_id_ary[] = $row['topic_id']; + } + while ($row = $db->sql_fetchrow($result)); + + $sql = 'DELETE FROM ' . TOPICS_TABLE . ' + WHERE topic_id IN (' . implode(', ', $topic_id_ary) . ')'; + $db->sql_query($sql); + unset($topic_id_ary); } - sync('forum', 'forum_id', $to_id); + $db->sql_freeresult($result); - // - // TODO: there might be conflicts in ACL tables =\ - // make sure that the query that retrieves shadow topics uses the correct index (topic_type or topic_moved_id) - // + sync('forum', 'forum_id', $to_id); } function delete_forum_content($forum_id) { global $db; - $db->sql_query('DELETE FROM ' . ACL_GROUPS_TABLE . " WHERE forum_id = $forum_id"); - $db->sql_query('DELETE FROM ' . MODERATOR_TABLE . " WHERE forum_id = $forum_id"); - $db->sql_query('DELETE FROM ' . LOG_MOD_TABLE . " WHERE forum_id = $forum_id"); - $db->sql_query('DELETE FROM ' . FORUMS_WATCH_TABLE . " WHERE forum_id = $forum_id"); + $db->sql_transaction(); - $ids = array(); - $result = $db->sql_query('SELECT post_id FROM ' . POSTS_TABLE . " WHERE forum_id = $forum_id"); + $sql = 'SELECT post_id + FROM ' . POSTS_TABLE . " + WHERE forum_id = $forum_id"; + $result = $db->sql_query(); - while ($row = $db->sql_fetchrow($result)) + if ($row = $db->sql_fetchrow($result)) { - $ids[] = $row['post_id']; + $id_ary = array(); + + do + { + $id_ary[] = $row['post_id']; + } + while ($row = $db->sql_fetchrow($result)); + + // TODO + // Could be problematical with large forums ... should split array + // if large + $sql = 'DELETE FROM ' . SEARCH_MATCH_TABLE . ' + WHERE post_id IN (' . implode(', ', $id_ary) . ')'; + $db->sql_query($sql); + unset($id_ary); } - $ids = implode(',', $ids); $db->sql_freeresult(); - if ($ids) + $sql = 'SELECT topic_id + FROM ' . TOPICS_TABLE . " + WHERE forum_id = $forum_id"; + $result = $db->sql_query(); + + if ($row = $db->sql_fetchrow($result)) { - $db->sql_query('DELETE FROM ' . SEARCH_MATCH_TABLE . " WHERE post_id IN ($ids)"); - $db->sql_query('DELETE FROM ' . POSTS_TABLE . " WHERE forum_id = $forum_id"); - $db->sql_query('DELETE FROM ' . POSTS_TEXT_TABLE . " WHERE post_id IN ($ids)"); - } + $id_ary = array(); + do + { + $id_ary[] = $row['topic_id']; + } + while ($row = $db->sql_fetchrow($result)); - $ids = array(); - $result = $db->sql_query('SELECT topic_id FROM ' . TOPICS_TABLE . " WHERE forum_id = $forum_id"); + $sql_in = implode(', ', $id_ary); + unset($id_ary); - while ($row = $db->sql_fetchrow($result)) - { - $ids[] = $row['topic_id']; + $table_ary = array(TOPICS_WATCH_TABLE, POLL_OPTIONS_TABLE, POLL_VOTES_TABLE); + foreach ($sql_ary as $table) + { + $sql = "DELETE FROM $table + WHERE topic_id IN ($sql_in)"; + $db->sql_query($sql); + } + unset($table_ary); + + $sql = 'DELETE FROM ' . TOPICS_TABLE . " + WHERE topic_moved_id IN ($sql_in)"; + $db->sql_query($sql); + + unset($sql_in); } - $ids = implode(',', $ids); $db->sql_freeresult(); - if ($ids) + $table_ary = array(TOPICS_TABLE, POSTS_TABLE, ACL_GROUPS_TABLE, ACL_USERS_TABLE, MODERATOR_TABLE, LOG_MOD_TABLE, FORUMS_WATCH_TABLE); + foreach ($sql_ary as $table) { - $db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . " WHERE topic_id IN ($ids)"); - $db->sql_query('DELETE FROM ' . TOPICS_TABLE . " WHERE forum_id = $forum_id"); - $db->sql_query('DELETE FROM ' . TOPICS_TABLE . " WHERE topic_moved_id IN ($ids)"); + $sql = "DELETE FROM $table + WHERE forum_id = $forum_id"; + $db->sql_query($sql); + } + unset($table_ary); + + switch (SQL_LAYER) + { + case 'mysql': + case 'mysql4': +/* $sql = 'SHOW TABLES'; + $result = $db->sql_query($sql); + + $field_name = 'Tables_in_' . $db->dbname; + $table_ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + if (preg_match('#^' . preg_quote($phpEx, '#') . '#', $row[$field_name])) + { + $table_ary[] = $row[$field_name]; + } + } + $db->sql_freeresult($result); + + if (sizeof($table_ary)) + {*/ + $table_ary = array(TOPICS_TABLE, POSTS_TABLE, ACL_GROUPS_TABLE, ACL_USERS_TABLE, MODERATOR_TABLE, LOG_MOD_TABLE, FORUMS_WATCH_TABLE, TOPICS_WATCH_TABLE, POLL_OPTIONS_TABLE, POLL_VOTES_TABLE, SEARCH_MATCH_TABLE); + $sql = 'OPTIMIZE TABLE ' . implode(', ', $table_ary); + $db->sql_query($sql); +// } + unset($table_ary); + + break; + + case 'postgresql': + $db->sql_query('VACUUM'); + break; } // // TODO: delete attachments - // delete polls - // OPTIMIZE / VACUUM table ? // + + $db->sql_transaction('commit'); } // diff --git a/phpBB/adm/admin_permissions.php b/phpBB/adm/admin_permissions.php index be5f8e8af3..bc505d7a40 100644 --- a/phpBB/adm/admin_permissions.php +++ b/phpBB/adm/admin_permissions.php @@ -46,7 +46,7 @@ require('pagestart.' . $phpEx); $mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : ''; $submode = (isset($_REQUEST['submode'])) ? htmlspecialchars($_REQUEST['submode']) : ''; $which_mode = (!empty($submode) && $submode != $mode) ? $submode : $mode; -$submit = array_values(preg_grep('#^submit_(.*)$#i', array_keys($_POST))); +$submit = array_values(preg_grep('#^submit_(.*)$#i', array_keys($_REQUEST))); $submit = (sizeof($submit)) ? substr($submit[0], strpos($submit[0], '_') + 1) : ''; diff --git a/phpBB/adm/admin_prune.php b/phpBB/adm/admin_prune.php index a672acff16..88909384b8 100644 --- a/phpBB/adm/admin_prune.php +++ b/phpBB/adm/admin_prune.php @@ -74,7 +74,7 @@ if (isset($_POST['doprune'])) // NOTE: this query will conceal all forum names, even those the user isn't authed for $sql = 'SELECT forum_id, forum_name FROM ' . FORUMS_TABLE . ' - WHERE forum_postable = 1' . (($forum_id) ? ' AND forum_id = ' . $forum_id : '') . ' + WHERE forum_type = ' . FORUM_POST . ' ' . (($forum_id) ? ' AND forum_id = ' . $forum_id : '') . ' ORDER BY left_id ASC'; $result = $db->sql_query($sql); diff --git a/phpBB/adm/admin_styles.php b/phpBB/adm/admin_styles.php index 0035c9f7fe..e38f8f9530 100644 --- a/phpBB/adm/admin_styles.php +++ b/phpBB/adm/admin_styles.php @@ -28,22 +28,10 @@ if (!$auth->acl_get('a_styles')) trigger_error($user->lang['No_admin']); } -/* -$dp = opendir($phpbb_root_path . 'templates/cache/'); -while ($file = readdir($dp)) -{ - if (!is_file($phpbb_root_path . 'templates/cache/' . $file) && !is_link($phpbb_root_path . 'templates/cache/' . $file) && $file != '.' && $file != '..') - { - $selected = ($tplroot == $file) ? ' selected="selected"' : ''; - $tplroot_options .= '<option name="' . $file . '"' . $selected . '>' . $file . '</option>'; - } -} -closedir($dp); -*/ - // $mode = (isset($_GET['mode'])) ? $_GET['mode'] : $_POST['mode']; + switch ($mode) { case 'editimageset': @@ -157,7 +145,7 @@ switch ($mode) { $str = "<?php\n" . $template->compile(stripslashes($_POST['decompile'])) . "\n?".">"; - $fp = fopen($phpbb_root_path . 'templates/cache/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 'w+'); + $fp = fopen($phpbb_root_path . 'cache/templates/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 'w+'); fwrite ($fp, $str); fclose($fp); @@ -169,14 +157,32 @@ switch ($mode) } else if (!empty($tplname) && isset($_POST['tpl_name'])) { - $fp = fopen($phpbb_root_path . 'templates/cache/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 'r'); + $fp = fopen($phpbb_root_path . 'cache/templates/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 'r'); while (!feof($fp)) { $str .= fread($fp, 4096); } @fclose($fp); - $template->decompile($str); + $match_preg = array( + '#\$this\->_tpl_include\(\'(.*?)\'\);#', + '#echo \$this->_tpldata\[\'\.\'\]\[0\]\[\'(.*?)\'\];#', + '#echo \(\(isset\(\$this\->_tpldata\[\'\.\'\]\[0\]\[\'(.*?)\'\]\)\).*?;#', + '#if \(.*?\[\'\.\'\]\[0\]\[\'(.*?)\'\]\) \{ #', + '#\$_(.*?)_count.*?;if \(.*?\)\{#', + ); + + $replace_preg = array( + '<!-- INCLUDE $1 -->', + '{$1}', + '{$1}', + '<!-- IF \1 -->', + '<!-- BEGIN \1 -->', + ); + + $str = preg_replace($match_preg, $replace_preg, $str); + $str = str_replace('<?php ', '', $str); + $str = str_replace(' ?>', '', $str); } else { @@ -195,10 +201,10 @@ switch ($mode) $tplroot_options = get_templates($tplroot); $tplname_options = ''; - $dp = @opendir($phpbb_root_path . 'templates/cache/' . $tplroot . '/'); + $dp = @opendir($phpbb_root_path . 'cache/templates/' . $tplroot . '/'); while ($file = readdir($dp)) { - if (strstr($file, '.html.' . $phpEx) && is_file($phpbb_root_path . 'templates/cache/' . $tplroot . '/' . $file)) + if (strstr($file, '.html.' . $phpEx) && is_file($phpbb_root_path . 'cache/templates/' . $tplroot . '/' . $file)) { $tpl = substr($file, 0, strpos($file, '.')); $selected = ($tplname == $tpl) ? ' selected="selected"' : ''; diff --git a/phpBB/adm/admin_viewlogs.php b/phpBB/adm/admin_viewlogs.php index 30c4ae365e..6a997fb62d 100644 --- a/phpBB/adm/admin_viewlogs.php +++ b/phpBB/adm/admin_viewlogs.php @@ -114,7 +114,7 @@ page_header($l_title); if ($mode == 'mod') { - $forum_box = '<option value="0">' . $user->lang['ALL_FORUMS'] . '</option>' . make_forum_select($forum_id, false, false); + $forum_box = '<option value="0">' . $user->lang['ALL_FORUMS'] . '</option>' . make_forum_select($forum_id); ?> <table width="100%" cellpadding="1" cellspacing="1" border="0"> @@ -130,7 +130,7 @@ if ($mode == 'mod') <table class="bg" width="100%" cellpadding="4" cellspacing="1" border="0"> <tr> - <td class="cat" colspan="5" height="28" align="center"><span class="gensmall"><?php echo $user->lang['DISPLAY_LOG']; ?>: <?php echo $s_limit_days; ?> <?php echo $user->lang['SORT_BY']; ?> <?php echo $s_sort_key; ?> <?php echo $s_sort_dir; ?> <input class="liteoption" type="submit" value="<?php echo $user->lang['GO']; ?>" name="sort" /></span></td> + <td class="cat" colspan="5" height="28" align="center"><?php echo $user->lang['DISPLAY_LOG']; ?>: <?php echo $s_limit_days; ?> <?php echo $user->lang['SORT_BY']; ?>: <?php echo $s_sort_key; ?> <?php echo $s_sort_dir; ?> <input class="liteoption" type="submit" value="<?php echo $user->lang['GO']; ?>" name="sort" /></td> </tr> <tr> <th width="15%" height="25" nowrap="nowrap"><?php echo $user->lang['USERNAME']; ?></th> @@ -193,19 +193,17 @@ else <table width="100%" cellspacing="2" cellpadding="2" border="0" align="center"> <tr> <td align="left" valign="top"> <span class="nav"><?php echo on_page($log_count, $config['topics_per_page'], $start); ?></span></td> - <td align="right" valign="top" nowrap="nowrap"><?php + <td align="right" valign="top" nowrap="nowrap"><span class="nav"><?php if ($auth->acl_get('a_clearlogs')) { -?><b><span class="gensmall"><a href="javascript:marklist(true);" class="gensmall"><?php echo $user->lang['MARK_ALL']; ?></a> :: <a href="javascript:marklist(false);" class="gensmall"><?php echo $user->lang['UNMARK_ALL']; ?></a></span></b> <br /><br /><?php +?><b><a href="javascript:marklist(true);"><?php echo $user->lang['MARK_ALL']; ?></a> :: <a href="javascript:marklist(false);"><?php echo $user->lang['UNMARK_ALL']; ?></a></b> <br /><br /><?php } - $pagination = generate_pagination("admin_viewlogs.$phpEx$SID&mode=$mode&sort_days=$sort_days&sort_key=$sort_key&sort_dir=$sort_dir", $log_count, $config['topics_per_page'], $start); - - ?><span class="nav"><?php echo $pagination; ?></span></td> + echo generate_pagination("admin_viewlogs.$phpEx$SID&mode=$mode&st=$sort_days&sk=$sort_key&sd=$sort_dir", $log_count, $config['topics_per_page'], $start); ?></span></td> </tr> </table></form> diff --git a/phpBB/adm/images/icon_folder_link.gif b/phpBB/adm/images/icon_folder_link.gif Binary files differnew file mode 100644 index 0000000000..d5e86d47d7 --- /dev/null +++ b/phpBB/adm/images/icon_folder_link.gif diff --git a/phpBB/adm/images/icon_subfolder.gif b/phpBB/adm/images/icon_subfolder.gif Binary files differindex c29bb43f49..9179303e7f 100644 --- a/phpBB/adm/images/icon_subfolder.gif +++ b/phpBB/adm/images/icon_subfolder.gif diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php index 352795a04b..5cb8d69423 100644 --- a/phpBB/adm/index.php +++ b/phpBB/adm/index.php @@ -411,7 +411,7 @@ elseif (isset($_GET['pane']) && $_GET['pane'] == 'right') } else { - $dbsize = $user->lang['Not_available']; + $dbsize = $user->lang['NOT_AVAILABLE']; } if (is_int($dbsize)) diff --git a/phpBB/adm/pagestart.php b/phpBB/adm/pagestart.php index e47f6c319e..8f5e2c03d6 100644 --- a/phpBB/adm/pagestart.php +++ b/phpBB/adm/pagestart.php @@ -114,6 +114,11 @@ function page_footer($copyright_html = true) // Close our DB connection. $db->sql_close(); + if (!empty($cache)) + { + $cache->unload(); + } + ?> </td> @@ -126,7 +131,7 @@ function page_footer($copyright_html = true) ?> -<div align="center"><span class="copyright">Powered by phpBB <?php echo $config['version']; ?> © 2002 <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB Group</a></span></div> +<div class="copyright" align="center">Powered by phpBB <?php echo $config['version']; ?> © 2002 <a href="http://www.phpbb.com/" target="_phpbb">phpBB Group</a></div> <br clear="all" /> @@ -136,11 +141,6 @@ function page_footer($copyright_html = true) } - if (!empty($cache)) - { - $cache->unload(); - } - exit; } diff --git a/phpBB/adm/subSilver.css b/phpBB/adm/subSilver.css index 96197f3c16..bfc0b403b7 100644 --- a/phpBB/adm/subSilver.css +++ b/phpBB/adm/subSilver.css @@ -49,36 +49,22 @@ p { */ a:link, a:active, a:visited { color: #006699; -} -a.gen, a.genmed, a.gensmall { - color: #006699; - text-decoration: none; -} -a.nav { - color: #006699; text-decoration: none; } -a.copyright { - color: #444444; - text-decoration: none; -} - -a.gen:hover, a.genmed:hover, a.gensmall:hover { - color: #DD6900; - text-decoration: underline; -} a:hover { color: #DD6900; text-decoration: underline; } -a.nav:hover { - text-decoration: underline; + +a.nav { + color: #006699; + text-decoration: none; } -a.copyright:hover { - color: #DD6900; +a.nav:hover { text-decoration: underline; } + /* Non-tag specific */ @@ -95,6 +81,9 @@ a.copyright:hover { color: black; font: bold 11px; } +.forumlink { + font: bold 120% Verdana, Arial, Helvetica, sans-serif; +} .name { color: black; font-size: 11px; diff --git a/phpBB/common.php b/phpBB/common.php index 4428337f0c..926c692c86 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -88,6 +88,9 @@ define('GROUP_SPECIAL', 3); define('GROUP_FREE', 4); // Forum/Topic states +define('FORUM_CAT', 0); +define('FORUM_POST', 1); +define('FORUM_LINK', 2); define('ITEM_UNLOCKED', 0); define('ITEM_LOCKED', 1); define('ITEM_MOVED', 2); diff --git a/phpBB/imagesets/subSilver/folder_link_big.gif b/phpBB/imagesets/subSilver/folder_link_big.gif Binary files differnew file mode 100644 index 0000000000..d5e86d47d7 --- /dev/null +++ b/phpBB/imagesets/subSilver/folder_link_big.gif diff --git a/phpBB/imagesets/subSilver/subfolder_big.gif b/phpBB/imagesets/subSilver/subfolder_big.gif Binary files differindex c29bb43f49..9179303e7f 100644 --- a/phpBB/imagesets/subSilver/subfolder_big.gif +++ b/phpBB/imagesets/subSilver/subfolder_big.gif diff --git a/phpBB/imagesets/subSilver/subfolder_new_big.gif b/phpBB/imagesets/subSilver/subfolder_new_big.gif Binary files differindex fa9332d958..af3c93b1a1 100644 --- a/phpBB/imagesets/subSilver/subfolder_new_big.gif +++ b/phpBB/imagesets/subSilver/subfolder_new_big.gif diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 8adc170b1f..78fcc9ba2f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -116,13 +116,13 @@ function generate_forum_nav(&$forum_data) { $template->assign_block_vars('navlinks', array( 'FORUM_NAME' => $parent_name, - 'U_VIEW_FORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $parent_forum_id) + 'U_VIEW_FORUM' => "viewforum.$phpEx$SID&f=$parent_forum_id") ); } $template->assign_block_vars('navlinks', array( 'FORUM_NAME' => $forum_data['forum_name'], - 'U_VIEW_FORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $forum_data['forum_id']) + 'U_VIEW_FORUM' => "viewforum.$phpEx$SID&f=" . $forum_data['forum_id']) ); $template->assign_vars(array( @@ -224,7 +224,7 @@ function gen_forum_rules($mode, &$forum_id) return; } -function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key, &$sort_dir, &$s_limit_days, &$s_sort_key, &$s_sort_dir) +function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key, &$sort_dir, &$s_limit_days, &$s_sort_key, &$s_sort_dir, &$u_sort_param) { global $user; @@ -254,6 +254,8 @@ function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key, } $s_sort_dir .= '</select>'; + $u_sort_param = "st=$sort_days&sk=$sort_key&sd=$sort_dir"; + return; } @@ -262,7 +264,7 @@ function make_jumpbox($action, $forum_id = false, $select_all = false) global $auth, $template, $user, $db, $nav_links, $phpEx, $SID; $boxstring = ''; - $sql = 'SELECT forum_id, forum_name, forum_postable, left_id, right_id + $sql = 'SELECT forum_id, forum_name, forum_type, left_id, right_id FROM ' . FORUMS_TABLE . ' ORDER BY left_id ASC'; $result = $db->sql_query($sql, 600); @@ -271,7 +273,7 @@ function make_jumpbox($action, $forum_id = false, $select_all = false) $padding = $forum_list = $holding = ''; while ($row = $db->sql_fetchrow($result)) { - if (!$row['forum_postable'] && ($row['left_id'] + 1 == $row['right_id'])) + if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) { // Non-postable forum with no subforums, don't display continue; @@ -447,10 +449,7 @@ function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $mat $db->sql_query($sql); } - $template->assign_vars(array( - 'META' => '<meta http-equiv="refresh" content="3;url=' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&start=$start" . '">') - ); - + meta_refresh(3, "view$mode.$phpEx$SID&$u_url=$match_id&start=$start"); $message = $user->lang['NOT_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&start=$start" . '">', '</a>'); trigger_error($message); } @@ -481,10 +480,7 @@ function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $mat $db->sql_query($sql); } - $template->assign_vars(array( - 'META' => '<meta http-equiv="refresh" content="3;url=' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&start=$start" . '">') - ); - + meta_refresh(3, "view$mode.$phpEx$SID&$u_url=$match_id&start=$start"); $message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&start=$start" . '">', '</a>'); trigger_error($message); } @@ -512,14 +508,14 @@ function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $mat if ($can_watch) { - $s_watching = ($is_watching) ? '<a href="' . "view$mode." . $phpEx . $SID . '&' . $u_url . "=$match_id&unwatch=$mode&start=$start" . '">' . $user->lang['STOP_WATCHING_' . strtoupper($mode)] . '</a>' : '<a href="' . "view$mode." . $phpEx . $SID . '&' . $u_url . "=$match_id&watch=$mode&start=$start" . '">' . $user->lang['START_WATCHING_' . strtoupper($mode)] . '</a>'; + $s_watching = ($is_watching) ? "<a href=\"view$mode.$phpEx$SID&$u_url=$match_id&unwatch=$mode&start=$start\">" . $user->lang['STOP_WATCHING_' . strtoupper($mode)] . '</a>' : "<a href=\"view$mode.$phpEx$SID&$u_url=$match_id&watch=$mode&start=$start\">" . $user->lang['START_WATCHING_' . strtoupper($mode)] . '</a>'; } return; } // Marks a topic or form as read -function markread($mode, $forum_id = 0, $topic_id = 0, $post_id = 0) +function markread($mode, $forum_id = 0, $topic_id = 0, $marktime = false) { global $config, $db, $user; @@ -530,7 +526,7 @@ function markread($mode, $forum_id = 0, $topic_id = 0, $post_id = 0) // Default tracking type $type = TRACK_NORMAL; - $current_time = time(); + $current_time = ($marktime) ? $marktime : time(); switch ($mode) { @@ -857,7 +853,7 @@ function generate_board_url() // Redirects the user to another page then exits the script nicely function redirect($url) { - global $db, $cache, $config; + global $db, $cache, $config, $user; if (isset($db)) { @@ -869,13 +865,14 @@ function redirect($url) $cache->unload(); } - $url = generate_board_url() . preg_replace('#^/?(.*?)/?$#', '/\1', trim($url)); + // Local redirect? If not, prepend the boards url + $url = (!strstr($url, '://')) ? (generate_board_url() . preg_replace('#^/?(.*?)/?$#', '/\1', trim($url))) : $url; // Redirect via an HTML form for PITA webservers if (@preg_match('#Microsoft|WebSTAR|Xitami#', getenv('SERVER_SOFTWARE'))) { header('Refresh: 0; URL=' . $url); - echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="refresh" content="0; url=' . $url . '"><title>Redirect</title></head><body><div align="center">If your browser does not support meta redirection please click <a href="' . $url . '">HERE</a> to be redirected</div></body></html>'; + echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="refresh" content="0; url=' . $url . '"><title>Redirect</title></head><body><div align="center">' . sprintf($user->lang['URL_REDIRECT'], '<a href="' . $url . '">', '</a>') . '</div></body></html>'; exit; } @@ -1045,5 +1042,339 @@ function msg_handler($errno, $msg_text, $errfile, $errline) break; } } +/* +// +function page_header($page_title = '') +{ + global $db, $config, $template, $user, $auth, $cache; + + define('HEADER_INC', TRUE); + + // gzip_compression + if ($config['gzip_compress']) + { + if (extension_loaded('zlib') && !headers_sent()) + { + ob_start('ob_gzhandler'); + } + } + + // Generate logged in/logged out status + if ($user->data['user_id'] != ANONYMOUS) + { + $u_login_logout = 'ucp.'.$phpEx. $SID . '&mode=logout'; + $l_login_logout = sprintf($user->lang['LOGOUT_USER'], $user->data['username']); + } + else + { + $u_login_logout = 'ucp.'.$phpEx . $SID . '&mode=login'; + $l_login_logout = $user->lang['LOGIN']; + } + + // Last visit date/time + $s_last_visit = ($user->data['user_id'] != ANONYMOUS) ? $user->format_date($user->data['session_last_visit']) : ''; + + // Get users online list ... if required + $l_online_users = $online_userlist = $l_online_record = ''; + if (!empty($config['load_online']) && !empty($config['load_online_time'])) + { + $userlist_ary = $userlist_visible = array(); + $logged_visible_online = $logged_hidden_online = $guests_online = 0; + + $prev_user_id = 0; + $prev_user_ip = $reading_sql = ''; + if (!empty($_REQUEST['f'])) + { + $reading_sql = "AND s.session_page LIKE '%f=" . intval($_REQUEST['f']) . "%'"; + } + + $sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_colour, s.session_ip, s.session_allow_viewonline + FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE ." s + WHERE s.session_time >= " . (time() - (intval($config['load_online_time']) * 60)) . " + $reading_sql + AND u.user_id = s.session_user_id + ORDER BY u.username ASC, s.session_ip ASC"; + $result = $db->sql_query($sql, false); + + while ($row = $db->sql_fetchrow($result)) + { + // User is logged in and therefor not a guest + if ($row['user_id'] != ANONYMOUS) + { + // Skip multiple sessions for one user + if ($row['user_id'] != $prev_user_id) + { + if ($row['user_colour']) + { + $row['username'] = '<b style="color:#' . $row['user_colour'] . '">' . $row['username'] . '</b>'; + } + + if ($row['user_allow_viewonline'] && $row['session_allow_viewonline']) + { + $user_online_link = $row['username']; + $logged_visible_online++; + } + else + { + $user_online_link = '<i>' . $row['username'] . '</i>'; + $logged_hidden_online++; + } + + if ($row['user_allow_viewonline'] || $auth->acl_get('u_viewonline')) + { + $user_online_link = '<a href="' . "memberlist.$phpEx$SID&mode=viewprofile&u=" . $row['user_id'] . '">' . $user_online_link . '</a>'; + $online_userlist .= ($online_userlist != '') ? ', ' . $user_online_link : $user_online_link; + } + } + + $prev_user_id = $row['user_id']; + } + else + { + // Skip multiple sessions for one user + if ($row['session_ip'] != $prev_session_ip) + { + $guests_online++; + } + } + + $prev_session_ip = $row['session_ip']; + } + + if ($online_userlist == '') + { + $online_userlist = $user->lang['NONE']; + } + + if (empty($_REQUEST['f'])) + { + $online_userlist = $user->lang['Registered_users'] . ' ' . $online_userlist; + } + else + { + $l_online = ($guests_online == 1) ? $user->lang['Browsing_forum_guest'] : $user->lang['Browsing_forum_guests']; + $online_userlist = sprintf($l_online, $online_userlist, $guests_online); + } + + $total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online; + + if ($total_online_users > $config['record_online_users']) + { + set_config('record_online_users', $total_online_users, TRUE); + set_config('record_online_date', time(), TRUE); + } + + // Build online listing + $vars_online = array( + 'ONLINE'=> array('total_online_users', 'l_t_user_s'), + 'REG' => array('logged_visible_online', 'l_r_user_s'), + 'HIDDEN'=> array('logged_hidden_online', 'l_h_user_s'), + 'GUEST' => array('guests_online', 'l_g_user_s') + ); + + foreach ($vars_online as $l_prefix => $var_ary) + { + switch ($$var_ary[0]) + { + case 0: + $$var_ary[1] = $user->lang[$l_prefix . '_USERS_ZERO_TOTAL']; + break; + + case 1: + $$var_ary[1] = $user->lang[$l_prefix . '_USER_TOTAL']; + break; + + default: + $$var_ary[1] = $user->lang[$l_prefix . '_USERS_TOTAL']; + break; + } + } + unset($vars_online); + + $l_online_users = sprintf($l_t_user_s, $total_online_users); + $l_online_users .= sprintf($l_r_user_s, $logged_visible_online); + $l_online_users .= sprintf($l_h_user_s, $logged_hidden_online); + $l_online_users .= sprintf($l_g_user_s, $guests_online); + $l_online_record = sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'], $user->format_date($config['record_online_date'])); + $l_online_time = ($config['load_online_time'] == 1) ? 'VIEW_ONLINE_TIME' : 'VIEW_ONLINE_TIMES'; + $l_online_time = sprintf($user->lang[$l_online_time], $config['load_online_time']); + } + + // Obtain number of new private messages if user is logged in + if ($user->data['user_id'] != ANONYMOUS) + { + if ($user->data['user_new_privmsg']) + { + $l_message_new = ($user->data['user_new_privmsg'] == 1) ? $user->lang['New_pm'] : $user->lang['New_pms']; + $l_privmsgs_text = sprintf($l_message_new, $user->data['user_new_privmsg']); + + if ($user->data['user_last_privmsg'] > $user->data['session_last_visit']) + { + $sql = "UPDATE " . USERS_TABLE . " + SET user_last_privmsg = " . $user->data['session_last_visit'] . " + WHERE user_id = " . $user->data['user_id']; + $db->sql_query($sql); + + $s_privmsg_new = 1; + } + else + { + $s_privmsg_new = 0; + } + } + else + { + $l_privmsgs_text = $user->lang['No_new_pm']; + $s_privmsg_new = 0; + } + + if ($user->data['user_unread_privmsg']) + { + $l_message_unread = ($user->data['user_unread_privmsg'] == 1) ? $user->lang['Unread_pm'] : $user->lang['Unread_pms']; + $l_privmsgs_text_unread = sprintf($l_message_unread, $user->data['user_unread_privmsg']); + } + else + { + $l_privmsgs_text_unread = $user->lang['No_unread_pm']; + } + } + + // Generate HTML required for Mozilla Navigation bar + $nav_links_html = ''; + * + $nav_link_proto = '<link rel="%s" href="%s" title="%s" />' . "\n"; + foreach ($nav_links as $nav_item => $nav_array) + { + if (!empty($nav_array['url'])) + { + $nav_links_html .= sprintf($nav_link_proto, $nav_item, $nav_array['url'], $nav_array['title']); + } + else + { + // We have a nested array, used for items like <link rel='chapter'> that can occur more than once. + foreach ($nav_array as $key => $nested_array) + { + $nav_links_html .= sprintf($nav_link_proto, $nav_item, $nested_array['url'], $nested_array['title']); + } + } + } + * + + // Which timezone? + $tz = ($user->data['user_id'] != ANONYMOUS) ? strval(doubleval($user->data['user_timezone'])) : strval(doubleval($config['board_timezone'])); + + // The following assigns all _common_ variables that may be used at any point + // in a template. + $template->assign_vars(array( + 'SITENAME' => $config['sitename'], + 'SITE_DESCRIPTION' => $config['site_desc'], + 'PAGE_TITLE' => $page_title, + 'LAST_VISIT_DATE' => sprintf($user->lang['YOU_LAST_VISIT'], $s_last_visit), + 'CURRENT_TIME' => sprintf($user->lang['CURRENT_TIME'], $user->format_date(time())), + 'TOTAL_USERS_ONLINE' => $l_online_users, + 'LOGGED_IN_USER_LIST' => $online_userlist, + 'RECORD_USERS' => $l_online_record, + 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, + 'PRIVATE_MESSAGE_NEW_FLAG' => $s_privmsg_new, + 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, + + 'L_LOGIN_LOGOUT' => $l_login_logout, + 'L_INDEX' => $user->lang['FORUM_INDEX'], + 'L_ONLINE_EXPLAIN' => $l_online_time, + + 'U_PRIVATEMSGS' => 'ucp.'.$phpEx.$SID.'&mode=pm&folder=inbox', + 'U_MEMBERLIST' => 'memberlist.'.$phpEx.$SID, + 'U_VIEWONLINE' => 'viewonline.'.$phpEx.$SID, + 'U_MEMBERSLIST' => 'memberlist.'.$phpEx.$SID, + 'U_GROUP_CP' => 'groupcp.'.$phpEx.$SID, + 'U_LOGIN_LOGOUT'=> $u_login_logout, + 'U_INDEX' => 'index.'.$phpEx.$SID, + 'U_SEARCH' => 'search.'.$phpEx.$SID, + 'U_REGISTER' => 'ucp.'.$phpEx.$SID.'&mode=register', + 'U_PROFILE' => 'ucp.'.$phpEx.$SID.'&mode=editprofile', + 'U_MODCP' => 'mcp.'.$phpEx.$SID, + 'U_FAQ' => 'faq.'.$phpEx.$SID, + 'U_SEARCH_SELF' => 'search.'.$phpEx.$SID.'&search_id=egosearch', + 'U_SEARCH_NEW' => 'search.'.$phpEx.$SID.'&search_id=newposts', + 'U_SEARCH_UNANSWERED' => 'search.'.$phpEx.$SID.'&search_id=unanswered', + + 'S_USER_LOGGED_IN' => ($user->data['user_id'] != ANONYMOUS) ? true : false, + 'S_USER_PM_POPUP' => (!empty($user->data['user_popup_pm'])) ? true : false, + 'S_USER_BROWSER' => $user->data['session_browser'], + 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], + 'S_CONTENT_ENCODING' => $user->lang['ENCODING'], + 'S_CONTENT_DIR_LEFT' => $user->lang['LEFT'], + 'S_CONTENT_DIR_RIGHT' => $user->lang['RIGHT'], + 'S_TIMEZONE' => ($user->data['user_dst'] || ($user->data['user_id'] == ANONYMOUS && $config['board_dst'])) ? sprintf($user->lang['ALL_TIMES'], $user->lang[$tz], $user->lang['tz']['dst']) : sprintf($user->lang['ALL_TIMES'], $user->lang[$tz], ''), + 'S_DISPLAY_ONLINE_LIST' => (!empty($config['load_online'])) ? 1 : 0, + 'S_DISPLAY_SEARCH' => (!empty($config['load_search'])) ? 1 : 0, + 'S_DISPLAY_PM' => (empty($config['privmsg_disable'])) ? 1 : 0, + 'S_DISPLAY_MEMBERLIST' => (isset($auth)) ? $auth->acl_get('u_viewprofile') : 0, + + 'T_STYLESHEET_DATA' => $user->theme['css_data'], + 'T_STYLESHEET_LINK' => 'templates/' . $user->theme['css_external'], + + 'NAV_LINKS' => $nav_links_html) + ); + + if ($config['send_encoding']) + { + header ('Content-type: text/html; charset: ' . $user->lang['ENCODING']); + } + header ('Cache-Control: private, no-cache="set-cookie", pre-check=0, post-check=0'); + header ('Expires: 0'); + header ('Pragma: no-cache'); + + return; +} + +// +function page_footer() +{ + global $db, $config, $template, $user, $auth, $cache, $starttime; + + // Close our DB connection. + $db->sql_close(); + + // Unload cache + if (!empty($cache)) + { + $cache->unload(); + } + + // Output page creation time + if (defined('DEBUG')) + { + $mtime = explode(' ', microtime()); + $totaltime = $mtime[0] + $mtime[1] - $starttime; + + if (!empty($_REQUEST['explain']) && $auth->acl_get('a_')) + { + echo $db->sql_report; + echo "<pre><b>Page generated in $totaltime seconds with " . $db->num_queries . " queries,\nspending " . $db->sql_time . ' doing SQL queries and ' . ($totaltime - $db->sql_time) . ' doing PHP things.</b></pre>'; + + exit; + } + + $debug_output = sprintf('<br /><br />[ Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . ( ( $config['gzip_compress'] ) ? 'On' : 'Off' ) . ' | Load : ' . (($user->load) ? $user->load : 'N/A'), $totaltime); + + if ($auth->acl_get('a_')) + { + $debug_output .= ' | <a href="' . htmlspecialchars($_SERVER['REQUEST_URI']) . '&explain=1">Explain</a>'; + } + $debug_output .= ' ]'; + } + + $template->assign_vars(array( + 'PHPBB_VERSION' => $config['version'], + 'ADMIN_LINK' => ($auth->acl_get('a_')) ? sprintf($user->lang['ACP'], '<a href="' . "adm/index.$phpEx?sid=" . $user->data['session_id'] . '">', '</a>') . '<br /><br />' : '', + 'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '') + ); + + $template->display('body'); + + exit; +} +*/ ?>
\ No newline at end of file diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 01bbd60836..b38a06141c 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -20,21 +20,20 @@ ***************************************************************************/ // Simple version of jumpbox, just lists authed forums -// This needs altering to allow for ignoring acl checks ... they aren't needed -// everywhere ... -function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = false) +function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = false, $ignore_nonpost = false, $ignore_emptycat = true) { global $db, $user, $auth; $right = $cat_right = 0; $forum_list = $padding = $holding = ''; - $acl = ($ignore_acl) ? '' : 'f_list'; - $rowset = get_forum_list($acl, FALSE, FALSE, TRUE); + $acl = ($ignore_acl) ? '' : array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel'); + $rowset = get_forum_list($acl, false, $ignore_nonpost, true); foreach ($rowset as $row) { - if ($row['forum_id'] == $ignore_id) + if ((is_array($ignore_id) && in_array($row['forum_id'], $ignore_id)) || + $row['forum_id'] == $ignore_id) { continue; } @@ -57,15 +56,16 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = $holding = ''; } - if ($row['right_id'] - $row['left_id'] > 1) + if ($row['right_id'] - $row['left_id'] > 1 && $ignore_emptycat) { $cat_right = max($cat_right, $row['right_id']); - $holding .= '<option class="sep" value="' . $row['forum_id'] . '"' . $selected . '>' . $padding . '+ ' . $row['forum_name'] . '</option>'; + $holding .= '<option value="' . $row['forum_id'] . '"' . $selected . '>' . $padding . '+ ' . $row['forum_name'] . '</option>'; } else { - $forum_list .= $holding . '<option value="' . $row['forum_id'] . '"' . $selected . '>' . $padding . '- ' . $row['forum_name'] . '</option>'; + $sep = ($row['right_id'] - $row['left_id'] > 1) ? '+ ' : '- '; + $forum_list .= $holding . '<option value="' . $row['forum_id'] . '"' . $selected . '>' . $padding . $sep . $row['forum_name'] . '</option>'; $holding = ''; } } @@ -88,7 +88,7 @@ function get_forum_list($acl_list = 'f_list', $id_only = TRUE, $postable_only = { // This query is identical to the jumpbox one $expire_time = ($no_cache) ? 0 : 120; - $sql = 'SELECT forum_id, forum_name, forum_postable, left_id, right_id + $sql = 'SELECT forum_id, forum_name, forum_type, left_id, right_id FROM ' . FORUMS_TABLE . ' ORDER BY left_id ASC'; $result = $db->sql_query($sql, $expire_time); @@ -102,7 +102,7 @@ function get_forum_list($acl_list = 'f_list', $id_only = TRUE, $postable_only = $rowset = array(); foreach ($forum_rows as $row) { - if ($postable_only && !$row['forum_postable']) + if ($postable_only && $row['forum_type'] == FORUM_CAT) { continue; } @@ -122,49 +122,45 @@ function move_topics($topic_ids, $forum_id, $auto_sync = TRUE) global $db; $forum_ids = array($forum_id); - $where_sql = (is_array($topic_ids)) ? 'IN (' . implode(', ', $topic_ids) . ')' : '= ' . $topic_ids; + $sql_where = (is_array($topic_ids)) ? 'IN (' . implode(', ', $topic_ids) . ')' : '= ' . $topic_ids; + + $sql = 'DELETE FROM ' . TOPICS_TABLE . " + WHERE topic_moved_id $sql_where + AND forum_id = " . $forum_id; + $db->sql_query($sql); + + $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_MOD_TABLE); + foreach ($table_ary as $table) + { + $sql = "UPDATE $table + SET forum_id = $forum_id + WHERE topic_id " . $sql_where; + $db->sql_query($sql); + } + unset($table_ary); if ($auto_sync) { $sql = 'SELECT DISTINCT forum_id FROM ' . TOPICS_TABLE . ' - WHERE topic_id ' . $where_sql; + WHERE topic_id ' . $sql_where; $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { $forum_ids[] = $row['forum_id']; } - } - - $sql = 'DELETE FROM ' . TOPICS_TABLE . " - WHERE topic_moved_id $where_sql - AND forum_id = " . $forum_id; - $db->sql_query($sql); - - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET forum_id = $forum_id - WHERE topic_id " . $where_sql; - $db->sql_query($sql); - - $sql = 'UPDATE ' . POSTS_TABLE . " - SET forum_id = $forum_id - WHERE topic_id " . $where_sql; - $db->sql_query($sql); - - $sql = 'UPDATE ' . LOG_MOD_TABLE . " - SET forum_id = $forum_id - WHERE topic_id " . $where_sql; - $db->sql_query($sql); + $db->sql_freeresult($result); - if ($auto_sync) - { sync('forum', 'forum_id', $forum_ids, TRUE); + unset($forum_ids); } } function move_posts($post_ids, $topic_id, $auto_sync = TRUE) { global $db; + if (!is_array($post_ids)) { $post_ids = array($post_ids); @@ -179,19 +175,25 @@ function move_posts($post_ids, $topic_id, $auto_sync = TRUE) FROM ' . POSTS_TABLE . ' WHERE post_id IN (' . implode(', ', $post_ids) . ')'; $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { $forum_ids[] = $row['forum_id']; $topic_ids[] = $row['topic_id']; } + $db->sql_freeresult($result); } - $sql = 'SELECT * FROM ' . TOPICS_TABLE . ' WHERE topic_id = ' . $topic_id; + $sql = 'SELECT * + FROM ' . TOPICS_TABLE . ' + WHERE topic_id = ' . $topic_id; $result = $db->sql_query($sql); - if (!$row = $db->sql_fetchrow($result)) + + if (!($row = $db->sql_fetchrow($result))) { - trigger_error('Topic_post_not_exist'); + trigger_error('NO_TOPIC'); } + $db->sql_freeresult($result); $sql = 'UPDATE ' . POSTS_TABLE . ' SET forum_id = ' . $row['forum_id'] . ", topic_id = $topic_id @@ -217,6 +219,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = TRUE) { $where_ids = array_unique($where_ids); } + if (!count($where_ids)) { return array('topics' => 0, 'posts' => '0'); @@ -226,13 +229,13 @@ function delete_topics($where_type, $where_ids, $auto_sync = TRUE) 'posts' => delete_posts($where_type, $where_ids, FALSE) ); - $where_sql = "WHERE $where_type " . ((!is_array($where_ids)) ? "= $where_ids" : 'IN (' . implode(', ', $where_ids) . ')'); +//???? $where_sql = "WHERE $where_type " . ((!is_array($where_ids)) ? "= $where_ids" : 'IN (' . implode(', ', $where_ids) . ')'); $sql = 'SELECT topic_id, forum_id FROM ' . TOPICS_TABLE . " WHERE $where_type " . ((!is_array($where_ids)) ? "= $where_ids" : 'IN (' . implode(', ', $where_ids) . ')'); - $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { $forum_ids[] = $row['forum_id']; @@ -247,17 +250,25 @@ function delete_topics($where_type, $where_ids, $auto_sync = TRUE) return $return; } - // TODO: clean up topics cache if any, last read marking, probably some other stuff too + // TODO: probably some other stuff too - $where_sql = ' IN (' . implode(', ', $topic_ids) . ')'; + $sql_where = ' IN (' . implode(', ', $topic_ids) . ')'; $db->sql_transaction('begin'); - $db->sql_query('DELETE FROM ' . LASTREAD_TABLE . ' WHERE topic_id' . $where_sql); - $db->sql_query('DELETE FROM ' . POLL_VOTES_TABLE . ' WHERE topic_id' . $where_sql); - $db->sql_query('DELETE FROM ' . POLL_OPTIONS_TABLE . ' WHERE topic_id' . $where_sql); - $db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE topic_id' . $where_sql); - $db->sql_query('DELETE FROM ' . TOPICS_TABLE . ' WHERE topic_moved_id' . $where_sql); - $db->sql_query('DELETE FROM ' . TOPICS_TABLE . ' WHERE topic_id' . $where_sql); + + $table_ary = array(TOPICS_TRACK_TABLE, POLL_VOTES_TABLE, POLL_OPTIONS_TABLE, TOPICS_WATCH_TABLE, TOPICS_TABLE); + foreach ($table_ary as $table) + { + $sql = "DELETE FROM $table + WHERE topic_id $sql_where"; + $db->sql_query($sql); + } + unset($table_ary); + + $sql = 'DELETE FROM ' . TOPICS_TABLE . ' + WHERE topic_moved_id' . $sql_where; + $db->sql_query($sql); + $db->sql_transaction('commit'); if ($auto_sync) @@ -266,6 +277,23 @@ function delete_topics($where_type, $where_ids, $auto_sync = TRUE) sync('topic_reported', $where_type, $where_ids); } + // Optimize/vacuum tables + switch (SQL_LAYER) + { + case 'mysql': + case 'mysql4': + $table_ary = array(TOPICS_TRACK_TABLE, POLL_VOTES_TABLE, POLL_OPTIONS_TABLE, TOPICS_WATCH_TABLE, TOPICS_TABLE); + $sql = 'OPTIMIZE TABLE ' . implode(', ', $table_ary); + $db->sql_query($sql); + unset($table_ary); + + break; + + case 'postgresql': + $db->sql_query('VACUUM'); + break; + } + return $return; } @@ -301,13 +329,19 @@ function delete_posts($where_type, $where_ids, $auto_sync = TRUE) return false; } - $where_sql = ' WHERE post_id IN (' . implode(', ', $post_ids) . ')'; + $sql_where = implode(', ', $post_ids); $db->sql_transaction('begin'); - $db->sql_query('DELETE FROM ' . POSTS_TABLE . $where_sql); - $db->sql_query('DELETE FROM ' . RATINGS_TABLE . $where_sql); - $db->sql_query('DELETE FROM ' . REPORTS_TABLE . $where_sql); - $db->sql_query('DELETE FROM ' . SEARCH_MATCH_TABLE . $where_sql); + + $table_ary = array(POSTS_TABLE, RATINGS_TABLE, REPORTS_TABLE, SEARCH_MATCH_TABLE); + foreach ($table_ary as $table) + { + $sql = "DELETE FROM $table + WHERE post_id IN ($sql_where)"; + $db->sql_query($sql); + } + unset($table_ary); + $db->sql_transaction('commit'); delete_attachment($post_ids); @@ -319,18 +353,35 @@ function delete_posts($where_type, $where_ids, $auto_sync = TRUE) sync('forum', 'forum_id', $forum_ids, TRUE); } + // Optimize/vacuum tables + switch (SQL_LAYER) + { + case 'mysql': + case 'mysql4': + $table_ary = array(POSTS_TABLE, RATINGS_TABLE, REPORTS_TABLE, SEARCH_MATCH_TABLE); + $sql = 'OPTIMIZE TABLE ' . implode(', ', $table_ary); + $db->sql_query($sql); + unset($table_ary); + + break; + + case 'postgresql': + $db->sql_query('VACUUM'); + break; + } + return count($post_ids); } +// All-encompasing sync function // // Usage: // sync('topic', 'topic_id', 123); <= resynch topic #123 // sync('topic', 'forum_id', array(2, 3)); <= resynch topics from forum #2 and #3 // sync('topic'); <= resynch all topics -// function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, $sync_extra = FALSE) { - global $db, $dbms; + global $db; if (is_array($where_ids)) { @@ -351,13 +402,13 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, else { $where_sql = 'WHERE ' . $mode{0} . ".$where_type IN (" . implode(', ', $where_ids) . ')'; - $where_sql_and = $where_sql . "\n\tAND"; + $where_sql_and = $where_sql . ' AND'; } } else { $where_sql = "WHERE t.$where_type IN (" . implode(', ', $where_ids) . ')'; - $where_sql_and = $where_sql . "\n\tAND"; + $where_sql_and = $where_sql . ' AND'; } switch ($mode) @@ -370,7 +421,6 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, $result = $db->sql_query($sql); $topic_ids = $approved_unapproved_ids = array(); - while ($row = $db->sql_fetchrow($result)) { $approved_unapproved_ids[] = $row['topic_id']; @@ -386,29 +436,34 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, SET topic_approved = 1 - topic_approved WHERE topic_id IN (' . implode(', ', $approved_unapproved_ids) . ')'; $db->sql_query($sql); - break; + break; case 'post_attachment': $post_ids = array(); - switch ($dbms) + switch (SQL_LAYER) { + case 'oracle': + //TODO + break; + default: $sql = 'SELECT t.post_id, t.post_attachment, COUNT(a.attachment_id) AS attachments FROM ' . POSTS_TABLE . ' t LEFT JOIN ' . ATTACHMENTS_TABLE . " a ON t.post_id = a.post_id $where_sql GROUP BY t.post_id"; + } + $result = $db->sql_query($sql); - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - if (($row['post_attachment'] && !$row['attachments']) || ($row['attachments'] && !$row['post_attachment'])) - { - $post_ids[] = $row['post_id']; - } - } + while ($row = $db->sql_fetchrow($result)) + { + if (($row['post_attachment'] && !$row['attachments']) || ($row['attachments'] && !$row['post_attachment'])) + { + $post_ids[] = $row['post_id']; + } } + $db->sql_freeresult($result); if (!count($post_ids)) { @@ -419,32 +474,37 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, SET post_attachment = 1 - post_attachment WHERE post_id IN (' . implode(', ', $post_ids) . ')'; $db->sql_query($sql); - break; + break; case 'topic_attachment': - $topic_ids = array(); - switch ($dbms) + switch (SQL_LAYER) { + case 'oracle': + //TODO + break; + default: $sql = 'SELECT t.topic_id, t.topic_attachment, COUNT(a.attachment_id) AS attachments FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p LEFT JOIN ' . ATTACHMENTS_TABLE . " a ON p.post_id = a.post_id $where_sql_and t.topic_id = p.topic_id AND ((t.topic_attachment = 1 AND attachments = 0) - OR (t.topic_attachment = 0 AND attachments > 0)) + OR (t.topic_attachment = 0 AND attachments > 0)) GROUP BY t.topic_id"; + } + $result = $db->sql_query($sql); - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - if (($row['topic_attachment'] && !$row['attachments']) - || ($row['attachments'] && !$row['topic_attachment'])) - { - $topic_ids[] = $row['topic_id']; - } - } + $topic_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + if (($row['topic_attachment'] && !$row['attachments']) + || ($row['attachments'] && !$row['topic_attachment'])) + { + $topic_ids[] = $row['topic_id']; + } } + $db->sql_freeresult($result); if (count($topic_ids)) { @@ -455,98 +515,122 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, SET topic_attachment = 1 - topic_attachment WHERE topic_id IN (' . implode(', ', $topic_ids) . ')'; $db->sql_query($sql); - break; + break; case 'reported': $topic_data = $topic_ids = $post_ids = array(); if ($sync_extra) { - // NOTE: untested - $sql = 'SELECT p.post_id - FROM ' . POSTS_TABLE . ' t - LEFT JOIN ' . REPORTS_TABLE . " r ON r.post_id = t.post_id - $where_sql - AND ((t.post_reported = 1 AND r.post_id IS NULL) - OR (t.post_reported = 0 AND r.post_id > 0)) - GROUP p.post_id"; - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + switch (SQL_LAYER) { - $post_ids[] = $row['post_id']; + case 'oracle': + //TODO + break; + + default: + // NOTE: untested + $sql = 'SELECT p.post_id + FROM ' . POSTS_TABLE . ' t + LEFT JOIN ' . REPORTS_TABLE . " r ON r.post_id = t.post_id + $where_sql + AND ((t.post_reported = 1 AND r.post_id IS NULL) + OR (t.post_reported = 0 AND r.post_id > 0)) + GROUP p.post_id"; } - $db->sql_freeresult(); + $result = $db->sql_query($sql); - if (count($post_ids)) + if ($row = $db->sql_fetchrow($result)) { + do + { + $post_ids[] = $row['post_id']; + } + while ($row = $db->sql_fetchrow($result)); + $sql = 'UPDATE ' . POSTS_TABLE . ' SET post_reported = 1 - post_reported WHERE post_id IN (' . implode(', ', $post_ids) . ')'; $db->sql_query($sql); unset($post_ids); } + $db->sql_freeresult(); } - // NOTE: untested - $sql = 'SELECT t.topic_id, t.topic_reported, p.post_reported - FROM ' . TOPICS_TABLE . ' t - LEFT JOIN ' . POSTS_TABLE . " p ON p.topic_id = t.topic_id - $where_sql - GROUP BY p.topic_id, p.post_reported"; + switch (SQL_LAYER) + { + case 'oracle': + //TODO + break; + + default: + // NOTE: untested + $sql = 'SELECT t.topic_id, t.topic_reported, p.post_reported + FROM ' . TOPICS_TABLE . ' t + LEFT JOIN ' . POSTS_TABLE . " p ON p.topic_id = t.topic_id + $where_sql + GROUP BY p.topic_id, p.post_reported"; + } $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + if ($row = $db->sql_fetchrow($result)) { - if (!isset($topic_data[$row['topic_id']])) - { - $topic_data[$row['topic_id']] = array( - 'topic_reported' => $row['topic_reported'], - 'post_reported' => $row['post_reported'] - ); - } - else + do { - $topic_data[$row['topic_id']]['post_reported'] |= $row['post_reported']; + if (!isset($topic_data[$row['topic_id']])) + { + $topic_data[$row['topic_id']] = array( + 'topic_reported' => $row['topic_reported'], + 'post_reported' => $row['post_reported'] + ); + } + else + { + $topic_data[$row['topic_id']]['post_reported'] |= $row['post_reported']; + } } - } + while ($row = $db->sql_fetchrow($result)); - foreach ($topic_data as $topic_id => $row) - { - if ($row['post_reported'] != $row['topic_reported']) + foreach ($topic_data as $topic_id => $row) { - $topic_ids[] = $topic_id; + if ($row['post_reported'] != $row['topic_reported']) + { + $topic_ids[] = $topic_id; + } } - } - if (count($topic_ids)) - { $sql = 'UPDATE ' . TOPICS_TABLE . ' SET topic_reported = 1 - topic_reported WHERE topic_id IN (' . implode(', ', $topic_ids) . ')'; $db->sql_query($sql); + unset($topic_ids); } + $db->sql_freeresult($result); + return; - break; + break; case 'forum': if ($resync_parents) { - $forum_ids = array(); - $sql = 'SELECT f2.forum_id FROM ' . FORUMS_TABLE . ' f, ' . FORUMS_TABLE . " f2 $where_sql_and f.left_id BETWEEN f2.left_id AND f2.right_id"; - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = $row['forum_id']; - } - if (count($forum_ids)) + if ($row = $db->sql_fetchrow($result)) { + $forum_ids = array(); + do + { + $forum_ids[] = $row['forum_id']; + } + while ($row = $db->sql_fetchrow($result)); + sync('forum', 'forum_id', $forum_ids, FALSE); + unset($forum_ids); } + $db->sql_freeresult($result); return; } @@ -555,12 +639,16 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, $sql = 'SELECT f.*, f2.forum_id AS id FROM ' . FORUMS_TABLE . ' f, ' . FORUMS_TABLE . " f2 $where_sql_and f2.left_id BETWEEN f.left_id AND f.right_id"; + $result = $db->sql_query($sql); $forum_data = $forum_ids = $post_ids = $subforum_list = $post_count = $last_post_id = $post_info = $topic_count = $topic_count_real = array(); - - $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { + if ($row['forum_type'] == FORUM_LINK) + { + continue; + } + $forum_ids[$row['id']] = $row['id']; if (!isset($subforum_list[$row['forum_id']])) { @@ -596,6 +684,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, { $topic_count_real[$row['forum_id']] += $row['forum_topics']; } + if ($row['topic_approved']) { $topic_count[$row['forum_id']] = $row['forum_topics']; @@ -624,6 +713,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, $forum_data[$forum_id]['topics'] += $topic_count[$subforum_id]; $forum_data[$forum_id]['topics_real'] += $topic_count_real[$subforum_id]; } + if (isset($post_count[$subforum_id])) { $forum_data[$forum_id]['posts'] += $post_count[$subforum_id]; @@ -640,6 +730,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, $post_ids[] = $data['last_post_id']; } } + if (count($post_ids)) { $sql = 'SELECT p.post_id, p.poster_id, u.username, p.post_time @@ -682,35 +773,21 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, { if (preg_match('#name$#', $fieldname)) { - if (isset($row[$fieldname])) - { - $sql['forum_' . $fieldname] = (string) $row[$fieldname]; - } - else - { - $sql['forum_' . $fieldname] = ''; - } + $sql['forum_' . $fieldname] = (isset($row[$fieldname])) ? (string) $row[$fieldname] : ''; } else { - if (isset($row[$fieldname])) - { - $sql['forum_' . $fieldname] = (int) $row[$fieldname]; - } - else - { - $sql['forum_' . $fieldname] = 0; - } + $sql['forum_' . $fieldname] = (isset($row[$fieldname])) ? (int) $row[$fieldname] : 0; } } - $sql = 'UPDATE ' . FORUMS_TABLE . ' + $sql = 'UPDATE ' . FORUMS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql) . ' WHERE forum_id = ' . $forum_id; $db->sql_query($sql); } } - break; + break; case 'topic': $topic_data = $topic_ids = $post_ids = $approved_unapproved_ids = $resync_forums = array(); @@ -719,8 +796,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p $where_sql_and p.topic_id = t.topic_id GROUP BY p.topic_id, p.post_approved"; - $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { $row['total_posts'] = intval($row['total_posts']); @@ -766,7 +843,6 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, if (!count($topic_ids)) { // If we get there, topic ids were invalid or topics did not contain any posts - delete_topics($where_type, $where_ids); return; } @@ -830,10 +906,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE p.post_id IN (' . implode(', ', $post_ids) . ') AND u.user_id = p.poster_id'; + $result = $db->sql_query($sql); $post_ids = array(); - - $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if ($row['post_id'] == $topic_data[$row['topic_id']]['first_post_id']) @@ -874,33 +949,35 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, { // This routine assumes that post_reported values are correct // if they are not, use sync('reported') instead - $fieldnames[] = 'reported'; $sql = 'SELECT t.topic_id, p.post_id FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p $where_sql_and p.topic_id = t.topic_id AND p.post_reported = 1 GROUP t.topic_id"; - $result = $db->sql_query($sql); + + $fieldnames[] = 'reported'; while ($row = $db->sql_fetchrow($result)) { $topic_data[$row['topic_id']]['reported'] = 1; } + $db->sql_freeresult($result); // This routine assumes that post_attachment values are correct // if they are not, use sync('post_attachment') instead - $fieldnames[] = 'attachment'; $sql = 'SELECT t.topic_id, p.post_id FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p $where_sql_and p.topic_id = t.topic_id AND p.post_attachment = 1 GROUP t.topic_id"; - $result = $db->sql_query($sql); + + $fieldnames[] = 'attachment'; while ($row = $db->sql_fetchrow($result)) { $topic_data[$row['topic_id']]['attachment'] = 1; } + $db->sql_freeresult($result); } foreach ($topic_data as $topic_id => $row) @@ -929,8 +1006,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, // NOTE: should shadow topics be updated as well? $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql) . ' - WHERE topic_id = ' . $topic_id; + SET ' . $db->sql_build_array('UPDATE', $sql) . ' + WHERE topic_id = ' . $topic_id; $db->sql_query($sql); $resync_forums[] = $row['forum_id']; @@ -948,17 +1025,21 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, GROUP BY f.forum_id'; $result = $db->sql_query($sql); - $forum_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = $row['forum_id']; - } - if (count($forum_ids)) + if ($row = $db->sql_fetchrow($result)) { + $forum_ids = array(); + do + { + $forum_ids[] = $row['forum_id']; + } + while ($row = $db->sql_fetchrow($result)); + sync('forum', 'forum_id', $forum_ids, FALSE); + unset($forum_ids); } + $db->sql_freeresult($result); } - break; + break; } } @@ -1003,8 +1084,7 @@ function prune($forum_id, $prune_date = '', $auto_sync = TRUE) } $db->sql_freeresult($result); - $p_result = delete_topics('topic_id', $topic_list, $auto_sync); - return $p_result; + return delete_topics('topic_id', $topic_list, $auto_sync); } // Function auto_prune(), this function now relies on passed vars @@ -1036,7 +1116,7 @@ function remove_comments(&$output) $in_comment = false; for($i = 0; $i < $linecount; $i++) { - if (preg_match('/^\/\*/', preg_quote($lines[$i]))) + if (preg_match('#^\/\*#', preg_quote($lines[$i]))) { $in_comment = true; } @@ -1046,7 +1126,7 @@ function remove_comments(&$output) $output .= $lines[$i] . "\n"; } - if (preg_match('/\*\/$/', preg_quote($lines[$i]))) + if (preg_match('#\*\/$#', preg_quote($lines[$i]))) { $in_comment = false; } @@ -1103,10 +1183,10 @@ function split_sql_file($sql, $delimiter) if ($i != $token_count - 1 || strlen($tokens[$i] > 0)) { // This is the total number of single quotes in the token. - $total_quotes = preg_match_all("/'/", $tokens[$i], $matches); + $total_quotes = preg_match_all("#'#", $tokens[$i], $matches); // Counts single quotes that are preceded by an odd number of backslashes, // which means they're escaped quotes. - $escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$i], $matches); + $escaped_quotes = preg_match_all("#(?<!\\\\)(\\\\\\\\)*\\\\'#", $tokens[$i], $matches); $unescaped_quotes = $total_quotes - $escaped_quotes; @@ -1132,10 +1212,10 @@ function split_sql_file($sql, $delimiter) for ($j = $i + 1; (!$complete_stmt && ($j < $token_count)); $j++) { // This is the total number of single quotes in the token. - $total_quotes = preg_match_all("/'/", $tokens[$j], $matches); + $total_quotes = preg_match_all("#'#", $tokens[$j], $matches); // Counts single quotes that are preceded by an odd number of backslashes, // which means they're escaped quotes. - $escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$j], $matches); + $escaped_quotes = preg_match_all("#(?<!\\\\)(\\\\\\\\)*\\\\'#", $tokens[$j], $matches); $unescaped_quotes = $total_quotes - $escaped_quotes; @@ -1170,10 +1250,8 @@ function split_sql_file($sql, $delimiter) return $output; } -// Cache moderators, called whenever permissions are -// changed via admin_permissions. Changes of username -// and group names must be carried through for the -// moderators table +// Cache moderators, called whenever permissions are changed via admin_permissions. Changes of username +// and group names must be carried through for the moderators table function cache_moderators() { global $db; diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index ce93a1c4e5..487fd129e9 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -81,7 +81,7 @@ function display_forums($root_data = '', $display_moderators = TRUE) unset($right_id); } - if (!$row['forum_postable'] && ($row['left_id'] + 1 == $row['right_id'])) + if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) { // Non-postable forum with no subforums: don't display continue; @@ -103,7 +103,7 @@ function display_forums($root_data = '', $display_moderators = TRUE) $forum_rows[$forum_id] = $row; $forum_ids[] = $forum_id; - if (!$row['forum_postable'] && $row['parent_id'] == $root_data['forum_id']) + if ($row['forum_type'] == FORUM_CAT && $row['parent_id'] == $root_data['forum_id']) { $branch_root_id = $forum_id; } @@ -122,11 +122,30 @@ function display_forums($root_data = '', $display_moderators = TRUE) $forum_rows[$forum_id]['forum_id_last_post'] = $row['forum_id']; } } - elseif ($row['forum_postable']) + elseif ($row['forum_type'] != FORUM_CAT) { $subforums[$parent_id]['display'] = ($row['display_on_index']) ? true : false;; $subforums[$parent_id]['name'][$forum_id] = $row['forum_name']; + + // Include subforum topic/post counts in parent counts + $forum_rows[$parent_id]['forum_topics'] += $row['forum_topics']; + $forum_rows[$parent_id]['forum_posts'] += $row['forum_posts']; + + // Show most recent last post info on parent if we're a subforum + if (isset($forum_rows[$parent_id]) && $row['forum_last_post_time'] > $forum_rows[$parent_id]['forum_last_post_time']) + { + $forum_rows[$parent_id]['forum_last_post_id'] = $row['forum_last_post_id']; + $forum_rows[$parent_id]['forum_last_post_time'] = $row['forum_last_post_time']; + $forum_rows[$parent_id]['forum_last_poster_id'] = $row['forum_last_poster_id']; + $forum_rows[$parent_id]['forum_last_poster_name'] = $row['forum_last_poster_name']; + $forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id']; + } + else + { + $forum_rows[$forum_id]['forum_id_last_post'] = $row['forum_id']; + } } + /* if (!empty($forum_unread[$forum_id])) { @@ -186,7 +205,7 @@ function display_forums($root_data = '', $display_moderators = TRUE) { if ($row['parent_id'] == $root_id) { - if (!$row['forum_postable']) + if ($row['forum_type'] == FORUM_CAT) { $hold = $row; continue; @@ -243,7 +262,16 @@ function display_forums($root_data = '', $display_moderators = TRUE) } else { - $folder_image = ($forum_unread[$forum_id]) ? 'forum_new' : 'forum'; + switch ($row['forum_type']) + { + case FORUM_POST: + $folder_image = ($forum_unread[$forum_id]) ? 'forum_new' : 'forum'; + break; + + case FORUM_LINK: + $folder_image = 'forum_link'; + break; + } $subforums_list = ''; $l_subforums = ''; @@ -286,8 +314,12 @@ function display_forums($root_data = '', $display_moderators = TRUE) $moderators_list = implode(', ', $forum_moderators[$forum_id]); } + $l_post_click_count = ($row['forum_type'] == FORUM_LINK) ? 'CLICKS' : 'POSTS'; + $post_click_count = ($row['forum_type'] != FORUM_LINK || $row['forum_link_track']) ? $row['forum_posts'] : ''; + $template->assign_block_vars('forumrow', array( - 'S_IS_CAT' => FALSE, + 'S_IS_CAT' => false, + 'S_IS_LINK' => ($row['forum_type'] != FORUM_LINK) ? false : true, 'FORUM_IMG' => $row['forum_image'], 'LAST_POST_IMG' => $user->img('icon_post_latest', 'VIEW_LATEST_POST'), @@ -295,7 +327,7 @@ function display_forums($root_data = '', $display_moderators = TRUE) 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), 'FORUM_NAME' => $row['forum_name'], 'FORUM_DESC' => $row['forum_desc'], - 'POSTS' => $row['forum_posts'], + $l_post_click_count => $post_click_count, 'TOPICS' => $row['forum_topics'], 'LAST_POST_TIME' => $last_post_time, 'LAST_POSTER' => $last_poster, @@ -305,15 +337,15 @@ function display_forums($root_data = '', $display_moderators = TRUE) 'L_SUBFORUM_STR' => $l_subforums, 'L_MODERATOR_STR' => $l_moderator, 'L_FORUM_FOLDER_ALT'=> $folder_alt, - + 'U_LAST_POSTER' => $last_poster_url, 'U_LAST_POST' => $last_post_url, - 'U_VIEWFORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $row['forum_id']) + 'U_VIEWFORUM' => ($row['forum_type'] != FORUM_LINK || $row['forum_link_track']) ? 'viewforum.' . $phpEx . $SID . '&f=' . $row['forum_id'] : $row['forum_link']) ); } $template->assign_vars(array( - 'S_HAS_SUBFORUM' => ($visible_forums) ? TRUE : FALSE, + 'S_HAS_SUBFORUM' => ($visible_forums) ? true : false, 'L_SUBFORUM' => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS']) ); } diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 40eaaf2cfc..ec72d2c940 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -438,8 +438,12 @@ class userdata extends user { global $db, $user; + // Clean up username ... convert any entities into normal + // text, remove excess spaces, then escape it + $username = strtr(trim($username), array_flip(get_html_translation_table(HTML_ENTITIES))); + $username = preg_replace('#[\s]{2,}#', '', $username); $username = $db->sql_escape($username); - + $sql = "SELECT username FROM " . USERS_TABLE . " WHERE LOWER(username) = '" . strtolower($username) . "'"; @@ -500,7 +504,7 @@ class userdata extends user if ($email != '') { - if (preg_match('/^[a-z0-9\.\-_\+]+@[a-z0-9\-_]+\.([a-z0-9\-_]+\.)*?[a-z]+$/is', $email)) + if (preg_match('#^[a-z0-9\.\-_\+]+@[a-z0-9\-_]+\.([a-z0-9\-_]+\.)*?[a-z]+$#is', $email)) { $sql = "SELECT ban_email FROM " . BANLIST_TABLE; diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 241e8cfd7a..c86b093ef8 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -794,7 +794,8 @@ class fulltext_search } } - preg_match_all('/\b([\w]+)\b/', $text, $split_entries); + preg_match_all('#\b([\w]+)\b#', $text, $split_entries); + return array_unique($split_entries[1]); } @@ -824,6 +825,7 @@ class fulltext_search WHERE m.post_id = " . intval($post_id) . " AND w.word_id = m.word_id"; $result = $db->sql_query($sql); + $cur_words = array(); while ($row = $db->sql_fetchrow($result)) { @@ -908,25 +910,33 @@ class fulltext_search { $title_match = ($word_in == 'title') ? 1 : 0; - $sql = ''; if (sizeof($word_ary)) { + $sql_in = array(); foreach ($word_ary as $word) { - $sql .= (($sql != '') ? ', ' : '') . $cur_words[$word_in][$word]; + $sql_in[] = $cur_words[$word_in][$word]; } - $sql = "DELETE FROM " . SEARCH_MATCH_TABLE . " WHERE word_id IN ($sql) AND post_id = " . intval($post_id) . " AND title_match = $title_match"; + + $sql = 'DELETE FROM ' . SEARCH_MATCH_TABLE . ' + WHERE word_id IN (' . implode(', ', $sql_in) . ') + AND post_id = ' . intval($post_id) . " + AND title_match = $title_match"; $db->sql_query($sql); + unset($sql_in); } } foreach ($words['add'] as $word_in => $word_ary) { - $title_match = ( $word_in == 'title' ) ? 1 : 0; + $title_match = ($word_in == 'title') ? 1 : 0; if (sizeof($word_ary)) { - $sql = "INSERT INTO " . SEARCH_MATCH_TABLE . " (post_id, word_id, title_match) SELECT $post_id, word_id, $title_match FROM " . SEARCH_WORD_TABLE . " WHERE word_text IN (" . implode(', ', preg_replace('#^(.*)$#', '\'\1\'', $word_ary)) . ")"; + $sql = 'INSERT INTO ' . SEARCH_MATCH_TABLE . " (post_id, word_id, title_match) + SELECT $post_id, word_id, $title_match + FROM " . SEARCH_WORD_TABLE . ' + WHERE word_text IN (' . implode(', ', preg_replace('#^(.*)$#', '\'\1\'', $word_ary)) . ')'; $db->sql_query($sql); } } @@ -957,58 +967,66 @@ class fulltext_search } // Remove common (> 60% of posts ) words - $result = $db->sql_query("SELECT SUM(forum_posts) AS total_posts FROM " . FORUMS_TABLE); + $sql = "SELECT SUM(forum_posts) AS total_posts + FROM " . FORUMS_TABLE; + $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); if ($row['total_posts'] >= 100) { - $sql = "SELECT word_id - FROM " . SEARCH_MATCH_TABLE . " + $sql = 'SELECT word_id + FROM ' . SEARCH_MATCH_TABLE . ' GROUP BY word_id - HAVING COUNT(word_id) > " . floor($row['total_posts'] * 0.6); + HAVING COUNT(word_id) > ' . floor($row['total_posts'] * 0.6); $result = $db->sql_query($sql); - $in_sql = ''; - while ($row = $db->sql_fetchrow($result)) + if ($row = $db->sql_fetchrow($result)) { - $in_sql .= (( $in_sql != '') ? ', ' : '') . $row['word_id']; - } - $db->sql_freeresult($result); + $sql_in = array(); + do + { + $sql_in[] = $row['word_id']; + } + while ($row = $db->sql_fetchrow($result)); - if ($in_sql) - { - $sql = "UPDATE " . SEARCH_WORD_TABLE . " - SET word_common = " . TRUE . " - WHERE word_id IN ($in_sql)"; + $sql_in = implode(', ', $sql_in); + + $sql = 'UPDATE ' . SEARCH_WORD_TABLE . " + SET word_common = 1 + WHERE word_id IN ($sql_in)"; $db->sql_query($sql); - $sql = "DELETE FROM " . SEARCH_MATCH_TABLE . " - WHERE word_id IN ($in_sql)"; + $sql = 'DELETE FROM ' . SEARCH_MATCH_TABLE . " + WHERE word_id IN ($sql_in)"; $db->sql_query($sql); + unset($sql_in); } + $db->sql_freeresult($result); } // Remove words with no matches ... this is a potentially nasty query - $sql = "SELECT w.word_id - FROM ( " . SEARCH_WORD_TABLE . " w - LEFT JOIN " . SEARCH_MATCH_TABLE . " m ON w.word_id = m.word_id + $sql = 'SELECT w.word_id + FROM ( ' . SEARCH_WORD_TABLE . ' w + LEFT JOIN ' . SEARCH_MATCH_TABLE . ' m ON w.word_id = m.word_id AND m.word_id IS NULL - GROUP BY m.word_id"; + GROUP BY m.word_id'; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { - $in_sql = ''; + $sql_in = array(); do { - $in_sql .= ', ' . $row['word_id']; + $sql_in[] = $row['word_id']; } while ($row = $db->sql_fetchrow($result)); $sql = 'DELETE FROM ' . SEARCH_WORD_TABLE . ' - WHERE word_id IN (' . substr($in_sql, 2) . ')'; + WHERE word_id IN (' . implode(', ', $sql_in) . ')'; $db->sql_query($sql); + unset($sql_in); } $db->sql_freeresult($result); } diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index 4ca701ff9f..09ce07225e 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -37,11 +37,6 @@ to this source */ -// Changes for 2.2: -// -// * Allow use of Smarty plug-ins? -// * Reduce number of methods and variables - class Template { diff --git a/phpBB/index.php b/phpBB/index.php index 8b6b93cf29..2d634ba630 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -27,11 +27,12 @@ include($phpbb_root_path . 'common.'.$phpEx); // Get posted/get info $mark_read = (isset($_REQUEST['mark'])) ? $_REQUEST['mark'] : ''; + // Start session management $user->start(); $user->setup(); $auth->acl($user->data); -// End session management + // Handle marking posts if ($mark_read == 'forums') @@ -130,9 +131,13 @@ $template->assign_vars(array( $page_title = $user->lang['Index']; include($phpbb_root_path . 'includes/page_header.'.$phpEx); +//page_header($user->lang['INDEX']); + $template->set_filenames(array( - 'body' => 'index_body.html' -)); + 'body' => 'index_body.html') +); + +//page_footer(); include($phpbb_root_path . 'includes/page_tail.'.$phpEx); diff --git a/phpBB/install/schemas/mysql_basic.sql b/phpBB/install/schemas/mysql_basic.sql index 18206aa616..b4137c60d7 100644 --- a/phpBB/install/schemas/mysql_basic.sql +++ b/phpBB/install/schemas/mysql_basic.sql @@ -209,7 +209,7 @@ INSERT INTO phpbb_auth_options (auth_option, is_global) VALUES ('u_search', 1); INSERT INTO phpbb_styles (style_id, template_id, theme_id, imageset_id, style_name) VALUES (1, 1, 1, 1, 'subSilver'); # -- phpbb_styles_imageset -INSERT INTO phpbb_styles_imageset (imageset_id, imageset_name, imageset_path, btn_post, btn_post_pm, btn_reply, btn_reply_pm, btn_locked, btn_profile, btn_pm, btn_delete, btn_ip, btn_quote, btn_search, btn_edit, btn_report, btn_email, btn_www, btn_icq, btn_aim, btn_yim, btn_msnm, btn_no_email, btn_no_www, btn_no_icq, btn_no_aim, btn_no_yim, btn_no_msnm, btn_online, btn_offline, btn_topic_watch, btn_topic_unwatch, icon_unapproved, icon_reported, icon_attach, icon_post, icon_post_new, icon_post_latest, icon_post_newest, forum, forum_new, forum_locked, sub_forum, sub_forum_new, folder, folder_posted, folder_new, folder_new_posted, folder_hot, folder_hot_posted, folder_hot_new, folder_hot_new_posted, folder_locked, folder_locked_posted, folder_locked_new, folder_locked_new_posted, folder_sticky, folder_sticky_posted, folder_sticky_new, folder_sticky_new_posted, folder_announce, folder_announce_posted, folder_announce_new, folder_announce_new_posted, poll_left, poll_center, poll_right) VALUES (1, 'subSilver © phpBB Group', 'subSilver', '"imagesets/subSilver/{LANG}/btn_post.gif" width="82" height="25" border="0"', '"imagesets/subSilver/{LANG}/btn_post_pm.gif" width="82" height="25" border="0"', '"imagesets/subSilver/{LANG}/btn_reply.gif" width="88" height="25" border="0"', '"imagesets/subSilver/{LANG}/reply.gif" width="88" height="25" border="0"', '"imagesets/subSilver/{LANG}/btn_locked.gif" width="82" height="25" border="0"', '"imagesets/subSilver/{LANG}/btn_profile.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_pm.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_delete.gif" width="16" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_ip.gif" width="16" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_quote.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_search.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_edit.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_report.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_email.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_www.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_icq.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_aim.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_yim.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_msnm.gif" width="59" height="18" border="0"', '', '', '', '', '', '', '"imagesets/subSilver/{LANG}/btn_online.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_offline.gif" width="59" height="18" border="0"', NULL, NULL, '"imagesets/subSilver/icon_unapproved.gif" width="19" height="18" border="0"', '"imagesets/subSilver/icon_reported.gif" width="19" height="18" border="0"', '"imagesets/subSilver/icon_attach.gif" width="14" height="18" border="0"', '"imagesets/subSilver/icon_minipost.gif" width="12" height="9" border="0"', '"imagesets/subSilver/icon_minipost_new.gif" width="12" height="9" border="0"', '"imagesets/subSilver/icon_latest_reply.gif" width="18" height="9" border="0"', '"imagesets/subSilver/icon_newest_reply.gif" width="18" height="9" border="0"', '"imagesets/subSilver/folder_big.gif" width="46" height="25" border="0"', '"imagesets/subSilver/folder_new_big.gif" width="46" height="25" border="0"', '"imagesets/subSilver/folder_locked_big.gif" width="46" height="25" border="0"', '"imagesets/subSilver/subfolder_big.gif" width="46" height="25" border="0"', '"imagesets/subSilver/subfolder_new_big.gif" width="46" height="25" border="0"', '"imagesets/subSilver/folder.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_new.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_new_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_hot.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_hot_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_new_hot.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_new_hot_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_lock.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_lock_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_lock_new.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_lock_new_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_sticky.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_sticky_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_sticky_new.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_sticky_new_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_announce.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_announce_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_announce_new.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_announce_new_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/vote_lcap.gif" width="4" height="12" border="0"', '"imagesets/subSilver/voting_bar.gif" height="12" border="0"', '"imagesets/subSilver/vote_rcap.gif" width="4" height="12" border="0"'); +INSERT INTO phpbb_styles_imageset (imageset_id, imageset_name, imageset_path, btn_post, btn_post_pm, btn_reply, btn_reply_pm, btn_locked, btn_profile, btn_pm, btn_delete, btn_ip, btn_quote, btn_search, btn_edit, btn_report, btn_email, btn_www, btn_icq, btn_aim, btn_yim, btn_msnm, btn_no_email, btn_no_www, btn_no_icq, btn_no_aim, btn_no_yim, btn_no_msnm, btn_online, btn_offline, btn_topic_watch, btn_topic_unwatch, icon_unapproved, icon_reported, icon_attach, icon_post, icon_post_new, icon_post_latest, icon_post_newest, forum, forum_new, forum_locked, sub_forum, sub_forum_new, folder, folder_posted, folder_new, folder_new_posted, folder_hot, folder_hot_posted, folder_hot_new, folder_hot_new_posted, folder_locked, folder_locked_posted, folder_locked_new, folder_locked_new_posted, folder_sticky, folder_sticky_posted, folder_sticky_new, folder_sticky_new_posted, folder_announce, folder_announce_posted, folder_announce_new, folder_announce_new_posted, poll_left, poll_center, poll_right) VALUES (1, 'subSilver © phpBB Group', 'subSilver', '"imagesets/subSilver/{LANG}/btn_post.gif" width="82" height="25" border="0"', '"imagesets/subSilver/{LANG}/btn_post_pm.gif" width="82" height="25" border="0"', '"imagesets/subSilver/{LANG}/btn_reply.gif" width="82" height="25" border="0"', '"imagesets/subSilver/{LANG}/reply.gif" width="88" height="25" border="0"', '"imagesets/subSilver/{LANG}/btn_locked.gif" width="82" height="25" border="0"', '"imagesets/subSilver/{LANG}/btn_profile.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_pm.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_delete.gif" width="16" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_ip.gif" width="16" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_quote.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_search.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_edit.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_report.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_email.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_www.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_icq.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_aim.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_yim.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_msnm.gif" width="59" height="18" border="0"', '', '', '', '', '', '', '"imagesets/subSilver/{LANG}/btn_online.gif" width="59" height="18" border="0"', '"imagesets/subSilver/{LANG}/btn_offline.gif" width="59" height="18" border="0"', NULL, NULL, '"imagesets/subSilver/icon_unapproved.gif" width="19" height="18" border="0"', '"imagesets/subSilver/icon_reported.gif" width="19" height="18" border="0"', '"imagesets/subSilver/icon_attach.gif" width="14" height="18" border="0"', '"imagesets/subSilver/icon_minipost.gif" width="12" height="9" border="0"', '"imagesets/subSilver/icon_minipost_new.gif" width="12" height="9" border="0"', '"imagesets/subSilver/icon_latest_reply.gif" width="18" height="9" border="0"', '"imagesets/subSilver/icon_newest_reply.gif" width="18" height="9" border="0"', '"imagesets/subSilver/folder_big.gif" width="46" height="25" border="0"', '"imagesets/subSilver/folder_new_big.gif" width="46" height="25" border="0"', '"imagesets/subSilver/folder_locked_big.gif" width="46" height="25" border="0"', '"imagesets/subSilver/subfolder_big.gif" width="46" height="25" border="0"', '"imagesets/subSilver/subfolder_new_big.gif" width="46" height="25" border="0"', '"imagesets/subSilver/folder.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_new.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_new_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_hot.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_hot_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_new_hot.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_new_hot_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_lock.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_lock_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_lock_new.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_lock_new_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_sticky.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_sticky_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_sticky_new.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_sticky_new_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_announce.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_announce_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_announce_new.gif" width="19" height="18" border="0"', '"imagesets/subSilver/folder_announce_new_posted.gif" width="19" height="18" border="0"', '"imagesets/subSilver/vote_lcap.gif" width="4" height="12" border="0"', '"imagesets/subSilver/voting_bar.gif" height="12" border="0"', '"imagesets/subSilver/vote_rcap.gif" width="4" height="12" border="0"'); # -- phpbb_styles_template INSERT INTO phpbb_styles_template (template_id, template_name, template_path, poll_length, pm_box_length) VALUES (1, 'subSilver © phpBB Group', 'subSilver', 205, 175); @@ -219,9 +219,9 @@ INSERT INTO phpbb_styles_theme (theme_id, css_data, css_external) VALUES (1, 'bo # -- Forums -INSERT INTO phpbb_forums (forum_id, forum_name, forum_desc, left_id, right_id, parent_id, forum_postable, forum_posts, forum_topics, forum_topics_real, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_post_time) VALUES (1, 'My first Category', '', 1, 4, 0, 0, 1, 1, 1, 1, 2, 'Admin', 972086460); +INSERT INTO phpbb_forums (forum_id, forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts, forum_topics, forum_topics_real, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_post_time) VALUES (1, 'My first Category', '', 1, 4, 0, 0, 1, 1, 1, 1, 2, 'Admin', 972086460); -INSERT INTO phpbb_forums (forum_id, forum_name, forum_desc, left_id, right_id, parent_id, forum_postable, forum_posts, forum_topics, forum_topics_real, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_post_time) VALUES (2, 'Test Forum 1', 'This is just a test forum.', 2, 3, 1, 1, 1, 1, 1, 1, 2, 'Admin', 972086460); +INSERT INTO phpbb_forums (forum_id, forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts, forum_topics, forum_topics_real, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_post_time) VALUES (2, 'Test Forum 1', 'This is just a test forum.', 2, 3, 1, 1, 1, 1, 1, 1, 2, 'Admin', 972086460); # -- Users diff --git a/phpBB/install/schemas/mysql_schema.sql b/phpBB/install/schemas/mysql_schema.sql index 49eaed8d05..685d76a8fd 100644 --- a/phpBB/install/schemas/mysql_schema.sql +++ b/phpBB/install/schemas/mysql_schema.sql @@ -206,11 +206,13 @@ CREATE TABLE phpbb_forums ( forum_parents text, forum_name varchar(150) NOT NULL, forum_desc text, + forum_link varchar(200) DEFAULT '' NOT NULL, + forum_link_track tinyint(1) DEFAULT '0' NOT NULL, forum_password varchar(32) DEFAULT '' NOT NULL, forum_style tinyint(4) UNSIGNED, - forum_image varchar(50), + forum_image varchar(50) DEFAULT '' NOT NULL, + forum_type tinyint(4) DEFAULT '0' NOT NULL, forum_status tinyint(4) DEFAULT '0' NOT NULL, - forum_postable tinyint(4) DEFAULT '0' NOT NULL, forum_posts mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, forum_topics mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, forum_topics_real mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, diff --git a/phpBB/language/en/lang_admin.php b/phpBB/language/en/lang_admin.php index 19aaf3565d..6bc725237b 100644 --- a/phpBB/language/en/lang_admin.php +++ b/phpBB/language/en/lang_admin.php @@ -83,6 +83,11 @@ $lang = array_merge($lang, array( 'RANKS' => 'Ranks', 'PRUNE_USERS' => 'Prune users', + 'RUN_HOW' => 'When to run', + 'RUN_AS_NOW'=> 'Run now', + 'RUN_AS_EVT'=> 'Run as Event', + 'RUN_AS_CRN'=> 'Run as Cron', + 'ADMINISTRATORS' => 'Administrators', 'LOOK_UP_FORUM' => 'Select a Forum', @@ -112,7 +117,6 @@ $lang = array_merge($lang, array( 'LOG_BAN_USER' => '<b>Banned User</b> for reason %s<br />» %s ', 'LOG_BAN_IP' => '<b>Banned ip</b> for reason %s<br />» %s', 'LOG_BAN_EMAIL' => '<b>Banned email</b> for reason %s<br />» %s', - 'LOG_UNBAN_USER' => '<b>Unbanned user</b><br />» %s', 'LOG_UNBAN_IP' => '<b>Unbanned ip</b><br />» %s', 'LOG_UNBAN_EMAIL' => '<b>Unbanned email</b><br />» %s', @@ -124,13 +128,17 @@ $lang = array_merge($lang, array( 'LOG_EMAIL_CONFIG' => '<b>Altered email settings</b>', 'LOG_AVATAR_CONFIG' => '<b>Altered avatar settings</b>', 'LOG_AUTH_CONFIG' => '<b>Altered authentication settings</b>', + 'LOG_ATTACH_CONFIG' => '<b>Altered attachment settings</b>', + 'log_prune_user_deac' => '<b>Users Deactivated</b><br />%s', 'log_prune_user_del_del'=> '<b>Users Pruned and Posts Deleted</b><br />%s', 'log_prune_user_del_anon'=> '<b>Users Pruned and Posts Retained</b><br />%s', + 'LOG_RESYNC_STATS' => '<b>Post, topic and user stats reset</b>', 'LOG_RESET_DATE' => '<b>Board start date reset</b>', 'LOG_RESET_ONLINE' => '<b>Most users online reset</b>', + 'LOG_ACL_MOD_DEL' => '<b>Removed Moderators</b> from %s<br />» %s', 'LOG_ACL_MOD_ADD' => '<b>Added or edited Moderators</b> from %s<br />» %s', 'LOG_ACL_SUPERMOD_DEL' => '<b>Removed Super Moderators</b><br />» %s', @@ -148,10 +156,19 @@ $lang = array_merge($lang, array( 'LOG_ATTACH_EXTGROUP_ADD' => '<b>Added or edited extension group</b><br />» %s', 'LOG_ATTACH_EXTGROUP_DEL' => '<b>Removed extension group</b><br />» %s', - 'RUN_HOW' => 'When to run', - 'RUN_AS_NOW'=> 'Run now', - 'RUN_AS_EVT'=> 'Run as Event', - 'RUN_AS_CRN'=> 'Run as Cron', + 'LOG_FORUM_ADD' => '<b>Created new forum</b><br />» %s', + 'LOG_FORUM_MOVE_UP' => '<b>Moved forum</b> %s <b>above</b> %s', + 'LOG_FORUM_MOVE_DOWN' => '<b>Moved forum</b> %s <b>below</b> %s', + 'LOG_FORUM_EDIT' => '<b>Edited forum details</b><br />» %s', + 'LOG_FORUM_SYNC' => '<b>Re-synchronised forum</b><br />» %s', + 'LOG_FORUM_DEL_POSTS' => '<b>Deleted forum and its messages</b><br />» %s', + 'LOG_FORUM_DEL_FORUMS' => '<b>Deleted forum and its subforums</b><br />» %s', + 'LOG_FORUM_DEL_POSTS_MOVE_FORUMS' => '<b>Deleted forum and its messages, moved subforums</b> to %s<br />» %s', + 'LOG_FORUM_DEL_MOVE_POSTS_FORUMS' => '<b>Deleted forum and its subforums, moved messages</b> to %s<br />» %s', + 'LOG_FORUM_DEL_MOVE_POSTS' => '<b>Deleted forum and moved posts </b> to %s<br />» %s', + 'LOG_FORUM_DEL_MOVE_FORUMS' => '<b>Deleted forum and moved subforums</b> to %s<br />» %s', + 'LOG_FORUM_DEL_POSTS_FORUMS'=> '<b>Deleted forum, its messages and subforums</b><br />» %s', + 'LOG_FORUM_DEL_MOVE_POSTS_MOVE_FORUMS' => '<b>Deleted forum, moved posts</b> to %s <b>and subforums</b> to %s<br />» %s', 'WELCOME_PHPBB' => 'Welcome to phpBB', @@ -487,20 +504,21 @@ $lang = array_merge($lang, array( 'ENABLE_EMAIL_EXPLAIN' => 'If this is set to disabled no emails will be sent by the board at all.', 'BOARD_EMAIL_FORM' => 'Users send email via board', 'BOARD_EMAIL_FORM_EXPLAIN' => 'This function keeps email addresses completely private.', - 'ADMIN_EMAIL' => 'Admin Email Address', + 'ADMIN_EMAIL' => 'Return Email Address', + 'ADMIN_EMAIL_EXPLAIN' => 'This will be used as the return address on all emails.', 'EMAIL_SIG' => 'Email Signature', - 'EMAIL_SIG_EXPLAIN' => 'This text will be attached to all emails the board sends', - 'CONTACT_EMAIL' => 'Abuse email address', - 'CONTACT_EMAIL_EXPLAIN' => 'This address will be used whenever a specific contact point is needed, e.g. spam, failures, etc.', + 'EMAIL_SIG_EXPLAIN' => 'This text will be attached to all emails the board sends.', + 'CONTACT_EMAIL' => 'Contact email address', + 'CONTACT_EMAIL_EXPLAIN' => 'This address will be used whenever a specific contact point is needed, e.g. spam, error output, etc.', 'USE_SMTP' => 'Use SMTP Server for email', - 'USE_SMTP_EXPLAIN' => 'Say yes if you want or have to send email via a named server instead of the local mail function', + 'USE_SMTP_EXPLAIN' => 'Say yes if you want or have to send email via a named server instead of the local mail function.', 'SMTP_SERVER' => 'SMTP Server Address', 'SMTP_PORT' => 'SMTP Server Port', - 'SMTP_PORT_EXPLAIN' => 'Only change this if you know your SMTP server is on a different port', + 'SMTP_PORT_EXPLAIN' => 'Only change this if you know your SMTP server is on a different port.', 'SMTP_USERNAME' => 'SMTP Username', - 'SMTP_USERNAME_EXPLAIN' => 'Only enter a username if your smtp server requires it', + 'SMTP_USERNAME_EXPLAIN' => 'Only enter a username if your smtp server requires it.', 'SMTP_PASSWORD' => 'SMTP Password', - 'SMTP_PASSWORD_EXPLAIN' => 'Only enter a password if your smtp server requires it', + 'SMTP_PASSWORD_EXPLAIN' => 'Only enter a password if your smtp server requires it.', 'BOARD_SETTINGS_EXPLAIN' => 'Here you can determine the basic operation of your board, from the site name through user registration to private messaging.', @@ -582,100 +600,115 @@ $lang = array_merge($lang, array( 'PHP_INFO_EXPLAIN' => 'This page lists information on the version of PHP installed on this server. It includes details of loaded modules, available variables and default settings. This information may be useful when diagnosing problems. Please be aware that some hosting companies will limit what information is displayed here for security reasons. You are advised to not give out any details on this page except when asked by support or other Team Member on the support forums.', - 'Forum_admin_explain' => 'In phpBB 2.2 there are no categories, everything is forum based. Each forum can have an unlimited number of sub-forums and you can determine whether each may be posted to or not (i.e. whether it acts like an old category). Here you can add, edit, delete, lock, unlock individual forums as well as set certain additional controls. If your posts and topics have got out of sync you can also resynchronise a forum.', - 'Edit_forum' => 'Edit forum', - 'Edit_category' => 'Edit category', - 'Create_forum' => 'Create new forum', - 'Remove' => 'Remove', - 'Config_updated' => 'Forum configuration updated successfully', - 'EDIT' => 'Edit', - 'MOVE_UP' => 'Move up', - 'MOVE_DOWN' => 'Move down', - 'Resync' => 'Sync', - 'Category_name' => 'Category name', - 'FORUM_TYPE' => 'Forum Type', - 'FORUM_STATUS' => 'Forum Status', - 'FORUM_STYLE' => 'Forum Style', - 'FORUM_IMAGE' => 'Forum Image', - 'Parent' => 'Parent', - 'No_parent' => 'No parent', - 'Locked' => 'Locked', - 'Unlocked' => 'Unlocked', - 'General_settings' => 'General settings', - 'Forum_settings' => 'Forum settings', - 'IS_POSTABLE' => 'Can Post', - 'NOT_POSTABLE' => 'Cannot Post', - 'ENABLE_TOPIC_ICONS' => 'Enable topic icons', - 'DISABLE_POST_COUNT' => 'Disable user post count incrementing', - 'FORUM_MODERATED' => 'Enable moderation queue', - 'Display_on_index' => 'Display link to forum on index', - 'Forum_edit_delete_explain' => 'The form below will allow you to customize all the general board options. For User and Forum configurations use the related links on the left hand side', - 'Forum_general' => 'General Forum Settings', - 'Forum_name' => 'Forum name', - 'Forum_desc' => 'Description', - 'Forum_pruning' => 'Auto-pruning', - 'prune_freq' => 'Check for topic age every', - 'prune_days' => 'Remove topics that have not been posted to in', - 'SET_NON_POSTABLE' => 'Set this forum as non-postable and', - 'Forum_delete' => 'Delete Forum', - - 'UPDATE' => 'Update', - - 'Forum_delete_explain' => 'The form below will allow you to delete a forum and decide where you want to put all topics (or forums) it contained.', - 'Move_and_Delete' => 'Move and Delete', - 'Move_posts_to' => 'Move posts to', - 'Move_subforums_to' => 'Move subforums to', - 'Delete_all_posts' => 'Delete all posts', - 'Delete_subforums' => 'Delete subforums and associated posts', - 'No_destination_forum' => 'You have not specified a forum to move content to', - 'FORUM_UPDATED' => 'Forum informations updated successfully', - 'Forum_deleted' => 'Forum successfully deleted', - 'Click_return_forumadmin' => 'Click %sHere%s to return to Forum Administration', - - - 'ICONS_EXPLAIN' => 'From this page you can add, remove and edit the icons users may add to their topics or posts. These icons are generally displayed next to topic titles on the forum listing, or the post subjects in topic listings. You can also install and create new packages of icons.', + + 'FORUM_ADMIN_EXPLAIN' => 'In phpBB 2.2 there are no categories, everything is forum based. Each forum can have an unlimited number of sub-forums and you can determine whether each may be posted to or not (i.e. whether it acts like an old category). Here you can add, edit, delete, lock, unlock individual forums as well as set certain additional controls. If your posts and topics have got out of sync you can also resynchronise a forum.', + 'FORUM_EDIT_EXPLAIN' => 'The form below will allow you to customise this forum. Please note that moderation and post count controls are set via forum permissions for each user or usergroup.', + 'FORUM_DELETE' => 'Delete Forum', + 'FORUM_DELETE_EXPLAIN' => 'The form below will allow you to delete a forum and decide where you want to put all topics (or forums) it contained.', + + 'EDIT_FORUM' => 'Edit forum', + 'CREATE_FORUM' => 'Create new forum', + 'REMOVE' => 'Remove', + 'EDIT' => 'Edit', + 'MOVE_UP' => 'Move up', + 'MOVE_DOWN' => 'Move down', + 'RESYNC' => 'Sync', + 'UPDATE' => 'Update', + + 'FORUM_SETTINGS' => 'Forum Settings', + 'FORUM_GENERAL' => 'General Forum Settings', + 'FORUM_TYPE' => 'Forum Type', + 'TYPE_FORUM' => 'Forum', + 'TYPE_CAT' => 'Category', + 'TYPE_LINK' => 'Link', + 'FORUM_NAME' => 'Forum Name', + 'FORUM_DESC' => 'Description', + 'FORUM_DESC_EXPLAIN'=> 'Any markup entered here will displayed as is.', + 'FORUM_LINK' => 'Forum Link', + 'FORUM_LINK_EXPLAIN'=> 'Full URL to location clicking this forum will take the user.', + 'FORUM_LINK_TRACK' => 'Track Link Redirects', + 'FORUM_LINK_TRACK_EXPLAIN' => 'Records the number of times a forum link was clicked.', + 'FORUM_STATUS' => 'Forum Status', + 'FORUM_STYLE' => 'Forum Style', + 'FORUM_IMAGE' => 'Forum Image', + 'FORUM_IMAGE_EXPLAIN'=> 'Location, relative to the phpBB root directory, of an image to associate with this forum.', + 'FORUM_PARENT' => 'Parent Forum', + 'NO_PARENT' => 'No Parent', + 'LOCKED' => 'Locked', + 'UNLOCKED' => 'Unlocked', + 'ENABLE_TOPIC_ICONS'=> 'Enable Topic Icons', + 'LIST_INDEX' => 'List Forum On Index', + 'LIST_INDEX_EXPLAIN'=> 'Displays a link to this forum under the root parent forum on the index.', + 'FORUM_AUTO_PRUNE' => 'Enable Auto-Pruning', + 'FORUM_AUTO_PRUNE_EXPLAIN' => 'Prunes the forum of topics, set the frequency/age parameters below.', + 'AUTO_PRUNE_FREQ' => 'Auto-prune Frequency', + 'AUTO_PRUNE_FREQ_EXPLAIN' => 'Time in days between pruning events.', + 'AUTO_PRUNE_DAYS' => 'Auto-prune Post Age', + 'AUTO_PRUNE_DAYS_EXPLAIN' => 'Number of days since last post after which topic is removed.', + 'FORUM_TOPICS_PAGE' => 'Topics Per Page', + 'FORUM_TOPICS_PAGE_EXPLAIN' => 'If non-zero this value will override the default topics per page setting.', + 'FORUM_PASSWORD' => 'Forum Password', + 'FORUM_PASSWORD_EXPLAIN' => 'Defines a password for this forum, use the permission system in preference.', + 'FORUM_PASSWORD_CONFIRM' => 'Confirm Forum Password', + 'FORUM_PASSWORD_CONFIRM_EXPLAIN' => 'Only needs to be set if a forum password is entered.', + + 'MOVE_POSTS_TO' => 'Move posts', + 'MOVE_SUBFORUMS_TO' => 'Move subforums', + 'DELETE_ALL_POSTS' => 'Delete posts', + 'DELETE_SUBFORUMS' => 'Delete subforums and posts', + + 'NO_DESTINATION_FORUM' => 'You have not specified a forum to move content to', + 'FORUM_PASSWORD_MISMATCH' => 'The passwords you entered did not match.', + 'FORUM_NAME_EMPTY' => 'You must enter a name for this forum.', + 'FORUM_DATA_NEGATIVE' => 'Pruning parameters cannot be negative.', + 'FORUM_UPDATED' => 'Forum informations updated successfully.', + 'REDIRECT_ACL' => 'To set permissions for this forum click %sHERE%s.', + 'FORUM_DELETED' => 'Forum successfully deleted', + + + 'ICONS_EXPLAIN' => 'From this page you can add, remove and edit the icons users may add to their topics or posts. These icons are generally displayed next to topic titles on the forum listing, or the post subjects in topic listings. You can also install and create new packages of icons.', 'SMILE_EXPLAIN' => 'Smilies or emoticons are typically small, sometimes animated images used to convey an emotion or feeling. From this page you can add, remove and edit the emoticons users can use in their posts and private messages. You can also install and create new packages of smilies.', - 'IMPORT_SMILE' => 'Install smilies pak', - 'EXPORT_SMILE' => 'Create smilies pak', - 'IMPORT_ICONS' => 'Install icons pak', - 'EXPORT_ICONS' => 'Create icons pak', - 'ADD_SMILE' => 'Add smilie', - 'ADD_ICONS' => 'Add icon', + 'IMPORT_SMILE' => 'Install smilies pak', + 'EXPORT_SMILE' => 'Create smilies pak', + 'IMPORT_ICONS' => 'Install icons pak', + 'EXPORT_ICONS' => 'Create icons pak', + 'ADD_SMILE' => 'Add smilie', + 'ADD_ICONS' => 'Add icon', 'SMILE_NOT_DISPLAYED' => 'The following smilies are not displayed on the posting page', 'ICONS_NOT_DISPLAYED' => 'The following icons are not displayed on the posting page', - 'EMOTION' => 'Emotion', - 'REORDER' => 'Reorder', + 'EMOTION' => 'Emotion', + 'REORDER' => 'Reorder', 'DISPLAY_ON_POSTING' => 'Display on posting', - 'FIRST' => 'First', - 'AFTER_SMILE' => 'After %s', - 'AFTER_ICONS' => 'After %s', - 'SMILE_CONFIG' => 'Smilie configuration', - 'SMILE_CODE' => 'Smilie code', - 'SMILE_URL' => 'Smilie image file', - 'SMILE_HEIGHT' => 'Smilie height', - 'SMILE_WIDTH' => 'Smilie width', - 'SMILE_ORDER' => 'Smilie order', + 'FIRST' => 'First', + 'AFTER_SMILE' => 'After %s', + 'AFTER_ICONS' => 'After %s', + 'SMILE_CONFIG' => 'Smilie configuration', + 'SMILE_CODE' => 'Smilie code', + 'SMILE_URL' => 'Smilie image file', + 'SMILE_HEIGHT' => 'Smilie height', + 'SMILE_WIDTH' => 'Smilie width', + 'SMILE_ORDER' => 'Smilie order', 'SMILE_EMOTION' => 'Emotion', - 'SMILE_ADD' => 'Add a new Smilie', - 'SMILE_EDIT' => 'Edit Smilie', - 'ICONS_CONFIG' => 'Icon configuration', - 'ICONS_URL' => 'Icon image file', - 'ICONS_HEIGHT' => 'Icon height', - 'ICONS_WIDTH' => 'Icon width', - 'ICONS_ORDER' => 'Icon order', - 'ICONS_ADD' => 'Add a new Icon', - 'ICONS_EDIT' => 'Edit Icon', + 'SMILE_ADD' => 'Add a new Smilie', + 'SMILE_EDIT' => 'Edit Smilie', + 'ICONS_CONFIG' => 'Icon configuration', + 'ICONS_URL' => 'Icon image file', + 'ICONS_HEIGHT' => 'Icon height', + 'ICONS_WIDTH' => 'Icon width', + 'ICONS_ORDER' => 'Icon order', + 'ICONS_ADD' => 'Add a new Icon', + 'ICONS_EDIT' => 'Edit Icon', 'EXPORT_SMILE_EXPLAIN' => 'To create a package of your currently installed smilies, click %sHERE%s to download the emoticons.pak file. Once downloaded create a zip or tgz file containing all of your smilies plus this .pak configuration file.', 'EXPORT_ICONS_EXPLAIN' => 'To create a package of your currently installed icons, click %sHERE%s to download the icons package file. Once downloaded create a zip or tgz file containing all of your icons plus this .pak configuration file.', - 'NO_SMILE_EXPORT' => 'You have no smilies with which to create a package.', - 'NO_ICONS_EXPORT' => 'You have no icons with which to create a package.', - 'WRONG_PAK_TYPE' => 'The specified package does not contain the appropriate data.', - 'SELECT_PACKAGE' => 'Select a package file', - 'DELETE_ALL' => 'Delete all', - 'KEEP_ALL' => 'Keep all', - 'REPLACE_MATCHES' => 'Replace matches', - 'NO_SMILE_PAK' => 'No smilie packages found.', - 'CURRENT_SMILE' => 'Current smilies', + 'NO_SMILE_EXPORT' => 'You have no smilies with which to create a package.', + 'NO_ICONS_EXPORT' => 'You have no icons with which to create a package.', + 'WRONG_PAK_TYPE' => 'The specified package does not contain the appropriate data.', + 'SELECT_PACKAGE' => 'Select a package file', + 'DELETE_ALL' => 'Delete all', + 'KEEP_ALL' => 'Keep all', + 'REPLACE_MATCHES' => 'Replace matches', + 'NO_SMILE_PAK' => 'No smilie packages found.', + 'CURRENT_SMILE' => 'Current smilies', 'SMILE_IMPORT_SUCCESS' => 'The smilies pack was imported successfully', 'NO_ICONS_PAK' => 'No icon packages found.', 'CURRENT_ICONS' => 'Current icons', diff --git a/phpBB/language/en/lang_main.php b/phpBB/language/en/lang_main.php index d835fb1b45..cb21b782a9 100644 --- a/phpBB/language/en/lang_main.php +++ b/phpBB/language/en/lang_main.php @@ -115,10 +115,9 @@ $lang = array( 'RETURN_MCP' => 'Click %sHere%s to return to the Moderator Control Panel', 'RETURN_GROUP' => 'Click %sHere%s to return to the Group Control Panel', 'VIEW_MESSAGE' => 'Click %sHere%s to view your message', + 'URL_REDIRECT' => 'If your browser does not support meta redirection please click %sHERE%s to be redirected.', - - 'INFORMATION' => 'Information', - + 'INFORMATION' => 'Information', 'BOARD_DISABLE' => 'Sorry but this board is currently unavailable', 'BOARD_UNAVAILABLE' => 'Sorry but the board is temporarily unavailable, please try again in a few minutes', @@ -197,14 +196,14 @@ $lang = array( 'Registered_user_total' => 'We have <b>%d</b> registered user', 'Newest_user' => 'The newest registered user is <b>%s%s%s</b>', - 'NO_NEW_POSTS' => 'No new posts', - 'NEW_POSTS' => 'New posts', - 'NEW_POST' => 'New post', - 'NO_NEW_POSTS_HOT' => 'No new posts [ Popular ]', - 'NEW_POSTS_HOT' => 'New posts [ Popular ]', + 'NO_NEW_POSTS' => 'No new posts', + 'NEW_POSTS' => 'New posts', + 'NEW_POST' => 'New post', + 'NO_NEW_POSTS_HOT' => 'No new posts [ Popular ]', + 'NEW_POSTS_HOT' => 'New posts [ Popular ]', 'NO_NEW_POSTS_LOCKED' => 'No new posts [ Locked ]', - 'NEW_POSTS_LOCKED' => 'New posts [ Locked ]', - 'FORUM_LOCKED' => 'Forum Locked', + 'NEW_POSTS_LOCKED' => 'New posts [ Locked ]', + 'FORUM_LOCKED' => 'Forum Locked', 'POST_STICKY' => 'Sticky', 'POST_ANNOUNCEMENT' => 'Announcement', @@ -214,9 +213,10 @@ $lang = array( 'LIST_USER' => '1 User', - 'LIST_USERS' => '%d Users', + 'LIST_USERS'=> '%d Users', + 'REDIRECTS' => 'Total redirects', 'LOGIN' => 'Login', 'TERMS_USE' => 'Terms of Use', 'PRIVACY' => 'Privacy Policy', @@ -273,7 +273,7 @@ $lang = array( 'NO_FORUM' => 'The forum you selected does not exist', 'NO_TOPICS' => 'There are no topics or posts in this forum.', 'NO_TOPIC' => 'The requested topic does not exist.', - 'NO_POSTS' => 'No Posts were found.', + 'NO_POSTS' => 'No Posts', 'NO_POST' => 'The requested post does not exist.', 'NO_USER' => 'The requested user does not exist.', 'NO_GROUP' => 'The requested usergroup does not exist.', @@ -295,7 +295,7 @@ $lang = array( 'EMAIL_TOPIC' => 'Email to friend', 'VIEW_NEXT_TOPIC' => 'View next topic', 'VIEW_PREVIOUS_TOPIC' => 'View previous topic', - 'VIEW_UNREAD_POST' => 'View first unread topic', + 'VIEW_UNREAD_POST' => 'View first unread post', 'NO_NEWER_TOPICS' => 'There are no newer topics in this forum', 'NO_OLDER_TOPICS' => 'There are no older topics in this forum', diff --git a/phpBB/mcp.php b/phpBB/mcp.php index 066e04868a..6c6d267657 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -49,15 +49,14 @@ include($phpbb_root_path . 'extension.inc'); include($phpbb_root_path . 'common.'.$phpEx); include($phpbb_root_path . 'includes/functions_admin.'.$phpEx); + // Start session management $user->start(); $user->setup(); $auth->acl($user->data); -// End session management -// + // Obtain initial var settings -// $forum_id = (isset($_REQUEST['f'])) ? max(0, intval($_REQUEST['f'])) : 0; $topic_id = (!empty($_REQUEST['t'])) ? intval($_REQUEST['t']) : 0; $post_id = (!empty($_REQUEST['p'])) ? intval($_REQUEST['p']) : 0; @@ -75,10 +74,9 @@ $mode = (!empty($_REQUEST['mode'])) ? $_REQUEST['mode'] : ''; $action = (!empty($_GET['action'])) ? $_GET['action'] : ''; $quickmod = (!empty($_REQUEST['quickmod'])) ? TRUE : FALSE; -// + // Check if user did or did not confirm // If they did not, forward them to the last page they were on -// if (isset($_POST['cancel'])) { $redirect = ''; @@ -161,17 +159,17 @@ switch ($mode) case 'make_global': case 'make_announce': $acl_src = 'f_announce'; - break; + break; case 'make_sticky': $acl_src = 'f_sticky'; - break; + break; case 'approve': case 'unapprove': case 'disapprove': $acl_src = 'm_approve'; - break; + break; case 'split': case 'split_all': @@ -180,7 +178,7 @@ switch ($mode) $acl_trg = 'f_post'; $return_mode = '<br /><br />' . sprintf($user->lang['RETURN_MCP'], '<a href="mcp.' . $phpEx . $SID . '&mode=split&t=' . $topic_id . $url_extra . '&subject=' . htmlspecialchars($subject) . '">', '</a>'); - break; + break; case 'merge': case 'merge_posts': @@ -188,16 +186,16 @@ switch ($mode) $acl_trg = 'm_merge'; $return_mode = '<br /><br />' . sprintf($user->lang['RETURN_MCP'], '<a href="mcp.' . $phpEx . $SID . '&mode=merge&t=' . $topic_id . $url_extra . '">', '</a>'); - break; + break; case 'move': $acl_src = 'm_move'; $acl_trg = 'f_post'; - break; + break; case 'viewlogs': - $acl_src = array('m_', 'a_general'); - break; + $acl_src = array('m_', 'a_'); + break; case 'fork': $acl_trg = 'f_post'; @@ -206,12 +204,17 @@ switch ($mode) // Check destination forum or topic if applicable if ($to_topic_id > 0) { - $result = $db->sql_query('SELECT * FROM ' . TOPICS_TABLE . ' WHERE topic_id = ' . $to_topic_id); + $sql = 'SELECT * + FROM ' . TOPICS_TABLE . ' + WHERE topic_id = ' . $to_topic_id; + $result = $db->sql_query($sql); if (!$row = $db->sql_fetchrow($result)) { trigger_error($user->lang['Topic_not_exist'] . $return_mode); } + $db->sql_freeresult($result); + if (!isset($topic_data[$to_topic_id])) { $topic_data[$to_topic_id] = $row; @@ -224,12 +227,16 @@ if ($to_forum_id > 0) { if (!isset($forum_data[$to_forum_id])) { - $result = $db->sql_query('SELECT * FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $to_forum_id); + $sql = 'SELECT * + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $to_forum_id; + $result = $db->sql_query($sql); if (!$row = $db->sql_fetchrow($result)) { trigger_error($user->lang['FORUM_NOT_EXIST'] . $return_mode); } + $db->sql_freeresult($result); $forum_data[$to_forum_id] = $row; } @@ -333,10 +340,12 @@ if (count($forum_id_list)) // Using isset() rather than !empty() because of the jumpbox having f="0" for "All forums" list($void, $forum_id) = each($forum_id_list); } + if (!$topic_id && count($topic_id_list) == 1) { list($void, $topic_id) = each($topic_id_list); } + if (!$post_id && count($post_id_list) == 1) { list($void, $post_id) = each($post_id_list); @@ -409,7 +418,7 @@ $tabs[] = array( 'url' => $mcp_url . '&mode=viewlogs' ); -if ($forum_id && $forum_data[$forum_id]['forum_postable'] && $auth->acl_get('m_', $forum_id)) +if ($forum_id && $forum_data[$forum_id]['forum_type'] == FORUM_POST && $auth->acl_get('m_', $forum_id)) { $tabs[] = array( 'mode' => 'forum_view', @@ -455,7 +464,7 @@ if (!$mode) { $mode = 'topic_view'; } - elseif ($forum_id && $forum_data[$forum_id]['forum_postable']) + elseif ($forum_id && $forum_data[$forum_id]['forum_type'] == FORUM_POST) { $mode = 'forum_view'; } @@ -493,8 +502,8 @@ foreach ($tabs as $tab) $template->assign_block_vars('tab', array( 'S_IS_SELECTED' => ($tab['mode'] == $mode) ? TRUE : FALSE, 'NAME' => $tab['title'], - 'U_LINK' => $tab['url'] - )); + 'U_LINK' => $tab['url']) + ); } // @@ -611,7 +620,7 @@ switch ($mode) } else { - if (!$forum_data[$to_forum_id]['forum_postable']) + if ($forum_data[$to_forum_id]['forum_type'] == FORUM_CAT) { trigger_error($user->lang['FORUM_NOT_POSTABLE'] . $return_mcp); } @@ -760,7 +769,7 @@ switch ($mode) } else { - if (!$forum_data[$to_forum_id]['forum_postable']) + if ($forum_data[$to_forum_id]['forum_type'] == FORUM_CAT) { trigger_error($user->lang['FORUM_NOT_POSTABLE'] . $return_mcp); } @@ -861,22 +870,18 @@ switch ($mode) } } - $return_forum = sprintf($user->lang['RETURN_FORUM'], "<a href=\"viewforum.$phpEx$SID&f=$forum_id\">", '</a>'); - $return_topic = sprintf($user->lang['RETURN_TOPIC'], "<a href=\"viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&start=$start\">", '</a>'); - - $template->assign_vars(array( - 'META' => "<meta http-equiv=\"refresh\" content=\"3;url=viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&start=$start\">" - )); - add_log('mod', $forum_id, $topic_id, 'logm_' . $mode); - trigger_error($user->lang['TOPIC_TYPE_CHANGED'] . '<br /><br />' . $return_topic . '<br /><br />' . $return_forum); - break; + meta_refresh(3, "viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&start=$start"); + + $message = $user->lang['TOPIC_TYPE_CHANGED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], "<a href=\"viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&start=$start\">", '</a>') . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], "<a href=\"viewforum.$phpEx$SID&f=$forum_id\">", '</a>'); + trigger_error($message); + break; case 'disapprove': - // NOTE: what happens if the user disapproves the first post of the topic? Answer: the topic is deleted + // NOTE: what happens if the user disapproves the first post of the topic? Answer: the topic is deleted $redirect_page = "mcp.$phpEx$SID&f=$forum_id"; - $l_redirect = sprintf($user->lang['RETURN_MCP'], '<a href="mcp.' . $phpEx . $SID . '&f=' . $forum_id . '">', '</a>'); + $l_redirect = sprintf($user->lang['RETURN_MCP'], "<a href=\"mcp.$phpEx$SID&f=$forum_id\">", '</a>'); if (!count($post_id_list)) { @@ -897,6 +902,7 @@ switch ($mode) $post_ids[] = $p_id; } } + foreach ($post_id_list as $p_id) { if (!in_array($topic_ids, $post_data[$p_id]['topic_id'])) @@ -904,21 +910,21 @@ switch ($mode) $post_ids[] = $p_id; } } + if (count($topic_ids)) { delete_topics('topic_id', $topic_ids); } + if (count($post_ids)) { delete_posts('post_id', $post_ids); } - $template->assign_vars(array( - 'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">') - ); - // TODO: warn the user when post is disapproved + meta_refresh(3, $redirect_page); + $msg = (count($post_id_list) == 1) ? $user->lang['POST_REMOVED'] : $user->lang['POSTS_REMOVED']; trigger_error($msg . '<br /><br />' . $l_redirect); } @@ -934,13 +940,13 @@ switch ($mode) mcp_header('confirm_body.html'); $template->assign_vars(array( - 'MESSAGE_TITLE' => $user->lang['CONFIRM'], - 'MESSAGE_TEXT' => (count($post_id_list) == 1) ? $user->lang['CONFIRM_DELETE_POST'] : $user->lang['CONFIRM_DELETE_POSTS'], + 'MESSAGE_TITLE' => $user->lang['CONFIRM'], + 'MESSAGE_TEXT' => (count($post_id_list) == 1) ? $user->lang['CONFIRM_DELETE_POST'] : $user->lang['CONFIRM_DELETE_POSTS'], - 'S_CONFIRM_ACTION' => "mcp.$phpEx$SID&mode=disapprove", - 'S_HIDDEN_FIELDS' => $hidden_fields - )); - break; + 'S_CONFIRM_ACTION' => "mcp.$phpEx$SID&mode=disapprove", + 'S_HIDDEN_FIELDS' => $hidden_fields) + ); + break; case 'approve': case 'unapprove': @@ -979,7 +985,7 @@ switch ($mode) add_log('mod', $forum_id, $post_data[$post_id]['topic_id'], $logm_mode, $post_id); -//NOTE: hey, who removed the enable_post_count field?! lol ^ ^ + //NOTE: hey, who removed the enable_post_count field?! lol ^ ^ $forum_data[$post_data[$post_id]['forum_id']]['enable_post_count'] = 1; if ($forum_data[$post_data[$post_id]['forum_id']]['enable_post_count']) { @@ -1042,6 +1048,7 @@ switch ($mode) $resync_count[$post_count] = array($user_id); } } + foreach ($resync_count as $post_count => $user_list) { $sql = 'UPDATE ' . USERS_TABLE . " @@ -1580,7 +1587,7 @@ switch ($mode) { trigger_error($user->lang['SELECT_DESTINATION_FORUM'] . $return_split); } - if (!$forum_data[$to_forum_id]['forum_postable']) + if ($forum_data[$to_forum_id]['forum_type'] == FORUM_CAT) { trigger_error($user->lang['FORUM_NOT_POSTABLE'] . $return_split); } @@ -2013,7 +2020,7 @@ function mcp_jumpbox($action, $acl_list = 'f_list', $forum_id = false, $enable_s { global $auth, $template, $user, $db, $nav_links, $phpEx, $SID; - $sql = 'SELECT forum_id, forum_name, forum_postable, left_id, right_id + $sql = 'SELECT forum_id, forum_name, forum_type, left_id, right_id FROM ' . FORUMS_TABLE . ' ORDER BY left_id ASC'; $result = $db->sql_query($sql, 120); @@ -2022,18 +2029,18 @@ function mcp_jumpbox($action, $acl_list = 'f_list', $forum_id = false, $enable_s $padding = $forum_list = $holding = ''; while ($row = $db->sql_fetchrow($result)) { - if (!$row['forum_postable'] && ($row['left_id'] + 1 == $row['right_id'])) + if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) { // Non-postable forum with no subforums, don't display continue; } - if (!$auth->acl_gets('f_list', $row['forum_id'])) + if (!$auth->acl_get('f_list', $row['forum_id'])) { // if the user does not have permissions to list this forum skip continue; } - if (!$row['forum_postable'] || !$auth->acl_gets($acl_list, $row['forum_id'])) + if ($row['forum_type'] == FORUM_CAT || !$auth->acl_gets($acl_list, $row['forum_id'])) { $row['forum_id'] = -1; } diff --git a/phpBB/posting.php b/phpBB/posting.php index 628386291a..11cf0fc29e 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -77,7 +77,7 @@ $topic_validate = false; $post_validate = false; // Easier validation -$forum_fields = array('forum_name' => 's', 'parent_id' => 'i', 'forum_parents' => 's', 'forum_status' => 'i', 'forum_postable' => 'i', 'enable_icons' => 'i'); +$forum_fields = array('forum_name' => 's', 'parent_id' => 'i', 'forum_parents' => 's', 'forum_status' => 'i', 'forum_type' => 'i', 'enable_icons' => 'i'); $topic_fields = array('topic_status' => 'i', 'topic_first_post_id' => 'i', 'topic_last_post_id' => 'i', 'topic_type' => 'i', 'topic_title' => 's', 'poll_last_vote' => 'i', 'poll_start' => 'i', 'poll_title' => 's', 'poll_max_options' => 'i', 'poll_length' => 'i'); @@ -237,8 +237,8 @@ if ($sql != '') // Get Attachment Data $message_parser->attachment_data = (isset($_POST['attachment_data'])) ? $_POST['attachment_data'] : array(); - - if (($post_attachment) && (!$submit) && (!$refresh) && (!$preview) && ($mode == 'edit')) + + if ($post_attachment && !$submit && !$refresh && !$preview && $mode == 'edit') { $sql = 'SELECT d.* FROM ' . ATTACHMENTS_TABLE . ' a, ' . ATTACHMENTS_DESC_TABLE . ' d @@ -252,7 +252,7 @@ if ($sql != '') $db->sql_freeresult($result); } - if (($poster_id == ANONYMOUS) || (!$poster_id)) + if ($poster_id == ANONYMOUS || !$poster_id) { $username = ($post_validate) ? trim($post_username) : ''; } @@ -289,47 +289,47 @@ if ($mode != 'post' && $user->data['user_id'] != ANONYMOUS) // Collect general Permissions to be used within the complete page $perm = array( - 'm_lock' => $auth->acl_get('m_lock', $forum_id), - 'm_edit' => $auth->acl_get('m_edit', $forum_id), - 'm_delete' => $auth->acl_get('m_delete', $forum_id), + 'm_lock' => $auth->acl_get('m_lock', $forum_id), + 'm_edit' => $auth->acl_get('m_edit', $forum_id), + 'm_delete' => $auth->acl_get('m_delete', $forum_id), - 'u_delete' => $auth->acl_get('f_delete', $forum_id), + 'u_delete' => $auth->acl_get('f_delete', $forum_id), - 'f_attach' => $auth->acl_get('f_attach', $forum_id), - 'f_news' => $auth->acl_get('f_news', $forum_id), - 'f_announce' => $auth->acl_get('f_announce', $forum_id), - 'f_sticky' => $auth->acl_get('f_sticky', $forum_id), + 'f_attach' => $auth->acl_get('f_attach', $forum_id), + 'f_news' => $auth->acl_get('f_news', $forum_id), + 'f_announce' => $auth->acl_get('f_announce', $forum_id), + 'f_sticky' => $auth->acl_get('f_sticky', $forum_id), 'f_ignoreflood' => $auth->acl_get('f_ignoreflood', $forum_id), - 'f_sigs' => $auth->acl_get('f_sigs', $forum_id), - 'f_save' => $auth->acl_get('f_save', $forum_id) + 'f_sigs' => $auth->acl_get('f_sigs', $forum_id), + 'f_save' => $auth->acl_get('f_save', $forum_id) ); -if ( (!$auth->acl_get('f_' . $mode, $forum_id)) && ($forum_postable) ) +if (!$auth->acl_get('f_' . $mode, $forum_id) && $forum_type == FORUM_POST) { trigger_error($user->lang['USER_CANNOT_' . strtoupper($mode)]); } // Forum/Topic locked? -if ( ($forum_status == ITEM_LOCKED || $topic_status == ITEM_LOCKED) && !$perm['m_edit']) +if (($forum_status == ITEM_LOCKED || $topic_status == ITEM_LOCKED) && !$perm['m_edit']) { $message = ($forum_status == ITEM_LOCKED) ? 'FORUM_LOCKED' : 'TOPIC_LOCKED'; trigger_error($user->lang[$message]); } // Can we edit this post? -if ( ($mode == 'edit' || $mode == 'delete') && !empty($config['edit_time']) && $post_time < time() - intval($config['edit_time']) && !$perm['m_edit']) +if (($mode == 'edit' || $mode == 'delete') && !$perm['m_edit'] && $config['edit_time'] && $post_time > time() - $config['edit_time']) { trigger_error($user->lang['CANNOT_EDIT_TIME']); } // Do we want to edit our post ? -if ( ($mode == 'edit') && (!$perm['m_edit']) && ($user->data['user_id'] != $poster_id)) +if ($mode == 'edit' && !$perm['m_edit'] && $user->data['user_id'] != $poster_id) { trigger_error($user->lang['USER_CANNOT_EDIT']); } // Is edit posting locked ? -if ( ($mode == 'edit') && ($post_edit_locked) && (!$auth->acl_gets('m_', 'a_', $forum_id)) ) +if ($mode == 'edit' && $post_edit_locked && !$auth->acl_get('m_', $forum_id)) { trigger_error($user->lang['CANNOT_EDIT_POST_LOCKED']); } @@ -340,7 +340,7 @@ if ($mode == 'edit') } // Delete triggered ? -if ( ($mode == 'delete') && ((($poster_id == $user->data['user_id']) && ($user->data['user_id'] != ANONYMOUS) && ($perm['u_delete']) && ($post_id == $topic_last_post_id)) || ($perm['m_delete'])) ) +if ($mode == 'delete' && (($poster_id == $user->data['user_id'] && $user->data['user_id'] != ANONYMOUS && $perm['u_delete'] && $post_id == $topic_last_post_id) || $perm['m_delete'])) { // Do we need to confirm ? if ($confirm) @@ -374,8 +374,9 @@ if ( ($mode == 'delete') && ((($poster_id == $user->data['user_id']) && ($user-> $forum_update_sql .= 'forum_topics = forum_topics - 1, forum_topics_real = forum_topics_real - 1'; } - // TODO: delete common words... maybe just call search_tidy ? -// $search->del_words($post_id); + // TODO: delete common words... maybe just call search_tidy ? <- No, search tidy is intensive and should be + // called irregularly (at present). +// $search->del_words($post_id); // Sync last post informations $db->sql_transaction(); @@ -399,11 +400,11 @@ if ( ($mode == 'delete') && ((($poster_id == $user->data['user_id']) && ($user-> $db->sql_freeresult($result); // If Post is first post, but not the only post... make next post the topic starter one. ;) - if (($post_data['topic_first_post_id'] != $post_data['topic_last_post_id']) && ($post_id == $post_data['topic_first_post_id'])) + if ($post_data['topic_first_post_id'] != $post_data['topic_last_post_id'] && $post_id == $post_data['topic_first_post_id']) { $topic_sql = array( - 'topic_first_post_id' => intval($row['post_id']), - 'topic_first_poster_name' => ( intval($row['poster_id']) == ANONYMOUS) ? trim($row['post_username']) : trim($row['username']) + 'topic_first_post_id' => intval($row['post_id']), + 'topic_first_poster_name' => ($row['poster_id'] == ANONYMOUS) ? trim($row['post_username']) : trim($row['username']) ); } @@ -446,18 +447,17 @@ if ( ($mode == 'delete') && ((($poster_id == $user->data['user_id']) && ($user-> if ($post_data['topic_first_post_id'] == $post_data['topic_last_post_id']) { $meta_info = '<meta http-equiv="refresh" content="5; url=viewforum.' . $phpEx . $SID . '&f=' . $forum_id . '">'; + $message = $user->lang['DELETED']; } else { $meta_info = '<meta http-equiv="refresh" content="5; url=viewtopic.' . $phpEx . $SID . '&f=' . $forum_id . '&t=' . $topic_id . '&p=' . $post_data['next_post_id'] . '#' . $post_data['next_post_id'] . '">'; + $message = $user->lang['DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="viewtopic.' . $phpEx . $SID . '&f=' . $forum_id . '&t=' . $topic_id . '&p=' . $post_data['next_post_id'] . '#' . $post_data['next_post_id'] . '">', '</a>'); } - $template->assign_vars(array( - 'META' => $meta_info) - ); - + meta_refresh(4, $meta_info); $message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="viewforum.' . $phpEx . $SID . '&f=' . $forum_id . '">', '</a>'); trigger_error($message); @@ -474,23 +474,23 @@ if ( ($mode == 'delete') && ((($poster_id == $user->data['user_id']) && ($user-> ); $template->assign_vars(array( - 'MESSAGE_TITLE' => $user->lang['DELETE_MESSAGE'], - 'MESSAGE_TEXT' => $user->lang['CONFIRM_DELETE'], + 'MESSAGE_TITLE' => $user->lang['DELETE_MESSAGE'], + 'MESSAGE_TEXT' => $user->lang['CONFIRM_DELETE'], - 'S_CONFIRM_ACTION' => $phpbb_root_path . 'posting.' . $phpEx . $SID, - 'S_HIDDEN_FIELDS' => $s_hidden_fields) + 'S_CONFIRM_ACTION' => $phpbb_root_path . 'posting.' . $phpEx . $SID, + 'S_HIDDEN_FIELDS' => $s_hidden_fields) ); include($phpbb_root_path . 'includes/page_tail.'.$phpEx); } } -if ( ($mode == 'delete') && ( ($poster_id != $user->data['user_id']) && (!$perm['u_delete'])) ) +if ($mode == 'delete' && $poster_id != $user->data['user_id'] && !$perm['u_delete']) { trigger_error($user->lang['DELETE_OWN_POSTS']); } -if ( ($mode == 'delete') && ( ($poster_id == $user->data['user_id']) && ($perm['u_delete'])) && ($post_id != $topic_last_post_id)) +if ($mode == 'delete' && $poster_id == $user->data['user_id'] && $perm['u_delete'] && $post_id != $topic_last_post_id) { trigger_error($user->lang['CANNOT_DELETE_REPLIED']); } @@ -500,7 +500,7 @@ if ($mode == 'delete') trigger_error('USER_CANNOT_DELETE'); } -if (($submit) || ($preview) || ($refresh)) +if ($submit || $preview || $refresh) { $topic_cur_post_id = (isset($_POST['topic_cur_post_id'])) ? intval($_POST['topic_cur_post_id']) : false; $subject = (!empty($_POST['subject'])) ? trim(htmlspecialchars(strip_tags($_POST['subject']))) : ''; @@ -534,7 +534,7 @@ if (($submit) || ($preview) || ($refresh)) $poll_delete = (isset($_POST['poll_delete'])) ? true : false; - if ( ($poll_delete) && ($mode == 'edit' && !empty($poll_options) && ((empty($poll_last_vote) && $poster_id == $user->data['user_id'] && $perm['u_delete']) || $perm['m_delete'])) ) + if ($poll_delete && (($mode == 'edit' && !empty($poll_options) && empty($poll_last_vote) && $poster_id == $user->data['user_id'] && $perm['u_delete']) || $perm['m_delete'])) { // Delete Poll $sql = "DELETE FROM " . POLL_OPTIONS_TABLE . " @@ -553,7 +553,9 @@ if (($submit) || ($preview) || ($refresh)) 'poll_max_options' => 0 ); - $sql = 'UPDATE ' . TOPICS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $topic_sql) . ' WHERE topic_id = ' . $topic_id; + $sql = 'UPDATE ' . TOPICS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $topic_sql) . ' + WHERE topic_id = ' . $topic_id; $db->sql_query($sql); $poll_title = ''; @@ -575,7 +577,7 @@ if (($submit) || ($preview) || ($refresh)) // If replying/quoting and last post id has changed // give user option of continuing submit or return to post // notify and show user the post made between his request and the final submit - if ( ($mode == 'reply' || $mode == 'quote') && ($topic_cur_post_id != $topic_last_post_id) ) + if (($mode == 'reply' || $mode == 'quote') && $topic_cur_post_id != $topic_last_post_id) { $template->assign_vars(array( 'S_POST_REVIEW' => true) @@ -662,7 +664,7 @@ if (($submit) || ($preview) || ($refresh)) $err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $result; } - if (($mode != 'edit') && (!$preview) && (!$refresh) && (!$perm['f_ignoreflood'])) + if ($mode != 'edit' && !$preview && !$refresh && !$perm['f_ignoreflood']) { // Flood check $where_sql = ($user->data['user_id'] == ANONYMOUS) ? "poster_ip = '$user->ip'" : 'poster_id = ' . $user->data['user_id']; @@ -693,7 +695,7 @@ if (($submit) || ($preview) || ($refresh)) } // Parse subject - if ( ($subject == '') && ($mode == 'post' || ($mode == 'edit' && $topic_first_post_id == $post_id))) + if ($subject == '' && ($mode == 'post' || ($mode == 'edit' && $topic_first_post_id == $post_id))) { $err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $user->lang['EMPTY_SUBJECT']; } diff --git a/phpBB/templates/subSilver/index_body.html b/phpBB/templates/subSilver/index_body.html index 9e48288e6b..cd5ba8b757 100644 --- a/phpBB/templates/subSilver/index_body.html +++ b/phpBB/templates/subSilver/index_body.html @@ -24,10 +24,21 @@ <td class="cat" colspan="2" height="28"><a class="cattitle" href="{forumrow.U_VIEWFORUM}">{forumrow.FORUM_NAME}</a></td> <td class="rowpic" colspan="3" align="right"> </td> </tr> + <!-- ELSEIF forumrow.S_IS_LINK --> + <tr> + <td class="row1" width="50" height="50" align="center" valign="middle">{forumrow.FORUM_FOLDER_IMG}</td> + <td class="row1" height="50"><a class="forumlink" href="{forumrow.U_VIEWFORUM}">{forumrow.FORUM_NAME}</a><br /> + <table cellspacing="5" cellpadding="0" border="0"> + <tr> + <td><span class="gensmall">{forumrow.FORUM_DESC}</span></td> + </tr> + </table></td> + <td class="row2" colspan="3" align="center" valign="middle" height="50"><!-- IF forumrow.CLICKS neq '' --><span class="gensmall">{L_REDIRECTS}: {forumrow.CLICKS}</span><!-- ENDIF --></td> + </tr> <!-- ELSE --> <tr> <td class="row1" width="50" height="50" align="center" valign="middle">{forumrow.FORUM_FOLDER_IMG}</td> - <td class="row1" width="100%" height="50" valign="top"><a class="forumlink" href="{forumrow.U_VIEWFORUM}">{forumrow.FORUM_NAME}</a><br /> + <td class="row1" width="100%" height="50" valign="top"><a class="forumlink" href="{forumrow.U_VIEWFORUM}">{forumrow.FORUM_NAME}</a><br /> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td><span class="gensmall">{forumrow.FORUM_DESC}</span></td> diff --git a/phpBB/templates/subSilver/posting_body.html b/phpBB/templates/subSilver/posting_body.html index 46069753bd..61297d74c3 100644 --- a/phpBB/templates/subSilver/posting_body.html +++ b/phpBB/templates/subSilver/posting_body.html @@ -29,7 +29,7 @@ function checkForm() alert('{L_EMPTY_MESSAGE}'); return false; } else { - bbstyle(-1); +// document.post.post.disabled = true; return true; } } diff --git a/phpBB/templates/subSilver/viewforum_subforum.html b/phpBB/templates/subSilver/viewforum_subforum.html index 4a902fd398..439649cbd0 100644 --- a/phpBB/templates/subSilver/viewforum_subforum.html +++ b/phpBB/templates/subSilver/viewforum_subforum.html @@ -8,7 +8,19 @@ <!-- BEGIN forumrow --> <!-- IF forumrow.S_IS_CAT --> <tr> - <td class="cat" colspan="5" height="28"><a class="cattitle" href="{forumrow.U_VIEWFORUM}">{forumrow.FORUM_NAME}</a></td> + <td class="cat" colspan="2" height="28"><a class="cattitle" href="{forumrow.U_VIEWFORUM}">{forumrow.FORUM_NAME}</a></td> + <td class="rowpic" colspan="3" align="right"> </td> + </tr> + <!-- ELSEIF forumrow.S_IS_LINK --> + <tr> + <td class="row1" width="50" height="50" align="center" valign="middle">{forumrow.FORUM_FOLDER_IMG}</td> + <td class="row1" height="50"><a class="forumlink" href="{forumrow.U_VIEWFORUM}">{forumrow.FORUM_NAME}</a><br /> + <table cellspacing="5" cellpadding="0" border="0"> + <tr> + <td><span class="gensmall">{forumrow.FORUM_DESC}</span></td> + </tr> + </table></td> + <td class="row2" colspan="3" align="center" valign="middle" height="50"><!-- IF forumrow.CLICKS neq '' --><span class="gensmall">{L_REDIRECTS}: {forumrow.CLICKS}</span><!-- ENDIF --></td> </tr> <!-- ELSE --> <tr> @@ -21,7 +33,7 @@ </table><span class="gensmall"><!-- IF forumrow.MODERATORS --><b>{forumrow.L_MODERATOR_STR}:</b> {forumrow.MODERATORS}<br /><!-- ENDIF --><!-- IF forumrow.SUBFORUMS --><br /><b>{forumrow.L_SUBFORUM_STR}</b> {forumrow.SUBFORUMS}<!-- ENDIF --></span></td> <td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{forumrow.TOPICS}</span></td> <td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{forumrow.POSTS}</span></td> - <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><!-- IF forumrow.LAST_POST_TIME --><span class="gensmall">{forumrow.LAST_POST_TIME}<br /><!-- IF forumrow.U_LAST_POSTER --><a href="{forumrow.U_LAST_POSTER}">{forumrow.LAST_POSTER}</a><!-- ELSE -->{forumrow.LAST_POSTER}<!-- ENDIF --> <a href="{forumrow.U_LAST_POST}">{forumrow.LAST_POST_IMG}</a></span><!-- ELSE -->{L_NO_POSTS}<!-- ENDIF --></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="gensmall"><!-- IF forumrow.LAST_POST_TIME -->{forumrow.LAST_POST_TIME}<br /><!-- IF forumrow.U_LAST_POSTER --><a href="{forumrow.U_LAST_POSTER}">{forumrow.LAST_POSTER}</a><!-- ELSE -->{forumrow.LAST_POSTER}<!-- ENDIF --> <a href="{forumrow.U_LAST_POST}">{forumrow.LAST_POST_IMG}</a><!-- ELSE -->{L_NO_POSTS}<!-- ENDIF --></span></td> </tr> <!-- ENDIF --> <!-- END forumrow --> diff --git a/phpBB/templates/subSilver/viewtopic_body.html b/phpBB/templates/subSilver/viewtopic_body.html index f3034414c8..8818c0c33e 100644 --- a/phpBB/templates/subSilver/viewtopic_body.html +++ b/phpBB/templates/subSilver/viewtopic_body.html @@ -23,7 +23,7 @@ <td class="cat" colspan="2" height="28"><table width="100%" cellspacing="0" cellpadding="0" border="0"> <tr> <td><span class="nav"> <a href="{U_PRINT_TOPIC}" title="{L_PRINT_TOPIC}">{L_PRINT_TOPIC}</a> :: <a href="{U_EMAIL_TOPIC}" title="{L_EMAIL_TOPIC}">{L_EMAIL_TOPIC}</a></span></td> - <td align="right"><span class="nav"><a href="{U_VIEW_OLDER_TOPIC}">{L_VIEW_PREVIOUS_TOPIC}</a> :: <a href="{U_VIEW_NEWER_TOPIC}">{L_VIEW_NEXT_TOPIC}</a> </span></td> + <td align="right"><span class="nav"><a href="{U_VIEW_UNREAD_POST}">{L_VIEW_UNREAD_POST}</a> :: <a href="{U_VIEW_OLDER_TOPIC}">{L_VIEW_PREVIOUS_TOPIC}</a> :: <a href="{U_VIEW_NEWER_TOPIC}">{L_VIEW_NEXT_TOPIC}</a> </span></td> </tr> </table></td> </tr> diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index fe796bdaee..64dd9948df 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -89,23 +89,47 @@ else } $result = $db->sql_query($sql); -if (!$forum_data = $db->sql_fetchrow($result)) +if (!($forum_data = $db->sql_fetchrow($result))) { trigger_error('NO_FORUM'); } $db->sql_freeresult($result); +// Is this forum a link? ... User got here either because the +// number of clicks is being tracked or they guessed the id +if ($forum_data['forum_link']) +{ + // Does it have click tracking enabled? + if ($forum_data['forum_link_track']) + { + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET forum_posts = forum_posts + 1'; + $db->sql_query($sql); + } + + redirect($forum_data['forum_link']); +} + + // Configure style, language, etc. $user->setup(false, $forum_data['forum_style']); +// Does a password exist for this forum? If so do the necessary +if ($forum_data['forum_password']) +{ + + +} + + // Permissions check if (!$auth->acl_gets('f_read', $forum_id)) { if ($user->data['user_id'] != ANONYMOUS) { - trigger_error('SORRY_AUTH_READ'); + trigger_error($user->lang['SORRY_AUTH_READ']); } login_box(preg_replace('#.*?([a-z]+?\.' . $phpEx . '.*?)$#i', '\1', htmlspecialchars($_SERVER['REQUEST_URI'])), '', $user->lang['LOGIN_VIEWFORUM']); @@ -132,7 +156,7 @@ else // Output forum listing if it is postable -if ($forum_data['forum_postable']) +if ($forum_data['forum_type'] == FORUM_POST) { // Handle marking posts if ($mark_read == 'topics') @@ -215,6 +239,13 @@ if ($forum_data['forum_postable']) $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); + // Is a forum specific topic count required? + if ($forum_data['forum_topics_per_page']) + { + $config['topics_per_page'] = $forum_data['forum_topics_per_page']; + } + + // Basic pagewide vars $post_alt = (intval($forum_data['forum_status']) == ITEM_LOCKED) ? 'FORUM_LOCKED' : 'POST_NEW_TOPIC'; @@ -242,10 +273,10 @@ if ($forum_data['forum_postable']) 'L_NO_TOPICS' => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['POST_FORUM_LOCKED'] : $user->lang['NO_TOPICS'], - 'S_IS_POSTABLE' => TRUE, - 'S_SELECT_SORT_DIR' => $s_sort_dir, - 'S_SELECT_SORT_KEY' => $s_sort_key, - 'S_SELECT_SORT_DAYS' => $s_limit_days, + 'S_IS_POSTABLE' => TRUE, + 'S_SELECT_SORT_DIR' => $s_sort_dir, + 'S_SELECT_SORT_KEY' => $s_sort_key, + 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_TOPIC_ICONS' => ($forum_data['enable_icons']) ? true : false, 'S_WATCH_FORUM' => $s_watching_forum, 'S_FORUM_ACTION' => "viewforum.$phpExx$SIDx&f=$forum_id&start=$start", @@ -266,6 +297,7 @@ if ($forum_data['forum_postable']) $total_topics = 0; $row_ary = array(); + // TODO - Oracle support $sql_approved = ($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1'; $sql_tracking = (($config['load_db_lastread'] || $config['load_db_track']) && $user->data['user_id'] != ANONYMOUS) ? 'LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')' : ''; $sql_select = (($config['load_db_lastread'] || $config['load_db_track']) && $user->data['user_id'] != ANONYMOUS) ? ', tt.mark_type, tt.mark_time' : ''; @@ -378,6 +410,7 @@ if ($forum_data['forum_postable']) $folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS'); + // Posted image? if (!empty($row['mark_type'])) { $folder_img .= '_posted'; @@ -466,7 +499,7 @@ if ($forum_data['forum_postable']) 'S_ROW_COUNT' => $i, 'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test, 'S_TOPIC_TYPE' => $row['topic_type'], - 'S_USER_POSTED' => ($row['lastread_type'] == LASTREAD_POSTED) ? true : false, + 'S_USER_POSTED' => (!empty($row['mark_type'])) ? true : false, 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_gets('m_', $forum_id)) ? TRUE : FALSE, 'S_TOPIC_UNAPPROVED' => (!$row['topic_approved'] && $auth->acl_gets('m_approve', $forum_id)) ? TRUE : FALSE, @@ -514,13 +547,13 @@ if ($forum_data['forum_postable']) } } - +/* // Mozilla navigation links $nav_links['up'] = array( 'url' => 'index.' . $phpEx . $SID, 'title' => sprintf($user->lang['FORUM_INDEX'], $config['sitename']) ); - +*/ // Dump out the page header and load viewforum template $page_title = $user->lang['VIEW_FORUM'] . ' - ' . $forum_data['forum_name']; diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 4ba92ad7d7..75ec334c5b 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -241,8 +241,8 @@ $limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); $sort_by_sql = array('a' => 'u.username', 't' => 'p.post_id', 's' => 'p.post_subject'); -$s_limit_days = $s_sort_key = $s_sort_dir = ''; -gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir); +$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; +gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); // Obtain correct post count and ordering SQL if user has // requested anything different @@ -356,7 +356,7 @@ $topic_mod .= ($auth->acl_get('f_announce', $forum_id) && ($topic_type != POST_A $topic_mod .= ($auth->acl_get('m_', $forum_id)) ? '<option value="viewlogs">' . $user->lang['VIEW_TOPIC_LOGS'] . '</option>' : ''; // If we've got a hightlight set pass it on to pagination. -$pagination_url = "viewtopic.$phpEx$SID&t=$topic_id&st=$sort_days&sk=$sort_key&sd=$sort_dir" . (($highlight_match) ? "&hilit=$highlight" : ''); +$pagination_url = "viewtopic.$phpEx$SID&t=$topic_id&" . (($highlight_match) ? "&hilit=$highlight" : ''); $pagination = generate_pagination($pagination_url, $total_posts, $config['posts_per_page'], $start); @@ -406,7 +406,7 @@ $template->assign_vars(array( 'PAGINATION' => (isset($_GET['view']) && $_GET['view'] == 'print') ? '' : $pagination, 'PAGE_NUMBER' => (isset($_GET['view']) && $_GET['view'] == 'print') ? '' : on_page($total_posts, $config['posts_per_page'], $start), 'TOTAL_POSTS' => ($total_posts == 1) ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total_posts), - 'MCP' => ($auth->acl_get('m_', $forum_id)) ? sprintf($user->lang['MCP'], "<a href=\"mcp.$phpEx?sid=" . $user->session_id . "&f=$forum_id&t=$topic_id&start=$start&st=$sort_days&sk=$sort_key&sd=$sort_dir&posts_per_page=" . $config['posts_per_page'] . '">', '</a>') : '', + 'MCP' => ($auth->acl_get('m_', $forum_id)) ? sprintf($user->lang['MCP'], "<a href=\"mcp.$phpEx?sid=" . $user->session_id . "&f=$forum_id&t=$topic_id&start=$start&$u_sort_param&posts_per_page=" . $config['posts_per_page'] . '">', '</a>') : '', 'MODERATORS' => (sizeof($forum_moderators[$forum_id])) ? implode(', ', $forum_moderators[$forum_id]) : '', 'POST_IMG' => $post_img, @@ -430,12 +430,12 @@ $template->assign_vars(array( 'U_TOPIC' => $server_path . "viewtopic.$phpEx?f=$forum_id&t=$topic_id", 'U_FORUM' => $server_path, - - 'U_VIEW_TOPIC' => "viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&start=$start&st=$sort_days&sk=$sort_key&sd=$sort_dir&hilit=$highlight", + 'U_VIEW_UNREAD_POST' => "viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&view=unread", + 'U_VIEW_TOPIC' => "viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&start=$start&$u_sort_param&hilit=$highlight", 'U_VIEW_FORUM' => $view_forum_url, 'U_VIEW_OLDER_TOPIC' => $view_prev_topic_url, 'U_VIEW_NEWER_TOPIC' => $view_next_topic_url, - 'U_PRINT_TOPIC' => "viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&st=$sort_days&sk=$sort_key&sd=$sort_dir&view=print", + 'U_PRINT_TOPIC' => "viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&$u_sort_param&view=print", 'U_EMAIL_TOPIC' => "viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&view=email", 'U_POST_NEW_TOPIC' => $new_topic_url, @@ -577,10 +577,13 @@ if (!empty($poll_start)) 'S_CAN_VOTE' => $s_can_vote, 'S_DISPLAY_RESULTS' => $s_display_results, 'S_IS_MULTI_CHOICE' => ($poll_max_options > 1) ? true : false, - 'S_POLL_ACTION' => "viewtopic.$phpEx$SID&t=$topic_id&sk=$sort_key&sd=$sort_dir", + 'S_POLL_ACTION' => "viewtopic.$phpEx$SID&t=$topic_id&$u_sort_param", - 'U_VIEW_RESULTS' => "viewtopic.$phpEx$SID&t=$topic_id&st=$sort_days&sk=$sort_key&sd=$sort_dir&vote=viewresult") + 'U_VIEW_RESULTS' => "viewtopic.$phpEx$SID&t=$topic_id&$u_sort_param&vote=viewresult") ); + + unset($poll_info); + unset($voted_id); } @@ -814,6 +817,10 @@ while ($row = $db->sql_fetchrow($result)); $db->sql_freeresult($result); +// Store the last post time for this page ... for use in marking +$last_post_time = $row['post_time']; + + // Pull attachment data if (count($attach_list)) { @@ -944,7 +951,7 @@ foreach ($rowset as $key => $row) $quote_img = '<a href="' . $temp_url . '">' . $user->img('btn_quote', $user->lang['REPLY_WITH_QUOTE']) . '</a>'; $quote = '<a href="' . $temp_url . '">' . $user->lang['REPLY_WITH_QUOTE'] . '</a>'; - if (($user->data['user_id'] == $poster_id && $auth->acl_get('f_edit', $forum_id)) || $auth->acl_get('m_edit', $forum_id)) + if (($user->data['user_id'] == $poster_id && $auth->acl_get('f_edit', $forum_id) && ($post_time > time() - $config['edit_time'] || !$config['edit_time'])) || $auth->acl_get('m_edit', $forum_id)) { $temp_url = "posting.$phpEx$SID&mode=edit&f=" . $row['forum_id'] . "&p=" . $row['post_id']; $edit_img = '<a href="' . $temp_url . '">' . $user->img('btn_edit', $user->lang['EDIT_DELETE_POST']) . '</a>'; @@ -1005,7 +1012,7 @@ foreach ($rowset as $key => $row) // If we allow users to disable display of emoticons // we'll need an appropriate check and preg_replace here - $message = (empty($row['enable_smilies']) || empty($config['allow_smilies'])) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $message) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $config['smilies_path'], $message); + $message = (empty($config['allow_smilies'])) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $message) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $config['smilies_path'], $message); // Highlight active words (primarily for search) @@ -1156,8 +1163,9 @@ foreach ($rowset as $key => $row) $denied = true; $template->assign_block_vars('postrow.attachment', array( - 'IS_DENIED' => true, - 'L_DENIED' => sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension'])) + 'IS_DENIED' => true, + + 'L_DENIED' => sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension'])) ); } @@ -1202,18 +1210,15 @@ foreach ($rowset as $key => $row) // NOTE: If you want to use the download.php everytime an image is displayed inlined, replace the // Section between BEGIN and END with (Without the // of course): // $img_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id']; - // - // BEGIN if (!empty($config['ftp_upload']) && trim($config['upload_dir']) == '') { - $img_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id']; + $img_source = $phpbb_root_path . "download.$phpEx$SID&id=" . $attachment['attach_id']; } else { $img_source = $filename; $update_count[] = $attachment['attach_id']; } - // END $l_downloaded_viewed = $user->lang['VIEWED']; $download_link = $img_source; @@ -1224,23 +1229,20 @@ foreach ($rowset as $key => $row) // NOTE: If you want to use the download.php everytime an thumnmail is displayed inlined, replace the // Section between BEGIN and END with (Without the // of course): // $thumb_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id'] . '&thumb=1'; - // - // BEGIN if (!empty($config['allow_ftp_upload']) && trim($config['upload_dir']) == '') { - $thumb_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id'] . '&thumb=1'; + $thumb_source = $phpbb_root_path . "download.$phpEx$SID&id=" . $attachment['attach_id'] . '&thumb=1'; } else { $thumb_source = $thumbnail_filename; } - // END $l_downloaded_viewed = $user->lang['VIEWED']; - $download_link = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id']; + $download_link = $phpbb_root_path . "download.$phpEx$SID&id=" . $attachment['attach_id']; $additional_array = array( - 'IMG_THUMB_SRC' => $thumb_source + 'IMG_THUMB_SRC' => $thumb_source // should be THUMB_IMG or similar ); break; @@ -1250,10 +1252,7 @@ foreach ($rowset as $key => $row) $download_link = $filename; // Viewed/Heared File ... update the download count (download.php is not called here) - if (!preg_match("#&t=$topic_id#", $user->data['session_page'])) - { - $update_count[] = $attachment['attach_id']; - } + $update_count[] = $attachment['attach_id']; break; case RM_CAT: @@ -1262,15 +1261,12 @@ foreach ($rowset as $key => $row) $download_link = $filename; $additional_array = array( - 'FORUM_URL' => generate_board_url(), + 'FORUM_URL' => generate_board_url(), // should be U_FORUM or similar 'ATTACH_ID' => $attachment['attach_id'] ); // Viewed/Heared File ... update the download count (download.php is not called here) - if (!preg_match("#&t=$topic_id#", $user->data['session_page'])) - { - $update_count[] = $attachment['attach_id']; - } + $update_count[] = $attachment['attach_id']; break; /* case SWF_CAT: @@ -1329,26 +1325,29 @@ unset($rowset); unset($user_cache); -// Udate the attachment download counts -if (count($update_count)) -{ - $sql = "UPDATE " . ATTACHMENTS_DESC_TABLE . " - SET download_count = download_count + 1 - WHERE attach_id IN (" . implode(', ', array_unique($update_count)) . ")"; - $db->sql_query($sql); -} -// Update the topic view counter, excepted when the user was already reading it +// Update topic view and if necessary attachment view counters ... but only +// if this is the first 'page view' if (!preg_match("#&t=$topic_id#", $user->data['session_page'])) { $sql = "UPDATE " . TOPICS_TABLE . " SET topic_views = topic_views + 1 WHERE topic_id = $topic_id"; $db->sql_query($sql); + + // Update the attachment download counts + if (count($update_count)) + { + $sql = "UPDATE " . ATTACHMENTS_DESC_TABLE . " + SET download_count = download_count + 1 + WHERE attach_id IN (" . implode(', ', array_unique($update_count)) . ")"; + $db->sql_query($sql); + } } // Mozilla navigation bar +/* $nav_links['prev'] = array( 'url' => $view_prev_topic_url, 'title' => $user->lang['View_previous_topic'] @@ -1361,10 +1360,10 @@ $nav_links['up'] = array( 'url' => $view_forum_url, 'title' => $forum_name ); - +*/ // Mark topics read -markread('topic', $forum_id, $topic_id, $topic_data['topic_last_post_id']); +markread('topic', $forum_id, $topic_id, $last_post_time); // Change encoding if appropriate @@ -1375,7 +1374,7 @@ if ($force_encoding != '') // Output the page -$page_title = $user->lang['View_topic'] .' - ' . $topic_title; +$page_title = $user->lang['VIEW_TOPIC'] .' - ' . $topic_title; include($phpbb_root_path . 'includes/page_header.'.$phpEx); $template->set_filenames(array( |