system_specs.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. /**
  3. * This script gathers system specification details for use with bug reporting
  4. * and anyone else who needs it.
  5. *
  6. * @copyright &copy; 1999-2007 The SquirrelMail Project Team
  7. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8. * @version $Id$
  9. * @package plugins
  10. * @subpackage bug_report
  11. */
  12. /**
  13. * do not allow to call this file directly
  14. */
  15. if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) {
  16. header("Location: ../../src/login.php");
  17. die();
  18. }
  19. /**
  20. * load required libraries
  21. */
  22. include_once(SM_PATH . 'functions/imap_general.php');
  23. /**
  24. * converts array to string
  25. *
  26. * @param array $array array that has to be displayed
  27. * @return string
  28. * @access private
  29. */
  30. function Show_Array($array) {
  31. $str = '';
  32. foreach ($array as $key => $value) {
  33. if ($key != 0 || $value != '') {
  34. $str .= " * $key = $value\n";
  35. }
  36. }
  37. if ($str == '') {
  38. return " * Nothing listed\n";
  39. }
  40. return $str;
  41. }
  42. /**
  43. * converts plugin's array to string and adds version numbers
  44. * @return string preformated text with installed plugin's information
  45. * @access private
  46. */
  47. function br_show_plugins() {
  48. global $plugins;
  49. $str = '';
  50. if (is_array($plugins) && $plugins!=array()) {
  51. foreach ($plugins as $key => $value) {
  52. if ($key != 0 || $value != '') {
  53. $str .= " * $key = $value " . get_plugin_version($value, TRUE) . "\n";
  54. }
  55. }
  56. // compatibility plugin can be used without needing to enable it in sm config
  57. if (file_exists(SM_PATH . 'plugins/compatibility/setup.php')
  58. && ! in_array('compatibility',$plugins)) {
  59. $str.= ' * compatibility ' . get_plugin_version('compatibility', TRUE) . "\n";
  60. }
  61. }
  62. if ($str == '') {
  63. return " * Nothing listed\n";
  64. }
  65. return $str;
  66. }
  67. $browscap = ini_get('browscap');
  68. if(!empty($browscap)) {
  69. $browser = get_browser();
  70. }
  71. sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER);
  72. if ( ! sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER) )
  73. $HTTP_USER_AGENT="Browser information is not available.";
  74. $body_top = "My browser information:\n" .
  75. ' '.$HTTP_USER_AGENT . "\n" ;
  76. if(isset($browser)) {
  77. $body_top .= " get_browser() information (List)\n" .
  78. Show_Array((array) $browser);
  79. }
  80. $body_top .= "\nMy web server information:\n" .
  81. " PHP Version " . phpversion() . "\n" .
  82. " PHP Extensions (List)\n" .
  83. Show_Array(get_loaded_extensions()) .
  84. "\nSquirrelMail-specific information:\n" .
  85. " Version: $version\n" .
  86. " Plugins (List)\n" .
  87. br_show_plugins();
  88. if (isset($ldap_server) && $ldap_server[0] && ! extension_loaded('ldap')) {
  89. $warning = 1;
  90. $warnings['ldap'] = "LDAP server defined in SquirrelMail config, " .
  91. "but the module is not loaded in PHP";
  92. $corrections['ldap'][] = "Reconfigure PHP with the option '--with-ldap'";
  93. $corrections['ldap'][] = "Then recompile PHP and reinstall";
  94. $corrections['ldap'][] = "-- OR --";
  95. $corrections['ldap'][] = "Reconfigure SquirrelMail to not use LDAP";
  96. }
  97. $body = "\nMy IMAP server information:\n" .
  98. " Server type: $imap_server_type\n";
  99. $imapServerAddress = sqimap_get_user_server($imapServerAddress, $username);
  100. $imap_stream = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls);
  101. if ($imap_stream) {
  102. $body.= ' Capabilities: ';
  103. if ($imap_capabilities = sqimap_capability($imap_stream)) {
  104. foreach ($imap_capabilities as $capability => $value) {
  105. $body.= $capability . (is_bool($value) ? ' ' : "=$value ");
  106. }
  107. }
  108. $body.="\n";
  109. sqimap_logout($imap_stream);
  110. } else {
  111. $body .= " Unable to connect to IMAP server to get information.\n";
  112. $warning = 1;
  113. $warnings['imap'] = "Unable to connect to IMAP server";
  114. $corrections['imap'][] = "Make sure you specified the correct mail server";
  115. $corrections['imap'][] = "Make sure the mail server is running IMAP, not POP";
  116. $corrections['imap'][] = "Make sure the server responds to port $imapPort";
  117. }
  118. $warning_html = '';
  119. $warning_num = 0;
  120. if (isset($warning) && $warning) {
  121. foreach ($warnings as $key => $value) {
  122. if ($warning_num == 0) {
  123. $body_top .= "WARNINGS WERE REPORTED WITH YOUR SETUP:\n";
  124. $body_top = "WARNINGS WERE REPORTED WITH YOUR SETUP -- SEE BELOW\n\n$body_top";
  125. $warning_html = "<h1>Warnings were reported with your setup:</h1>\n<dl>\n";
  126. }
  127. $warning_num ++;
  128. $warning_html .= "<dt><b>$value</b></dt>\n";
  129. $body_top .= "\n$value\n";
  130. foreach ($corrections[$key] as $corr_val) {
  131. $body_top .= " * $corr_val\n";
  132. $warning_html .= "<dd>* $corr_val</dd>\n";
  133. }
  134. }
  135. $warning_html .= "</dl>\n<p>$warning_num warning(s) reported.</p>\n<hr />\n";
  136. $body_top .= "\n$warning_num warning(s) reported.\n";
  137. $body_top .= "----------------------------------------------\n";
  138. }
  139. $body = htmlspecialchars($body_top . $body);