3 ** spamcop.php -- SpamCop plugin
5 ** Copyright (c) 1999-2002 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
11 define('SM_PATH','../../');
13 /* SquirrelMail required files. */
14 require_once(SM_PATH
. 'include/validate.php');
15 require_once(SM_PATH
. 'functions/imap.php');
17 function getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
18 $passed_ent_id='', $imapConnection) {
19 global $attachments, $attachment_dir, $username, $data_dir, $uid_support;
21 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
22 if (!$passed_ent_id) {
23 $body_a = sqimap_run_command($imapConnection,
24 'FETCH '.$passed_id.' RFC822',
25 TRUE, $response, $readmessage,
28 $body_a = sqimap_run_command($imapConnection,
29 'FETCH '.$passed_id.' BODY['.$passed_ent_id.']',
30 TRUE, $response, $readmessage, $uid_support);
31 $message = $message->parent
;
33 if ($response = 'OK') {
34 $subject = encodeHeader($message->rfc822_header
->subject
);
36 $body = implode('', $body_a) . "\r\n";
38 $localfilename = GenerateRandomString(32, 'FILE', 7);
39 $full_localfilename = "$hashed_attachment_dir/$localfilename";
40 $fp = fopen( $full_localfilename, 'w');
44 /* dirty relative dir fix */
45 if (substr($attachment_dir,0,3) == '../') {
46 $attachment_dir = substr($attachment_dir,3);
47 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
49 $full_localfilename = "$hashed_attachment_dir/$localfilename";
51 $composeMessage->initAttachment('message/rfc822','email.txt',
54 return $composeMessage;
59 $username = $_SESSION['username'];
60 $key = $_COOKIE['key'];
61 $onetimepad = $_SESSION['onetimepad'];
62 $mailbox = $_GET['mailbox'];
63 $passed_id = $_GET['passed_id'];
64 if (isset($_GET['startMessage'])) {
65 $startMessage = $_GET['startMessage'];
69 if (isset($_GET['passed_ent_id'])) {
70 $passed_ent_id = $_GET['passed_ent_id'];
74 if ( isset($_SESSION['compose_messages']) ) {
75 $compose_messages = &$_SESSION['compose_messages'];
78 if ( isset($_SESSION['composesession']) ) {
79 $composesession = $_SESSION['composesession'];
82 sqsession_register($composesession, 'composesession');
87 displayPageHeader($color, $mailbox);
89 $imap_stream = sqimap_login($username, $key, $imapServerAddress,
91 sqimap_mailbox_select($imap_stream, $mailbox);
94 $sid = sqimap_session_id($uid_support);
95 fputs($imap_stream, $sid.' FETCH ' . $passed_id . ' RFC822' . "\r\n");
97 $read = sqimap_read_data($imap_stream, $sid, true, $response, $message);
100 if ($spamcop_method == 'quick_email' ||
101 $spamcop_method == 'thorough_email') {
102 // Use email-based reporting -- save as an attachment
103 $session = "$composesession"+
1;
104 $composesession = $session;
105 sqsession_register($composesession,'composesession');
106 if (!isset($compose_messages)) {
107 $compose_messages = array();
109 if (!isset($compose_messages[$session]) ||
($compose_messages[$session] == NULL)) {
110 $composeMessage = new Message();
111 $rfc822_header = new Rfc822Header();
112 $composeMessage->rfc822_header
= $rfc822_header;
113 $composeMessage->reply_rfc822_header
= '';
114 $compose_messages[$session] = $composeMessage;
115 sqsession_register($compose_messages,'compose_messages');
117 $composeMessage=$compose_messages[$session];
121 $message = sqimap_get_message($imap_stream, $passed_id, $mailbox);
122 $composeMessage = getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
123 $passed_ent_id='', $imap_stream);
125 $compose_messages[$session] = $composeMessage;
126 sqsession_register($compose_messages, 'compose_messages');
128 $fn = getPref($data_dir, $username, 'full_name');
129 $em = getPref($data_dir, $username, 'email_address');
131 $HowItLooks = $fn . ' ';
133 $HowItLooks .= '<' . $em . '>';
138 <p
>Sending this spam report will give you back a reply with URLs that you
139 can click on to properly report this spam message to the proper authorities
.
140 This is a free service
. By pressing the
"Send Spam Report" button
, you
141 agree to follow SpamCop
's rules/terms of service/etc.</p>
143 <table align=center width="75%" border=0 cellpadding=0 cellspacing=0>
145 <td align=left valign=top>
146 <?PHP if (isset($js_web) && $js_web) {
147 ?><form method=post action="javascript:return false">
148 <input type=button value="Close Window"
149 onClick="window.close(); return true;">
152 ?><form method=post action="../../src/right_main.php">
153 <input type=hidden name="mailbox" value="<?PHP echo
154 htmlspecialchars($mailbox) ?>">
155 <input type=hidden name="startMessage" value="<?PHP echo
156 htmlspecialchars($startMessage) ?>">
157 <input type=submit value="Cancel / Done">
162 <td align=right valign=top>
163 <?PHP if ($spamcop_method == 'thorough_email
' ||
164 $spamcop_method == 'quick_email
') {
165 if ($spamcop_method == 'thorough_email
')
166 $report_email = 'submit
.' . $spamcop_id . '@spam
.spamcop
.net
';
168 $report_email = 'quick
.' . $spamcop_id . '@spam
.spamcop
.net
';
169 $form_action = SM_PATH . 'src
/compose
.php
';
170 ?> <form method=post action="<?PHP echo $form_action?>">
171 <input type=hidden name="mailbox" value="<?PHP echo
172 htmlspecialchars($mailbox) ?>">
173 <input type=hidden name="spamcop_is_composing" value="<?PHP echo
174 htmlspecialchars($passed_id) ?>">
175 <input type=hidden name="send_to" value="<?PHP echo $report_email?>">
176 <input type=hidden name="send_to_cc" value="">
177 <input type=hidden name="send_to_bcc" value="">
178 <input type=hidden name="subject" value="reply anyway">
179 <input type=hidden name="identity" value="default">
180 <input type=hidden name="session" value="<?PHP echo $session?>">
181 <input type=submit name="send" value="Send Spam Report">
183 $Message = implode('', $read);
184 if (strlen($Message) > 50000) {
185 $Warning = "\n[truncated by SpamCop]\n";
186 $Message = substr($Message, 0, 50000 - strlen($Warning)) . $Warning;
188 if (isset($js_web) && $js_web) {
189 ?> <form method=post action="http://spamcop.net/sc" name="submitspam"
190 enctype="multipart/form-data"><?PHP
192 ?> <form method=post action="http://spamcop.net/sc" name="submitspam"
193 enctype="multipart/form-data" target="_blank"><?PHP
195 <input type=hidden name=action value=submit>
196 <input type=hidden name=oldverbose value=1>
197 <input type=hidden name=code value="<?PHP echo $spamcop_id ?>">
198 <input type=hidden name=spam value="<?PHP
199 echo htmlspecialchars($Message);
201 <input type=submit name="x1" value="Send Spam Report">