updating error_box() function calls. second argument was modified.
[squirrelmail.git] / plugins / spamcop / spamcop.php
1 <?php
2
3 /**
4 * spamcop.php -- SpamCop plugin -- main page
5 *
6 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 * @version $Id$
9 * @package plugins
10 * @subpackage spamcop
11 */
12
13 /**
14 * Include the SquirrelMail initialization file.
15 */
16 require('../../include/init.php');
17
18 include_once(SM_PATH . 'functions/imap_general.php');
19 include_once(SM_PATH . 'functions/imap_messages.php');
20 /* plugin functions */
21 include_once(SM_PATH . 'plugins/spamcop/functions.php');
22
23 /* GLOBALS */
24
25 sqgetGlobalVar('username', $username, SQ_SESSION);
26
27 sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
28 sqgetGlobalVar('passed_id', $passed_id, SQ_GET);
29 sqgetGlobalVar('js_web', $js_web, SQ_GET);
30
31 if (! sqgetGlobalVar('startMessage', $startMessage, SQ_GET) ) {
32 $startMessage = 1;
33 }
34 if (! sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) {
35 $passed_ent_id = 0;
36 }
37 if (! sqgetGlobalVar('js_web', $js_web, SQ_GET) ) {
38 $js_web = 0;
39 }
40
41 sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION);
42
43 if(! sqgetGlobalVar('composesession', $composesession, SQ_SESSION) ) {
44 $composesession = 0;
45 sqsession_register($composesession, 'composesession');
46 }
47 /* END GLOBALS */
48
49 // js_web variable is 1 only when link opens web based report page in new window
50 // and in new window menu line or extra javascript code is not needed.
51 if ($js_web) {
52 displayHTMLHeader(_("SpamCop reporting"));
53 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n";
54 } else {
55 displayPageHeader($color,$mailbox);
56 }
57
58 /** is spamcop plugin disabled */
59 if (! is_plugin_enabled('spamcop')) {
60 error_box(_("Plugin is disabled."));
61 // display footer (closes html tags) and stop script execution
62 $oTemplate->display('footer.tpl');
63 exit();
64 }
65
66 $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
67 sqimap_mailbox_select($imap_stream, $mailbox);
68
69 if ($spamcop_method == 'quick_email' ||
70 $spamcop_method == 'thorough_email') {
71 // Use email-based reporting -- save as an attachment
72 $session = "$composesession"+1;
73 $composesession = $session;
74 sqsession_register($composesession,'composesession');
75 if (!isset($compose_messages)) {
76 $compose_messages = array();
77 }
78 if (!isset($compose_messages[$session]) || ($compose_messages[$session] == NULL)) {
79 $composeMessage = new Message();
80 $rfc822_header = new Rfc822Header();
81 $composeMessage->rfc822_header = $rfc822_header;
82 $composeMessage->reply_rfc822_header = '';
83 $compose_messages[$session] = $composeMessage;
84 sqsession_register($compose_messages,'compose_messages');
85 } else {
86 $composeMessage=$compose_messages[$session];
87 }
88
89
90 $message = sqimap_get_message($imap_stream, $passed_id, $mailbox);
91 $composeMessage = spamcop_getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
92 $passed_ent_id, $imap_stream);
93
94 $compose_messages[$session] = $composeMessage;
95 sqsession_register($compose_messages, 'compose_messages');
96
97 $fn = getPref($data_dir, $username, 'full_name');
98 $em = getPref($data_dir, $username, 'email_address');
99
100 $HowItLooks = $fn . ' ';
101 if ($em != '')
102 $HowItLooks .= '<' . $em . '>';
103 }
104
105
106 echo "<p>";
107 echo _("Sending this spam report will give you back a reply with URLs that you can click on to properly report this spam message to the proper authorities. This is a free service. By pressing the \"Send Spam Report\" button, you agree to follow SpamCop's rules/terms of service/etc.");
108 echo "</p>";
109
110 ?>
111
112 <table align="center" width="75%" border="0" cellpadding="0" cellspacing="0">
113 <tr>
114 <td align="left" valign="top">
115 <?php if (isset($js_web) && $js_web) {
116 echo '<form method="post" action="javascript:return false">';
117 echo '<input type="button" value="' . _("Close Window") . "\" onclick=\"window.close(); return true;\" />\n";
118 } else {
119 ?><form method="post" action="../../src/right_main.php">
120 <input type="hidden" name="mailbox" value="<?php echo htmlspecialchars($mailbox) ?>" />
121 <input type="hidden" name="startMessage" value="<?php echo htmlspecialchars($startMessage) ?>" />
122 <?php
123 echo '<input type="submit" value="' . _("Cancel / Done") . "\" />";
124 }
125 ?></form>
126 </td>
127 <td align="right" valign="top">
128 <?php if ($spamcop_method == 'thorough_email' ||
129 $spamcop_method == 'quick_email') {
130 if ($spamcop_method == 'thorough_email')
131 $report_email = 'submit.' . $spamcop_id . '@spam.spamcop.net';
132 else
133 $report_email = 'quick.' . $spamcop_id . '@spam.spamcop.net';
134 $form_action = SM_PATH . 'src/compose.php';
135 ?> <form method="post" action="<?php echo $form_action?>">
136 <input type="hidden" name="mailbox" value="<?php echo htmlspecialchars($mailbox) ?>" />
137 <input type="hidden" name="spamcop_is_composing" value="<?php echo htmlspecialchars($passed_id) ?>" />
138 <input type="hidden" name="send_to" value="<?php echo htmlspecialchars($report_email)?>" />
139 <input type="hidden" name="subject" value="reply anyway" />
140 <input type="hidden" name="identity" value="0" />
141 <input type="hidden" name="session" value="<?php echo $session?>" />
142 <?php
143 echo '<input type="submit" name="send" value="' . _("Send Spam Report") . "\" />\n";
144 } else {
145 $spam_message = mime_fetch_body ($imap_stream, $passed_id, $passed_ent_id, 50000);
146
147 if (strlen($spam_message) == 50000) {
148 $Warning = "\n[truncated by SpamCop]\n";
149 $spam_message = substr($spam_message, 0, 50000 - strlen($Warning)) . $Warning;
150 }
151 if ($spamcop_type=='member') {
152 $action_url="http://members.spamcop.net/sc";
153 } else {
154 $action_url="http://www.spamcop.net/sc";
155 }
156 if (isset($js_web) && $js_web) {
157 echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
158 " enctype=\"multipart/form-data\">\n";
159 } else {
160 echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
161 " enctype=\"multipart/form-data\" target=\"_blank\">\n";
162 } ?>
163 <input type="hidden" name="action" value="submit" />
164 <input type="hidden" name="oldverbose" value="1" />
165 <input type="hidden" name="code" value="<?php echo htmlspecialchars($spamcop_id) ?>" />
166 <input type="hidden" name="spam" value="<?php echo htmlspecialchars($spam_message); ?>" />
167 <?php
168 echo '<input type="submit" name="x1" value="' . _("Send Spam Report") . "\" />\n";
169 }
170 ?> </form>
171 </td>
172 </tr>
173 </table>
174 </body>
175 </html>