setup.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. /**
  3. * Message and Spam Filter Plugin
  4. *
  5. * Copyright (c) 1999-2002 The SquirrelMail Project Team
  6. * Licensed under the GNU GPL. For full terms see the file COPYING.
  7. *
  8. * This plugin filters your inbox into different folders based upon given
  9. * criteria. It is most useful for people who are subscibed to mailing lists
  10. * to help organize their messages. The argument stands that filtering is
  11. * not the place of the client, which is why this has been made a plugin for
  12. * SquirrelMail. You may be better off using products such as Sieve or
  13. * Procmail to do your filtering so it happens even when SquirrelMail isn't
  14. * running.
  15. *
  16. * If you need help with this, or see improvements that can be made, please
  17. * email me directly at the address above. I definately welcome suggestions
  18. * and comments. This plugin, as is the case with all SquirrelMail plugins,
  19. * is not directly supported by the developers. Please come to me off the
  20. * mailing list if you have trouble with it.
  21. *
  22. * Also view plugins/README.plugins for more information.
  23. *
  24. * $Id$
  25. */
  26. /*
  27. * Set this to true if you have problems -- check the README file
  28. * Note: This doesn't work all of the time (No idea why)
  29. * Seems to be related to UW
  30. */
  31. global $UseSeparateImapConnection;
  32. $UseSeparateImapConnection = false;
  33. /*
  34. * Set this to false if you do not want the user to be able to enable
  35. * spam filters
  36. */
  37. global $AllowSpamFilters;
  38. $AllowSpamFilters = true;
  39. /*
  40. * Set this to a string containing something unique to the line in the
  41. * header you want me to find IPs to scan the databases with. For example,
  42. * All the email coming IN from the internet to my site has a line in
  43. * the header that looks like (all on one line):
  44. * Received: [from usw-sf-list1.sourceforge.net (usw-sf-fw2.sourceforge.net
  45. * [216.136.171.252]) by firewall.persistence.com (SYSADMIN-antispam
  46. * 0.2) with
  47. * Since this line indicates the FIRST hop the email takes into my network,
  48. * I set my SpamFilters_YourHop to 'by firewall.persistence.com' but any
  49. * case-sensitive string will do. You can set it to something found on
  50. * every line in the header (like ' ') if you want to scan all IPs in
  51. * the header (lots of false alarms here tho).
  52. */
  53. global $SpamFilters_YourHop;
  54. $SpamFilters_YourHop = ' ';
  55. /*
  56. * Some of the SPAM filters are COMMERCIAL and require a fee. If your users
  57. * select them and you're not allowed to use them, it will make SPAM filtering
  58. * very slow. If you don't want them to even be offered to the users, you
  59. * should set SpamFilters_ShowCommercial to false.
  60. */
  61. global $SpamFilters_ShowCommercial;
  62. $SpamFilters_ShowCommercial = false;
  63. /*
  64. * A cache of IPs we've already checked or are known bad boys or good boys
  65. * ie. $SpamFilters_DNScache["210.54.220.18"] = true;
  66. * would tell filters to not even bother doing the DNS queries for that
  67. * IP and any email coming from it are SPAM - false would mean that any
  68. * email coming from it would NOT be SPAM
  69. */
  70. global $SpamFilters_DNScache;
  71. /*
  72. * Absolute path to the bulkquery program. Leave blank if you don't have
  73. * bulkquery compiled, installed, and lwresd running. See the README file
  74. * in the bulkquery directory for more information on using bulkquery.
  75. */
  76. global $SpamFilters_BulkQuery;
  77. $SpamFilters_BulkQuery = "";
  78. /*
  79. * Do you want to use a shared file for the DNS cache or a session variable?
  80. * Using a shared file means that every user can benefit from any queries
  81. * made by other users. The shared file is named "dnscache" and is in the
  82. * data directory.
  83. */
  84. global $SpamFilters_SharedCache;
  85. $SpamFilters_SharedCache = true;
  86. /*
  87. * How long should DNS query results be cached for by default (in seconds)?
  88. */
  89. global $SpamFilters_CacheTTL;
  90. $SpamFilters_CacheTTL = 7200;
  91. require_once ('../plugins/filters/filters.php');
  92. function squirrelmail_plugin_init_filters() {
  93. global $squirrelmail_plugin_hooks;
  94. global $mailbox, $imap_stream, $imapConnection;
  95. $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters';
  96. if ($mailbox == 'INBOX') {
  97. $squirrelmail_plugin_hooks['right_main_after_header']['filters'] = 'start_filters';
  98. }
  99. $squirrelmail_plugin_hooks['optpage_register_block']['filters'] = 'filters_optpage_register_block';
  100. # $squirrelmail_plugin_hooks['special_mailbox']['filters'] = 'filters_special_mailbox';
  101. $squirrelmail_plugin_hooks['rename_or_delete_folder']['filters'] = 'update_for_folder';
  102. $squirrelmail_plugin_hooks['webmail_bottom']['filters'] = 'start_filters';
  103. }
  104. function filters_special_mailbox( $mb ) {
  105. GLOBAL $data_dir, $username;
  106. return( $mb == getPref($data_dir, $username, 'filters_spam_folder', 'na' ) );
  107. }
  108. function filters_optpage_register_block() {
  109. global $optpage_blocks;
  110. global $AllowSpamFilters;
  111. $optpage_blocks[] = array(
  112. 'name' => _("Message Filters"),
  113. 'url' => '../plugins/filters/options.php',
  114. 'desc' => _("Filtering enables messages with different criteria to be automatically filtered into different folders for easier organization."),
  115. 'js' => false
  116. );
  117. if ($AllowSpamFilters) {
  118. $optpage_blocks[] = array(
  119. 'name' => _("SPAM Filters"),
  120. 'url' => '../plugins/filters/spamoptions.php',
  121. '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)."),
  122. 'js' => false
  123. );
  124. }
  125. }
  126. ?>