note 81029 added to function.ip2long

From: Date: Mon, 11 Feb 2008 19:44:43 +0000
Subject: note 81029 added to function.ip2long
Groups: php.notes 
Request: Send a blank email to php-notes+get-136049@lists.php.net to get a copy of this message
Just a little function to check visitor's ip if it is in given range or not (I could'nt find anywhere so i improvise): 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'); ---- Server IP: 89.248.170.58 Probable Submitter: 62.212.134.96 ---- Manual Page -- http://www.php.net/manual/en/function.ip2long.php Edit -- https://master.php.net/note/edit/81029 Del: integrated -- https://master.php.net/note/delete/81029/integrated Del: useless -- https://master.php.net/note/delete/81029/useless Del: bad code -- https://master.php.net/note/delete/81029/bad+code Del: spam -- https://master.php.net/note/delete/81029/spam Del: non-english -- https://master.php.net/note/delete/81029/non-english Del: in docs -- https://master.php.net/note/delete/81029/in+docs Del: other reasons-- https://master.php.net/note/delete/81029 Reject -- https://master.php.net/note/reject/81029 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136049) next »