Source for file spamoptions.php

Documentation is available at spamoptions.php

  1. <?php
  2. /**
  3.  * Message and Spam Filter Plugin - Spam Options
  4.  *
  5.  * This plugin filters your inbox into different folders based upon given
  6.  * criteria.  It is most useful for people who are subscibed to mailing lists
  7.  * to help organize their messages.  The argument stands that filtering is
  8.  * not the place of the client, which is why this has been made a plugin for
  9.  * SquirrelMail.  You may be better off using products such as Sieve or
  10.  * Procmail to do your filtering so it happens even when SquirrelMail isn't
  11.  * running.
  12.  *
  13.  * If you need help with this, or see improvements that can be made, please
  14.  * email me directly at the address above.  I definately welcome suggestions
  15.  * and comments.  This plugin, as is the case with all SquirrelMail plugins,
  16.  * is not directly supported by the developers.  Please come to me off the
  17.  * mailing list if you have trouble with it.
  18.  *
  19.  * Also view plugins/README.plugins for more information.
  20.  *
  21.  * @version $Id: spamoptions.php 14840 2020-01-07 07:42:38Z pdontthink $
  22.  * @copyright (c) 1999-2020 The SquirrelMail Project Team
  23.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  24.  * @package plugins
  25.  * @subpackage filters
  26.  */
  27.  
  28. /**
  29.  * Path for SquirrelMail required files.
  30.  * @ignore
  31.  */
  32. define('SM_PATH','../../');
  33.  
  34. /* SquirrelMail required files. */
  35. require_once(SM_PATH 'include/validate.php');
  36. require_once(SM_PATH 'functions/page_header.php');
  37. require_once(SM_PATH 'functions/imap.php');
  38. require_once(SM_PATH 'include/load_prefs.php');
  39. require_once(SM_PATH 'functions/html.php');
  40. require_once(SM_PATH 'plugins/filters/filters.php');
  41. global $AllowSpamFilters;
  42.  
  43. /* get globals */
  44. sqgetGlobalVar('username'$usernameSQ_SESSION);
  45. sqgetGlobalVar('key'$keySQ_COOKIE);
  46. sqgetGlobalVar('onetimepad'$onetimepadSQ_SESSION);
  47. sqgetGlobalVar('delimiter'$delimiterSQ_SESSION);
  48.  
  49. sqgetGlobalVar('action'$actionSQ_GET);
  50. global $imap_stream_options// in case not defined in config
  51. /* end globals */
  52.  
  53. displayPageHeader($color'None');
  54.  
  55. if (sqgetGlobalVar('spam_submit',$spam_submit,SQ_POST)) {
  56.     $spam_filters load_spam_filters();
  57.  
  58.     // setting spam folder    
  59.     sqgetGlobalVar('filters_spam_folder_set',$filters_spam_folder_set,SQ_POST);
  60.     if (isset($filters_spam_folder_set)) {
  61.         setPref($data_dir$username'filters_spam_folder'$filters_spam_folder_set);
  62.     else {
  63.     echo _("You must select a spam folder.");
  64.     }
  65.  
  66.     // setting scan type
  67.     sqgetGlobalVar('filters_spam_scan_set',$filters_spam_scan_set,SQ_POST);
  68.     if (isset($filters_spam_scan_set)) {
  69.     setPref($data_dir$username'filters_spam_scan'$filters_spam_scan_set);
  70.     else {
  71.     echo _("You must select a scan type.");
  72.     }
  73.  
  74.     foreach ($spam_filters as $Key => $Value{
  75.         $input $spam_filters[$Key]['prefname''_set';
  76.         if sqgetGlobalVar($input,$input_key,SQ_POST) ) {
  77.             setPref$data_dir$username$spam_filters[$Key]['prefname'],$input_key);
  78.         else {
  79.             removePref($data_dir$username$spam_filters[$Key]['prefname']);
  80.         }
  81.     }
  82. }
  83.  
  84. $filters_spam_folder getPref($data_dir$username'filters_spam_folder');
  85. $filters_spam_scan getPref($data_dir$username'filters_spam_scan');
  86. $filters load_filters();
  87.  
  88. echo html_tag'table',
  89.             html_tag'tr',
  90.                 html_tag'th'_("Spam Filtering")'center' )
  91.             ,
  92.         'center'$color[0]'width="95%" border="0" cellpadding="2" cellspacing="0"' );
  93.  
  94. if ($SpamFilters_YourHop == ' '{
  95.     echo '<br />' .
  96.         html_tag'div''<b>' .
  97.             sprintf(_("WARNING! Tell the administrator to set the %s variable.")'&quot;SpamFilters_YourHop&quot;'.
  98.             '</b>' ,
  99.         'center' .
  100.         '<br />';
  101. }
  102.  
  103.  
  104. if (isset($action&& $action == 'spam'{
  105.     $imapConnection sqimap_login($username$key$imapServerAddress$imapPort0$imap_stream_options);
  106.     $boxes sqimap_mailbox_list($imapConnection);
  107.     sqimap_logout($imapConnection);
  108.     $numboxes count($boxes);
  109.  
  110.     for ($i 0$i $numboxes && $filters_spam_folder == ''$i++{
  111.         if ((isset($boxes[$i]['flags'][0]&& $boxes[$i]['flags'][0!= 'noselect'&&
  112.             (isset($boxes[$i]['flags'][1]&& $boxes[$i]['flags'][1!= 'noselect'&&
  113.             (isset($boxes[$i]['flags'][2]&& $boxes[$i]['flags'][2!= 'noselect')) {
  114.             $filters_spam_folder $boxes[$i]['unformatted'];
  115.         }
  116.     }
  117.  
  118.     echo '<form method="post" action="spamoptions.php">'.
  119.         '<center>'.
  120.         html_tag'table''''''''width="85%" border="0" cellpadding="2" cellspacing="0"' .
  121.             html_tag'tr' .
  122.                 html_tag'th'_("Move spam to:")'right''''nowrap' .
  123.                 html_tag'td''''left' .
  124.                     '<select name="filters_spam_folder_set">';
  125.  
  126.         $selected 0;
  127.         if isset($filters_spam_folder) )
  128.           $selected array(strtolower($filters_spam_folder));
  129.         echo sqimap_mailbox_option_list(0$selected0$boxes);
  130.     echo    '</select>'.
  131.         '</td>'.
  132.         '</tr>'.
  133.         html_tag'tr',
  134.             html_tag'td''&nbsp;' .
  135.             html_tag'td',
  136.                 _("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.",
  137.             'left' )
  138.         .
  139.         html_tag'tr' .
  140.             html_tag'th'_("What to Scan:")'right''''nowrap' .
  141.             html_tag'td' .
  142.             '<select name="filters_spam_scan_set">'.
  143.             '<option value=""';
  144.     if ($filters_spam_scan == ''{
  145.         echo ' selected="selected"';
  146.     }
  147.     echo '>' _("All messages"'</option>'.
  148.             '<option value="new"';
  149.     if ($filters_spam_scan == 'new'{
  150.         echo ' selected="selected"';
  151.     }
  152.     echo '>' _("Unread messages only"'</option>' .
  153.             '</select>'.
  154.         '</td>'.
  155.     '</tr>'.
  156.     html_tag'tr',
  157.           html_tag'td''&nbsp;' .
  158.           html_tag'td',
  159.               _("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.",
  160.           'left' )
  161.       );
  162.  
  163.     $spam_filters load_spam_filters();
  164.  
  165.     foreach ($spam_filters as $Key => $Value{
  166.         echo html_tag'tr' .
  167.                    html_tag'th'$Key'right''''nowrap' ."\n" .
  168.                    html_tag'td' .
  169.             '<input type="checkbox" name="' .
  170.             $spam_filters[$Key]['prefname'.
  171.             '_set"';
  172.         if ($spam_filters[$Key]['enabled']{
  173.             echo ' checked="checked"';
  174.         }
  175.         echo ' /> - ';
  176.         if ($spam_filters[$Key]['link']{
  177.             echo '<a href="' .
  178.                  $spam_filters[$Key]['link'.
  179.                  '" target="_blank">';
  180.         }
  181.         echo $spam_filters[$Key]['name'];
  182.         if ($spam_filters[$Key]['link']{
  183.             echo '</a>';
  184.         }
  185.         echo '</td></tr>' .
  186.         html_tag'tr',
  187.             html_tag'td''&nbsp;' .
  188.             html_tag'td'$spam_filters[$Key]['comment']'left' )
  189.         "\n";
  190.  
  191.     }
  192.     echo html_tag'tr',
  193.         html_tag'td''<input type="submit" name="spam_submit" value="' _("Save"'" />''center''''colspan="2"' )
  194.     "\n" .
  195.         '</table>'.
  196.         '</center>'.
  197.         '</form>';
  198. else {
  199.     // action is not set or action is not spam
  200.     echo html_tag'p''''center' .
  201.          '[<a href="spamoptions.php?action=spam">' _("Edit"'</a>]' .
  202.          ' - [<a href="../../src/options.php">' _("Done"'</a>]</center><br /><br />';
  203.     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>]' ) );
  204.     echo '<br />';
  205.     printf_("Spam scan is limited to %s.")'<b>' ( ($filters_spam_scan == 'new')?_("Unread messages only"):_("All messages") ) '</b>' );
  206.     echo '</p>'.
  207.         '<table border="0" cellpadding="3" cellspacing="0" align="center" bgcolor="' $color[0"\">\n";
  208.  
  209.     $spam_filters load_spam_filters();
  210.  
  211.     foreach ($spam_filters as $Key => $Value{
  212.         echo html_tag'tr' .
  213.                     html_tag'th''''center' );
  214.  
  215.         if ($spam_filters[$Key]['enabled']{
  216.             echo _("ON");
  217.         else {
  218.             echo _("OFF");
  219.         }
  220.  
  221.         echo '</th>' 
  222.                html_tag'td''&nbsp;-&nbsp;''left' .
  223.                html_tag'td''''left' );
  224.  
  225.         if ($spam_filters[$Key]['link']{
  226.         echo '<a href="' .
  227.             $spam_filters[$Key]['link'.
  228.             '" target="_blank">';
  229.         }
  230.  
  231.         echo $spam_filters[$Key]['name'];
  232.         if ($spam_filters[$Key]['link']{
  233.         echo '</a>';
  234.         }
  235.         echo "</td></tr>\n";
  236.     }
  237.     echo '</table>';
  238. }
  239. ?>
  240. </body></html>

Documentation generated on Mon, 13 Jan 2020 04:25:21 +0100 by phpDocumentor 1.4.3