\n";
/*
Catch situation when user uses quick_email and does not update
preferences. User gets web_form link. If prefs are set to
quick_email format - they will be updated after clicking the link
*/
if (! $spamcop_quick_report && $spamcop_method=='quick_email') {
$spamcop_method = 'web_form';
}
// Javascript is used only in web based reporting
// don't insert javascript if javascript is disabled
if ($spamcop_method == 'web_form' && $javascript_on) {
?>
_("SpamCop - Spam Reporting"),
'url' => '../plugins/spamcop/options.php',
'desc' => _("Help fight the battle against unsolicited email. SpamCop reads the spam email and determines the correct addresses to send complaints to. Quite fast, really smart, and easy to use."),
'js' => false
);
}
/**
* Process messages that are submitted by email.
*
* Delete spam if user wants to delete it. Don't save submitted emails.
* Implement overrides that fix compose.php behavior.
* @since 1.5.1
* @access private
*/
function spamcop_while_sending_function() {
global $mailbox, $spamcop_delete, $spamcop_save, $spamcop_is_composing, $auto_expunge,
$username, $imapServerAddress, $imapPort;
if (sqgetGlobalVar('spamcop_is_composing' , $spamcop_is_composing)) {
// delete spam message
if ($spamcop_delete) {
$imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
sqimap_mailbox_select($imapConnection, $mailbox);
sqimap_msgs_list_delete($imapConnection, $mailbox, array($spamcop_is_composing));
if ($auto_expunge)
sqimap_mailbox_expunge($imapConnection, $mailbox, true);
}
if (! $spamcop_save) {
// disable use of send folder.
// Temporally override in order to disable saving of 'reply anyway' messages.
global $default_move_to_sent;
$default_move_to_sent=false;
}
// change default email composition setting. Plugin always operates in right frame.
// make sure that compose.php redirects to right page. Temporally override.
global $compose_new_win;
$compose_new_win = false;
}
}
/**
* Internal spamcop plugin function.
*
* It is used to display similar action links.
* @access private
*/
function spamcop_enable_disable($option,$disable_action,$enable_action) {
if ($option) {
$ret= _("Enabled") . " (" . _("Disable it") . ")\n";
} else {
$ret = _("Disabled") . " (" . _("Enable it") . ")\n";
}
return $ret;
}
/**
* Stores message in attachment directory, when email based reports are used
* @access private
* @todo Duplicate code in src/compose.php
*/
function spamcop_getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
$passed_ent_id='', $imapConnection) {
global $attachment_dir, $username;
$hashed_attachment_dir = getHashedDir($username, $attachment_dir);
if (!$passed_ent_id) {
$body_a = sqimap_run_command($imapConnection,
'FETCH '.$passed_id.' RFC822',
TRUE, $response, $readmessage,
TRUE);
} else {
$body_a = sqimap_run_command($imapConnection,
'FETCH '.$passed_id.' BODY['.$passed_ent_id.']',
TRUE, $response, $readmessage,TRUE);
$message = $message->parent;
}
if ($response == 'OK') {
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;
}