fix listcommands template for Send form changes
[squirrelmail.git] / plugins / spamcop / spamcop.php
index 15a23fc27d333c30bbd02ac53cf1b289b6f0bba7..9e9ee06416e8deefb34337ecc5e355ea4e0e7952 100644 (file)
@@ -1,32 +1,34 @@
 <?php
+
 /**
  * spamcop.php -- SpamCop plugin -- main page
  *
- * @copyright (c) 1999-2005 The SquirrelMail Project Team
+ * @copyright &copy; 1999-2007 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');
-include_once(SM_PATH . 'functions/display_messages.php');
-include_once(SM_PATH . 'functions/imap.php');
+/**
+ * Include the SquirrelMail initialization file.
+ */
+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');
 
-/* GLOBALS */
+include_once(SM_PATH . 'functions/compose.php');
 
-sqgetGlobalVar('username', $username, SQ_SESSION);
-sqgetGlobalVar('key',      $key,      SQ_COOKIE);
-sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
+/* GLOBALS */
 
 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) ) {
@@ -58,13 +60,13 @@ if ($js_web) {
 
 /** is spamcop plugin disabled */
 if (! is_plugin_enabled('spamcop')) {
-    error_box(_("Plugin is disabled."),$color);
-    echo "\n</body></html>\n";
+    error_box(_("Plugin is disabled."));
+    // display footer (closes html tags) and stop script execution
+    $oTemplate->display('footer.tpl');
     exit();
 }
 
-    $imap_stream = sqimap_login($username, $key, $imapServerAddress,
-       $imapPort, 0);
+    $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
     sqimap_mailbox_select($imap_stream, $mailbox);
 
     if ($spamcop_method == 'quick_email' ||
@@ -89,7 +91,7 @@ if (! is_plugin_enabled('spamcop')) {
 
 
         $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;
@@ -117,7 +119,7 @@ echo "</p>";
   echo '<form method="post" action="javascript:return false">';
   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
@@ -132,7 +134,7 @@ echo "</p>";
       $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) ?>" />
@@ -149,11 +151,8 @@ echo "</p>";
       $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";
@@ -163,7 +162,6 @@ echo "</p>";
    } ?>
   <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";
@@ -173,4 +171,4 @@ echo "</p>";
 </tr>
 </table>
 </body>
-</html>
\ No newline at end of file
+</html>