forked from phpmyadmin/phpmyadmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_report.php
144 lines (127 loc) · 4.7 KB
/
error_report.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Display the form to edit/create an index
*
* @package PhpMyAdmin
*/
/**
* Gets some core libraries
*/
require_once 'libraries/common.inc.php';
require_once 'libraries/Index.class.php';
require_once 'libraries/tbl_info.inc.php';
require_once 'libraries/user_preferences.lib.php';
$submission_url="localhost/phpmyadminserver/reports/new";
$response = PMA_Response::getInstance();
if ($_REQUEST['send_error_report'] == true) {
send_error_report(get_report_data(false));
if ($_REQUEST['automatic'] == true) {
$response->addJSON('message', PMA_Message::error(
__('An error has been detected and an error report has been '
.'automatically submitted based on your settings.')
. '<br />'
. __('You may want to refresh the page.')));
} else {
$response->addJSON('message', PMA_Message::success(
__('Thank you for submitting this report.')
. '<br />'
. __('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 .= '<form action="error_report.php" method="post" name="report_frm"'
.' id="report_frm" class="ajax">'
.'<fieldset style="padding-top:0px">';
$html .= '<p>'
. __('Phpmyadmin has encountered an error. We have collected data about'
.' this error as well as information about relevant configuration'
.' settings to send to phpmyadmin for processing to help us in'
.' debugging the problem')
.'</p>';
$html .= '<div class="label"><label><p>'
. __('You may examine the data in the error report:')
.'</p></label></div>'
.'<textarea cols="80" style="height:13em; overflow:scroll" disabled>'
.get_report_data()
.'</textarea>';
$html .= '<div class="label"><label><p>'
. __('Please explain the steps that lead to the error:')
.'</p></label></div>'
.'<textarea cols="80" style="height:10em" name="description"'
.'id="report_description"></textarea>';
$html .= '<input type="checkbox" name="always_send"'
.' id="always_send_checkbox"/>'
.'<span>'
. __('Automatically send report next time')
.'</span>';
$html .= '</fieldset>';
$form_params = array(
'db' => $db,
'table' => $table,
);
$html .= PMA_generate_common_hidden_inputs($form_params);
$html .= PMA_getHiddenFields(get_report_data(false));
$html .= '</form>';
$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(
"error_message" => $_REQUEST['message'],
"line_number" => $_REQUEST['line'],
"file" => $_REQUEST['file'],
"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 $result the reply of the server
*/
function send_error_report($report) {
$data_string = json_encode($report);
$ch = curl_init($submission_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
return $result;
}
?>