595848f9 |
1 | <?php |
595848f9 |
2 | /** |
2329d86d |
3 | * This script gathers system specification details for use with bug reporting |
595848f9 |
4 | * and anyone else who needs it. |
5 | * |
d4e46166 |
6 | * @copyright © 1999-2009 The SquirrelMail Project Team |
4b4abf93 |
7 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
3b43404b |
8 | * @version $Id$ |
9 | * @package plugins |
10 | * @subpackage bug_report |
595848f9 |
11 | */ |
12 | |
595848f9 |
13 | |
14 | /** |
15 | * converts array to string |
16 | * |
17 | * @param array $array array that has to be displayed |
18 | * @return string |
19 | * @access private |
20 | */ |
21 | function Show_Array($array) { |
22 | $str = ''; |
23 | foreach ($array as $key => $value) { |
24 | if ($key != 0 || $value != '') { |
25 | $str .= " * $key = $value\n"; |
26 | } |
27 | } |
28 | if ($str == '') { |
29 | return " * Nothing listed\n"; |
30 | } |
31 | return $str; |
32 | } |
33 | |
38b88e48 |
34 | /** |
35 | * converts plugin's array to string and adds version numbers |
36 | * @return string preformated text with installed plugin's information |
37 | * @access private |
38 | */ |
39 | function br_show_plugins() { |
40 | global $plugins; |
41 | $str = ''; |
42 | if (is_array($plugins) && $plugins!=array()) { |
1a219da9 |
43 | foreach ($plugins as $key => $plugin_name) { |
44 | |
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 |
48 | // or newlines |
49 | // |
50 | ob_start(); |
51 | use_plugin($plugin_name); |
52 | ob_end_clean(); |
53 | |
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"; |
38b88e48 |
57 | } |
58 | } |
d95b10b3 |
59 | // compatibility plugin can be used without needing to enable it in sm config |
f8a1ed5a |
60 | if (file_exists(SM_PATH . 'plugins/compatibility/setup.php') |
38b88e48 |
61 | && ! in_array('compatibility',$plugins)) { |
1a219da9 |
62 | $str.= ' * Compatibility (compatibility) ' . get_plugin_version('compatibility', TRUE) . "\n"; |
38b88e48 |
63 | } |
64 | } |
65 | if ($str == '') { |
66 | return " * Nothing listed\n"; |
67 | } |
68 | return $str; |
69 | } |
70 | |
595848f9 |
71 | |
1a219da9 |
72 | /** |
73 | * Retrieve long text string containing semi-formatted (simple text |
74 | * with newlines and spaces for indentation) SquirrelMail system |
75 | * specs |
76 | * |
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. |
86 | * |
87 | * @since 1.5.2 |
88 | * |
89 | */ |
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 |
92 | |
93 | global $imapServerAddress, $username, $imapPort, $imap_server_type, |
94 | $use_imap_tls, $ldap_server; |
595848f9 |
95 | |
1a219da9 |
96 | // load required libraries |
97 | // |
98 | include_once(SM_PATH . 'functions/imap_general.php'); |
99 | |
100 | $browscap = ini_get('browscap'); |
101 | if(!empty($browscap)) { |
102 | $browser = get_browser(); |
103 | } |
104 | |
105 | $warnings = array(); |
106 | $corrections = array(); |
107 | |
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."; |
111 | |
112 | $body_top = "My browser information:\n" . |
595848f9 |
113 | ' '.$HTTP_USER_AGENT . "\n" ; |
114 | if(isset($browser)) { |
115 | $body_top .= " get_browser() information (List)\n" . |
116 | Show_Array((array) $browser); |
117 | } |
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" . |
1a219da9 |
123 | " Version: " . SM_VERSION . "\n" . |
595848f9 |
124 | " Plugins (List)\n" . |
1a219da9 |
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"; |
133 | } |
595848f9 |
134 | |
1a219da9 |
135 | $body = "\nMy IMAP server information:\n" . |
595848f9 |
136 | " Server type: $imap_server_type\n"; |
110691ca |
137 | |
1a219da9 |
138 | $imapServerAddress = sqimap_get_user_server($imapServerAddress, $username); |
139 | $imap_stream = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls); |
140 | if ($imap_stream) { |
141 | $body.= ' Capabilities: '; |
142 | if ($imap_capabilities = sqimap_capability($imap_stream)) { |
143 | foreach ($imap_capabilities as $capability => $value) { |
144 | $body.= $capability . (is_bool($value) ? ' ' : "=$value "); |
145 | } |
110691ca |
146 | } |
1a219da9 |
147 | $body.="\n"; |
148 | sqimap_logout($imap_stream); |
149 | } else { |
150 | $body .= " Unable to connect to IMAP server to get information.\n"; |
151 | $warnings['imap'] = "Unable to connect to IMAP server"; |
152 | $corrections['imap'][] = "Make sure you specified the correct mail server"; |
153 | $corrections['imap'][] = "Make sure the mail server is running IMAP, not POP"; |
154 | $corrections['imap'][] = "Make sure the server responds to port $imapPort"; |
110691ca |
155 | } |
1a219da9 |
156 | $warning_num = 0; |
157 | if (!empty($warnings)) { |
158 | foreach ($warnings as $key => $value) { |
159 | if ($warning_num == 0) { |
160 | $body_top .= "WARNINGS WERE REPORTED WITH YOUR SETUP:\n"; |
161 | $body_top = "WARNINGS WERE REPORTED WITH YOUR SETUP -- SEE BELOW\n\n$body_top"; |
162 | } |
163 | $warning_num ++; |
164 | $body_top .= "\n$value\n"; |
165 | foreach ($corrections[$key] as $corr_val) { |
166 | $body_top .= " * $corr_val\n"; |
167 | } |
595848f9 |
168 | } |
1a219da9 |
169 | $body_top .= "\n$warning_num warning(s) reported.\n"; |
170 | $body_top .= "----------------------------------------------\n"; |
595848f9 |
171 | } |
1a219da9 |
172 | |
173 | $body = $body_top . $body; |
174 | |
175 | return array($body, $warnings, $corrections); |
176 | |
595848f9 |
177 | } |
178 | |
1a219da9 |
179 | |