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