| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
<span class="code-comment"> * admin_words.php |
|---|
| 4 |
* ------------------- |
|---|
| 5 |
* begin : Thursday, Jul 12, 2001 |
|---|
| 6 |
* copyright : (C) 2001 The phpBB Group |
|---|
| 7 |
* email : support@phpbb.com |
|---|
| 8 |
* |
|---|
| 9 |
* $Id: admin_words.php,v 1.10.2.3 2004/03/25 15:57:20 acydburn Exp $ |
|---|
| 10 |
* |
|---|
| 11 |
* |
|---|
| 12 |
***************************************************************************/ |
|---|
| 13 |
|
|---|
| 14 |
/*************************************************************************** |
|---|
| 15 |
* |
|---|
| 16 |
* This program is free software; you can redistribute it and/or modify |
|---|
| 17 |
* it under the terms of the GNU General Public License as published by |
|---|
| 18 |
* the Free Software Foundation; either version 2 of the License, or |
|---|
| 19 |
* (at your option) any later version. |
|---|
| 20 |
* |
|---|
| 21 |
***************************************************************************/ |
|---|
| 22 |
|
|---|
| 23 |
if( !empty($setmodules) )</span> |
|---|
| 24 |
<span class="code-keyword">{ |
|---|
| 25 |
$file = basename(__FILE__); |
|---|
| 26 |
$module['general']['word_censor'] = $file; |
|---|
| 27 |
return; |
|---|
| 28 |
} |
|---|
| 29 |
|
|---|
| 30 |
define('IN_PHPBB', 1); |
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
<span class="code-comment">// Load default header |
|---|
| 34 |
// |
|---|
| 35 |
$root_path = './../';</span> |
|---|
| 36 |
<span class="code-lang">require($root_path . 'extension.inc'); |
|---|
| 37 |
require('./pagestart.' . $phpEx); |
|---|
| 38 |
$cancel = ( isset($_POST['cancel']) ) ? true : false; |
|---|
| 39 |
$no_page_header = $cancel;</span> |
|---|
| 40 |
<span class="code-lang">if ($cancel) |
|---|
| 41 |
{ |
|---|
| 42 |
redirect('admin/' . append_sid("admin_words.$phpEx")); |
|---|
| 43 |
} |
|---|
| 44 |
|
|---|
| 45 |
if( isset($_GET['mode']) || isset($_POST['mode']) ) |
|---|
| 46 |
{ |
|---|
| 47 |
$mode = (isset($_GET['mode'])) ? $_GET['mode'] : $_POST['mode']; |
|---|
| 48 |
$mode = htmlspecialchars($mode); |
|---|
| 49 |
} |
|---|
| 50 |
else |
|---|
| 51 |
{ |
|---|
| 52 |
|
|---|
| 53 |
// These could be entered via a form button |
|---|
| 54 |
// |
|---|
| 55 |
if( isset($_POST['add']) ) |
|---|
| 56 |
{ |
|---|
| 57 |
$mode = "add"; |
|---|
| 58 |
} |
|---|
| 59 |
else if( isset($_POST['save']) ) |
|---|
| 60 |
{ |
|---|
| 61 |
$mode = "save"; |
|---|
| 62 |
} |
|---|
| 63 |
else |
|---|
| 64 |
{ |
|---|
| 65 |
$mode = ""; |
|---|
| 66 |
} |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
$mode = ( in_array($mode, array('add', 'edit', 'save', 'delete')) ) ? $mode : '';</span> |
|---|
| 71 |
<span class="code-lang"> |
|---|
| 72 |
if( $mode != "" ) |
|---|
| 73 |
{ |
|---|
| 74 |
if( $mode == "edit" || $mode == "add" ) |
|---|
| 75 |
{ |
|---|
| 76 |
$word_id = ( isset($_GET['id']) ) ? intval($_GET['id']) : 0; |
|---|
| 77 |
|
|---|
| 78 |
$template->set_filenames(array( |
|---|
| 79 |
"body" => "../admin/words_edit_body.tpl") |
|---|
| 80 |
); |
|---|
| 81 |
$word_info = array('word' => '', 'replacement' => ''); |
|---|
| 82 |
|
|---|
| 83 |
$s_hidden_fields = ''; |
|---|
| 84 |
|
|---|
| 85 |
if( $mode == "edit" ) |
|---|
| 86 |
{ |
|---|
| 87 |
if( $word_id ) |
|---|
| 88 |
{ |
|---|
| 89 |
$sql = "SELECT * |
|---|
| 90 |
FROM " . WORDS_TABLE . " |
|---|
| 91 |
WHERE word_id = $word_id"; |
|---|
| 92 |
$result = $db->sql_query($sql); |
|---|
| 93 |
|
|---|
| 94 |
$word_info = $db->sql_fetchrow($result); |
|---|
| 95 |
$s_hidden_fields .= '<input type="hidden" name="id" value="' . $word_id . '" />'; |
|---|
| 96 |
} |
|---|
| 97 |
else |
|---|
| 98 |
{ |
|---|
| 99 |
trigger_error($lang['no_word_selected']); |
|---|
| 100 |
return; |
|---|
| 101 |
} |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|
| 104 |
$template->assign_vars(array( |
|---|
| 105 |
"WORD" => $word_info['word'], |
|---|
| 106 |
"REPLACEMENT" => htmlspecialchars($word_info['replacement']), |
|---|
| 107 |
|
|---|
| 108 |
"L_WORDS_TEXT" => $lang['words_explain'], |
|---|
| 109 |
"L_WORD_CENSOR" => $lang['edit_word_censor'], |
|---|
| 110 |
|
|---|
| 111 |
"S_WORDS_ACTION" => append_sid("admin_words.$phpEx"), |
|---|
| 112 |
"S_HIDDEN_FIELDS" => $s_hidden_fields) |
|---|
| 113 |
); |
|---|
| 114 |
|
|---|
| 115 |
$template->display("body"); |
|---|
| 116 |
|
|---|
| 117 |
include('./page_footer_admin.'.$phpEx); |
|---|
| 118 |
} |
|---|
| 119 |
else if( $mode == "save" ) |
|---|
| 120 |
{ |
|---|
| 121 |
$word_id = ( isset($_POST['id']) ) ? intval($_POST['id']) : 0; |
|---|
| 122 |
$word = ( isset($_POST['word']) ) ? trim($_POST['word']) : ""; |
|---|
| 123 |
$replacement = ( isset($_POST['replacement']) ) ? trim($_POST['replacement']) : ""; |
|---|
| 124 |
|
|---|
| 125 |
if($word == "" || $replacement == "") |
|---|
| 126 |
{ |
|---|
| 127 |
trigger_error($lang['must_enter_word']); |
|---|
| 128 |
return; |
|---|
| 129 |
} |
|---|
| 130 |
$sql_ary = array( |
|---|
| 131 |
'word' => $word, |
|---|
| 132 |
'replacement' => $replacement |
|---|
| 133 |
); |
|---|
| 134 |
if ($word_id) { |
|---|
| 135 |
$db->sql_query('UPDATE ' . WORDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE word_id = ' . $word_id); |
|---|
| 136 |
$message = $lang['word_updated']; |
|---|
| 137 |
} |
|---|
| 138 |
else { |
|---|
| 139 |
$db->sql_query('INSERT INTO ' . WORDS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); |
|---|
| 140 |
$message = $lang['word_added']; |
|---|
| 141 |
} |
|---|
| 142 |
|
|---|
| 143 |
$cache->destroy('_word_censors'); |
|---|
| 144 |
|
|---|
| 145 |
$message .= "<br /><br />" . sprintf($lang['click_return_wordadmin'], "<a href=\"" . append_sid("admin_words.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); |
|---|
| 146 |
|
|---|
| 147 |
trigger_error($message); |
|---|
| 148 |
return; |
|---|
| 149 |
} |
|---|
| 150 |
else if( $mode == "delete" ) |
|---|
| 151 |
{ |
|---|
| 152 |
if( isset($_POST['id']) || isset($_GET['id']) ) |
|---|
| 153 |
{ |
|---|
| 154 |
$word_id = ( isset($_POST['id']) ) ? $_POST['id'] : $_GET['id']; |
|---|
| 155 |
$word_id = intval($word_id); |
|---|
| 156 |
} |
|---|
| 157 |
else |
|---|
| 158 |
{ |
|---|
| 159 |
$word_id = 0; |
|---|
| 160 |
} |
|---|
| 161 |
|
|---|
| 162 |
$confirm = isset($_POST['confirm']) ? 1 : 0; |
|---|
| 163 |
|
|---|
| 164 |
if( $word_id && $confirm ) |
|---|
| 165 |
{ |
|---|
| 166 |
$sql = "DELETE FROM " . WORDS_TABLE . " |
|---|
| 167 |
WHERE word_id = $word_id"; |
|---|
| 168 |
$result = $db->sql_query($sql); |
|---|
| 169 |
|
|---|
| 170 |
$cache->destroy('_word_censors'); |
|---|
| 171 |
|
|---|
| 172 |
$message = $lang['word_removed'] . "<br /><br />" . sprintf($lang['click_return_wordadmin'], "<a href=\"" . append_sid("admin_words.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); |
|---|
| 173 |
|
|---|
| 174 |
trigger_error($message); |
|---|
| 175 |
} |
|---|
| 176 |
elseif( $word_id && !$confirm) |
|---|
| 177 |
{ |
|---|
| 178 |
|
|---|
| 179 |
$template->set_filenames(array( |
|---|
| 180 |
'body' => '../admin/confirm_body.tpl') |
|---|
| 181 |
); |
|---|
| 182 |
|
|---|
| 183 |
$hidden_fields = '<input type="hidden" name="mode" value="delete" /><input type="hidden" name="id" value="' . $word_id . '" />'; |
|---|
| 184 |
|
|---|
| 185 |
$template->assign_vars(array( |
|---|
| 186 |
'MESSAGE_TITLE' => $lang['confirm'], |
|---|
| 187 |
'MESSAGE_TEXT' => $lang['confirm_delete_word'], |
|---|
| 188 |
|
|---|
| 189 |
'S_CONFIRM_ACTION' => append_sid("admin_words.$phpEx"), |
|---|
| 190 |
'S_HIDDEN_FIELDS' => $hidden_fields) |
|---|
| 191 |
); |
|---|
| 192 |
$template->display("body"); |
|---|
| 193 |
|
|---|
| 194 |
return; |
|---|
| 195 |
} |
|---|
| 196 |
else |
|---|
| 197 |
{ |
|---|
| 198 |
trigger_error($lang['no_word_selected']); |
|---|
| 199 |
return; |
|---|
| 200 |
} |
|---|
| 201 |
} |
|---|
| 202 |
} |
|---|
| 203 |
else |
|---|
| 204 |
{ |
|---|
| 205 |
$template->set_filenames(array( |
|---|
| 206 |
"body" => "../admin/words_list_body.tpl") |
|---|
| 207 |
); |
|---|
| 208 |
|
|---|
| 209 |
$sql = "SELECT * |
|---|
| 210 |
FROM " . WORDS_TABLE . " |
|---|
| 211 |
ORDER BY word"; |
|---|
| 212 |
$result = $db->sql_query($sql); |
|---|
| 213 |
|
|---|
| 214 |
$template->assign_vars(array( |
|---|
| 215 |
"L_WORDS_TEXT" => $lang['words_explain'], |
|---|
| 216 |
"L_ADD_WORD" => $lang['add_new_word'], |
|---|
| 217 |
|
|---|
| 218 |
"S_WORDS_ACTION" => append_sid("admin_words.$phpEx"), |
|---|
| 219 |
"S_HIDDEN_FIELDS" => '') |
|---|
| 220 |
); |
|---|
| 221 |
$i = 0; |
|---|
| 222 |
while ($word_rows = $db->sql_fetchrow($result)) |
|---|
| 223 |
{ |
|---|
| 224 |
++$i; |
|---|
| 225 |
$word = $word_rows['word']; |
|---|
| 226 |
$replacement = $word_rows['replacement']; |
|---|
| 227 |
$word_id = $word_rows['word_id']; |
|---|
| 228 |
|
|---|
| 229 |
$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; |
|---|
| 230 |
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; |
|---|
| 231 |
|
|---|
| 232 |
$template->assign_block_vars("words", array( |
|---|
| 233 |
"ROW_COLOR" => "#" . $row_color, |
|---|
| 234 |
"ROW_CLASS" => $row_class, |
|---|
| 235 |
"WORD" => $word, |
|---|
| 236 |
"REPLACEMENT" => $replacement, |
|---|
| 237 |
|
|---|
| 238 |
"U_WORD_EDIT" => append_sid("admin_words.$phpEx?mode=edit&id=$word_id"), |
|---|
| 239 |
"U_WORD_DELETE" => append_sid("admin_words.$phpEx?mode=delete&id=$word_id")) |
|---|
| 240 |
); |
|---|
| 241 |
} |
|---|
| 242 |
} |
|---|
| 243 |
|
|---|
| 244 |
$template->display("body");</span> |
|---|
| 245 |
<span class="code-lang"> |
|---|
| 246 |
include('./page_footer_admin.'.$phpEx); |
|---|
| 247 |
|
|---|
| 248 |
?> |
|---|