Source for file functions.php
Documentation is available at functions.php
* SpamCop plugin - functions
* @copyright 1999-2020 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: functions.php 14845 2020-01-07 08:09:34Z pdontthink $
/* sqgetGlobalVar(), getPref(), setPref(), sqimap functions are used */
* Disable Quick Reporting by default
* @global boolean $spamcop_quick_report
global $spamcop_quick_report;
$spamcop_quick_report =
false;
* Loads spamcop settings and validates some of values (make '' into 'default', etc.)
* Internal function used to reduce size of setup.php
function spamcop_load_function() {
global $username, $data_dir, $spamcop_enabled, $spamcop_delete, $spamcop_save,
$spamcop_enabled =
getPref($data_dir, $username, 'spamcop_enabled');
$spamcop_delete =
getPref($data_dir, $username, 'spamcop_delete');
$spamcop_save =
getPref($data_dir, $username, 'spamcop_save',true);
$spamcop_method =
getPref($data_dir, $username, 'spamcop_method');
$spamcop_type =
getPref($data_dir, $username, 'spamcop_type');
$spamcop_id =
getPref($data_dir, $username, 'spamcop_id');
if ($spamcop_method ==
'') {
// Default to web_form. It is faster.
$spamcop_method =
'web_form';
setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
if (! $spamcop_quick_report &&
$spamcop_method==
'quick_email') {
$spamcop_method =
'web_form';
setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
if ($spamcop_type ==
'') {
setPref($data_dir, $username, 'spamcop_type', $spamcop_type);
* Add spamcop link to read_body (internal function)
function spamcop_show_link_function(&$links) {
$startMessage = (int)
$startMessage;
// catch unset passed_ent_id
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';
// FIXME: do we need this javascript and if so, fix it
// <script type="text/javascript">
// document.write('<a href="../plugins/spamcop/spamcop.php?passed_id=<php echo urlencode($passed_id); >&js_web=1&mailbox=<php echo urlencode($mailbox); >&passed_ent_id=<php echo urlencode($passed_ent_id); >" target="_blank">');
//document.write("<php echo _("Report as Spam"); >");
//document.write("</a>");
$url =
'../plugins/spamcop/spamcop.php?passed_id=' .
urlencode($passed_id) .
'&passed_ent_id=' .
urlencode($passed_ent_id);
$links[] =
array ( 'URL' =>
$url,
'Text' =>
_("Report as Spam")
* Add spamcop option block (internal function)
function spamcop_options_function() {
$optpage_blocks[] =
array(
'name' =>
_("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."),
* 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.
function spamcop_while_sending_function() {
global $mailbox, $spamcop_delete, $spamcop_save, $spamcop_is_composing, $auto_expunge,
$username, $imapServerAddress, $imapPort, $imap_stream_options;
$imapConnection =
sqimap_login($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
// 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.
$compose_new_win =
false;
* Internal spamcop plugin function.
* It is used to display similar action links.
function spamcop_enable_disable($option,$disable_action,$enable_action) {
$ret=
_("Enabled") .
" (<a href=\"options.php?action=$disable_action\">" .
_("Disable it") .
"</a>)\n";
$ret =
_("Disabled") .
" (<a href=\"options.php?action=$enable_action\">" .
_("Enable it") .
"</a>)\n";
* Stores message in attachment directory, when email based reports are used
* @todo Duplicate code in src/compose.php
function spamcop_getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
$passed_ent_id=
'', $imapConnection) {
global $username, $attachment_dir;
'FETCH '.
$passed_id.
' RFC822',
TRUE, $response, $readmessage,
'FETCH '.
$passed_id.
' BODY['.
$passed_ent_id.
']',
TRUE, $response, $readmessage,TRUE);
$message =
$message->parent;
$body =
implode('', $body_a) .
"\r\n";
$hashed_attachment_dir =
getHashedDir($username, $attachment_dir);
$fp =
fopen("$hashed_attachment_dir/$filename", 'wb');
$composeMessage->initAttachment('message/rfc822','email.txt',
Documentation generated on Mon, 13 Jan 2020 04:22:34 +0100 by phpDocumentor 1.4.3