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