Add compatibility with Dovecot's bigint UIDs
[squirrelmail.git] / plugins / spamcop / spamcop.php
CommitLineData
5121598d 1<?php
4b4abf93 2
91e0dccc 3/**
f3a91d6b 4 * spamcop.php -- SpamCop plugin -- main page
5 *
4b5049de 6 * @copyright &copy; 1999-2007 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');
13a35bde 17/* IMAP functions depend on date and mime */
18include_once(SM_PATH . 'functions/date.php');
19include_once(SM_PATH . 'functions/mime.php');
20/* IMAP functions */
202bcbcc 21include_once(SM_PATH . 'functions/imap_general.php');
22include_once(SM_PATH . 'functions/imap_messages.php');
da297dd0 23/* plugin functions */
24include_once(SM_PATH . 'plugins/spamcop/functions.php');
1e89ed41 25
628bce99 26include_once(SM_PATH . 'functions/compose.php');
27
8ddc4111 28/* GLOBALS */
04f6008a 29
8ddc4111 30sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
51bbe8fa 31sqgetGlobalVar('passed_id', $passed_id, SQ_GET, NULL, SQ_TYPE_BIGINT);
9a422982 32sqgetGlobalVar('js_web', $js_web, SQ_GET);
8ddc4111 33
34if (! sqgetGlobalVar('startMessage', $startMessage, SQ_GET) ) {
35 $startMessage = 1;
36}
37if (! sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) {
9a422982 38 $passed_ent_id = 0;
39}
40if (! sqgetGlobalVar('js_web', $js_web, SQ_GET) ) {
41 $js_web = 0;
8ddc4111 42}
43
44sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION);
45
46if(! sqgetGlobalVar('composesession', $composesession, SQ_SESSION) ) {
47 $composesession = 0;
48 sqsession_register($composesession, 'composesession');
49}
50/* END GLOBALS */
1e89ed41 51
9a422982 52// js_web variable is 1 only when link opens web based report page in new window
53// and in new window menu line or extra javascript code is not needed.
54if ($js_web) {
7d56f214 55 displayHTMLHeader(_("SpamCop reporting"));
9a422982 56 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n";
57} else {
58 displayPageHeader($color,$mailbox);
59}
5121598d 60
da297dd0 61/** is spamcop plugin disabled */
62if (! is_plugin_enabled('spamcop')) {
1b858d86 63 error_box(_("Plugin is disabled."));
64 // display footer (closes html tags) and stop script execution
65 $oTemplate->display('footer.tpl');
da297dd0 66 exit();
67}
68
045ec1a1 69 $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
5121598d 70 sqimap_mailbox_select($imap_stream, $mailbox);
5121598d 71
91e0dccc 72 if ($spamcop_method == 'quick_email' ||
5121598d 73 $spamcop_method == 'thorough_email') {
74 // Use email-based reporting -- save as an attachment
1e89ed41 75 $session = "$composesession"+1;
76 $composesession = $session;
77 sqsession_register($composesession,'composesession');
78 if (!isset($compose_messages)) {
79 $compose_messages = array();
430be822 80 }
1e89ed41 81 if (!isset($compose_messages[$session]) || ($compose_messages[$session] == NULL)) {
82 $composeMessage = new Message();
83 $rfc822_header = new Rfc822Header();
84 $composeMessage->rfc822_header = $rfc822_header;
85 $composeMessage->reply_rfc822_header = '';
86 $compose_messages[$session] = $composeMessage;
91e0dccc 87 sqsession_register($compose_messages,'compose_messages');
1e89ed41 88 } else {
89 $composeMessage=$compose_messages[$session];
430be822 90 }
91
04f6008a 92
1e89ed41 93 $message = sqimap_get_message($imap_stream, $passed_id, $mailbox);
2b42190d 94 $composeMessage = spamcop_getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
9a422982 95 $passed_ent_id, $imap_stream);
1e89ed41 96
91e0dccc 97 $compose_messages[$session] = $composeMessage;
98 sqsession_register($compose_messages, 'compose_messages');
1e89ed41 99
100 $fn = getPref($data_dir, $username, 'full_name');
101 $em = getPref($data_dir, $username, 'email_address');
102
103 $HowItLooks = $fn . ' ';
104 if ($em != '')
5121598d 105 $HowItLooks .= '<' . $em . '>';
1e89ed41 106 }
5121598d 107
5121598d 108
2bd52bbe 109echo "<p>";
99aaff8b 110echo _("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 111echo "</p>";
112
113?>
5121598d 114
8ddc4111 115<table align="center" width="75%" border="0" cellpadding="0" cellspacing="0">
5121598d 116<tr>
8ddc4111 117<td align="left" valign="top">
6fd95361 118<?php if (isset($js_web) && $js_web) {
7d56f214 119 echo '<form method="post" action="javascript:return false">';
c435f076 120 echo '<input type="button" value="' . _("Close Window") . "\" onclick=\"window.close(); return true;\" />\n";
5121598d 121} else {
d2b387cb 122 ?><form method="post" action="<?php echo sqm_baseuri(); ?>src/right_main.php">
6fd95361 123 <input type="hidden" name="mailbox" value="<?php echo htmlspecialchars($mailbox) ?>" />
124 <input type="hidden" name="startMessage" value="<?php echo htmlspecialchars($startMessage) ?>" />
125<?php
7d56f214 126 echo '<input type="submit" value="' . _("Cancel / Done") . "\" />";
5121598d 127}
128 ?></form>
129</td>
8ddc4111 130<td align="right" valign="top">
6fd95361 131<?php if ($spamcop_method == 'thorough_email' ||
5121598d 132 $spamcop_method == 'quick_email') {
133 if ($spamcop_method == 'thorough_email')
134 $report_email = 'submit.' . $spamcop_id . '@spam.spamcop.net';
135 else
136 $report_email = 'quick.' . $spamcop_id . '@spam.spamcop.net';
d2b387cb 137 $form_action = sqm_baseuri() . 'src/compose.php';
6fd95361 138?> <form method="post" action="<?php echo $form_action?>">
139 <input type="hidden" name="mailbox" value="<?php echo htmlspecialchars($mailbox) ?>" />
140 <input type="hidden" name="spamcop_is_composing" value="<?php echo htmlspecialchars($passed_id) ?>" />
141 <input type="hidden" name="send_to" value="<?php echo htmlspecialchars($report_email)?>" />
7d56f214 142 <input type="hidden" name="subject" value="reply anyway" />
143 <input type="hidden" name="identity" value="0" />
6fd95361 144 <input type="hidden" name="session" value="<?php echo $session?>" />
7d56f214 145<?php
146 echo '<input type="submit" name="send" value="' . _("Send Spam Report") . "\" />\n";
147} else {
9a422982 148 $spam_message = mime_fetch_body ($imap_stream, $passed_id, $passed_ent_id, 50000);
9538cd4c 149
2b5fddf5 150 if (strlen($spam_message) == 50000) {
5121598d 151 $Warning = "\n[truncated by SpamCop]\n";
2b5fddf5 152 $spam_message = substr($spam_message, 0, 50000 - strlen($Warning)) . $Warning;
5121598d 153 }
13a35bde 154 $action_url="http://members.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="spam" value="<?php echo htmlspecialchars($spam_message); ?>" />
7d56f214 166 <?php
91e0dccc 167 echo '<input type="submit" name="x1" value="' . _("Send Spam Report") . "\" />\n";
7d56f214 168 }
5121598d 169?> </form>
170</td>
171</tr>
172</table>
7d56f214 173</body>
2128bbc6 174</html>