Verzeichnisstruktur phpBB-2.0.0


Veröffentlicht
03.04.2002

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

admin_words.php

Zuletzt modifiziert: 09.10.2024, 12:51 - Dateigröße: 7.64 KiB


001  <?php
002  /***************************************************************************
003   *                              admin_words.php
004   *                            -------------------
005   *   begin                : Thursday, Jul 12, 2001
006   *   copyright            : (C) 2001 The phpBB Group
007   *   email                : support@phpbb.com
008   *
009   *   $Id$
010   *
011   *
012   ***************************************************************************/
013   
014  /***************************************************************************
015   *
016   *   This program is free software; you can redistribute it and/or modify
017   *   it under the terms of the GNU General Public License as published by
018   *   the Free Software Foundation; either version 2 of the License, or
019   *   (at your option) any later version.
020   *
021   ***************************************************************************/
022   
023  if( !empty($setmodules) )
024  {
025      $file = basename(__FILE__);
026      $module['General']['Word_Censor'] = $file;
027      return;
028  }
029   
030  define('IN_PHPBB', 1);
031   
032  //
033  // Load default header
034  //
035  $phpbb_root_path = "./../";
036  require($phpbb_root_path . 'extension.inc');
037   
038  $cancel = (isset($HTTP_POST_VARS['cancel']) || isset($_POST['cancel'])) ? true : false;
039  $no_page_header = $cancel;
040   
041  require('./pagestart.' . $phpEx);
042   
043  if ($cancel)
044  {
045      redirect('admin/' . append_sid("admin_words.$phpEx", true));
046  }
047   
048  if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
049  {
050      $mode = (isset($HTTP_GET_VARS['mode'])) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode'];
051      $mode = htmlspecialchars($mode);
052  }
053  else 
054  {
055      //
056      // These could be entered via a form button
057      //
058      if( isset($HTTP_POST_VARS['add']) )
059      {
060          $mode = "add";
061      }
062      else if( isset($HTTP_POST_VARS['save']) )
063      {
064          $mode = "save";
065      }
066      else
067      {
068          $mode = "";
069      }
070  }
071   
072  // Restrict mode input to valid options
073  $mode = ( in_array($mode, array('add', 'edit', 'save', 'delete')) ) ? $mode : '';
074   
075  if( $mode != "" )
076  {
077      if( $mode == "edit" || $mode == "add" )
078      {
079          $word_id = ( isset($HTTP_GET_VARS['id']) ) ? intval($HTTP_GET_VARS['id']) : 0;
080   
081          $template->set_filenames(array(
082              "body" => "admin/words_edit_body.tpl")
083          );
084   
085          $word_info = array('word' => '', 'replacement' => '');
086          $s_hidden_fields = '';
087   
088          if( $mode == "edit" )
089          {
090              if( $word_id )
091              {
092                  $sql = "SELECT * 
093                      FROM " . WORDS_TABLE . " 
094                      WHERE word_id = $word_id";
095                  if(!$result = $db->sql_query($sql))
096                  {
097                      message_die(GENERAL_ERROR, "Could not query words table", "Error", __LINE__, __FILE__, $sql);
098                  }
099   
100                  $word_info = $db->sql_fetchrow($result);
101                  $s_hidden_fields .= '<input type="hidden" name="id" value="' . $word_id . '" />';
102              }
103              else
104              {
105                  message_die(GENERAL_MESSAGE, $lang['No_word_selected']);
106              }
107          }
108   
109          $template->assign_vars(array(
110              "WORD" => htmlspecialchars($word_info['word']),
111              "REPLACEMENT" => htmlspecialchars($word_info['replacement']),
112   
113              "L_WORDS_TITLE" => $lang['Words_title'],
114              "L_WORDS_TEXT" => $lang['Words_explain'],
115              "L_WORD_CENSOR" => $lang['Edit_word_censor'],
116              "L_WORD" => $lang['Word'],
117              "L_REPLACEMENT" => $lang['Replacement'],
118              "L_SUBMIT" => $lang['Submit'],
119   
120              "S_WORDS_ACTION" => append_sid("admin_words.$phpEx"),
121              "S_HIDDEN_FIELDS" => $s_hidden_fields)
122          );
123   
124          $template->pparse("body");
125   
126          include('./page_footer_admin.'.$phpEx);
127      }
128      else if( $mode == "save" )
129      {
130          $word_id = ( isset($HTTP_POST_VARS['id']) ) ? intval($HTTP_POST_VARS['id']) : 0;
131          $word = ( isset($HTTP_POST_VARS['word']) ) ? trim($HTTP_POST_VARS['word']) : "";
132          $replacement = ( isset($HTTP_POST_VARS['replacement']) ) ? trim($HTTP_POST_VARS['replacement']) : "";
133   
134          if($word == "" || $replacement == "")
135          {
136              message_die(GENERAL_MESSAGE, $lang['Must_enter_word']);
137          }
138   
139          if( $word_id )
140          {
141              $sql = "UPDATE " . WORDS_TABLE . 
142                  SET word = '" . str_replace("\'", "''", $word) . "', replacement = '" . str_replace("\'", "''", $replacement) . "
143                  WHERE word_id = $word_id";
144              $message = $lang['Word_updated'];
145          }
146          else
147          {
148              $sql = "INSERT INTO " . WORDS_TABLE . " (word, replacement) 
149                  VALUES ('" . str_replace("\'", "''", $word) . "', '" . str_replace("\'", "''", $replacement) . "')";
150              $message = $lang['Word_added'];
151          }
152   
153          if(!$result = $db->sql_query($sql))
154          {
155              message_die(GENERAL_ERROR, "Could not insert data into words table", $lang['Error'], __LINE__, __FILE__, $sql);
156          }
157   
158          $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>");
159   
160          message_die(GENERAL_MESSAGE, $message);
161      }
162      else if( $mode == "delete" )
163      {
164          if( isset($HTTP_POST_VARS['id']) ||  isset($HTTP_GET_VARS['id']) )
165          {
166              $word_id = ( isset($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id'];
167              $word_id = intval($word_id);
168          }
169          else
170          {
171              $word_id = 0;
172          }
173   
174          $confirm = isset($HTTP_POST_VARS['confirm']);
175   
176          if( $word_id && $confirm )
177          {
178              $sql = "DELETE FROM " . WORDS_TABLE . " 
179                  WHERE word_id = $word_id";
180   
181              if(!$result = $db->sql_query($sql))
182              {
183                  message_die(GENERAL_ERROR, "Could not remove data from words table", $lang['Error'], __LINE__, __FILE__, $sql);
184              }
185   
186              $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>");
187   
188              message_die(GENERAL_MESSAGE, $message);
189          }
190          elseif( $word_id && !$confirm)
191          {
192              // Present the confirmation screen to the user
193              $template->set_filenames(array(
194                  'body' => 'admin/confirm_body.tpl')
195              );
196   
197              $hidden_fields = '<input type="hidden" name="mode" value="delete" /><input type="hidden" name="id" value="' . $word_id . '" />';
198   
199              $template->assign_vars(array(
200                  'MESSAGE_TITLE' => $lang['Confirm'],
201                  'MESSAGE_TEXT' => $lang['Confirm_delete_word'],
202   
203                  'L_YES' => $lang['Yes'],
204                  'L_NO' => $lang['No'],
205   
206                  'S_CONFIRM_ACTION' => append_sid("admin_words.$phpEx"),
207                  'S_HIDDEN_FIELDS' => $hidden_fields)
208              );
209          }
210          else
211          {
212              message_die(GENERAL_MESSAGE, $lang['No_word_selected']);
213          }
214      }
215  }
216  else
217  {
218      $template->set_filenames(array(
219          "body" => "admin/words_list_body.tpl")
220      );
221   
222      $sql = "SELECT * 
223          FROM " . WORDS_TABLE . 
224          ORDER BY word";
225      if( !$result = $db->sql_query($sql) )
226      {
227          message_die(GENERAL_ERROR, "Could not query words table", $lang['Error'], __LINE__, __FILE__, $sql);
228      }
229   
230      $word_rows = $db->sql_fetchrowset($result);
231      $db->sql_freeresult($result);
232      $word_count = count($word_rows);
233   
234      $template->assign_vars(array(
235          "L_WORDS_TITLE" => $lang['Words_title'],
236          "L_WORDS_TEXT" => $lang['Words_explain'],
237          "L_WORD" => $lang['Word'],
238          "L_REPLACEMENT" => $lang['Replacement'],
239          "L_EDIT" => $lang['Edit'],
240          "L_DELETE" => $lang['Delete'],
241          "L_ADD_WORD" => $lang['Add_new_word'],
242          "L_ACTION" => $lang['Action'],
243   
244          "S_WORDS_ACTION" => append_sid("admin_words.$phpEx"),
245          "S_HIDDEN_FIELDS" => '')
246      );
247   
248      for($i = 0; $i < $word_count; $i++)
249      {
250          $word = $word_rows[$i]['word'];
251          $replacement = $word_rows[$i]['replacement'];
252          $word_id = $word_rows[$i]['word_id'];
253   
254          $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
255          $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
256   
257          $template->assign_block_vars("words", array(
258              "ROW_COLOR" => "#" . $row_color,
259              "ROW_CLASS" => $row_class,
260              "WORD" => htmlspecialchars($word),
261              "REPLACEMENT" => htmlspecialchars($replacement),
262   
263              "U_WORD_EDIT" => append_sid("admin_words.$phpEx?mode=edit&amp;id=$word_id"),
264              "U_WORD_DELETE" => append_sid("admin_words.$phpEx?mode=delete&amp;id=$word_id"))
265          );
266      }
267  }
268   
269  $template->pparse("body");
270   
271  include('./page_footer_admin.'.$phpEx);
272   
273  ?>