$last_int) { $ip_refuse('A range is two IPv4 addresses, the lower first.'); } if ($last_int - $first_int >= 256) { $ip_refuse('A range is up to 256 addresses at a time.'); } for ($int = $first_int; $int <= $last_int; $int++) { $ip = intToIpv4($int); if (checkIpForNetwork($ip, $network_id) !== '') { $skipped++; continue; } mysqli_query($mysqli, "INSERT INTO network_ips SET ip_address = '" . escapeSql($ip) . "', $fields, ip_network_id = $network_id"); $added[] = intval(mysqli_insert_id($mysqli)); } if (!$added) { $ip_refuse("None of $first to $last could be documented - they are outside the subnet or documented already."); } $what = "$first - $last"; } else { $ip_error = checkIpForNetwork($ip_address, $network_id); if ($ip_error) { $ip_refuse($ip_error); } mysqli_query($mysqli, "INSERT INTO network_ips SET ip_address = '" . escapeSql($ip_address) . "', $fields, ip_network_id = $network_id"); $added[] = intval(mysqli_insert_id($mysqli)); $what = $ip_address; } $insert_id = $added[0] ?: false; $return_arr['added'] = count($added); $return_arr['skipped'] = $skipped; $label = escapeSql("$what on network " . $network['network_name']); logAudit("IP Address", "Create", "Documented " . count($added) . " address(es), $label via API ($api_key_name)", $client_id, $network_id); logAudit("API", "Success", "Documented $label via API ($api_key_name)", $client_id); } // Output require_once '../create_output.php';