note 81030 deleted from function.ip2long by cmb

From: Date: Sun, 18 Aug 2019 08:44:43 +0000
Subject: note 81030 deleted from function.ip2long by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211944@lists.php.net to get a copy of this message
Note Submitter: mhakopian at gmail dot com ---- Just a little function to check visitor's ip if it is in given range or not (I couldn't find anywhere so i improvise): <?php function in_ip_range($ip_one, $ip_two=false){ if($ip_two===false){ if($ip_one==$_SERVER['REMOTE_ADDR']){ $ip=true; }else{ $ip=false; } }else{ if(ip2long($ip_one)<=ip2long($_SERVER['REMOTE_ADDR']) && ip2long($ip_two)>=ip2long($_SERVER['REMOTE_ADDR'])){ $ip=true; }else{ $ip=false; } } return $ip; } //usage echo in_ip_range('192.168.0.0','192.168.1.254'); ?>

« previous php.notes (#211944) next »