public function getNmask($cdr_nmask) { $bin_nmask = SubnetCalculator::cdrtobin($cdr_nmask); return SubnetCalculator::bintodq($bin_nmask); }
$network = new Network(false, false, $network, (int) $_POST['netmask'], 6); if ($network->fetch()) { //if network found, then try to add ip address $ip = new Ip(false, false, $network->getNetworkId(), $ip); if ($ip->fetch()) { $networkinterface = new Networkinterface($ip->getInterfaceId()); $networkinterface->fetch(); $router = new Router($networkinterface->getRouterId()); $router->fetch(); $smarty->assign('object', "router"); $smarty->assign('object_data', $router); } } } elseif (isset($_POST['what']) and $_POST['what'] == 'ip' and $_POST['ipv'] == 4) { //first try to determine network of given address $network = SubnetCalculator::getDqNet($_POST['ip'], (int) $_POST['netmask']); $network = new Network(false, false, $network, (int) $_POST['netmask'], 4); if ($network->fetch()) { //if network found, then try to add ip address $ip = new Ip(false, false, $network->getNetworkId(), $_POST['ip']); if ($ip->fetch()) { $networkinterface = new Networkinterface($ip->getInterfaceId()); $networkinterface->fetch(); $router = new Router($networkinterface->getRouterId()); $router->fetch(); $smarty->assign('object', "router"); $smarty->assign('object_data', $router); } } } elseif (isset($_POST['what']) and $_POST['what'] == 'mac_add') { }