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