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