system_specs.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /**
  3. * This gathers system specification details for use with bug reporting
  4. * and anyone else who needs it.
  5. *
  6. * Copyright (c) 1999-2004 The SquirrelMail development team
  7. * Licensed under the GNU GPL. For full terms see the file COPYING.
  8. *
  9. * This is a standard Squirrelmail-1.2 API for plugins.
  10. *
  11. * @version $Id$
  12. * @package plugins
  13. * @subpackage bug_report
  14. */
  15. /**
  16. * load required libraries
  17. */
  18. include_once(SM_PATH . 'include/validate.php');
  19. global $body;
  20. /**
  21. * converts array to string
  22. *
  23. * @param array $array array that has to be displayed
  24. * @return string
  25. * @access private
  26. */
  27. function Show_Array($array) {
  28. $str = '';
  29. foreach ($array as $key => $value) {
  30. if ($key != 0 || $value != '') {
  31. $str .= " * $key = $value\n";
  32. }
  33. }
  34. if ($str == '') {
  35. return " * Nothing listed\n";
  36. }
  37. return $str;
  38. }
  39. $browscap = ini_get('browscap');
  40. if(!empty($browscap)) {
  41. $browser = get_browser();
  42. }
  43. sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER);
  44. if ( ! sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER) )
  45. $HTTP_USER_AGENT="Browser information is not available.";
  46. $body_top = "My browser information:\n" .
  47. ' '.$HTTP_USER_AGENT . "\n" ;
  48. if(isset($browser)) {
  49. $body_top .= " get_browser() information (List)\n" .
  50. Show_Array((array) $browser);
  51. }
  52. $body_top .= "\nMy web server information:\n" .
  53. " PHP Version " . phpversion() . "\n" .
  54. " PHP Extensions (List)\n" .
  55. Show_Array(get_loaded_extensions()) .
  56. "\nSquirrelMail-specific information:\n" .
  57. " Version: $version\n" .
  58. " Plugins (List)\n" .
  59. Show_Array($plugins);
  60. if (isset($ldap_server) && $ldap_server[0] && ! extension_loaded('ldap')) {
  61. $warning = 1;
  62. $warnings['ldap'] = "LDAP server defined in SquirrelMail config, " .
  63. "but the module is not loaded in PHP";
  64. $corrections['ldap'][] = "Reconfigure PHP with the option '--with-ldap'";
  65. $corrections['ldap'][] = "Then recompile PHP and reinstall";
  66. $corrections['ldap'][] = "-- OR --";
  67. $corrections['ldap'][] = "Reconfigure SquirrelMail to not use LDAP";
  68. }
  69. $body = "\nMy IMAP server information:\n" .
  70. " Server type: $imap_server_type\n";
  71. $imap_stream = fsockopen ($imapServerAddress, $imapPort, $error_number, $error_string);
  72. $server_info = fgets ($imap_stream, 1024);
  73. if ($imap_stream) {
  74. // SUPRESS HOST NAME
  75. $list = explode(' ', $server_info);
  76. $list[2] = '[HIDDEN]';
  77. $server_info = implode(' ', $list);
  78. $body .= " Server info: $server_info";
  79. fputs ($imap_stream, "a001 CAPABILITY\r\n");
  80. $read = fgets($imap_stream, 1024);
  81. $list = explode(' ', $read);
  82. array_shift($list);
  83. array_shift($list);
  84. $read = implode(' ', $list);
  85. $body .= " Capabilities: $read";
  86. fputs ($imap_stream, "a002 LOGOUT\r\n");
  87. fclose($imap_stream);
  88. } else {
  89. $body .= " Unable to connect to IMAP server to get information.\n";
  90. $warning = 1;
  91. $warnings['imap'] = "Unable to connect to IMAP server";
  92. $corrections['imap'][] = "Make sure you specified the correct mail server";
  93. $corrections['imap'][] = "Make sure the mail server is running IMAP, not POP";
  94. $corrections['imap'][] = "Make sure the server responds to port $imapPort";
  95. }
  96. $warning_html = '';
  97. $warning_num = 0;
  98. if (isset($warning) && $warning) {
  99. foreach ($warnings as $key => $value) {
  100. if ($warning_num == 0) {
  101. $body_top .= "WARNINGS WERE REPORTED WITH YOUR SETUP:\n";
  102. $body_top = "WARNINGS WERE REPORTED WITH YOUR SETUP -- SEE BELOW\n\n$body_top";
  103. $warning_html = "<h1>Warnings were reported with your setup:</h1>\n<dl>\n";
  104. }
  105. $warning_num ++;
  106. $warning_html .= "<dt><b>$value</b></dt>\n";
  107. $body_top .= "\n$value\n";
  108. foreach ($corrections[$key] as $corr_val) {
  109. $body_top .= " * $corr_val\n";
  110. $warning_html .= "<dd>* $corr_val</dd>\n";
  111. }
  112. }
  113. $warning_html .= "</dl>\n<p>$warning_num warning(s) reported.</p>\n<hr>\n";
  114. $body_top .= "\n$warning_num warning(s) reported.\n";
  115. $body_top .= "----------------------------------------------\n";
  116. }
  117. $body = htmlspecialchars($body_top . $body);
  118. ?>