Some plugins to rg=0: bug_report message_details newmail sent_subfolders spamcop...
[squirrelmail.git] / plugins / spamcop / spamcop.php
1 <?php
2 /**
3 ** spamcop.php -- SpamCop plugin
4 **
5 ** Copyright (c) 1999-2002 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 **
8 ** $Id$
9 **/
10
11 define('SM_PATH','../../');
12
13 /* SquirrelMail required files. */
14 require_once(SM_PATH . 'include/validate.php');
15 require_once(SM_PATH . 'functions/imap.php');
16
17 /* GLOBALS */
18
19 $username = $_SESSION['username'];
20 $key = $_COOKIE['key'];
21 $onetimepad = $_SESSION['onetimepad'];
22
23 $mailbox = $_GET['mailbox'];
24 $passed_id = $_GET['passed_id'];
25 $startMessage = $_GET['startMessage'];
26
27 /* END GLOBALS */
28
29 displayPageHeader($color, $mailbox);
30
31 $imap_stream = sqimap_login($username, $key, $imapServerAddress,
32 $imapPort, 0);
33 sqimap_mailbox_select($imap_stream, $mailbox);
34 $sid = sqimap_session_id($uid_support)
35 fputs($imap_stream, $sid.' FETCH ' . $passed_id . ' RFC822' . "\r\n");
36
37 $read = sqimap_read_data($imap_stream, $sid, true, $response, $message);
38 array_shift($read);
39
40 if ($spamcop_method == 'quick_email' ||
41 $spamcop_method == 'thorough_email') {
42 // Use email-based reporting -- save as an attachment
43 if(!isset($composesession)) {
44 $composesession = 0;
45 sqsession_register($composesession, 'composesession');
46 }
47 if (!isset($session)) {
48 $session = "$composesession" +1;
49 $composesession = $session;
50 }
51
52 if (!isset($attachments)) {
53 $attachments = array();
54 sqsession_register($attachments, 'attachments');
55 }
56
57 foreach ($attachments as $info) {
58 if (file_exists($attachment_dir . $info['localfilename']))
59 unlink($attachment_dir . $info['localfilename']);
60 }
61 $attachments = array();
62
63 $file = GenerateRandomString(32, '', 7);
64 while (file_exists($attachment_dir . $file))
65 $file = GenerateRandomString(32, '', 7);
66 $newAttachment['localfilename'] = $file;
67 $newAttachment['remotefilename'] = 'email.txt';
68 $newAttachment['type'] = 'message/rfc822';
69 $newAttachment['session'] = $session;
70 $fp = fopen($attachment_dir . $file, 'w');
71 foreach ($read as $line) {
72 fputs($fp, $line);
73 }
74 sqsession_unregister('attachments');
75 $attachments[] = $newAttachment;
76 sqsession_register($attachments , 'attachments');
77
78 $fn = getPref($data_dir, $username, 'full_name');
79 $em = getPref($data_dir, $username, 'email_address');
80
81 $HowItLooks = $fn . ' ';
82 if ($em != '')
83 $HowItLooks .= '<' . $em . '>';
84 }
85
86 ?>
87
88 <p>Sending this spam report will give you back a reply with URLs that you
89 can click on to properly report this spam message to the proper authorities.
90 This is a free service. By pressing the "Send Spam Report" button, you
91 agree to follow SpamCop's rules/terms of service/etc.</p>
92
93 <table align=center width="75%" border=0 cellpadding=0 cellspacing=0>
94 <tr>
95 <td align=left valign=top>
96 <?PHP if (isset($js_web) && $js_web) {
97 ?><form method=post action="javascript:return false">
98 <input type=button value="Close Window"
99 onClick="window.close(); return true;">
100 <?PHP
101 } else {
102 ?><form method=post action="../../src/right_main.php">
103 <input type=hidden name="mailbox" value="<?PHP echo
104 htmlspecialchars($mailbox) ?>">
105 <input type=hidden name="startMessage" value="<?PHP echo
106 htmlspecialchars($startMessage) ?>">
107 <input type=submit value="Cancel / Done">
108 <?PHP
109 }
110 ?></form>
111 </td>
112 <td align=right valign=top>
113 <?PHP if ($spamcop_method == 'thorough_email' ||
114 $spamcop_method == 'quick_email') {
115 if ($spamcop_method == 'thorough_email')
116 $report_email = 'submit.' . $spamcop_id . '@spam.spamcop.net';
117 else
118 $report_email = 'quick.' . $spamcop_id . '@spam.spamcop.net';
119 ?> <form method=post action="../../src/compose.php">
120 <input type=hidden name="mailbox" value="<?PHP echo
121 htmlspecialchars($mailbox) ?>">
122 <input type=hidden name="spamcop_is_composing" value="<?PHP echo
123 htmlspecialchars($passed_id) ?>">
124 <input type=hidden name="send_to" value="<?PHP echo $report_email ?>">
125 <input type=hidden name="send_to_cc" value="">
126 <input type=hidden name="send_to_bcc" value="">
127 <input type=hidden name="subject" value="reply anyway">
128 <input type=hidden name="identity" value="default">
129 <input type=hidden name="session" value="<?PHP echo $session?>">
130 <input type=submit name="send" value="Send Spam Report">
131 <?PHP } else {
132 $Message = implode('', $read);
133 if (strlen($Message) > 50000) {
134 $Warning = "\n[truncated by SpamCop]\n";
135 $Message = substr($Message, 0, 50000 - strlen($Warning)) . $Warning;
136 }
137 if (isset($js_web) && $js_web) {
138 ?> <form method=post action="http://spamcop.net/sc" name="submitspam"
139 enctype="multipart/form-data"><?PHP
140 } else {
141 ?> <form method=post action="http://spamcop.net/sc" name="submitspam"
142 enctype="multipart/form-data" target="_blank"><?PHP
143 } ?>
144 <input type=hidden name=action value=submit>
145 <input type=hidden name=oldverbose value=1>
146 <input type=hidden name=code value="<?PHP echo $spamcop_id ?>">
147 <input type=hidden name=spam value="<?PHP
148 echo htmlspecialchars($Message);
149 ?>">
150 <input type=submit name="x1" value="Send Spam Report">
151 <?PHP }
152 ?> </form>
153 </td>
154 </tr>
155 </table>
156 </body>
157 </html>