punbb/moderate.php
author Dan
Wed, 11 Jul 2007 21:01:48 -0400
changeset 0 f9ffdbd96607
child 2 a8a21e1c7afa
permissions -rw-r--r--
Initial population
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     1
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     2
/***********************************************************************
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     3
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     4
  Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     5
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     6
  This file is part of PunBB.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     7
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     8
  PunBB is free software; you can redistribute it and/or modify it
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     9
  under the terms of the GNU General Public License as published
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    10
  by the Free Software Foundation; either version 2 of the License,
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    11
  or (at your option) any later version.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    12
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    13
  PunBB is distributed in the hope that it will be useful, but
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    14
  WITHOUT ANY WARRANTY; without even the implied warranty of
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    15
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    16
  GNU General Public License for more details.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    17
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    18
  You should have received a copy of the GNU General Public License
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    19
  along with this program; if not, write to the Free Software
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    20
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    21
  MA  02111-1307  USA
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    22
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    23
************************************************************************/
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    24
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    25
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    26
define('PUN_ROOT', './');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    27
require PUN_ROOT.'include/common.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    28
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    29
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    30
// This particular function doesn't require forum-based moderator access. It can be used
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    31
// by all moderators and admins.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    32
if (isset($_GET['get_host']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    33
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    34
	if ($pun_user['g_id'] > PUN_MOD)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    35
		message($lang_common['No permission']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    36
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    37
	// Is get_host an IP address or a post ID?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    38
	if (@preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $_GET['get_host']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    39
		$ip = $_GET['get_host'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    40
	else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    41
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    42
		$get_host = intval($_GET['get_host']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    43
		if ($get_host < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    44
			message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    45
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    46
		$result = $db->query('SELECT poster_ip FROM '.$db->prefix.'posts WHERE id='.$get_host) or error('Unable to fetch post IP address', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    47
		if (!$db->num_rows($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    48
			message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    49
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    50
		$ip = $db->result($result);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    51
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    52
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    53
	message('The IP address is: '.$ip.'<br />The host name is: '.@gethostbyaddr($ip).'<br /><br /><a href="admin_users.php?show_users='.$ip.'">Show more users for this IP</a>');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    54
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    55
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    56
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    57
// All other functions require moderator/admin access
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    58
$fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    59
if ($fid < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    60
	message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    61
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    62
$result = $db->query('SELECT moderators FROM '.$db->prefix.'forums WHERE id='.$fid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    63
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    64
$moderators = $db->result($result);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    65
$mods_array = ($moderators != '') ? unserialize($moderators) : array();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    66
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    67
if ($pun_user['g_id'] != PUN_ADMIN && ($pun_user['g_id'] != PUN_MOD || !array_key_exists($pun_user['username'], $mods_array)))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    68
	message($lang_common['No permission']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    69
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    70
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    71
// Load the misc.php language file
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    72
require PUN_ROOT.'lang/'.$pun_user['language'].'/misc.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    73
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    74
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    75
// All other topic moderation features require a topic id in GET
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    76
if (isset($_GET['tid']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    77
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    78
	$tid = intval($_GET['tid']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    79
	if ($tid < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    80
		message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    81
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    82
	// Fetch some info about the topic
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    83
	$result = $db->query('SELECT t.subject, t.num_replies, f.id AS forum_id, forum_name FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['id'].') LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.id='.$fid.' AND t.id='.$tid.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    84
	if (!$db->num_rows($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    85
		message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    86
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    87
	$cur_topic = $db->fetch_assoc($result);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    88
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    89
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    90
	// Delete one or more posts
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    91
	if (isset($_POST['delete_posts']) || isset($_POST['delete_posts_comply']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    92
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    93
		$posts = $_POST['posts'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    94
		if (empty($posts))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    95
			message($lang_misc['No posts selected']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    96
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    97
		if (isset($_POST['delete_posts_comply']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    98
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    99
			confirm_referrer('moderate.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   100
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   101
			if (@preg_match('/[^0-9,]/', $posts))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   102
				message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   103
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   104
			// Verify that the post IDs are valid
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   105
			$result = $db->query('SELECT 1 FROM '.$db->prefix.'posts WHERE id IN('.$posts.') AND topic_id='.$tid) or error('Unable to check posts', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   106
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   107
			if ($db->num_rows($result) != substr_count($posts, ',') + 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   108
				message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   109
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   110
			// Delete the posts
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   111
			$db->query('DELETE FROM '.$db->prefix.'posts WHERE id IN('.$posts.')') or error('Unable to delete posts', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   112
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   113
			require PUN_ROOT.'include/search_idx.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   114
			strip_search_index($posts);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   115
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   116
			// Get last_post, last_post_id, and last_poster for the topic after deletion
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   117
			$result = $db->query('SELECT id, poster, posted FROM '.$db->prefix.'posts WHERE topic_id='.$tid.' ORDER BY id DESC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   118
			$last_post = $db->fetch_assoc($result);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   119
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   120
			// How many posts did we just delete?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   121
			$num_posts_deleted = substr_count($posts, ',') + 1;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   122
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   123
			// Update the topic
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   124
			$db->query('UPDATE '.$db->prefix.'topics SET last_post='.$last_post['posted'].', last_post_id='.$last_post['id'].', last_poster=\''.$db->escape($last_post['poster']).'\', num_replies=num_replies-'.$num_posts_deleted.' WHERE id='.$tid) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   125
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   126
			update_forum($fid);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   127
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   128
			redirect('viewtopic.php?id='.$tid, $lang_misc['Delete posts redirect']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   129
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   130
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   131
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   132
		$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_misc['Moderate'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   133
		require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   134
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   135
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   136
<div class="blockform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   137
	<h2><span><?php echo $lang_misc['Delete posts'] ?></span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   138
	<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   139
		<form method="post" action="moderate.php?fid=<?php echo $fid ?>&amp;tid=<?php echo $tid ?>">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   140
			<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   141
				<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   142
					<legend><?php echo $lang_misc['Confirm delete legend'] ?></legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   143
					<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   144
						<input type="hidden" name="posts" value="<?php echo implode(',', array_keys($posts)) ?>" />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   145
						<p><?php echo $lang_misc['Delete posts comply'] ?></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   146
					</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   147
				</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   148
			</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   149
			<p><input type="submit" name="delete_posts_comply" value="<?php echo $lang_misc['Delete'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   150
		</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   151
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   152
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   153
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   154
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   155
		require PUN_ROOT.'footer.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   156
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   157
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   158
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   159
	// Show the delete multiple posts view
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   160
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   161
	// Load the viewtopic.php language file
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   162
	require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   163
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   164
	// Used to disable the Move and Delete buttons if there are no replies to this topic
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   165
	$button_status = ($cur_topic['num_replies'] == 0) ? ' disabled' : '';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   166
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   167
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   168
	// Determine the post offset (based on $_GET['p'])
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   169
	$num_pages = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   170
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   171
	$p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   172
	$start_from = $pun_user['disp_posts'] * ($p - 1);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   173
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   174
	// Generate paging links
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   175
	$paging_links = $lang_common['Pages'].': '.paginate($num_pages, $p, 'moderate.php?fid='.$fid.'&amp;tid='.$tid);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   176
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   177
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   178
	if ($pun_config['o_censoring'] == '1')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   179
		$cur_topic['subject'] = censor_words($cur_topic['subject']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   180
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   181
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   182
	$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$cur_topic['subject'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   183
	require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   184
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   185
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   186
<div class="linkst">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   187
	<div class="inbox">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   188
		<p class="pagelink conl"><?php echo $paging_links ?></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   189
		<ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li><li>&nbsp;&raquo;&nbsp;<a href="viewforum.php?id=<?php echo $fid ?>"><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li><li>&nbsp;&raquo;&nbsp;<?php echo pun_htmlspecialchars($cur_topic['subject']) ?></li></ul>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   190
		<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   191
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   192
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   193
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   194
<form method="post" action="moderate.php?fid=<?php echo $fid ?>&amp;tid=<?php echo $tid ?>">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   195
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   196
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   197
	require PUN_ROOT.'include/parser.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   198
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   199
	$bg_switch = true;	// Used for switching background color in posts
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   200
	$post_count = 0;	// Keep track of post numbers
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   201
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   202
	// Retrieve the posts (and their respective poster)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   203
	$result = $db->query('SELECT u.title, u.num_posts, g.g_id, g.g_user_title, p.id, p.poster, p.poster_id, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE p.topic_id='.$tid.' ORDER BY p.id LIMIT '.$start_from.','.$pun_user['disp_posts'], true) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   204
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   205
	while ($cur_post = $db->fetch_assoc($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   206
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   207
		$post_count++;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   208
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   209
		// If the poster is a registered user.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   210
		if ($cur_post['poster_id'] > 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   211
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   212
			$poster = '<a href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a>';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   213
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   214
			// get_title() requires that an element 'username' be present in the array
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   215
			$cur_post['username'] = $cur_post['poster'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   216
			$user_title = get_title($cur_post);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   217
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   218
			if ($pun_config['o_censoring'] == '1')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   219
				$user_title = censor_words($user_title);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   220
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   221
		// If the poster is a guest (or a user that has been deleted)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   222
		else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   223
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   224
			$poster = pun_htmlspecialchars($cur_post['poster']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   225
			$user_title = $lang_topic['Guest'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   226
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   227
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   228
		// Switch the background color for every message.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   229
		$bg_switch = ($bg_switch) ? $bg_switch = false : $bg_switch = true;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   230
		$vtbg = ($bg_switch) ? ' roweven' : ' rowodd';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   231
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   232
		// Perform the main parsing of the message (BBCode, smilies, censor words etc)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   233
		$cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   234
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   235
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   236
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   237
<div class="blockpost<?php echo $vtbg ?>">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   238
	<a name="<?php echo $cur_post['id'] ?>"></a>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   239
	<h2><span><span class="conr">#<?php echo ($start_from + $post_count) ?>&nbsp;</span><a href="viewtopic.php?pid=<?php echo $cur_post['id'].'#p'.$cur_post['id'] ?>"><?php echo format_time($cur_post['posted']) ?></a></span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   240
	<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   241
		<div class="inbox">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   242
			<div class="postleft">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   243
				<dl>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   244
					<dt><strong><?php echo $poster ?></strong></dt>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   245
					<dd><strong><?php echo $user_title ?></strong></dd>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   246
				</dl>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   247
			</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   248
			<div class="postright">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   249
				<h3 class="nosize"><?php echo $lang_common['Message'] ?></h3>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   250
				<div class="postmsg">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   251
					<?php echo $cur_post['message']."\n" ?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   252
<?php if ($cur_post['edited'] != '') echo "\t\t\t\t\t".'<p class="postedit"><em>'.$lang_topic['Last edit'].' '.pun_htmlspecialchars($cur_post['edited_by']).' ('.format_time($cur_post['edited']).')</em></p>'."\n"; ?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   253
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   254
				<?php if ($start_from + $post_count > 1) echo '<p class="multidelete"><label><strong>'.$lang_misc['Select'].'</strong>&nbsp;&nbsp;<input type="checkbox" name="posts['.$cur_post['id'].']" value="1" /></label></p>'."\n" ?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   255
			</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   256
			<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   257
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   258
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   259
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   260
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   261
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   262
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   263
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   264
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   265
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   266
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   267
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   268
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   269
<div class="postlinksb">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   270
	<div class="inbox">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   271
		<p class="pagelink conl"><?php echo $paging_links ?></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   272
		<p class="conr"><input type="submit" name="delete_posts" value="<?php echo $lang_misc['Delete'] ?>"<?php echo $button_status ?> /></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   273
		<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   274
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   275
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   276
</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   277
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   278
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   279
	require PUN_ROOT.'footer.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   280
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   281
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   282
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   283
// Move one or more topics
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   284
if (isset($_REQUEST['move_topics']) || isset($_POST['move_topics_to']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   285
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   286
	if (isset($_POST['move_topics_to']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   287
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   288
		confirm_referrer('moderate.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   289
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   290
		if (@preg_match('/[^0-9,]/', $_POST['topics']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   291
			message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   292
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   293
		$topics = explode(',', $_POST['topics']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   294
		$move_to_forum = isset($_POST['move_to_forum']) ? intval($_POST['move_to_forum']) : 0;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   295
		if (empty($topics) || $move_to_forum < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   296
			message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   297
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   298
		// Verify that the topic IDs are valid
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   299
		$result = $db->query('SELECT 1 FROM '.$db->prefix.'topics WHERE id IN('.implode(',',$topics).') AND forum_id='.$fid) or error('Unable to check topics', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   300
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   301
		if ($db->num_rows($result) != count($topics))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   302
			message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   303
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   304
		// Delete any redirect topics if there are any (only if we moved/copied the topic back to where it where it was once moved from)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   305
		$db->query('DELETE FROM '.$db->prefix.'topics WHERE forum_id='.$move_to_forum.' AND moved_to IN('.implode(',',$topics).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   306
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   307
		// Move the topic(s)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   308
		$db->query('UPDATE '.$db->prefix.'topics SET forum_id='.$move_to_forum.' WHERE id IN('.implode(',',$topics).')') or error('Unable to move topics', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   309
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   310
		// Should we create redirect topics?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   311
		if (isset($_POST['with_redirect']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   312
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   313
			while (list(, $cur_topic) = @each($topics))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   314
			{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   315
				// Fetch info for the redirect topic
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   316
				$result = $db->query('SELECT poster, subject, posted, last_post FROM '.$db->prefix.'topics WHERE id='.$cur_topic) or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   317
				$moved_to = $db->fetch_assoc($result);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   318
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   319
				// Create the redirect topic
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   320
				$db->query('INSERT INTO '.$db->prefix.'topics (poster, subject, posted, last_post, moved_to, forum_id) VALUES(\''.$db->escape($moved_to['poster']).'\', \''.$db->escape($moved_to['subject']).'\', '.$moved_to['posted'].', '.$moved_to['last_post'].', '.$cur_topic.', '.$fid.')') or error('Unable to create redirect topic', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   321
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   322
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   323
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   324
		update_forum($fid);				// Update the forum FROM which the topic was moved
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   325
		update_forum($move_to_forum);	// Update the forum TO which the topic was moved
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   326
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   327
		$redirect_msg = (count($topics) > 1) ? $lang_misc['Move topics redirect'] : $lang_misc['Move topic redirect'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   328
		redirect('viewforum.php?id='.$move_to_forum, $redirect_msg);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   329
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   330
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   331
	if (isset($_POST['move_topics']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   332
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   333
		$topics = isset($_POST['topics']) ? $_POST['topics'] : array();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   334
		if (empty($topics))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   335
			message($lang_misc['No topics selected']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   336
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   337
		$topics = implode(',', array_keys($topics));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   338
		$action = 'multi';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   339
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   340
	else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   341
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   342
		$topics = intval($_GET['move_topics']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   343
		if ($topics < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   344
			message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   345
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   346
		$action = 'single';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   347
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   348
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   349
	$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Moderate';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   350
	require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   351
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   352
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   353
<div class="blockform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   354
	<h2><span><?php echo ($action == 'single') ? $lang_misc['Move topic'] : $lang_misc['Move topics'] ?></span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   355
	<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   356
		<form method="post" action="moderate.php?fid=<?php echo $fid ?>">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   357
			<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   358
			<input type="hidden" name="topics" value="<?php echo $topics ?>" />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   359
				<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   360
					<legend><?php echo $lang_misc['Move legend'] ?></legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   361
					<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   362
						<label><?php echo $lang_misc['Move to'] ?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   363
						<br /><select name="move_to_forum">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   364
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   365
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   366
	$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.redirect_url IS NULL ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   367
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   368
	$cur_category = 0;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   369
	while ($cur_forum = $db->fetch_assoc($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   370
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   371
		if ($cur_forum['cid'] != $cur_category)	// A new category since last iteration?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   372
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   373
			if ($cur_category)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   374
				echo "\t\t\t\t\t\t\t".'</optgroup>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   375
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   376
			echo "\t\t\t\t\t\t\t".'<optgroup label="'.pun_htmlspecialchars($cur_forum['cat_name']).'">'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   377
			$cur_category = $cur_forum['cid'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   378
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   379
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   380
		if ($cur_forum['fid'] != $fid)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   381
			echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_forum['fid'].'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</option>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   382
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   383
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   384
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   385
							</optgroup>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   386
						</select>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   387
						<br /></label>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   388
						<div class="rbox">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   389
							<label><input type="checkbox" name="with_redirect" value="1"<?php if ($action == 'single') echo ' checked="checked"' ?> /><?php echo $lang_misc['Leave redirect'] ?><br /></label>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   390
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   391
					</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   392
				</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   393
			</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   394
			<p><input type="submit" name="move_topics_to" value="<?php echo $lang_misc['Move'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   395
		</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   396
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   397
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   398
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   399
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   400
	require PUN_ROOT.'footer.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   401
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   402
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   403
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   404
// Delete one or more topics
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   405
if (isset($_REQUEST['delete_topics']) || isset($_POST['delete_topics_comply']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   406
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   407
	$topics = isset($_POST['topics']) ? $_POST['topics'] : array();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   408
	if (empty($topics))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   409
		message($lang_misc['No topics selected']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   410
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   411
	if (isset($_POST['delete_topics_comply']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   412
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   413
		confirm_referrer('moderate.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   414
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   415
		if (@preg_match('/[^0-9,]/', $topics))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   416
			message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   417
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   418
		require PUN_ROOT.'include/search_idx.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   419
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   420
		// Verify that the topic IDs are valid
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   421
		$result = $db->query('SELECT 1 FROM '.$db->prefix.'topics WHERE id IN('.$topics.') AND forum_id='.$fid) or error('Unable to check topics', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   422
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   423
		if ($db->num_rows($result) != substr_count($topics, ',') + 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   424
			message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   425
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   426
		// Delete the topics and any redirect topics
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   427
		$db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.$topics.') OR moved_to IN('.$topics.')') or error('Unable to delete topic', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   428
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   429
		// Delete any subscriptions
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   430
		$db->query('DELETE FROM '.$db->prefix.'subscriptions WHERE topic_id IN('.$topics.')') or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   431
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   432
		// Create a list of the post ID's in this topic and then strip the search index
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   433
		$result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id IN('.$topics.')') or error('Unable to fetch posts', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   434
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   435
		$post_ids = '';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   436
		while ($row = $db->fetch_row($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   437
			$post_ids .= ($post_ids != '') ? ','.$row[0] : $row[0];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   438
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   439
		// We have to check that we actually have a list of post ID's since we could be deleting just a redirect topic
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   440
		if ($post_ids != '')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   441
			strip_search_index($post_ids);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   442
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   443
		// Delete posts
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   444
		$db->query('DELETE FROM '.$db->prefix.'posts WHERE topic_id IN('.$topics.')') or error('Unable to delete posts', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   445
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   446
		update_forum($fid);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   447
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   448
		redirect('viewforum.php?id='.$fid, $lang_misc['Delete topics redirect']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   449
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   450
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   451
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   452
	$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_misc['Moderate'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   453
	require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   454
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   455
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   456
<div class="blockform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   457
	<h2><?php echo $lang_misc['Delete topics'] ?></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   458
	<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   459
		<form method="post" action="moderate.php?fid=<?php echo $fid ?>">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   460
			<input type="hidden" name="topics" value="<?php echo implode(',', array_keys($topics)) ?>" />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   461
			<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   462
				<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   463
					<legend><?php echo $lang_misc['Confirm delete legend'] ?></legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   464
					<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   465
						<p><?php echo $lang_misc['Delete topics comply'] ?></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   466
					</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   467
				</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   468
			</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   469
			<p><input type="submit" name="delete_topics_comply" value="<?php echo $lang_misc['Delete'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   470
		</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   471
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   472
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   473
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   474
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   475
	require PUN_ROOT.'footer.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   476
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   477
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   478
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   479
// Open or close one or more topics
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   480
else if (isset($_REQUEST['open']) || isset($_REQUEST['close']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   481
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   482
	$action = (isset($_REQUEST['open'])) ? 0 : 1;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   483
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   484
	// There could be an array of topic ID's in $_POST
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   485
	if (isset($_POST['open']) || isset($_POST['close']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   486
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   487
		confirm_referrer('moderate.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   488
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   489
		$topics = isset($_POST['topics']) ? @array_map('intval', @array_keys($_POST['topics'])) : array();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   490
		if (empty($topics))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   491
			message($lang_misc['No topics selected']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   492
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   493
		$db->query('UPDATE '.$db->prefix.'topics SET closed='.$action.' WHERE id IN('.implode(',', $topics).') AND forum_id='.$fid) or error('Unable to close topics', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   494
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   495
		$redirect_msg = ($action) ? $lang_misc['Close topics redirect'] : $lang_misc['Open topics redirect'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   496
		redirect('moderate.php?fid='.$fid, $redirect_msg);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   497
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   498
	// Or just one in $_GET
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   499
	else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   500
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   501
		confirm_referrer('viewtopic.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   502
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   503
		$topic_id = ($action) ? intval($_GET['close']) : intval($_GET['open']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   504
		if ($topic_id < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   505
			message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   506
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   507
		$db->query('UPDATE '.$db->prefix.'topics SET closed='.$action.' WHERE id='.$topic_id.' AND forum_id='.$fid) or error('Unable to close topic', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   508
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   509
		$redirect_msg = ($action) ? $lang_misc['Close topic redirect'] : $lang_misc['Open topic redirect'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   510
		redirect('viewtopic.php?id='.$topic_id, $redirect_msg);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   511
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   512
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   513
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   514
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   515
// Stick a topic
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   516
else if (isset($_GET['stick']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   517
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   518
	confirm_referrer('viewtopic.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   519
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   520
	$stick = intval($_GET['stick']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   521
	if ($stick < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   522
		message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   523
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   524
	$db->query('UPDATE '.$db->prefix.'topics SET sticky=\'1\' WHERE id='.$stick.' AND forum_id='.$fid) or error('Unable to stick topic', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   525
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   526
	redirect('viewtopic.php?id='.$stick, $lang_misc['Stick topic redirect']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   527
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   528
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   529
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   530
// Unstick a topic
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   531
else if (isset($_GET['unstick']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   532
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   533
	confirm_referrer('viewtopic.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   534
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   535
	$unstick = intval($_GET['unstick']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   536
	if ($unstick < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   537
		message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   538
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   539
	$db->query('UPDATE '.$db->prefix.'topics SET sticky=\'0\' WHERE id='.$unstick.' AND forum_id='.$fid) or error('Unable to unstick topic', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   540
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   541
	redirect('viewtopic.php?id='.$unstick, $lang_misc['Unstick topic redirect']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   542
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   543
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   544
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   545
// No specific forum moderation action was specified in the query string, so we'll display the moderator forum
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   546
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   547
// Load the viewforum.php language file
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   548
require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   549
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   550
// Fetch some info about the forum
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   551
$result = $db->query('SELECT f.forum_name, f.redirect_url, f.num_topics FROM '.$db->prefix.'forums AS f LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.id='.$fid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   552
if (!$db->num_rows($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   553
	message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   554
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   555
$cur_forum = $db->fetch_assoc($result);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   556
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   557
// Is this a redirect forum? In that case, abort!
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   558
if ($cur_forum['redirect_url'] != '')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   559
	message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   560
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   561
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.pun_htmlspecialchars($cur_forum['forum_name']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   562
require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   563
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   564
// Determine the topic offset (based on $_GET['p'])
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   565
$num_pages = ceil($cur_forum['num_topics'] / $pun_user['disp_topics']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   566
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   567
$p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   568
$start_from = $pun_user['disp_topics'] * ($p - 1);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   569
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   570
// Generate paging links
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   571
$paging_links = $lang_common['Pages'].': '.paginate($num_pages, $p, 'moderate.php?fid='.$fid)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   572
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   573
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   574
<div class="linkst">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   575
	<div class="inbox">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   576
		<p class="pagelink conl"><?php echo $paging_links ?></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   577
		<ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></li></ul>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   578
		<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   579
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   580
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   581
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   582
<form method="post" action="moderate.php?fid=<?php echo $fid ?>">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   583
<div id="vf" class="blocktable">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   584
	<h2><span><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   585
	<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   586
		<div class="inbox">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   587
			<table cellspacing="0">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   588
			<thead>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   589
				<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   590
					<th class="tcl" scope="col"><?php echo $lang_common['Topic'] ?></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   591
					<th class="tc2" scope="col"><?php echo $lang_common['Replies'] ?></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   592
					<th class="tc3" scope="col"><?php echo $lang_forum['Views'] ?></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   593
					<th class="tcr"><?php echo $lang_common['Last post'] ?></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   594
					<th class="tcmod" scope="col"><?php echo $lang_misc['Select'] ?></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   595
				</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   596
			</thead>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   597
			<tbody>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   598
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   599
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   600
// Select topics
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   601
$result = $db->query('SELECT id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to FROM '.$db->prefix.'topics WHERE forum_id='.$fid.' ORDER BY sticky DESC, last_post DESC LIMIT '.$start_from.', '.$pun_user['disp_topics']) or error('Unable to fetch topic list for forum', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   602
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   603
// If there are topics in this forum.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   604
if ($db->num_rows($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   605
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   606
	$button_status = '';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   607
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   608
	while ($cur_topic = $db->fetch_assoc($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   609
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   610
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   611
		$icon_text = $lang_common['Normal icon'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   612
		$item_status = '';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   613
		$icon_type = 'icon';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   614
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   615
		if ($cur_topic['moved_to'] == null)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   616
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   617
			$last_post = '<a href="viewtopic.php?pid='.$cur_topic['last_post_id'].'#p'.$cur_topic['last_post_id'].'">'.format_time($cur_topic['last_post']).'</a> '.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['last_poster']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   618
			$ghost_topic = false;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   619
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   620
		else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   621
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   622
			$last_post = '&nbsp;';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   623
			$ghost_topic = true;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   624
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   625
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   626
		if ($pun_config['o_censoring'] == '1')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   627
			$cur_topic['subject'] = censor_words($cur_topic['subject']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   628
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   629
		if ($cur_topic['moved_to'] != 0)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   630
			$subject = $lang_forum['Moved'].': <a href="viewtopic.php?id='.$cur_topic['moved_to'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   631
		else if ($cur_topic['closed'] == '0')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   632
			$subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span>'.$lang_common['by'].'&nbsp;'.pun_htmlspecialchars($cur_topic['poster']).'</span>';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   633
		else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   634
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   635
			$subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   636
			$icon_text = $lang_common['Closed icon'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   637
			$item_status = 'iclosed';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   638
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   639
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   640
		if ($cur_topic['last_post'] > $pun_user['last_visit'] && !$ghost_topic)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   641
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   642
			$icon_text .= ' '.$lang_common['New icon'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   643
			$item_status .= ' inew';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   644
			$icon_type = 'icon inew';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   645
			$subject = '<strong>'.$subject.'</strong>';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   646
			$subject_new_posts = '<span class="newtext">[&nbsp;<a href="viewtopic.php?id='.$cur_topic['id'].'&amp;action=new" title="'.$lang_common['New posts info'].'">'.$lang_common['New posts'].'</a>&nbsp;]</span>';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   647
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   648
		else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   649
			$subject_new_posts = null;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   650
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   651
		// We won't display "the dot", but we add the spaces anyway
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   652
		if ($pun_config['o_show_dot'] == '1')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   653
			$subject = '&nbsp;&nbsp;'.$subject;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   654
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   655
		if ($cur_topic['sticky'] == '1')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   656
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   657
			$subject = '<span class="stickytext">'.$lang_forum['Sticky'].': </span>'.$subject;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   658
			$item_status .= ' isticky';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   659
			$icon_text .= ' '.$lang_forum['Sticky'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   660
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   661
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   662
		$num_pages_topic = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   663
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   664
		if ($num_pages_topic > 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   665
			$subject_multipage = '[ '.paginate($num_pages_topic, -1, 'viewtopic.php?id='.$cur_topic['id']).' ]';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   666
		else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   667
			$subject_multipage = null;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   668
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   669
		// Should we show the "New posts" and/or the multipage links?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   670
		if (!empty($subject_new_posts) || !empty($subject_multipage))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   671
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   672
			$subject .= '&nbsp; '.(!empty($subject_new_posts) ? $subject_new_posts : '');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   673
			$subject .= !empty($subject_multipage) ? ' '.$subject_multipage : '';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   674
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   675
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   676
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   677
				<tr<?php if ($item_status != '') echo ' class="'.trim($item_status).'"'; ?>>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   678
					<td class="tcl">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   679
						<div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo trim($icon_text) ?></div></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   680
						<div class="tclcon">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   681
							<?php echo $subject."\n" ?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   682
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   683
					</td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   684
					<td class="tc2"><?php echo (!$ghost_topic) ? $cur_topic['num_replies'] : '&nbsp;' ?></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   685
					<td class="tc3"><?php echo (!$ghost_topic) ? $cur_topic['num_views'] : '&nbsp;' ?></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   686
					<td class="tcr"><?php echo $last_post ?></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   687
					<td class="tcmod"><input type="checkbox" name="topics[<?php echo $cur_topic['id'] ?>]" value="1" /></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   688
				</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   689
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   690
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   691
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   692
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   693
else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   694
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   695
	$button_status = ' disabled';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   696
	echo "\t\t\t\t\t".'<tr><td class="tcl" colspan="5">'.$lang_forum['Empty forum'].'</td></tr>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   697
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   698
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   699
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   700
			</tbody>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   701
			</table>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   702
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   703
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   704
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   705
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   706
<div class="linksb">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   707
	<div class="inbox">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   708
		<p class="pagelink conl"><?php echo $paging_links ?></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   709
		<p class="conr"><input type="submit" name="move_topics" value="<?php echo $lang_misc['Move'] ?>"<?php echo $button_status ?> />&nbsp;&nbsp;<input type="submit" name="delete_topics" value="<?php echo $lang_misc['Delete'] ?>"<?php echo $button_status ?> />&nbsp;&nbsp;<input type="submit" name="open" value="<?php echo $lang_misc['Open'] ?>"<?php echo $button_status ?> />&nbsp;&nbsp;<input type="submit" name="close" value="<?php echo $lang_misc['Close'] ?>"<?php echo $button_status ?> /></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   710
		<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   711
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   712
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   713
</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   714
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   715
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   716
require PUN_ROOT.'footer.php';