2 /***********************************************************************
4 Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org)
6 This file is part of PunBB.
8 PunBB is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published
10 by the Free Software Foundation; either version 2 of the License,
11 or (at your option) any later version.
13 PunBB is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 ************************************************************************/
26 // Tell header.php to use the admin template
27 define('PUN_ADMIN_CONSOLE', 1);
29 define('PUN_ROOT', './');
30 require PUN_ROOT
.'include/common.php';
31 require PUN_ROOT
.'include/common_admin.php';
34 if ($pun_user['g_id'] > PUN_MOD
)
35 message($lang_common['No permission']);
39 if (isset($_POST['add_word']))
41 confirm_referrer('admin_censoring.php');
43 $search_for = trim($_POST['new_search_for']);
44 $replace_with = trim($_POST['new_replace_with']);
46 if ($search_for == '' ||
$replace_with == '')
47 message('You must enter both a word to censor and text to replace it with.');
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());
51 redirect('admin_censoring.php', 'Censor word added. Redirecting …');
55 // Update a censor word
56 else if (isset($_POST['update']))
58 confirm_referrer('admin_censoring.php');
60 $id = intval(key($_POST['update']));
62 $search_for = trim($_POST['search_for'][$id]);
63 $replace_with = trim($_POST['replace_with'][$id]);
65 if ($search_for == '' ||
$replace_with == '')
66 message('You must enter both text to search for and text to replace with.');
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());
70 redirect('admin_censoring.php', 'Censor word updated. Redirecting …');
74 // Remove a censor word
75 else if (isset($_POST['remove']))
77 confirm_referrer('admin_censoring.php');
79 $id = intval(key($_POST['remove']));
81 $db->query('DELETE FROM '.$db->prefix
.'censoring WHERE id='.$id) or error('Unable to delete censor word', __FILE__
, __LINE__
, $db->error());
83 redirect('admin_censoring.php', 'Censor word removed. Redirecting …');
87 $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Censoring';
88 $focus_element = array('censoring', 'new_search_for');
89 require PUN_ROOT
.'header.php';
91 generate_admin_menu('censoring');
94 <div
class="blockform">
95 <h2
><span
>Censoring
</span
></h2
>
97 <form id
="censoring" method
="post" action
="admin_censoring.php?action=foo">
100 <legend
>Add word
</legend
>
101 <div
class="infldset">
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
>
103 <table cellspacing
="0">
106 <th
class="tcl" scope
="col">Censored
 
;word
</th
>
107 <th
class="tc2" scope
="col">Replacement
 
;text
</th
>
108 <th
class="hidehead" scope
="col">Action
</th
>
113 <td
><input type
="text" name
="new_search_for" size
="24" maxlength
="60" tabindex
="1" /></td
>
114 <td
><input type
="text" name
="new_replace_with" size
="24" maxlength
="60" tabindex
="2" /></td
>
115 <td
><input type
="submit" name
="add_word" value
=" Add " tabindex
="3" /></td
>
124 <legend
>Edit
/remove words
</legend
>
125 <div
class="infldset">
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());
129 if ($db->num_rows($result))
133 <table cellspacing
="0" >
136 <th
class="tcl" scope
="col">Censored
 
;word
</th
>
137 <th
class="tc2" scope
="col">Replacement
 
;text
</th
>
138 <th
class="hidehead" scope
="col">Actions
</th
>
144 while ($cur_word = $db->fetch_assoc($result))
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" /> <input type="submit" name="remove['.$cur_word['id'].']" value="Remove" /></td></tr>'."\n";
154 echo "\t\t\t\t\t\t\t".'<p>No censor words in list.</p>'."\n";
163 <div
class="clearer"></div
>
167 require PUN_ROOT
.'footer.php';