addJSON('message', PMA_Message::error(
__('An error has been detected and an error report has been '
.'automatically submitted based on your settings.')
. '
'
. __('You may want to refresh the page.')));
} else {
$response->addJSON('message', PMA_Message::success(
__('Thank you for submitting this report.')
. '
'
. __('You may want to refresh the page.')));
if($_REQUEST['always_send'] === "true") {
PMA_persistOption("SendErrorReports", "always", "ask");
}
}
} elseif ($_REQUEST['get_settings']) {
$response->addJSON('report_setting', $GLOBALS['cfg']['SendErrorReports']);
} else {
$html = "";
$html .= '
';
$response->addHTML($html);
}
/**
* returns the error report data collected from the current configuration or
* from the request parameters sent by the error reporting js code.
*
* @param boolean $json_encode whether to encode the array as a json string
*
* @return Array/String $report
*/
function get_report_data($json_encode = true) {
$report = array(
"exception" => $_REQUEST['exception'],
"pma_version" => PMA_VERSION,
"browser_agent" => PMA_USR_BROWSER_AGENT,
"browser_version" => PMA_USR_BROWSER_VER,
"operating_system" => PMA_USR_OS,
"user_agent_string" => $_SERVER['HTTP_USER_AGENT'],
"current_locale" => $_COOKIE['pma_lang'],
"current_url" => $_REQUEST['current_url'],
"configuration_storage_enabled" =>
!empty($GLOBALS['cfg']['Servers'][1]['pmadb']),
"php_version" => phpversion(),
"microhistory" => $_REQUEST['microhistory'],
);
if(!empty($_REQUEST['description'])) {
$report['description'] = $_REQUEST['description'];
}
if($json_encode) {
return json_encode($report, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
} else {
return $report;
}
}
/**
* Sends report data to the error reporting server
*
* @param Array $report the report info to be sent
*
* @return String $response the reply of the server
*/
function send_error_report($report) {
$data_string = json_encode($report);
if (ini_get('allow_url_fopen')) {
if (strlen($cfg['VersionCheckProxyUrl'])) {
$context = array(
'method' => 'POST',
'header' => 'Content-type: application/json',
'content' => $data_string,
'http' => array(
'proxy' => $cfg['VersionCheckProxyUrl'],
'request_fulluri' => true
)
);
if (strlen($cfg['VersionCheckProxyUser'])) {
$auth = base64_encode(
$cfg['VersionCheckProxyUser'] . ':' . $cfg['VersionCheckProxyPass']
);
$context['http']['header'] = 'Proxy-Authorization: Basic ' . $auth;
}
$response = file_get_contents(
$submission_url,
false,
stream_context_create($context)
);
} else {
$response = file_get_contents($file);
}
} else if (function_exists('curl_init')) {
$curl_handle = curl_init($submission_url);
if (strlen($cfg['VersionCheckProxyUrl'])) {
curl_setopt($curl_handle, CURLOPT_PROXY, $cfg['VersionCheckProxyUrl']);
if (strlen($cfg['VersionCheckProxyUser'])) {
curl_setopt(
$curl_handle,
CURLOPT_PROXYUSERPWD,
$cfg['VersionCheckProxyUser'] . ':' . $cfg['VersionCheckProxyPass']
);
}
}
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($curl_handle);
}
return $response;
}
?>