XHTML fixes
[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-2004 The SquirrelMail development 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 /**
17 * load required libraries
18 */
19 include_once(SM_PATH . 'include/validate.php');
20 global $body;
21
22
23 /**
24 * converts array to string
25 *
26 * @param array $array array that has to be displayed
27 * @return string
28 * @access private
29 */
30 function Show_Array($array) {
31 $str = '';
32 foreach ($array as $key => $value) {
33 if ($key != 0 || $value != '') {
34 $str .= " * $key = $value\n";
35 }
36 }
37 if ($str == '') {
38 return " * Nothing listed\n";
39 }
40 return $str;
41 }
42
43 $browscap = ini_get('browscap');
44 if(!empty($browscap)) {
45 $browser = get_browser();
46 }
47
48 sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER);
49 if ( ! sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER) )
50 $HTTP_USER_AGENT="Browser information is not available.";
51
52 $body_top = "My browser information:\n" .
53 ' '.$HTTP_USER_AGENT . "\n" ;
54 if(isset($browser)) {
55 $body_top .= " get_browser() information (List)\n" .
56 Show_Array((array) $browser);
57 }
58 $body_top .= "\nMy web server information:\n" .
59 " PHP Version " . phpversion() . "\n" .
60 " PHP Extensions (List)\n" .
61 Show_Array(get_loaded_extensions()) .
62 "\nSquirrelMail-specific information:\n" .
63 " Version: $version\n" .
64 " Plugins (List)\n" .
65 Show_Array($plugins);
66 if (isset($ldap_server) && $ldap_server[0] && ! extension_loaded('ldap')) {
67 $warning = 1;
68 $warnings['ldap'] = "LDAP server defined in SquirrelMail config, " .
69 "but the module is not loaded in PHP";
70 $corrections['ldap'][] = "Reconfigure PHP with the option '--with-ldap'";
71 $corrections['ldap'][] = "Then recompile PHP and reinstall";
72 $corrections['ldap'][] = "-- OR --";
73 $corrections['ldap'][] = "Reconfigure SquirrelMail to not use LDAP";
74 }
75
76 $body = "\nMy IMAP server information:\n" .
77 " Server type: $imap_server_type\n";
78 $imap_stream = fsockopen ($imapServerAddress, $imapPort, $error_number, $error_string);
79 $server_info = fgets ($imap_stream, 1024);
80 if ($imap_stream) {
81 // SUPRESS HOST NAME
82 $list = explode(' ', $server_info);
83 $list[2] = '[HIDDEN]';
84 $server_info = implode(' ', $list);
85 $body .= " Server info: $server_info";
86 fputs ($imap_stream, "a001 CAPABILITY\r\n");
87 $read = fgets($imap_stream, 1024);
88 $list = explode(' ', $read);
89 array_shift($list);
90 array_shift($list);
91 $read = implode(' ', $list);
92 $body .= " Capabilities: $read";
93 fputs ($imap_stream, "a002 LOGOUT\r\n");
94 fclose($imap_stream);
95 } else {
96 $body .= " Unable to connect to IMAP server to get information.\n";
97 $warning = 1;
98 $warnings['imap'] = "Unable to connect to IMAP server";
99 $corrections['imap'][] = "Make sure you specified the correct mail server";
100 $corrections['imap'][] = "Make sure the mail server is running IMAP, not POP";
101 $corrections['imap'][] = "Make sure the server responds to port $imapPort";
102 }
103 $warning_html = '';
104 $warning_num = 0;
105 if (isset($warning) && $warning) {
106 foreach ($warnings as $key => $value) {
107 if ($warning_num == 0) {
108 $body_top .= "WARNINGS WERE REPORTED WITH YOUR SETUP:\n";
109 $body_top = "WARNINGS WERE REPORTED WITH YOUR SETUP -- SEE BELOW\n\n$body_top";
110 $warning_html = "<h1>Warnings were reported with your setup:</h1>\n<dl>\n";
111 }
112 $warning_num ++;
113 $warning_html .= "<dt><b>$value</b></dt>\n";
114 $body_top .= "\n$value\n";
115 foreach ($corrections[$key] as $corr_val) {
116 $body_top .= " * $corr_val\n";
117 $warning_html .= "<dd>* $corr_val</dd>\n";
118 }
119 }
120 $warning_html .= "</dl>\n<p>$warning_num warning(s) reported.</p>\n<hr />\n";
121 $body_top .= "\n$warning_num warning(s) reported.\n";
122 $body_top .= "----------------------------------------------\n";
123 }
124
125 $body = htmlspecialchars($body_top . $body);
126
127 ?>