@@ -138,6 +138,9 @@ |
||
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | + /** |
|
| 142 | + * @param string $ip |
|
| 143 | + */ |
|
| 141 | 144 | private static function _cut_ip( $ip, $cut_end = true ) { |
| 142 | 145 | $separator = ( self::_is_ipv4($ip) ? '.' : ':' ); |
| 143 | 146 | $part = ( $cut_end ? strrchr( $ip, $separator) : strstr( $ip, $separator) ); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | /* Check if logged in */ |
| 13 | 13 | if ( is_user_logged_in() ) { |
| 14 | - return $response; |
|
| 14 | + return $response; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /* Honeypot */ |
@@ -65,10 +65,10 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | - * Check for form submission time |
|
| 69 | - * |
|
| 70 | - * @return boolean TRUE if the action time is less than 5 seconds |
|
| 71 | - */ |
|
| 68 | + * Check for form submission time |
|
| 69 | + * |
|
| 70 | + * @return boolean TRUE if the action time is less than 5 seconds |
|
| 71 | + */ |
|
| 72 | 72 | |
| 73 | 73 | private static function _is_shortest_time() { |
| 74 | 74 | $too_short = false; |
@@ -124,11 +124,11 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | - * Check for an IPv6 address |
|
| 128 | - * |
|
| 129 | - * @param string $ip IP to validate |
|
| 130 | - * @return boolean TRUE if IPv6 |
|
| 131 | - */ |
|
| 127 | + * Check for an IPv6 address |
|
| 128 | + * |
|
| 129 | + * @param string $ip IP to validate |
|
| 130 | + * @return boolean TRUE if IPv6 |
|
| 131 | + */ |
|
| 132 | 132 | |
| 133 | 133 | private static function _is_ipv6( $ip ) { |
| 134 | 134 | if ( function_exists('filter_var') ) { |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /* Honeypot */ |
| 18 | - if ( ! empty($_POST['ab_spam__hidden_field']) ) { |
|
| 18 | + if ( ! empty( $_POST['ab_spam__hidden_field'] ) ) { |
|
| 19 | 19 | $response['reason'] = 'css'; |
| 20 | 20 | return $response; |
| 21 | 21 | } |
@@ -32,12 +32,12 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /* BBCode Spam */ |
| 35 | - if ( $options['bbcode_check'] && self::_is_bbcode_spam($body) ) { |
|
| 35 | + if ( $options['bbcode_check'] && self::_is_bbcode_spam( $body ) ) { |
|
| 36 | 36 | $response['reason'] = 'bbcode'; |
| 37 | 37 | return $response; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if ( $options['advanced_check'] && self::_is_fake_ip($ip) ) { |
|
| 40 | + if ( $options['advanced_check'] && self::_is_fake_ip( $ip ) ) { |
|
| 41 | 41 | $response['reason'] = 'server'; |
| 42 | 42 | return $response; |
| 43 | 43 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | if ( $options['regexp_check'] ) { |
| 47 | 47 | $is_spam = self::_is_regexp_spam( array( |
| 48 | 48 | 'ip' => $ip, |
| 49 | - 'host' => parse_url($url, PHP_URL_HOST), |
|
| 49 | + 'host' => parse_url( $url, PHP_URL_HOST ), |
|
| 50 | 50 | 'body' => $body, |
| 51 | 51 | 'email' => $email, |
| 52 | 52 | 'author' => $author, |
@@ -113,10 +113,10 @@ discard block |
||
| 113 | 113 | return true; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $ip_by_host = gethostbyname($client_host); |
|
| 116 | + $ip_by_host = gethostbyname( $client_host ); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - if ( strpos( $client_ip, self::_cut_ip($ip_by_host) ) === false ) { |
|
| 119 | + if ( strpos( $client_ip, self::_cut_ip( $ip_by_host ) ) === false ) { |
|
| 120 | 120 | return true; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | |
| 133 | 133 | private static function _is_ipv6( $ip ) { |
| 134 | - if ( function_exists('filter_var') ) { |
|
| 134 | + if ( function_exists( 'filter_var' ) ) { |
|
| 135 | 135 | return filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) !== false; |
| 136 | 136 | } else { |
| 137 | 137 | return ! self::_is_ipv4( $ip ); |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | private static function _cut_ip( $ip, $cut_end = true ) { |
| 142 | - $separator = ( self::_is_ipv4($ip) ? '.' : ':' ); |
|
| 143 | - $part = ( $cut_end ? strrchr( $ip, $separator) : strstr( $ip, $separator) ); |
|
| 142 | + $separator = ( self::_is_ipv4( $ip ) ? '.' : ':' ); |
|
| 143 | + $part = ( $cut_end ? strrchr( $ip, $separator ) : strstr( $ip, $separator ) ); |
|
| 144 | 144 | |
| 145 | 145 | return str_replace( $part, '', $ip ); |
| 146 | 146 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | ); |
| 169 | 169 | |
| 170 | 170 | /* Spammy author */ |
| 171 | - if ( $quoted_author = preg_quote($comment['author'], '/') ) { |
|
| 171 | + if ( $quoted_author = preg_quote( $comment['author'], '/' ) ) { |
|
| 172 | 172 | $patterns[] = array( |
| 173 | 173 | 'body' => sprintf( |
| 174 | 174 | '<a.+?>%s<\/a>$', |
@@ -201,30 +201,30 @@ discard block |
||
| 201 | 201 | return false; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - foreach ($patterns as $pattern) { |
|
| 204 | + foreach ( $patterns as $pattern ) { |
|
| 205 | 205 | $hits = array(); |
| 206 | 206 | |
| 207 | - foreach ($pattern as $field => $regexp) { |
|
| 207 | + foreach ( $pattern as $field => $regexp ) { |
|
| 208 | 208 | /* Empty value? */ |
| 209 | - if ( empty($field) OR !in_array($field, $fields) OR empty($regexp) ) { |
|
| 209 | + if ( empty( $field ) OR ! in_array( $field, $fields ) OR empty( $regexp ) ) { |
|
| 210 | 210 | continue; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /* Ignore non utf-8 chars */ |
| 214 | - $comment[$field] = ( function_exists('iconv') ? iconv('utf-8', 'utf-8//TRANSLIT', $comment[$field]) : $comment[$field] ); |
|
| 214 | + $comment[$field] = ( function_exists( 'iconv' ) ? iconv( 'utf-8', 'utf-8//TRANSLIT', $comment[$field] ) : $comment[$field] ); |
|
| 215 | 215 | |
| 216 | 216 | /* Empty value? */ |
| 217 | - if ( empty($comment[$field]) ) { |
|
| 217 | + if ( empty( $comment[$field] ) ) { |
|
| 218 | 218 | continue; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /* Perform regex */ |
| 222 | - if ( @preg_match('/' .$regexp. '/isu', $comment[$field]) ) { |
|
| 222 | + if ( @preg_match( '/' . $regexp . '/isu', $comment[$field] ) ) { |
|
| 223 | 223 | $hits[$field] = true; |
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - if ( count($hits) === count($pattern) ) { |
|
| 227 | + if ( count( $hits ) === count( $pattern ) ) { |
|
| 228 | 228 | return true; |
| 229 | 229 | } |
| 230 | 230 | } |
@@ -206,7 +206,7 @@ |
||
| 206 | 206 | |
| 207 | 207 | foreach ($pattern as $field => $regexp) { |
| 208 | 208 | /* Empty value? */ |
| 209 | - if ( empty($field) OR !in_array($field, $fields) OR empty($regexp) ) { |
|
| 209 | + if ( empty($field) or !in_array($field, $fields) or empty($regexp) ) { |
|
| 210 | 210 | continue; |
| 211 | 211 | } |
| 212 | 212 | |