setup.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. // Set this to true if you have problems -- check the README file
  27. // Note: This doesn't work all of the time (No idea why)
  28. // Seems to be related to UW
  29. global $UseSeparateImapConnection;
  30. $UseSeparateImapConnection = false;
  31. // Set this to false if you do not want the user to be able to enable
  32. // spam filters
  33. global $AllowSpamFilters;
  34. $AllowSpamFilters = true;
  35. // Set this to a string containing something unique to the line in the
  36. // header you want me to find IPs to scan the databases with. For example,
  37. // All the email coming IN from the internet to my site has a line in
  38. // the header that looks like (all on one line):
  39. // Received: [from usw-sf-list1.sourceforge.net (usw-sf-fw2.sourceforge.net
  40. // [216.136.171.252]) by firewall.persistence.com (SYSADMIN-antispam
  41. // 0.2) with
  42. // Since this line indicates the FIRST hop the email takes into my network,
  43. // I set my SpamFilters_YourHop to 'by firewall.persistence.com' but any
  44. // case-sensitive string will do. You can set it to something found on
  45. // every line in the header (like ' ') if you want to scan all IPs in
  46. // the header (lots of false alarms here tho).
  47. global $SpamFilters_YourHop;
  48. $SpamFilters_YourHop = ' ';
  49. // A cache of IPs we've already checked or are known bad boys or good boys
  50. // ie. $SpamFilters_DNScache["210.54.220.18"] = true;
  51. // would tell filters to not even bother doing the DNS queries for that
  52. // IP and any email coming from it are SPAM - false would mean that any
  53. // email coming from it would NOT be SPAM
  54. global $SpamFilters_DNScache;
  55. require_once ('../plugins/filters/filters.php');
  56. function squirrelmail_plugin_init_filters() {
  57. global $squirrelmail_plugin_hooks;
  58. global $mailbox, $imap_stream, $imapConnection;
  59. $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters';
  60. if ($mailbox == 'INBOX') {
  61. $squirrelmail_plugin_hooks['right_main_after_header']['filters'] = 'start_filters';
  62. }
  63. $squirrelmail_plugin_hooks['optpage_register_block']['filters'] = 'squirrelmail_plugin_optpage_register_block';
  64. $squirrelmail_plugin_hooks['special_mailbox']['filters'] = 'filters_special_mailbox';
  65. }
  66. function filters_special_mailbox( $mb ) {
  67. GLOBAL $data_dir, $username;
  68. if ( $mb == getPref($data_dir, $username, 'filters_spam_folder', 'na' ) ) {
  69. return( TRUE );
  70. } else {
  71. return( FALSE );
  72. }
  73. }
  74. function squirrelmail_plugin_optpage_register_block() {
  75. global $optpage_blocks;
  76. global $AllowSpamFilters;
  77. $optpage_blocks[] = array(
  78. 'name' => _("Message Filters"),
  79. 'url' => '../plugins/filters/options.php',
  80. 'desc' => _("Filtering enables messages with different criteria to be automatically filtered into different folders for easier organization."),
  81. 'js' => false
  82. );
  83. if ($AllowSpamFilters) {
  84. $optpage_blocks[] = array(
  85. 'name' => _("SPAM Filters"),
  86. 'url' => '../plugins/filters/spamoptions.php',
  87. '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)."),
  88. 'js' => false
  89. );
  90. }
  91. }
  92. ?>