/** * Deletes a user and all of the objects he owns * @author Clemens John <*****@*****.**> */ public function delete() { //Delete routers $routerlist = new Routerlist(false, $this->getUserId()); $routerlist->delete(); //Delete api keys $api_key_list = new ApiKeyList($this->getUserId(), 'user'); $api_key_list->delete(); //Delete user remember mes $user_remember_me_list = new UserRememberMeList($this->getUserId()); $user_remember_me_list->delete(); //delete the user from the database try { $stmt = DB::getInstance()->prepare("DELETE FROM users WHERE id=?"); $stmt->execute(array($this->getUserId())); } catch (PDOException $e) { echo $e->getMessage(); return false; } return true; }
private function routerlist() { if ($this->get_request_method() == "GET") { $this->_request['crawl_cycle_id'] = isset($this->_request['crawl_cycle_id']) ? $this->_request['crawl_cycle_id'] : false; $this->_request['user_id'] = isset($this->_request['user_id']) ? $this->_request['user_id'] : false; $this->_request['crawl_method'] = isset($this->_request['crawl_method']) ? $this->_request['crawl_method'] : false; $this->_request['status'] = isset($this->_request['status']) ? $this->_request['status'] : false; $this->_request['hardware_name'] = isset($this->_request['hardware_name']) ? $this->_request['hardware_name'] : false; $this->_request['firmware_version'] = isset($this->_request['firmware_version']) ? $this->_request['firmware_version'] : false; $this->_request['batman_advanced_version'] = isset($this->_request['batman_advanced_version']) ? $this->_request['batman_advanced_version'] : false; $this->_request['kernel_version'] = isset($this->_request['kernel_version']) ? $this->_request['kernel_version'] : false; $routerlist = new Routerlist((int) $this->_request['crawl_cycle_id'], (int) $this->_request['user_id'], $this->_request['crawl_method'], $this->_request['status'], $this->_request['hardware_name'], $this->_request['firmware_version'], $this->_request['batman_advanced_version'], $this->_request['kernel_version'], (int) $this->_request['offset'], (int) $this->_request['limit'], $this->_request['sort_by'], $this->_request['order']); $domxmldata = $routerlist->getDomXMLElement($this->domxml); $this->response($this->finishxml($domxmldata), 200); } else { $this->error_code = 2; $this->error_message = "The routerlist 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/Routerlist.class.php'; require_once ROOT_DIR . '/lib/core/crawling.class.php'; $smarty->assign('message', Message::getMessage()); $_GET['crawl_method'] = isset($_GET['crawl_method']) ? $_GET['crawl_method'] : false; $_GET['status'] = isset($_GET['status']) ? $_GET['status'] : false; $_GET['hardware_name'] = isset($_GET['hardware_name']) ? $_GET['hardware_name'] : false; $_GET['firmware_version'] = isset($_GET['firmware_version']) ? $_GET['firmware_version'] : false; $_GET['batman_advanced_version'] = isset($_GET['batman_advanced_version']) ? $_GET['batman_advanced_version'] : false; $_GET['kernel_version'] = isset($_GET['kernel_version']) ? $_GET['kernel_version'] : false; $routerlist = new Routerlist(false, false, $_GET['crawl_method'], $_GET['status'], $_GET['hardware_name'], $_GET['firmware_version'], $_GET['batman_advanced_version'], $_GET['kernel_version'], 0, -1); $smarty->assign('routerlist', $routerlist->getRouterlist()); $smarty->display("header.tpl.html"); $smarty->display("routerlist.tpl.html"); $smarty->display("footer.tpl.html");
$interfaces_used_for_crawling = array("br-mesh", "br-client", "floh_fix", "tata_fix"); //use the ip adresses of these interfaces for crawling $actual_crawl_cycle = Crawling::getActualCrawlCycle()['id']; echo "Crawling routers {$router_offset}-{$router_limit} (offset-limit) with the following options:\n"; echo "\tping_count: {$ping_count}\n"; echo "\tping_timeout: {$ping_timeout}\n"; echo "\tcrawl_timeout: {$crawl_timeout}\n"; 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) {
$event_notification = new EventNotification((int) $_GET['event_notification_id']); $event_notification->fetch(); if (permission::checkIfUserIsOwnerOrPermitted(PERM_ROOT, $event_notification->getUserId())) { if ($event_notification->delete()) { $message[] = array('Die Benachrichtigung wurde gelöscht.', 1); } else { $message[] = array('Die Benachrichtigung konnte nicht gelöscht werden.', 2); } Message::setMessage($message); header('Location: ./event_notifications.php'); } else { Permission::denyAccess(PERM_ROOT, $event_notification->getUserId()); } } elseif (empty($_POST)) { if (Permission::checkPermission(PERM_USER)) { $routerlist = new Routerlist(false, false, false, false, false, false, false, false, 0, -1); $routerlist->sort("hostname", "asc"); $smarty->assign('routerlist', $routerlist->getRouterlist()); $event_notification_list = new EventNotificationList($_SESSION['user_id']); $smarty->assign('event_notification_list', $event_notification_list->getEventNotificationList()); $smarty->display("header.tpl.html"); $smarty->display("event_notifications.tpl.html"); $smarty->display("footer.tpl.html"); } else { Permission::denyAccess(PERM_USER); } } else { if (Permission::checkPermission(PERM_USER)) { $event_notification = new EventNotification(false, (int) $_SESSION['user_id'], $_POST['action'], (int) $_POST['object'], true); if ($event_notification->store()) { $message[] = array('Die Benachrichtigung wurde eingetragen.', 1);