[ticket/16287] After installation an error is given over statistics submission

The phpBB.com website required specific fields to be available for the
statistics. This change switched over to a new statistics page on
www.phpbb.com that uses form fields instead, and that returns JSON as value.

PHPBB3-16287
This commit is contained in:
paul sohier 2020-01-02 15:21:34 +01:00
parent dce0441ecf
commit f866a8fd1b
No known key found for this signature in database
GPG key ID: 1514E166808D920F
4 changed files with 19 additions and 10 deletions

View file

@ -38,10 +38,12 @@
<dd>{L_SEND_STATISTICS_LONG}</dd> <dd>{L_SEND_STATISTICS_LONG}</dd>
</dl> </dl>
</div> </div>
<script>
var statsData = {S_STATS_DATA};
</script>
<!-- EVENT acp_help_phpbb_stats_after --> <!-- EVENT acp_help_phpbb_stats_after -->
<fieldset> <fieldset>
<p class="submit-buttons"> <p class="submit-buttons">
<input type="hidden" name="systemdata" value="{RAW_DATA}" />
<input type="hidden" name="help_send_statistics_time" value="{COLLECT_STATS_TIME}" /> <input type="hidden" name="help_send_statistics_time" value="{COLLECT_STATS_TIME}" />
<input class="button1" type="submit" id="submit" name="submit" value="{L_SUBMIT}" /> <input class="button1" type="submit" id="submit" name="submit" value="{L_SUBMIT}" />
</p> </p>
@ -52,7 +54,11 @@
<form action="{U_COLLECT_STATS}" method="post" target="questionaire_result" id="questionnaire-form"> <form action="{U_COLLECT_STATS}" method="post" target="questionaire_result" id="questionnaire-form">
<fieldset> <fieldset>
<p class="submit-buttons"> <p class="submit-buttons">
<input type="hidden" name="systemdata" value="{RAW_DATA}" /> <!-- BEGIN providers -->
<!-- BEGIN values -->
<input type="hidden" name="{providers.NAME}[{providers.values.KEY}]" value="{providers.values.VALUE}" />
<!-- END values -->
<!-- END providers -->
<input class="button1" type="submit" id="submit_stats" name="submit" value="{L_SEND_STATISTICS}" /> <input class="button1" type="submit" id="submit_stats" name="submit" value="{L_SEND_STATISTICS}" />
</p> </p>
</fieldset> </fieldset>

View file

@ -1,4 +1,4 @@
/* global phpbb */ /* global phpbb, statsData */
(function($) { // Avoid conflicts with other libraries (function($) { // Avoid conflicts with other libraries
@ -87,7 +87,7 @@ phpbb.prepareSendStats = function () {
$.ajax({ $.ajax({
url: $this.attr('data-ajax-action').replace('&amp;', '&'), url: $this.attr('data-ajax-action').replace('&amp;', '&'),
type: 'POST', type: 'POST',
data: 'systemdata=' + encodeURIComponent($this.find('input[name=systemdata]').val()), data: statsData,
success: returnHandler, success: returnHandler,
error: errorHandler, error: errorHandler,
cache: false cache: false

View file

@ -32,7 +32,7 @@ class acp_help_phpbb
include($phpbb_root_path . 'includes/questionnaire/questionnaire.' . $phpEx); include($phpbb_root_path . 'includes/questionnaire/questionnaire.' . $phpEx);
} }
$collect_url = "https://www.phpbb.com/stats/receive_stats.php"; $collect_url = "https://www.phpbb.com/statistics/send";
$this->tpl_name = 'acp_help_phpbb'; $this->tpl_name = 'acp_help_phpbb';
$this->page_title = 'ACP_HELP_PHPBB'; $this->page_title = 'ACP_HELP_PHPBB';
@ -90,13 +90,15 @@ class acp_help_phpbb
if (!empty($response)) if (!empty($response))
{ {
if ((strpos($response, 'Thank you') !== false || strpos($response, 'Flood protection') !== false)) $decoded_response = json_decode($response, true);
if ($decoded_response && isset($decoded_response['status']) && $decoded_response['status'] == 'ok')
{ {
trigger_error($user->lang('THANKS_SEND_STATISTICS') . adm_back_link($this->u_action)); trigger_error($user->lang('THANKS_SEND_STATISTICS') . adm_back_link($this->u_action));
} }
else else
{ {
trigger_error($user->lang('FAIL_SEND_STATISTICS') . adm_back_link($this->u_action)); trigger_error($user->lang('FAIL_SEND_STATISTICS') . adm_back_link($this->u_action), E_USER_WARNING);
} }
} }
@ -106,7 +108,8 @@ class acp_help_phpbb
$template->assign_vars(array( $template->assign_vars(array(
'U_COLLECT_STATS' => $collect_url, 'U_COLLECT_STATS' => $collect_url,
'S_COLLECT_STATS' => (!empty($config['help_send_statistics'])) ? true : false, 'S_COLLECT_STATS' => (!empty($config['help_send_statistics'])) ? true : false,
'RAW_DATA' => $collector->get_data_for_form(), 'S_STATS' => $collector->get_data_raw(),
'S_STATS_DATA' => json_encode($collector->get_data_raw()),
'U_ACP_MAIN' => append_sid("{$phpbb_admin_path}index.$phpEx"), 'U_ACP_MAIN' => append_sid("{$phpbb_admin_path}index.$phpEx"),
'U_ACTION' => $this->u_action, 'U_ACTION' => $this->u_action,
// Pass earliest time we should try to send stats again // Pass earliest time we should try to send stats again

View file

@ -68,7 +68,7 @@ class phpbb_questionnaire_data_collector
function get_data_for_form() function get_data_for_form()
{ {
return base64_encode(serialize($this->get_data_raw())); return base64_encode(json_encode($this->get_data_raw()));
} }
/** /**
@ -124,7 +124,7 @@ class phpbb_questionnaire_php_data_provider
'zend.ze1_compatibility_mode' => (int) @ini_get('zend.ze1_compatibility_mode'), 'zend.ze1_compatibility_mode' => (int) @ini_get('zend.ze1_compatibility_mode'),
'unicode.semantics' => (int) @ini_get('unicode.semantics'), 'unicode.semantics' => (int) @ini_get('unicode.semantics'),
'zend_thread_safty' => (int) function_exists('zend_thread_id'), 'zend_thread_safty' => (int) function_exists('zend_thread_id'),
'extensions' => get_loaded_extensions(), 'extensions' => implode(",", get_loaded_extensions()),
); );
} }
} }