updating error_box() function calls. second argument was modified.
[squirrelmail.git] / plugins / spamcop / spamcop.php
CommitLineData
5121598d 1<?php
4b4abf93 2
91e0dccc 3/**
f3a91d6b 4 * spamcop.php -- SpamCop plugin -- main page
5 *
47ccfad4 6 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
f3a91d6b 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 * @version $Id$
9 * @package plugins
10 * @subpackage spamcop
11 */
5121598d 12
202bcbcc 13/**
14 * Include the SquirrelMail initialization file.
15 */
16require('../../include/init.php');
7afb9a75 17
202bcbcc 18include_once(SM_PATH . 'functions/imap_general.php');
19include_once(SM_PATH . 'functions/imap_messages.php');
da297dd0 20/* plugin functions */
21include_once(SM_PATH . 'plugins/spamcop/functions.php');
1e89ed41 22
8ddc4111 23/* GLOBALS */
04f6008a 24
8ddc4111 25sqgetGlobalVar('username', $username, SQ_SESSION);
8ddc4111 26
27sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
28sqgetGlobalVar('passed_id', $passed_id, SQ_GET);
9a422982 29sqgetGlobalVar('js_web', $js_web, SQ_GET);
8ddc4111 30
31if (! sqgetGlobalVar('startMessage', $startMessage, SQ_GET) ) {
32 $startMessage = 1;
33}
34if (! sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) {
9a422982 35 $passed_ent_id = 0;
36}
37if (! sqgetGlobalVar('js_web', $js_web, SQ_GET) ) {
38 $js_web = 0;
8ddc4111 39}
40
41sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION);
42
43if(! sqgetGlobalVar('composesession', $composesession, SQ_SESSION) ) {
44 $composesession = 0;
45 sqsession_register($composesession, 'composesession');
46}
47/* END GLOBALS */
1e89ed41 48
9a422982 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.
51if ($js_web) {
7d56f214 52 displayHTMLHeader(_("SpamCop reporting"));
9a422982 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}
5121598d 57
da297dd0 58/** is spamcop plugin disabled */
59if (! is_plugin_enabled('spamcop')) {
1b858d86 60 error_box(_("Plugin is disabled."));
61 // display footer (closes html tags) and stop script execution
62 $oTemplate->display('footer.tpl');
da297dd0 63 exit();
64}
65
045ec1a1 66 $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
5121598d 67 sqimap_mailbox_select($imap_stream, $mailbox);
5121598d 68
91e0dccc 69 if ($spamcop_method == 'quick_email' ||
5121598d 70 $spamcop_method == 'thorough_email') {
71 // Use email-based reporting -- save as an attachment
1e89ed41 72 $session = "$composesession"+1;
73 $composesession = $session;
74 sqsession_register($composesession,'composesession');
75 if (!isset($compose_messages)) {
76 $compose_messages = array();
430be822 77 }
1e89ed41 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;
91e0dccc 84 sqsession_register($compose_messages,'compose_messages');
1e89ed41 85 } else {
86 $composeMessage=$compose_messages[$session];
430be822 87 }
88
04f6008a 89
1e89ed41 90 $message = sqimap_get_message($imap_stream, $passed_id, $mailbox);
2b42190d 91 $composeMessage = spamcop_getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
9a422982 92 $passed_ent_id, $imap_stream);
1e89ed41 93
91e0dccc 94 $compose_messages[$session] = $composeMessage;
95 sqsession_register($compose_messages, 'compose_messages');
1e89ed41 96
97 $fn = getPref($data_dir, $username, 'full_name');
98 $em = getPref($data_dir, $username, 'email_address');
99
100 $HowItLooks = $fn . ' ';
101 if ($em != '')
5121598d 102 $HowItLooks .= '<' . $em . '>';
1e89ed41 103 }
5121598d 104
5121598d 105
2bd52bbe 106echo "<p>";
99aaff8b 107echo _("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.");
2bd52bbe 108echo "</p>";
109
110?>
5121598d 111
8ddc4111 112<table align="center" width="75%" border="0" cellpadding="0" cellspacing="0">
5121598d 113<tr>
8ddc4111 114<td align="left" valign="top">
6fd95361 115<?php if (isset($js_web) && $js_web) {
7d56f214 116 echo '<form method="post" action="javascript:return false">';
c435f076 117 echo '<input type="button" value="' . _("Close Window") . "\" onclick=\"window.close(); return true;\" />\n";
5121598d 118} else {
8ddc4111 119 ?><form method="post" action="../../src/right_main.php">
6fd95361 120 <input type="hidden" name="mailbox" value="<?php echo htmlspecialchars($mailbox) ?>" />
121 <input type="hidden" name="startMessage" value="<?php echo htmlspecialchars($startMessage) ?>" />
122<?php
7d56f214 123 echo '<input type="submit" value="' . _("Cancel / Done") . "\" />";
5121598d 124}
125 ?></form>
126</td>
8ddc4111 127<td align="right" valign="top">
6fd95361 128<?php if ($spamcop_method == 'thorough_email' ||
5121598d 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';
1e89ed41 134 $form_action = SM_PATH . 'src/compose.php';
6fd95361 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)?>" />
7d56f214 139 <input type="hidden" name="subject" value="reply anyway" />
140 <input type="hidden" name="identity" value="0" />
6fd95361 141 <input type="hidden" name="session" value="<?php echo $session?>" />
7d56f214 142<?php
143 echo '<input type="submit" name="send" value="' . _("Send Spam Report") . "\" />\n";
144} else {
9a422982 145 $spam_message = mime_fetch_body ($imap_stream, $passed_id, $passed_ent_id, 50000);
9538cd4c 146
2b5fddf5 147 if (strlen($spam_message) == 50000) {
5121598d 148 $Warning = "\n[truncated by SpamCop]\n";
2b5fddf5 149 $spam_message = substr($spam_message, 0, 50000 - strlen($Warning)) . $Warning;
5121598d 150 }
9a422982 151 if ($spamcop_type=='member') {
152 $action_url="http://members.spamcop.net/sc";
153 } else {
154 $action_url="http://www.spamcop.net/sc";
155 }
5121598d 156 if (isset($js_web) && $js_web) {
9a422982 157 echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
158 " enctype=\"multipart/form-data\">\n";
5121598d 159 } else {
9a422982 160 echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
161 " enctype=\"multipart/form-data\" target=\"_blank\">\n";
5121598d 162 } ?>
7d56f214 163 <input type="hidden" name="action" value="submit" />
164 <input type="hidden" name="oldverbose" value="1" />
6fd95361 165 <input type="hidden" name="code" value="<?php echo htmlspecialchars($spamcop_id) ?>" />
166 <input type="hidden" name="spam" value="<?php echo htmlspecialchars($spam_message); ?>" />
7d56f214 167 <?php
91e0dccc 168 echo '<input type="submit" name="x1" value="' . _("Send Spam Report") . "\" />\n";
7d56f214 169 }
5121598d 170?> </form>
171</td>
172</tr>
173</table>
7d56f214 174</body>
91e0dccc 175</html>