setup.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <?php
  2. /**
  3. * Message and Spam Filter Plugin - Setup script
  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$
  22. * @copyright (c) 1999-2005 The SquirrelMail Project Team
  23. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  24. * @package plugins
  25. * @subpackage filters
  26. */
  27. /** SquirrelMail required files. */
  28. require_once(SM_PATH . 'plugins/filters/filters.php');
  29. /**
  30. * Imap connection control
  31. *
  32. * Set this to true if you have problems -- check the README file
  33. * Note: This doesn't work all of the time (No idea why)
  34. * Seems to be related to UW
  35. * @global bool $UseSeparateImapConnection
  36. */
  37. global $UseSeparateImapConnection;
  38. $UseSeparateImapConnection = false;
  39. /**
  40. * User level spam filters control
  41. *
  42. * Set this to false if you do not want the user to be able to enable
  43. * spam filters
  44. * @global bool $AllowSpamFilters
  45. */
  46. global $AllowSpamFilters;
  47. $AllowSpamFilters = true;
  48. /**
  49. * SpamFilters YourHop Setting
  50. *
  51. * Set this to a string containing something unique to the line in the
  52. * header you want me to find IPs to scan the databases with. For example,
  53. * All the email coming IN from the internet to my site has a line in
  54. * the header that looks like (all on one line):
  55. * Received: [from usw-sf-list1.sourceforge.net (usw-sf-fw2.sourceforge.net
  56. * [216.136.171.252]) by firewall.persistence.com (SYSADMIN-antispam
  57. * 0.2) with
  58. * Since this line indicates the FIRST hop the email takes into my network,
  59. * I set my SpamFilters_YourHop to 'by firewall.persistence.com' but any
  60. * case-sensitive string will do. You can set it to something found on
  61. * every line in the header (like ' ') if you want to scan all IPs in
  62. * the header (lots of false alarms here tho).
  63. * @global string $SpamFilters_YourHop
  64. */
  65. global $SpamFilters_YourHop;
  66. $SpamFilters_YourHop = ' ';
  67. /**
  68. * Commercial Spam Filters Control
  69. *
  70. * Some of the SPAM filters are COMMERCIAL and require a fee. If your users
  71. * select them and you're not allowed to use them, it will make SPAM filtering
  72. * very slow. If you don't want them to even be offered to the users, you
  73. * should set SpamFilters_ShowCommercial to false.
  74. * @global bool $SpamFilters_ShowCommercial
  75. */
  76. global $SpamFilters_ShowCommercial;
  77. $SpamFilters_ShowCommercial = false;
  78. /**
  79. * SpamFiltring Cache
  80. *
  81. * A cache of IPs we've already checked or are known bad boys or good boys
  82. * ie. $SpamFilters_DNScache["210.54.220.18"] = true;
  83. * would tell filters to not even bother doing the DNS queries for that
  84. * IP and any email coming from it are SPAM - false would mean that any
  85. * email coming from it would NOT be SPAM
  86. * @global array $SpamFilters_DNScache
  87. */
  88. global $SpamFilters_DNScache;
  89. /**
  90. * Path to bulkquery program
  91. *
  92. * Absolute path to the bulkquery program. Leave blank if you don't have
  93. * bulkquery compiled, installed, and lwresd running. See the README file
  94. * in the bulkquery directory for more information on using bulkquery.
  95. * @global string $SpamFilters_BulkQuery
  96. */
  97. global $SpamFilters_BulkQuery;
  98. $SpamFilters_BulkQuery = '';
  99. /**
  100. * Shared filtering cache control
  101. *
  102. * Do you want to use a shared file for the DNS cache or a session variable?
  103. * Using a shared file means that every user can benefit from any queries
  104. * made by other users. The shared file is named "dnscache" and is in the
  105. * data directory.
  106. * @global bool $SpamFilters_SharedCache
  107. */
  108. global $SpamFilters_SharedCache;
  109. $SpamFilters_SharedCache = true;
  110. /**
  111. * DNS query TTL
  112. *
  113. * How long should DNS query results be cached for by default (in seconds)?
  114. * @global integer $SpamFilters_CacheTTL
  115. */
  116. global $SpamFilters_CacheTTL;
  117. $SpamFilters_CacheTTL = 7200;
  118. /**
  119. * Init plugin
  120. * @access private
  121. */
  122. function squirrelmail_plugin_init_filters() {
  123. global $squirrelmail_plugin_hooks;
  124. if (sqgetGlobalVar('mailbox',$mailbox,SQ_FORM)) {
  125. sqgetGlobalVar('mailbox',$mailbox,SQ_FORM);
  126. } else {
  127. $mailbox = 'INBOX';
  128. }
  129. $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters';
  130. if (isset($mailbox) && $mailbox == 'INBOX') {
  131. $squirrelmail_plugin_hooks['right_main_after_header']['filters'] = 'start_filters';
  132. }
  133. $squirrelmail_plugin_hooks['optpage_register_block']['filters'] = 'filters_optpage_register_block';
  134. $squirrelmail_plugin_hooks['special_mailbox']['filters'] = 'filters_special_mailbox';
  135. $squirrelmail_plugin_hooks['rename_or_delete_folder']['filters'] = 'update_for_folder';
  136. $squirrelmail_plugin_hooks['webmail_bottom']['filters'] = 'start_filters';
  137. }
  138. /**
  139. * Report spam folder as special mailbox
  140. * @param string $mb variable used by hook
  141. * @return string spam folder name
  142. * @access private
  143. */
  144. function filters_special_mailbox( $mb ) {
  145. global $data_dir, $username;
  146. return( $mb == getPref($data_dir, $username, 'filters_spam_folder', 'na' ) );
  147. }
  148. /**
  149. * Register option blocks
  150. * @access private
  151. */
  152. function filters_optpage_register_block() {
  153. global $optpage_blocks;
  154. global $AllowSpamFilters;
  155. $optpage_blocks[] = array(
  156. 'name' => _("Message Filters"),
  157. 'url' => '../plugins/filters/options.php',
  158. 'desc' => _("Filtering enables messages with different criteria to be automatically filtered into different folders for easier organization."),
  159. 'js' => false
  160. );
  161. if ($AllowSpamFilters) {
  162. $optpage_blocks[] = array(
  163. 'name' => _("SPAM Filters"),
  164. 'url' => '../plugins/filters/spamoptions.php',
  165. 'desc' => _("SPAM filters allow you to select from various DNS based blacklists to detect junk email in your INBOX and move it to another folder (like Trash)."),
  166. 'js' => false
  167. );
  168. }
  169. }
  170. ?>