getMessage()); $ip = new \IPTools\IP(self::$default_ip); } // Check List foreach ($range as $list) { try { $contains_ip = Range::parse($list)->contains($ip); } catch (\Exception $e) { \WP_Statistics::log($e->getMessage()); $contains_ip = false; } if ($contains_ip) { return true; } } return false; } /** * Check Validation IP * * @param $ip * @return bool */ public static function isIP($ip) { return filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE); } /** * what is Method $_SERVER for get User Real IP */ public static function getIPMethod() { $ip_method = Option::get('ip_method'); return ($ip_method != false ? $ip_method : self::$default_ip_method); } /** * Check IP contain Special Character * * @param $ip * @return bool */ public static function check_sanitize_ip($ip) { $preg = preg_replace('/[^0-9- .:]/', '', $ip); return $preg == $ip; } /** * Update All Hash String For Hash IP */ public static function Update_HashIP_Visitor() { global $wpdb; // Get the rows from the Visitors table. $result = $wpdb->get_results("SELECT DISTINCT ip FROM " . DB::table('visitor')); foreach ($result as $row) { if (IP::IsHashIP($row->ip)) { $wpdb->update( DB::table('visitor'), array('ip' => IP::$hash_ip_prefix . sha1($row->ip . Helper::random_string()),), array('ip' => $row->ip) ); } } } }