0,0 → 1,90 |
#!/usr/bin/php |
<?php |
|
# |
# generic Whois - Maintenance Framework: Testcases |
# |
# (c) 2012-2014 Daniel Marschall, ViaThinkSoft [www.viathinksoft.de] |
# |
# Distribution, usage etc. pp. regulated by the current version of GPL. |
# |
# |
# Version 2014-11-25 |
# |
|
require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php'; |
|
$patterns = glob(__DIR__ . '/../../main/pattern/*'); |
|
#$bs = '\\b'; |
#$be = '\\b'; |
|
$vc = '[\p{L}a-zA-Z0-9_\\-\\+\\*\\.]'; |
$bs = '(?<!'.$vc.')'; |
$be = '(?!'.$vc.')'; |
|
foreach ($patterns as $pattern_file) { |
$pattern = file($pattern_file); |
|
$pattern[] = ':end'; |
|
$content = ''; |
foreach ($pattern as $p) { |
$p = trim($p); |
if ($p == '') continue; |
if ($p[0] == '#') continue; // comment |
|
if (preg_match('@^\\^redirect:@ismU', $p, $m)) continue; |
|
$p = str_replace(array('(.*)', '(.+)'), '', $p); |
|
if ($p[0] == ':') { |
$content = ''; |
} else { |
if ($p[0] == '=') { |
// IP |
$p_ = substr($p, 1); |
|
// ignore for now |
continue; |
} else if ($p[0] == '*') { |
// ASN |
|
preg_match('#\*(.*):(\d+)(-(\d+)){0,1}#isU', $p, $m); |
$prefix = $m[1]; |
$min = $m[2]; |
$max = (isset($m[4])) ? $m[4] : $min; |
|
// ignore for now |
continue; |
} else if (preg_match('@^(urn:){0,1}oid:(.*)@i', $p, $m)) { |
// OIDs |
|
$regex = normalize_oid($m[2]); |
$regex = str_replace('.', '\\.0*', $regex); |
$regex = '@('.$bs.$regex.'(\\.\\d+)*'.$be.')@iU'; |
|
echo "$regex\n"; |
} else { |
// REGEX |
|
$regex = $p; |
|
if ($regex == '.') continue; // last resort |
|
$regex = preg_replace('@(?<!(?<!\\\\)\\$)$@', $vc.'*', $regex); |
$regex = preg_replace('@(?<!\\\\)\\$$@', '', $regex); |
|
$regex = preg_replace('@^(?!\\^)@', $vc.'*', $regex); |
$regex = preg_replace('@^\\^@', '', $regex); |
|
$regex = preg_replace('@(?>!\\$)$@', $vc.'*', $regex); |
$regex = preg_replace('@\\$$@', '', $regex); |
|
$regex = '@('.$bs.$regex.$be.')@iUu'; |
|
echo "$regex\n"; |
} |
} |
} |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |