if ($network->fetch()) { //if network found, then try to add ip address. //first we need to check if the interface we want to add th ip to already exists //and if not we need to create it. $networkinterface = new Networkinterface(false, (int) $_GET['router_id'], $_GET['networkinterface_name']); if (!$networkinterface->fetch()) { $networkinterface_id = $networkinterface->store(); if (!$networkinterface_id) { echo "error,new_interface_not_stored"; die; } } else { $networkinterface_id = $networkinterface->getNetworkinterfaceId(); } //then we can create the ip $ip = new Ip(false, (int) $networkinterface_id, (int) $network->getNetworkId(), $_GET['ip']); if ($ip->store()) { echo "success,address_does_not_exists," . $ip->getIp(); } else { echo "error,new_ip_not_stored"; die; } } else { echo "error,network_not_found"; die; } } if ($_GET['section'] == "get_hostname") { $router_data = Router_old::getRouterInfo($_GET['router_id']); echo "success," . $router_data['hostname'] . ","; }
} else { Permission::denyAccess(PERM_ROOT, $networkinterface->getRouter()->getUserId()); } } elseif ($_GET['section'] == 'insert_add') { $networkinterface = new Networkinterface((int) $_GET['interface_id']); $networkinterface->fetch(); if (permission::checkIfUserIsOwnerOrPermitted(PERM_ROOT, $networkinterface->getRouter()->getUserId())) { $ip = new Ip(false, (int) $_GET['interface_id'], (int) $_POST['network_id'], $_POST['ip']); if ($ip->store()) { $message[] = array('Die IP ' . $_POST['ip'] . ' wurde angelegt.', 1); Message::setMessage($message); } else { $message[] = array('Die IP ' . $_POST['ip'] . ' konnte nicht angelegt werden.', 2); Message::setMessage($message); } header('Location: ./router.php?router_id=' . $_GET['router_id']); } else { Permission::denyAccess(PERM_ROOT, $networkinterface->getRouter()->getUserId()); } } elseif ($_GET['section'] == 'delete') { $ip = new Ip((int) $_GET['ip_id']); $ip->fetch(); if (permission::checkIfUserIsOwnerOrPermitted(PERM_ROOT, $ip->getNetworkinterface()->getRouter()->getUserId())) { $ip->delete(); $message[] = array('Die IP ' . $ip->getIp() . '/' . $ip->getNetwork()->getNetmask() . ' wurde gelöscht.', 1); Message::setMessage($message); header('Location: ./router.php?router_id=' . $_GET['router_id']); } else { Permission::denyAccess(PERM_ROOT, $ip->getNetworkinterface()->getRouter()->getUserId()); } }
<?php require_once 'runtime.php'; require_once ROOT_DIR . '/lib/core/Ip.class.php'; require_once ROOT_DIR . '/lib/core/ConfigLine.class.php'; $ip = new Ip((int) $_GET['ip_id']); if ($ip->fetch()) { if ($ip->getNetwork()->getIpv() == 6) { $command = "ping6 -c 4 -I " . ConfigLine::configByName("network_connection_ipv6_interface") . " " . $ip->getIp(); } elseif ($ip->getNetwork()->getIpv() == 4) { $command = "ping -c 4 " . $ip->getIp(); } } else { echo "Could not fetch Info."; } $return = array(); echo "Command: " . $command . "<br><br>"; exec($command, $return); echo "Result:<pre>"; print_r($return); echo "</pre>";
<?php require_once 'runtime.php'; require_once ROOT_DIR . '/lib/core/Ip.class.php'; require_once ROOT_DIR . '/lib/core/ConfigLine.class.php'; $ip = new Ip((int) $_GET['ip_id']); if ($ip->fetch()) { $return = array(); if ($ip->getNetwork()->getIpv() == 6) { $command = "curl -s --max-time 10 -g http://[" . $ip->getIp() . "%25\$(cat /sys/class/net/" . ConfigLine::configByName("network_connection_ipv6_interface") . "/ifindex)]/node.data"; } elseif ($ip->getNetwork()->getIpv() == 4) { $command = "curl -s --max-time 10 -g http://" . $ip->getIp() . "/node.data"; } exec($command, $return); $return_string = ""; foreach ($return as $string) { $return_string .= $string; } $smarty->assign('crawl_data', htmlentities($return_string)); } $smarty->assign('message', Message::getMessage()); $smarty->display("header.tpl.html"); $smarty->display("show_crawl_data.tpl.html"); $smarty->display("footer.tpl.html");