Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
viglink_module.php
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 /**
030 * Main ACP module
031 *
032 * @throws \Exception
033 */
034 public function main($id, $mode)
035 {
036 global $phpbb_container;
037
038 /** @var \phpbb\config\config $config Config object */
039 $config = $phpbb_container->get('config');
040
041 /** @var \phpbb\language\language $language Language object */
042 $language = $phpbb_container->get('language');
043
044 /** @var \phpbb\request\request $request Request object */
045 $request = $phpbb_container->get('request');
046
047 /** @var \phpbb\template\template $template Template object */
048 $template = $phpbb_container->get('template');
049
050 $language->add_lang('viglink_module_acp', 'phpbb/viglink');
051
052 $this->tpl_name = 'acp_viglink';
053 $this->page_title = 'ACP_VIGLINK_SETTINGS';
054
055 $submit = $request->is_set_post('submit');
056
057 if ($mode !== 'settings')
058 {
059 return;
060 }
061
062 $form_key = 'acp_viglink';
063 add_form_key($form_key);
064
065 $error = array();
066
067 // Get stored config/default values
068 $cfg_array = array(
069 'viglink_enabled' => isset($config['viglink_enabled']) ? $config['viglink_enabled'] : 0,
070 );
071
072 // Error if the form is invalid
073 if ($submit && !check_form_key($form_key))
074 {
075 $error[] = $language->lang('FORM_INVALID');
076 }
077
078 // Do not process form if invalid
079 if (count($error))
080 {
081 $submit = false;
082 }
083
084 if ($submit)
085 {
086 // Get the VigLink form field values
087 $cfg_array['viglink_enabled'] = $request->variable('viglink_enabled', 0);
088
089 // If no errors, set the config values
090 if (!count($error))
091 {
092 foreach ($cfg_array as $cfg => $value)
093 {
094 $config->set($cfg, $value);
095 }
096
097 trigger_error($language->lang('CONFIG_UPDATED') . adm_back_link($this->u_action));
098 }
099 }
100
101 if (!isset($config['questionnaire_unique_id']))
102 {
103 $config->set('questionnaire_unique_id', unique_id());
104 }
105
106 // Set a general error message if VigLink has been disabled by phpBB
107 if (!$config['allow_viglink_phpbb'])
108 {
109 $error[] = $language->lang('ACP_VIGLINK_DISABLED_PHPBB');
110 }
111
112 // Try to get convert account key from .com
113 $sub_id = md5($config['viglink_api_siteid'] . $config['questionnaire_unique_id']);
114 $convert_account_link = $config->offsetGet('viglink_convert_account_url');
115
116 if (empty($convert_account_link) || strpos($config['viglink_convert_account_url'], 'subId=' . $sub_id) === false)
117 {
118 $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']);
119 if (!empty($convert_account_link) && strpos($convert_account_link, 'https://www.viglink.com/users/convertAccount') === 0)
120 {
121 $type_caster = new type_cast_helper();
122 $type_caster->set_var($convert_account_link, $convert_account_link, 'string', false, false);
123 $config->set('viglink_convert_account_url', $convert_account_link);
124 }
125 else
126 {
127 $error[] = $language->lang('ACP_VIGLINK_NO_CONVERT_LINK');
128 $convert_account_link = '';
129 }
130 }
131
132 $template->assign_vars(array(
133 'S_ERROR' => (bool) count($error),
134 'ERROR_MSG' => implode('<br />', $error),
135
136 'VIGLINK_ENABLED' => $cfg_array['viglink_enabled'],
137
138 'U_VIGLINK_CONVERT' => $convert_account_link,
139 'U_ACTION' => $this->u_action,
140 ));
141 }
142 }
143