thicker border
[squirrelmail.git] / plugins / bug_report / system_specs.php
CommitLineData
595848f9 1<?php
4b4abf93 2
595848f9 3/**
4 * This gathers system specification details for use with bug reporting
5 * and anyone else who needs it.
6 *
598294a7 7 * This is a standard SquirrelMail 1.2 API for plugins.
595848f9 8 *
4b4abf93 9 * @copyright &copy; 1999-2005 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
3b43404b 11 * @version $Id$
12 * @package plugins
13 * @subpackage bug_report
595848f9 14 */
15
e1df9174 16/** @ignore */
17if (!defined('SM_PATH')) define('SM_PATH','../../');
18
3b43404b 19/**
20 * load required libraries
21 */
595848f9 22include_once(SM_PATH . 'include/validate.php');
110691ca 23include_once(SM_PATH . 'functions/imap.php');
24global $body, $username;
595848f9 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 */
34function 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
38b88e48 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 */
52function 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
f8a1ed5a 67 if (file_exists(SM_PATH . 'plugins/compatibility/setup.php')
38b88e48 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
595848f9 83$browscap = ini_get('browscap');
84if(!empty($browscap)) {
85 $browser = get_browser();
86}
87
88sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER);
89if ( ! 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" .
38b88e48 105 br_show_plugins();
595848f9 106if (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";
110691ca 118
119$imapServerAddress = sqimap_get_user_server($imapServerAddress, $username);
120$imap_stream = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls);
595848f9 121if ($imap_stream) {
110691ca 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);
595848f9 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;
140if (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 }
3c621ba1 155 $warning_html .= "</dl>\n<p>$warning_num warning(s) reported.</p>\n<hr />\n";
595848f9 156 $body_top .= "\n$warning_num warning(s) reported.\n";
157 $body_top .= "----------------------------------------------\n";
158}
159
160$body = htmlspecialchars($body_top . $body);
161
3c621ba1 162?>