Source for file spamcop.php

Documentation is available at spamcop.php

  1. <?php
  2.  
  3. /**
  4.  * spamcop.php -- SpamCop plugin -- main page
  5.  *
  6.  * @copyright 1999-2018 The SquirrelMail Project Team
  7.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8.  * @version $Id: spamcop.php 14750 2018-01-16 23:44:07Z pdontthink $
  9.  * @package plugins
  10.  * @subpackage spamcop
  11.  */
  12.  
  13. /**
  14.  * Include the SquirrelMail initialization file.
  15.  */
  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');
  20. /* IMAP functions */
  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');
  25.  
  26. include_once(SM_PATH 'functions/compose.php');
  27.  
  28. /* GLOBALS */
  29.  
  30. sqgetGlobalVar('mailbox'$mailboxSQ_GET);
  31. sqgetGlobalVar('passed_id'$passed_idSQ_GETNULLSQ_TYPE_BIGINT);
  32. sqgetGlobalVar('js_web'$js_webSQ_GET);
  33.  
  34. if (sqgetGlobalVar('startMessage'$startMessageSQ_GET) ) {
  35.     $startMessage 1;
  36. }
  37. if (sqgetGlobalVar('passed_ent_id'$passed_ent_idSQ_GET) ) {
  38.     $passed_ent_id 0;
  39. }
  40. if (sqgetGlobalVar('js_web'$js_webSQ_GET) ) {
  41.     $js_web 0;
  42. }
  43.  
  44. sqgetGlobalVar('compose_messages'$compose_messagesSQ_SESSION);
  45.  
  46. if(sqgetGlobalVar('composesession'$composesessionSQ_SESSION) ) {
  47.     $composesession 0;
  48.     sqsession_register($composesession'composesession');
  49. }
  50. /* END GLOBALS */
  51.  
  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.
  54. if ($js_web{
  55.   displayHTMLHeader(_("SpamCop reporting"));
  56.   echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n";
  57. else {
  58.   displayPageHeader($color,$mailbox);
  59. }
  60.  
  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');
  66.     exit();
  67. }
  68.  
  69.     global $imap_stream_options// in case not defined in config
  70.     $imap_stream sqimap_login($usernamefalse$imapServerAddress$imapPort0$imap_stream_options);
  71.     sqimap_mailbox_select($imap_stream$mailbox);
  72.  
  73.     if ($spamcop_method == 'quick_email' ||
  74.         $spamcop_method == 'thorough_email'{
  75.        // Use email-based reporting -- save as an attachment
  76.        $session "$composesession"+1;
  77.        $composesession $session;
  78.        sqsession_register($composesession,'composesession');
  79.        if (!isset($compose_messages)) {
  80.           $compose_messages array();
  81.        }
  82.        if (!isset($compose_messages[$session]|| ($compose_messages[$session== NULL)) {
  83.           $composeMessage new Message();
  84.           $rfc822_header new Rfc822Header();
  85.           $composeMessage->rfc822_header $rfc822_header;
  86.           $composeMessage->reply_rfc822_header '';
  87.           $compose_messages[$session$composeMessage;
  88.           sqsession_register($compose_messages,'compose_messages');
  89.        else {
  90.           $composeMessage=$compose_messages[$session];
  91.        }
  92.  
  93.  
  94.         $message sqimap_get_message($imap_stream$passed_id$mailbox);
  95.         $composeMessage spamcop_getMessage_RFC822_Attachment($message$composeMessage$passed_id,
  96.                                       $passed_ent_id$imap_stream);
  97.  
  98.             $compose_messages[$session$composeMessage;
  99.         sqsession_register($compose_messages'compose_messages');
  100.  
  101.         $fn getPref($data_dir$username'full_name');
  102.         $em getPref($data_dir$username'email_address');
  103.  
  104.         $HowItLooks $fn ' ';
  105.         if ($em != '')
  106.           $HowItLooks .= '<' $em '>';
  107.      }
  108.  
  109.  
  110. echo "<p>";
  111. 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.");
  112. echo "</p>";
  113.  
  114. ?>
  115.  
  116. <table align="center" width="75%" border="0" cellpadding="0" cellspacing="0">
  117. <tr>
  118. <td align="left" valign="top">
  119. <?php if (isset($js_web&& $js_web{
  120.   echo '<form method="post" action="javascript:return false">';
  121.   echo '<input type="button" value="' _("Close Window""\" onclick=\"window.close(); return true;\" />\n";
  122. else {
  123.    ?><form method="post" action="<?php echo sqm_baseuri()?>src/right_main.php">
  124.   <input type="hidden" name="mailbox" value="<?php echo sm_encode_html_special_chars($mailbox?>" />
  125.   <input type="hidden" name="startMessage" value="<?php echo sm_encode_html_special_chars($startMessage?>" />
  126. <?php
  127.   echo '<input type="submit" value="' _("Cancel / Done""\" />";
  128. }
  129.   ?></form>
  130. </td>
  131. <td align="right" valign="top">
  132. <?php if ($spamcop_method == 'thorough_email' ||
  133.           $spamcop_method == 'quick_email'{
  134.    if ($spamcop_method == 'thorough_email')
  135.       $report_email 'submit.' $spamcop_id '@spam.spamcop.net';
  136.    else
  137.       $report_email 'quick.' $spamcop_id '@spam.spamcop.net';
  138.    $form_action sqm_baseuri('src/compose.php';
  139. ?>  <form method="post" action="<?php echo $form_action?>">
  140.   <input type="hidden" name="smtoken" value="<?php echo sm_generate_security_token(?>" />
  141.   <input type="hidden" name="mailbox" value="<?php echo sm_encode_html_special_chars($mailbox?>" />
  142.   <input type="hidden" name="spamcop_is_composing" value="<?php echo sm_encode_html_special_chars($passed_id?>" />
  143.   <input type="hidden" name="send_to" value="<?php echo sm_encode_html_special_chars($report_email)?>" />
  144.   <input type="hidden" name="subject" value="reply anyway" />
  145.   <input type="hidden" name="identity" value="0" />
  146.   <input type="hidden" name="session" value="<?php echo $session?>" />
  147. <?php
  148.   echo '<input type="submit" name="send1" value="' _("Send Spam Report""\" />\n";
  149. else {
  150.    $spam_message mime_fetch_body ($imap_stream$passed_id$passed_ent_id50000);
  151.  
  152.    if (strlen($spam_message== 50000{
  153.       $Warning "\n[truncated by SpamCop]\n";
  154.       $spam_message substr($spam_message050000 strlen($Warning)) $Warning;
  155.    }
  156.    $action_url="http://members.spamcop.net/sc";
  157.  
  158.    if (isset($js_web&& $js_web{
  159.      echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
  160.        " enctype=\"multipart/form-data\">\n";
  161.    else {
  162.      echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
  163.        " enctype=\"multipart/form-data\" target=\"_blank\">\n";
  164.    ?>
  165.   <input type="hidden" name="action" value="submit" />
  166.   <input type="hidden" name="oldverbose" value="1" />
  167.   <input type="hidden" name="spam" value="<?php echo sm_encode_html_special_chars($spam_message)?>" />
  168.     <?php
  169.         echo '<input type="submit" name="x1" value="' _("Send Spam Report""\" />\n";
  170.     }
  171. ?>  </form>
  172. </td>
  173. </tr>
  174. </table>
  175. </body>
  176. </html>

Documentation generated on Sat, 20 Jan 2018 04:24:26 +0100 by phpDocumentor 1.4.3