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