adopted md5sum
[archlinuxdevstack.git] / fluxbb / admin_censoring.php
blobcbfad3890995f7c67dcc688d2172b5d1060ff5b9
1 <?php
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,
21 MA 02111-1307 USA
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']);
38 // Add a censor word
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 &hellip;');
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 &hellip;');
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 &hellip;');
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>
96 <div class="box">
97 <form id="censoring" method="post" action="admin_censoring.php?action=foo">
98 <div class="inform">
99 <fieldset>
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">
104 <thead>
105 <tr>
106 <th class="tcl" scope="col">Censored&nbsp;word</th>
107 <th class="tc2" scope="col">Replacement&nbsp;text</th>
108 <th class="hidehead" scope="col">Action</th>
109 </tr>
110 </thead>
111 <tbody>
112 <tr>
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>
116 </tr>
117 </tbody>
118 </table>
119 </div>
120 </fieldset>
121 </div>
122 <div class="inform">
123 <fieldset>
124 <legend>Edit/remove words</legend>
125 <div class="infldset">
126 <?php
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" >
134 <thead>
135 <tr>
136 <th class="tcl" scope="col">Censored&nbsp;word</th>
137 <th class="tc2" scope="col">Replacement&nbsp;text</th>
138 <th class="hidehead" scope="col">Actions</th>
139 </tr>
140 </thead>
141 <tbody>
142 <?php
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" />&nbsp;<input type="submit" name="remove['.$cur_word['id'].']" value="Remove" /></td></tr>'."\n";
148 </tbody>
149 </table>
150 <?php
153 else
154 echo "\t\t\t\t\t\t\t".'<p>No censor words in list.</p>'."\n";
157 </div>
158 </fieldset>
159 </div>
160 </form>
161 </div>
162 </div>
163 <div class="clearer"></div>
164 </div>
165 <?php
167 require PUN_ROOT.'footer.php';