log_register('CHANGE Tariff (' . $login . ') ON ' . $newtariff); } //ip editing if (wf_CheckPost(array('editip'))) { $service = $_POST['serviceselect']; //if ip is not a same if ($service != 'SAME') { $currentip = zb_UserGetIP($login); $currentmac = zb_MultinetGetMAC($currentip); $newnetid = multinet_get_service_networkid($service); $newip = trim($_POST['editip']); $newip = mysql_real_escape_string($newip); @($checkfreeip = multinet_get_next_freeip('nethosts', 'ip', $newnetid)); if (!empty($checkfreeip)) { //check is ip acceptable for this pool? $allfreeips = multinet_get_all_free_ip('nethosts', 'ip', $newnetid); $allfreeips = array_flip($allfreeips); if (isset($allfreeips[$newip])) { $billing->setip($login, $newip); multinet_delete_host($currentip); multinet_add_host($newnetid, $newip, $currentmac); multinet_rebuild_all_handlers(); multinet_RestartDhcp(); log_register("CHANGE MultiNetIP (" . $login . ") FROM " . $currentip . " ON " . $newip); } else { $alert = ' <script type="text/javascript"> alert("' . __('Error') . ': ' . __('Wrong IP') . '"); document.location.href="?module=expresscard&username='******'"; </script> ';
function multinet_get_next_freeip($table, $field, $network_id) { $all_free_ips = multinet_get_all_free_ip($table, $field, $network_id); $temp = array_keys($all_free_ips); return @$all_free_ips[$temp[0]]; }
/** * Returns IP selector ajax container content * * @param int $serviceId * * @return string */ public function ajIpSelector($serviceId) { $serviceId = vf($serviceId, 3); $result = ''; if (isset($this->allServices[$serviceId])) { $networkId = multinet_get_service_networkid($serviceId); //default IP selection - first free if (!$this->customFlag) { @($nextFreeIp = multinet_get_next_freeip('nethosts', 'ip', $networkId)); if (!empty($nextFreeIp)) { $result = wf_HiddenInput('ipselector', $nextFreeIp) . ' ' . $nextFreeIp . ' (' . __('first free for this service') . ')'; $result .= wf_HiddenInput('serviceselector', $serviceId); } else { $result = __('No free IP available in selected pool. Please fix it in networks and services module.'); } } else { //custom IP selection box $allFreeIpsRaw = multinet_get_all_free_ip('nethosts', 'ip', $networkId); if (!empty($allFreeIpsRaw)) { $allFreeIpsSelector = array(); foreach ($allFreeIpsRaw as $io => $each) { $allFreeIpsSelector[$each] = $each; } $result = wf_Selector('ipselector', $allFreeIpsSelector, '', '', true); $result .= wf_HiddenInput('serviceselector', $serviceId); } else { $result = __('No free IP available in selected pool. Please fix it in networks and services module.'); } } } return $result; }