<?php require_once 'runtime.php'; if (isset($_GET['embed']) and $_GET['embed']) { if (isset($_GET['key'])) { $smarty->assign('key', $_GET['key']); } else { $smarty->assign('key', false); } if (!isset($_GET['longitude']) or !isset($_GET['latitude']) or !isset($_GET['zoom'])) { $smarty->assign('community_location_longitude', Config::getConfigValueByName('community_location_longitude')); $smarty->assign('community_location_latitude', Config::getConfigValueByName('community_location_latitude')); $smarty->assign('community_location_zoom', Config::getConfigValueByName('community_location_zoom')); } else { $smarty->assign('community_location_longitude', $_GET['longitude']); $smarty->assign('community_location_latitude', $_GET['latitude']); $smarty->assign('community_location_zoom', $_GET['zoom']); } $smarty->assign('google_maps_api_key', $GLOBALS['google_maps_api_key']); $smarty->display("map_embed.tpl.html"); } else { $smarty->assign('community_location_longitude', Config::getConfigValueByName('community_location_longitude')); $smarty->assign('community_location_latitude', Config::getConfigValueByName('community_location_latitude')); $smarty->assign('community_location_zoom', Config::getConfigValueByName('community_location_zoom')); $smarty->assign('google_maps_api_key', $GLOBALS['google_maps_api_key']); $smarty->display("header.tpl.html"); $smarty->display("map.tpl.html"); $smarty->display("footer.tpl.html"); }
public function batman_advanced_conn_nexthop() { header('Content-type: text/xml'); $xw = new xmlWriter(); $xw->openMemory(); $xw->startDocument('1.0', 'UTF-8'); $xw->startElement('kml'); $xw->writeAttribute('xmlns', 'http://earth.google.com/kml/2.1'); $xw->startElement('Document'); $xw->writeElement('name', '200903170407-200903170408'); $xw->startElement('Folder'); $xw->startElement('name'); $xw->writeRaw('create'); $xw->endElement(); $routers = Router_old::getRouters(); $last_endet_crawl_cycle = Crawling::getLastEndedCrawlCycle(); foreach ($routers as $router) { //set own position to the position saved fix in netmon $router_longitude = $router['longitude']; $router_latitude = $router['latitude']; //if the router has an position in it's actual crawl data, then prefer this position $router_crawl = Router_old::getCrawlRouterByCrawlCycleId($last_endet_crawl_cycle['id'], $router['id']); if (!empty($router_crawl['longitude']) and !empty($router_crawl['latitude'])) { $router_longitude = $router_crawl['longitude']; $router_latitude = $router_crawl['latitude']; } //if the own position is not empt, then look for neighbours if (!empty($router_longitude) and !empty($router_latitude)) { //$originators = BatmanAdvanced::getCrawlBatmanAdvOriginatorsByCrawlCycleId($last_endet_crawl_cycle['id'], $router['id']); $originators = BatmanAdvanced::getCrawlBatmanAdvNexthopsByCrawlCycleId($last_endet_crawl_cycle['id'], $router['id']); //$originators = unserialize($originators['originators']); if (!empty($originators)) { foreach ($originators as $originator) { $neighbour_router = Router_old::getRouterByMacAndCrawlCycleId($originator['nexthop'], $last_endet_crawl_cycle['id']); $neighbour_router_longitude = $neighbour_router['longitude']; $neighbour_router_latitude = $neighbour_router['latitude']; $neighbour_router = Router_old::getCrawlRouterByCrawlCycleId($last_endet_crawl_cycle['id'], $neighbour_router['router_id']); if (!empty($neighbour_router['longitude']) and !empty($neighbour_router['latitude'])) { $neighbour_router_longitude = $neighbour_router['longitude']; $neighbour_router_latitude = $neighbour_router['latitude']; } //check if the position is not empty if (!empty($neighbour_router_longitude) and !empty($neighbour_router_longitude) and strlen($originator['nexthop']) == 17) { $xw->startElement('Placemark'); $xw->startElement('Style'); $xw->startElement('LineStyle'); $xw->startElement('color'); if (Config::getConfigValueByName('routervpnif') == $originator['outgoing_interface']) { $xw->writeRaw("20ff0000"); } else { if ($originator['link_quality'] >= 0 and $originator['link_quality'] < 105) { $xw->writeRaw("ff1e1eff"); } elseif ($originator['link_quality'] >= 105 and $originator['link_quality'] < 130) { $xw->writeRaw("ff4949ff"); } elseif ($originator['link_quality'] >= 130 and $originator['link_quality'] < 155) { $xw->writeRaw("ff6a6aff"); } elseif ($originator['link_quality'] >= 155 and $originator['link_quality'] < 180) { $xw->writeRaw("ff53acff"); } elseif ($originator['link_quality'] >= 180 and $originator['link_quality'] < 205) { $xw->writeRaw("ff79ebff"); } elseif ($originator['link_quality'] >= 205 and $originator['link_quality'] < 230) { $xw->writeRaw("ff7cff79"); } elseif ($originator['link_quality'] >= 230) { $xw->writeRaw("ff0aff04"); } } $xw->endElement(); /*$xw->startElement('width'); $xw->writeRaw("5"); $xw->endElement();*/ $xw->endElement(); $xw->endElement(); $xw->startElement('name'); $xw->writeRaw("myname"); $xw->endElement(); $xw->startElement('Polygon'); $xw->startElement('outerBoundaryIs'); $xw->startElement('LinearRing'); $xw->startElement('coordinates'); $xw->writeRaw("{$router['longitude']},{$router['latitude']},0\n\t\t\t\t\t\t\t{$neighbour_router_longitude},{$neighbour_router_latitude},0"); $xw->endElement(); $xw->endElement(); $xw->endElement(); $xw->endElement(); $xw->endElement(); } } } } } $xw->endElement(); $xw->endElement(); $xw->endElement(); $xw->endDocument(); print $xw->outputMemory(true); return true; }
$GLOBALS['mail_smtp_login_auth'] = Config::getConfigValueByName('mail_smtp_login_auth'); $GLOBALS['mail_smtp_ssl'] = Config::getConfigValueByName('mail_smtp_ssl'); //NETWORK $GLOBALS['community_name'] = Config::getConfigValueByName('community_name'); $GLOBALS['community_slogan'] = Config::getConfigValueByName('community_slogan'); //PROJEKT $GLOBALS['hours_to_keep_mysql_crawl_data'] = Config::getConfigValueByName('hours_to_keep_mysql_crawl_data'); $GLOBALS['hours_to_keep_history_table'] = Config::getConfigValueByName('hours_to_keep_history_table'); //GOOGLEMAPSAPIKEY $GLOBALS['google_maps_api_key'] = Config::getConfigValueByName('google_maps_api_key'); //CRAWLER $GLOBALS['crawl_cycle'] = Config::getConfigValueByName('crawl_cycle_length_in_minutes'); //TEMPLATE $GLOBALS['template'] = Config::getConfigValueByName('template'); //WEBSERVER $GLOBALS['url_to_netmon'] = Config::getConfigValueByName('url_to_netmon'); } //load smarty template engine require_once ROOT_DIR . '/lib/extern/smarty/Smarty.class.php'; $smarty = new Smarty(); $smarty->compile_check = true; $smarty->debugging = false; // base template directory // this is used as a fallback if nothing is found in the custom template folder // lookup ordered by param2 $smarty->addTemplateDir(ROOT_DIR . '/templates/base/html', 10); // custom template folder - smarty will try here first ( order 0 ) $smarty->addTemplateDir(ROOT_DIR . '/templates/' . $GLOBALS['template'] . '/html', 0); $smarty->compile_dir = ROOT_DIR . '/templates_c'; $smarty->assign('template', $GLOBALS['template']); $smarty->assign('installed', $GLOBALS['installed']);
require_once ROOT_DIR . '/lib/core/Networkinterfacelist.class.php'; require_once ROOT_DIR . '/lib/core/OriginatorStatusList.class.php'; require_once ROOT_DIR . '/lib/core/Chipsetlist.class.php'; require_once ROOT_DIR . '/lib/core/ConfigLine.class.php'; require_once ROOT_DIR . '/lib/core/Eventlist.class.php'; require_once ROOT_DIR . '/lib/core/crawling.class.php'; if (isset($_GET['router_id']) and isset($_GET['embed']) and $_GET['embed']) { $smarty->assign('community_essid', Config::getConfigValueByName('community_essid')); $smarty->assign('google_maps_api_key', Config::getConfigValueByName('google_maps_api_key')); $router = new Router((int) $_GET['router_id']); $router->fetch(); $smarty->assign('router', $router); $smarty->display("router_embed.tpl.html"); } elseif (!isset($_GET['section']) and isset($_GET['router_id'])) { $smarty->assign('message', Message::getMessage()); $smarty->assign('google_maps_api_key', Config::getConfigValueByName('google_maps_api_key')); $router = new Router((int) $_GET['router_id']); $router->fetch(); $smarty->assign('router', $router); $networkinterfacelist = new Networkinterfacelist(false, $router->getRouterId(), 0, -1, 'name', 'asc'); $smarty->assign('networkinterfacelist', $networkinterfacelist); $originator_status_list = new OriginatorStatusList($router->getRouterId(), $router->getStatusdata()->getCrawlCycleId(), 0, -1); $smarty->assign('originator_status_list', $originator_status_list); $eventlist = new Eventlist(); $eventlist->init('router', $router->getRouterId(), false, 0, 10, 'event_id', 'desc'); $smarty->assign('eventlist', $eventlist); $smarty->display("header.tpl.html"); $smarty->display("router.tpl.html"); $smarty->display("footer.tpl.html"); } elseif (isset($_GET['section']) and $_GET['section'] == 'add') { //Logged in users can add a new router
public function insertNewRouter() { $check_router_hostname_exist = Router_old::getRouterByHostname($_POST['hostname']); if (!isset($_POST['allow_router_auto_assign'])) { $_POST['allow_router_auto_assign'] = 0; $_POST['router_auto_assign_login_string'] = ''; } if ($_POST['allow_router_auto_assign'] == '1' and !empty($_POST['router_auto_assign_login_string'])) { $check_router_auto_assign_login_string = Router_old::getRouterByAutoAssignLoginString($_POST['router_auto_assign_login_string']); } if (empty($_POST['hostname'])) { $message[] = array("Bitte geben Sie einen Hostname an.", 2); Message::setMessage($message); return array("result" => false, "router_id" => $router_id); } elseif (!empty($check_router_hostname_exist)) { $message[] = array("Ein Router mit dem Hostnamen {$_POST['hostname']} existiert bereits, bitte wählen Sie einen anderen Hostnamen.", 2); Message::setMessage($message); return array("result" => false, "router_id" => $router_id); } elseif (!(is_string($_POST['hostname']) and strlen($_POST['hostname']) <= 255 and preg_match("/^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])(\\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9]))*\$/", $_POST['hostname']))) { //check for valid hostname as specified in rfc 1123 //see http://stackoverflow.com/a/3824105 $message[] = array("Der Hostname ist ungültig. Erlaubt sind Hostnames nach RFC 1123.", 2); Message::setMessage($message); return array("result" => false, "router_id" => $router_id); } elseif (!empty($check_router_auto_assign_login_string)) { $message[] = array("Der Router Auto Assign Login String wird bereits verwendet.", 2); Message::setMessage($message); return array("result" => false, "router_id" => $router_id); } elseif ($_POST['allow_router_auto_assign'] == '1' and ($_POST['router_auto_assign_login_string'] == "Mac-Adresse..." or empty($_POST['router_auto_assign_login_string']) or ctype_space($_POST['router_auto_assign_login_string']))) { $message[] = array("Wenn Automatische Routerzuweisung aktiviert ist, muss eine Mac-Adresse gesetzt werden.", 2); $message[] = array("Du findest die Mac-Adresse oft auf der Rückseite des Routers.", 0); Message::setMessage($message); return array("result" => false, "router_id" => $router_id); } else { if (!is_numeric($_POST['latitude']) or !is_numeric($_POST['longitude'])) { $_POST['latitude'] = 0; $_POST['longitude'] = 0; } try { $stmt = DB::getInstance()->prepare("INSERT INTO routers (user_id, create_date, update_date, crawl_method, hostname, allow_router_auto_assign, router_auto_assign_login_string, description, location, latitude, longitude, chipset_id)\n\t\t\t\t\t\t\t\t VALUES (?, NOW(), NOW(), ?, ?, ?, ?, ?, ?, ?, ?, ?)"); $stmt->execute(array($_SESSION['user_id'], $_POST['crawl_method'], $_POST['hostname'], $_POST['allow_router_auto_assign'], $_POST['router_auto_assign_login_string'], $_POST['description'], $_POST['location'], $_POST['latitude'], $_POST['longitude'], $_POST['chipset_id'])); $router_id = DB::getInstance()->lastInsertId(); } catch (PDOException $e) { echo $e->getMessage(); echo $e->getTraceAsString(); } $crawl_cycle_id = Crawling::getLastEndedCrawlCycle(); $router_status = new RouterStatus(false, (int) $crawl_cycle_id['id'], (int) $router_id, "offline"); $router_status->store(); //add new api key do { $api_key = new ApiKey(false, ApiKey::generateApiKey(), (int) $router_id, "router", "Initial key"); $api_key_id = $api_key->store(); } while (!$api_key_id); if ($_POST['allow_router_auto_assign'] == '1' and !empty($_POST['router_auto_assign_login_string'])) { RoutersNotAssigned::deleteByAutoAssignLoginString($_POST['router_auto_assign_login_string']); } $message[] = array("Der Router {$_POST['hostname']} wurde angelegt.", 1); //Add event for new router //TODO: add Router Object to data array $event = new Event(false, 'router', (int) $router_id, 'new', array()); $event->store(); //Send Message to twitter if ($_POST['twitter_notification'] == '1') { Message::postTwitterMessage(Config::getConfigValueByName('community_name') . " hat einen neuen #Freifunk Knoten! Wo? Schau nach: " . Config::getConfigValueByName('url_to_netmon') . "/router.php?router_id={$router_id}"); } Message::setMessage($message); return array("result" => true, "router_id" => $router_id); } }
if (!empty($_GET) && isset($_SESSION['TWITTER_REQUEST_TOKEN'])) { $token = $consumer->getAccessToken($_GET, unserialize($_SESSION['TWITTER_REQUEST_TOKEN'])); $_SESSION['TWITTER_ACCESS_TOKEN'] = serialize($token); // Now that we have an Access Token, we can discard the Request Token $_SESSION['TWITTER_REQUEST_TOKEN'] = null; } else { // Mistaken request? Some malfeasant trying something? exit('Invalid callback request. Oops. Sorry.'); } Config::writeConfigLine('twitter_username', $token->getParam('screen_name')); Config::writeConfigLine('twitter_token', $_SESSION['TWITTER_ACCESS_TOKEN']); $message[] = array('Netmon wurde an den Twitteraccount <a href="https://twitter.com/' . $token->getParam('screen_name') . '">' . $token->getParam('screen_name') . '</a> angebunden.', 1); Message::setMessage($message); header('Location: ./config.php?section=edit_twitter'); } elseif ($_GET['section'] == "get_twitter_token") { $config = array('callbackUrl' => Config::getConfigValueByName('url_to_netmon') . '/config.php?section=recieve_twitter_token', 'siteUrl' => 'https://api.twitter.com/oauth', 'consumerKey' => ConfigLine::configByName('twitter_consumer_key'), 'consumerSecret' => ConfigLine::configByName('twitter_consumer_secret')); $consumer = new Zend_Oauth_Consumer($config); // fetch a request token $token = $consumer->getRequestToken(); // persist the token to storage $_SESSION['TWITTER_REQUEST_TOKEN'] = serialize($token); // redirect the user $consumer->redirect(); } elseif ($_GET['section'] == "edit_hardware") { $chipsetlist = new Chipsetlist(); $smarty->assign('chipsetlist', $chipsetlist->getList()); $smarty->assign('message', Message::getMessage()); $smarty->display("header.tpl.html"); $smarty->display("config_hardware.tpl.html"); $smarty->display("footer.tpl.html"); } elseif ($_GET['section'] == "add_hardware") {