Source for file spamoptions.php

Documentation is available at spamoptions.php

  1. <?php
  2.  
  3. /**
  4.  * Message and Spam Filter Plugin - Spam Options
  5.  *
  6.  * @copyright 1999-2018 The SquirrelMail Project Team
  7.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8.  * @version $Id: spamoptions.php 14750 2018-01-16 23:44:07Z pdontthink $
  9.  * @package plugins
  10.  * @subpackage filters
  11.  */
  12.  
  13. /**
  14.  * Include the SquirrelMail initialization file.
  15.  */
  16. require('../../include/init.php');
  17.  
  18. include_once(SM_PATH 'functions/imap_general.php');
  19. include_once(SM_PATH 'functions/imap_messages.php');
  20. include_once(SM_PATH 'plugins/filters/filters.php');
  21.  
  22. /* get globals */
  23. sqgetGlobalVar('delimiter'$delimiterSQ_SESSION);
  24.  
  25. sqgetGlobalVar('action'$actionSQ_GET);
  26. global $imap_stream_options// in case not defined in config
  27. /* end globals */
  28.  
  29.  
  30. if (sqgetGlobalVar('spam_submit',$spam_submit,SQ_POST)) {
  31.     $spam_filters load_spam_filters();
  32.  
  33.     // setting spam folder
  34.     sqgetGlobalVar('filters_spam_folder_set',$filters_spam_folder_set,SQ_POST);
  35.     if (isset($filters_spam_folder_set)) {
  36.         setPref($data_dir$username'filters_spam_folder'$filters_spam_folder_set);
  37.     else {
  38.         echo _("You must select a spam folder.");
  39.     }
  40.  
  41.     // setting scan type
  42.     sqgetGlobalVar('filters_spam_scan_set',$filters_spam_scan_set,SQ_POST);
  43.     if (isset($filters_spam_scan_set)) {
  44.         setPref($data_dir$username'filters_spam_scan'$filters_spam_scan_set);
  45.     else {
  46.         echo _("You must select a scan type.");
  47.     }
  48.  
  49.     foreach ($spam_filters as $Key => $Value{
  50.         $input $spam_filters[$Key]['prefname''_set';
  51.         if sqgetGlobalVar($input,$input_key,SQ_POST) ) {
  52.             setPref$data_dir$username$spam_filters[$Key]['prefname'],$input_key);
  53.         else {
  54.             removePref($data_dir$username$spam_filters[$Key]['prefname']);
  55.         }
  56.     }
  57. }
  58.  
  59. $filters_spam_folder getPref($data_dir$username'filters_spam_folder');
  60. $filters_spam_scan getPref($data_dir$username'filters_spam_scan');
  61. $filters load_filters();
  62.  
  63. echo html_tag'table',
  64.             html_tag'tr',
  65.                 html_tag'th'_("Spam Filtering")'center' )
  66.             ,
  67.         'center'$color[0]'width="95%" border="0" cellpadding="2" cellspacing="0"' );
  68.  
  69. if ($SpamFilters_YourHop == ' '{
  70.     echo '<br />' .
  71.         html_tag'div''<b>' .
  72.             sprintf(_("WARNING! Tell the administrator to set the %s variable.")'&quot;SpamFilters_YourHop&quot;'.
  73.             '</b>' ,
  74.         'center' .
  75.         '<br />';
  76. }
  77.  
  78.  
  79. if (isset($action&& $action == 'spam'{
  80.     $imapConnection sqimap_login($usernamefalse$imapServerAddress$imapPort0$imap_stream_options);
  81.     $boxes sqimap_mailbox_list($imapConnection);
  82.     sqimap_logout($imapConnection);
  83.     $numboxes count($boxes);
  84.  
  85.     for ($i 0$i $numboxes && $filters_spam_folder == ''$i++{
  86.         if ((isset($boxes[$i]['flags'][0]&& $boxes[$i]['flags'][0!= 'noselect'&&
  87.             (isset($boxes[$i]['flags'][1]&& $boxes[$i]['flags'][1!= 'noselect'&&
  88.             (isset($boxes[$i]['flags'][2]&& $boxes[$i]['flags'][2!= 'noselect')) {
  89.             $filters_spam_folder $boxes[$i]['unformatted'];
  90.         }
  91.     }
  92.  
  93.     echo '<form method="post" action="spamoptions.php">'.
  94.         '<div style="text-align: center;">'.
  95.         html_tag'table''''''''width="85%" border="0" cellpadding="2" cellspacing="0"' .
  96.             html_tag'tr' .
  97.                 html_tag'th'_("Move spam to:")'right''''style="white-space: nowrap;"' .
  98.                 html_tag'td''''left' .
  99.                     '<select name="filters_spam_folder_set">';
  100.  
  101.         $selected 0;
  102.         if isset($filters_spam_folder) )
  103.           $selected array(strtolower($filters_spam_folder));
  104.         echo sqimap_mailbox_option_list(0$selected0$boxes);
  105.     echo    '</select>'.
  106.         '</td>'.
  107.         '</tr>'.
  108.         html_tag'tr',
  109.             html_tag'td''&nbsp;' .
  110.             html_tag'td',
  111.                 _("Moving spam directly to the trash may not be a good idea at first, since messages from friends and mailing lists might accidentally be marked as spam. Whatever folder you set this to, make sure that it gets cleaned out periodically, so that you don't have an excessively large mailbox hanging around.",
  112.             'left' )
  113.         .
  114.         html_tag'tr' .
  115.             html_tag'th'_("What to Scan:")'right''''style="white-space: nowrap;"' .
  116.             html_tag'td' .
  117.             '<select name="filters_spam_scan_set">'.
  118.             '<option value=""';
  119.     if ($filters_spam_scan == ''{
  120.         echo ' selected="selected"';
  121.     }
  122.     echo '>' _("All messages"'</option>'.
  123.             '<option value="new"';
  124.     if ($filters_spam_scan == 'new'{
  125.         echo ' selected="selected"';
  126.     }
  127.     echo '>' _("Unread messages only"'</option>' .
  128.             '</select>'.
  129.         '</td>'.
  130.     '</tr>'.
  131.     html_tag'tr',
  132.           html_tag'td''&nbsp;' .
  133.           html_tag'td',
  134.               _("The more messages scanned, the longer it takes. It's recommended to scan unread messages only. If a change to the filters is made, it's recommended to set it to scan all messages, then go view the INBOX, then come back and set it to scan unread messages only. That way, the new spam filters will be applied and even the spam you didn't catch with the old filters will be scanned.",
  135.           'left' )
  136.       );
  137.  
  138.     $spam_filters load_spam_filters();
  139.  
  140.     foreach ($spam_filters as $Key => $Value{
  141.         echo html_tag'tr' .
  142.                    html_tag'th'$Key'right''''style="white-space: nowrap;"' ."\n" .
  143.                    html_tag'td' .
  144.             '<input type="checkbox" name="' .
  145.             $spam_filters[$Key]['prefname'.
  146.             '_set"';
  147.         if ($spam_filters[$Key]['enabled']{
  148.             echo ' checked="checked"';
  149.         }
  150.         echo ' /> - ';
  151.         if ($spam_filters[$Key]['link']{
  152.             echo '<a href="' .
  153.                  $spam_filters[$Key]['link'.
  154.                  '" target="_blank">';
  155.         }
  156.         echo $spam_filters[$Key]['name'];
  157.         if ($spam_filters[$Key]['link']{
  158.             echo '</a>';
  159.         }
  160.         echo '</td></tr>' .
  161.         html_tag'tr',
  162.             html_tag'td''&nbsp;' .
  163.             html_tag'td'$spam_filters[$Key]['comment']'left' )
  164.         "\n";
  165.  
  166.     }
  167.     echo html_tag'tr',
  168.         html_tag'td''<input type="submit" name="spam_submit" value="' _("Save"'" />''center''''colspan="2"' )
  169.     "\n" .
  170.         '</table>'.
  171.         '</div>'.
  172.         '</form>';
  173. else {
  174.     // action is not set or action is not spam
  175.     echo html_tag'p''''center' .
  176.          '[<a href="spamoptions.php?action=spam">' _("Edit"'</a>]' .
  177.          ' - [<a href="../../src/options.php">' _("Done"'</a>]</div><br /><br />';
  178.     printf_("Spam is sent to %s.")($filters_spam_folder?'<b>'.sm_encode_html_special_chars(imap_utf7_decode_local($filters_spam_folder)).'</b>':'[<i>'._("not set yet").'</i>]' ) );
  179.     echo '<br />';
  180.     printf_("Spam scan is limited to %s.")'<b>' ( ($filters_spam_scan == 'new')?_("Unread messages only"):_("All messages") ) '</b>' );
  181.     echo '</p>'.
  182.         '<table border="0" cellpadding="3" cellspacing="0" align="center" bgcolor="' $color[0"\">\n";
  183.  
  184.     $spam_filters load_spam_filters();
  185.  
  186.     foreach ($spam_filters as $Key => $Value{
  187.         echo html_tag'tr' .
  188.                     html_tag'th''''center' );
  189.  
  190.         if ($spam_filters[$Key]['enabled']{
  191.             echo _("ON");
  192.         else {
  193.             echo _("OFF");
  194.         }
  195.  
  196.         echo '</th>' .
  197.                html_tag'td''&nbsp;-&nbsp;''left' .
  198.                html_tag'td''''left' );
  199.  
  200.         if ($spam_filters[$Key]['link']{
  201.         echo '<a href="' .
  202.             $spam_filters[$Key]['link'.
  203.             '" target="_blank">';
  204.         }
  205.  
  206.         echo $spam_filters[$Key]['name'];
  207.         if ($spam_filters[$Key]['link']{
  208.         echo '</a>';
  209.         }
  210.         echo "</td></tr>\n";
  211.     }
  212.     echo '</table>';
  213. }
  214. ?>
  215. </body></html>

Documentation generated on Thu, 18 Jan 2018 04:24:25 +0100 by phpDocumentor 1.4.3