Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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

viglink_module.php

Zuletzt modifiziert: 09.10.2024, 12:55 - Dateigröße: 3.70 KiB


001  <?php
002  /**
003   *
004   * VigLink extension for the phpBB Forum Software package.
005   *
006   * @copyright (c) 2014 phpBB Limited <https://www.phpbb.com>
007   * @license GNU General Public License, version 2 (GPL-2.0)
008   *
009   */
010   
011  namespace phpbb\viglink\acp;
012   
013  use phpbb\request\type_cast_helper;
014   
015  /**
016   * VigLink ACP module
017   */
018  class viglink_module
019  {
020      /** @var string $page_title The page title */
021      public $page_title;
022   
023      /** @var string $tpl_name The page template name */
024      public $tpl_name;
025   
026      /** @var string $u_action Custom form action */
027      public $u_action;
028   
029      public function main($id, $mode)
030      {
031          global $phpbb_container;
032   
033          /** @var \phpbb\config\config $config Config object */
034          $config = $phpbb_container->get('config');
035   
036          /** @var \phpbb\language\language $language Language object */
037          $language = $phpbb_container->get('language');
038   
039          /** @var \phpbb\request\request $request Request object */
040          $request  = $phpbb_container->get('request');
041   
042          /** @var \phpbb\template\template $template Template object */
043          $template = $phpbb_container->get('template');
044   
045          $language->add_lang('viglink_module_acp', 'phpbb/viglink');
046   
047          $this->tpl_name = 'acp_viglink';
048          $this->page_title = $language->lang('ACP_VIGLINK_SETTINGS');
049   
050          $submit = $request->is_set_post('submit');
051   
052          if ($mode !== 'settings')
053          {
054              return;
055          }
056   
057          $form_key = 'acp_viglink';
058          add_form_key($form_key);
059   
060          $error = array();
061   
062          // Get stored config/default values
063          $cfg_array = array(
064              'viglink_enabled' => isset($config['viglink_enabled']) ? $config['viglink_enabled'] : 0,
065          );
066   
067          // Error if the form is invalid
068          if ($submit && !check_form_key($form_key))
069          {
070              $error[] = $language->lang('FORM_INVALID');
071          }
072   
073          // Do not process form if invalid
074          if (count($error))
075          {
076              $submit = false;
077          }
078   
079          if ($submit)
080          {
081              // Get the VigLink form field values
082              $cfg_array['viglink_enabled'] = $request->variable('viglink_enabled', 0);
083   
084              // If no errors, set the config values
085              if (!count($error))
086              {
087                  foreach ($cfg_array as $cfg => $value)
088                  {
089                      $config->set($cfg, $value);
090                  }
091   
092                  trigger_error($language->lang('CONFIG_UPDATED') . adm_back_link($this->u_action));
093              }
094          }
095   
096          if (!isset($config['questionnaire_unique_id']))
097          {
098              $config->set('questionnaire_unique_id', unique_id());
099          }
100   
101          // Set a general error message if VigLink has been disabled by phpBB
102          if (!$config['allow_viglink_phpbb'])
103          {
104              $error[] = $language->lang('ACP_VIGLINK_DISABLED_PHPBB');
105          }
106   
107          // Try to get convert account key from .com
108          $sub_id = md5($config['viglink_api_siteid'] . $config['questionnaire_unique_id']);
109          $convert_account_link = $config->offsetGet('viglink_convert_account_url');
110   
111          if (empty($convert_account_link) || strpos($config['viglink_convert_account_url'], 'subId=' . $sub_id) === false)
112          {
113              $convert_account_link = @file_get_contents('https://www.phpbb.com/viglink/convert?domain=' . urlencode($config['server_name']) . '&siteid=' . $config['viglink_api_siteid'] . '&uuid=' . $config['questionnaire_unique_id'] . '&key=' . $config['phpbb_viglink_api_key']);
114              if (!empty($convert_account_link) && strpos($convert_account_link, 'https://www.viglink.com/users/convertAccount') === 0)
115              {
116                  $type_caster = new type_cast_helper();
117                  $type_caster->set_var($convert_account_link, $convert_account_link, 'string', false, false);
118                  $config->set('viglink_convert_account_url', $convert_account_link);
119              }
120              else
121              {
122                  $error[] = $language->lang('ACP_VIGLINK_NO_CONVERT_LINK');
123                  $convert_account_link = '';
124              }
125          }
126   
127          $template->assign_vars(array(
128              'S_ERROR'                => (bool) count($error),
129              'ERROR_MSG'                => implode('<br />', $error),
130   
131              'VIGLINK_ENABLED'        => $cfg_array['viglink_enabled'],
132   
133              'U_VIGLINK_CONVERT'        => $convert_account_link,
134              'U_ACTION'                => $this->u_action,
135          ));
136      }
137  }
138