Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

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

acp_words.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 4.62 KiB


001  <?php
002  /**
003  *
004  * This file is part of the phpBB Forum Software package.
005  *
006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
007  * @license GNU General Public License, version 2 (GPL-2.0)
008  *
009  * For full copyright and license information, please see
010  * the docs/CREDITS.txt file.
011  *
012  */
013   
014  /**
015  * @ignore
016  */
017  if (!defined('IN_PHPBB'))
018  {
019      exit;
020  }
021   
022  /**
023  * @todo [words] check regular expressions for special char replacements (stored specialchared in db)
024  */
025  class acp_words
026  {
027      var $u_action;
028   
029      function main($id, $mode)
030      {
031          global $db, $user, $auth, $template, $cache;
032          global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
033   
034          $user->add_lang('acp/posting');
035   
036          // Set up general vars
037          $action = request_var('action', '');
038          $action = (isset($_POST['add'])) ? 'add' : ((isset($_POST['save'])) ? 'save' : $action);
039   
040          $s_hidden_fields = '';
041          $word_info = array();
042   
043          $this->tpl_name = 'acp_words';
044          $this->page_title = 'ACP_WORDS';
045   
046          $form_name = 'acp_words';
047          add_form_key($form_name);
048   
049          switch ($action)
050          {
051              case 'edit':
052   
053                  $word_id = request_var('id', 0);
054   
055                  if (!$word_id)
056                  {
057                      trigger_error($user->lang['NO_WORD'] . adm_back_link($this->u_action), E_USER_WARNING);
058                  }
059   
060                  $sql = 'SELECT *
061                      FROM ' . WORDS_TABLE . "
062                      WHERE word_id = $word_id";
063                  $result = $db->sql_query($sql);
064                  $word_info = $db->sql_fetchrow($result);
065                  $db->sql_freeresult($result);
066   
067                  $s_hidden_fields .= '<input type="hidden" name="id" value="' . $word_id . '" />';
068   
069              case 'add':
070   
071                  $template->assign_vars(array(
072                      'S_EDIT_WORD'        => true,
073                      'U_ACTION'            => $this->u_action,
074                      'U_BACK'            => $this->u_action,
075                      'WORD'                => (isset($word_info['word'])) ? $word_info['word'] : '',
076                      'REPLACEMENT'        => (isset($word_info['replacement'])) ? $word_info['replacement'] : '',
077                      'S_HIDDEN_FIELDS'    => $s_hidden_fields)
078                  );
079   
080                  return;
081   
082              break;
083   
084              case 'save':
085   
086                  if (!check_form_key($form_name))
087                  {
088                      trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING);
089                  }
090   
091                  $word_id        = request_var('id', 0);
092                  $word            = utf8_normalize_nfc(request_var('word', '', true));
093                  $replacement    = utf8_normalize_nfc(request_var('replacement', '', true));
094   
095                  if ($word === '' || $replacement === '')
096                  {
097                      trigger_error($user->lang['ENTER_WORD'] . adm_back_link($this->u_action), E_USER_WARNING);
098                  }
099   
100                  // Replace multiple consecutive asterisks with single one as those are not needed
101                  $word = preg_replace('#\*{2,}#', '*', $word);
102   
103                  $sql_ary = array(
104                      'word'            => $word,
105                      'replacement'    => $replacement
106                  );
107   
108                  if ($word_id)
109                  {
110                      $db->sql_query('UPDATE ' . WORDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE word_id = ' . $word_id);
111                  }
112                  else
113                  {
114                      $db->sql_query('INSERT INTO ' . WORDS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
115                  }
116   
117                  $cache->destroy('_word_censors');
118   
119                  $log_action = ($word_id) ? 'LOG_WORD_EDIT' : 'LOG_WORD_ADD';
120                  add_log('admin', $log_action, $word);
121   
122                  $message = ($word_id) ? $user->lang['WORD_UPDATED'] : $user->lang['WORD_ADDED'];
123                  trigger_error($message . adm_back_link($this->u_action));
124   
125              break;
126   
127              case 'delete':
128   
129                  $word_id = request_var('id', 0);
130   
131                  if (!$word_id)
132                  {
133                      trigger_error($user->lang['NO_WORD'] . adm_back_link($this->u_action), E_USER_WARNING);
134                  }
135   
136                  if (confirm_box(true))
137                  {
138                      $sql = 'SELECT word
139                          FROM ' . WORDS_TABLE . "
140                          WHERE word_id = $word_id";
141                      $result = $db->sql_query($sql);
142                      $deleted_word = $db->sql_fetchfield('word');
143                      $db->sql_freeresult($result);
144   
145                      $sql = 'DELETE FROM ' . WORDS_TABLE . "
146                          WHERE word_id = $word_id";
147                      $db->sql_query($sql);
148   
149                      $cache->destroy('_word_censors');
150   
151                      add_log('admin', 'LOG_WORD_DELETE', $deleted_word);
152   
153                      trigger_error($user->lang['WORD_REMOVED'] . adm_back_link($this->u_action));
154                  }
155                  else
156                  {
157                      confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
158                          'i'            => $id,
159                          'mode'        => $mode,
160                          'id'        => $word_id,
161                          'action'    => 'delete',
162                      )));
163                  }
164   
165              break;
166          }
167   
168          $template->assign_vars(array(
169              'U_ACTION'            => $this->u_action,
170              'S_HIDDEN_FIELDS'    => $s_hidden_fields)
171          );
172   
173          $sql = 'SELECT *
174              FROM ' . WORDS_TABLE . '
175              ORDER BY word';
176          $result = $db->sql_query($sql);
177   
178          while ($row = $db->sql_fetchrow($result))
179          {
180              $template->assign_block_vars('words', array(
181                  'WORD'            => $row['word'],
182                  'REPLACEMENT'    => $row['replacement'],
183                  'U_EDIT'        => $this->u_action . '&amp;action=edit&amp;id=' . $row['word_id'],
184                  'U_DELETE'        => $this->u_action . '&amp;action=delete&amp;id=' . $row['word_id'])
185              );
186          }
187          $db->sql_freeresult($result);
188      }
189  }
190