1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-03-25 18:13:28 +01:00

[ticket/14492] Use guzzle for submitting data to stats service

PHPBB3-14492
This commit is contained in:
Marc Alexander 2016-02-01 13:55:36 +01:00
parent 9fb2a5d5f8
commit cc7a0aa4fb
No known key found for this signature in database
GPG Key ID: 50E0D2423696F995
3 changed files with 51 additions and 1 deletions

View File

@ -4,6 +4,7 @@
<h1>{L_ACP_HELP_PHPBB}</h1>
<form id="acp_board" method="post" action="{U_ACTION}">
<div class="send-stats-row">
<div class="send-stats-tile">
<h2><i class="icon fa-bar-chart"></i>Send statistics</h2>
@ -47,6 +48,13 @@
<dd>Enable</dd>
</dl>
</div>
<fieldset>
<p class="submit-buttons">
<input class="button1" type="submit" id="submit" name="submit" value="{L_SUBMIT}" />
</p>
{S_FORM_TOKEN}
</fieldset>
</div>
</form>
<!-- INCLUDE overall_footer.html -->

View File

@ -25,7 +25,7 @@ class acp_help_phpbb
function main($id, $mode)
{
global $config, $template, $phpbb_admin_path, $phpbb_root_path, $phpEx;
global $config, $request, $template, $user, $phpbb_admin_path, $phpbb_root_path, $phpEx;
if (!class_exists('phpbb_questionnaire_data_collector'))
{
@ -37,6 +37,22 @@ class acp_help_phpbb
$this->tpl_name = 'acp_help_phpbb';
$this->page_title = 'ACP_HELP_PHPBB';
$submit = ($request->is_set_post('submit')) ? true : false;
$form_key = 'acp_help_phpbb';
add_form_key($form_key);
$error = array();
if ($submit && !check_form_key($form_key))
{
$error[] = $user->lang['FORM_INVALID'];
}
// Do not write values if there is an error
if (sizeof($error))
{
$submit = false;
}
// generate a unique id if necessary
if (!isset($config['questionnaire_unique_id']))
{
@ -55,6 +71,31 @@ class acp_help_phpbb
$collector->add_data_provider(new phpbb_questionnaire_system_data_provider());
$collector->add_data_provider(new phpbb_questionnaire_phpbb_data_provider($config));
if ($submit)
{
$client = new \Guzzle\Http\Client(
$this->u_action,
array(
'timeout' => 6,
'connect_timeout' => 6,
)
);
$collect_request = $client->post($collect_url, [], [
'systemdata' => $collector->get_data_for_form(),
]);
$response = $collect_request->send();
if ($response->isSuccessful())
{
trigger_error($user->lang('THANKS_SEND_STATISTICS') . adm_back_link($this->u_action));
}
else
{
trigger_error($user->lang('FAIL_SEND_STATISTICS') . adm_back_link($this->u_action));
}
}
$template->assign_vars(array(
'U_COLLECT_STATS' => $collect_url,
'RAW_DATA' => $collector->get_data_for_form(),

View File

@ -486,6 +486,7 @@ $lang = array_merge($lang, array(
'SEND_STATISTICS_LONG' => 'Send statistical information',
'SHOW_STATISTICS' => 'Show details',
'THANKS_SEND_STATISTICS' => 'Thank you for submitting your information.',
'FAIL_SEND_STATISTICS' => 'phpBB was unable to send statistics',
'EXPLAIN_ENABLE_VIGLINK' => 'Viglink is a non-invasive third-party service that will monetize existing links posted by users of your forum. When visitors click on those existing links and perform certain actions, such as shopping, the merchants pay VigLink a commission, of which a share is donated to the phpBB project. By agreeing to enable VigLink and donating proceeds to the phpBB project, you are supporting our open source organization and ensuring our continued financial security.<br /><br />You can change these settings at any time in VigLink settings panel.',
));