X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=plugins%2Fspamcop%2Fspamcop.php;h=2d0d0acd0f8db171544a6969bca04ced4520f4b4;hp=0fb65efa78a8d8f02506a24cd287081afb4db1e5;hb=701e7beed3baca980039f978c6d536dd91cae775;hpb=1d80c108a1d741b7dcb562ea1cf6d2214322b192 diff --git a/plugins/spamcop/spamcop.php b/plugins/spamcop/spamcop.php index 0fb65efa..2d0d0acd 100644 --- a/plugins/spamcop/spamcop.php +++ b/plugins/spamcop/spamcop.php @@ -1,77 +1,44 @@ parent; - } - if ($response == 'OK') { - $subject = encodeHeader($message->rfc822_header->subject); - array_shift($body_a); - $body = implode('', $body_a) . "\r\n"; - - $localfilename = GenerateRandomString(32, 'FILE', 7); - $full_localfilename = "$hashed_attachment_dir/$localfilename"; - $fp = fopen( $full_localfilename, 'w'); - fwrite ($fp, $body); - fclose($fp); - - /* dirty relative dir fix */ - if (substr($attachment_dir,0,3) == '../') { - $attachment_dir = substr($attachment_dir,3); - $hashed_attachment_dir = getHashedDir($username, $attachment_dir); - } - $full_localfilename = "$hashed_attachment_dir/$localfilename"; - - $composeMessage->initAttachment('message/rfc822','email.txt', - $full_localfilename); - } - return $composeMessage; -} +/** + * spamcop.php -- SpamCop plugin -- main page + * + * @copyright 1999-2014 The SquirrelMail Project Team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @version $Id$ + * @package plugins + * @subpackage spamcop + */ + +/** + * Include the SquirrelMail initialization file. + */ +require('../../include/init.php'); +/* IMAP functions depend on date and mime */ +include_once(SM_PATH . 'functions/date.php'); +include_once(SM_PATH . 'functions/mime.php'); +/* IMAP functions */ +include_once(SM_PATH . 'functions/imap_general.php'); +include_once(SM_PATH . 'functions/imap_messages.php'); +/* plugin functions */ +include_once(SM_PATH . 'plugins/spamcop/functions.php'); + +include_once(SM_PATH . 'functions/compose.php'); /* GLOBALS */ -sqgetGlobalVar('username', $username, SQ_SESSION); -sqgetGlobalVar('key', $key, SQ_COOKIE); -sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); - sqgetGlobalVar('mailbox', $mailbox, SQ_GET); -sqgetGlobalVar('passed_id', $passed_id, SQ_GET); +sqgetGlobalVar('passed_id', $passed_id, SQ_GET, NULL, SQ_TYPE_BIGINT); +sqgetGlobalVar('js_web', $js_web, SQ_GET); if (! sqgetGlobalVar('startMessage', $startMessage, SQ_GET) ) { $startMessage = 1; } if (! sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) { - $passed_ent_id = ''; + $passed_ent_id = 0; +} +if (! sqgetGlobalVar('js_web', $js_web, SQ_GET) ) { + $js_web = 0; } sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION); @@ -82,14 +49,27 @@ if(! sqgetGlobalVar('composesession', $composesession, SQ_SESSION) ) { } /* END GLOBALS */ - - displayPageHeader($color, $mailbox); +// js_web variable is 1 only when link opens web based report page in new window +// and in new window menu line or extra javascript code is not needed. +if ($js_web) { + displayHTMLHeader(_("SpamCop reporting")); + echo "\n"; +} else { + displayPageHeader($color,$mailbox); +} + +/** is spamcop plugin disabled */ +if (! is_plugin_enabled('spamcop')) { + error_box(_("Plugin is disabled.")); + // display footer (closes html tags) and stop script execution + $oTemplate->display('footer.tpl'); + exit(); +} - $imap_stream = sqimap_login($username, $key, $imapServerAddress, - $imapPort, 0); + $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0); sqimap_mailbox_select($imap_stream, $mailbox); - if ($spamcop_method == 'quick_email' || + if ($spamcop_method == 'quick_email' || $spamcop_method == 'thorough_email') { // Use email-based reporting -- save as an attachment $session = "$composesession"+1; @@ -104,18 +84,18 @@ if(! sqgetGlobalVar('composesession', $composesession, SQ_SESSION) ) { $composeMessage->rfc822_header = $rfc822_header; $composeMessage->reply_rfc822_header = ''; $compose_messages[$session] = $composeMessage; - sqsession_register($compose_messages,'compose_messages'); + sqsession_register($compose_messages,'compose_messages'); } else { $composeMessage=$compose_messages[$session]; } $message = sqimap_get_message($imap_stream, $passed_id, $mailbox); - $composeMessage = getMessage_RFC822_Attachment($message, $composeMessage, $passed_id, - $passed_ent_id='', $imap_stream); + $composeMessage = spamcop_getMessage_RFC822_Attachment($message, $composeMessage, $passed_id, + $passed_ent_id, $imap_stream); - $compose_messages[$session] = $composeMessage; - sqsession_register($compose_messages, 'compose_messages'); + $compose_messages[$session] = $composeMessage; + sqsession_register($compose_messages, 'compose_messages'); $fn = getPref($data_dir, $username, 'full_name'); $em = getPref($data_dir, $username, 'email_address'); @@ -127,7 +107,7 @@ if(! sqgetGlobalVar('composesession', $composesession, SQ_SESSION) ) { echo "

"; -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."); +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."); echo "

"; ?> @@ -135,58 +115,61 @@ echo "

";
-
- - '; + echo '\n"; } else { - ?> - - - - + + +"; } ?>
-
- - - - - - - - + + + + + + + +\n"; +} else { + $spam_message = mime_fetch_body ($imap_stream, $passed_id, $passed_ent_id, 50000); if (strlen($spam_message) == 50000) { $Warning = "\n[truncated by SpamCop]\n"; $spam_message = substr($spam_message, 0, 50000 - strlen($Warning)) . $Warning; } + $action_url="http://members.spamcop.net/sc"; + if (isset($js_web) && $js_web) { -?> \n"; } else { -?> \n"; } ?> - - - - - - + + + \n"; + } ?>
- + +