if (sizeof($lineArr) < 9) { $errors[] = "Line {$k} is invalid"; unset($outFile[$k]); //wrong line, unset! } else { // reformat IP state $lineArr[1] = $Addresses->address_type_type_to_index($lineArr[1]); // reformat device from name to id $devices = $Tools->fetch_devices(); foreach ($devices as $d) { if ($d->hostname == $lineArr[6]) { $lineArr[6] = $d->id; } } // insert $ret = $Addresses->import_address_from_csv($lineArr, $_POST['subnetId']); if (!is_bool($ret) && strlen($ret) > 0) { $errors[] = $ret; $failed = true; } elseif ($ret === false) { $failed = true; } } } # print success if no errors if (@$failed === true) { # errors if (sizeof($errors) > 0) { foreach ($errors as $e) { $Result->show("danger", _("Error") . ": " . _($e), false); }