note 34796 added to function.ip2long

From: Date: Thu, 07 Aug 2003 03:02:19 +0000
Subject: note 34796 added to function.ip2long
Groups: php.notes 
Request: Send a blank email to php-notes+get-53544@lists.php.net to get a copy of this message
If you want to get the interface of an IP, based on the local route table, use this. function GetIfaceforIP($user_ip) { $route = "/bin/netstat -rn"; exec($route, $aoutput); foreach($aoutput as $key => $line) { if($key > 1) { $line = ereg_replace("[[:space:]]+",",",$line); list($network, $gateway, $mask, $flags, $mss, $window, $irtt, $iface) = explode(",", $line) if((ip2long($user_ip) & ip2long($mask)) == ip2long($network)) { return $iface; } } } } ---- Manual Page -- http://www.php.net/manual/en/function.ip2long.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34796 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34796&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34796&report=yes

« previous php.notes (#53544) next »