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