punbb/admin_censoring.php
author Dan
Thu, 12 Jul 2007 01:04:01 -0400
changeset 2 a8a21e1c7afa
parent 0 f9ffdbd96607
child 3 c0c445d4a13e
permissions -rw-r--r--
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
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
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    29
//define('PUN_ROOT', './');
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    30
//require PUN_ROOT.'include/common.php';
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    31
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    32
global $pun_db, $pun_user, $pun_config, $lang_common;
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    33
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    34
require PUN_ROOT.'include/common_admin.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    35
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    36
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    37
if ($pun_user['g_id'] < PUN_MOD)
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    38
	message($lang_common['No permission']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    39
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    40
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    41
// Add a censor word
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    42
if (isset($_POST['add_word']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    43
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    44
	confirm_referrer('admin_censoring.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    45
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    46
	$search_for = trim($_POST['new_search_for']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    47
	$replace_with = trim($_POST['new_replace_with']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    48
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    49
	if ($search_for == '' || $replace_with == '')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    50
		message('You must enter both a word to censor and text to replace it with.');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    51
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    52
	$pun_db->query('INSERT INTO '.$pun_db->prefix.'censoring (search_for, replace_with) VALUES (\''.$pun_db->escape($search_for).'\', \''.$pun_db->escape($replace_with).'\')') or error('Unable to add censor word', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    53
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    54
	pun_redirect('admin_censoring.php', 'Censor word added. Redirecting &hellip;');
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    55
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    56
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    57
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    58
// Update a censor word
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    59
else if (isset($_POST['update']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    60
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    61
	confirm_referrer('admin_censoring.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    62
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    63
	$id = intval(key($_POST['update']));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    64
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    65
	$search_for = trim($_POST['search_for'][$id]);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    66
	$replace_with = trim($_POST['replace_with'][$id]);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    67
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    68
	if ($search_for == '' || $replace_with == '')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    69
		message('You must enter both text to search for and text to replace with.');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    70
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    71
	$pun_db->query('UPDATE '.$pun_db->prefix.'censoring SET search_for=\''.$pun_db->escape($search_for).'\', replace_with=\''.$pun_db->escape($replace_with).'\' WHERE id='.$id) or error('Unable to update censor word', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    72
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    73
	pun_redirect('admin_censoring.php', 'Censor word updated. Redirecting &hellip;');
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    74
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    75
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    76
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    77
// Remove a censor word
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    78
else if (isset($_POST['remove']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    79
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    80
	confirm_referrer('admin_censoring.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    81
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    82
	$id = intval(key($_POST['remove']));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    83
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    84
	$pun_db->query('DELETE FROM '.$pun_db->prefix.'censoring WHERE id='.$id) or error('Unable to delete censor word', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    85
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    86
	pun_redirect('admin_censoring.php', 'Censor word removed. Redirecting &hellip;');
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    87
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    88
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    89
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    90
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Censoring';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    91
$focus_element = array('censoring', 'new_search_for');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    92
require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    93
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    94
generate_admin_menu('censoring');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    95
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    96
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    97
	<div class="blockform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    98
		<h2><span>Censoring</span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    99
		<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   100
			<form id="censoring" method="post" action="admin_censoring.php?action=foo">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   101
				<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   102
					<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   103
						<legend>Add word</legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   104
						<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   105
							<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
   106
							<table  cellspacing="0">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   107
							<thead>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   108
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   109
									<th class="tcl" scope="col">Censored&nbsp;word</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   110
									<th class="tc2" scope="col">Replacement&nbsp;text</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   111
									<th class="hidehead" scope="col">Action</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   112
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   113
							</thead>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   114
							<tbody>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   115
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   116
									<td><input type="text" name="new_search_for" size="24" maxlength="60" tabindex="1" /></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   117
									<td><input type="text" name="new_replace_with" size="24" maxlength="60" tabindex="2" /></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   118
									<td><input type="submit" name="add_word" value=" Add " tabindex="3" /></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   119
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   120
							</tbody>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   121
							</table>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   122
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   123
					</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   124
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   125
				<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   126
					<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   127
						<legend>Edit/remove words</legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   128
						<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   129
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   130
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   131
$result = $pun_db->query('SELECT id, search_for, replace_with FROM '.$pun_db->prefix.'censoring ORDER BY id') or error('Unable to fetch censor word list', __FILE__, __LINE__, $pun_db->error());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   132
if ($pun_db->num_rows($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   133
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   134
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   135
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   136
							<table cellspacing="0" >
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   137
							<thead>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   138
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   139
									<th class="tcl" scope="col">Censored&nbsp;word</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   140
									<th class="tc2" scope="col">Replacement&nbsp;text</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   141
									<th class="hidehead" scope="col">Actions</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   142
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   143
							</thead>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   144
							<tbody>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   145
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   146
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   147
	while ($cur_word = $pun_db->fetch_assoc($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   148
		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
   149
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   150
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   151
							</tbody>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   152
							</table>
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
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   156
else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   157
	echo "\t\t\t\t\t\t\t".'<p>No censor words in list.</p>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   158
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   159
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   160
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   161
					</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   162
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   163
			</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   164
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   165
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   166
	<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   167
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   168
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   169
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   170
require PUN_ROOT.'footer.php';