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