public function delete() { if ($this->getNetworkinterfaceId() != 0) { //delete all assigned ip addresses $iplist = new Iplist($this->getNetworkinterfaceId()); $iplist->delete(); //delete all interface crawl data $networkinterfacestatuslist = new NetworkinterfaceStatusList($this->getNetworkinterfaceId()); $networkinterfacestatuslist->delete(); //delete interface try { $stmt = DB::getInstance()->prepare("DELETE FROM interfaces WHERE id=?"); $stmt->execute(array($this->getNetworkinterfaceId())); return $stmt->rowCount(); } catch (PDOException $e) { echo $e->getMessage(); echo $e->getTraceAsString(); } } return false; }
public function setIplist($itemlist = false) { if ($itemlist instanceof Iplist) { $this->iplist = $itemlist; return true; } elseif (is_array($itemlist)) { $iplist = new Iplist(false, false, 0, 0); foreach ($itemlist as $ip_id) { $ip = new Ip((int) $ip_id); if ($ip->fetch()) { $iplist->add($ip); } } $this->setIplist($iplist); return true; } elseif ($itemlist == false and $this->getServiceId() != 0) { $result = array(); try { $stmt = DB::getInstance()->prepare("SELECT ip_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM service_ips\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE service_id = ?"); $stmt->execute(array($this->getServiceId())); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { echo $e->getMessage(); echo $e->getTraceAsString(); } $iplist = new Iplist(false, false, 0, 0); foreach ($result as $ip_id) { $ip = new Ip((int) $ip_id['ip_id']); if ($ip->fetch()) { $iplist->add($ip); } } $this->setIplist($iplist); return true; } return false; }
private function iplist() { if ($this->get_request_method() == "GET") { $this->_request['interface_id'] = isset($this->_request['interface_id']) ? $this->_request['interface_id'] : false; $this->_request['network_id'] = isset($this->_request['network_id']) ? $this->_request['network_id'] : false; $iplist = new Iplist((int) $this->_request['interface_id'], (int) $this->_request['network_id'], (int) $this->_request['offset'], (int) $this->_request['limit'], $this->_request['sort_by'], $this->_request['order']); $domxmldata = $iplist->getDomXMLElement($this->domxml); $this->response($this->finishxml($domxmldata), 200); } else { $this->error_code = 2; $this->error_message = "The iplist could not be created, your request seems to be malformed."; $this->response($this->finishxml(), 400); } }
<?php require_once 'runtime.php'; require_once ROOT_DIR . '/lib/core/Network.class.php'; require_once ROOT_DIR . '/lib/core/Iplist.class.php'; $network = new Network((int) $_GET['network_id']); $network->fetch(); $smarty->assign('network', $network); $iplist = new Iplist(false, (int) $_GET['network_id']); $smarty->assign('iplist', $iplist->getIplist()); $smarty->display("header.tpl.html"); $smarty->display("iplist.tpl.html"); $smarty->display("footer.tpl.html");
echo "\tnetwork_connection_ipv6_interface: {$network_connection_ipv6_interface}\n"; echo "\tinterfaces_used_for_crawling: "; foreach ($interfaces_used_for_crawling as $iface) { echo $iface; } echo "\n"; echo "\tactual_crawl_cycle: " . $actual_crawl_cycle . "\n"; //fetch all routers that need to be crawled by a crawler. Respect offset and limit! $routerlist = new Routerlist(false, false, "crawler", false, false, false, false, false, (int) $router_offset, (int) $router_limit, "router_id", "asc"); foreach ($routerlist->getRouterlist() as $key => $router) { echo $key + 1 . ". crawling Router " . $router->getHostname() . " (" . $router->getRouterId() . ")\n"; foreach ($interfaces_used_for_crawling as $name) { echo "\tFetching IP-Addresses of interface " . $name . "\n"; $networkinterface = new Networkinterface(false, $router->getRouterId(), $name); if ($networkinterface->fetch()) { $iplist = new Iplist($networkinterface->getNetworkinterfaceId()); foreach ($iplist->getIplist() as $ip) { echo "\t\tWorking with " . $ip->getIp() . "\n"; $xml_array = array(); $ping = false; $return = array(); if ($ip->getNetwork()->getIpv() == 6) { $command = "ping6 -c {$ping_count} -w " . ($ping_count + 1) * $ping_timeout . " -W {$ping_timeout} -I {$network_connection_ipv6_interface} " . $ip->getIp(); } elseif ($ip->getNetwork()->getIpv() == 4) { $command = "ping -c {$ping_count} -w " . ($ping_count + 1) * $ping_timeout . " -W {$ping_timeout} " . $ip->getIp(); } echo "\t\t\t" . $command . "\n"; PsExecute($command, $ping_hard_timeout, 1); //fetch crawl data from router $return = array(); if ($ip->getNetwork()->getIpv() == 6) {