PDF rausgenommen

This commit is contained in:
aschwarz
2023-01-23 11:03:31 +01:00
parent 82d562a322
commit a6523903eb
28078 changed files with 4247552 additions and 2 deletions

View File

@ -0,0 +1,146 @@
<?php
/**
*
* VigLink extension for the phpBB Forum Software package.
*
* @copyright (c) 2014 phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
namespace phpbb\viglink\acp;
/**
* Class to handle allowing or disallowing VigLink services
*/
class viglink_helper
{
/** @var \phpbb\cache\driver\driver_interface $cache */
protected $cache;
/** @var \phpbb\config\config $config */
protected $config;
/** @var \phpbb\file_downloader $file_downloader */
protected $file_downloader;
/** @var \phpbb\language\language $language */
protected $language;
/** @var \phpbb\log\log $log */
protected $log;
/** @var \phpbb\user $user */
protected $user;
/** @var bool Use SSL or not */
protected $use_ssl = false;
/**
* Constructor
*
* @param \phpbb\cache\driver\driver_interface $cache
* @param \phpbb\config\config $config
* @param \phpbb\file_downloader $file_downloader
* @param \phpbb\language\language $language
* @param \phpbb\log\log $log
* @param \phpbb\user $user
*/
public function __construct(\phpbb\cache\driver\driver_interface $cache, \phpbb\config\config $config, \phpbb\file_downloader $file_downloader, \phpbb\language\language $language, \phpbb\log\log $log, \phpbb\user $user)
{
$this->cache = $cache;
$this->config = $config;
$this->file_downloader = $file_downloader;
$this->language = $language;
$this->log = $log;
$this->user = $user;
}
/**
* Obtains the latest VigLink services information from phpBB
*
* @param bool $force_update Ignores cached data. Defaults to false.
* @param bool $force_cache Force the use of the cache. Override $force_update.
*
* @throws \RuntimeException
*
* @return void
*/
public function set_viglink_services($force_update = false, $force_cache = false)
{
$cache_key = '_versioncheck_viglink_' . $this->use_ssl;
$info = $this->cache->get($cache_key);
if ($info === false && $force_cache)
{
throw new \RuntimeException($this->language->lang('VERSIONCHECK_FAIL'));
}
else if ($info === false || $force_update)
{
try
{
$info = $this->file_downloader->get('www.phpbb.com', '/viglink', 'enabled', 443);
}
catch (\phpbb\exception\runtime_exception $exception)
{
$prepare_parameters = array_merge(array($exception->getMessage()), $exception->get_parameters());
throw new \RuntimeException(call_user_func_array(array($this->language, 'lang'), $prepare_parameters));
}
if ($info === '0')
{
$this->set_viglink_configs(array(
'allow_viglink_phpbb' => false,
));
}
else
{
$info = '1';
$this->set_viglink_configs(array(
'allow_viglink_phpbb' => true,
));
}
$this->cache->put($cache_key, $info, 86400); // 24 hours
}
}
/**
* Sets VigLink service configs as determined by phpBB
*
* @param array $data Array of VigLink file data.
*
* @return void
*/
protected function set_viglink_configs($data)
{
$viglink_configs = array(
'allow_viglink_phpbb',
'phpbb_viglink_api_key',
);
foreach ($viglink_configs as $cfg_name)
{
if (array_key_exists($cfg_name, $data) && ($data[$cfg_name] != $this->config[$cfg_name] || !isset($this->config[$cfg_name])))
{
$this->config->set($cfg_name, $data[$cfg_name]);
}
}
$this->config->set('viglink_last_gc', time(), false);
}
/**
* Log a VigLink error message to the error log
*
* @param string $message The error message
*/
public function log_viglink_error($message)
{
$user_id = empty($this->user->data) ? ANONYMOUS : $this->user->data['user_id'];
$user_ip = empty($this->user->ip) ? '' : $this->user->ip;
$this->log->add('critical', $user_id, $user_ip, 'LOG_VIGLINK_CHECK_FAIL', false, array($message));
}
}

View File

