Virtual machine supports SG11 extension
How to encrypt
<? php function ip_in_range( $ip, $range ) { if ( strpos( $range, '/' ) == false ) { $range .= '/ 32'; } // $range is in IP/CIDR format eg 127.0.0.1/24 list( $range, $netmask ) = explode( '/', $range, 2 ); $range_decimal = ip2long( $range ); $ip_decimal = ip2long( $ip ); $wildcard_decimal = pow( 2, ( 32 - $netmask ) ) - 1; $netmask_decimal = ~ $wildcard_decimal; return ( ( $ip_decimal & $netmask_decimal ) == ( $range_decimal & $netmask_decimal ) ); } var_dump(ip_in_range('8.8.8.8', '8.8.8.0/24'));
[ mingming6@bx219.onlinemgr ~]$ curl ' http://1.lazysingle2.sc2yun.com/sg11/example.php ' bool(true) [ mingming6@bx219.onlinemgr ~]$ curl ' http://1.lazysingle2.sc2yun.com/sg11/example_encode.php ' bool(true)