error_report.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Handle error report submission
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. require_once 'libraries/common.inc.php';
  9. require_once 'libraries/error_report.lib.php';
  10. $response = PMA_Response::getInstance();
  11. if (isset($_REQUEST['send_error_report'])
  12. && $_REQUEST['send_error_report'] == true
  13. ) {
  14. $server_response = PMA_sendErrorReport(PMA_getReportData(false));
  15. if ($server_response === false) {
  16. $success = false;
  17. } else {
  18. $decoded_response = json_decode($server_response, true);
  19. $success = !empty($decoded_response) ? $decoded_response["success"] : false;
  20. }
  21. if (isset($_REQUEST['automatic'])
  22. && $_REQUEST['automatic'] === "true"
  23. ) {
  24. if ($success) {
  25. $response->addJSON(
  26. 'message',
  27. PMA_Message::error(
  28. __(
  29. 'An error has been detected and an error report has been '
  30. . 'automatically submitted based on your settings.'
  31. )
  32. . '<br />'
  33. . __('You may want to refresh the page.')
  34. )
  35. );
  36. } else {
  37. $response->addJSON(
  38. 'message',
  39. PMA_Message::error(
  40. __(
  41. 'An error has been detected and an error report has been '
  42. . 'generated but failed to be sent.'
  43. )
  44. . ' '
  45. . __(
  46. 'If you experience any '
  47. . 'problems please submit a bug report manually.'
  48. )
  49. . '<br />'
  50. . __('You may want to refresh the page.')
  51. )
  52. );
  53. }
  54. } else {
  55. if ($success) {
  56. $response->addJSON(
  57. 'message',
  58. PMA_Message::success(
  59. __('Thank you for submitting this report.')
  60. . '<br />'
  61. . __('You may want to refresh the page.')
  62. )
  63. );
  64. } else {
  65. $response->addJSON(
  66. 'message',
  67. PMA_Message::error(
  68. __('Thank you for submitting this report.')
  69. . ' '
  70. . __('Unfortunately the submission failed.')
  71. . ' '
  72. . __(
  73. 'If you experience any '
  74. . 'problems please submit a bug report manually.'
  75. )
  76. . '<br />'
  77. . __('You may want to refresh the page.')
  78. )
  79. );
  80. }
  81. if (isset($_REQUEST['always_send'])
  82. && $_REQUEST['always_send'] === "true"
  83. ) {
  84. PMA_persistOption("SendErrorReports", "always", "ask");
  85. }
  86. }
  87. } elseif (! empty($_REQUEST['get_settings'])) {
  88. $response->addJSON('report_setting', $GLOBALS['cfg']['SendErrorReports']);
  89. } else {
  90. $response->addHTML(PMA_getErrorReportForm());
  91. }