修訂 | 78994767de288b0cdf025cbb34086e0ee0b860a9 (tree) |
---|---|
時間 | 2007-02-20 00:34:47 |
作者 | henoheno <henoheno> |
Commiter | henoheno |
$Id: spam.php,v 1.119 2007/02/19 15:28:42 henoheno Exp $
* pkwk_mail_notify(): HEADER option
* Remains more data
* scheme:////////nasty.example.com
@@ -1,5 +1,5 @@ | ||
1 | 1 | <?php |
2 | -// $Id: spam.php,v 1.18 2007/02/04 10:42:41 henoheno Exp $ | |
2 | +// $Id: spam.php,v 1.19 2007/02/19 15:34:47 henoheno Exp $ | |
3 | 3 | // Copyright (C) 2006-2007 PukiWiki Developers Team |
4 | 4 | // License: GPL v2 or (at your option) any later version |
5 | 5 | // Functions for Concept-work of spam-uri metrics |
@@ -51,7 +51,7 @@ function uri_pickup($string = '', $normalize = TRUE, | ||
51 | 51 | preg_match_all( |
52 | 52 | // scheme://userinfo@host:port/path/or/pathinfo/maybefile.and?query=string#fragment |
53 | 53 | // Refer RFC3986 (Regex below is not strict) |
54 | - '#(\b[a-z][a-z0-9.+-]{1,8})://' . // 1: Scheme | |
54 | + '#(\b[a-z][a-z0-9.+-]{1,8}):/+' . // 1: Scheme | |
55 | 55 | '(?:' . |
56 | 56 | '([^\s<>"\'\[\]/\#?@]*)' . // 2: Userinfo (Username) |
57 | 57 | '@)?' . |
@@ -793,7 +793,7 @@ function check_uri_spam($target = '', $method = array()) | ||
793 | 793 | $remains = & $progress['remains']; |
794 | 794 | $asap = isset($method['asap']); |
795 | 795 | |
796 | - // Return if ... | |
796 | + // Recurse | |
797 | 797 | if (is_array($target)) { |
798 | 798 | foreach($target as $str) { |
799 | 799 | // Recurse |
@@ -820,7 +820,11 @@ function check_uri_spam($target = '', $method = array()) | ||
820 | 820 | } |
821 | 821 | foreach ($_remains as $key=>$value) { |
822 | 822 | foreach ($value as $_key=>$_value) { |
823 | - $remains[$key][$_key] = $_value; | |
823 | + if (is_int($_key)) { | |
824 | + $remains[$key][] = $_value; | |
825 | + } else { | |
826 | + $remains[$key][$_key] = $_value; | |
827 | + } | |
824 | 828 | } |
825 | 829 | } |
826 | 830 | if ($asap && $is_spam) break; |
@@ -855,14 +859,14 @@ function check_uri_spam($target = '', $method = array()) | ||
855 | 859 | } |
856 | 860 | |
857 | 861 | // Return if ... |
858 | - if ($asap && $is_spam) { | |
859 | - return $progress; | |
860 | - } | |
861 | - // URI Init | |
862 | + if ($asap && $is_spam) return $progress; | |
863 | + | |
864 | + // URI: Pickup | |
862 | 865 | $pickups = spam_uri_pickup($target, $method); |
863 | - if (empty($pickups)) { | |
864 | - return $progress; | |
865 | - } | |
866 | + //$remains['uri_pickup'] = & $pickups; | |
867 | + | |
868 | + // Return if ... | |
869 | + if (empty($pickups)) return $progress; | |
866 | 870 | |
867 | 871 | // URI: Check quantity |
868 | 872 | $sum['quantity'] += count($pickups); |
@@ -930,14 +934,13 @@ function check_uri_spam($target = '', $method = array()) | ||
930 | 934 | } |
931 | 935 | |
932 | 936 | // Return if ... |
933 | - if ($asap && $is_spam) { | |
934 | - return $progress; | |
935 | - } | |
937 | + if ($asap && $is_spam) return $progress; | |
936 | 938 | |
937 | 939 | // Host: Uniqueness (uniq / non-uniq) |
938 | 940 | $hosts = array(); |
939 | 941 | foreach ($pickups as $pickup) $hosts[] = & $pickup['host']; |
940 | 942 | $hosts = array_unique($hosts); |
943 | + //$remains['uniqhost'] = & $hosts; | |
941 | 944 | $sum['uniqhost'] += count($hosts); |
942 | 945 | if ((! $asap || ! $is_spam) && isset($method['non_uniqhost'])) { |
943 | 946 | $sum['non_uniqhost'] = $sum['quantity'] - $sum['uniqhost']; |
@@ -947,9 +950,7 @@ function check_uri_spam($target = '', $method = array()) | ||
947 | 950 | } |
948 | 951 | |
949 | 952 | // Return if ... |
950 | - if ($asap && $is_spam) { | |
951 | - return $progress; | |
952 | - } | |
953 | + if ($asap && $is_spam) return $progress; | |
953 | 954 | |
954 | 955 | // URI: Bad host |
955 | 956 | if ((! $asap || ! $is_spam) && isset($method['badhost'])) { |
@@ -959,9 +960,9 @@ function check_uri_spam($target = '', $method = array()) | ||
959 | 960 | } else { |
960 | 961 | $badhost = is_badhost($hosts, $asap, $__remains); |
961 | 962 | if ($__remains) { |
962 | - $progress['remains']['badhost'] = array(); | |
963 | + $remains['badhost'] = array(); | |
963 | 964 | foreach ($__remains as $value) { |
964 | - $progress['remains']['badhost'][$value] = TRUE; | |
965 | + $remains['badhost'][$value] = TRUE; | |
965 | 966 | } |
966 | 967 | } |
967 | 968 | } |
@@ -1094,7 +1095,7 @@ function pkwk_spamnotify($action, $page, $target = array('title' => ''), $progre | ||
1094 | 1095 | $summary['URI'] = get_script_uri() . '?' . rawurlencode($page); |
1095 | 1096 | $summary['USER_AGENT'] = TRUE; |
1096 | 1097 | $summary['REMOTE_ADDR'] = TRUE; |
1097 | - pkwk_mail_notify($notify_subject, var_export($target, TRUE), $summary); | |
1098 | + pkwk_mail_notify($notify_subject, var_export($target, TRUE), $summary, TRUE); | |
1098 | 1099 | } |
1099 | 1100 | |
1100 | 1101 | ?> |