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