Syntax error fix
[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 " . get_plugin_version($value, TRUE) . "\n";
61 }
62 }
63 // compatibility plugin can be used without needing to enable it in sm config
64 if (file_exists(SM_PATH . 'plugins/compatibility/setup.php')
65 && ! in_array('compatibility',$plugins)) {
66 $str.= ' * compatibility ' . get_plugin_version('compatibility', TRUE) . "\n";
67 }
68 }
69 if ($str == '') {
70 return " * Nothing listed\n";
71 }
72 return $str;
73 }
74
75 $browscap = ini_get('browscap');
76 if(!empty($browscap)) {
77 $browser = get_browser();
78 }
79
80 sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER);
81 if ( ! sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER) )
82 $HTTP_USER_AGENT="Browser information is not available.";
83
84 $body_top = "My browser information:\n" .
85 ' '.$HTTP_USER_AGENT . "\n" ;
86 if(isset($browser)) {
87 $body_top .= " get_browser() information (List)\n" .
88 Show_Array((array) $browser);
89 }
90 $body_top .= "\nMy web server information:\n" .
91 " PHP Version " . phpversion() . "\n" .
92 " PHP Extensions (List)\n" .
93 Show_Array(get_loaded_extensions()) .
94 "\nSquirrelMail-specific information:\n" .
95 " Version: $version\n" .
96 " Plugins (List)\n" .
97 br_show_plugins();
98 if (isset($ldap_server) && $ldap_server[0] && ! extension_loaded('ldap')) {
99 $warning = 1;
100 $warnings['ldap'] = "LDAP server defined in SquirrelMail config, " .
101 "but the module is not loaded in PHP";
102 $corrections['ldap'][] = "Reconfigure PHP with the option '--with-ldap'";
103 $corrections['ldap'][] = "Then recompile PHP and reinstall";
104 $corrections['ldap'][] = "-- OR --";
105 $corrections['ldap'][] = "Reconfigure SquirrelMail to not use LDAP";
106 }
107
108 $body = "\nMy IMAP server information:\n" .
109 " Server type: $imap_server_type\n";
110
111 $imapServerAddress = sqimap_get_user_server($imapServerAddress, $username);
112 $imap_stream = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls);
113 if ($imap_stream) {
114 $body.= ' Capabilities: ';
115 if ($imap_capabilities = sqimap_capability($imap_stream)) {
116 foreach ($imap_capabilities as $capability => $value) {
117 $body.= $capability . (is_bool($value) ? ' ' : "=$value ");
118 }
119 }
120 $body.="\n";
121 sqimap_logout($imap_stream);
122 } else {
123 $body .= " Unable to connect to IMAP server to get information.\n";
124 $warning = 1;
125 $warnings['imap'] = "Unable to connect to IMAP server";
126 $corrections['imap'][] = "Make sure you specified the correct mail server";
127 $corrections['imap'][] = "Make sure the mail server is running IMAP, not POP";
128 $corrections['imap'][] = "Make sure the server responds to port $imapPort";
129 }
130 $warning_html = '';
131 $warning_num = 0;
132 if (isset($warning) && $warning) {
133 foreach ($warnings as $key => $value) {
134 if ($warning_num == 0) {
135 $body_top .= "WARNINGS WERE REPORTED WITH YOUR SETUP:\n";
136 $body_top = "WARNINGS WERE REPORTED WITH YOUR SETUP -- SEE BELOW\n\n$body_top";
137 $warning_html = "<h1>Warnings were reported with your setup:</h1>\n<dl>\n";
138 }
139 $warning_num ++;
140 $warning_html .= "<dt><b>$value</b></dt>\n";
141 $body_top .= "\n$value\n";
142 foreach ($corrections[$key] as $corr_val) {
143 $body_top .= " * $corr_val\n";
144 $warning_html .= "<dd>* $corr_val</dd>\n";
145 }
146 }
147 $warning_html .= "</dl>\n<p>$warning_num warning(s) reported.</p>\n<hr />\n";
148 $body_top .= "\n$warning_num warning(s) reported.\n";
149 $body_top .= "----------------------------------------------\n";
150 }
151
152 $body = htmlspecialchars($body_top . $body);