diff options
author | Othmar Gsenger <otti@ffgraz.net> | 2013-11-12 18:24:00 +0000 |
---|---|---|
committer | Othmar Gsenger <otti@ffgraz.net> | 2013-11-12 18:24:00 +0000 |
commit | a47c4eecff79c1d57650b46c437b628d873705b2 (patch) | |
tree | 9d53fe963419ce8965fe237be47784c1afd84510 | |
parent | f6be9edd401664d95e60ae3c81aeaf36723ba891 (diff) |
bisher uncommitete aenderungen am www.ffgraz.net (nicht von mir)
-rw-r--r-- | config.php | 5 | ||||
-rw-r--r-- | data.php | 534 | ||||
-rw-r--r-- | db.class.php | 94 | ||||
-rw-r--r-- | index.php | 282 | ||||
-rw-r--r-- | map.css | 20 | ||||
-rw-r--r-- | map.js | 264 |
6 files changed, 870 insertions, 329 deletions
@@ -6,15 +6,16 @@ $conf['db']['host'] = 'localhost'; $conf['db']['database'] = 'mappe'; $conf['topo']['file'] = 'topology.dot.plain'; +$conf['router']['file'] = 'InfoRouter.plain'; /* neue eintraege bitte kommentieren !!!! */ $conf['acl']['range'] = array( "10.0.0.0/8", // Funkfeuer Graz Private - "83.64.208.18/32", // Funkfeuer Graz Nat + "217.29.149.64/28", // 0xFF Citycom IP Bereich "193.33.150.0/23", // Funkfeuer Graz Public "193.238.156.0/22", // Funkfeuer Wien "89.106.208.0/21", // mur.at -// "84.119.56.63/32", // equinox home test +// "84.119.56.63/32", // equinox home test "212.17.113.195/32" // roland home wien ); @@ -1,145 +1,389 @@ -<?php
-session_start();
-
-require_once("db.class.php");
-require_once("ipmatch.php");
-require_once("config.php");
-
-header("Content-Type: text/xml");
-header("Cache-Control: no-cache, must-revalidate");
-header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
-
-$db = new DB($conf['db']['user'], $conf['db']['password'], $conf['db']['host'], $conf['db']['database']);
-$conf['acl']['auth'] = match_network($conf['acl']['range'],$_SERVER[REMOTE_ADDR]);
-
-if(!$conf['acl']['auth'] )
-{
- if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'])
- $conf['acl']['auth'] = true;
-}
-
-$x_startpoint = 4080;
-$lng_startpoint = 15.43844103813;
-$dx_dLng = 50675.5176;
-$y_startpoint = 4806;
-$lat_startpoint= 47.07177327969;
-$dy_dLat = 75505.521;
-
-$locations = array();
-$locids = array();
-$nodename = array();
-$links = array();
-$already = array();
-$count = array();
-
-$db->query("SELECT ip, location.id as locid,location.name as locname, node.name as nodename FROM ip, node, location WHERE ip.node_id = node.id and node.location_id=location.id");
-while ($data = $db->getNextObject()) {
- $locids[$data->ip]= $data->locid;
- $nodename[$data->ip]= $data->nodename;
-}
-
-if($conf['acl']['auth'])
- $db->query("SELECT id as locid, name as locname, pixel_x, pixel_y, gallery_link, location.hastinc as hastinc FROM location ORDER BY name ASC");
-else
- $db->query("SELECT id as locid, name as locname, pixel_x, pixel_y, gallery_link, location.hastinc as hastinc FROM location WHERE location.hidden = 0 ORDER BY name ASC");
-
-while ($data = $db->getNextObject()) {
- if ($data->pixel_x == "0")
- continue;
-
- $data->lng = $lng_startpoint + ($data->pixel_x - $x_startpoint) / $dx_dLng;
- $data->lat = $lat_startpoint + ($y_startpoint - $data->pixel_y) / $dy_dLat;
- $data->state = "offline";
- $locations[$data->locid] = $data;
-}
-
-$regmatch = '#\"(.+)\" -> \"(.+)\"\[label=\"([0-9]+.[0-9]+)\"]#';
-$lines = file($conf['topo']['file']);
-
-$linecnt=0;
-$i =0;
-foreach ($lines as $num => $line)
-{
- $linecnt++;
- preg_match($regmatch,$line,$matches);
- list( , $ipfromLoc, $iptoLoc, $label) = $matches;
-
- if (empty($ipfromLoc) || empty($iptoLoc) || empty($label))
- continue;
-
- if(empty($locations[$locids[$ipfromLoc]]->locid) || empty($locations[$locids[$iptoLoc]]->locid))
- continue;
-
- if($locations[$locids[$ipfromLoc]]->locid == $locations[$locids[$iptoLoc]]->locid)
- continue;
-
- if($already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid]->used == true) {
- $jot = $already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid]->i;
- if($links[$jot]->label != -1)
- $links[$jot]->label = ($links[$jot]->label + $label)/2;
- }
- elseif($already[$locations[$locids[$iptoLoc]]->locid . '-' . $locations[$locids[$ipfromLoc]]->locid]->used == true) {
- $jot = $already[$locations[$locids[$iptoLoc]]->locid . '-' . $locations[$locids[$ipfromLoc]]->locid]->i;
- if($links[$jot]->label != -1)
- $links[$jot]->label = ($links[$jot]->label + $label)/2;
- }
- else {
- $already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid]->used = true;
- $already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid]->i = $i;
-
- $links[$i]->ipfromLoc = $ipfromLoc;
- $links[$i]->iptoLoc = $iptoLoc;
- if($links[$i]->label != -1)
- $links[$i]->label = $label;
- if($locations[$locids[$ipfromLoc]]->state == "offline")
- $locations[$locids[$ipfromLoc]]->state = "online";
- if($locations[$locids[$iptoLoc]]->state == "offline")
- $locations[$locids[$iptoLoc]]->state = "online";
-
- if (($nodename[$ipfromLoc] == "tunnel" && $locations[$locids[$ipfromLoc]]->locname=="housing") ||
- ($nodename[$iptoLoc] == "tunnel" && $locations[$locids[$iptoLoc]]->locname=="housing" ) ||
- ($locations[$locids[$iptoLoc]]->hastinc && $locations[$locids[$ipfromLoc]]->hastinc)) {
- $links[$i]->label = -1;
- $locations[$locids[$ipfromLoc]]->state = "tunnel";
- $locations[$locids[$iptoLoc]]->state = "tunnel";
- }
-
- $i++;
- }
-}
-
-
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
-echo "<root>\n";
-
-echo "<nodes>\n";
-foreach ($locations as $location) {
- $data = $locations[$location->locid];
- printf("\t" . '<node id="%s" name="%s" lat="%s" lng="%s" pixel_x="%s" pixel_y="%s" state="%s" gallery_link="%s"/>' . "\n",
- $data->locid, $data->locname, $data->lat, $data->lng, $data->pixel_x, $data->pixel_y, $data->state, $data->gallery_link);
-}
-echo "</nodes>\n";
-
-echo "<links>\n";
-foreach ($links as $link)
-{
- $data1 = $locations[$locids[$link->ipfromLoc]];
- $data2 = $locations[$locids[$link->iptoLoc]];
-
- $count[$data1->locid]=true;
- $count[$data2->locid]=true;
-
- printf("\t" . '<link fromid="%s" from="%s" latfrom="%s" lngfrom="%s" toid="%s" to="%s" latto="%s" lngto="%s" value="%s" />' . "\n",
- $data1->locid, $data1->locname, $data1->lat,$data1->lng,$data2->locid, $data2->locname, $data2->lat, $data2->lng, $link->label);
-}
-echo "</links>\n";
-
-echo "<counts>\n";
-printf("\t" . '<count number="');
-echo sizeof($count);
-printf('" />' . "\n");
-echo "</counts>\n";
-
-echo "</root>";
-
-?>
+<?php +session_start(); +error_reporting(0); +require_once("db.class.php"); +require_once("ipmatch.php"); +require_once("config.php"); + +header("Content-Type: text/xml"); +header("Cache-Control: no-cache, must-revalidate"); +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +$db = new DB($conf['db']['user'], $conf['db']['password'], $conf['db']['host'], $conf['db']['database']); +$conf['acl']['auth'] = match_network($conf['acl']['range'],$_SERVER["REMOTE_ADDR"]); + +$handle = fopen ($conf['router']['file'],"r"); +while ( ($data = fgetcsv ($handle, 1000, ",")) !== FALSE ) { // Daten werden aus der Datei + $routerhash[$data[0]]=$data; +} +fclose ($handle); + +if(!$conf['acl']['auth'] ) +{ + if (isset($_SESSION['logged_in']) && $_SESSION['logged_in']) + $conf['acl']['auth'] = true; +} + +//zum Test +//$conf['acl']['auth'] = true; + +$x_startpoint = 4080; +$lng_startpoint = 15.43844103813; +$dx_dLng = 50675.5176; +$y_startpoint = 4806; +$lat_startpoint= 47.07177327969; +$dy_dLat = 75505.521; + +$locations = array(); +$locids = array(); +$nodename = array(); +$locname = array(); +$ipname = array(); +$dnsnames = array(); +$ip = array(); +$nodelocnames = array(); +$ipnodelocnames = array(); +$links = array(); +$already = array(); +$count = array(); + +$db->query("SELECT ip, ip.name as ipname,location.id as locid,location.name as locname, node.name as nodename FROM ip, node, location WHERE ip.node_id = node.id and node.location_id=location.id"); +while ($data = $db->getNextObject()) { + $locids[$data->ip]= $data->locid; + $nodename[$data->ip]= $data->nodename; + $locname[$data->ip]= $data->locname; + $ipname[$data->ip]= $data->ipname; + $dnsname = $data->ipname.'.'.$data->nodename.'.'.$data->locname; + $dnsnames[$data->locid][]=$dnsname; + $ip[$dnsname]=$data->ip; + $nodelocname = $data->nodename.'.'.$data->locname; + $nodelocnames[$data->locid][]=$nodelocname; + $ipnodelocnames[$nodelocname][]=$data->ipname; +} +if($conf['acl']['auth']) + $db->query("SELECT id as locid, name as locname, pixel_x, pixel_y, gallery_link, location.hastinc as hastinc FROM location ORDER BY name ASC"); +else + $db->query("SELECT id as locid, name as locname, pixel_x, pixel_y, gallery_link, location.hastinc as hastinc FROM location WHERE location.hidden = 0 ORDER BY name ASC"); + +while ($data = $db->getNextObject()) { + if ($data->pixel_x == "0") + continue; + + $data->lng = $lng_startpoint + ($data->pixel_x - $x_startpoint) / $dx_dLng; + $data->lat = $lat_startpoint + ($y_startpoint - $data->pixel_y) / $dy_dLat; + $data->state = "offline"; + if($conf['acl']['auth']){ + foreach($nodelocnames[$data->locid] as $nodelocname){ + while(strpos($data->dnsnames,$nodelocname)===false){ + foreach($ipnodelocnames[$nodelocname] as $ipnodelocname){ +// echo $nodelocname; +// echo "\n"; +// print_r($ipnodelocnames[$nodelocname]); +// echo "\n"; +// echo $ipnodelocname; +// echo "\n"; + $channel=""; + $frequence=""; + $dnsname=$ipnodelocname.".".$nodelocname; + if($routerhash[$ip[$dnsname]][4]!=""){ + $channel= $routerhash[$ip[$dnsname]][4]; + } + if ($routerhash[$ip[$dnsname]][5]!=""){ + $frequence = $routerhash[$ip[$dnsname]][5]; + } + if ($channel!="" or $frequence!=""){ + $data->dnsnames = $dnsname." (Kanal: ".$channel." / ".$frequence." GHz);".$data->dnsnames; + break 2; + } + } + $data->dnsnames = $dnsname.";".$data->dnsnames; + } + } +/* foreach($dnsnames[$data->locid] as $dnsname){ + if(strpos($data->dnsnames,substr($dnsname,strpos($dnsname,".")))===false){ + $channel=""; + $frequence=""; + if($routerhash[$ip[$dnsname]][4]!=""){ + $channel= $routerhash[$ip[$dnsname]][4]; + } + if ($routerhash[$ip[$dnsname]][5]!=""){ + $frequence = $routerhash[$ip[$dnsname]][5]; + } + if ($channel!="" or $frequence!=""){ + $data->dnsnames = $dnsname." (Kanal: ".$channel." / ".$frequence."GHz);".$data->dnsnames; + break; + } else { + $data->dnsnames = $dnsname.";".$data->dnsnames; + } + } + } +*/ + } + $locations[$data->locid] = $data; +} + +$regmatch = '#\"(.+)\" -> \"(.+)\"\[label=\"([0-9]+.[0-9]+)\"]#'; +$lines = file($conf['topo']['file']); + +$linecnt=0; +$i =0; +foreach ($lines as $num => $line) +{ + + $linecnt++; + if(preg_match($regmatch,$line,$matches)==0) + continue; + + list( , $ipfromLoc, $iptoLoc, $label) = $matches; + + if (empty($ipfromLoc) || empty($iptoLoc) || empty($label)) + continue; + + if (empty($locids[$ipfromLoc]) || empty($locids[$iptoLoc])) + continue; + + if(empty($locations[$locids[$ipfromLoc]]->locid) || empty($locations[$locids[$iptoLoc]]->locid)) + continue; + + if($locations[$locids[$ipfromLoc]]->locid == $locations[$locids[$iptoLoc]]->locid) + continue; +// echo $locations[$locids[$ipfromLoc]]->locid; +// echo "-"; +// echo "$ipfromLoc\n"; +// echo $locations[$locids[$iptoLoc]]->locid; +// echo "\n\n"; +// echo "$iptoLoc\n"; + + + + if(isset($already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid])&& + ($already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid]->used == true)) { + $jot = $already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid]->i; + if($links[$jot]->label != -1){ + if (($links[$jot]->$ipfromLoc==$iptoLoc) || ($links[$jot]->$iptoLoc==$ipfromLoc)){ + $links[$jot]->label = ($links[$jot]->label + $label)/2; + } else if ($links[$jot]->label > $label){ + $links[$jot]->label = $label; + } + } + if (array_key_exists($ipfromLoc,$routerhash)){ + if ($routerhash[$ipfromLoc][4]!==""){ + $links[$jot]->channel = $routerhash[$ipfromLoc][4]; + + } + if ($routerhash[$ipfromLoc][5]!==""){ + $links[$jot]->frequence = $routerhash[$ipfromLoc][5]; + } + + } else if (array_key_exists($iptoLoc,$routerhash)){ + if ($routerhash[$iptoLoc][4]!==""){ + $links[$jot]->channel = $routerhash[$iptoLoc][4]; + } + if ($routerhash[$iptoLoc][5]!==""){ + $links[$jot]->frequence = $routerhash[$iptoLoc][5]; + } + } else{ + $links[$jot]->channel ="undef"; + $links[$jot]->frequence ="undef"; + // echo "keine IP\n"; + } + if (array_key_exists($ipfromLoc,$routerhash)){ + if($conf['acl']['auth']){ + if (strpos($links[$jot]->dnsfrom ,$routerhash[$ipfromLoc][1])===false){ + + $links[$jot]->dnsfrom =($routerhash[$ipfromLoc][1].' (Kanal: '.$links[$jot]->channel.' / '.$links[$jot]->frequence.' GHz)'.';'.($links[$jot]->dnsfrom)); + } + + } + if ($routerhash[$ipfromLoc][3]==$iptoLoc){ + $links[$jot]->defaultroute = "1"; + } + } + if (array_key_exists($iptoLoc,$routerhash)){ + if($conf['acl']['auth']){ + if (strpos($links[$jot]->dnsto ,$routerhash[$iptoLoc][1])===false){ +// echo "B\n"; + $links[$jot]->dnsto =($routerhash[$iptoLoc][1].' (Kanal: '.$links[$jot]->channel.' / '.$links[$jot]->frequence.' GHz)'.';'.($links[$jot]->dnsto)); + } + } + if ($routerhash[$iptoLoc][3]==$ipfromLoc){ + $links[$jot]->defaultroute = "1"; + } + } + + } + elseif(isset($already[$locations[$locids[$iptoLoc]]->locid . '-' . $locations[$locids[$ipfromLoc]]->locid])&& + ($already[$locations[$locids[$iptoLoc]]->locid . '-' . $locations[$locids[$ipfromLoc]]->locid]->used == true)) { + $jot = $already[$locations[$locids[$iptoLoc]]->locid . '-' . $locations[$locids[$ipfromLoc]]->locid]->i; + if($links[$jot]->label != -1){ + if (($links[$jot]->$ipfromLoc==$iptoLoc) || ($links[$jot]->$iptoLoc==$ipfromLoc)){ + $links[$jot]->label = ($links[$jot]->label + $label)/2; + } else if ($links[$jot]->label > $label){ + $links[$jot]->label = $label; + } + } + if (array_key_exists($ipfromLoc,$routerhash)){ + if ($routerhash[$ipfromLoc][4]!==""){ + $links[$jot]->channel = $routerhash[$ipfromLoc][4]; + + } + if ($routerhash[$ipfromLoc][5]!==""){ + $links[$jot]->frequence = $routerhash[$ipfromLoc][5]; + } + + } else if (array_key_exists($iptoLoc,$routerhash)){ + if ($routerhash[$iptoLoc][4]!==""){ + $links[$jot]->channel = $routerhash[$iptoLoc][4]; + } + if ($routerhash[$iptoLoc][5]!==""){ + $links[$jot]->frequence = $routerhash[$iptoLoc][5]; + } + } else{ + $links[$jot]->channel ="undef"; + $links[$jot]->frequence ="undef"; + // echo "keine IP\n"; + } + if (array_key_exists($ipfromLoc,$routerhash)){ + if($conf['acl']['auth']){ + if (strpos($links[$jot]->dnsto,$routerhash[$ipfromLoc][1])===false){ +// echo "C\n"; + $links[$jot]->dnsto =($routerhash[$ipfromLoc][1].' (Kanal: '.$links[$jot]->channel.' / '.$links[$jot]->frequence.' GHz)'.';'.($links[$jot]->dnsto)); + } + } + if ($routerhash[$ipfromLoc][3]==$iptoLoc){ + $links[$jot]->defaultroute = "1"; + } + } + if (array_key_exists($iptoLoc,$routerhash)){ + if($conf['acl']['auth']){ + if (strpos($links[$jot]->dnsfrom,$routerhash[$iptoLoc][1])===false){ +// echo "D\n"; + $links[$jot]->dnsfrom =($routerhash[$iptoLoc][1].' (Kanal: '.$links[$jot]->channel.' / '.$links[$jot]->frequence.' GHz)'.';'.($links[$jot]->dnsfrom)); + } + } + if ($routerhash[$iptoLoc][3]==$ipfromLoc){ + $links[$jot]->defaultroute = "1"; + } + } + + } + else { +// if(isset($already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid])) { + $already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid]->used = true; + $already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid]->i = $i; +// + $links[$i]->ipfromLoc = $ipfromLoc; + $links[$i]->iptoLoc = $iptoLoc; + + if (array_key_exists($ipfromLoc,$routerhash)){ + if ($routerhash[$ipfromLoc][4]!==""){ + $links[$i]->channel = $routerhash[$ipfromLoc][4]; + + } + if ($routerhash[$ipfromLoc][5]!==""){ + $links[$i]->frequence = $routerhash[$ipfromLoc][5]; + } + + } else if (array_key_exists($iptoLoc,$routerhash)){ + if ($routerhash[$iptoLoc][4]!==""){ + $links[$i]->channel = $routerhash[$iptoLoc][4]; + } + if ($routerhash[$iptoLoc][5]!==""){ + $links[$i]->frequence = $routerhash[$iptoLoc][5]; + } + } else{ + $links[$i]->channel ="undef"; + $links[$i]->frequence ="undef"; + // echo "keine IP\n"; + } + $links[$i]->defaultroute = "0"; + + if($conf['acl']['auth']){ + $links[$i]->dnsfrom =$ipname[$ipfromLoc].'.'.$nodename[$ipfromLoc].'.'.$locname[$ipfromLoc].' (Kanal: '.$links[$i]->channel.' / '.$links[$i]->frequence.' GHz )'; + $links[$i]->dnsto =$ipname[$iptoLoc].'.'.$nodename[$iptoLoc].'.'.$locname[$iptoLoc].' (Kanal: '.$links[$i]->channel.' / '.$links[$i]->frequence.' GHz)'; + } + + if (array_key_exists($ipfromLoc,$routerhash)){ + + if($conf['acl']['auth']){ + $links[$i]->dnsfrom =$routerhash[$ipfromLoc][1].' (Kanal: '.$links[$i]->channel.' / '.$links[$i]->frequence.' GHz)'; + } + if ($routerhash[$ipfromLoc][3]==$iptoLoc){ + $links[$i]->defaultroute = "1"; + } + } + if (array_key_exists($iptoLoc,$routerhash)){ + if($conf['acl']['auth']){ + $links[$i]->dnsto =$routerhash[$iptoLoc][1].' (Kanal: '.$links[$i]->channel.' / '.$links[$i]->frequence.' GHz)'; + } + + if ($routerhash[$iptoLoc][3]==$ipfromLoc){ + $links[$i]->defaultroute = "1"; + } + } + + + + if($links[$i]->label != -1){ + $links[$i]->label = $label; + if($locations[$locids[$ipfromLoc]]->state == "offline") + $locations[$locids[$ipfromLoc]]->state = "online"; + if($locations[$locids[$iptoLoc]]->state == "offline") + $locations[$locids[$iptoLoc]]->state = "online"; + } + if (($nodename[$ipfromLoc] == "tunnel" && $locations[$locids[$ipfromLoc]]->locname=="housing") || + ($nodename[$iptoLoc] == "tunnel" && $locations[$locids[$iptoLoc]]->locname=="housing" ) || + ($locations[$locids[$iptoLoc]]->hastinc && $locations[$locids[$ipfromLoc]]->hastinc)) { + $links[$i]->label = -1; + + $links[$i]->defaultroute ="1"; + $locations[$locids[$ipfromLoc]]->state = "tunnel"; + $locations[$locids[$iptoLoc]]->state = "tunnel"; + } + if (($nodename[$ipfromLoc] == "tunnel" && $locations[$locids[$ipfromLoc]]->locname=="housing") || + ($nodename[$iptoLoc] == "tunnel" && $locations[$locids[$iptoLoc]]->locname=="housing" )){ + $links[$i]->frequence ="LAN"; + $links[$i]->channel ="undef"; + } + + $i++; + } +} + + +echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; +echo "<root>\n"; + +echo "<nodes>\n"; +foreach ($locations as $location) { + $data = $locations[$location->locid]; + printf("\t" . '<node id="%s" name="%s" lat="%s" lng="%s" pixel_x="%s" pixel_y="%s" state="%s" gallery_link="%s" router_links="%s"/>' . "\n", + $data->locid, $data->locname, $data->lat, $data->lng, $data->pixel_x, $data->pixel_y, $data->state, $data->gallery_link, $data->dnsnames); +} +echo "</nodes>\n"; + +echo "<links>\n"; + +foreach ($links as $link) + + +{ + $data1 = $locations[$locids[$link->ipfromLoc]]; + $data2 = $locations[$locids[$link->iptoLoc]]; + + $count[$data1->locid]=true; + $count[$data2->locid]=true; + + printf("\t" . '<link fromid="%s" from="%s" latfrom="%s" lngfrom="%s" toid="%s" to="%s" latto="%s" lngto="%s" value="%s" channel="%s" defaultroute="%s" frequence="%s" dnsfrom="%s" dnsto="%s"/>' . "\n", + $data1->locid, $data1->locname, $data1->lat,$data1->lng,$data2->locid, $data2->locname, $data2->lat, $data2->lng, $link->label, $link->channel, $link->defaultroute, $link->frequence, $link->dnsfrom,$link->dnsto); +} +echo "</links>\n"; + +echo "<counts>\n"; +printf("\t" . '<count number="'); +echo sizeof($count); +printf('" />' . "\n"); +echo "</counts>\n"; + +echo "</root>"; + +?> diff --git a/db.class.php b/db.class.php index 28dba49..0921bc8 100644 --- a/db.class.php +++ b/db.class.php @@ -1,47 +1,47 @@ -<?php
-class DB {
-var $user, $pass, $host, $dbname;
-var $db;
-var $res;
-
-function DB($user, $pass, $host, $dbname) {
- $this->user = $user;
- $this->pass = $pass;
- $this->host = $host;
- $this->dbname = $dbname;
- $this->connect();
-}
-
-function connect() {
- $this->db = mysql_connect($this->host, $this->user, $this->pass)
- or $this->error("Verbindungsaufbau fehlgeschlagen");
- mysql_select_db($this->dbname);
-}
-
-function error($msg) {
- die($msg . ": " . @mysql_error());
-}
-
-function query($query) {
- $this->res = mysql_query($query, $this->db)
- or $this->error("Fehler bei Datenbankanfrage");
-}
-
-function escape_string($string) {
- return mysql_real_escape_string($string, $this->db);
-}
-
-function numObjects() {
- return mysql_num_rows($this->res);
-}
-
-function getNextObject() {
- if (!$this->res) {
- return;
- }
- return mysql_fetch_object($this->res);
- }
-}
-
-
-?>
+<?php +class DB { +var $user, $pass, $host, $dbname; +var $db; +var $res; + +function DB($user, $pass, $host, $dbname) { + $this->user = $user; + $this->pass = $pass; + $this->host = $host; + $this->dbname = $dbname; + $this->connect(); +} + +function connect() { + $this->db = mysql_connect($this->host, $this->user, $this->pass) + or $this->error("Verbindungsaufbau fehlgeschlagen"); + mysql_select_db($this->dbname); +} + +function error($msg) { + die($msg . ": " . @mysql_error()); +} + +function query($query) { + $this->res = mysql_query($query, $this->db) + or $this->error("Fehler bei Datenbankanfrage"); +} + +function escape_string($string) { + return mysql_real_escape_string($string, $this->db); +} + +function numObjects() { + return mysql_num_rows($this->res); +} + +function getNextObject() { + if (!$this->res) { + return; + } + return mysql_fetch_object($this->res); + } +} + + +?> @@ -1,110 +1,172 @@ -<?php
-session_start();
-
-if(isset($_REQUEST['lat'])) $lat = mysql_escape_string($_REQUEST['lat']);
-if(isset($_REQUEST['lng'])) $lng = mysql_escape_string($_REQUEST['lng']);
-if(isset($_REQUEST['res'])) $res = $_REQUEST['res'];
-
-//default values
-if(empty($lat)) $lat=47.07102;
-if(empty($lng)) $lng=15.440;
-if(empty($res)) $res=15;
-
-$apikey = 'unknownhost';
-if($_SERVER['HTTP_HOST'] == 'dev-karte.ffgraz.net') {
- $apikey = 'ABQIAAAAZRu0cBQNp9TOBJp1i-DhohS9pf3riiZoWFmOpEuQ19If-UHZjhRHIGQIC00eY1H5H71yDqx-QzdyJA';
-} elseif($_SERVER['HTTP_HOST'] == 'dev-karte.graz.funkfeuer.at') {
- $apikey = 'ABQIAAAAZRu0cBQNp9TOBJp1i-DhohSbKGG4yPVU7VmuBMuIIaQfSNuMAxRrbvJwWee4f-0iW-LpRZkkrl531Q';
-}
-?>
-
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
- <title>Funkfeuer Graz: Map</title>
- <link rel="stylesheet" href="map.css" type="text/css" />
- <script src="http://maps.google.com/maps?file=api&v=2&&key=<?php echo $apikey; ?>"
- type="text/javascript"></script>
- <script src="map.js" type="text/javascript"></script>
- <script type="text/javascript">
- function onLoad() {
-<?php
- printf(" initialize(" . $lat . ", " . $lng . ", " . $res . ");\n");
-?>
- }
- </script>
- </head>
-
- <body onload="onLoad()" onunload="GUnload()">
- <div id="map" style="width:100%; height:100%;"></div>
- <div id="northeastcontainer">
- <div id="legendbox" class="box">
- <b>Legende:</b>
- <table class="legend">
- <tr><td align="center"><img src="./img/marker_online.png" /></td><td> </td><td>Online</td></tr>
- <tr><td align="center"><img src="./img/marker_offline.png" /></td><td> </td><td>Offline</td></tr>
- <tr><td align="center"><img src="./img/marker_tunnel.png" /></td><td> </td><td>Tunnel</td></tr>
- <tr><td align="center"><img src="./img/link_green.png" /></td><td> </td><td>Gut</td></tr>
- <tr><td align="center"><img src="./img/link_yellow.png" /></td><td> </td><td>Mittel</td></tr>
- <tr><td align="center"><img src="./img/link_grey.png" /></td><td> </td><td>Schlecht</td></tr>
- <tr><td align="center"><img src="./img/link_blue.png" /></td><td> </td><td>Tunnel</td></tr>
- </table>
- </div>
- <div id="countbox" class="box">
- </div>
- <div id="visibox" class="box">
- <b>Elemente<br />ausblenden</b>
- <form name="visibleform" action="#" onsubmit="return false">
- <table class="legend">
- <tr>
- <td><input type="checkbox" name="offline" value="true" onclick="javascript:toggleVisible('offline')"></td>
- <td> </td><td align="center"><img src="./img/marker_offline.png" /></td>
- </tr>
- <tr>
- <td><input type="checkbox" name="online" value="true" onclick="javascript:toggleVisible('online')");></td>
- <td> </td><td align="center"><img src="./img/marker_online.png" /> <img src="./img/marker_tunnel.png" /></td>
- </tr>
- <tr>
- <td><input type="checkbox" name="bad" value="true" onclick="javascript:toggleVisible('bad')" checked="checked"></td>
- <td> </td><td align="center"><img src="./img/link_grey.png" /></td>
- </tr>
- <tr>
- <td><input type="checkbox" name="middle" value="true" onclick="javascript:toggleVisible('middle')"></td>
- <td> </td><td align="center"><img src="./img/link_yellow.png" /></td>
- </tr>
- <tr>
- <td><input type="checkbox" name="good" value="true" onclick="javascript:toggleVisible('good')"></td>
- <td> </td><td align="center"><img src="./img/link_green.png" /></td>
- </tr>
- <tr>
- <td><input type="checkbox" name="tunnel" value="true" onclick="javascript:toggleVisible('tunnel')"></td>
- <td> </td><td align="center"><img src="./img/link_blue.png" /></td>
- </tr>
- </table>
- </form>
- </div>
- </div>
- <div id="southeastcontainer">
- <div id="loginbox" class="box">
- <script type="text/javascript">
- <?php
- if (!isset($_SESSION['logged_in']) || !$_SESSION['logged_in']) {
- echo 'showFFLogin();';
- } else {
- echo 'showFFLogout("'.$_SESSION['username'].'");';
- }
- ?>11
- </script>
- </div>
- <div id="addressbox" class="box">
- <b>Adresse suchen:</b>
- <form action="#" onsubmit="showAddress(this.address.value); return false">
- <p>
- <input type="text" size="35" name="address" value="Lendkai 1" />
- <input type="submit" value="Suchen" />
- </p>
- </form>
- </div>
- </div>
- </body>
-</html>
+<?php +session_start(); + +if(isset($_REQUEST['lat'])) $lat = mysql_escape_string($_REQUEST['lat']); +if(isset($_REQUEST['lng'])) $lng = mysql_escape_string($_REQUEST['lng']); +if(isset($_REQUEST['res'])) $res = $_REQUEST['res']; + +//default values +if(empty($lat)) $lat=47.07102; +if(empty($lng)) $lng=15.440; +if(empty($res)) $res=15; + +$apikey = 'unknownhost'; +if($_SERVER['HTTP_HOST'] == 'dev-karte.ffgraz.net') { + $apikey = 'ABQIAAAAZRu0cBQNp9TOBJp1i-DhohS9pf3riiZoWFmOpEuQ19If-UHZjhRHIGQIC00eY1H5H71yDqx-QzdyJA'; +} elseif($_SERVER['HTTP_HOST'] == 'dev-karte.graz.funkfeuer.at') { + $apikey = 'ABQIAAAAZRu0cBQNp9TOBJp1i-DhohSbKGG4yPVU7VmuBMuIIaQfSNuMAxRrbvJwWee4f-0iW-LpRZkkrl531Q'; +} +?> + +<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> + <head> + <meta http-equiv="content-type" content="text/html; charset=utf-8"/> + <title>Funkfeuer Graz: Map</title> + <link rel="stylesheet" href="map.css" type="text/css" /> + <script src="http://maps.google.com/maps?file=api&v=2&&key=<?php echo $apikey; ?>" + type="text/javascript"></script> + <script src="map.js" type="text/javascript"></script> + <script type="text/javascript"> + function onLoad() { +<?php + printf(" initialize(" . $lat . ", " . $lng . ", " . $res . ");\n"); +?> + } + </script> + </head> + + <body onload="onLoad()" onunload="GUnload()"> + <div id="map" style="width:100%; height:100%;"></div> + <div id="outerheader"><div id="header"> + <h1 align="center">..:: 0xFF FunkFeuer Freenet Graz ::..</h1> + </div></div> + <div id="northeastcontainer"> + <div id="legendbox" class="box"> + <b>Legende:</b> + <table class="legend"> + <tr><td align="center"><img src="./img/marker_online.png" /></td><td> </td><td>Online</td></tr> + <tr><td align="center"><img src="./img/marker_offline.png" /></td><td> </td><td>Offline</td></tr> + <tr><td align="center"><img src="./img/marker_tunnel.png" /></td><td> </td><td>Tunnel</td></tr> + <tr><td align="center"><img src="./img/link_green.png" /></td><td> </td><td>Gut</td></tr> + <tr><td align="center"><img src="./img/link_yellow.png" /></td><td> </td><td>Mittel</td></tr> + <tr><td align="center"><img src="./img/link_grey.png" /></td><td> </td><td>Schlecht</td></tr> + <tr><td align="center"><img src="./img/link_blue.png" /></td><td> </td><td>Tunnel</td></tr> + </table> + </div> + <div id="countbox" class="box"> + </div> + <div id="visibox" class="box"> + <b>Elemente<br />aus-/einblenden</b> + <form name="visibleform" action="#" onsubmit="return false"> + <table class="legend"> + <tr> + <td><input type="checkbox" name="defaultroute" value="true" onclick="javascript:toggleVisible('defaultroute')"></td> + <td> </td><td>!Default</td> + </tr> + <tr> + <td><input type="checkbox" name="offline" value="true" onclick="javascript:toggleVisible('offline')"></td> + <td> </td><td align="center"><img src="./img/marker_offline.png" /></td> + </tr> + <tr> + <td><input type="checkbox" name="online" value="true" onclick="javascript:toggleVisible('online')");></td> + <td> </td><td align="center"><img src="./img/marker_online.png" /> <img src="./img/marker_tunnel.png" /></td> + </tr> + <tr> + <td><input type="checkbox" name="bad" value="true" onclick="javascript:toggleVisible('bad')" checked="checked"></td> + <td> </td><td align="center"><img src="./img/link_grey.png" /></td> + </tr> + <tr> + <td><input type="checkbox" name="middle" value="true" onclick="javascript:toggleVisible('middle')"></td> + <td> </td><td align="center"><img src="./img/link_yellow.png" /></td> + </tr> + <tr> + <td><input type="checkbox" name="good" value="true" onclick="javascript:toggleVisible('good')"></td> + <td> </td><td align="center"><img src="./img/link_green.png" /></td> + </tr> + <tr> + <td><input type="checkbox" name="tunnel" value="true" onclick="javascript:toggleVisible('tunnel')"></td> + <td> </td><td align="center"><img src="./img/link_blue.png" /></td> + </tr> + </table> + <table class="undef"> + <td><input type="checkbox" name="undef" value="true" onclick="javascript:toggleVisible('undef')"></td> + <td> </td><td>Kanaele undef.</td> + </table> + <table class="5channel"> + <tr> + <td><input type="checkbox" name="5channel" value="true" onclick="javascript:toggleVisible('5channel')"></td> + <td> </td><td>Alle 5GHz Kanaele</td> + </tr> + </table> + <table class="2.4channel"> + <tr> + <td><input type="checkbox" name="2.4channel" value="true" onclick="javascript:toggleVisible('2.4channel')"></td> + <td> </td><td>Alle 2.4GHz Kanaele</td> + </tr> + </table> + <table class="channel"> + <tr> + <td><input type="checkbox" name="channel1" value="true" onclick="javascript:toggleVisible('channel1')"></td> + <td> </td><td>1</td> + <td><input type="checkbox" name="channel2" value="true" onclick="javascript:toggleVisible('channel2')"></td> + <td> </td><td>2</td> + <td><input type="checkbox" name="channel3" value="true" onclick="javascript:toggleVisible('channel3')"></td> + <td> </td><td>3</td> + </tr> + <tr> + + <td><input type="checkbox" name="channel4" value="true" onclick="javascript:toggleVisible('channel4')"></td> + <td> </td><td>4</td> + <td><input type="checkbox" name="channel5" value="true" onclick="javascript:toggleVisible('channel5')"></td> + <td> </td><td>5</td> + <td><input type="checkbox" name="channel6" value="true" onclick="javascript:toggleVisible('channel6')"></td> + <td> </td><td>6</td> + </tr> + <tr> + <td><input type="checkbox" name="channel7" value="true" onclick="javascript:toggleVisible('channel7')"></td> + <td> </td><td>7</td> + <td><input type="checkbox" name="channel8" value="true" onclick="javascript:toggleVisible('channel8')"></td> + <td> </td><td>8</td> + <td><input type="checkbox" name="channel9" value="true" onclick="javascript:toggleVisible('channel9')"></td> + <td> </td><td>9</td> + </tr> + <tr> + <td><input type="checkbox" name="channel10" value="true" onclick="javascript:toggleVisible('channel10')"></td> + <td> </td><td>10</td> + <td><input type="checkbox" name="channel11" value="true" onclick="javascript:toggleVisible('channel11')"></td> + <td> </td><td>11</td> + <td><input type="checkbox" name="channel12" value="true" onclick="javascript:toggleVisible('channel12')"></td> + <td> </td><td>12</td> + </tr> + <tr> + <td><input type="checkbox" name="channel13" value="true" onclick="javascript:toggleVisible('channel13')"></td> + <td> </td><td>13</td> + </tr> + </table> + </form> + </div> + </div> + <div id="southeastcontainer"> + <div id="loginbox" class="box"> + <script type="text/javascript"> + <?php + if (!isset($_SESSION['logged_in']) || !$_SESSION['logged_in']) { + echo 'showFFLogin();'; + } else { + echo 'showFFLogout("'.$_SESSION['username'].'");'; + } + ?>11 + </script> + </div> + <div id="addressbox" class="box"> + <b>Adresse suchen (Strassenname Nr. <, Ort>):</b> + <form action="#" onsubmit="showAddress(this.address.value); return false"> + <p> + <input type="text" size="35" name="address" value="Lendkai 1" /> + <input type="submit" value="Suchen" /> + </p> + </form> + </div> + </div> + </body> +</html> @@ -27,6 +27,7 @@ div.box { } #northeastcontainer { + position: absolute; right: 10px; top: 5ex; @@ -34,13 +35,14 @@ div.box { } #legendbox { + width: 90%; margin-top: 0; margin-left: auto; margin-right: 0; } #countbox { - width: 70%; + width: 90%; margin-top: 1ex; margin-left: auto; margin-right: 0; @@ -49,7 +51,7 @@ div.box { } #visibox { - width: 70%; + width: 90%; margin-top: 1ex; margin-left: auto; margin-right: 0; @@ -57,21 +59,21 @@ div.box { #southeastcontainer { position: absolute; - right: 10px; - bottom: 10px; + right: center; + bottom: 40px; padding: 0; } #loginbox { margin-top: 0; margin-left: auto; - marign-right: 0; + marign-right: center; } #addressbox { - margin-top: 1ex; + margin-top: 0; margin-left: auto; - margin-bottom: 0; + margin-bottom: 1ex; } #distboxouter { @@ -114,6 +116,10 @@ div.btn { color: black; } +*.linkinfo,table { + font-size: 8pt; + color: black; +} table.legend { margin-top: 3px; } @@ -1,10 +1,11 @@ var map = null; +var linkinfo; var physicalMaxLevel; var geocoder = null; var reloadcon = null; var countboxText = null; var overlays = new Array(); -overlays["newmarker"] = null; +overlays["new"] = null; overlays["ruler"] = new Array(); overlays["locations"] = new Array(); overlays["links"] = new Array(); @@ -21,10 +22,25 @@ function initialize(lat, lng, res) { map.disableDoubleClickZoom(); map.enableScrollWheelZoom(); - map.removeMapType(G_HYBRID_MAP); - map.removeMapType(G_SATELLITE_MAP); +// map.removeMapType(G_HYBRID_MAP); +// map.removeMapType(G_SATELLITE_MAP); map.addMapType(G_PHYSICAL_MAP); - map.setMapType(G_PHYSICAL_MAP); +// map.setMapType(G_HYBRID_MAP); + + // openStreetMap + var copyOSM = new GCopyrightCollection("<a href=\"http://www.openstreetmap.org/\">OpenStreetMap</a>"); + var copyOGDGraz = new GCopyrightCollection("Open Government Data Graz"); + copyOSM.addCopyright(new GCopyright(1, new GLatLngBounds(new GLatLng(-90,-180), new GLatLng(90,180)), 0, " ")); + var tilesOsmarender = new GTileLayer(copyOSM, 1, 17, {tileUrlTemplate: 'http://tah.openstreetmap.org/Tiles/tile/{Z}/{X}/{Y}.png'}); + var mapOsmarender = new GMapType([tilesOsmarender], G_NORMAL_MAP.getProjection(), "openSM", {urlArg: 'y'}); + map.addMapType(mapOsmarender); + var tilesMapnik = new GTileLayer(copyOSM, 1, 17, {tileUrlTemplate: 'http://tile.openstreetmap.org/{Z}/{X}/{Y}.png'}); + var mapMapnik = new GMapType([tilesMapnik], G_NORMAL_MAP.getProjection(), "Mapnik", {urlArg: 'x'}); + map.addMapType(mapMapnik); +// var tilesOpenGeoServer = new GTileLayer(copyOGDGraz, 1, 17, {tileUrlTemplate: 'http://services.opengeoserver.org/tiles/1.0.0/globe.aerial_EPSG3857/${Z}/${X}/${Y}.png?origin=nw'}); +// var mapOpenGeoServer = new GMapType([tilesOpenGeoServer], G_NORMAL_MAP.getProjection(), "OpenGeoServer"); +// map.addMapType(mapOpenGeoServer); + physicalMaxLevel = map.getCurrentMapType().getMaximumResolution(); if(res > physicalMaxLevel) { map.setMapType(G_NORMAL_MAP); @@ -39,11 +55,19 @@ function initialize(lat, lng, res) { GEvent.addListener(map, "addoverlay", onAddOverlay); GEvent.addListener(map, "zoomend", onZoom); GEvent.addListener(map, "click", onMapClick); - + + lineinfo = document.createElement("div"); + document.getElementById("map").appendChild(lineinfo); + lineinfo.style.visibility = "hidden" + + dnsinfo = document.createElement("div"); + document.getElementById("map").appendChild(dnsinfo); + dnsinfo.style.visibility = "hidden" + var mt = map.getMapTypes(); for (var i=0; i<mt.length; i++) { mt[i].getMinimumResolution = function() {return 0;} - mt[i].getMaximumResolution = function() {return 17;} + mt[i].getMaximumResolution = function() {return 22;} } geocoder = new GClientGeocoder(); @@ -72,7 +96,7 @@ function onAddOverlay(overlay) { switch(overlay.overlaytype) { case "location": overlays["locations"].push(overlay); break; case "link": overlays["links"].push(overlay); break; - case "newmarker": { + case "new": { if(overlays["newmarker"]) { map.removeOverlay(overlays["newmarker"]); } @@ -92,13 +116,14 @@ function onAddOverlay(overlay) { function onZoom(oldLevel, newLevel) { if(newLevel > physicalMaxLevel) { - map.setMapType(G_NORMAL_MAP); + // map.setMapType(G_SATELLITE_MAP); } } function onMapClick(overlay, point) { if(!overlay) { + map.setCenter(point); setNewMarker(point); } } @@ -162,6 +187,7 @@ function Location(element) { location.pixel_y = parseInt(element.getAttribute("pixel_y")); location.state = element.getAttribute("state"); location.gallery_link = element.getAttribute("gallery_link"); + location.dnsnames = element.getAttribute("router_links"); return location; } @@ -172,18 +198,64 @@ function onLocationClick(latlng) { html += '<table class="locinfo">'; html += '<tr><td>Breitengrad:</td><td> </td><td>' + convertCoords(locations[this.locid].point.lat()) + '</td></tr>'; html += '<tr><td>Längengrad:</td><td> </td><td>' + convertCoords(locations[this.locid].point.lng()) + '</td></tr>'; - html += '<tr><td>Datenbank:</td><td> </td><td><a href="http://manman.graz.funkfeuer.at/location/show/' + this.locid + '">Link</td></tr>'; - html += '<tr><td>Smokeping:</td><td> </td><td><a href="http://www.graz.funkfeuer.at/cgi-bin/smokeping.cgi?target=FunkFeuer.' + locations[this.locid].name + '">Link</td></tr>'; + html += '<tr><td>Datenbank:</td><td> </td><td><a href="http://manman.graz.funkfeuer.at/location/show/' + this.locid + '" target="_blank">Link-Database</td></tr>'; + html += '<tr><td>Smokeping:</td><td> </td><td><a href="http://stats.graz.funkfeuer.at/smokeping/?target=Funkfeuer.' + locations[this.locid].name + '" target="_blank">Link-Smokeping</td></tr>'; if(locations[this.locid].gallery_link) { - html += '<tr><td>Galerie:</td><td> </td><td><a href="' + locations[this.locid].gallery_link + '">Link</td></tr>'; + html += '<tr><td>Galerie:</td><td> </td><td><a href="' + locations[this.locid].gallery_link + '" target="_blank">Link-Galerie/Knoten</td></tr>'; } else { - html += '<tr><td>Galerie:</td><td> </td><td><a href="http://gallery.funkfeuer.at/v/Graz/Knoten/">Link</td></tr>'; - } + html += '<tr><td>Galerie:</td><td> </td><td><a href="http://gallery.funkfeuer.at/v/Graz/Knoten/" target="_blank">Link-Galerie</td></tr>'; + } + if (locations[this.locid].dnsnames){ + var dnsname = locations[this.locid].dnsnames.split(";"); + for (var i = 0;i < dnsname.length; ++i){ + if (dnsname[i]!==""){ + if(dnsname[i].indexOf(" (")>=0) { + link=dnsname[i].substring(0,dnsname[i].indexOf(" (")); + } else { + link=dnsname[i]; + } + html += '<tr><td> Router:</td><td> </td><td><a href="http://' + link+ '.ext.graz.funkfeuer.at/" target="_blank">'+dnsname[i]+'</td></tr>'; + } + } + } html += '</table>'; html += '</div>'; this.openInfoWindowHtml(html); } +function onLineClick(line,latlng) { +// var html ='<div id="linkbox" class="box">'; + var html ='<div class="locinfo">'; + html += '<b>'+line.name+'</b>'; + html += '<table class="linkinfo">'; + if (line.dnsfrom){ + var dnsfrom = line.dnsfrom.split(";"); + for (var i = 0;i < dnsfrom.length; ++i){ + if(dnsfrom[i].indexOf(" (")>=0) { + link=dnsfrom[i].substring(0,dnsfrom[i].indexOf(" (")); + } else { + link=dnsfrom[i]; + } + html += '<tr><td> Router:</td><td> </td><td><a href="http://' + link+ '.ext.graz.funkfeuer.at/" target="_blank">'+dnsfrom[i]+'</td></tr>'; + } + } + + if(line.dnsto){ + var dnsto = line.dnsto.split(";"); + for (var i = 0;i < dnsto.length; ++i){ + if(dnsto[i].indexOf(" (")>=0) { + link=dnsto[i].substring(0,dnsto[i].indexOf(" (")); + } else { + link=dnsto[i]; + } + html += '<tr><td> Router:</td><td> </td><td><a href="http://' + link+ '.ext.graz.funkfeuer.at/" target="_blank">'+dnsto[i]+'</td></tr>'; + } + } + html += '</table>'; + html += '</div>'; + map.openInfoWindowHtml(latlng,html); +} + function convertCoords(x) { var deg = Math.floor(x); var min = (x - deg) * 60; @@ -194,13 +266,33 @@ function convertCoords(x) { function drawLinks(xmlData) { var element = xmlData.getElementsByTagName("link"); for (var i = 0; i< element.length; i++) { + var state; + var color; + var textcolor; + var width; + state="Unbekannt" var id = element[i].getAttribute("from") + "-" + element[i].getAttribute("to"); links[id] = new Link(element[i]); var line = new GPolyline([links[id].frompoint, links[id].topoint], makeColor(Math.floor(links[id].value)), makeWeight(Math.floor(links[id].value))); + line.name = id; + line.textcolor = textcolor; + line.state = state; line.overlaytype = "link"; line.linkid = id; + line.dnsfrom = element[i].getAttribute("dnsfrom"); + line.dnsto = element[i].getAttribute("dnsto"); + line.Routerfrom = element[i].getAttribute("from"); + line.Routerto = element[i].getAttribute("to"); + GEvent.addListener(line, "mouseout", function() { lineinfo.style.visibility = "hidden"; }); + GEvent.addListener(line, "mouseover", function(point) { showLinkInfo(this, point)}); + GEvent.addListener(line, "click", function(point){onLineClick(this,point)}); +// GEvent.addListener(line, "click", function(latlng){map.openInfoWindowHtml(latlng, message)}); + map.addOverlay(line); + } + if(document.visibleform.elements["defaultroute"].checked) { + toggleVisible("defaultroute"); } if(document.visibleform.elements["bad"].checked) { toggleVisible("bad"); @@ -214,6 +306,80 @@ function drawLinks(xmlData) { if(document.visibleform.elements["tunnel"].checked) { toggleVisible("tunnel"); } + if(document.visibleform.elements["2.4channel"].checked) { + toggleVisible("2.4channel"); + } + if(document.visibleform.elements["channel1"].checked) { + toggleVisible("channel1"); + } + if(document.visibleform.elements["channel2"].checked) { + toggleVisible("channel2"); + } + if(document.visibleform.elements["channel3"].checked) { + toggleVisible("channel3"); + } + if(document.visibleform.elements["channel4"].checked) { + toggleVisible("channel4"); + } + if(document.visibleform.elements["channel5"].checked) { + toggleVisible("channel5"); + } + if(document.visibleform.elements["channel6"].checked) { + toggleVisible("channel6"); + } + if(document.visibleform.elements["channel7"].checked) { + toggleVisible("channel7"); + } + if(document.visibleform.elements["channel8"].checked) { + toggleVisible("channel8"); + } + if(document.visibleform.elements["channel9"].checked) { + toggleVisible("channel9"); + } + if(document.visibleform.elements["channel10"].checked) { + toggleVisible("channel10"); + } + if(document.visibleform.elements["channel11"].checked) { + toggleVisible("channel11"); + } + if(document.visibleform.elements["channel12"].checked) { + toggleVisible("channel12"); + } + if(document.visibleform.elements["channel13"].checked) { + toggleVisible("channel13"); + } + if(document.visibleform.elements["5channel"].checked) { + toggleVisible("5channel"); + } + if(document.visibleform.elements["undef"].checked) { + toggleVisible("undef"); + } +} +function showLinkInfo(link, point) { + var html = '<div id="linkbox" class="box" style="border-color: ' + link.color + '">'; + if((links[link.name].frequence !== "undef") && (links[link.name].frequence !== "")){ + html += '<strong>Frequenz:</strong> ' + links[link.name].frequence + '<br />'; + } else { + html += '<strong>Frequenz:</strong> undef <br />'; + } + if(links[link.name].channel !== "undef") { + html += '<strong>Kanal:</strong> ' + links[link.name].channel + '<br />'; + } else { + html += '<strong>Kanal:</strong> undef <br />'; + } + if (links[link.name].value !==-1){ + html += '<strong>Mittlerer ETX:</strong> ' + links[link.name].value + '<br />'; + } else { + html += '<strong>Mittlerer ETX:</strong> undef <br />'; + } + html += '<strong>Name:</strong> ' + link.name + '<br />'; + html += '<strong>Länge:</strong> ' + link.getLength().toFixed(0) + ' m<br />'; + html += '</div>'; + lineinfo.innerHTML = html; + var pos = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(180, 0)); + + pos.apply(lineinfo); + lineinfo.style.visibility = "visible"; } function Link(element) { @@ -231,7 +397,9 @@ function Link(element) { link.topoint = new GLatLng(lat, lng); link.value = parseFloat(element.getAttribute("value")); - + link.channel = element.getAttribute("channel"); + link.defaultroute = element.getAttribute("defaultroute"); + link.frequence = element.getAttribute("frequence"); return link; } @@ -279,13 +447,64 @@ function makeIcon(type) { function toggleVisible(element) { var elements = Object(); + if (element=='bad' || element=='middle' || element=='good'){ + document.visibleform.elements["2.4channel"].checked=false; + document.visibleform.elements["channel1"].checked=false; + document.visibleform.elements["channel2"].checked=false; + document.visibleform.elements["channel3"].checked=false; + document.visibleform.elements["channel4"].checked=false; + document.visibleform.elements["channel5"].checked=false; + document.visibleform.elements["channel6"].checked=false; + document.visibleform.elements["channel7"].checked=false; + document.visibleform.elements["channel8"].checked=false; + document.visibleform.elements["channel9"].checked=false; + document.visibleform.elements["channel10"].checked=false; + document.visibleform.elements["channel11"].checked=false; + document.visibleform.elements["channel12"].checked=false; + document.visibleform.elements["channel13"].checked=false; + document.visibleform.elements["5channel"].checked=false; + document.visibleform.elements["undef"].checked=false; + } + if (element=='2.4channel'){ + document.visibleform.elements["channel1"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel2"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel3"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel4"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel5"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel6"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel7"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel8"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel9"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel10"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel11"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel12"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel13"].checked=document.visibleform.elements["2.4channel"].checked; + } switch(element) { + case 'defaultroute': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].defaultroute == '0');"); break; case 'offline': elements.overlays = overlays["locations"]; elements.select = new Function("id", "return (locations[overlays['locations'][id].locid].state == 'offline');"); break; case 'online': elements.overlays = overlays["locations"]; elements.select = new Function("id", "return (locations[overlays['locations'][id].locid].state != 'offline');"); break; case 'bad': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].value >= 6);"); break; case 'middle': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].value >= 3 && links[overlays['links'][id].linkid].value < 6);"); break; case 'good': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].value >= 0 && links[overlays['links'][id].linkid].value < 3);"); break; case 'tunnel': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].value == -1);"); break; + case 'channel1': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '1');"); break; + case 'channel2': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '2');"); break; + case 'channel3': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '3');"); break; + case 'channel4': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '4');"); break; + case 'channel5': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '5');"); break; + case 'channel6': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '6');"); break; + case 'channel7': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '7');"); break; + case 'channel8': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '8');"); break; + case 'channel9': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '9');"); break; + case 'channel10': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '10');"); break; + case 'channel11': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '11');"); break; + case 'channel12': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '12');"); break; + case 'channel13': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '13');"); break; + case 'undef': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].frequence == 'undef');"); break; + case '2.4channel': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].frequence == '2.4');"); break; + case '5channel': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].frequence !=='2.4' && links[overlays['links'][id].linkid].frequence !=='undef');"); break; + } if(document.visibleform.elements[element].checked) { @@ -336,7 +555,8 @@ function addNewNodeText(point) { return html; } -function setNewMarker(point) { +function setNewMarker(point) { +/* var marker = new GMarker(point,{icon: makeIcon('newnode'), draggable: true}); GEvent.addListener(marker, "dragstart", function() { @@ -362,6 +582,14 @@ function setNewMarker(point) { marker.overlaytype = "newmarker"; map.addOverlay(marker); marker.openInfoWindowHtml(addNewNodeText(point)); +*/ + var marker = new GMarker(point,makeIcon('newnode')); + GEvent.addListener(marker,"infowindowclose",function () { + map.removeOverlay(marker); + }); + + map.addOverlay(marker); + marker.openInfoWindowHtml(addNewNodeText(point)); } function fflogin(username, password) { @@ -439,7 +667,7 @@ function showFFLogout(username) { function showAddress(address) { if (geocoder) { - address += ", Graz, Austria"; +// address += ", Graz, Austria"; geocoder.getLatLng(address, function(point) { if (!point) { @@ -511,7 +739,7 @@ RulerControl.prototype.initialize = function(map) { dist = (parseInt(dist)/1000).toFixed(1) + " km"; } distText.data = "Entfernung: " + dist; - var poly = new GPolyline(line,'#FFFF00', 8, 1) + var poly = new GPolyline(line,'#FFFF00', 3, 1) poly.overlaytype = "ruler"; poly.overlaysubtype = "line"; map.addOverlay(poly); @@ -576,5 +804,5 @@ RulerControl.prototype.initialize = function(map) { } RulerControl.prototype.getDefaultPosition = function() { - return new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(7, 7)); + return new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(7, 7)); } |