increment year in copyright notices
[squirrelmail.git] / plugins / bug_report / system_specs.php
CommitLineData
595848f9 1<?php
595848f9 2/**
2329d86d 3 * This script gathers system specification details for use with bug reporting
595848f9 4 * and anyone else who needs it.
5 *
4b5049de 6 * @copyright &copy; 1999-2007 The SquirrelMail Project Team
4b4abf93 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
3b43404b 8 * @version $Id$
9 * @package plugins
10 * @subpackage bug_report
595848f9 11 */
12
202bcbcc 13/**
14 * do not allow to call this file directly
15 */
24afb0e9 16if ((isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) ||
17 (isset($HTTP_SERVER_SERVER['SCRIPT_FILENAME']) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__) ) {
202bcbcc 18 header("Location: ../../src/login.php");
19 die();
20}
e1df9174 21
3b43404b 22/**
23 * load required libraries
24 */
202bcbcc 25include_once(SM_PATH . 'functions/imap_general.php');
26
595848f9 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 */
36function 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
38b88e48 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 */
54function 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";
61 // add plugin version
62 if (function_exists($value . '_version')) {
63 $str.= ' ' . call_user_func($value . '_version');
64 }
65 $str.="\n";
66 }
67 }
68 // compatibility plugin can be used without need to enable it in sm config
f8a1ed5a 69 if (file_exists(SM_PATH . 'plugins/compatibility/setup.php')
38b88e48 70 && ! in_array('compatibility',$plugins)) {
71 $str.= ' * compatibility';
72 include_once(SM_PATH . 'plugins/compatibility/setup.php');
73 if (function_exists('compatibility_version')) {
74 $str.= ' ' . call_user_func('compatibility_version');
75 }
76 $str.="\n";
77 }
78 }
79 if ($str == '') {
80 return " * Nothing listed\n";
81 }
82 return $str;
83}
84
595848f9 85$browscap = ini_get('browscap');
86if(!empty($browscap)) {
87 $browser = get_browser();
88}
89
90sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER);
91if ( ! sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER) )
92 $HTTP_USER_AGENT="Browser information is not available.";
93
94$body_top = "My browser information:\n" .
95 ' '.$HTTP_USER_AGENT . "\n" ;
96 if(isset($browser)) {
97 $body_top .= " get_browser() information (List)\n" .
98 Show_Array((array) $browser);
99 }
100 $body_top .= "\nMy web server information:\n" .
101 " PHP Version " . phpversion() . "\n" .
102 " PHP Extensions (List)\n" .
103 Show_Array(get_loaded_extensions()) .
104 "\nSquirrelMail-specific information:\n" .
105 " Version: $version\n" .
106 " Plugins (List)\n" .
38b88e48 107 br_show_plugins();
595848f9 108if (isset($ldap_server) && $ldap_server[0] && ! extension_loaded('ldap')) {
109 $warning = 1;
110 $warnings['ldap'] = "LDAP server defined in SquirrelMail config, " .
111 "but the module is not loaded in PHP";
112 $corrections['ldap'][] = "Reconfigure PHP with the option '--with-ldap'";
113 $corrections['ldap'][] = "Then recompile PHP and reinstall";
114 $corrections['ldap'][] = "-- OR --";
115 $corrections['ldap'][] = "Reconfigure SquirrelMail to not use LDAP";
116}
117
118$body = "\nMy IMAP server information:\n" .
119 " Server type: $imap_server_type\n";
110691ca 120
121$imapServerAddress = sqimap_get_user_server($imapServerAddress, $username);
122$imap_stream = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls);
595848f9 123if ($imap_stream) {
110691ca 124 $body.= ' Capabilities: ';
125 if ($imap_capabilities = sqimap_capability($imap_stream)) {
126 foreach ($imap_capabilities as $capability => $value) {
127 $body.= $capability . (is_bool($value) ? ' ' : "=$value ");
128 }
129 }
130 $body.="\n";
131 sqimap_logout($imap_stream);
595848f9 132} else {
133 $body .= " Unable to connect to IMAP server to get information.\n";
134 $warning = 1;
135 $warnings['imap'] = "Unable to connect to IMAP server";
136 $corrections['imap'][] = "Make sure you specified the correct mail server";
137 $corrections['imap'][] = "Make sure the mail server is running IMAP, not POP";
138 $corrections['imap'][] = "Make sure the server responds to port $imapPort";
139}
140$warning_html = '';
141$warning_num = 0;
142if (isset($warning) && $warning) {
143 foreach ($warnings as $key => $value) {
144 if ($warning_num == 0) {
145 $body_top .= "WARNINGS WERE REPORTED WITH YOUR SETUP:\n";
146 $body_top = "WARNINGS WERE REPORTED WITH YOUR SETUP -- SEE BELOW\n\n$body_top";
147 $warning_html = "<h1>Warnings were reported with your setup:</h1>\n<dl>\n";
148 }
149 $warning_num ++;
150 $warning_html .= "<dt><b>$value</b></dt>\n";
151 $body_top .= "\n$value\n";
152 foreach ($corrections[$key] as $corr_val) {
153 $body_top .= " * $corr_val\n";
154 $warning_html .= "<dd>* $corr_val</dd>\n";
155 }
156 }
3c621ba1 157 $warning_html .= "</dl>\n<p>$warning_num warning(s) reported.</p>\n<hr />\n";
595848f9 158 $body_top .= "\n$warning_num warning(s) reported.\n";
159 $body_top .= "----------------------------------------------\n";
160}
161
162$body = htmlspecialchars($body_top . $body);