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