system_specs.php 5.5 KB

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