[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/includes/acp/ -> acp_jabber.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  * @todo Check/enter/update transport info
  16  */
  17  
  18  /**
  19  * @ignore
  20  */
  21  if (!defined('IN_PHPBB'))
  22  {
  23      exit;
  24  }
  25  
  26  class acp_jabber
  27  {
  28      var $u_action;
  29  
  30  	function main($id, $mode)
  31      {
  32          global $db, $user, $auth, $template;
  33          global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
  34  
  35          $user->add_lang('acp/board');
  36  
  37          if (!class_exists('jabber'))
  38          {
  39              include($phpbb_root_path . 'includes/functions_jabber.' . $phpEx);
  40          }
  41  
  42          $action    = request_var('action', '');
  43          $submit = (isset($_POST['submit'])) ? true : false;
  44  
  45          if ($mode != 'settings')
  46          {
  47              return;
  48          }
  49  
  50          $this->tpl_name = 'acp_jabber';
  51          $this->page_title = 'ACP_JABBER_SETTINGS';
  52  
  53          $jab_enable                = request_var('jab_enable',                (bool) $config['jab_enable']);
  54          $jab_host                = request_var('jab_host',                (string) $config['jab_host']);
  55          $jab_port                = request_var('jab_port',                (int) $config['jab_port']);
  56          $jab_username            = request_var('jab_username',            (string) $config['jab_username']);
  57          $jab_password            = request_var('jab_password',            (string) $config['jab_password']);
  58          $jab_package_size        = request_var('jab_package_size',        (int) $config['jab_package_size']);
  59          $jab_use_ssl            = request_var('jab_use_ssl',            (bool) $config['jab_use_ssl']);
  60          $jab_verify_peer        = request_var('jab_verify_peer',        (bool) $config['jab_verify_peer']);
  61          $jab_verify_peer_name    = request_var('jab_verify_peer_name',    (bool) $config['jab_verify_peer_name']);
  62          $jab_allow_self_signed    = request_var('jab_allow_self_signed',    (bool) $config['jab_allow_self_signed']);
  63  
  64          $form_name = 'acp_jabber';
  65          add_form_key($form_name);
  66  
  67          if ($submit)
  68          {
  69              if (!check_form_key($form_name))
  70              {
  71                  trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING);
  72              }
  73  
  74              $error = array();
  75  
  76              $message = $user->lang['JAB_SETTINGS_CHANGED'];
  77              $log = 'JAB_SETTINGS_CHANGED';
  78  
  79              // Is this feature enabled? Then try to establish a connection
  80              if ($jab_enable)
  81              {
  82                  $jabber = new jabber($jab_host, $jab_port, $jab_username, $jab_password, $jab_use_ssl, $jab_verify_peer, $jab_verify_peer_name, $jab_allow_self_signed);
  83  
  84                  if (!$jabber->connect())
  85                  {
  86                      trigger_error($user->lang['ERR_JAB_CONNECT'] . '<br /><br />' . $jabber->get_log() . adm_back_link($this->u_action), E_USER_WARNING);
  87                  }
  88  
  89                  // We'll try to authorise using this account
  90                  if (!$jabber->login())
  91                  {
  92                      trigger_error($user->lang['ERR_JAB_AUTH'] . '<br /><br />' . $jabber->get_log() . adm_back_link($this->u_action), E_USER_WARNING);
  93                  }
  94  
  95                  $jabber->disconnect();
  96              }
  97              else
  98              {
  99                  // This feature is disabled.
 100                  // We update the user table to be sure all users that have IM as notify type are set to both as notify type
 101                  // We set this to both because users still have their jabber address entered and may want to receive jabber notifications again once it is re-enabled.
 102                  $sql_ary = array(
 103                      'user_notify_type'        => NOTIFY_BOTH,
 104                  );
 105  
 106                  $sql = 'UPDATE ' . USERS_TABLE . '
 107                      SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
 108                      WHERE user_notify_type = ' . NOTIFY_IM;
 109                  $db->sql_query($sql);
 110              }
 111  
 112              set_config('jab_enable', $jab_enable);
 113              set_config('jab_host', $jab_host);
 114              set_config('jab_port', $jab_port);
 115              set_config('jab_username', $jab_username);
 116              if ($jab_password !== '********')
 117              {
 118                  set_config('jab_password', $jab_password);
 119              }
 120              set_config('jab_package_size', $jab_package_size);
 121              set_config('jab_use_ssl', $jab_use_ssl);
 122              set_config('jab_verify_peer', $jab_verify_peer);
 123              set_config('jab_verify_peer_name', $jab_verify_peer_name);
 124              set_config('jab_allow_self_signed', $jab_allow_self_signed);
 125  
 126              add_log('admin', 'LOG_' . $log);
 127              trigger_error($message . adm_back_link($this->u_action));
 128          }
 129  
 130          $template->assign_vars(array(
 131              'U_ACTION'                => $this->u_action,
 132              'JAB_ENABLE'            => $jab_enable,
 133              'L_JAB_SERVER_EXPLAIN'    => sprintf($user->lang['JAB_SERVER_EXPLAIN'], '<a href="http://www.jabber.org/">', '</a>'),
 134              'JAB_HOST'                => $jab_host,
 135              'JAB_PORT'                => ($jab_port) ? $jab_port : '',
 136              'JAB_USERNAME'            => $jab_username,
 137              'JAB_PASSWORD'            => $jab_password !== '' ? '********' : '',
 138              'JAB_PACKAGE_SIZE'        => $jab_package_size,
 139              'JAB_USE_SSL'            => $jab_use_ssl,
 140              'JAB_VERIFY_PEER'        => $jab_verify_peer,
 141              'JAB_VERIFY_PEER_NAME'    => $jab_verify_peer_name,
 142              'JAB_ALLOW_SELF_SIGNED'    => $jab_allow_self_signed,
 143              'S_CAN_USE_SSL'            => jabber::can_use_ssl(),
 144              'S_GTALK_NOTE'            => (!@function_exists('dns_get_record')) ? true : false,
 145          ));
 146      }
 147  }


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