4 * spamcop.php -- SpamCop plugin -- main page
6 * @copyright 1999-2022 The SquirrelMail Project Team
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 * Include the SquirrelMail initialization file.
16 require('../../include/init.php');
17 /* IMAP functions depend on date and mime */
18 include_once(SM_PATH
. 'functions/date.php');
19 include_once(SM_PATH
. 'functions/mime.php');
21 include_once(SM_PATH
. 'functions/imap_general.php');
22 include_once(SM_PATH
. 'functions/imap_messages.php');
23 /* plugin functions */
24 include_once(SM_PATH
. 'plugins/spamcop/functions.php');
26 include_once(SM_PATH
. 'functions/compose.php');
30 sqgetGlobalVar('mailbox', $mailbox, SQ_GET
);
31 sqgetGlobalVar('passed_id', $passed_id, SQ_GET
, NULL, SQ_TYPE_BIGINT
);
32 sqgetGlobalVar('js_web', $js_web, SQ_GET
);
34 if (! sqgetGlobalVar('startMessage', $startMessage, SQ_GET
) ) {
37 if (! sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET
) ) {
40 if (! sqgetGlobalVar('js_web', $js_web, SQ_GET
) ) {
44 sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION
);
46 if(! sqgetGlobalVar('composesession', $composesession, SQ_SESSION
) ) {
48 sqsession_register($composesession, 'composesession');
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.
55 displayHTMLHeader(_("SpamCop reporting"));
56 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n";
58 displayPageHeader($color,$mailbox);
61 /** is spamcop plugin disabled */
62 if (! is_plugin_enabled('spamcop')) {
63 error_box(_("Plugin is disabled."));
64 // display footer (closes html tags) and stop script execution
65 $oTemplate->display('footer.tpl');
69 global $imap_stream_options; // in case not defined in config
70 $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
71 sqimap_mailbox_select($imap_stream, $mailbox);
73 if ($spamcop_method == 'quick_email' ||
74 $spamcop_method == 'thorough_email') {
75 // Use email-based reporting -- save as an attachment
76 $session = "$composesession"+
1;
77 $composesession = $session;
78 sqsession_register($composesession,'composesession');
79 if (!isset($compose_messages)) {
80 $compose_messages = array();
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;
88 sqsession_register($compose_messages,'compose_messages');
90 $composeMessage=$compose_messages[$session];
94 $message = sqimap_get_message($imap_stream, $passed_id, $mailbox);
95 $composeMessage = spamcop_getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
96 $passed_ent_id, $imap_stream);
98 $compose_messages[$session] = $composeMessage;
99 sqsession_register($compose_messages, 'compose_messages');
101 $fn = getPref($data_dir, $username, 'full_name');
102 $em = getPref($data_dir, $username, 'email_address');
104 $HowItLooks = $fn . ' ';
106 $HowItLooks .= '<' . $em . '>';
111 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.");
116 <table align
="center" width
="75%" border
="0" cellpadding
="0" cellspacing
="0">
118 <td align
="left" valign
="top">
119 <?php
if (isset($js_web) && $js_web) {
120 echo '<form method="post" action="javascript:return false">';
121 echo '<input type="button" value="' . _("Close Window") . "\" onclick=\"window.close(); return true;\" />\n";
123 ?
><form method
="post" action
="<?php echo sqm_baseuri(); ?>src/right_main.php">
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) ?>" />
127 echo '<input type="submit" value="' . _("Cancel / Done") . "\" />";
131 <td align
="right" valign
="top">
132 <?php
if ($spamcop_method == 'thorough_email' ||
133 $spamcop_method == 'quick_email') {
134 if ($spamcop_method == 'thorough_email')
135 $report_email = 'submit.' . $spamcop_id . '@spam.spamcop.net';
137 $report_email = 'quick.' . $spamcop_id . '@spam.spamcop.net';
138 $form_action = sqm_baseuri() . 'src/compose.php';
139 ?
> <form method
="post" action
="<?php echo $form_action?>">
140 <input type
="hidden" name
="smtoken" value
="<?php echo sm_generate_security_token() ?>" />
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)?>" />
144 <input type
="hidden" name
="subject" value
="reply anyway" />
145 <input type
="hidden" name
="identity" value
="0" />
146 <input type
="hidden" name
="session" value
="<?php echo $session?>" />
148 echo '<input type="submit" name="send1" value="' . _("Send Spam Report") . "\" />\n";
150 $spam_message = mime_fetch_body ($imap_stream, $passed_id, $passed_ent_id, 50000);
152 if (strlen($spam_message) == 50000) {
153 $Warning = "\n[truncated by SpamCop]\n";
154 $spam_message = substr($spam_message, 0, 50000 - strlen($Warning)) . $Warning;
156 $action_url="http://members.spamcop.net/sc";
158 if (isset($js_web) && $js_web) {
159 echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
160 " enctype=\"multipart/form-data\">\n";
162 echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
163 " enctype=\"multipart/form-data\" target=\"_blank\">\n";
165 <input type
="hidden" name
="action" value
="submit" />
166 <input type
="hidden" name
="oldverbose" value
="1" />
167 <input type
="hidden" name
="spam" value
="<?php echo sm_encode_html_special_chars($spam_message); ?>" />
169 echo '<input type="submit" name="x1" value="' . _("Send Spam Report") . "\" />\n";