示例#1
0
function optSig(&$sigs)
{
    $sigs = array_unique($sigs);
    // Add SigId
    foreach ($sigs as &$s) {
        $s .= '(?<X' . myCheckSum($s) . '>)';
    }
    unset($s);
    $fix = array('([^\\?\\s])\\({0,1}\\.[\\+\\*]\\){0,1}\\2[a-z]*e' => '(?J)\\.[+*](?<=(?<d>[^\\?\\s])\\(..|(?<d>[^\\?\\s])..)\\)?\\g{d}[a-z]*e', 'http://.+?/.+?\\.php\\?a' => 'http://[^?\\s]++(?<=\\.php)\\?a', '\\s*[\'"]{0,1}.+?[\'"]{0,1}\\s*' => '.+?', '[\'"]{0,1}.+?[\'"]{0,1}' => '.+?');
    $sigs = str_replace(array_keys($fix), array_values($fix), $sigs);
    $fix = array('~^\\\\[d]\\+&@~' => '&@(?<=\\d..)', '~^((\\[\'"\\]|\\\\s|@)(\\{0,1\\}\\.?|[?*]))+~' => '');
    $sigs = preg_replace(array_keys($fix), array_values($fix), $sigs);
    optSigCheck($sigs);
    $tmp = array();
    foreach ($sigs as $i => $s) {
        if (strpos($s, '.+') !== false || strpos($s, '.*') !== false) {
            unset($sigs[$i]);
            $tmp[] = $s;
        }
    }
    usort($sigs, 'strcasecmp');
    $txt = implode("\n", $sigs);
    for ($i = 24; $i >= 1; $i > 4 ? $i -= 4 : --$i) {
        $txt = preg_replace_callback('#^((?>(?:\\\\.|\\[.+?\\]|[^(\\n]|\\((?:\\\\.|[^)(\\n])++\\))(?:[*?+]\\+?|)){' . $i . ',}).*(?:\\n\\1(?![{?*+]).+)+#im', 'optMergePrefixes', $txt);
    }
    $sigs = array_merge(explode("\n", $txt), $tmp);
    optSigCheck($sigs);
}
示例#2
0
function optSig(&$sigs)
{
    optSigCheck($sigs);
    usort($sigs, 'strcasecmp');
    $txt = implode("\n", $sigs);
    for ($i = 24; $i >= 1; $i > 4 ? $i -= 4 : --$i) {
        $txt = preg_replace_callback('#^((?>(?:\\\\.|\\[.+?\\]|[^(\\n]|\\((?:\\\\.|[^)(\\n])++\\))(?:[*?+]\\+?|)){' . $i . ',}).*(?:\\n\\1(?![{?*+]).+)+#im', 'optMergePrefixes', $txt);
    }
    $sigs = explode("\n", $txt);
    optSigCheck($sigs);
}