c7b1397c6d20b988fe47a28f8d45d2f9c0dbfe49
3 ** spamcop.php -- SpamCop plugin
5 ** Copyright (c) 1999-2003 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');
20 function getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
21 $passed_ent_id='', $imapConnection) {
22 global $attachments, $attachment_dir, $username, $data_dir, $uid_support;
24 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
25 if (!$passed_ent_id) {
26 $body_a = sqimap_run_command($imapConnection,
27 'FETCH '.$passed_id.' RFC822',
28 TRUE, $response, $readmessage,
31 $body_a = sqimap_run_command($imapConnection,
32 'FETCH '.$passed_id.' BODY['.$passed_ent_id.']',
33 TRUE, $response, $readmessage, $uid_support);
34 $message = $message->parent
;
36 if ($response == 'OK') {
37 $subject = encodeHeader($message->rfc822_header
->subject
);
39 $body = implode('', $body_a) . "\r\n";
41 $localfilename = GenerateRandomString(32, 'FILE', 7);
42 $full_localfilename = "$hashed_attachment_dir/$localfilename";
43 $fp = fopen( $full_localfilename, 'w');
47 /* dirty relative dir fix */
48 if (substr($attachment_dir,0,3) == '../') {
49 $attachment_dir = substr($attachment_dir,3);
50 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
52 $full_localfilename = "$hashed_attachment_dir/$localfilename";
54 $composeMessage->initAttachment('message/rfc822','email.txt',
57 return $composeMessage;
63 sqgetGlobalVar('username', $username, SQ_SESSION
);
64 sqgetGlobalVar('key', $key, SQ_COOKIE
);
65 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
67 sqgetGlobalVar('mailbox', $mailbox, SQ_GET
);
68 sqgetGlobalVar('passed_id', $passed_id, SQ_GET
);
70 if (! sqgetGlobalVar('startMessage', $startMessage, SQ_GET
) ) {
73 if (! sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET
) ) {
77 sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION
);
79 if(! sqgetGlobalVar('composesession', $composesession, SQ_SESSION
) ) {
81 sqsession_register($composesession, 'composesession');
86 displayPageHeader($color, $mailbox);
88 $imap_stream = sqimap_login($username, $key, $imapServerAddress,
90 sqimap_mailbox_select($imap_stream, $mailbox);
92 if ($spamcop_method == 'quick_email' ||
93 $spamcop_method == 'thorough_email') {
94 // Use email-based reporting -- save as an attachment
95 $session = "$composesession"+
1;
96 $composesession = $session;
97 sqsession_register($composesession,'composesession');
98 if (!isset($compose_messages)) {
99 $compose_messages = array();
101 if (!isset($compose_messages[$session]) ||
($compose_messages[$session] == NULL)) {
102 $composeMessage = new Message();
103 $rfc822_header = new Rfc822Header();
104 $composeMessage->rfc822_header
= $rfc822_header;
105 $composeMessage->reply_rfc822_header
= '';
106 $compose_messages[$session] = $composeMessage;
107 sqsession_register($compose_messages,'compose_messages');
109 $composeMessage=$compose_messages[$session];
113 $message = sqimap_get_message($imap_stream, $passed_id, $mailbox);
114 $composeMessage = getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
115 $passed_ent_id='', $imap_stream);
117 $compose_messages[$session] = $composeMessage;
118 sqsession_register($compose_messages, 'compose_messages');
120 $fn = getPref($data_dir, $username, 'full_name');
121 $em = getPref($data_dir, $username, 'email_address');
123 $HowItLooks = $fn . ' ';
125 $HowItLooks .= '<' . $em . '>';
130 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.");
135 <table align
="center" width
="75%" border
="0" cellpadding
="0" cellspacing
="0">
137 <td align
="left" valign
="top">
138 <?PHP
if (isset($js_web) && $js_web) {
139 ?
><form method
="post" action
="javascript:return false">
140 <input type
="button" value
="Close Window"
141 onClick
="window.close(); return true;">
144 ?
><form method
="post" action
="../../src/right_main.php">
145 <input type
="hidden" name
="mailbox" value
="<?PHP echo htmlspecialchars($mailbox) ?>">
146 <input type
="hidden" name
="startMessage" value
="<?PHP echo htmlspecialchars($startMessage) ?>">
147 <input type
="submit" value
="Cancel / Done">
152 <td align
="right" valign
="top">
153 <?PHP
if ($spamcop_method == 'thorough_email' ||
154 $spamcop_method == 'quick_email') {
155 if ($spamcop_method == 'thorough_email')
156 $report_email = 'submit.' . $spamcop_id . '@spam.spamcop.net';
158 $report_email = 'quick.' . $spamcop_id . '@spam.spamcop.net';
159 $form_action = SM_PATH
. 'src/compose.php';
160 ?
> <form method
="post" action
="<?PHP echo $form_action?>">
161 <input type
="hidden" name
="mailbox" value
="<?PHP echo htmlspecialchars($mailbox) ?>">
162 <input type
="hidden" name
="spamcop_is_composing" value
="<?PHP echo htmlspecialchars($passed_id) ?>">
163 <input type
="hidden" name
="send_to" value
="<?PHP echo $report_email?>">
164 <input type
="hidden" name
="subject" value
="reply anyway">
165 <input type
="hidden" name
="identity" value
="0">
166 <input type
="hidden" name
="session" value
="<?PHP echo $session?>">
167 <input type
="submit" name
="send" value
="Send Spam Report">
169 $spam_message = mime_fetch_body ($imap_stream, $passed_id, 0, 50000);
171 if (strlen($spam_message) == 50000) {
172 $Warning = "\n[truncated by SpamCop]\n";
173 $spam_message = substr($spam_message, 0, 50000 - strlen($Warning)) . $Warning;
175 if (isset($js_web) && $js_web) {
176 ?
> <form method
="post" action
="http://www.spamcop.net/sc" name
="submitspam"
177 enctype
="multipart/form-data"><?PHP
179 ?
> <form method
="post" action
="http://www.spamcop.net/sc" name
="submitspam"
180 enctype
="multipart/form-data" target
="_blank"><?PHP
182 <input type
="hidden" name
="action" value
="submit">
183 <input type
="hidden" name
="oldverbose" value
="1">
184 <input type
="hidden" name
="code" value
="<?PHP echo $spamcop_id ?>">
185 <input type
="hidden" name
="spam" value
="<?PHP echo htmlspecialchars($spam_message); ?>">
186 <input type
="submit" name
="x1" value
="Send Spam Report">