[1] | 1 | <?php |
---|
| 2 | |
---|
[3] | 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 | */ |
---|
[1] | 8 | |
---|
| 9 | // Tell header.php to use the admin template |
---|
| 10 | define('PUN_ADMIN_CONSOLE', 1); |
---|
| 11 | |
---|
[3] | 12 | define('PUN_ROOT', dirname(__FILE__).'/'); |
---|
[1] | 13 | require PUN_ROOT.'include/common.php'; |
---|
| 14 | require PUN_ROOT.'include/common_admin.php'; |
---|
| 15 | |
---|
| 16 | |
---|
[3] | 17 | if ($pun_user['g_id'] != PUN_ADMIN) |
---|
[1] | 18 | message($lang_common['No permission']); |
---|
| 19 | |
---|
[3] | 20 | // Load the admin_censoring.php language file |
---|
| 21 | require PUN_ROOT.'lang/'.$admin_language.'/admin_censoring.php'; |
---|
[1] | 22 | |
---|
| 23 | // Add a censor word |
---|
| 24 | if (isset($_POST['add_word'])) |
---|
| 25 | { |
---|
| 26 | confirm_referrer('admin_censoring.php'); |
---|
| 27 | |
---|
[3] | 28 | $search_for = pun_trim($_POST['new_search_for']); |
---|
| 29 | $replace_with = pun_trim($_POST['new_replace_with']); |
---|
[1] | 30 | |
---|
[3] | 31 | if ($search_for == '') |
---|
| 32 | message($lang_admin_censoring['Must enter word message']); |
---|
[1] | 33 | |
---|
[3] | 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()); |
---|
[1] | 35 | |
---|
[3] | 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']); |
---|
[1] | 43 | } |
---|
| 44 | |
---|
| 45 | // Update a censor word |
---|
| 46 | else if (isset($_POST['update'])) |
---|
| 47 | { |
---|
| 48 | confirm_referrer('admin_censoring.php'); |
---|
| 49 | |
---|
| 50 | $id = intval(key($_POST['update'])); |
---|
| 51 | |
---|
[3] | 52 | $search_for = pun_trim($_POST['search_for'][$id]); |
---|
| 53 | $replace_with = pun_trim($_POST['replace_with'][$id]); |
---|
[1] | 54 | |
---|
[3] | 55 | if ($search_for == '') |
---|
| 56 | message($lang_admin_censoring['Must enter word message']); |
---|
[1] | 57 | |
---|
[3] | 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()); |
---|
[1] | 59 | |
---|
[3] | 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']); |
---|
[1] | 67 | } |
---|
| 68 | |
---|
| 69 | // Remove a censor word |
---|
| 70 | else if (isset($_POST['remove'])) |
---|
| 71 | { |
---|
| 72 | confirm_referrer('admin_censoring.php'); |
---|
| 73 | |
---|
| 74 | $id = intval(key($_POST['remove'])); |
---|
| 75 | |
---|
[3] | 76 | $db->query('DELETE FROM '.$db->prefix.'censoring WHERE id='.$id) or error('Unable to delete censor word', __FILE__, __LINE__, $db->error()); |
---|
[1] | 77 | |
---|
[3] | 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']); |
---|
[1] | 85 | } |
---|
| 86 | |
---|
[3] | 87 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Censoring']); |
---|
[1] | 88 | $focus_element = array('censoring', 'new_search_for'); |
---|
[3] | 89 | define('PUN_ACTIVE_PAGE', 'admin'); |
---|
[1] | 90 | require PUN_ROOT.'header.php'; |
---|
| 91 | |
---|
| 92 | generate_admin_menu('censoring'); |
---|
| 93 | |
---|
| 94 | ?> |
---|
| 95 | <div class="blockform"> |
---|
[3] | 96 | <h2><span><?php echo $lang_admin_censoring['Censoring head'] ?></span></h2> |
---|
[1] | 97 | <div class="box"> |
---|
[3] | 98 | <form id="censoring" method="post" action="admin_censoring.php"> |
---|
[1] | 99 | <div class="inform"> |
---|
| 100 | <fieldset> |
---|
[3] | 101 | <legend><?php echo $lang_admin_censoring['Add word subhead'] ?></legend> |
---|
[1] | 102 | <div class="infldset"> |
---|
[3] | 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"> |
---|
[1] | 105 | <thead> |
---|
| 106 | <tr> |
---|
[3] | 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> |
---|
[1] | 110 | </tr> |
---|
| 111 | </thead> |
---|
| 112 | <tbody> |
---|
| 113 | <tr> |
---|
[3] | 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> |
---|
[1] | 117 | </tr> |
---|
| 118 | </tbody> |
---|
| 119 | </table> |
---|
| 120 | </div> |
---|
| 121 | </fieldset> |
---|
| 122 | </div> |
---|
| 123 | <div class="inform"> |
---|
| 124 | <fieldset> |
---|
[3] | 125 | <legend><?php echo $lang_admin_censoring['Edit remove subhead'] ?></legend> |
---|
[1] | 126 | <div class="infldset"> |
---|
| 127 | <?php |
---|
| 128 | |
---|
[3] | 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()); |
---|
[1] | 130 | if ($db->num_rows($result)) |
---|
| 131 | { |
---|
| 132 | |
---|
| 133 | ?> |
---|
| 134 | <table cellspacing="0" > |
---|
| 135 | <thead> |
---|
| 136 | <tr> |
---|
[3] | 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> |
---|
[1] | 140 | </tr> |
---|
| 141 | </thead> |
---|
| 142 | <tbody> |
---|
| 143 | <?php |
---|
| 144 | |
---|
| 145 | while ($cur_word = $db->fetch_assoc($result)) |
---|
[3] | 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'].'" /> <input type="submit" name="remove['.$cur_word['id'].']" value="'.$lang_admin_common['Remove'].'" /></td></tr>'."\n"; |
---|
[1] | 147 | |
---|
| 148 | ?> |
---|
| 149 | </tbody> |
---|
| 150 | </table> |
---|
| 151 | <?php |
---|
| 152 | |
---|
| 153 | } |
---|
| 154 | else |
---|
[3] | 155 | echo "\t\t\t\t\t\t\t".'<p>'.$lang_admin_censoring['No words in list'].'</p>'."\n"; |
---|
[1] | 156 | |
---|
| 157 | ?> |
---|
| 158 | </div> |
---|
| 159 | </fieldset> |
---|
| 160 | </div> |
---|
| 161 | </form> |
---|
| 162 | </div> |
---|
| 163 | </div> |
---|
| 164 | <div class="clearer"></div> |
---|
| 165 | </div> |
---|
| 166 | <?php |
---|
| 167 | |
---|
| 168 | require PUN_ROOT.'footer.php'; |
---|