Some code cleanups to read_body.php
[squirrelmail.git] / plugins / bug_report / bug_report.php
CommitLineData
15e6162e 1<?php
2
3/**
4 * bug_report.php
5 *
6 * This generates the bug report data, gives information about where
7 * it will be sent to and what people will do with it, and provides
8 * a button to show the bug report mail message in order to actually
9 * send it.
10 *
11 * Copyright (c) 1999-2002 The SquirrelMail development team
12 * Licensed under the GNU GPL. For full terms see the file COPYING.
13 *
14 * This is a standard Squirrelmail-1.2 API for plugins.
15 *
16 * $Id$
17 */
d79e01f5 18
d79e01f5 19session_start();
aa7fb30c 20chdir('..');
21define('SM_PATH','../');
d79e01f5 22
aa7fb30c 23require_once(SM_PATH . 'config/config.php');
24require_once(SM_PATH . 'functions/strings.php');
25require_once(SM_PATH . 'functions/page_header.php');
26require_once(SM_PATH . 'functions/display_messages.php');
27require_once(SM_PATH . 'functions/imap.php');
28require_once(SM_PATH . 'functions/array.php');
29require_once(SM_PATH . 'functions/i18n.php');
30require_once(SM_PATH . 'include/load_prefs.php');
0b0e96c5 31displayPageHeader($color, 'None');
d79e01f5 32
33
34function Show_Array($array) {
07aeb697 35 $str = '';
d79e01f5 36 foreach ($array as $key => $value) {
37 if ($key != 0 || $value != '') {
38 $str .= " * $key = $value\n";
39 }
40 }
41 if ($str == '') {
42 return " * Nothing listed\n";
43 }
44 return $str;
45}
46
47$browser = get_browser();
07aeb697 48$body_top = "I subscribe to the squirrelmail-users mailing list.\n" .
d79e01f5 49 " [ ] True - No need to CC me when replying\n" .
50 " [ ] False - Please CC me when replying\n" .
51 "\n" .
52 "This bug occurs when I ...\n" .
53 " ... view a particular message\n" .
54 " ... use a specific plugin/function\n" .
55 " ... try to do/view/use ....\n" .
56 "\n\n\n" .
57 "The description of the bug:\n\n\n" .
58 "I can reproduce the bug by:\n\n\n" .
59 "(Optional) I got bored and found the bug occurs in:\n\n\n" .
60 "(Optional) I got really bored and here's a fix:\n\n\n" .
61 "----------------------------------------------\n" .
62 "\nMy browser information:\n" .
63 " $HTTP_USER_AGENT\n" .
64 " get_browser() information (List)\n" .
65 Show_Array((array) $browser) .
66 "\nMy web server information:\n" .
67 " PHP Version " . phpversion() . "\n" .
68 " PHP Extensions (List)\n" .
69 Show_Array(get_loaded_extensions()) .
70 "\nSquirrelMail-specific information:\n" .
71 " Version: $version\n" .
72 " Plugins (List)\n" .
73 Show_Array($plugins);
07aeb697 74if (isset($ldap_server) && $ldap_server[0] && ! extension_loaded('ldap')) {
d79e01f5 75 $warning = 1;
76 $warnings['ldap'] = "LDAP server defined in SquirrelMail config, " .
77 "but the module is not loaded in PHP";
78 $corrections['ldap'][] = "Reconfigure PHP with the option '--with-ldap'";
79 $corrections['ldap'][] = "Then recompile PHP and reinstall";
80 $corrections['ldap'][] = "-- OR --";
81 $corrections['ldap'][] = "Reconfigure SquirrelMail to not use LDAP";
82}
83
07aeb697 84$body = "\nMy IMAP server information:\n" .
d79e01f5 85 " Server type: $imap_server_type\n";
7a0d72ee 86$imap_stream = fsockopen ($imapServerAddress, $imapPort, $error_number, $error_string);
d79e01f5 87$server_info = fgets ($imap_stream, 1024);
88if ($imap_stream) {
89 // SUPRESS HOST NAME
90 $list = explode(' ', $server_info);
91 $list[2] = '[HIDDEN]';
92 $server_info = implode(' ', $list);
93 $body .= " Server info: $server_info";
94 fputs ($imap_stream, "a001 CAPABILITY\r\n");
95 $read = fgets($imap_stream, 1024);
96 $list = explode(' ', $read);
97 array_shift($list);
98 array_shift($list);
99 $read = implode(' ', $list);
100 $body .= " Cabailities: $read";
101 fputs ($imap_stream, "a002 LOGOUT\r\n");
102 fclose($imap_stream);
103} else {
104 $body .= " Unable to connect to IMAP server to get information.\n";
105 $warning = 1;
106 $warnings['imap'] = "Unable to connect to IMAP server";
107 $corrections['imap'][] = "Make sure you specified the correct mail server";
108 $corrections['imap'][] = "Make sure the mail server is running IMAP, not POP";
109 $corrections['imap'][] = "Make sure the server responds to port $imapPort";
110}
07aeb697 111$warning_html = '';
d79e01f5 112$warning_num = 0;
07aeb697 113if (isset($warning) && $warning) {
d79e01f5 114 foreach ($warnings as $key => $value) {
115 if ($warning_num == 0) {
116 $body_top .= "WARNINGS WERE REPORTED WITH YOUR SETUP:\n";
117 $body_top = "WARNINGS WERE REPORTED WITH YOUR SETUP -- SEE BELOW\n\n$body_top";
118 $warning_html = "<h1>Warnings were reported with your setup:</h1>\n<dl>\n";
119 }
120 $warning_num ++;
121 $warning_html .= "<dt><b>$value</b></dt>\n";
122 $body_top .= "\n$value\n";
123 foreach ($corrections[$key] as $corr_val) {
124 $body_top .= " * $corr_val\n";
125 $warning_html .= "<dd>* $corr_val</dd>\n";
126 }
127 }
128 $warning_html .= "</dl>\n<p>$warning_num warning(s) reported.</p>\n<hr>\n";
129 $body_top .= "\n$warning_num warning(s) reported.\n";
130 $body_top .= "----------------------------------------------\n";
131}
132
133$body = htmlspecialchars($body_top . $body);
15e6162e 134
135?>
136 <br>
137 <table width=95% align=center border=0 cellpadding=2 cellspacing=0><tr><td bgcolor="<?php echo $color[0] ?>">
138 <center><b>Submit a Bug Report</b></center>
139 </td></tr></table>
140
141 <?PHP echo $warning_html; ?>
142
143 <p><font size="+1">Before you send your bug report</font>, please make sure to
144 check this checklist for any common problems.</p>
d79e01f5 145
15e6162e 146 <ul>
d79e01f5 147 <li>Make sure that you are running the most recent copy of
15e6162e 148 <a href="http://www.squirrelmail.org/">SquirrelMail</a>. You are currently
149 using version <?PHP echo $version ?>.</li>
150 <li>Check to see if you bug is already listed in the
151 <a href="http://sourceforge.net/bugs/?group_id=311">Bug List</a> on SourceForge.
152 If it is, we already know about it and are trying to fix it.</li>
153 <li>Try to make sure that you can repeat it. If the bug happens
154 sporatically, try to document what you did when it happened. If it
d79e01f5 155 always occurs when you view a specific message, keep that message around
15e6162e 156 so maybe we can see it.</li>
157 <li>If there were warnings displayed above, try to resolve them yourself.
158 Read the guides in the <tt>doc/</tt> directory where SquirrelMail was
159 installed.</li>
160 </ul>
d79e01f5 161
15e6162e 162 <p>Pressing the button below will start a mail message to the developers
163 of SquirrelMail that will contain a lot of information about your system,
164 your browser, how SquirrelMail is set up, and your IMAP server. It will
165 also prompt you for information. Just fill out the sections at the top.
166 If you like, you can scroll down in the message to see what else is being
167 sent.</p>
d79e01f5 168
15e6162e 169 <p>Please make sure to fill out as much information as you possibly can to
170 give everyone a good chance of finding and removing the bug. Submitting
171 your bug like this will not have it automatically added to the bug list on
172 SourceForge, but someone who gets your message may add it for you.</p>
173
174 <form action="../../src/compose.php" method=post>
175 <table align=center border=0>
176 <tr>
177 <td>
178 This bug involves: <select name="send_to">
d7d5829a 179 <option value="squirrelmail-users@lists.sourceforge.net">the general program</option>
15e6162e 180 <option value="squirrelmail-plugins@lists.sourceforge.net">a specific plugin</option>
181 </select>
182 </td>
183 </tr>
184 <tr>
185 <td align=center>
186 <input type="hidden" name="send_to_cc" value="">
187 <input type="hidden" name="send_to_bcc" value="">
188 <input type="hidden" name="subject" value="Bug Report">
189 <input type="hidden" name="body" value="<?PHP echo $body ?>">
190 <input type="submit" value="Start Bug Report Form">
191 </td>
192 </tr>
193 </table>
194 </form>
7a0d72ee 195</body></html>