punbb/admin_censoring.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
// Tell header.php to use the admin template
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    27
define('PUN_ADMIN_CONSOLE', 1);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    28
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    29
define('PUN_ROOT', './');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    30
require PUN_ROOT.'include/common.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    31
require PUN_ROOT.'include/common_admin.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    32
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
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    38
// Add a censor word
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    39
if (isset($_POST['add_word']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    40
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    41
	confirm_referrer('admin_censoring.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    42
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    43
	$search_for = trim($_POST['new_search_for']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    44
	$replace_with = trim($_POST['new_replace_with']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    45
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    46
	if ($search_for == '' || $replace_with == '')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    47
		message('You must enter both a word to censor and text to replace it with.');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    48
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    49
	$db->query('INSERT INTO '.$db->prefix.'censoring (search_for, replace_with) VALUES (\''.$db->escape($search_for).'\', \''.$db->escape($replace_with).'\')') or error('Unable to add censor word', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    50
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    51
	redirect('admin_censoring.php', 'Censor word added. Redirecting &hellip;');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    52
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    53
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    54
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    55
// Update a censor word
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    56
else if (isset($_POST['update']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    57
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    58
	confirm_referrer('admin_censoring.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    59
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    60
	$id = intval(key($_POST['update']));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    61
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    62
	$search_for = trim($_POST['search_for'][$id]);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    63
	$replace_with = trim($_POST['replace_with'][$id]);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    64
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    65
	if ($search_for == '' || $replace_with == '')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    66
		message('You must enter both text to search for and text to replace with.');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    67
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    68
	$db->query('UPDATE '.$db->prefix.'censoring SET search_for=\''.$db->escape($search_for).'\', replace_with=\''.$db->escape($replace_with).'\' WHERE id='.$id) or error('Unable to update censor word', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    69
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    70
	redirect('admin_censoring.php', 'Censor word updated. Redirecting &hellip;');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    71
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    72
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    73
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    74
// Remove a censor word
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    75
else if (isset($_POST['remove']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    76
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    77
	confirm_referrer('admin_censoring.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    78
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    79
	$id = intval(key($_POST['remove']));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    80
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    81
	$db->query('DELETE FROM '.$db->prefix.'censoring WHERE id='.$id) or error('Unable to delete censor word', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    82
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    83
	redirect('admin_censoring.php', 'Censor word removed. Redirecting &hellip;');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    84
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    85
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    86
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    87
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Censoring';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    88
$focus_element = array('censoring', 'new_search_for');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    89
require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    90
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    91
generate_admin_menu('censoring');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    92
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    93
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    94
	<div class="blockform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    95
		<h2><span>Censoring</span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    96
		<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    97
			<form id="censoring" method="post" action="admin_censoring.php?action=foo">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    98
				<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    99
					<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   100
						<legend>Add word</legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   101
						<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   102
							<p>Enter a word that you want to censor and the replacement text for this word. Wildcards are accepted (i.e. *some* would match somewhere and lonesome). Censor words also affect usernames. New users will not be able to register with usernames containing any censored words. The search is case insensitive. <strong>Censor words must be enabled in <a href="admin_options.php#censoring">Options</a> for this to have any effect.</strong></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   103
							<table  cellspacing="0">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   104
							<thead>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   105
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   106
									<th class="tcl" scope="col">Censored&nbsp;word</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   107
									<th class="tc2" scope="col">Replacement&nbsp;text</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   108
									<th class="hidehead" scope="col">Action</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   109
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   110
							</thead>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   111
							<tbody>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   112
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   113
									<td><input type="text" name="new_search_for" size="24" maxlength="60" tabindex="1" /></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   114
									<td><input type="text" name="new_replace_with" size="24" maxlength="60" tabindex="2" /></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   115
									<td><input type="submit" name="add_word" value=" Add " tabindex="3" /></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   116
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   117
							</tbody>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   118
							</table>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   119
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   120
					</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   121
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   122
				<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   123
					<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   124
						<legend>Edit/remove words</legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   125
						<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   126
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   127
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   128
$result = $db->query('SELECT id, search_for, replace_with FROM '.$db->prefix.'censoring ORDER BY id') or error('Unable to fetch censor word list', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   129
if ($db->num_rows($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   130
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   131
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   132
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   133
							<table cellspacing="0" >
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   134
							<thead>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   135
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   136
									<th class="tcl" scope="col">Censored&nbsp;word</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   137
									<th class="tc2" scope="col">Replacement&nbsp;text</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   138
									<th class="hidehead" scope="col">Actions</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   139
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   140
							</thead>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   141
							<tbody>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   142
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   143
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   144
	while ($cur_word = $db->fetch_assoc($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   145
		echo "\t\t\t\t\t\t\t\t".'<tr><td><input type="text" name="search_for['.$cur_word['id'].']" value="'.pun_htmlspecialchars($cur_word['search_for']).'" size="24" maxlength="60" /></td><td><input type="text" name="replace_with['.$cur_word['id'].']" value="'.pun_htmlspecialchars($cur_word['replace_with']).'" size="24" maxlength="60" /></td><td><input type="submit" name="update['.$cur_word['id'].']" value="Update" />&nbsp;<input type="submit" name="remove['.$cur_word['id'].']" value="Remove" /></td></tr>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   146
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   147
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   148
							</tbody>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   149
							</table>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   150
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   151
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   152
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   153
else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   154
	echo "\t\t\t\t\t\t\t".'<p>No censor words in list.</p>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   155
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   156
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   157
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   158
					</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   159
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   160
			</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   161
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   162
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   163
	<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   164
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   165
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   166
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   167
require PUN_ROOT.'footer.php';