| [ Index ] |
|
Code source de PHP NUKE 7.9 |
1 <?php 2 /*************************************************************************** 3 * 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 define('IN_PHPBB', 1); 24 25 if( !empty($setmodules) ) 26 { 27 $file = basename(__FILE__); 28 $module['General']['Word_Censor'] = "$file"; 29 return; 30 } 31 32 // 33 // Load default header 34 // 35 $phpbb_root_path = "./../"; 36 require ($phpbb_root_path . 'extension.inc'); 37 require('./pagestart.' . $phpEx); 38 39 if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) ) 40 { 41 $mode = ($HTTP_GET_VARS['mode']) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode']; 42 $mode = htmlspecialchars($mode); 43 } 44 else 45 { 46 // 47 // These could be entered via a form button 48 // 49 if( isset($HTTP_POST_VARS['add']) ) 50 { 51 $mode = "add"; 52 } 53 else if( isset($HTTP_POST_VARS['save']) ) 54 { 55 $mode = "save"; 56 } 57 else 58 { 59 $mode = ""; 60 } 61 } 62 63 if( $mode != "" ) 64 { 65 if( $mode == "edit" || $mode == "add" ) 66 { 67 $word_id = ( isset($HTTP_GET_VARS['id']) ) ? intval($HTTP_GET_VARS['id']) : 0; 68 69 $template->set_filenames(array( 70 "body" => "admin/words_edit_body.tpl") 71 ); 72 73 $s_hidden_fields = ''; 74 75 if( $mode == "edit" ) 76 { 77 if( $word_id ) 78 { 79 $sql = "SELECT * 80 FROM " . WORDS_TABLE . " 81 WHERE word_id = $word_id"; 82 if(!$result = $db->sql_query($sql)) 83 { 84 message_die(GENERAL_ERROR, "Could not query words table", "Error", __LINE__, __FILE__, $sql); 85 } 86 87 $word_info = $db->sql_fetchrow($result); 88 $s_hidden_fields .= '<input type="hidden" name="id" value="' . $word_id . '" />'; 89 } 90 else 91 { 92 message_die(GENERAL_MESSAGE, $lang['No_word_selected']); 93 } 94 } 95 96 $template->assign_vars(array( 97 "WORD" => $word_info['word'], 98 "REPLACEMENT" => $word_info['replacement'], 99 100 "L_WORDS_TITLE" => $lang['Words_title'], 101 "L_WORDS_TEXT" => $lang['Words_explain'], 102 "L_WORD_CENSOR" => $lang['Edit_word_censor'], 103 "L_WORD" => $lang['Word'], 104 "L_REPLACEMENT" => $lang['Replacement'], 105 "L_SUBMIT" => $lang['Submit'], 106 107 "S_WORDS_ACTION" => append_sid("admin_words.$phpEx"), 108 "S_HIDDEN_FIELDS" => $s_hidden_fields) 109 ); 110 111 $template->pparse("body"); 112 113 include('./page_footer_admin.'.$phpEx); 114 } 115 else if( $mode == "save" ) 116 { 117 $word_id = ( isset($HTTP_POST_VARS['id']) ) ? intval($HTTP_POST_VARS['id']) : 0; 118 $word = ( isset($HTTP_POST_VARS['word']) ) ? trim($HTTP_POST_VARS['word']) : ""; 119 $replacement = ( isset($HTTP_POST_VARS['replacement']) ) ? trim($HTTP_POST_VARS['replacement']) : ""; 120 121 if($word == "" || $replacement == "") 122 { 123 message_die(GENERAL_MESSAGE, $lang['Must_enter_word']); 124 } 125 126 if( $word_id ) 127 { 128 $sql = "UPDATE " . WORDS_TABLE . " 129 SET word = '" . str_replace("\'", "''", $word) . "', replacement = '" . str_replace("\'", "''", $replacement) . "' 130 WHERE word_id = $word_id"; 131 $message = $lang['Word_updated']; 132 } 133 else 134 { 135 $sql = "INSERT INTO " . WORDS_TABLE . " (word, replacement) 136 VALUES ('" . str_replace("\'", "''", $word) . "', '" . str_replace("\'", "''", $replacement) . "')"; 137 $message = $lang['Word_added']; 138 } 139 140 if(!$result = $db->sql_query($sql)) 141 { 142 message_die(GENERAL_ERROR, "Could not insert data into words table", $lang['Error'], __LINE__, __FILE__, $sql); 143 } 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 message_die(GENERAL_MESSAGE, $message); 148 } 149 else if( $mode == "delete" ) 150 { 151 if( isset($HTTP_POST_VARS['id']) || isset($HTTP_GET_VARS['id']) ) 152 { 153 $word_id = ( isset($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id']; 154 $word_id = intval($word_id); 155 } 156 else 157 { 158 $word_id = 0; 159 } 160 161 if( $word_id ) 162 { 163 $sql = "DELETE FROM " . WORDS_TABLE . " 164 WHERE word_id = $word_id"; 165 166 if(!$result = $db->sql_query($sql)) 167 { 168 message_die(GENERAL_ERROR, "Could not remove data from words table", $lang['Error'], __LINE__, __FILE__, $sql); 169 } 170 171 $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>"); 172 173 message_die(GENERAL_MESSAGE, $message); 174 } 175 else 176 { 177 message_die(GENERAL_MESSAGE, $lang['No_word_selected']); 178 } 179 } 180 } 181 else 182 { 183 $template->set_filenames(array( 184 "body" => "admin/words_list_body.tpl") 185 ); 186 187 $sql = "SELECT * 188 FROM " . WORDS_TABLE . " 189 ORDER BY word"; 190 if( !$result = $db->sql_query($sql) ) 191 { 192 message_die(GENERAL_ERROR, "Could not query words table", $lang['Error'], __LINE__, __FILE__, $sql); 193 } 194 195 $word_rows = $db->sql_fetchrowset($result); 196 $word_count = count($word_rows); 197 198 $template->assign_vars(array( 199 "L_WORDS_TITLE" => $lang['Words_title'], 200 "L_WORDS_TEXT" => $lang['Words_explain'], 201 "L_WORD" => $lang['Word'], 202 "L_REPLACEMENT" => $lang['Replacement'], 203 "L_EDIT" => $lang['Edit'], 204 "L_DELETE" => $lang['Delete'], 205 "L_ADD_WORD" => $lang['Add_new_word'], 206 "L_ACTION" => $lang['Action'], 207 208 "S_WORDS_ACTION" => append_sid("admin_words.$phpEx"), 209 "S_HIDDEN_FIELDS" => '') 210 ); 211 212 for($i = 0; $i < $word_count; $i++) 213 { 214 $word = $word_rows[$i]['word']; 215 $replacement = $word_rows[$i]['replacement']; 216 $word_id = $word_rows[$i]['word_id']; 217 218 $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; 219 $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; 220 221 $template->assign_block_vars("words", array( 222 "ROW_COLOR" => "#" . $row_color, 223 "ROW_CLASS" => $row_class, 224 "WORD" => $word, 225 "REPLACEMENT" => $replacement, 226 227 "U_WORD_EDIT" => append_sid("admin_words.$phpEx?mode=edit&id=$word_id"), 228 "U_WORD_DELETE" => append_sid("admin_words.$phpEx?mode=delete&id=$word_id")) 229 ); 230 } 231 } 232 233 $template->pparse("body"); 234 235 include('./page_footer_admin.'.$phpEx); 236 237 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Apr 1 11:11:59 2007 | par Balluche grâce à PHPXref 0.7 |