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