3b08b5bcf7190cee66e90e3db90b494871e35c68
3 * This script gathers system specification details for use with bug reporting
4 * and anyone else who needs it.
6 * @copyright 1999-2021 The SquirrelMail Project Team
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
10 * @subpackage bug_report
15 * converts array to string
17 * @param array $array array that has to be displayed
21 function Show_Array($array) {
23 foreach ($array as $key => $value) {
24 if ($key != 0 ||
$value != '') {
25 $str .= " * $key = $value\n";
29 return " * Nothing listed\n";
35 * converts plugin's array to string and adds version numbers
36 * @return string preformated text with installed plugin's information
39 function br_show_plugins() {
42 if (is_array($plugins) && $plugins!=array()) {
43 foreach ($plugins as $key => $plugin_name) {
45 // note that some plugins may not have been loaded up by now
46 // so we do that here to make sure... also turn on output
47 // buffering so they don't screw up our output with spacing
51 use_plugin($plugin_name);
54 if ($key != 0 ||
$plugin_name != '') {
55 $english_name = get_plugin_requirement($plugin_name, 'english_name');
56 $str .= " * $key = " . (!empty($english_name) ?
$english_name . " ($plugin_name) " : "$plugin_name ") . get_plugin_version($plugin_name, TRUE) . "\n";
59 // compatibility plugin can be used without needing to enable it in sm config
60 if (file_exists(SM_PATH
. 'plugins/compatibility/setup.php')
61 && ! in_array('compatibility',$plugins)) {
62 $str.= ' * Compatibility (compatibility) ' . get_plugin_version('compatibility', TRUE) . "\n";
66 return " * Nothing listed\n";
73 * Retrieve long text string containing semi-formatted (simple text
74 * with newlines and spaces for indentation) SquirrelMail system
77 * @return array A three-element array, the first element containing
78 * the string of system specs, the second one containing
79 * a list of any warnings that may have occurred, keyed
80 * by a warning "type" (which is used to key the corrections
81 * array next), and the third element of which is a list
82 * of sub-arrays keyed by warning "type": the sub-arrays
83 * are lists of correction messages associated with the
84 * warnings. The second and third return elements may
85 * be empty arrays if no warnings were found.
90 function get_system_specs() {
91 //FIXME: configtest and this plugin should be using the same code to generate the basic SM system specifications and setup detection
93 global $imapServerAddress, $username, $imapPort, $imap_server_type,
94 $use_imap_tls, $ldap_server;
96 // load required libraries
98 include_once(SM_PATH
. 'functions/imap_general.php');
100 $browscap = ini_get('browscap');
101 if(!empty($browscap)) {
102 $browser = get_browser();
106 $corrections = array();
108 sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER
);
109 if ( ! sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER
) )
110 $HTTP_USER_AGENT="Browser information is not available.";
112 $body_top = "My browser information:\n" .
113 ' '.$HTTP_USER_AGENT . "\n" ;
114 if(isset($browser)) {
115 $body_top .= " get_browser() information (List)\n" .
116 Show_Array((array) $browser);
118 $body_top .= "\nMy web server information:\n" .
119 " PHP Version " . phpversion() . "\n" .
120 " PHP Extensions (List)\n" .
121 Show_Array(get_loaded_extensions()) .
122 "\nSquirrelMail-specific information:\n" .
123 " Version: " . SM_VERSION
. "\n" .
124 " Plugins (List)\n" .
125 br_show_plugins() . "\n";
126 if (!empty($ldap_server[0]) && $ldap_server[0] && ! extension_loaded('ldap')) {
127 $warnings['ldap'] = "LDAP server defined in SquirrelMail config, " .
128 "but the module is not loaded in PHP";
129 $corrections['ldap'][] = "Reconfigure PHP with the option '--with-ldap'";
130 $corrections['ldap'][] = "Then recompile PHP and reinstall";
131 $corrections['ldap'][] = "-- OR --";
132 $corrections['ldap'][] = "Reconfigure SquirrelMail to not use LDAP";
135 $body = "\nMy IMAP server information:\n" .
136 " Server type: $imap_server_type\n";
138 $imapServerAddress = sqimap_get_user_server($imapServerAddress, $username);
139 $imap_stream = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls);
141 $body.= ' Capabilities: ';
142 if ($imap_capabilities = sqimap_capability($imap_stream)) {
143 foreach ($imap_capabilities as $capability => $value) {
144 if (is_array($value)) {
145 foreach($value as $val) {
146 $body .= $capability . "=$val ";
149 $body.= $capability . (is_bool($value) ?
' ' : "=$value ");
154 sqimap_logout($imap_stream);
156 $body .= " Unable to connect to IMAP server to get information.\n";
157 $warnings['imap'] = "Unable to connect to IMAP server";
158 $corrections['imap'][] = "Make sure you specified the correct mail server";
159 $corrections['imap'][] = "Make sure the mail server is running IMAP, not POP";
160 $corrections['imap'][] = "Make sure the server responds to port $imapPort";
163 if (!empty($warnings)) {
164 foreach ($warnings as $key => $value) {
165 if ($warning_num == 0) {
166 $body_top .= "WARNINGS WERE REPORTED WITH YOUR SETUP:\n";
167 $body_top = "WARNINGS WERE REPORTED WITH YOUR SETUP -- SEE BELOW\n\n$body_top";
170 $body_top .= "\n$value\n";
171 foreach ($corrections[$key] as $corr_val) {
172 $body_top .= " * $corr_val\n";
175 $body_top .= "\n$warning_num warning(s) reported.\n";
176 $body_top .= "----------------------------------------------\n";
179 $body = $body_top . $body;
181 return array($body, $warnings, $corrections);