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