@ -0,0 +1,32 @@
<?php
/**
*
* VigLink extension for the phpBB Forum Software package.
*
* @copyright (c) 2014 phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
namespace phpbb\viglink\acp;
/**
* VigLink ACP module info
*/
class viglink_info
{
public function module()
{
return array(
'filename' => '\phpbb\viglink\acp\viglink_module',
'title' => 'ACP_VIGLINK_SETTINGS',
'modes' => array(
'settings' => array(
'title' => 'ACP_VIGLINK_SETTINGS',
'auth' => 'ext_phpbb/viglink && acl_a_board',
'cat' => array('ACP_BOARD_CONFIGURATION')
),
),
);
}
}

View File

@ -0,0 +1,137 @@
<?php
/**
*
* VigLink extension for the phpBB Forum Software package.
*
* @copyright (c) 2014 phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
namespace phpbb\viglink\acp;
use phpbb\request\type_cast_helper;
/**
* VigLink ACP module
*/
class viglink_module
{
/** @var string $page_title The page title */
public $page_title;
/** @var string $tpl_name The page template name */
public $tpl_name;
/** @var string $u_action Custom form action */
public $u_action;
public function main($id, $mode)
{
global $phpbb_container;
/** @var \phpbb\config\config $config Config object */
$config = $phpbb_container->get('config');
/** @var \phpbb\language\language $language Language object */
$language = $phpbb_container->get('language');
/** @var \phpbb\request\request $request Request object */
$request = $phpbb_container->get('request');
/** @var \phpbb\template\template $template Template object */
$template = $phpbb_container->get('template');
$language->add_lang('viglink_module_acp', 'phpbb/viglink');
$this->tpl_name = 'acp_viglink';
$this->page_title = $language->lang('ACP_VIGLINK_SETTINGS');
$submit = $request->is_set_post('submit');
if ($mode !== 'settings')
{
return;
}
$form_key = 'acp_viglink';
add_form_key($form_key);
$error = array();
// Get stored config/default values
$cfg_array = array(
'viglink_enabled' => isset($config['viglink_enabled']) ? $config['viglink_enabled'] : 0,
);
// Error if the form is invalid
if ($submit && !check_form_key($form_key))
{
$error[] = $language->lang('FORM_INVALID');
}
// Do not process form if invalid
if (count($error))
{
$submit = false;
}
if ($submit)
{
// Get the VigLink form field values
$cfg_array['viglink_enabled'] = $request->variable('viglink_enabled', 0);
// If no errors, set the config values
if (!count($error))
{
foreach ($cfg_array as $cfg => $value)
{
$config->set($cfg, $value);
}
trigger_error($language->lang('CONFIG_UPDATED') . adm_back_link($this->u_action));
}
}
if (!isset($config['questionnaire_unique_id']))
{
$config->set('questionnaire_unique_id', unique_id());
}
// Set a general error message if VigLink has been disabled by phpBB
if (!$config['allow_viglink_phpbb'])
{
$error[] = $language->lang('ACP_VIGLINK_DISABLED_PHPBB');
}
// Try to get convert account key from .com
$sub_id = md5($config['viglink_api_siteid'] . $config['questionnaire_unique_id']);
$convert_account_link = $config->offsetGet('viglink_convert_account_url');
if (empty($convert_account_link) || strpos($config['viglink_convert_account_url'], 'subId=' . $sub_id) === false)
{
$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']);
if (!empty($convert_account_link) && strpos($convert_account_link, 'https://www.viglink.com/users/convertAccount') === 0)
{
$type_caster = new type_cast_helper();
$type_caster->set_var($convert_account_link, $convert_account_link, 'string', false, false);
$config->set('viglink_convert_account_url', $convert_account_link);
}
else
{
$error[] = $language->lang('ACP_VIGLINK_NO_CONVERT_LINK');
$convert_account_link = '';
}
}
$template->assign_vars(array(
'S_ERROR' => (bool) count($error),
'ERROR_MSG' => implode('<br />', $error),
'VIGLINK_ENABLED' => $cfg_array['viglink_enabled'],
'U_VIGLINK_CONVERT' => $convert_account_link,
'U_ACTION' => $this->u_action,
));
}
}