Adding new plugin output sections 'provider_link_after' and 'provider_link_before'
[squirrelmail.git] / plugins / filters / filters.php
CommitLineData
849bdf42 1<?php
4b4abf93 2
15e6162e 3/**
0a1dc88e 4 * Message and Spam Filter Plugin - Filtering Functions
15e6162e 5 *
4b5049de 6 * @copyright &copy; 1999-2007 The SquirrelMail Project Team
b2d8bc6c 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
4b4abf93 8 * @version $Id$
ea5f4b8e 9 * @package plugins
10 * @subpackage filters
15e6162e 11 */
4eee5968 12
202bcbcc 13/**
14 * do not allow to call this file directly
15 */
f627180c 16if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) {
202bcbcc 17 header("Location: ../../src/login.php");
18 die();
19}
e5c8ec61 20
21/** load globals */
48879ef0 22global $UseSeparateImapConnection,
23 $AllowSpamFilters, $SpamFilters_YourHop, $SpamFilters_ShowCommercial,
24 $SpamFilters_DNScache, $SpamFilters_BulkQuery, $SpamFilters_SharedCache,
e5c8ec61 25 $SpamFilters_CacheTTL;
26
3bde2539 27/**
28 * load required functions. Plugin depends on IMAP functions and they are not
29 * loaded in src/webmail.php
30 */
31include_once (SM_PATH . 'functions/imap.php');
32
e5c8ec61 33/** load default config */
34if (file_exists(SM_PATH . 'plugins/filters/config_default.php')) {
35 include_once (SM_PATH . 'plugins/filters/config_default.php');
36} else {
37 // default config was removed.
38 $UseSeparateImapConnection = false;
39 $AllowSpamFilters = true;
40 $SpamFilters_YourHop = ' ';
41 $SpamFilters_ShowCommercial = false;
42 $SpamFilters_DNScache = array();
43 $SpamFilters_BulkQuery = '';
44 $SpamFilters_SharedCache = true;
45 $SpamFilters_CacheTTL = 7200;
46}
47
48if (file_exists(SM_PATH . 'config/filters_config.php')) {
49 include_once (SM_PATH . 'config/filters_config.php');
50} elseif (file_exists(SM_PATH . 'plugins/filters/config.php')) {
8510adf2 51 include_once (SM_PATH . 'plugins/filters/config.php');
e5c8ec61 52}
9c655416 53
ea5f4b8e 54/**
9c655416 55 * Register option blocks
56 * @access private
57 */
58function filters_optpage_register_block() {
59 global $optpage_blocks, $AllowSpamFilters;
f8a1ed5a 60
9c655416 61 $optpage_blocks[] = array(
62 'name' => _("Message Filters"),
63 'url' => SM_PATH . 'plugins/filters/options.php',
64 'desc' => _("Filtering enables messages with different criteria to be automatically filtered into different folders for easier organization."),
65 'js' => false
66 );
67
68 if ($AllowSpamFilters) {
69 $optpage_blocks[] = array(
70 'name' => _("SPAM Filters"),
71 'url' => SM_PATH . 'plugins/filters/spamoptions.php',
72 '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)."),
73 'js' => false
74 );
75 }
76}
77
48879ef0 78/* Receive the status of the folder and do something with it */
79function filters_folder_status($statusarr) {
80
b2f4cdad 81 global $filter_inbox_count;
82 if (empty($filter_inbox_count)) $filter_inbox_count=0;
202bcbcc 83
b2f4cdad 84 if ($statusarr['MAILBOX'] == 'INBOX')
48879ef0 85 {
86 if (!empty($statusarr['MESSAGES'])) $filter_inbox_count=$statusarr['MESSAGES'];
87 }
88}
89
9c655416 90/**
91 * Saves the DNS Cache to disk
0a1dc88e 92 * @access private
5b4ba967 93 */
a2a566eb 94function filters_SaveCache () {
95 global $data_dir, $SpamFilters_DNScache;
96
ae48f757 97 if (file_exists($data_dir . '/dnscache')) {
98 $fp = fopen($data_dir . '/dnscache', 'r');
a2a566eb 99 } else {
100 $fp = false;
101 }
102 if ($fp) {
103 flock($fp,LOCK_EX);
104 } else {
ae48f757 105 $fp = fopen($data_dir . '/dnscache', 'w+');
a2a566eb 106 fclose($fp);
ae48f757 107 $fp = fopen($data_dir . '/dnscache', 'r');
a2a566eb 108 flock($fp,LOCK_EX);
109 }
9c655416 110 $fp1 = fopen($data_dir . '/dnscache', 'w+');
a2a566eb 111
112 foreach ($SpamFilters_DNScache as $Key=> $Value) {
113 $tstr = $Key . ',' . $Value['L'] . ',' . $Value['T'] . "\n";
114 fputs ($fp1, $tstr);
115 }
116 fclose($fp1);
117 flock($fp,LOCK_UN);
118 fclose($fp);
119}
120
0a1dc88e 121/**
9c655416 122 * Loads the DNS Cache from disk
0a1dc88e 123 * @access private
124 */
a2a566eb 125function filters_LoadCache () {
126 global $data_dir, $SpamFilters_DNScache;
127
ae48f757 128 if (file_exists($data_dir . '/dnscache')) {
6ade76e0 129 $SpamFilters_DNScache = array();
ae48f757 130 if ($fp = fopen ($data_dir . '/dnscache', 'r')) {
a2a566eb 131 flock($fp,LOCK_SH);
9c655416 132 while ($data = fgetcsv($fp,1024)) {
a2a566eb 133 if ($data[2] > time()) {
134 $SpamFilters_DNScache[$data[0]]['L'] = $data[1];
135 $SpamFilters_DNScache[$data[0]]['T'] = $data[2];
136 }
137 }
a2a566eb 138 flock($fp,LOCK_UN);
139 }
140 }
141}
142
0a1dc88e 143/**
9c655416 144 * Uses the BulkQuery executable to query all the RBLs at once
145 * @param array $filters Array of SPAM Fitlers
146 * @param array $IPs Array of IP Addresses
0a1dc88e 147 * @access private
148 */
fb577a4d 149function filters_bulkquery($filters, $IPs) {
ce68b76b 150 global $attachment_dir, $username,
6ade76e0 151 $SpamFilters_DNScache, $SpamFilters_BulkQuery,
152 $SpamFilters_CacheTTL;
a2a566eb 153
a2a566eb 154 if (count($IPs) > 0) {
155 $rbls = array();
156 foreach ($filters as $key => $value) {
157 if ($filters[$key]['enabled']) {
158 if ($filters[$key]['dns']) {
159 $rbls[$filters[$key]['dns']] = true;
160 }
161 }
162 }
163
ae48f757 164 $bqfil = $attachment_dir . $username . '-bq.in';
165 $fp = fopen($bqfil, 'w');
6ade76e0 166 fputs ($fp, $SpamFilters_CacheTTL . "\n");
a2a566eb 167 foreach ($rbls as $key => $value) {
ae48f757 168 fputs ($fp, '.' . $key . "\n");
a2a566eb 169 }
170 fputs ($fp, "----------\n");
171 foreach ($IPs as $key => $value) {
172 fputs ($fp, $key . "\n");
173 }
174 fclose ($fp);
175 $bqout = array();
ae48f757 176 exec ($SpamFilters_BulkQuery . ' < ' . $bqfil, $bqout);
a2a566eb 177 foreach ($bqout as $value) {
178 $Chunks = explode(',', $value);
179 $SpamFilters_DNScache[$Chunks[0]]['L'] = $Chunks[1];
180 $SpamFilters_DNScache[$Chunks[0]]['T'] = $Chunks[2] + time();
181 }
182 unlink($bqfil);
183 }
184}
185
0a1dc88e 186/**
9c655416 187 * Starts the filtering process
b2f4cdad 188 * @param array $hook_args (since 1.5.2) do hook arguments. Is used to check
189 * hook name, array key = 0.
0a1dc88e 190 * @access private
191 */
b2f4cdad 192function start_filters($hook_args) {
ce68b76b 193 global $imapServerAddress, $imapPort, $imap_stream, $imapConnection,
2128bbc6 194 $UseSeparateImapConnection, $AllowSpamFilters, $filter_inbox_count,
195 $username;
10a26cea 196
b2f4cdad 197 /**
198 * check hook that calls filtering. If filters are called by right_main_after_header,
199 * do filtering only when we are in INBOX folder.
200 */
201 if ($hook_args[0]=='right_main_after_header' &&
202 (sqgetGlobalVar('mailbox',$mailbox,SQ_FORM) && $mailbox!='INBOX')) {
203 return;
204 }
205
9a43a06b 206 $filters = load_filters();
207
208 // No point running spam filters if there aren't any to run //
209 if ($AllowSpamFilters) {
210 $spamfilters = load_spam_filters();
211
212 $AllowSpamFilters = false;
c02ae58e 213 foreach($spamfilters as $filterskey=>$value) {
9a43a06b 214 if ($value['enabled'] == 'yes') {
215 $AllowSpamFilters = true;
216 break;
217 }
218 }
219 }
220
221 if (!$AllowSpamFilters && empty($filters)) {
222 return;
223 }
224
225
2714d4ff 226 // Detect if we have already connected to IMAP or not.
227 // Also check if we are forced to use a separate IMAP connection
228 if ((!isset($imap_stream) && !isset($imapConnection)) ||
229 $UseSeparateImapConnection ) {
2128bbc6 230 $stream = sqimap_login($username, false, $imapServerAddress,
1320cab5 231 $imapPort, 10);
232 $previously_connected = false;
2714d4ff 233 } else if (isset($imapConnection)) {
234 $stream = $imapConnection;
235 $previously_connected = true;
236 } else {
237 $previously_connected = true;
238 $stream = $imap_stream;
239 }
4eee5968 240
48879ef0 241 if (!isset($filter_inbox_count)) {
242 $aStatus = sqimap_status_messages ($stream, 'INBOX', array('MESSAGES'));
243 if (!empty($aStatus['MESSAGES'])) {
244 $filter_inbox_count=$aStatus['MESSAGES'];
245 } else {
246 $filter_inbox_count=0;
247 }
248 }
249
250 if ($filter_inbox_count > 0) {
2714d4ff 251 sqimap_mailbox_select($stream, 'INBOX');
252 // Filter spam from inbox before we sort them into folders
253 if ($AllowSpamFilters) {
254 spam_filters($stream);
10a26cea 255 }
4eee5968 256
2714d4ff 257 // Sort into folders
258 user_filters($stream);
259 }
260
261 if (!$previously_connected) {
262 sqimap_logout($stream);
263 }
10a26cea 264}
265
0a1dc88e 266/**
9c655416 267 * Does the loop through each filter
268 * @param stream imap_stream the stream to read from
0a1dc88e 269 * @access private
270 */
10a26cea 271function user_filters($imap_stream) {
c8a2c24d 272 global $data_dir, $username;
10a26cea 273 $filters = load_filters();
274 if (! $filters) return;
c8a2c24d 275 $filters_user_scan = getPref($data_dir, $username, 'filters_user_scan');
10a26cea 276
fb577a4d 277 $expunge = false;
53fcc494 278 // For every rule
ae48f757 279 for ($i=0, $num = count($filters); $i < $num; $i++) {
10a26cea 280 // If it is the "combo" rule
281 if ($filters[$i]['where'] == 'To or Cc') {
53fcc494 282 /*
283 * If it's "TO OR CC", we have to do two searches, one for TO
284 * and the other for CC.
285 */
fb577a4d 286 $expunge = filter_search_and_delete($imap_stream, 'TO',
287 $filters[$i]['what'], $filters[$i]['folder'], $filters_user_scan, $expunge);
288 $expunge = filter_search_and_delete($imap_stream, 'CC',
289 $filters[$i]['what'], $filters[$i]['folder'], $filters_user_scan, $expunge);
8a7ccd82 290 } else if ($filters[$i]['where'] == 'Header and Body') {
291 $expunge = filter_search_and_delete($imap_stream, 'TEXT',
292 $filters[$i]['what'], $filters[$i]['folder'], $filters_user_scan, $expunge);
293 } else if ($filters[$i]['where'] == 'Message Body') {
294 $expunge = filter_search_and_delete($imap_stream, 'BODY',
f8a1ed5a 295 $filters[$i]['what'], $filters[$i]['folder'], $filters_user_scan, $expunge);
10a26cea 296 } else {
53fcc494 297 /*
298 * If it's a normal TO, CC, SUBJECT, or FROM, then handle it
299 * normally.
300 */
fb577a4d 301 $expunge = filter_search_and_delete($imap_stream, $filters[$i]['where'],
302 $filters[$i]['what'], $filters[$i]['folder'], $filters_user_scan, $expunge);
4eee5968 303 }
4eee5968 304 }
53fcc494 305 // Clean out the mailbox whether or not auto_expunge is on
306 // That way it looks like it was redirected properly
fb577a4d 307 if ($expunge) {
4f6915b0 308 sqimap_mailbox_expunge($imap_stream, 'INBOX');
53fcc494 309 }
10a26cea 310}
311
0a1dc88e 312/**
9c655416 313 * Creates and runs the IMAP command to filter messages
314 * @param string $where Which part of the message to search (TO, CC, SUBJECT, etc...)
315 * @param string $what String to search for
316 * @param string $where_to Folder it will move to
317 * @param string $user_scan Whether to search all or just unseen
f8a1ed5a 318 * @param string $should_expunge
9c655416 319 * @param boolean $where Which part of location to search
0a1dc88e 320 * @access private
321 */
2714d4ff 322function filter_search_and_delete($imap_stream, $where, $what, $where_to, $user_scan,
fb577a4d 323 $should_expunge) {
6201339c 324 global $languages, $squirrelmail_language, $allow_charset_search, $imap_server_type;
325
1320cab5 326 //TODO: make use of new mailbox cache. See mailbox_display.phpinfo
327
174523e3 328 if (strtolower($where_to) == 'inbox') {
329 return array();
330 }
331
c8a2c24d 332 if ($user_scan == 'new') {
333 $category = 'UNSEEN';
334 } else {
335 $category = 'ALL';
336 }
86e6d79f 337 $category .= ' UNDELETED';
c8a2c24d 338
3eea00ca 339 if ($allow_charset_search &&
340 isset($languages[$squirrelmail_language]['CHARSET']) &&
53fcc494 341 $languages[$squirrelmail_language]['CHARSET']) {
3eea00ca 342 $search_str = 'SEARCH CHARSET '
343 . strtoupper($languages[$squirrelmail_language]['CHARSET'])
344 . ' ' . $category;
f9ca4be0 345 } else {
3eea00ca 346 $search_str = 'SEARCH CHARSET US-ASCII ' . $category;
f9ca4be0 347 }
ae48f757 348 if ($where == 'Header') {
3eea00ca 349 $what = explode(':', $what);
1320cab5 350 $where = strtoupper($where);
3eea00ca 351 $where = trim($where . ' ' . $what[0]);
352 $what = addslashes(trim($what[1]));
9da6bdde 353 }
f18ea37e 354
cf2aa192 355 // see comments in squirrelmail sqimap_search function
356 if ($imap_server_type == 'macosx' || $imap_server_type == 'hmailserver') {
1320cab5 357 $search_str .= ' ' . $where . ' ' . $what;
358 /* read data back from IMAP */
359 $read = sqimap_run_command($imap_stream, $search_str, true, $response, $message, TRUE);
f18ea37e 360 } else {
1320cab5 361 $search_str .= ' ' . $where . ' {' . strlen($what) . "}";
362 $sid = sqimap_session_id(true);
363 fputs ($imap_stream, $sid . ' ' . $search_str . "\r\n");
364 $read2 = sqimap_fgets($imap_stream);
365 # server should respond with Ready for argument, then we will send search text
366 #echo "RR2 $read2<br>";
367 fputs ($imap_stream, "$what\r\n");
368 #echo "SS $what<br>";
369 $read2 = sqimap_fgets($imap_stream);
370 #echo "RR2 $read2<br>";
371 $read[]=$read2;
372 $read3 = sqimap_fgets($imap_stream);
373 #echo "RR3 $read3<br>";
374 list($rtag,$response,$message)=explode(' ',$read3,3);
375## $read2 = sqimap_retrieve_imap_response($imap_stream, $sid, true,
376## $response, $message, $search_str, false, true, false);
377 #echo "RR2 $read2 / RESPONSE $response<br>";
f18ea37e 378 }
10a26cea 379
2714d4ff 380 if (isset($read[0])) {
381 $ids = array();
9c655416 382 for ($i = 0, $iCnt = count($read); $i < $iCnt; ++$i) {
2714d4ff 383 if (preg_match("/^\* SEARCH (.+)$/", $read[$i], $regs)) {
1320cab5 384 $ids += preg_split("/ /", trim($regs[1]));
fb577a4d 385 }
2714d4ff 386 }
387 if ($response == 'OK' && count($ids)) {
388 if (sqimap_mailbox_exists($imap_stream, $where_to)) {
389 $should_expunge = true;
4e6e5d2d 390 sqimap_msgs_list_move ($imap_stream, $ids, $where_to, false);
4eee5968 391 }
1320cab5 392 } elseif ($response != 'OK') {
9cda618e 393 $query = $search_str . "\r\n".$what ."\r\n";
1320cab5 394 if ($response == 'NO') {
1320cab5 395 if (strpos($message,'BADCHARSET') !== false ||
396 strpos($message,'character') !== false) {
397 sqm_trigger_imap_error('SQM_IMAP_BADCHARSET',$query, $response, $message);
398 } else {
399 sqm_trigger_imap_error('SQM_IMAP_ERROR',$query, $response, $message);
400 }
401 } else {
402 sqm_trigger_imap_error('SQM_IMAP_ERROR',$query, $response, $message);
403 }
4eee5968 404 }
405 }
fb577a4d 406 return $should_expunge;
10a26cea 407}
4eee5968 408
0a1dc88e 409/**
9c655416 410 * Loops through all the Received Headers to find IP Addresses
411 * @param stream imap_stream the stream to read from
0a1dc88e 412 * @access private
413 */
10a26cea 414function spam_filters($imap_stream) {
6201339c 415 global $data_dir, $username;
10a26cea 416 global $SpamFilters_YourHop;
417 global $SpamFilters_DNScache;
a2a566eb 418 global $SpamFilters_SharedCache;
419 global $SpamFilters_BulkQuery;
fb577a4d 420 global $SpamFilters_CacheTTL;
4eee5968 421
10a26cea 422 $filters_spam_scan = getPref($data_dir, $username, 'filters_spam_scan');
423 $filters_spam_folder = getPref($data_dir, $username, 'filters_spam_folder');
424 $filters = load_spam_filters();
4eee5968 425
a2a566eb 426 if ($SpamFilters_SharedCache) {
427 filters_LoadCache();
428 }
429
fb577a4d 430 $run = false;
4eee5968 431
fb577a4d 432 foreach ($filters as $Key => $Value) {
10a26cea 433 if ($Value['enabled']) {
fb577a4d 434 $run = true;
435 break;
4eee5968 436 }
10a26cea 437 }
4eee5968 438
10a26cea 439 // short-circuit
fb577a4d 440 if (!$run) {
10a26cea 441 return;
442 }
4eee5968 443
10a26cea 444 // Ask for a big list of all "Received" headers in the inbox with
445 // flags for each message. Kinda big.
2714d4ff 446
447 if ($filters_spam_scan == 'new') {
448 $search_array = array();
6201339c 449 $read = sqimap_run_command($imap_stream, 'SEARCH UNSEEN', true, $response, $message, TRUE);
2714d4ff 450 if (isset($read[0])) {
9c655416 451 for ($i = 0, $iCnt = count($read); $i < $iCnt; ++$i) {
2714d4ff 452 if (preg_match("/^\* SEARCH (.+)$/", $read[$i], $regs)) {
6174dcc7 453 $search_array = preg_split("/ /", trim($regs[1]));
2714d4ff 454 break;
6174dcc7 455 }
c8a2c24d 456 }
2714d4ff 457 }
c8a2c24d 458 }
2714d4ff 459 if ($filters_spam_scan == 'new' && count($search_array)) {
d3fae94f 460 $headers = sqimap_get_small_header_list ($imap_stream, $search_array, array('Received'),array());
2714d4ff 461 } else if ($filters_spam_scan != 'new') {
d3fae94f 462 $headers = sqimap_get_small_header_list ($imap_stream, null , array('Received'),array());
2714d4ff 463 } else {
464 return;
465 }
466 if (!count($headers)) {
10a26cea 467 return;
468 }
fb577a4d 469 $bulkquery = (strlen($SpamFilters_BulkQuery) > 0 ? true : false);
470 $IPs = array();
471 $aSpamIds = array();
472 foreach ($headers as $id => $aValue) {
2714d4ff 473 if (isset($aValue['UID'])) {
fb577a4d 474 $MsgNum = $aValue['UID'];
475 } else {
476 $MsgNum = $id;
10a26cea 477 }
10a26cea 478 // Look through all of the Received headers for IP addresses
2714d4ff 479 if (isset($aValue['RECEIVED'])) {
480 foreach ($aValue['RECEIVED'] as $received) {
fb577a4d 481 // Check to see if this line is the right "Received from" line
482 // to check
2714d4ff 483
484 // $aValue['Received'] is an array with all the received lines.
fb577a4d 485 // We should check them from bottom to top and only check the first 2.
486 // Currently we check only the header where $SpamFilters_YourHop in occures
2714d4ff 487
fb577a4d 488 if (is_int(strpos($received, $SpamFilters_YourHop))) {
489 if (preg_match('/([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/',$received,$aMatch)) {
490 $isspam = false;
491 if (filters_spam_check_site($aMatch[1],$aMatch[2],$aMatch[3],$aMatch[4],$filters)) {
492 $aSpamIds[] = $MsgNum;
493 $isspam = true;
494 }
495 if ($bulkquery) {
496 array_shift($aMatch);
497 $IP = explode('.',$aMatch);
498 foreach ($filters as $key => $value) {
499 if ($filters[$key]['enabled'] && $filters[$key]['dns']) {
500 if (strlen($SpamFilters_DNScache[$IP.'.'.$filters[$key]['dns']]) == 0) {
501 $IPs[$IP] = true;
502 break;
503 }
504 }
505 }
c8a2c24d 506 }
507 // If we've checked one IP and YourHop is
508 // just a space
fb577a4d 509 if ($SpamFilters_YourHop == ' ' || $isspam) {
c8a2c24d 510 break; // don't check any more
a9aa7ab7 511 }
a9aa7ab7 512 }
4eee5968 513 }
4eee5968 514 }
4eee5968 515 }
10a26cea 516 }
fb577a4d 517 // Lookie! It's spam! Yum!
518 if (count($aSpamIds) && sqimap_mailbox_exists($imap_stream, $filters_spam_folder)) {
519 sqimap_msgs_list_move ($imap_stream, $aSpamIds, $filters_spam_folder);
520 sqimap_mailbox_expunge($imap_stream, 'INBOX');
521 }
4eee5968 522
fb577a4d 523 if ($bulkquery && count($IPs)) {
524 filters_bulkquery($filters, $IPs);
525 }
4eee5968 526
a2a566eb 527 if ($SpamFilters_SharedCache) {
528 filters_SaveCache();
529 } else {
41100fce 530 sqsession_register($SpamFilters_DNScache, 'SpamFilters_DNScache');
a2a566eb 531 }
10a26cea 532}
4eee5968 533
0a1dc88e 534/**
0a1dc88e 535 * Does the loop through each enabled filter for the specified IP address.
536 * IP format: $a.$b.$c.$d
9c655416 537 * @param int $a First subset of IP
538 * @param int $b Second subset of IP
539 * @param int $c Third subset of IP
540 * @param int $d Forth subset of IP
541 * @param array $filters The Spam Filters
542 * @return boolean Whether the IP is Spam
0a1dc88e 543 * @access private
544 */
10a26cea 545function filters_spam_check_site($a, $b, $c, $d, &$filters) {
a2a566eb 546 global $SpamFilters_DNScache, $SpamFilters_CacheTTL;
10a26cea 547 foreach ($filters as $key => $value) {
548 if ($filters[$key]['enabled']) {
549 if ($filters[$key]['dns']) {
550 $filter_revip = $d . '.' . $c . '.' . $b . '.' . $a . '.' .
551 $filters[$key]['dns'];
ae48f757 552
553 if(!isset($SpamFilters_DNScache[$filter_revip]['L']))
554 $SpamFilters_DNScache[$filter_revip]['L'] = '';
555
556 if(!isset($SpamFilters_DNScache[$filter_revip]['T']))
557 $SpamFilters_DNScache[$filter_revip]['T'] = '';
558
a7cd90dd 559 if (strlen($SpamFilters_DNScache[$filter_revip]['L']) == 0) {
560 $SpamFilters_DNScache[$filter_revip]['L'] =
561 gethostbyname($filter_revip);
562 $SpamFilters_DNScache[$filter_revip]['T'] =
563 time() + $SpamFilters_CacheTTL;
564 }
565 if ($SpamFilters_DNScache[$filter_revip]['L'] ==
566 $filters[$key]['result']) {
567 return 1;
4eee5968 568 }
569 }
570 }
4eee5968 571 }
10a26cea 572 return 0;
573}
574
0a1dc88e 575/**
9c655416 576 * Loads the filters from the user preferences
577 * @return array All the user filters
0a1dc88e 578 * @access private
579 */
10a26cea 580function load_filters() {
581 global $data_dir, $username;
c8a2c24d 582
10a26cea 583 $filters = array();
9c655416 584 for ($i = 0; $fltr = getPref($data_dir, $username, 'filter' . $i); $i++) {
10a26cea 585 $ary = explode(',', $fltr);
586 $filters[$i]['where'] = $ary[0];
587 $filters[$i]['what'] = $ary[1];
588 $filters[$i]['folder'] = $ary[2];
4eee5968 589 }
10a26cea 590 return $filters;
591}
592
0a1dc88e 593/**
9c655416 594 * Loads the Spam Filters and checks the preferences for the enabled status
595 * @return array All the spam filters
0a1dc88e 596 * @access private
597 */
10a26cea 598function load_spam_filters() {
51199e7a 599 global $data_dir, $username, $SpamFilters_ShowCommercial;
600
601 if ($SpamFilters_ShowCommercial) {
602 $filters['MAPS RBL']['prefname'] = 'filters_spam_maps_rbl';
603 $filters['MAPS RBL']['name'] = 'MAPS Realtime Blackhole List';
604 $filters['MAPS RBL']['link'] = 'http://www.mail-abuse.org/rbl/';
605 $filters['MAPS RBL']['dns'] = 'blackholes.mail-abuse.org';
606 $filters['MAPS RBL']['result'] = '127.0.0.2';
607 $filters['MAPS RBL']['comment'] =
608 _("COMMERCIAL - This list contains servers that are verified spam senders. It is a pretty reliable list to scan spam from.");
609
610 $filters['MAPS RSS']['prefname'] = 'filters_spam_maps_rss';
611 $filters['MAPS RSS']['name'] = 'MAPS Relay Spam Stopper';
612 $filters['MAPS RSS']['link'] = 'http://www.mail-abuse.org/rss/';
613 $filters['MAPS RSS']['dns'] = 'relays.mail-abuse.org';
614 $filters['MAPS RSS']['result'] = '127.0.0.2';
615 $filters['MAPS RSS']['comment'] =
99aaff8b 616 _("COMMERCIAL - Servers that are configured (or misconfigured) to allow spam to be relayed through their system will be banned with this. Another good one to use.");
51199e7a 617
618 $filters['MAPS DUL']['prefname'] = 'filters_spam_maps_dul';
619 $filters['MAPS DUL']['name'] = 'MAPS Dial-Up List';
620 $filters['MAPS DUL']['link'] = 'http://www.mail-abuse.org/dul/';
621 $filters['MAPS DUL']['dns'] = 'dialups.mail-abuse.org';
622 $filters['MAPS DUL']['result'] = '127.0.0.3';
623 $filters['MAPS DUL']['comment'] =
99aaff8b 624 _("COMMERCIAL - Dial-up users are often filtered out since they should use their ISP's mail servers to send mail. Spammers typically get a dial-up account and send spam directly from there.");
51199e7a 625
626 $filters['MAPS RBLplus-RBL']['prefname'] = 'filters_spam_maps_rblplus_rbl';
627 $filters['MAPS RBLplus-RBL']['name'] = 'MAPS RBL+ RBL List';
628 $filters['MAPS RBLplus-RBL']['link'] = 'http://www.mail-abuse.org/';
629 $filters['MAPS RBLplus-RBL']['dns'] = 'rbl-plus.mail-abuse.org';
630 $filters['MAPS RBLplus-RBL']['result'] = '127.0.0.2';
631 $filters['MAPS RBLplus-RBL']['comment'] =
632 _("COMMERCIAL - RBL+ Blackhole entries.");
633
634 $filters['MAPS RBLplus-RSS']['prefname'] = 'filters_spam_maps_rblplus_rss';
635 $filters['MAPS RBLplus-RSS']['name'] = 'MAPS RBL+ List RSS entries';
636 $filters['MAPS RBLplus-RSS']['link'] = 'http://www.mail-abuse.org/';
637 $filters['MAPS RBLplus-RSS']['dns'] = 'rbl-plus.mail-abuse.org';
638 $filters['MAPS RBLplus-RSS']['result'] = '127.0.0.2';
639 $filters['MAPS RBLplus-RSS']['comment'] =
640 _("COMMERCIAL - RBL+ OpenRelay entries.");
641
642 $filters['MAPS RBLplus-DUL']['prefname'] = 'filters_spam_maps_rblplus_dul';
643 $filters['MAPS RBLplus-DUL']['name'] = 'MAPS RBL+ List DUL entries';
644 $filters['MAPS RBLplus-DUL']['link'] = 'http://www.mail-abuse.org/';
645 $filters['MAPS RBLplus-DUL']['dns'] = 'rbl-plus.mail-abuse.org';
646 $filters['MAPS RBLplus-DUL']['result'] = '127.0.0.3';
647 $filters['MAPS RBLplus-DUL']['comment'] =
648 _("COMMERCIAL - RBL+ Dial-up entries.");
649 }
10a26cea 650
10a26cea 651 $filters['FiveTen Direct']['prefname'] = 'filters_spam_fiveten_src';
652 $filters['FiveTen Direct']['name'] = 'Five-Ten-sg.com Direct SPAM Sources';
653 $filters['FiveTen Direct']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
654 $filters['FiveTen Direct']['dns'] = 'blackholes.five-ten-sg.com';
655 $filters['FiveTen Direct']['result'] = '127.0.0.2';
656 $filters['FiveTen Direct']['comment'] =
657 _("FREE - Five-Ten-sg.com - Direct SPAM sources.");
658
659 $filters['FiveTen DUL']['prefname'] = 'filters_spam_fiveten_dul';
660 $filters['FiveTen DUL']['name'] = 'Five-Ten-sg.com DUL Lists';
661 $filters['FiveTen DUL']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
662 $filters['FiveTen DUL']['dns'] = 'blackholes.five-ten-sg.com';
663 $filters['FiveTen DUL']['result'] = '127.0.0.3';
664 $filters['FiveTen DUL']['comment'] =
665 _("FREE - Five-Ten-sg.com - Dial-up lists - includes some DSL IPs.");
666
667 $filters['FiveTen Unc. OptIn']['prefname'] = 'filters_spam_fiveten_oi';
668 $filters['FiveTen Unc. OptIn']['name'] = 'Five-Ten-sg.com Unconfirmed OptIn Lists';
669 $filters['FiveTen Unc. OptIn']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
670 $filters['FiveTen Unc. OptIn']['dns'] = 'blackholes.five-ten-sg.com';
671 $filters['FiveTen Unc. OptIn']['result'] = '127.0.0.4';
672 $filters['FiveTen Unc. OptIn']['comment'] =
673 _("FREE - Five-Ten-sg.com - Bulk mailers that do not use confirmed opt-in.");
674
675 $filters['FiveTen Others']['prefname'] = 'filters_spam_fiveten_oth';
676 $filters['FiveTen Others']['name'] = 'Five-Ten-sg.com Other Misc. Servers';
677 $filters['FiveTen Others']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
678 $filters['FiveTen Others']['dns'] = 'blackholes.five-ten-sg.com';
679 $filters['FiveTen Others']['result'] = '127.0.0.5';
680 $filters['FiveTen Others']['comment'] =
681 _("FREE - Five-Ten-sg.com - Other misc. servers.");
682
683 $filters['FiveTen Single Stage']['prefname'] = 'filters_spam_fiveten_ss';
684 $filters['FiveTen Single Stage']['name'] = 'Five-Ten-sg.com Single Stage Servers';
685 $filters['FiveTen Single Stage']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
686 $filters['FiveTen Single Stage']['dns'] = 'blackholes.five-ten-sg.com';
687 $filters['FiveTen Single Stage']['result'] = '127.0.0.6';
688 $filters['FiveTen Single Stage']['comment'] =
689 _("FREE - Five-Ten-sg.com - Single Stage servers.");
690
691 $filters['FiveTen SPAM Support']['prefname'] = 'filters_spam_fiveten_supp';
692 $filters['FiveTen SPAM Support']['name'] = 'Five-Ten-sg.com SPAM Support Servers';
693 $filters['FiveTen SPAM Support']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
694 $filters['FiveTen SPAM Support']['dns'] = 'blackholes.five-ten-sg.com';
695 $filters['FiveTen SPAM Support']['result'] = '127.0.0.7';
696 $filters['FiveTen SPAM Support']['comment'] =
697 _("FREE - Five-Ten-sg.com - SPAM Support servers.");
698
699 $filters['FiveTen Web forms']['prefname'] = 'filters_spam_fiveten_wf';
700 $filters['FiveTen Web forms']['name'] = 'Five-Ten-sg.com Web Form IPs';
701 $filters['FiveTen Web forms']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
702 $filters['FiveTen Web forms']['dns'] = 'blackholes.five-ten-sg.com';
703 $filters['FiveTen Web forms']['result'] = '127.0.0.8';
704 $filters['FiveTen Web forms']['comment'] =
705 _("FREE - Five-Ten-sg.com - Web Form IPs.");
706
707 $filters['Dorkslayers']['prefname'] = 'filters_spam_dorks';
708 $filters['Dorkslayers']['name'] = 'Dorkslayers Lists';
709 $filters['Dorkslayers']['link'] = 'http://www.dorkslayers.com';
710 $filters['Dorkslayers']['dns'] = 'orbs.dorkslayers.com';
711 $filters['Dorkslayers']['result'] = '127.0.0.2';
712 $filters['Dorkslayers']['comment'] =
713 _("FREE - Dorkslayers appears to include only really bad open relays outside the US to avoid being sued. Interestingly enough, their website recommends you NOT use their service.");
714
715 $filters['SPAMhaus']['prefname'] = 'filters_spam_spamhaus';
716 $filters['SPAMhaus']['name'] = 'SPAMhaus Lists';
717 $filters['SPAMhaus']['link'] = 'http://www.spamhaus.org';
718 $filters['SPAMhaus']['dns'] = 'sbl.spamhaus.org';
719 $filters['SPAMhaus']['result'] = '127.0.0.6';
720 $filters['SPAMhaus']['comment'] =
721 _("FREE - SPAMhaus - A list of well-known SPAM sources.");
722
723 $filters['SPAMcop']['prefname'] = 'filters_spam_spamcop';
724 $filters['SPAMcop']['name'] = 'SPAM Cop Lists';
725 $filters['SPAMcop']['link'] = 'http://spamcop.net/bl.shtml';
726 $filters['SPAMcop']['dns'] = 'bl.spamcop.net';
727 $filters['SPAMcop']['result'] = '127.0.0.2';
728 $filters['SPAMcop']['comment'] =
ace4e0d3 729 _("FREE, for now - SpamCop - An interesting solution that lists servers that have a very high spam to legit email ratio (85 percent or more).");
10a26cea 730
46a184ff 731 $filters['dev.null.dk']['prefname'] = 'filters_spam_devnull';
732 $filters['dev.null.dk']['name'] = 'dev.null.dk Lists';
733 $filters['dev.null.dk']['link'] = 'http://dev.null.dk/';
734 $filters['dev.null.dk']['dns'] = 'dev.null.dk';
735 $filters['dev.null.dk']['result'] = '127.0.0.2';
736 $filters['dev.null.dk']['comment'] =
737 _("FREE - dev.null.dk - I don't have any detailed info on this list.");
738
739 $filters['visi.com']['prefname'] = 'filters_spam_visi';
740 $filters['visi.com']['name'] = 'visi.com Relay Stop List';
741 $filters['visi.com']['link'] = 'http://relays.visi.com';
742 $filters['visi.com']['dns'] = 'relays.visi.com';
743 $filters['visi.com']['result'] = '127.0.0.2';
744 $filters['visi.com']['comment'] =
745 _("FREE - visi.com - Relay Stop List. Very conservative OpenRelay List.");
746
bd35ab2b 747 $filters['ahbl.org Open Relays']['prefname'] = 'filters_spam_2mb_or';
748 $filters['ahbl.org Open Relays']['name'] = 'ahbl.org Open Relays List';
749 $filters['ahbl.org Open Relays']['link'] = 'http://www.ahbl.org/';
750 $filters['ahbl.org Open Relays']['dns'] = 'dnsbl.ahbl.org';
751 $filters['ahbl.org Open Relays']['result'] = '127.0.0.2';
752 $filters['ahbl.org Open Relays']['comment'] =
753 _("FREE - ahbl.org Open Relays - Another list of Open Relays.");
754
755 $filters['ahbl.org SPAM Source']['prefname'] = 'filters_spam_2mb_ss';
756 $filters['ahbl.org SPAM Source']['name'] = 'ahbl.org SPAM Source List';
757 $filters['ahbl.org SPAM Source']['link'] = 'http://www.ahbl.org/';
758 $filters['ahbl.org SPAM Source']['dns'] = 'dnsbl.ahbl.org';
759 $filters['ahbl.org SPAM Source']['result'] = '127.0.0.4';
760 $filters['ahbl.org SPAM Source']['comment'] =
761 _("FREE - ahbl.org SPAM Source - List of Direct SPAM Sources.");
762
763 $filters['ahbl.org SPAM ISPs']['prefname'] = 'filters_spam_2mb_isp';
764 $filters['ahbl.org SPAM ISPs']['name'] = 'ahbl.org SPAM-friendly ISP List';
765 $filters['ahbl.org SPAM ISPs']['link'] = 'http://www.ahbl.org/';
766 $filters['ahbl.org SPAM ISPs']['dns'] = 'dnsbl.ahbl.org';
767 $filters['ahbl.org SPAM ISPs']['result'] = '127.0.0.7';
768 $filters['ahbl.org SPAM ISPs']['comment'] =
769 _("FREE - ahbl.org SPAM ISPs - List of SPAM-friendly ISPs.");
46a184ff 770
771 $filters['Leadmon DUL']['prefname'] = 'filters_spam_lm_dul';
772 $filters['Leadmon DUL']['name'] = 'Leadmon.net DUL List';
773 $filters['Leadmon DUL']['link'] = 'http://www.leadmon.net/spamguard/';
774 $filters['Leadmon DUL']['dns'] = 'spamguard.leadmon.net';
775 $filters['Leadmon DUL']['result'] = '127.0.0.2';
776 $filters['Leadmon DUL']['comment'] =
777 _("FREE - Leadmon DUL - Another list of Dial-up or otherwise dynamically assigned IPs.");
778
779 $filters['Leadmon SPAM Source']['prefname'] = 'filters_spam_lm_ss';
780 $filters['Leadmon SPAM Source']['name'] = 'Leadmon.net SPAM Source List';
781 $filters['Leadmon SPAM Source']['link'] = 'http://www.leadmon.net/spamguard/';
782 $filters['Leadmon SPAM Source']['dns'] = 'spamguard.leadmon.net';
783 $filters['Leadmon SPAM Source']['result'] = '127.0.0.3';
784 $filters['Leadmon SPAM Source']['comment'] =
785 _("FREE - Leadmon SPAM Source - List of IPs Leadmon.net has received SPAM directly from.");
786
787 $filters['Leadmon Bulk Mailers']['prefname'] = 'filters_spam_lm_bm';
788 $filters['Leadmon Bulk Mailers']['name'] = 'Leadmon.net Bulk Mailers List';
789 $filters['Leadmon Bulk Mailers']['link'] = 'http://www.leadmon.net/spamguard/';
790 $filters['Leadmon Bulk Mailers']['dns'] = 'spamguard.leadmon.net';
791 $filters['Leadmon Bulk Mailers']['result'] = '127.0.0.4';
792 $filters['Leadmon Bulk Mailers']['comment'] =
793 _("FREE - Leadmon Bulk Mailers - Bulk mailers that do not require confirmed opt-in or that have allowed known spammers to become clients and abuse their services.");
794
795 $filters['Leadmon Open Relays']['prefname'] = 'filters_spam_lm_or';
796 $filters['Leadmon Open Relays']['name'] = 'Leadmon.net Open Relays List';
797 $filters['Leadmon Open Relays']['link'] = 'http://www.leadmon.net/spamguard/';
798 $filters['Leadmon Open Relays']['dns'] = 'spamguard.leadmon.net';
799 $filters['Leadmon Open Relays']['result'] = '127.0.0.5';
800 $filters['Leadmon Open Relays']['comment'] =
801 _("FREE - Leadmon Open Relays - Single Stage Open Relays that are not listed on other active RBLs.");
802
803 $filters['Leadmon Multi-stage']['prefname'] = 'filters_spam_lm_ms';
804 $filters['Leadmon Multi-stage']['name'] = 'Leadmon.net Multi-Stage Relay List';
805 $filters['Leadmon Multi-stage']['link'] = 'http://www.leadmon.net/spamguard/';
806 $filters['Leadmon Multi-stage']['dns'] = 'spamguard.leadmon.net';
807 $filters['Leadmon Multi-stage']['result'] = '127.0.0.6';
808 $filters['Leadmon Multi-stage']['comment'] =
809 _("FREE - Leadmon Multi-stage - Multi-Stage Open Relays that are not listed on other active RBLs and that have sent SPAM to Leadmon.net.");
810
811 $filters['Leadmon SpamBlock']['prefname'] = 'filters_spam_lm_sb';
812 $filters['Leadmon SpamBlock']['name'] = 'Leadmon.net SpamBlock Sites List';
813 $filters['Leadmon SpamBlock']['link'] = 'http://www.leadmon.net/spamguard/';
814 $filters['Leadmon SpamBlock']['dns'] = 'spamguard.leadmon.net';
815 $filters['Leadmon SpamBlock']['result'] = '127.0.0.7';
816 $filters['Leadmon SpamBlock']['comment'] =
817 _("FREE - Leadmon SpamBlock - Sites on this listing have sent Leadmon.net direct SPAM from IPs in netblocks where the entire block has no DNS mappings. It's a list of BLOCKS of IPs being used by people who have SPAMmed Leadmon.net.");
818
819 $filters['NJABL Open Relays']['prefname'] = 'filters_spam_njabl_or';
820 $filters['NJABL Open Relays']['name'] = 'NJABL Open Relay/Direct Spam Source List';
821 $filters['NJABL Open Relays']['link'] = 'http://www.njabl.org/';
822 $filters['NJABL Open Relays']['dns'] = 'dnsbl.njabl.org';
823 $filters['NJABL Open Relays']['result'] = '127.0.0.2';
824 $filters['NJABL Open Relays']['comment'] =
825 _("FREE, for now - Not Just Another Blacklist - Both Open Relays and Direct SPAM Sources.");
826
827 $filters['NJABL DUL']['prefname'] = 'filters_spam_njabl_dul';
828 $filters['NJABL DUL']['name'] = 'NJABL Dial-ups List';
829 $filters['NJABL DUL']['link'] = 'http://www.njabl.org/';
830 $filters['NJABL DUL']['dns'] = 'dnsbl.njabl.org';
831 $filters['NJABL DUL']['result'] = '127.0.0.3';
832 $filters['NJABL DUL']['comment'] =
833 _("FREE, for now - Not Just Another Blacklist - Dial-up IPs.");
834
18b078e9 835 $filters['Conf DSBL.ORG Relay']['prefname'] = 'filters_spam_dsbl_conf_ss';
836 $filters['Conf DSBL.ORG Relay']['name'] = 'DSBL.org Confirmed Relay List';
837 $filters['Conf DSBL.ORG Relay']['link'] = 'http://www.dsbl.org/';
838 $filters['Conf DSBL.ORG Relay']['dns'] = 'list.dsbl.org';
839 $filters['Conf DSBL.ORG Relay']['result'] = '127.0.0.2';
840 $filters['Conf DSBL.ORG Relay']['comment'] =
841 _("FREE - Distributed Sender Boycott List - Confirmed Relays");
842
843 $filters['Conf DSBL.ORG Multi-Stage']['prefname'] = 'filters_spam_dsbl_conf_ms';
844 $filters['Conf DSBL.ORG Multi-Stage']['name'] = 'DSBL.org Confirmed Multi-Stage Relay List';
845 $filters['Conf DSBL.ORG Multi-Stage']['link'] = 'http://www.dsbl.org/';
846 $filters['Conf DSBL.ORG Multi-Stage']['dns'] = 'multihop.dsbl.org';
847 $filters['Conf DSBL.ORG Multi-Stage']['result'] = '127.0.0.2';
848 $filters['Conf DSBL.ORG Multi-Stage']['comment'] =
849 _("FREE - Distributed Sender Boycott List - Confirmed Multi-stage Relays");
850
851 $filters['UN-Conf DSBL.ORG']['prefname'] = 'filters_spam_dsbl_unc';
852 $filters['UN-Conf DSBL.ORG']['name'] = 'DSBL.org UN-Confirmed Relay List';
853 $filters['UN-Conf DSBL.ORG']['link'] = 'http://www.dsbl.org/';
854 $filters['UN-Conf DSBL.ORG']['dns'] = 'unconfirmed.dsbl.org';
855 $filters['UN-Conf DSBL.ORG']['result'] = '127.0.0.2';
856 $filters['UN-Conf DSBL.ORG']['comment'] =
857 _("FREE - Distributed Sender Boycott List - UN-Confirmed Relays");
858
10a26cea 859 foreach ($filters as $Key => $Value) {
9c655416 860 $filters[$Key]['enabled'] = getPref($data_dir, $username, $filters[$Key]['prefname']);
4eee5968 861 }
862
10a26cea 863 return $filters;
864}
4eee5968 865
0a1dc88e 866/**
9c655416 867 * Removes a User filter
868 * @param int $id ID of the filter to remove
0a1dc88e 869 * @access private
870 */
10a26cea 871function remove_filter ($id) {
872 global $data_dir, $username;
4eee5968 873
9c655416 874 while ($nextFilter = getPref($data_dir, $username, 'filter' . ($id + 1))) {
10a26cea 875 setPref($data_dir, $username, 'filter' . $id, $nextFilter);
876 $id ++;
4eee5968 877 }
878
10a26cea 879 removePref($data_dir, $username, 'filter' . $id);
880}
4eee5968 881
0a1dc88e 882/**
9c655416 883 * Swaps two filters
884 * @param int $id1 ID of first filter to swap
f8a1ed5a 885 * @param int $id2 ID of second filter to swap
0a1dc88e 886 * @access private
887 */
10a26cea 888function filter_swap($id1, $id2) {
889 global $data_dir, $username;
4eee5968 890
10a26cea 891 $FirstFilter = getPref($data_dir, $username, 'filter' . $id1);
892 $SecondFilter = getPref($data_dir, $username, 'filter' . $id2);
893
894 if ($FirstFilter && $SecondFilter) {
895 setPref($data_dir, $username, 'filter' . $id2, $FirstFilter);
896 setPref($data_dir, $username, 'filter' . $id1, $SecondFilter);
4eee5968 897 }
10a26cea 898}
4eec80a7 899
0a1dc88e 900/**
9c655416 901 * This updates the filter rules when renaming or deleting folders
0a1dc88e 902 * @param array $args
b2d8bc6c 903 * @access private
0a1dc88e 904 */
f5ab1fb9 905function update_for_folder ($args) {
9c655416 906
f5ab1fb9 907 $old_folder = $args[0];
9c655416 908 $new_folder = $args[2];
909 $action = $args[1];
ce68b76b 910 global $data_dir, $username;
4eec80a7 911 $filters = array();
912 $filters = load_filters();
913 $filter_count = count($filters);
914 $p = 0;
9c655416 915 for ($i = 0; $i < $filter_count; $i++) {
4eec80a7 916 if (!empty($filters)) {
917 if ($old_folder == $filters[$i]['folder']) {
918 if ($action == 'rename') {
919 $filters[$i]['folder'] = $new_folder;
920 setPref($data_dir, $username, 'filter'.$i,
921 $filters[$i]['where'].','.$filters[$i]['what'].','.$new_folder);
922 }
923 elseif ($action == 'delete') {
924 remove_filter($p);
925 $p = $p-1;
926 }
927 }
928 $p++;
929 }
930 }
931}
0a1dc88e 932
933/**
0a1dc88e 934 * Display formated error message
935 * @param string $string text message
936 * @return string html formated text message
937 * @access private
938 */
939function do_error($string) {
940 global $color;
941 echo "<p align=\"center\"><font color=\"$color[2]\">";
942 echo $string;
943 echo "</font></p>\n";
944}