root / tags / release_2_0_2 / phpBB / admin / admin_words.php
History | View | Annotate | Download (6.4 kB)
| 1 | 968 | psotfx | <?php
|
|---|---|---|---|
| 2 | 968 | psotfx | /***************************************************************************
|
| 3 | 968 | psotfx | * admin_words.php |
| 4 | 968 | psotfx | * ------------------- |
| 5 | 968 | psotfx | * begin : Thursday, Jul 12, 2001 |
| 6 | 968 | psotfx | * copyright : (C) 2001 The phpBB Group |
| 7 | 968 | psotfx | * email : support@phpbb.com |
| 8 | 968 | psotfx | * |
| 9 | 968 | psotfx | * $Id$ |
| 10 | 968 | psotfx | * |
| 11 | 968 | psotfx | * |
| 12 | 968 | psotfx | ***************************************************************************/ |
| 13 | 968 | psotfx | |
| 14 | 968 | psotfx | /***************************************************************************
|
| 15 | 968 | psotfx | * |
| 16 | 968 | psotfx | * This program is free software; you can redistribute it and/or modify |
| 17 | 968 | psotfx | * it under the terms of the GNU General Public License as published by |
| 18 | 968 | psotfx | * the Free Software Foundation; either version 2 of the License, or |
| 19 | 968 | psotfx | * (at your option) any later version. |
| 20 | 968 | psotfx | * |
| 21 | 968 | psotfx | ***************************************************************************/ |
| 22 | 968 | psotfx | |
| 23 | 2310 | psotfx | define('IN_PHPBB', 1); |
| 24 | 2310 | psotfx | |
| 25 | 1928 | psotfx | if( !empty($setmodules) ) |
| 26 | 968 | psotfx | {
|
| 27 | 968 | psotfx | $file = basename(__FILE__); |
| 28 | 1432 | psotfx | $module['General']['Word_Censor'] = "$file"; |
| 29 | 968 | psotfx | return;
|
| 30 | 968 | psotfx | } |
| 31 | 968 | psotfx | |
| 32 | 968 | psotfx | //
|
| 33 | 1179 | psotfx | // Load default header
|
| 34 | 968 | psotfx | //
|
| 35 | 2564 | psotfx | $phpbb_root_path = "./../"; |
| 36 | 2397 | psotfx | require($phpbb_root_path . 'extension.inc'); |
| 37 | 2564 | psotfx | require('./pagestart.' . $phpEx); |
| 38 | 968 | psotfx | |
| 39 | 968 | psotfx | if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) ) |
| 40 | 968 | psotfx | {
|
| 41 | 968 | psotfx | $mode = ($HTTP_GET_VARS['mode']) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode']; |
| 42 | 968 | psotfx | } |
| 43 | 975 | psotfx | else
|
| 44 | 968 | psotfx | {
|
| 45 | 975 | psotfx | //
|
| 46 | 975 | psotfx | // These could be entered via a form button
|
| 47 | 975 | psotfx | //
|
| 48 | 975 | psotfx | if( isset($HTTP_POST_VARS['add']) ) |
| 49 | 975 | psotfx | {
|
| 50 | 975 | psotfx | $mode = "add"; |
| 51 | 975 | psotfx | } |
| 52 | 975 | psotfx | else if( isset($HTTP_POST_VARS['save']) ) |
| 53 | 975 | psotfx | {
|
| 54 | 975 | psotfx | $mode = "save"; |
| 55 | 975 | psotfx | } |
| 56 | 975 | psotfx | else
|
| 57 | 975 | psotfx | {
|
| 58 | 975 | psotfx | $mode = ""; |
| 59 | 975 | psotfx | } |
| 60 | 968 | psotfx | } |
| 61 | 968 | psotfx | |
| 62 | 968 | psotfx | if( $mode != "" ) |
| 63 | 968 | psotfx | {
|
| 64 | 968 | psotfx | if( $mode == "edit" || $mode == "add" ) |
| 65 | 968 | psotfx | {
|
| 66 | 975 | psotfx | $word_id = ( isset($HTTP_GET_VARS['id']) ) ? $HTTP_GET_VARS['id'] : 0; |
| 67 | 975 | psotfx | |
| 68 | 968 | psotfx | $template->set_filenames(array( |
| 69 | 968 | psotfx | "body" => "admin/words_edit_body.tpl") |
| 70 | 968 | psotfx | ); |
| 71 | 968 | psotfx | |
| 72 | 975 | psotfx | $s_hidden_fields = ''; |
| 73 | 968 | psotfx | |
| 74 | 968 | psotfx | if( $mode == "edit" ) |
| 75 | 968 | psotfx | {
|
| 76 | 975 | psotfx | if( $word_id ) |
| 77 | 968 | psotfx | {
|
| 78 | 975 | psotfx | $sql = "SELECT * |
| 79 | 975 | psotfx | FROM " . WORDS_TABLE . " |
| 80 | 975 | psotfx | WHERE word_id = $word_id"; |
| 81 | 975 | psotfx | if(!$result = $db->sql_query($sql)) |
| 82 | 975 | psotfx | {
|
| 83 | 975 | psotfx | message_die(GENERAL_ERROR, "Could not query words table", "Error", __LINE__, __FILE__, $sql); |
| 84 | 975 | psotfx | } |
| 85 | 975 | psotfx | |
| 86 | 975 | psotfx | $word_info = $db->sql_fetchrow($result); |
| 87 | 975 | psotfx | $s_hidden_fields .= '<input type="hidden" name="id" value="' . $word_id . '" />'; |
| 88 | 968 | psotfx | } |
| 89 | 975 | psotfx | else
|
| 90 | 975 | psotfx | {
|
| 91 | 975 | psotfx | message_die(GENERAL_MESSAGE, $lang['No_word_selected']); |
| 92 | 975 | psotfx | } |
| 93 | 968 | psotfx | } |
| 94 | 968 | psotfx | |
| 95 | 968 | psotfx | $template->assign_vars(array( |
| 96 | 968 | psotfx | "WORD" => $word_info['word'], |
| 97 | 968 | psotfx | "REPLACEMENT" => $word_info['replacement'], |
| 98 | 968 | psotfx | |
| 99 | 968 | psotfx | "L_WORDS_TITLE" => $lang['Words_title'], |
| 100 | 968 | psotfx | "L_WORDS_TEXT" => $lang['Words_explain'], |
| 101 | 1432 | psotfx | "L_WORD_CENSOR" => $lang['Edit_word_censor'], |
| 102 | 968 | psotfx | "L_WORD" => $lang['Word'], |
| 103 | 968 | psotfx | "L_REPLACEMENT" => $lang['Replacement'], |
| 104 | 968 | psotfx | "L_SUBMIT" => $lang['Submit'], |
| 105 | 968 | psotfx | |
| 106 | 968 | psotfx | "S_WORDS_ACTION" => append_sid("admin_words.$phpEx"), |
| 107 | 968 | psotfx | "S_HIDDEN_FIELDS" => $s_hidden_fields) |
| 108 | 968 | psotfx | ); |
| 109 | 968 | psotfx | |
| 110 | 968 | psotfx | $template->pparse("body"); |
| 111 | 968 | psotfx | |
| 112 | 2564 | psotfx | include('./page_footer_admin.'.$phpEx); |
| 113 | 968 | psotfx | } |
| 114 | 968 | psotfx | else if( $mode == "save" ) |
| 115 | 968 | psotfx | {
|
| 116 | 968 | psotfx | $word_id = ( isset($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : 0; |
| 117 | 968 | psotfx | $word = ( isset($HTTP_POST_VARS['word']) ) ? trim($HTTP_POST_VARS['word']) : ""; |
| 118 | 968 | psotfx | $replacement = ( isset($HTTP_POST_VARS['replacement']) ) ? trim($HTTP_POST_VARS['replacement']) : ""; |
| 119 | 968 | psotfx | |
| 120 | 974 | psotfx | if($word == "" || $replacement == "") |
| 121 | 968 | psotfx | {
|
| 122 | 968 | psotfx | message_die(GENERAL_MESSAGE, $lang['Must_enter_word']); |
| 123 | 968 | psotfx | } |
| 124 | 968 | psotfx | |
| 125 | 968 | psotfx | if( $word_id ) |
| 126 | 968 | psotfx | {
|
| 127 | 968 | psotfx | $sql = "UPDATE " . WORDS_TABLE . " |
| 128 | 1689 | psotfx | SET word = '" . str_replace("\'", "''", $word) . "', replacement = '" . str_replace("\'", "''", $replacement) . "' |
| 129 | 968 | psotfx | WHERE word_id = $word_id"; |
| 130 | 1432 | psotfx | $message = $lang['Word_updated']; |
| 131 | 968 | psotfx | } |
| 132 | 968 | psotfx | else
|
| 133 | 968 | psotfx | {
|
| 134 | 968 | psotfx | $sql = "INSERT INTO " . WORDS_TABLE . " (word, replacement) |
| 135 | 1689 | psotfx | VALUES ('" . str_replace("\'", "''", $word) . "', '" . str_replace("\'", "''", $replacement) . "')";
|
| 136 | 1432 | psotfx | $message = $lang['Word_added']; |
| 137 | 968 | psotfx | } |
| 138 | 968 | psotfx | |
| 139 | 968 | psotfx | if(!$result = $db->sql_query($sql)) |
| 140 | 968 | psotfx | {
|
| 141 | 968 | psotfx | message_die(GENERAL_ERROR, "Could not insert data into words table", $lang['Error'], __LINE__, __FILE__, $sql); |
| 142 | 968 | psotfx | } |
| 143 | 1432 | psotfx | |
| 144 | 1432 | psotfx | $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>"); |
| 145 | 1432 | psotfx | |
| 146 | 1432 | psotfx | message_die(GENERAL_MESSAGE, $message); |
| 147 | 968 | psotfx | } |
| 148 | 968 | psotfx | else if( $mode == "delete" ) |
| 149 | 968 | psotfx | {
|
| 150 | 968 | psotfx | if( isset($HTTP_POST_VARS['id']) || isset($HTTP_GET_VARS['id']) ) |
| 151 | 968 | psotfx | {
|
| 152 | 968 | psotfx | $word_id = ( isset($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id']; |
| 153 | 968 | psotfx | } |
| 154 | 968 | psotfx | else
|
| 155 | 968 | psotfx | {
|
| 156 | 968 | psotfx | $word_id = 0; |
| 157 | 968 | psotfx | } |
| 158 | 968 | psotfx | |
| 159 | 968 | psotfx | if( $word_id ) |
| 160 | 968 | psotfx | {
|
| 161 | 968 | psotfx | $sql = "DELETE FROM " . WORDS_TABLE . " |
| 162 | 968 | psotfx | WHERE word_id = $word_id"; |
| 163 | 968 | psotfx | |
| 164 | 968 | psotfx | if(!$result = $db->sql_query($sql)) |
| 165 | 968 | psotfx | {
|
| 166 | 968 | psotfx | message_die(GENERAL_ERROR, "Could not remove data from words table", $lang['Error'], __LINE__, __FILE__, $sql); |
| 167 | 968 | psotfx | } |
| 168 | 1432 | psotfx | |
| 169 | 1432 | psotfx | $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>"); |
| 170 | 1432 | psotfx | |
| 171 | 1432 | psotfx | message_die(GENERAL_MESSAGE, $message); |
| 172 | 968 | psotfx | } |
| 173 | 968 | psotfx | else
|
| 174 | 968 | psotfx | {
|
| 175 | 2570 | psotfx | message_die(GENERAL_MESSAGE, $lang['No_word_selected']); |
| 176 | 968 | psotfx | } |
| 177 | 968 | psotfx | } |
| 178 | 968 | psotfx | } |
| 179 | 968 | psotfx | else
|
| 180 | 968 | psotfx | {
|
| 181 | 968 | psotfx | $template->set_filenames(array( |
| 182 | 968 | psotfx | "body" => "admin/words_list_body.tpl") |
| 183 | 968 | psotfx | ); |
| 184 | 968 | psotfx | |
| 185 | 968 | psotfx | $sql = "SELECT * |
| 186 | 968 | psotfx | FROM " . WORDS_TABLE . " |
| 187 | 968 | psotfx | ORDER BY word";
|
| 188 | 968 | psotfx | if( !$result = $db->sql_query($sql) ) |
| 189 | 968 | psotfx | {
|
| 190 | 968 | psotfx | message_die(GENERAL_ERROR, "Could not query words table", $lang['Error'], __LINE__, __FILE__, $sql); |
| 191 | 968 | psotfx | } |
| 192 | 968 | psotfx | |
| 193 | 968 | psotfx | $word_rows = $db->sql_fetchrowset($result); |
| 194 | 968 | psotfx | $word_count = count($word_rows); |
| 195 | 968 | psotfx | |
| 196 | 968 | psotfx | $template->assign_vars(array( |
| 197 | 968 | psotfx | "L_WORDS_TITLE" => $lang['Words_title'], |
| 198 | 968 | psotfx | "L_WORDS_TEXT" => $lang['Words_explain'], |
| 199 | 968 | psotfx | "L_WORD" => $lang['Word'], |
| 200 | 968 | psotfx | "L_REPLACEMENT" => $lang['Replacement'], |
| 201 | 968 | psotfx | "L_EDIT" => $lang['Edit'], |
| 202 | 968 | psotfx | "L_DELETE" => $lang['Delete'], |
| 203 | 975 | psotfx | "L_ADD_WORD" => $lang['Add_new_word'], |
| 204 | 968 | psotfx | "L_ACTION" => $lang['Action'], |
| 205 | 968 | psotfx | |
| 206 | 968 | psotfx | "S_WORDS_ACTION" => append_sid("admin_words.$phpEx"), |
| 207 | 975 | psotfx | "S_HIDDEN_FIELDS" => '') |
| 208 | 968 | psotfx | ); |
| 209 | 968 | psotfx | |
| 210 | 968 | psotfx | for($i = 0; $i < $word_count; $i++) |
| 211 | 968 | psotfx | {
|
| 212 | 968 | psotfx | $word = $word_rows[$i]['word']; |
| 213 | 968 | psotfx | $replacement = $word_rows[$i]['replacement']; |
| 214 | 968 | psotfx | $word_id = $word_rows[$i]['word_id']; |
| 215 | 968 | psotfx | |
| 216 | 1046 | psotfx | $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; |
| 217 | 1046 | psotfx | $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; |
| 218 | 1046 | psotfx | |
| 219 | 968 | psotfx | $template->assign_block_vars("words", array( |
| 220 | 1046 | psotfx | "ROW_COLOR" => "#" . $row_color, |
| 221 | 1046 | psotfx | "ROW_CLASS" => $row_class, |
| 222 | 968 | psotfx | "WORD" => $word, |
| 223 | 968 | psotfx | "REPLACEMENT" => $replacement, |
| 224 | 1432 | psotfx | |
| 225 | 1432 | psotfx | "U_WORD_EDIT" => append_sid("admin_words.$phpEx?mode=edit&id=$word_id"), |
| 226 | 1432 | psotfx | "U_WORD_DELETE" => append_sid("admin_words.$phpEx?mode=delete&id=$word_id")) |
| 227 | 968 | psotfx | ); |
| 228 | 968 | psotfx | } |
| 229 | 968 | psotfx | } |
| 230 | 968 | psotfx | |
| 231 | 968 | psotfx | $template->pparse("body"); |
| 232 | 968 | psotfx | |
| 233 | 2564 | psotfx | include('./page_footer_admin.'.$phpEx); |
| 234 | 968 | psotfx | |
| 235 | 968 | psotfx | ?> |

