define('SM_PATH','../../');
require_once(SM_PATH . 'include/validate.php');
+/**
+ * Internal spamcop plugin function.
+ *
+ * It is used to display similar action links.
+ */
function spamcop_enable_disable($option,$disable_action,$enable_action) {
if ($option) {
$ret= _("Enabled") . "(<a href=\"options.php?action=$disable_action\">" . _("Disable it") . "</a>)\n";
/* globals */
sqgetGlobalVar('action', $action);
sqgetGlobalVar('meth', $meth);
+sqgetGlobalVar('type', $type);
sqgetGlobalVar('ID' , $ID);
sqgetGlobalVar('username', $username, SQ_SESSION);
setPref($data_dir, $username, 'spamcop_method', $meth);
}
break;
+ case 'type':
+ if (isset($type)) {
+ setPref($data_dir, $username, 'spamcop_type', $type);
+ }
+ break;
case 'save_id':
if (isset($ID)) {
$ID = trim($ID);
<input type="submit" value="<?php echo _("Save Method"); ?>">
</td></form>
</tr>
+ <tr>
+ <?php
+ echo html_tag('td',_("Spam Service Type:"),'right');
+ ?>
+ <form method="post" action="options.php">
+ <td>
+ <select name="type">
+ <option value="free"
+ <?php
+ if ($spamcop_type == 'free') echo ' selected';
+ echo ">"._("Free reporting");
+ ?>
+ </option>
+ <option value="member"
+ <?php
+ if ($spamcop_type == 'member') echo ' selected';
+ echo ">"._("Member services");
+ ?>
+ </option>
+ </select>
+ <input type="hidden" name="action" value="type">
+ <input type="submit" value="<?php echo _("Save Service Type"); ?>">
+ </td></form>
+ </tr>
<tr>
<?php
echo html_tag('td',_("Your SpamCop authorization code:") . "<br />" .
echo "</p>\n";
echo "<p>";
-echo _("The SpamCop service will display information as it finds it, so scroll down until you see a form button. It might pause a little while it is looking up information, so be a little patient. Read what it says, and submit the spam. Close the browser window. Press Cancel or click on the appropriate mail folder to see messages and/or delete the spam.");
+echo _("The SpamCop service will display information as it finds it, so scroll down until you see a form button. It might pause a little while it is looking up information, so be a little patient. Read what it says, and submit the spam. Close the browser window. Press Cancel or click on the appropriate mail folder to see messages and/or delete the spam.");
+echo "</p>\n";
+
+echo "<p><b>". _("Spamcop Service Type") . "</b><br />\n";
+echo _("Service type option allows selecting which spamcop services you are using. Member services use different web reporting forms and does not display nags. You can purchase these services, if you want to support SpamCop.");
echo "</p>\n";
echo "<p>";
}
-// Load the settings
-// Validate some of it (make '' into 'default', etc.)
+/**
+ * Loads spamcop settings and validates some of values (make '' into 'default', etc.)
+ */
function spamcop_load() {
global $username, $data_dir, $spamcop_enabled, $spamcop_delete,
- $spamcop_method, $spamcop_id, $spamcop_quick_report;
+ $spamcop_method, $spamcop_id, $spamcop_quick_report, $spamcop_type;
$spamcop_enabled = getPref($data_dir, $username, 'spamcop_enabled');
$spamcop_delete = getPref($data_dir, $username, 'spamcop_delete');
$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 == '') {
-// This variable is not used
-// if (getPref($data_dir, $username, 'spamcop_form'))
-// $spamcop_method = 'web_form';
-// else
-
-// Default to web_form. It is faster.
+ // Default to web_form. It is faster.
$spamcop_method = 'web_form';
setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
}
$spamcop_method = 'web_form';
setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
}
+ if ($spamcop_type == '') {
+ $spamcop_type = 'free';
+ setPref($data_dir, $username, 'spamcop_type', $spamcop_type);
+ }
if ($spamcop_id == '')
$spamcop_enabled = 0;
}
-// Show the link on the read-a-message screen
+/**
+ * Shows spamcop link on the read-a-message screen
+ */
function spamcop_show_link() {
- global $spamcop_enabled, $spamcop_method, $spamcop_quick_report;
+ global $spamcop_enabled, $spamcop_method, $spamcop_quick_report,$javascript_on;
if (! $spamcop_enabled)
return;
/* GLOBALS */
sqgetGlobalVar('passed_id', $passed_id, SQ_FORM);
+ sqgetGlobalVar('passed_ent_id',$passed_ent_id,SQ_FORM);
sqgetGlobalVar('mailbox', $mailbox, SQ_FORM);
sqgetGlobalVar('startMessage', $startMessage, SQ_FORM);
/* END GLOBALS */
+ // catch unset passed_ent_id
+ if (! sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_FORM) ) {
+ $passed_ent_id = 0;
+ }
+
echo "<br>\n";
/*
$spamcop_method = 'web_form';
}
- if ($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) {
?><script language="javascript" 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); ?>" target="_blank">');
+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>");
-</script><noscript>
-<a href="../plugins/spamcop/spamcop.php?passed_id=<?PHP echo urlencode($passed_id); ?>&mailbox=<?PHP echo urlencode($mailbox); ?>&startMessage=<?PHP echo urlencode($startMessage); ?>">
-<?PHP echo _("Report as Spam"); ?></a>
-</noscript><?PHP
+</script><?PHP
} else {
-?><a href="../plugins/spamcop/spamcop.php?passed_id=<?PHP echo urlencode($passed_id); ?>&mailbox=<?PHP echo urlencode($mailbox); ?>&startMessage=<?PHP echo urlencode($startMessage); ?>">
+?><a href="../plugins/spamcop/spamcop.php?passed_id=<?PHP echo urlencode($passed_id); ?>&mailbox=<?PHP echo urlencode($mailbox); ?>&startMessage=<?PHP echo urlencode($startMessage); ?>&passed_ent_id=<?PHP echo urlencode($passed_ent_id); ?>">
<?PHP echo _("Report as Spam"); ?></a>
<?PHP
}
}
-
-// Show the link to our own custom options page
+/**
+ * Show spamcop options block
+ */
function spamcop_options()
{
global $optpage_blocks;
}
-// When we send the email, we optionally trash it then too
+/**
+ * When we send the email, we optionally trash it then too
+ */
function spamcop_while_sending()
{
global $mailbox, $spamcop_delete, $spamcop_is_composing, $auto_expunge,
require_once(SM_PATH . 'include/validate.php');
require_once(SM_PATH . 'functions/imap.php');
+/**
+ * Stores message in attachment directory, when email based reports are used
+ */
function getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
$passed_ent_id='', $imapConnection) {
global $attachments, $attachment_dir, $username, $data_dir, $uid_support;
-
+
$hashed_attachment_dir = getHashedDir($username, $attachment_dir);
if (!$passed_ent_id) {
$body_a = sqimap_run_command($imapConnection,
sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
sqgetGlobalVar('passed_id', $passed_id, SQ_GET);
+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);
}
/* 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 "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n";
+} else {
+ displayPageHeader($color,$mailbox);
+}
$imap_stream = sqimap_login($username, $key, $imapServerAddress,
$imapPort, 0);
$message = sqimap_get_message($imap_stream, $passed_id, $mailbox);
$composeMessage = getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
- $passed_ent_id='', $imap_stream);
+ $passed_ent_id, $imap_stream);
$compose_messages[$session] = $composeMessage;
sqsession_register($compose_messages, 'compose_messages');
<input type="hidden" name="session" value="<?PHP echo $session?>">
<input type="submit" name="send" value="Send Spam Report">
<?PHP } else {
- $spam_message = mime_fetch_body ($imap_stream, $passed_id, 0, 50000);
+ $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;
}
+ if ($spamcop_type=='member') {
+ $action_url="http://members.spamcop.net/sc";
+ } else {
+ $action_url="http://www.spamcop.net/sc";
+ }
if (isset($js_web) && $js_web) {
-?> <form method="post" action="http://www.spamcop.net/sc" name="submitspam"
- enctype="multipart/form-data"><?PHP
+ echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
+ " enctype=\"multipart/form-data\">\n";
} else {
-?> <form method="post" action="http://www.spamcop.net/sc" name="submitspam"
- enctype="multipart/form-data" target="_blank"><?PHP
+ echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
+ " enctype=\"multipart/form-data\" target=\"_blank\">\n";
} ?>
<input type="hidden" name="action" value="submit">
<input type="hidden" name="oldverbose" value="1">