aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/acp/acp_help_phpbb.php
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2016-02-21 22:14:58 +0100
committerMarc Alexander <admin@m-a-styles.de>2016-12-03 14:23:34 +0100
commit89fef2ce13a183c7b963032274f455a09a05f325 (patch)
tree9a6d7d5306328c5f11e709e7bda33d0a65f069a6 /phpBB/includes/acp/acp_help_phpbb.php
parent80a63a9a94af042da37227ed747eba0feeac1049 (diff)
downloadforums-89fef2ce13a183c7b963032274f455a09a05f325.tar
forums-89fef2ce13a183c7b963032274f455a09a05f325.tar.gz
forums-89fef2ce13a183c7b963032274f455a09a05f325.tar.bz2
forums-89fef2ce13a183c7b963032274f455a09a05f325.tar.xz
forums-89fef2ce13a183c7b963032274f455a09a05f325.zip
[ticket/14492] Send statistics via ajax request
Flooding ajax requests will try to be prevented and sending stats without JS will also properly work. PHPBB3-14492
Diffstat (limited to 'phpBB/includes/acp/acp_help_phpbb.php')
-rw-r--r--phpBB/includes/acp/acp_help_phpbb.php36
1 files changed, 17 insertions, 19 deletions
diff --git a/phpBB/includes/acp/acp_help_phpbb.php b/phpBB/includes/acp/acp_help_phpbb.php
index fa4de60456..cc353376cd 100644
--- a/phpBB/includes/acp/acp_help_phpbb.php
+++ b/phpBB/includes/acp/acp_help_phpbb.php
@@ -84,23 +84,17 @@ class acp_help_phpbb
if ($submit)
{
$config->set('help_send_statistics', $request->variable('help_send_statistics', false));
+ $response = $request->variable('send_statistics_response', '');
- if ($config['help_send_statistics'])
+ if (!empty($response))
{
- $client = new \GuzzleHttp\Client([
- 'timeout' => 6,
- 'connect_timeout' => 6,
- ]);
-
- $response = $client->post($collect_url, [
- 'body' => [
- 'systemdata' => $collector->get_data_for_form(),
- ]
- ]);
- $response_status = $response->getStatusCode();
-
- if ($response_status >= 200 && $response_status < 300)
+ if ((strpos($response, 'Thank you') !== false || strpos($response, 'Flood protection') !== false))
{
+ // Update time when statistics were actually sent
+ if (strpos($response, 'Thank you') !== false)
+ {
+ $config->set('help_send_statistics_time', time());
+ }
trigger_error($user->lang('THANKS_SEND_STATISTICS') . adm_back_link($this->u_action));
}
else
@@ -108,14 +102,18 @@ class acp_help_phpbb
trigger_error($user->lang('FAIL_SEND_STATISTICS') . adm_back_link($this->u_action));
}
}
+
+ trigger_error($user->lang('CONFIG_UPDATED') . adm_back_link($this->u_action));
}
$template->assign_vars(array(
- 'U_COLLECT_STATS' => $collect_url,
- 'S_COLLECT_STATS' => (!empty($config['help_send_statistics'])) ? true : false,
- 'RAW_DATA' => $collector->get_data_for_form(),
- 'U_ACP_MAIN' => append_sid("{$phpbb_admin_path}index.$phpEx"),
- 'U_ACTION' => $this->u_action,
+ 'U_COLLECT_STATS' => $collect_url,
+ 'S_COLLECT_STATS' => (!empty($config['help_send_statistics'])) ? true : false,
+ 'RAW_DATA' => $collector->get_data_for_form(),
+ 'U_ACP_MAIN' => append_sid("{$phpbb_admin_path}index.$phpEx"),
+ 'U_ACTION' => $this->u_action,
+ // Pass earliest time we should try to send stats again
+ 'COLLECT_STATS_TIME' => intval($config['help_send_statistics_time']) + 86400,
));
$raw = $collector->get_data_raw();