<?php
-// $Id: SpamTest.php,v 1.23 2008/12/27 14:50:00 henoheno Exp $
+// $Id: SpamTest.php,v 1.24 2008/12/27 15:21:41 henoheno Exp $
// Copyright (C) 2007 heno
//
// Design test case for spam.php (called from runner.php)
// get_blocklist_add()
$array = array();
-
+ //
get_blocklist_add($array, 'foo', 'bar');
$this->assertEquals(1, count($array));
$this->assertEquals('bar', $array['foo']);
-
+ //
get_blocklist_add($array, 'hoge', 'fuga');
$this->assertEquals(2, count($array));
$this->assertEquals('bar', $array['foo']);
$this->assertEquals('fuga', $array['hoge']);
-
+ //
get_blocklist_add($array, -1, '*.txt');
$this->assertEquals(3, count($array));
$this->assertEquals('bar', $array['foo']);
$this->assertEquals('fuga', $array['hoge']);
- $this->assertEquals('/^.*\.txt$/i', $array['*.txt']);
+ $this->assertEquals('#^.*\.txt$#i', $array['*.txt']);
// get_blocklist()
// ALL
<?php
-// $Id: spam.php,v 1.206 2008/12/27 15:11:37 henoheno Exp $
+// $Id: spam.php,v 1.207 2008/12/27 15:21:41 henoheno Exp $
// Copyright (C) 2006-2007 PukiWiki Developers Team
// License: GPL v2 or (at your option) any later version
//
get_blocklist_add($regexes[$_list], $key, $value);
}
}
+
unset($blocklist[$_list]);
}
}
}
}
-// Subroutine of get_blocklist()
-function get_blocklist_add(& $array, $key = 0, $value = '*.example.org')
+// Subroutine of get_blocklist(): Add new regex to the $array
+function get_blocklist_add(& $array, $key = 0, $value = '*.example.org/path/to/file.html')
{
if (is_string($key)) {
- $array[$key] = & $value; // Treat $value as a regex for FQDN(host)s
+ $array[$key] = & $value; // Treat $value as a regex for FQDN(host)s
} else {
- $array[$value] = '/^' . generate_host_regex($value, '/') . '$/i';
+ $array[$value] = '#^' . generate_host_regex($value, '#') . '$#i';
}
}