<?php
+
/**
* spamcop.php -- SpamCop plugin -- main page
*
- * @copyright (c) 1999-2004 The SquirrelMail development team
+ * @copyright 1999-2009 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @package plugins
* @subpackage spamcop
*/
-/** @ignore */
-define('SM_PATH','../../');
-
- /* SquirrelMail required files. */
-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
- * @access private
+ * Include the SquirrelMail initialization file.
*/
-function 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;
-}
-
+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) ) {
displayPageHeader($color,$mailbox);
}
- $imap_stream = sqimap_login($username, $key, $imapServerAddress,
- $imapPort, 0);
+/** 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, false, $imapServerAddress, $imapPort, 0);
sqimap_mailbox_select($imap_stream, $mailbox);
if ($spamcop_method == 'quick_email' ||
$message = sqimap_get_message($imap_stream, $passed_id, $mailbox);
- $composeMessage = getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
+ $composeMessage = spamcop_getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
$passed_ent_id, $imap_stream);
$compose_messages[$session] = $composeMessage;
<td align="left" valign="top">
<?php if (isset($js_web) && $js_web) {
echo '<form method="post" action="javascript:return false">';
- echo '<input type="button" value="' . _("Close Window") . "\" onClick=\"window.close(); return true;\" />\n";
+ echo '<input type="button" value="' . _("Close Window") . "\" onclick=\"window.close(); return true;\" />\n";
} else {
- ?><form method="post" action="../../src/right_main.php">
+ ?><form method="post" action="<?php echo sqm_baseuri(); ?>src/right_main.php">
<input type="hidden" name="mailbox" value="<?php echo htmlspecialchars($mailbox) ?>" />
<input type="hidden" name="startMessage" value="<?php echo htmlspecialchars($startMessage) ?>" />
<?php
$report_email = 'submit.' . $spamcop_id . '@spam.spamcop.net';
else
$report_email = 'quick.' . $spamcop_id . '@spam.spamcop.net';
- $form_action = SM_PATH . 'src/compose.php';
+ $form_action = sqm_baseuri() . 'src/compose.php';
?> <form method="post" action="<?php echo $form_action?>">
<input type="hidden" name="mailbox" value="<?php echo htmlspecialchars($mailbox) ?>" />
<input type="hidden" name="spamcop_is_composing" value="<?php echo htmlspecialchars($passed_id) ?>" />
$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";
- }
+ $action_url="http://members.spamcop.net/sc";
+
if (isset($js_web) && $js_web) {
echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
" enctype=\"multipart/form-data\">\n";
} ?>
<input type="hidden" name="action" value="submit" />
<input type="hidden" name="oldverbose" value="1" />
- <input type="hidden" name="code" value="<?php echo htmlspecialchars($spamcop_id) ?>" />
<input type="hidden" name="spam" value="<?php echo htmlspecialchars($spam_message); ?>" />
<?php
echo '<input type="submit" name="x1" value="' . _("Send Spam Report") . "\" />\n";
</tr>
</table>
</body>
-</html>
\ No newline at end of file
+</html>