Fix variable name typo
[squirrelmail.git] / plugins / spamcop / spamcop.php
CommitLineData
5121598d 1<?php
4b4abf93 2
91e0dccc 3/**
f3a91d6b 4 * spamcop.php -- SpamCop plugin -- main page
5 *
c4faef33 6 * @copyright 1999-2020 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
a9805897 69 global $imap_stream_options; // in case not defined in config
70 $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
5121598d 71 sqimap_mailbox_select($imap_stream, $mailbox);
5121598d 72
91e0dccc 73 if ($spamcop_method == 'quick_email' ||
5121598d 74 $spamcop_method == 'thorough_email') {
75 // Use email-based reporting -- save as an attachment
1e89ed41 76 $session = "$composesession"+1;
77 $composesession = $session;
78 sqsession_register($composesession,'composesession');
79 if (!isset($compose_messages)) {
80 $compose_messages = array();
430be822 81 }
1e89ed41 82 if (!isset($compose_messages[$session]) || ($compose_messages[$session] == NULL)) {
83 $composeMessage = new Message();
84 $rfc822_header = new Rfc822Header();
85 $composeMessage->rfc822_header = $rfc822_header;
86 $composeMessage->reply_rfc822_header = '';
87 $compose_messages[$session] = $composeMessage;
91e0dccc 88 sqsession_register($compose_messages,'compose_messages');
1e89ed41 89 } else {
90 $composeMessage=$compose_messages[$session];
430be822 91 }
92
04f6008a 93
1e89ed41 94 $message = sqimap_get_message($imap_stream, $passed_id, $mailbox);
2b42190d 95 $composeMessage = spamcop_getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
9a422982 96 $passed_ent_id, $imap_stream);
1e89ed41 97
91e0dccc 98 $compose_messages[$session] = $composeMessage;
99 sqsession_register($compose_messages, 'compose_messages');
1e89ed41 100
101 $fn = getPref($data_dir, $username, 'full_name');
102 $em = getPref($data_dir, $username, 'email_address');
103
104 $HowItLooks = $fn . ' ';
105 if ($em != '')
5121598d 106 $HowItLooks .= '<' . $em . '>';
1e89ed41 107 }
5121598d 108
5121598d 109
2bd52bbe 110echo "<p>";
99aaff8b 111echo _("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 112echo "</p>";
113
114?>
5121598d 115
8ddc4111 116<table align="center" width="75%" border="0" cellpadding="0" cellspacing="0">
5121598d 117<tr>
8ddc4111 118<td align="left" valign="top">
6fd95361 119<?php if (isset($js_web) && $js_web) {
7d56f214 120 echo '<form method="post" action="javascript:return false">';
c435f076 121 echo '<input type="button" value="' . _("Close Window") . "\" onclick=\"window.close(); return true;\" />\n";
5121598d 122} else {
d2b387cb 123 ?><form method="post" action="<?php echo sqm_baseuri(); ?>src/right_main.php">
3047e291 124 <input type="hidden" name="mailbox" value="<?php echo sm_encode_html_special_chars($mailbox) ?>" />
125 <input type="hidden" name="startMessage" value="<?php echo sm_encode_html_special_chars($startMessage) ?>" />
6fd95361 126<?php
7d56f214 127 echo '<input type="submit" value="' . _("Cancel / Done") . "\" />";
5121598d 128}
129 ?></form>
130</td>
8ddc4111 131<td align="right" valign="top">
6fd95361 132<?php if ($spamcop_method == 'thorough_email' ||
5121598d 133 $spamcop_method == 'quick_email') {
134 if ($spamcop_method == 'thorough_email')
135 $report_email = 'submit.' . $spamcop_id . '@spam.spamcop.net';
136 else
137 $report_email = 'quick.' . $spamcop_id . '@spam.spamcop.net';
d2b387cb 138 $form_action = sqm_baseuri() . 'src/compose.php';
6fd95361 139?> <form method="post" action="<?php echo $form_action?>">
d272e234 140 <input type="hidden" name="smtoken" value="<?php echo sm_generate_security_token() ?>" />
3047e291 141 <input type="hidden" name="mailbox" value="<?php echo sm_encode_html_special_chars($mailbox) ?>" />
142 <input type="hidden" name="spamcop_is_composing" value="<?php echo sm_encode_html_special_chars($passed_id) ?>" />
143 <input type="hidden" name="send_to" value="<?php echo sm_encode_html_special_chars($report_email)?>" />
7d56f214 144 <input type="hidden" name="subject" value="reply anyway" />
145 <input type="hidden" name="identity" value="0" />
6fd95361 146 <input type="hidden" name="session" value="<?php echo $session?>" />
7d56f214 147<?php
d272e234 148 echo '<input type="submit" name="send1" value="' . _("Send Spam Report") . "\" />\n";
7d56f214 149} else {
9a422982 150 $spam_message = mime_fetch_body ($imap_stream, $passed_id, $passed_ent_id, 50000);
9538cd4c 151
2b5fddf5 152 if (strlen($spam_message) == 50000) {
5121598d 153 $Warning = "\n[truncated by SpamCop]\n";
2b5fddf5 154 $spam_message = substr($spam_message, 0, 50000 - strlen($Warning)) . $Warning;
5121598d 155 }
13a35bde 156 $action_url="http://members.spamcop.net/sc";
157
5121598d 158 if (isset($js_web) && $js_web) {
9a422982 159 echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
160 " enctype=\"multipart/form-data\">\n";
5121598d 161 } else {
9a422982 162 echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
163 " enctype=\"multipart/form-data\" target=\"_blank\">\n";
5121598d 164 } ?>
7d56f214 165 <input type="hidden" name="action" value="submit" />
166 <input type="hidden" name="oldverbose" value="1" />
3047e291 167 <input type="hidden" name="spam" value="<?php echo sm_encode_html_special_chars($spam_message); ?>" />
7d56f214 168 <?php
91e0dccc 169 echo '<input type="submit" name="x1" value="' . _("Send Spam Report") . "\" />\n";
7d56f214 170 }
5121598d 171?> </form>
172</td>
173</tr>
174</table>
7d56f214 175</body>
2128bbc6 176</html>