4 * spamcop.php -- SpamCop plugin -- main page
6 * @copyright 1999-2009 The SquirrelMail Project Team
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 * Include the SquirrelMail initialization file.
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');
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');
26 include_once(SM_PATH
. 'functions/compose.php');
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
);
34 if (! sqgetGlobalVar('startMessage', $startMessage, SQ_GET
) ) {
37 if (! sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET
) ) {
40 if (! sqgetGlobalVar('js_web', $js_web, SQ_GET
) ) {
44 sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION
);
46 if(! sqgetGlobalVar('composesession', $composesession, SQ_SESSION
) ) {
48 sqsession_register($composesession, 'composesession');
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.
55 displayHTMLHeader(_("SpamCop reporting"));
56 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n";
58 displayPageHeader($color,$mailbox);
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');
69 $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
70 sqimap_mailbox_select($imap_stream, $mailbox);
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();
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');
89 $composeMessage=$compose_messages[$session];
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);
97 $compose_messages[$session] = $composeMessage;
98 sqsession_register($compose_messages, 'compose_messages');
100 $fn = getPref($data_dir, $username, 'full_name');
101 $em = getPref($data_dir, $username, 'email_address');
103 $HowItLooks = $fn . ' ';
105 $HowItLooks .= '<' . $em . '>';
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.");
115 <table align
="center" width
="75%" border
="0" cellpadding
="0" cellspacing
="0">
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";
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) ?>" />
126 echo '<input type="submit" value="' . _("Cancel / Done") . "\" />";
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';
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?>" />
147 echo '<input type="submit" name="send1" value="' . _("Send Spam Report") . "\" />\n";
149 $spam_message = mime_fetch_body ($imap_stream, $passed_id, $passed_ent_id, 50000);
151 if (strlen($spam_message) == 50000) {
152 $Warning = "\n[truncated by SpamCop]\n";
153 $spam_message = substr($spam_message, 0, 50000 - strlen($Warning)) . $Warning;
155 $action_url="http://members.spamcop.net/sc";
157 if (isset($js_web) && $js_web) {
158 echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
159 " enctype=\"multipart/form-data\">\n";
161 echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
162 " enctype=\"multipart/form-data\" target=\"_blank\">\n";
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); ?>" />
168 echo '<input type="submit" name="x1" value="' . _("Send Spam Report") . "\" />\n";