e3b005689f8087359a9d700c1f9103cb1270f06f
3 ** spamcop.php -- SpamCop plugin
5 ** Copyright (c) 1999-2004 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
14 define('SM_PATH','../../');
16 /* SquirrelMail required files. */
17 require_once(SM_PATH
. 'include/validate.php');
18 require_once(SM_PATH
. 'functions/imap.php');
21 * Stores message in attachment directory, when email based reports are used
23 function getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
24 $passed_ent_id='', $imapConnection) {
25 global $attachments, $attachment_dir, $username, $data_dir;
27 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
28 if (!$passed_ent_id) {
29 $body_a = sqimap_run_command($imapConnection,
30 'FETCH '.$passed_id.' RFC822',
31 TRUE, $response, $readmessage,
34 $body_a = sqimap_run_command($imapConnection,
35 'FETCH '.$passed_id.' BODY['.$passed_ent_id.']',
36 TRUE, $response, $readmessage,TRUE);
37 $message = $message->parent
;
39 if ($response == 'OK') {
40 $subject = encodeHeader($message->rfc822_header
->subject
);
42 $body = implode('', $body_a) . "\r\n";
44 $localfilename = GenerateRandomString(32, 'FILE', 7);
45 $full_localfilename = "$hashed_attachment_dir/$localfilename";
46 $fp = fopen( $full_localfilename, 'w');
50 /* dirty relative dir fix */
51 if (substr($attachment_dir,0,3) == '../') {
52 $attachment_dir = substr($attachment_dir,3);
53 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
55 $full_localfilename = "$hashed_attachment_dir/$localfilename";
57 $composeMessage->initAttachment('message/rfc822','email.txt',
60 return $composeMessage;
66 sqgetGlobalVar('username', $username, SQ_SESSION
);
67 sqgetGlobalVar('key', $key, SQ_COOKIE
);
68 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
70 sqgetGlobalVar('mailbox', $mailbox, SQ_GET
);
71 sqgetGlobalVar('passed_id', $passed_id, SQ_GET
);
72 sqgetGlobalVar('js_web', $js_web, SQ_GET
);
74 if (! sqgetGlobalVar('startMessage', $startMessage, SQ_GET
) ) {
77 if (! sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET
) ) {
80 if (! sqgetGlobalVar('js_web', $js_web, SQ_GET
) ) {
84 sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION
);
86 if(! sqgetGlobalVar('composesession', $composesession, SQ_SESSION
) ) {
88 sqsession_register($composesession, 'composesession');
92 // js_web variable is 1 only when link opens web based report page in new window
93 // and in new window menu line or extra javascript code is not needed.
95 displayHTMLHeader('SpamCop reporting');
96 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n";
98 displayPageHeader($color,$mailbox);
101 $imap_stream = sqimap_login($username, $key, $imapServerAddress,
103 sqimap_mailbox_select($imap_stream, $mailbox);
105 if ($spamcop_method == 'quick_email' ||
106 $spamcop_method == 'thorough_email') {
107 // Use email-based reporting -- save as an attachment
108 $session = "$composesession"+
1;
109 $composesession = $session;
110 sqsession_register($composesession,'composesession');
111 if (!isset($compose_messages)) {
112 $compose_messages = array();
114 if (!isset($compose_messages[$session]) ||
($compose_messages[$session] == NULL)) {
115 $composeMessage = new Message();
116 $rfc822_header = new Rfc822Header();
117 $composeMessage->rfc822_header
= $rfc822_header;
118 $composeMessage->reply_rfc822_header
= '';
119 $compose_messages[$session] = $composeMessage;
120 sqsession_register($compose_messages,'compose_messages');
122 $composeMessage=$compose_messages[$session];
126 $message = sqimap_get_message($imap_stream, $passed_id, $mailbox);
127 $composeMessage = getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
128 $passed_ent_id, $imap_stream);
130 $compose_messages[$session] = $composeMessage;
131 sqsession_register($compose_messages, 'compose_messages');
133 $fn = getPref($data_dir, $username, 'full_name');
134 $em = getPref($data_dir, $username, 'email_address');
136 $HowItLooks = $fn . ' ';
138 $HowItLooks .= '<' . $em . '>';
143 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.");
148 <table align
="center" width
="75%" border
="0" cellpadding
="0" cellspacing
="0">
150 <td align
="left" valign
="top">
151 <?PHP
if (isset($js_web) && $js_web) {
152 ?
><form method
="post" action
="javascript:return false">
153 <input type
="button" value
="Close Window"
154 onClick
="window.close(); return true;">
157 ?
><form method
="post" action
="../../src/right_main.php">
158 <input type
="hidden" name
="mailbox" value
="<?PHP echo htmlspecialchars($mailbox) ?>">
159 <input type
="hidden" name
="startMessage" value
="<?PHP echo htmlspecialchars($startMessage) ?>">
160 <input type
="submit" value
="Cancel / Done">
165 <td align
="right" valign
="top">
166 <?PHP
if ($spamcop_method == 'thorough_email' ||
167 $spamcop_method == 'quick_email') {
168 if ($spamcop_method == 'thorough_email')
169 $report_email = 'submit.' . $spamcop_id . '@spam.spamcop.net';
171 $report_email = 'quick.' . $spamcop_id . '@spam.spamcop.net';
172 $form_action = SM_PATH
. 'src/compose.php';
173 ?
> <form method
="post" action
="<?PHP echo $form_action?>">
174 <input type
="hidden" name
="mailbox" value
="<?PHP echo htmlspecialchars($mailbox) ?>">
175 <input type
="hidden" name
="spamcop_is_composing" value
="<?PHP echo htmlspecialchars($passed_id) ?>">
176 <input type
="hidden" name
="send_to" value
="<?PHP echo $report_email?>">
177 <input type
="hidden" name
="subject" value
="reply anyway">
178 <input type
="hidden" name
="identity" value
="0">
179 <input type
="hidden" name
="session" value
="<?PHP echo $session?>">
180 <input type
="submit" name
="send" value
="Send Spam Report">
182 $spam_message = mime_fetch_body ($imap_stream, $passed_id, $passed_ent_id, 50000);
184 if (strlen($spam_message) == 50000) {
185 $Warning = "\n[truncated by SpamCop]\n";
186 $spam_message = substr($spam_message, 0, 50000 - strlen($Warning)) . $Warning;
188 if ($spamcop_type=='member') {
189 $action_url="http://members.spamcop.net/sc";
191 $action_url="http://www.spamcop.net/sc";
193 if (isset($js_web) && $js_web) {
194 echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
195 " enctype=\"multipart/form-data\">\n";
197 echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
198 " enctype=\"multipart/form-data\" target=\"_blank\">\n";
200 <input type
="hidden" name
="action" value
="submit">
201 <input type
="hidden" name
="oldverbose" value
="1">
202 <input type
="hidden" name
="code" value
="<?PHP echo $spamcop_id ?>">
203 <input type
="hidden" name
="spam" value
="<?PHP echo htmlspecialchars($spam_message); ?>">
204 <input type
="submit" name
="x1" value
="Send Spam Report">