Use <plugin>_info() function if at all possible instead of <plugin>_version()
[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
7af343f1 62 $version_found = FALSE;
63 if (function_exists($value . '_info')) {
64 $info = call_user_func($value . '_info');
65 if (!empty($info['version'])) {
66 $str .= ' ' . $info['version'];
67 $version_found = TRUE;
68 }
69 }
70 if (!$version_found && function_exists($value . '_version')) {
38b88e48 71 $str.= ' ' . call_user_func($value . '_version');
72 }
73 $str.="\n";
74 }
75 }
76 // compatibility plugin can be used without need to enable it in sm config
f8a1ed5a 77 if (file_exists(SM_PATH . 'plugins/compatibility/setup.php')
38b88e48 78 && ! in_array('compatibility',$plugins)) {
79 $str.= ' * compatibility';
80 include_once(SM_PATH . 'plugins/compatibility/setup.php');
81 if (function_exists('compatibility_version')) {
82 $str.= ' ' . call_user_func('compatibility_version');
83 }
84 $str.="\n";
85 }
86 }
87 if ($str == '') {
88 return " * Nothing listed\n";
89 }
90 return $str;
91}
92
595848f9 93$browscap = ini_get('browscap');
94if(!empty($browscap)) {
95 $browser = get_browser();
96}
97
98sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER);
99if ( ! sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER) )
100 $HTTP_USER_AGENT="Browser information is not available.";
101
102$body_top = "My browser information:\n" .
103 ' '.$HTTP_USER_AGENT . "\n" ;
104 if(isset($browser)) {
105 $body_top .= " get_browser() information (List)\n" .
106 Show_Array((array) $browser);
107 }
108 $body_top .= "\nMy web server information:\n" .
109 " PHP Version " . phpversion() . "\n" .
110 " PHP Extensions (List)\n" .
111 Show_Array(get_loaded_extensions()) .
112 "\nSquirrelMail-specific information:\n" .
113 " Version: $version\n" .
114 " Plugins (List)\n" .
38b88e48 115 br_show_plugins();
595848f9 116if (isset($ldap_server) && $ldap_server[0] && ! extension_loaded('ldap')) {
117 $warning = 1;
118 $warnings['ldap'] = "LDAP server defined in SquirrelMail config, " .
119 "but the module is not loaded in PHP";
120 $corrections['ldap'][] = "Reconfigure PHP with the option '--with-ldap'";
121 $corrections['ldap'][] = "Then recompile PHP and reinstall";
122 $corrections['ldap'][] = "-- OR --";
123 $corrections['ldap'][] = "Reconfigure SquirrelMail to not use LDAP";
124}
125
126$body = "\nMy IMAP server information:\n" .
127 " Server type: $imap_server_type\n";
110691ca 128
129$imapServerAddress = sqimap_get_user_server($imapServerAddress, $username);
130$imap_stream = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls);
595848f9 131if ($imap_stream) {
110691ca 132 $body.= ' Capabilities: ';
133 if ($imap_capabilities = sqimap_capability($imap_stream)) {
134 foreach ($imap_capabilities as $capability => $value) {
135 $body.= $capability . (is_bool($value) ? ' ' : "=$value ");
136 }
137 }
138 $body.="\n";
139 sqimap_logout($imap_stream);
595848f9 140} else {
141 $body .= " Unable to connect to IMAP server to get information.\n";
142 $warning = 1;
143 $warnings['imap'] = "Unable to connect to IMAP server";
144 $corrections['imap'][] = "Make sure you specified the correct mail server";
145 $corrections['imap'][] = "Make sure the mail server is running IMAP, not POP";
146 $corrections['imap'][] = "Make sure the server responds to port $imapPort";
147}
148$warning_html = '';
149$warning_num = 0;
150if (isset($warning) && $warning) {
151 foreach ($warnings as $key => $value) {
152 if ($warning_num == 0) {
153 $body_top .= "WARNINGS WERE REPORTED WITH YOUR SETUP:\n";
154 $body_top = "WARNINGS WERE REPORTED WITH YOUR SETUP -- SEE BELOW\n\n$body_top";
155 $warning_html = "<h1>Warnings were reported with your setup:</h1>\n<dl>\n";
156 }
157 $warning_num ++;
158 $warning_html .= "<dt><b>$value</b></dt>\n";
159 $body_top .= "\n$value\n";
160 foreach ($corrections[$key] as $corr_val) {
161 $body_top .= " * $corr_val\n";
162 $warning_html .= "<dd>* $corr_val</dd>\n";
163 }
164 }
3c621ba1 165 $warning_html .= "</dl>\n<p>$warning_num warning(s) reported.</p>\n<hr />\n";
595848f9 166 $body_top .= "\n$warning_num warning(s) reported.\n";
167 $body_top .= "----------------------------------------------\n";
168}
169
170$body = htmlspecialchars($body_top . $body);