inc/functions/ip_in_range.php throws error when exploded array lacks 2nd val
-
I had to modify this
$pieces = explode ("/", $range_ip, 2); $left_piece = $pieces[0]; $right_piece = $pieces[1]; // Extract out the main IP pieces $ip_pieces = explode("::", $left_piece, 2); $main_ip_piece = $ip_pieces[0]; $last_ip_piece = $ip_pieces[1];to something like this
$pieces = explode ("/", $range_ip, 2); if (count($pieces) > 0) $left_piece = $pieces[0]; if (count($pieces) > 1) $right_piece = $pieces[1]; // Extract out the main IP pieces $ip_pieces = explode("::", $left_piece, 2); if (count($ip_pieces) > 0) $main_ip_piece = $ip_pieces[0]; if (count($ip_pieces) > 1) $last_ip_piece = $ip_pieces[1];and this
if (trim($last_ip_piece) != "") {to something like this
if (isset($last_ip_piece) && trim($last_ip_piece) != "") {in two of the functions.
The topic ‘inc/functions/ip_in_range.php throws error when exploded array lacks 2nd val’ is closed to new replies.