Allow plugins to require CORE plugins
[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 */
f627180c 16if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) {
202bcbcc 17 header("Location: ../../src/login.php");
18 die();
19}
e1df9174 20
3b43404b 21/**
22 * load required libraries
23 */
202bcbcc 24include_once(SM_PATH . 'functions/imap_general.php');
25
595848f9 26
27
28/**
29 * converts array to string
30 *
31 * @param array $array array that has to be displayed
32 * @return string
33 * @access private
34 */
35function Show_Array($array) {
36 $str = '';
37 foreach ($array as $key => $value) {
38 if ($key != 0 || $value != '') {
39 $str .= " * $key = $value\n";
40 }
41 }
42 if ($str == '') {
43 return " * Nothing listed\n";
44 }
45 return $str;
46}
47
38b88e48 48/**
49 * converts plugin's array to string and adds version numbers
50 * @return string preformated text with installed plugin's information
51 * @access private
52 */
53function br_show_plugins() {
54 global $plugins;
55 $str = '';
56 if (is_array($plugins) && $plugins!=array()) {
57 foreach ($plugins as $key => $value) {
58 if ($key != 0 || $value != '') {
d95b10b3 59 $str .= " * $key = $value " . get_plugin_version($value, TRUE) . "\n";
38b88e48 60 }
61 }
d95b10b3 62 // compatibility plugin can be used without needing to enable it in sm config
f8a1ed5a 63 if (file_exists(SM_PATH . 'plugins/compatibility/setup.php')
38b88e48 64 && ! in_array('compatibility',$plugins)) {
d95b10b3 65 $str.= ' * compatibility ' . get_plugin_version('compatibility', TRUE) . "\n";
38b88e48 66 }
67 }
68 if ($str == '') {
69 return " * Nothing listed\n";
70 }
71 return $str;
72}
73
595848f9 74$browscap = ini_get('browscap');
75if(!empty($browscap)) {
76 $browser = get_browser();
77}
78
79sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER);
80if ( ! sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER) )
81 $HTTP_USER_AGENT="Browser information is not available.";
82
83$body_top = "My browser information:\n" .
84 ' '.$HTTP_USER_AGENT . "\n" ;
85 if(isset($browser)) {
86 $body_top .= " get_browser() information (List)\n" .
87 Show_Array((array) $browser);
88 }
89 $body_top .= "\nMy web server information:\n" .
90 " PHP Version " . phpversion() . "\n" .
91 " PHP Extensions (List)\n" .
92 Show_Array(get_loaded_extensions()) .
93 "\nSquirrelMail-specific information:\n" .
94 " Version: $version\n" .
95 " Plugins (List)\n" .
38b88e48 96 br_show_plugins();
595848f9 97if (isset($ldap_server) && $ldap_server[0] && ! extension_loaded('ldap')) {
98 $warning = 1;
99 $warnings['ldap'] = "LDAP server defined in SquirrelMail config, " .
100 "but the module is not loaded in PHP";
101 $corrections['ldap'][] = "Reconfigure PHP with the option '--with-ldap'";
102 $corrections['ldap'][] = "Then recompile PHP and reinstall";
103 $corrections['ldap'][] = "-- OR --";
104 $corrections['ldap'][] = "Reconfigure SquirrelMail to not use LDAP";
105}
106
107$body = "\nMy IMAP server information:\n" .
108 " Server type: $imap_server_type\n";
110691ca 109
110$imapServerAddress = sqimap_get_user_server($imapServerAddress, $username);
111$imap_stream = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls);
595848f9 112if ($imap_stream) {
110691ca 113 $body.= ' Capabilities: ';
114 if ($imap_capabilities = sqimap_capability($imap_stream)) {
115 foreach ($imap_capabilities as $capability => $value) {
116 $body.= $capability . (is_bool($value) ? ' ' : "=$value ");
117 }
118 }
119 $body.="\n";
120 sqimap_logout($imap_stream);
595848f9 121} else {
122 $body .= " Unable to connect to IMAP server to get information.\n";
123 $warning = 1;
124 $warnings['imap'] = "Unable to connect to IMAP server";
125 $corrections['imap'][] = "Make sure you specified the correct mail server";
126 $corrections['imap'][] = "Make sure the mail server is running IMAP, not POP";
127 $corrections['imap'][] = "Make sure the server responds to port $imapPort";
128}
129$warning_html = '';
130$warning_num = 0;
131if (isset($warning) && $warning) {
132 foreach ($warnings as $key => $value) {
133 if ($warning_num == 0) {
134 $body_top .= "WARNINGS WERE REPORTED WITH YOUR SETUP:\n";
135 $body_top = "WARNINGS WERE REPORTED WITH YOUR SETUP -- SEE BELOW\n\n$body_top";
136 $warning_html = "<h1>Warnings were reported with your setup:</h1>\n<dl>\n";
137 }
138 $warning_num ++;
139 $warning_html .= "<dt><b>$value</b></dt>\n";
140 $body_top .= "\n$value\n";
141 foreach ($corrections[$key] as $corr_val) {
142 $body_top .= " * $corr_val\n";
143 $warning_html .= "<dd>* $corr_val</dd>\n";
144 }
145 }
3c621ba1 146 $warning_html .= "</dl>\n<p>$warning_num warning(s) reported.</p>\n<hr />\n";
595848f9 147 $body_top .= "\n$warning_num warning(s) reported.\n";
148 $body_top .= "----------------------------------------------\n";
149}
150
151$body = htmlspecialchars($body_top . $body);