<?php
-// $Id: spam.php,v 1.129 2007/03/25 16:37:26 henoheno Exp $
+// $Id: spam.php,v 1.130 2007/04/11 13:13:33 henoheno Exp $
// Copyright (C) 2006-2007 PukiWiki Developers Team
// License: GPL v2 or (at your option) any later version
//
if ($destructive) {
foreach (array_keys($pickups) as $key) {
$_key = & $pickups[$key];
- $_key['scheme'] = isset($_key['scheme']) ? scheme_normalize($_key['scheme']) : '';
+ $_key['scheme'] = isset($_key['scheme']) ? scheme_normalize($_key['scheme']) : '';
$_key['host'] = isset($_key['host']) ? host_normalize($_key['host']) : '';
- $_key['port'] = isset($_key['port']) ? port_normalize($_key['port'], $_key['scheme'], FALSE) : '';
+ $_key['port'] = isset($_key['port']) ? port_normalize($_key['port'], $_key['scheme'], FALSE) : '';
$_key['path'] = isset($_key['path']) ? strtolower(path_normalize($_key['path'])) : '';
$_key['file'] = isset($_key['file']) ? file_normalize($_key['file']) : '';
$_key['query'] = isset($_key['query']) ? query_normalize($_key['query']) : '';
} else {
foreach (array_keys($pickups) as $key) {
$_key = & $pickups[$key];
- $_key['scheme'] = isset($_key['scheme']) ? scheme_normalize($_key['scheme']) : '';
- $_key['host'] = isset($_key['host']) ? strtolower($_key['host']) : '';
- $_key['port'] = isset($_key['port']) ? port_normalize($_key['port'], $_key['scheme'], FALSE) : '';
- $_key['path'] = isset($_key['path']) ? path_normalize($_key['path']) : '';
+ $_key['scheme'] = isset($_key['scheme']) ? scheme_normalize($_key['scheme']) : '';
+ $_key['host'] = isset($_key['host']) ? strtolower($_key['host']) : '';
+ $_key['port'] = isset($_key['port']) ? port_normalize($_key['port'], $_key['scheme'], FALSE) : '';
+ $_key['path'] = isset($_key['path']) ? path_normalize($_key['path']) : '';
}
}
-
return $pickups;
}
// [OK] nothing==&eg=dummy&eg=padding&eg=foobar => eg=foobar
function query_normalize($string = '', $equal = TRUE, $equal_cutempty = TRUE, $stortolower = TRUE)
{
+ if (! is_string($string)) return '';
if ($stortolower) $string = strtolower($string);
$array = explode('&', $string);
// 23 => ']',
);
+ if (! is_string($string)) return '';
+
$string = str_replace($from, $mid, $string); // Hide
$string = preg_quote($string, $divider);
$string = str_replace($mid, $to, $string); // Unhide
// TODO: IPv4, CIDR?, IPv6
function generate_host_regex($string = '', $divider = '/')
{
+ if (! is_string($string)) return '';
+
if (mb_strpos($string, '.') === FALSE)
return generate_glob_regex($string, $divider);
// 'IANA-examples' => '#^(?:.*\.)?example\.(?:com|net|org)$#',
// );
foreach(array('goodhost', 'badhost') as $_list) {
- if (! isset($blocklist[$list])) continue;
+ if (! isset($blocklist[$_list])) continue;
foreach ($blocklist[$_list] as $key => $value) {
if (is_array($value)) {
$regexs[$_list][$key] = array();
$result = array();
if (! is_array($hosts)) $hosts = array($hosts);
foreach(array_keys($hosts) as $key) {
- if (! is_string($hosts[$key])) unset($hosts[$key]);
+ if (! is_string($hosts[$key])) {
+ unset($hosts[$key]);
+ }
}
if (empty($hosts)) return $result;
}
if (empty($hosts)) return $result;
- $tmp = array();
foreach (get_blocklist('badhost') as $label => $regex) {
if (is_array($regex)) {
$result[$label] = array();
foreach($regex as $_label => $_regex) {
- if (is_badhost_avail($_label, $_regex, $hosts, $result[$label]) && $asap) break;
+ if (is_badhost_avail($_label, $_regex, $hosts, $result[$label]) && $asap) {
+ break;
+ }
}
if (empty($result[$label])) unset($result[$label]);
} else {
- if (is_badhost_avail($label, $regex, $hosts, $result) && $asap) break;
+ if (is_badhost_avail($label, $regex, $hosts, $result) && $asap) {
+ break;
+ }
}
}
<?php
-// $Id: spam.php,v 1.129 2007/03/25 16:37:26 henoheno Exp $
+// $Id: spam.php,v 1.130 2007/04/11 13:13:33 henoheno Exp $
// Copyright (C) 2006-2007 PukiWiki Developers Team
// License: GPL v2 or (at your option) any later version
//
if ($destructive) {
foreach (array_keys($pickups) as $key) {
$_key = & $pickups[$key];
- $_key['scheme'] = isset($_key['scheme']) ? scheme_normalize($_key['scheme']) : '';
+ $_key['scheme'] = isset($_key['scheme']) ? scheme_normalize($_key['scheme']) : '';
$_key['host'] = isset($_key['host']) ? host_normalize($_key['host']) : '';
- $_key['port'] = isset($_key['port']) ? port_normalize($_key['port'], $_key['scheme'], FALSE) : '';
+ $_key['port'] = isset($_key['port']) ? port_normalize($_key['port'], $_key['scheme'], FALSE) : '';
$_key['path'] = isset($_key['path']) ? strtolower(path_normalize($_key['path'])) : '';
$_key['file'] = isset($_key['file']) ? file_normalize($_key['file']) : '';
$_key['query'] = isset($_key['query']) ? query_normalize($_key['query']) : '';
} else {
foreach (array_keys($pickups) as $key) {
$_key = & $pickups[$key];
- $_key['scheme'] = isset($_key['scheme']) ? scheme_normalize($_key['scheme']) : '';
- $_key['host'] = isset($_key['host']) ? strtolower($_key['host']) : '';
- $_key['port'] = isset($_key['port']) ? port_normalize($_key['port'], $_key['scheme'], FALSE) : '';
- $_key['path'] = isset($_key['path']) ? path_normalize($_key['path']) : '';
+ $_key['scheme'] = isset($_key['scheme']) ? scheme_normalize($_key['scheme']) : '';
+ $_key['host'] = isset($_key['host']) ? strtolower($_key['host']) : '';
+ $_key['port'] = isset($_key['port']) ? port_normalize($_key['port'], $_key['scheme'], FALSE) : '';
+ $_key['path'] = isset($_key['path']) ? path_normalize($_key['path']) : '';
}
}
-
return $pickups;
}
// [OK] nothing==&eg=dummy&eg=padding&eg=foobar => eg=foobar
function query_normalize($string = '', $equal = TRUE, $equal_cutempty = TRUE, $stortolower = TRUE)
{
+ if (! is_string($string)) return '';
if ($stortolower) $string = strtolower($string);
$array = explode('&', $string);
// 23 => ']',
);
+ if (! is_string($string)) return '';
+
$string = str_replace($from, $mid, $string); // Hide
$string = preg_quote($string, $divider);
$string = str_replace($mid, $to, $string); // Unhide
// TODO: IPv4, CIDR?, IPv6
function generate_host_regex($string = '', $divider = '/')
{
+ if (! is_string($string)) return '';
+
if (mb_strpos($string, '.') === FALSE)
return generate_glob_regex($string, $divider);
// 'IANA-examples' => '#^(?:.*\.)?example\.(?:com|net|org)$#',
// );
foreach(array('goodhost', 'badhost') as $_list) {
- if (! isset($blocklist[$list])) continue;
+ if (! isset($blocklist[$_list])) continue;
foreach ($blocklist[$_list] as $key => $value) {
if (is_array($value)) {
$regexs[$_list][$key] = array();
$result = array();
if (! is_array($hosts)) $hosts = array($hosts);
foreach(array_keys($hosts) as $key) {
- if (! is_string($hosts[$key])) unset($hosts[$key]);
+ if (! is_string($hosts[$key])) {
+ unset($hosts[$key]);
+ }
}
if (empty($hosts)) return $result;
}
if (empty($hosts)) return $result;
- $tmp = array();
foreach (get_blocklist('badhost') as $label => $regex) {
if (is_array($regex)) {
$result[$label] = array();
foreach($regex as $_label => $_regex) {
- if (is_badhost_avail($_label, $_regex, $hosts, $result[$label]) && $asap) break;
+ if (is_badhost_avail($_label, $_regex, $hosts, $result[$label]) && $asap) {
+ break;
+ }
}
if (empty($result[$label])) unset($result[$label]);
} else {
- if (is_badhost_avail($label, $regex, $hosts, $result) && $asap) break;
+ if (is_badhost_avail($label, $regex, $hosts, $result) && $asap) {
+ break;
+ }
}
}