[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/includes/acp/ -> acp_disallow.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  /**
  15  * @ignore
  16  */
  17  if (!defined('IN_PHPBB'))
  18  {
  19      exit;
  20  }
  21  
  22  class acp_disallow
  23  {
  24      var $u_action;
  25  
  26  	function main($id, $mode)
  27      {
  28          global $db, $user, $auth, $template, $cache;
  29          global $config, $phpbb_admin_path;
  30  
  31          $user->add_lang('acp/posting');
  32  
  33          // Set up general vars
  34          $this->tpl_name = 'acp_disallow';
  35          $this->page_title = 'ACP_DISALLOW_USERNAMES';
  36  
  37          $form_key = 'acp_disallow';
  38          add_form_key($form_key);
  39  
  40          $disallow = (isset($_POST['disallow'])) ? true : false;
  41          $allow = (isset($_POST['allow'])) ? true : false;
  42  
  43          if (($allow || $disallow) && !check_form_key($form_key))
  44          {
  45              trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
  46          }
  47  
  48          if ($disallow)
  49          {
  50              $disallowed_user = str_replace('*', '%', utf8_normalize_nfc(request_var('disallowed_user', '', true)));
  51  
  52              if (!$disallowed_user)
  53              {
  54                  trigger_error($user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING);
  55              }
  56  
  57              $sql = 'SELECT disallow_id
  58                  FROM ' . DISALLOW_TABLE . "
  59                  WHERE disallow_username = '" . $db->sql_escape($disallowed_user) . "'";
  60              $result = $db->sql_query($sql);
  61              $row = $db->sql_fetchrow($result);
  62              $db->sql_freeresult($result);
  63  
  64              if ($row)
  65              {
  66                  trigger_error($user->lang['DISALLOWED_ALREADY'] . adm_back_link($this->u_action), E_USER_WARNING);
  67              }
  68  
  69              $sql = 'INSERT INTO ' . DISALLOW_TABLE . ' ' . $db->sql_build_array('INSERT', array('disallow_username' => $disallowed_user));
  70              $db->sql_query($sql);
  71  
  72              $cache->destroy('_disallowed_usernames');
  73  
  74              $message = $user->lang['DISALLOW_SUCCESSFUL'];
  75              add_log('admin', 'LOG_DISALLOW_ADD', str_replace('%', '*', $disallowed_user));
  76  
  77              trigger_error($message . adm_back_link($this->u_action));
  78          }
  79          else if ($allow)
  80          {
  81              $disallowed_id = request_var('disallowed_id', 0);
  82  
  83              if (!$disallowed_id)
  84              {
  85                  trigger_error($user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING);
  86              }
  87  
  88              $sql = 'DELETE FROM ' . DISALLOW_TABLE . '
  89                  WHERE disallow_id = ' . $disallowed_id;
  90              $db->sql_query($sql);
  91  
  92              $cache->destroy('_disallowed_usernames');
  93  
  94              add_log('admin', 'LOG_DISALLOW_DELETE');
  95  
  96              trigger_error($user->lang['DISALLOWED_DELETED'] . adm_back_link($this->u_action));
  97          }
  98  
  99          // Grab the current list of disallowed usernames...
 100          $sql = 'SELECT *
 101              FROM ' . DISALLOW_TABLE;
 102          $result = $db->sql_query($sql);
 103  
 104          $disallow_select = '';
 105          while ($row = $db->sql_fetchrow($result))
 106          {
 107              $disallow_select .= '<option value="' . $row['disallow_id'] . '">' . str_replace('%', '*', $row['disallow_username']) . '</option>';
 108          }
 109          $db->sql_freeresult($result);
 110  
 111          $template->assign_vars(array(
 112              'U_ACTION'                => $this->u_action,
 113              'S_DISALLOWED_NAMES'    => $disallow_select)
 114          );
 115      }
 116  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1