-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spamcop.php
215 lines (196 loc) · 8.52 KB
/
spamcop.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?php
/**
* spamcop.php -- SpamCop plugin -- main page
*
* @copyright 1999-2020 The SquirrelMail Project Team
* @modified 2018-2020 Andrew Sachen
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: spamcop.php 1.4 2020-11-01 23:50:00Z realityripple $
* @package plugins
* @subpackage spamcop
*/
/**
* Include the SquirrelMail initialization file.
*/
require('../../include/init.php');
/* IMAP functions depend on date and mime */
include_once(SM_PATH . 'functions/date.php');
include_once(SM_PATH . 'functions/mime.php');
/* IMAP functions */
include_once(SM_PATH . 'functions/imap_general.php');
include_once(SM_PATH . 'functions/imap_messages.php');
/* plugin functions */
include_once(SM_PATH . 'plugins/spamcop/functions.php');
include_once(SM_PATH . 'functions/compose.php');
/* GLOBALS */
sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
sqgetGlobalVar('passed_id', $passed_id, SQ_GET, NULL, SQ_TYPE_BIGINT);
sqgetGlobalVar('js_web', $js_web, SQ_GET);
if (! sqgetGlobalVar('startMessage', $startMessage, SQ_GET) ) {
$startMessage = 1;
}
if (! sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) {
$passed_ent_id = 0;
}
if (! sqgetGlobalVar('js_web', $js_web, SQ_GET) ) {
$js_web = 0;
}
if ( $passed_id == 0 ) {
if (! sqgetGlobalVar('passed_ids', $passed_ids, SQ_GET) ) {
$passed_ids = '0';
}
}
sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION);
if(! sqgetGlobalVar('composesession', $composesession, SQ_SESSION) ) {
$composesession = 0;
sqsession_register($composesession, 'composesession');
}
/* END GLOBALS */
// js_web variable is 1 only when link opens web based report page in new window
// and in new window menu line or extra javascript code is not needed.
if ($js_web) {
displayHTMLHeader(_("SpamCop reporting"));
echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n";
} else {
displayPageHeader($color,$mailbox);
}
/** is spamcop plugin disabled */
if (! is_plugin_enabled('spamcop')) {
error_box(_("Plugin is disabled."));
// display footer (closes html tags) and stop script execution
$oTemplate->display('footer.tpl');
exit();
}
global $imap_stream_options; // in case not defined in config
$imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
sqimap_mailbox_select($imap_stream, $mailbox);
if ($spamcop_method == 'quick_email' ||
$spamcop_method == 'thorough_email') {
// Use email-based reporting -- save as an attachment
$session = "$composesession"+1;
$composesession = $session;
sqsession_register($composesession,'composesession');
if (!isset($compose_messages)) {
$compose_messages = array();
}
if (!isset($compose_messages[$session]) || ($compose_messages[$session] == NULL)) {
$composeMessage = new Message();
$rfc822_header = new Rfc822Header();
$composeMessage->rfc822_header = $rfc822_header;
$composeMessage->reply_rfc822_header = '';
$compose_messages[$session] = $composeMessage;
sqsession_register($compose_messages,'compose_messages');
} else {
$composeMessage=$compose_messages[$session];
}
if ($passed_id == 0 && strpos($passed_ids, '.') !== false)
{
$aUids = explode('.', $passed_ids);
for($i = 0; $i < count($aUids); $i++)
{
$uid = $aUids[$i];
$message = sqimap_get_message($imap_stream, $uid, $mailbox);
$composeMessage = spamcop_getMessage_RFC822_Attachment($message, $composeMessage, $uid,
$passed_ent_id, $imap_stream);
}
}
else
{
$message = sqimap_get_message($imap_stream, $passed_id, $mailbox);
$composeMessage = spamcop_getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
$passed_ent_id, $imap_stream);
}
$compose_messages[$session] = $composeMessage;
sqsession_register($compose_messages, 'compose_messages');
}
if ($passed_id == 0 && strpos($passed_ids, '.') !== false)
{
$idCount = count(explode('.', $passed_ids));
if ($spamcop_method == 'quick_email')
{
echo "<p>";
echo _("Sending this spam report will automatically report these ").$idCount._(" spam messages 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.");
echo "</p>";
}
else
{
echo "<p>";
echo _("Sending this spam report will give you back a reply with URLs that you can click on to properly report these ").$idCount._(" spam messages 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.");
echo "</p>";
}
}
else
{
if ($spamcop_method == 'quick_email')
{
echo "<p>";
echo _("Sending this spam report will automatically 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.");
echo "</p>";
}
else
{
echo "<p>";
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.");
echo "</p>";
}
}
?>
<table align="center" width="75%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top">
<?php if (isset($js_web) && $js_web) {
echo '<form method="post" action="javascript:return false">';
echo '<input type="button" value="' . _("Close Window") . "\" onclick=\"window.close(); return true;\" />\n";
} else {
?><form method="post" action="<?php echo sqm_baseuri(); ?>src/right_main.php">
<input type="hidden" name="mailbox" value="<?php echo sm_encode_html_special_chars($mailbox) ?>" />
<input type="hidden" name="startMessage" value="<?php echo sm_encode_html_special_chars($startMessage) ?>" />
<?php
echo '<input type="submit" value="' . _("Cancel / Done") . "\" />";
}
?></form>
</td>
<td align="right" valign="top">
<?php if ($spamcop_method == 'thorough_email' ||
$spamcop_method == 'quick_email') {
if ($spamcop_method == 'thorough_email')
$report_email = 'submit.' . $spamcop_id . '@spam.spamcop.net';
else
$report_email = 'quick.' . $spamcop_id . '@spam.spamcop.net';
$form_action = sqm_baseuri() . 'src/compose.php';
?> <form method="post" action="<?php echo $form_action?>">
<input type="hidden" name="smtoken" value="<?php echo sm_generate_security_token() ?>" />
<input type="hidden" name="mailbox" value="<?php echo sm_encode_html_special_chars($mailbox) ?>" />
<input type="hidden" name="spamcop_is_composing" value="<?php if($passed_id == 0) echo sm_encode_html_special_chars($passed_ids); else echo sm_encode_html_special_chars($passed_id) ?>" />
<input type="hidden" name="send_to" value="<?php echo sm_encode_html_special_chars($report_email)?>" />
<input type="hidden" name="subject" value="reply anyway" />
<input type="hidden" name="identity" value="0" />
<input type="hidden" name="session" value="<?php echo $session?>" />
<?php
echo '<input type="submit" name="send1" value="' . _("Send Spam Report") . "\" />\n";
} else {
$spam_message = mime_fetch_body ($imap_stream, $passed_id, $passed_ent_id, 50000);
if (strlen($spam_message) == 50000) {
$Warning = "\n[truncated by SpamCop]\n";
$spam_message = substr($spam_message, 0, 50000 - strlen($Warning)) . $Warning;
}
$action_url="//members.spamcop.net/sc";
if (isset($js_web) && $js_web) {
echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
" enctype=\"multipart/form-data\">\n";
} else {
echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
" enctype=\"multipart/form-data\" target=\"_blank\">\n";
} ?>
<input type="hidden" name="action" value="submit" />
<input type="hidden" name="oldverbose" value="1" />
<input type="hidden" name="spam" value="<?php echo sm_encode_html_special_chars($spam_message); ?>" />
<?php
echo '<input type="submit" name="x1" value="' . _("Send Spam Report") . "\" />\n";
}
?> </form>
</td>
</tr>
</table>
</body>
</html>