source: branches/rsr.v5.1.dev/web/punbb/admin_censoring.php @ 3

Last change on this file since 3 was 3, checked in by dj3c1t, 12 years ago

passage a Fluxbb 1.4.7

File size: 6.1 KB
Line 
1<?php
2
3/**
4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */
8
9// Tell header.php to use the admin template
10define('PUN_ADMIN_CONSOLE', 1);
11
12define('PUN_ROOT', dirname(__FILE__).'/');
13require PUN_ROOT.'include/common.php';
14require PUN_ROOT.'include/common_admin.php';
15
16
17if ($pun_user['g_id'] != PUN_ADMIN)
18        message($lang_common['No permission']);
19
20// Load the admin_censoring.php language file
21require PUN_ROOT.'lang/'.$admin_language.'/admin_censoring.php';
22
23// Add a censor word
24if (isset($_POST['add_word']))
25{
26        confirm_referrer('admin_censoring.php');
27
28        $search_for = pun_trim($_POST['new_search_for']);
29        $replace_with = pun_trim($_POST['new_replace_with']);
30
31        if ($search_for == '')
32                message($lang_admin_censoring['Must enter word message']);
33
34        $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());
35
36        // Regenerate the censoring cache
37        if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
38                require PUN_ROOT.'include/cache.php';
39
40        generate_censoring_cache();
41
42        redirect('admin_censoring.php', $lang_admin_censoring['Word added redirect']);
43}
44
45// Update a censor word
46else if (isset($_POST['update']))
47{
48        confirm_referrer('admin_censoring.php');
49
50        $id = intval(key($_POST['update']));
51
52        $search_for = pun_trim($_POST['search_for'][$id]);
53        $replace_with = pun_trim($_POST['replace_with'][$id]);
54
55        if ($search_for == '')
56                message($lang_admin_censoring['Must enter word message']);
57
58        $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());
59
60        // Regenerate the censoring cache
61        if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
62                require PUN_ROOT.'include/cache.php';
63
64        generate_censoring_cache();
65
66        redirect('admin_censoring.php', $lang_admin_censoring['Word updated redirect']);
67}
68
69// Remove a censor word
70else if (isset($_POST['remove']))
71{
72        confirm_referrer('admin_censoring.php');
73
74        $id = intval(key($_POST['remove']));
75
76        $db->query('DELETE FROM '.$db->prefix.'censoring WHERE id='.$id) or error('Unable to delete censor word', __FILE__, __LINE__, $db->error());
77
78        // Regenerate the censoring cache
79        if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
80                require PUN_ROOT.'include/cache.php';
81
82        generate_censoring_cache();
83
84        redirect('admin_censoring.php',  $lang_admin_censoring['Word removed redirect']);
85}
86
87$page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Censoring']);
88$focus_element = array('censoring', 'new_search_for');
89define('PUN_ACTIVE_PAGE', 'admin');
90require PUN_ROOT.'header.php';
91
92generate_admin_menu('censoring');
93
94?>
95        <div class="blockform">
96                <h2><span><?php echo $lang_admin_censoring['Censoring head'] ?></span></h2>
97                <div class="box">
98                        <form id="censoring" method="post" action="admin_censoring.php">
99                                <div class="inform">
100                                        <fieldset>
101                                                <legend><?php echo $lang_admin_censoring['Add word subhead'] ?></legend>
102                                                <div class="infldset">
103                                                        <p><?php echo $lang_admin_censoring['Add word info'].' '.($pun_config['o_censoring'] == '1' ? sprintf($lang_admin_censoring['Censoring enabled'], '<a href="admin_options.php#censoring">'.$lang_admin_common['Options'].'</a>') : sprintf($lang_admin_censoring['Censoring disabled'], '<a href="admin_options.php#censoring">'.$lang_admin_common['Options'].'</a>')) ?></p>
104                                                        <table cellspacing="0">
105                                                        <thead>
106                                                                <tr>
107                                                                        <th class="tcl" scope="col"><?php echo $lang_admin_censoring['Censored word label'] ?></th>
108                                                                        <th class="tc2" scope="col"><?php echo $lang_admin_censoring['Replacement label'] ?></th>
109                                                                        <th class="hidehead" scope="col"><?php echo $lang_admin_censoring['Action label'] ?></th>
110                                                                </tr>
111                                                        </thead>
112                                                        <tbody>
113                                                                <tr>
114                                                                        <td class="tcl"><input type="text" name="new_search_for" size="24" maxlength="60" tabindex="1" /></td>
115                                                                        <td class="tc2"><input type="text" name="new_replace_with" size="24" maxlength="60" tabindex="2" /></td>
116                                                                        <td><input type="submit" name="add_word" value="<?php echo $lang_admin_common['Add'] ?>" tabindex="3" /></td>
117                                                                </tr>
118                                                        </tbody>
119                                                        </table>
120                                                </div>
121                                        </fieldset>
122                                </div>
123                                <div class="inform">
124                                        <fieldset>
125                                                <legend><?php echo $lang_admin_censoring['Edit remove subhead'] ?></legend>
126                                                <div class="infldset">
127<?php
128
129$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());
130if ($db->num_rows($result))
131{
132
133?>
134                                                        <table cellspacing="0" >
135                                                        <thead>
136                                                                <tr>
137                                                                        <th class="tcl" scope="col"><?php echo $lang_admin_censoring['Censored word label'] ?></th>
138                                                                        <th class="tc2" scope="col"><?php echo $lang_admin_censoring['Replacement label'] ?></th>
139                                                                        <th class="hidehead" scope="col"><?php echo $lang_admin_censoring['Action label'] ?></th>
140                                                                </tr>
141                                                        </thead>
142                                                        <tbody>
143<?php
144
145        while ($cur_word = $db->fetch_assoc($result))
146                echo "\t\t\t\t\t\t\t\t".'<tr><td class="tcl"><input type="text" name="search_for['.$cur_word['id'].']" value="'.pun_htmlspecialchars($cur_word['search_for']).'" size="24" maxlength="60" /></td><td class="tc2"><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="'.$lang_admin_common['Update'].'" />&#160;<input type="submit" name="remove['.$cur_word['id'].']" value="'.$lang_admin_common['Remove'].'" /></td></tr>'."\n";
147
148?>
149                                                        </tbody>
150                                                        </table>
151<?php
152
153}
154else
155        echo "\t\t\t\t\t\t\t".'<p>'.$lang_admin_censoring['No words in list'].'</p>'."\n";
156
157?>
158                                                </div>
159                                        </fieldset>
160                                </div>
161                        </form>
162                </div>
163        </div>
164        <div class="clearer"></div>
165</div>
166<?php
167
168require PUN_ROOT.'footer.php';
Note: See TracBrowser for help on using the repository browser.