5121598d |
1 | <?php |
4b4abf93 |
2 | |
91e0dccc |
3 | /** |
f3a91d6b |
4 | * spamcop.php -- SpamCop plugin -- main page |
5 | * |
47ccfad4 |
6 | * @copyright © 1999-2006 The SquirrelMail Project Team |
f3a91d6b |
7 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
8 | * @version $Id$ |
9 | * @package plugins |
10 | * @subpackage spamcop |
11 | */ |
5121598d |
12 | |
202bcbcc |
13 | /** |
14 | * Include the SquirrelMail initialization file. |
15 | */ |
16 | require('../../include/init.php'); |
7afb9a75 |
17 | |
202bcbcc |
18 | include_once(SM_PATH . 'functions/imap_general.php'); |
19 | include_once(SM_PATH . 'functions/imap_messages.php'); |
da297dd0 |
20 | /* plugin functions */ |
21 | include_once(SM_PATH . 'plugins/spamcop/functions.php'); |
1e89ed41 |
22 | |
8ddc4111 |
23 | /* GLOBALS */ |
04f6008a |
24 | |
8ddc4111 |
25 | sqgetGlobalVar('username', $username, SQ_SESSION); |
26 | sqgetGlobalVar('key', $key, SQ_COOKIE); |
27 | sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); |
28 | |
29 | sqgetGlobalVar('mailbox', $mailbox, SQ_GET); |
30 | sqgetGlobalVar('passed_id', $passed_id, SQ_GET); |
9a422982 |
31 | sqgetGlobalVar('js_web', $js_web, SQ_GET); |
8ddc4111 |
32 | |
33 | if (! sqgetGlobalVar('startMessage', $startMessage, SQ_GET) ) { |
34 | $startMessage = 1; |
35 | } |
36 | if (! sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) { |
9a422982 |
37 | $passed_ent_id = 0; |
38 | } |
39 | if (! sqgetGlobalVar('js_web', $js_web, SQ_GET) ) { |
40 | $js_web = 0; |
8ddc4111 |
41 | } |
42 | |
43 | sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION); |
44 | |
45 | if(! sqgetGlobalVar('composesession', $composesession, SQ_SESSION) ) { |
46 | $composesession = 0; |
47 | sqsession_register($composesession, 'composesession'); |
48 | } |
49 | /* END GLOBALS */ |
1e89ed41 |
50 | |
9a422982 |
51 | // js_web variable is 1 only when link opens web based report page in new window |
52 | // and in new window menu line or extra javascript code is not needed. |
53 | if ($js_web) { |
7d56f214 |
54 | displayHTMLHeader(_("SpamCop reporting")); |
9a422982 |
55 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n"; |
56 | } else { |
57 | displayPageHeader($color,$mailbox); |
58 | } |
5121598d |
59 | |
da297dd0 |
60 | /** is spamcop plugin disabled */ |
61 | if (! is_plugin_enabled('spamcop')) { |
62 | error_box(_("Plugin is disabled."),$color); |
63 | echo "\n</body></html>\n"; |
64 | exit(); |
65 | } |
66 | |
91e0dccc |
67 | $imap_stream = sqimap_login($username, $key, $imapServerAddress, |
5121598d |
68 | $imapPort, 0); |
69 | sqimap_mailbox_select($imap_stream, $mailbox); |
5121598d |
70 | |
91e0dccc |
71 | if ($spamcop_method == 'quick_email' || |
5121598d |
72 | $spamcop_method == 'thorough_email') { |
73 | // Use email-based reporting -- save as an attachment |
1e89ed41 |
74 | $session = "$composesession"+1; |
75 | $composesession = $session; |
76 | sqsession_register($composesession,'composesession'); |
77 | if (!isset($compose_messages)) { |
78 | $compose_messages = array(); |
430be822 |
79 | } |
1e89ed41 |
80 | if (!isset($compose_messages[$session]) || ($compose_messages[$session] == NULL)) { |
81 | $composeMessage = new Message(); |
82 | $rfc822_header = new Rfc822Header(); |
83 | $composeMessage->rfc822_header = $rfc822_header; |
84 | $composeMessage->reply_rfc822_header = ''; |
85 | $compose_messages[$session] = $composeMessage; |
91e0dccc |
86 | sqsession_register($compose_messages,'compose_messages'); |
1e89ed41 |
87 | } else { |
88 | $composeMessage=$compose_messages[$session]; |
430be822 |
89 | } |
90 | |
04f6008a |
91 | |
1e89ed41 |
92 | $message = sqimap_get_message($imap_stream, $passed_id, $mailbox); |
2b42190d |
93 | $composeMessage = spamcop_getMessage_RFC822_Attachment($message, $composeMessage, $passed_id, |
9a422982 |
94 | $passed_ent_id, $imap_stream); |
1e89ed41 |
95 | |
91e0dccc |
96 | $compose_messages[$session] = $composeMessage; |
97 | sqsession_register($compose_messages, 'compose_messages'); |
1e89ed41 |
98 | |
99 | $fn = getPref($data_dir, $username, 'full_name'); |
100 | $em = getPref($data_dir, $username, 'email_address'); |
101 | |
102 | $HowItLooks = $fn . ' '; |
103 | if ($em != '') |
5121598d |
104 | $HowItLooks .= '<' . $em . '>'; |
1e89ed41 |
105 | } |
5121598d |
106 | |
5121598d |
107 | |
2bd52bbe |
108 | echo "<p>"; |
99aaff8b |
109 | echo _("Sending this spam report will give you back a reply with URLs that you can click on to properly report this spam message to the proper authorities. This is a free service. By pressing the \"Send Spam Report\" button, you agree to follow SpamCop's rules/terms of service/etc."); |
2bd52bbe |
110 | echo "</p>"; |
111 | |
112 | ?> |
5121598d |
113 | |
8ddc4111 |
114 | <table align="center" width="75%" border="0" cellpadding="0" cellspacing="0"> |
5121598d |
115 | <tr> |
8ddc4111 |
116 | <td align="left" valign="top"> |
6fd95361 |
117 | <?php if (isset($js_web) && $js_web) { |
7d56f214 |
118 | echo '<form method="post" action="javascript:return false">'; |
c435f076 |
119 | echo '<input type="button" value="' . _("Close Window") . "\" onclick=\"window.close(); return true;\" />\n"; |
5121598d |
120 | } else { |
8ddc4111 |
121 | ?><form method="post" action="../../src/right_main.php"> |
6fd95361 |
122 | <input type="hidden" name="mailbox" value="<?php echo htmlspecialchars($mailbox) ?>" /> |
123 | <input type="hidden" name="startMessage" value="<?php echo htmlspecialchars($startMessage) ?>" /> |
124 | <?php |
7d56f214 |
125 | echo '<input type="submit" value="' . _("Cancel / Done") . "\" />"; |
5121598d |
126 | } |
127 | ?></form> |
128 | </td> |
8ddc4111 |
129 | <td align="right" valign="top"> |
6fd95361 |
130 | <?php if ($spamcop_method == 'thorough_email' || |
5121598d |
131 | $spamcop_method == 'quick_email') { |
132 | if ($spamcop_method == 'thorough_email') |
133 | $report_email = 'submit.' . $spamcop_id . '@spam.spamcop.net'; |
134 | else |
135 | $report_email = 'quick.' . $spamcop_id . '@spam.spamcop.net'; |
1e89ed41 |
136 | $form_action = SM_PATH . 'src/compose.php'; |
6fd95361 |
137 | ?> <form method="post" action="<?php echo $form_action?>"> |
138 | <input type="hidden" name="mailbox" value="<?php echo htmlspecialchars($mailbox) ?>" /> |
139 | <input type="hidden" name="spamcop_is_composing" value="<?php echo htmlspecialchars($passed_id) ?>" /> |
140 | <input type="hidden" name="send_to" value="<?php echo htmlspecialchars($report_email)?>" /> |
7d56f214 |
141 | <input type="hidden" name="subject" value="reply anyway" /> |
142 | <input type="hidden" name="identity" value="0" /> |
6fd95361 |
143 | <input type="hidden" name="session" value="<?php echo $session?>" /> |
7d56f214 |
144 | <?php |
145 | echo '<input type="submit" name="send" value="' . _("Send Spam Report") . "\" />\n"; |
146 | } else { |
9a422982 |
147 | $spam_message = mime_fetch_body ($imap_stream, $passed_id, $passed_ent_id, 50000); |
9538cd4c |
148 | |
2b5fddf5 |
149 | if (strlen($spam_message) == 50000) { |
5121598d |
150 | $Warning = "\n[truncated by SpamCop]\n"; |
2b5fddf5 |
151 | $spam_message = substr($spam_message, 0, 50000 - strlen($Warning)) . $Warning; |
5121598d |
152 | } |
9a422982 |
153 | if ($spamcop_type=='member') { |
154 | $action_url="http://members.spamcop.net/sc"; |
155 | } else { |
156 | $action_url="http://www.spamcop.net/sc"; |
157 | } |
5121598d |
158 | if (isset($js_web) && $js_web) { |
9a422982 |
159 | echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"". |
160 | " enctype=\"multipart/form-data\">\n"; |
5121598d |
161 | } else { |
9a422982 |
162 | echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"". |
163 | " enctype=\"multipart/form-data\" target=\"_blank\">\n"; |
5121598d |
164 | } ?> |
7d56f214 |
165 | <input type="hidden" name="action" value="submit" /> |
166 | <input type="hidden" name="oldverbose" value="1" /> |
6fd95361 |
167 | <input type="hidden" name="code" value="<?php echo htmlspecialchars($spamcop_id) ?>" /> |
168 | <input type="hidden" name="spam" value="<?php echo htmlspecialchars($spam_message); ?>" /> |
7d56f214 |
169 | <?php |
91e0dccc |
170 | echo '<input type="submit" name="x1" value="' . _("Send Spam Report") . "\" />\n"; |
7d56f214 |
171 | } |
5121598d |
172 | ?> </form> |
173 | </td> |
174 | </tr> |
175 | </table> |
7d56f214 |
176 | </body> |
91e0dccc |
177 | </html> |