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'); |
13a35bde |
17 | /* IMAP functions depend on date and mime */ |
18 | include_once(SM_PATH . 'functions/date.php'); |
19 | include_once(SM_PATH . 'functions/mime.php'); |
20 | /* IMAP functions */ |
202bcbcc |
21 | include_once(SM_PATH . 'functions/imap_general.php'); |
22 | include_once(SM_PATH . 'functions/imap_messages.php'); |
da297dd0 |
23 | /* plugin functions */ |
24 | include_once(SM_PATH . 'plugins/spamcop/functions.php'); |
1e89ed41 |
25 | |
8ddc4111 |
26 | /* GLOBALS */ |
04f6008a |
27 | |
8ddc4111 |
28 | sqgetGlobalVar('mailbox', $mailbox, SQ_GET); |
29 | sqgetGlobalVar('passed_id', $passed_id, SQ_GET); |
9a422982 |
30 | sqgetGlobalVar('js_web', $js_web, SQ_GET); |
8ddc4111 |
31 | |
32 | if (! sqgetGlobalVar('startMessage', $startMessage, SQ_GET) ) { |
33 | $startMessage = 1; |
34 | } |
35 | if (! sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) { |
9a422982 |
36 | $passed_ent_id = 0; |
37 | } |
38 | if (! sqgetGlobalVar('js_web', $js_web, SQ_GET) ) { |
39 | $js_web = 0; |
8ddc4111 |
40 | } |
41 | |
42 | sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION); |
43 | |
44 | if(! sqgetGlobalVar('composesession', $composesession, SQ_SESSION) ) { |
45 | $composesession = 0; |
46 | sqsession_register($composesession, 'composesession'); |
47 | } |
48 | /* END GLOBALS */ |
1e89ed41 |
49 | |
9a422982 |
50 | // js_web variable is 1 only when link opens web based report page in new window |
51 | // and in new window menu line or extra javascript code is not needed. |
52 | if ($js_web) { |
7d56f214 |
53 | displayHTMLHeader(_("SpamCop reporting")); |
9a422982 |
54 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n"; |
55 | } else { |
56 | displayPageHeader($color,$mailbox); |
57 | } |
5121598d |
58 | |
da297dd0 |
59 | /** is spamcop plugin disabled */ |
60 | if (! is_plugin_enabled('spamcop')) { |
1b858d86 |
61 | error_box(_("Plugin is disabled.")); |
62 | // display footer (closes html tags) and stop script execution |
63 | $oTemplate->display('footer.tpl'); |
da297dd0 |
64 | exit(); |
65 | } |
66 | |
045ec1a1 |
67 | $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0); |
5121598d |
68 | sqimap_mailbox_select($imap_stream, $mailbox); |
5121598d |
69 | |
91e0dccc |
70 | if ($spamcop_method == 'quick_email' || |
5121598d |
71 | $spamcop_method == 'thorough_email') { |
72 | // Use email-based reporting -- save as an attachment |
1e89ed41 |
73 | $session = "$composesession"+1; |
74 | $composesession = $session; |
75 | sqsession_register($composesession,'composesession'); |
76 | if (!isset($compose_messages)) { |
77 | $compose_messages = array(); |
430be822 |
78 | } |
1e89ed41 |
79 | if (!isset($compose_messages[$session]) || ($compose_messages[$session] == NULL)) { |
80 | $composeMessage = new Message(); |
81 | $rfc822_header = new Rfc822Header(); |
82 | $composeMessage->rfc822_header = $rfc822_header; |
83 | $composeMessage->reply_rfc822_header = ''; |
84 | $compose_messages[$session] = $composeMessage; |
91e0dccc |
85 | sqsession_register($compose_messages,'compose_messages'); |
1e89ed41 |
86 | } else { |
87 | $composeMessage=$compose_messages[$session]; |
430be822 |
88 | } |
89 | |
04f6008a |
90 | |
1e89ed41 |
91 | $message = sqimap_get_message($imap_stream, $passed_id, $mailbox); |
2b42190d |
92 | $composeMessage = spamcop_getMessage_RFC822_Attachment($message, $composeMessage, $passed_id, |
9a422982 |
93 | $passed_ent_id, $imap_stream); |
1e89ed41 |
94 | |
91e0dccc |
95 | $compose_messages[$session] = $composeMessage; |
96 | sqsession_register($compose_messages, 'compose_messages'); |
1e89ed41 |
97 | |
98 | $fn = getPref($data_dir, $username, 'full_name'); |
99 | $em = getPref($data_dir, $username, 'email_address'); |
100 | |
101 | $HowItLooks = $fn . ' '; |
102 | if ($em != '') |
5121598d |
103 | $HowItLooks .= '<' . $em . '>'; |
1e89ed41 |
104 | } |
5121598d |
105 | |
5121598d |
106 | |
2bd52bbe |
107 | echo "<p>"; |
99aaff8b |
108 | 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 |
109 | echo "</p>"; |
110 | |
111 | ?> |
5121598d |
112 | |
8ddc4111 |
113 | <table align="center" width="75%" border="0" cellpadding="0" cellspacing="0"> |
5121598d |
114 | <tr> |
8ddc4111 |
115 | <td align="left" valign="top"> |
6fd95361 |
116 | <?php if (isset($js_web) && $js_web) { |
7d56f214 |
117 | echo '<form method="post" action="javascript:return false">'; |
c435f076 |
118 | echo '<input type="button" value="' . _("Close Window") . "\" onclick=\"window.close(); return true;\" />\n"; |
5121598d |
119 | } else { |
8ddc4111 |
120 | ?><form method="post" action="../../src/right_main.php"> |
6fd95361 |
121 | <input type="hidden" name="mailbox" value="<?php echo htmlspecialchars($mailbox) ?>" /> |
122 | <input type="hidden" name="startMessage" value="<?php echo htmlspecialchars($startMessage) ?>" /> |
123 | <?php |
7d56f214 |
124 | echo '<input type="submit" value="' . _("Cancel / Done") . "\" />"; |
5121598d |
125 | } |
126 | ?></form> |
127 | </td> |
8ddc4111 |
128 | <td align="right" valign="top"> |
6fd95361 |
129 | <?php if ($spamcop_method == 'thorough_email' || |
5121598d |
130 | $spamcop_method == 'quick_email') { |
131 | if ($spamcop_method == 'thorough_email') |
132 | $report_email = 'submit.' . $spamcop_id . '@spam.spamcop.net'; |
133 | else |
134 | $report_email = 'quick.' . $spamcop_id . '@spam.spamcop.net'; |
1e89ed41 |
135 | $form_action = SM_PATH . 'src/compose.php'; |
6fd95361 |
136 | ?> <form method="post" action="<?php echo $form_action?>"> |
137 | <input type="hidden" name="mailbox" value="<?php echo htmlspecialchars($mailbox) ?>" /> |
138 | <input type="hidden" name="spamcop_is_composing" value="<?php echo htmlspecialchars($passed_id) ?>" /> |
139 | <input type="hidden" name="send_to" value="<?php echo htmlspecialchars($report_email)?>" /> |
7d56f214 |
140 | <input type="hidden" name="subject" value="reply anyway" /> |
141 | <input type="hidden" name="identity" value="0" /> |
6fd95361 |
142 | <input type="hidden" name="session" value="<?php echo $session?>" /> |
7d56f214 |
143 | <?php |
144 | echo '<input type="submit" name="send" value="' . _("Send Spam Report") . "\" />\n"; |
145 | } else { |
9a422982 |
146 | $spam_message = mime_fetch_body ($imap_stream, $passed_id, $passed_ent_id, 50000); |
9538cd4c |
147 | |
2b5fddf5 |
148 | if (strlen($spam_message) == 50000) { |
5121598d |
149 | $Warning = "\n[truncated by SpamCop]\n"; |
2b5fddf5 |
150 | $spam_message = substr($spam_message, 0, 50000 - strlen($Warning)) . $Warning; |
5121598d |
151 | } |
13a35bde |
152 | $action_url="http://members.spamcop.net/sc"; |
153 | |
5121598d |
154 | if (isset($js_web) && $js_web) { |
9a422982 |
155 | echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"". |
156 | " enctype=\"multipart/form-data\">\n"; |
5121598d |
157 | } else { |
9a422982 |
158 | echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"". |
159 | " enctype=\"multipart/form-data\" target=\"_blank\">\n"; |
5121598d |
160 | } ?> |
7d56f214 |
161 | <input type="hidden" name="action" value="submit" /> |
162 | <input type="hidden" name="oldverbose" value="1" /> |
6fd95361 |
163 | <input type="hidden" name="spam" value="<?php echo htmlspecialchars($spam_message); ?>" /> |
7d56f214 |
164 | <?php |
91e0dccc |
165 | echo '<input type="submit" name="x1" value="' . _("Send Spam Report") . "\" />\n"; |
7d56f214 |
166 | } |
5121598d |
167 | ?> </form> |
168 | </td> |
169 | </tr> |
170 | </table> |
7d56f214 |
171 | </body> |
2128bbc6 |
172 | </html> |