So I'm working on our SolusVM replacement and am hitting my head trying to figure out how to handle inserting hundreds of IPs at a time into a MySQL database. The field is varchar(30) and I was thinking of something like this (found the code while searching around):
$main = $_POST["ip"];
foreach(range(1, 254) as $ip) {
$adr = $main . $ip;
}
Any comments or suggestions for this? I was hoping to use a form to use a range of IPs (starting IP - ending IP) or use slash notation so certain size blocks would be added (/24, /27, /22, etc...) but code to add a /24 (254 IPs) would work just fine also. Keep in mind this is only for IPv4 for now.
$main = $_POST["ip"];
foreach(range(1, 254) as $ip) {
$adr = $main . $ip;
}
Any comments or suggestions for this? I was hoping to use a form to use a range of IPs (starting IP - ending IP) or use slash notation so certain size blocks would be added (/24, /27, /22, etc...) but code to add a /24 (254 IPs) would work just fine also. Keep in mind this is only for IPv4 for now.
Last edited by a moderator: