summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@ffgraz.net>2013-12-30 02:44:13 +0000
committerChristian Pointner <equinox@ffgraz.net>2013-12-30 02:44:13 +0000
commit70b378464945443b234380c5098ec7066bb0b15f (patch)
treef79d174c3be10cbf80eea6debca80042a1d8cdaa
parent736522335971a165326b741632dbd5e1efdf6ec3 (diff)
cleanup
-rw-r--r--check_user.php2
-rw-r--r--config.php8
-rw-r--r--data.php226
-rw-r--r--db.class.php2
4 files changed, 118 insertions, 120 deletions
diff --git a/check_user.php b/check_user.php
index 4b89267..bd7dfc7 100644
--- a/check_user.php
+++ b/check_user.php
@@ -10,7 +10,7 @@ function check_user($username, $password)
$db->query("SELECT password FROM person WHERE email='".$escaped_username."'");
$data = $db->getNextObject();
- if($data->password == md5($password))
+ if($data->password == md5($password))
return true;
return false;
diff --git a/config.php b/config.php
index 3f0e272..d806fbb 100644
--- a/config.php
+++ b/config.php
@@ -10,13 +10,11 @@ $conf['router']['file'] = 'InfoRouter.plain';
/* neue eintraege bitte kommentieren !!!! */
$conf['acl']['range'] = array(
- "10.0.0.0/8", // Funkfeuer Graz Private
- "217.29.149.64/28", // 0xFF Citycom IP Bereich
+ "10.0.0.0/8", // Funkfeuer Graz et.al Private Adressen
"193.33.150.0/23", // Funkfeuer Graz Public
+ "217.29.149.64/28", // 0xFF Citycom IP Bereich
"193.238.156.0/22", // Funkfeuer Wien
- "89.106.208.0/21", // mur.at
-// "84.119.56.63/32", // equinox home test
- "212.17.113.195/32" // roland home wien
+ "89.106.208.0/21" // mur.at
);
?>
diff --git a/data.php b/data.php
index 2735c0b..7f59f3f 100644
--- a/data.php
+++ b/data.php
@@ -41,35 +41,35 @@ $ipname = array();
$dnsnames = array();
$ip = array();
$nodelocnames = array();
-$ipnodelocnames = 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;
+ $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;
+ $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");
+ $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");
+ $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;
+ 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->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){
@@ -93,7 +93,7 @@ while ($data = $db->getNextObject()) {
if ($channel!="" or $frequence!=""){
$data->dnsnames = $dnsname." (Kanal: ".$channel." / ".$frequence." GHz);".$data->dnsnames;
break 2;
- }
+ }
}
$data->dnsnames = $dnsname.";".$data->dnsnames;
}
@@ -117,7 +117,7 @@ while ($data = $db->getNextObject()) {
}
}
*/
- }
+ }
$locations[$data->locid] = $data;
}
@@ -126,27 +126,27 @@ $lines = file($conf['topo']['file']);
$linecnt=0;
$i =0;
-foreach ($lines as $num => $line)
+foreach ($lines as $num => $line)
{
- $linecnt++;
- if(preg_match($regmatch,$line,$matches)==0)
+ $linecnt++;
+ if(preg_match($regmatch,$line,$matches)==0)
continue;
- list( , $ipfromLoc, $iptoLoc, $label) = $matches;
+ list( , $ipfromLoc, $iptoLoc, $label) = $matches;
+
+ if (empty($ipfromLoc) || empty($iptoLoc) || empty($label))
+ continue;
- 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;
+ 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;
@@ -154,26 +154,26 @@ foreach ($lines as $num => $line)
// 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;
+ ($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;
+ $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 (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];
@@ -183,20 +183,20 @@ foreach ($lines as $num => $line)
}
} else{
$links[$jot]->channel ="undef";
- $links[$jot]->frequence ="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 ($routerhash[$ipfromLoc][3]==$iptoLoc){
- $links[$jot]->defaultroute = "1";
- }
}
if (array_key_exists($iptoLoc,$routerhash)){
if($conf['acl']['auth']){
@@ -206,30 +206,30 @@ foreach ($lines as $num => $line)
}
}
if ($routerhash[$iptoLoc][3]==$ipfromLoc){
- $links[$jot]->defaultroute = "1";
- }
- }
-
- }
- elseif(isset($already[$locations[$locids[$iptoLoc]]->locid . '-' . $locations[$locids[$ipfromLoc]]->locid])&&
+ $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;
+ $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;
+ $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];
@@ -239,19 +239,19 @@ foreach ($lines as $num => $line)
}
} else{
$links[$jot]->channel ="undef";
- $links[$jot]->frequence ="undef";
+ $links[$jot]->frequence ="undef";
// echo "keine IP\n";
}
- if (array_key_exists($ipfromLoc,$routerhash)){
+ 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 ($routerhash[$ipfromLoc][3]==$iptoLoc){
+ $links[$jot]->defaultroute = "1";
+ }
}
if (array_key_exists($iptoLoc,$routerhash)){
if($conf['acl']['auth']){
@@ -261,28 +261,28 @@ foreach ($lines as $num => $line)
}
}
if ($routerhash[$iptoLoc][3]==$ipfromLoc){
- $links[$jot]->defaultroute = "1";
- }
+ $links[$jot]->defaultroute = "1";
+ }
}
- }
- else {
+ }
+ 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)){
+ $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];
@@ -292,24 +292,24 @@ foreach ($lines as $num => $line)
}
} else{
$links[$i]->channel ="undef";
- $links[$i]->frequence ="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 ($routerhash[$ipfromLoc][3]==$iptoLoc){
+ $links[$i]->defaultroute = "1";
+ }
}
if (array_key_exists($iptoLoc,$routerhash)){
if($conf['acl']['auth']){
@@ -317,36 +317,36 @@ foreach ($lines as $num => $line)
}
if ($routerhash[$iptoLoc][3]==$ipfromLoc){
- $links[$i]->defaultroute = "1";
- }
+ $links[$i]->defaultroute = "1";
+ }
}
if($links[$i]->label != -1){
- $links[$i]->label = $label;
+ $links[$i]->label = $label;
if($locations[$locids[$ipfromLoc]]->state == "offline")
- $locations[$locids[$ipfromLoc]]->state = "online";
+ $locations[$locids[$ipfromLoc]]->state = "online";
if($locations[$locids[$iptoLoc]]->state == "offline")
- $locations[$locids[$iptoLoc]]->state = "online";
+ $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" ) ||
- ($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" )){
+ 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";
+ $links[$i]->channel ="undef";
}
-
- $i++;
- }
+
+ $i++;
+ }
}
@@ -355,9 +355,9 @@ 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);
+ $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";
@@ -367,14 +367,14 @@ foreach ($links as $link)
{
- $data1 = $locations[$locids[$link->ipfromLoc]];
- $data2 = $locations[$locids[$link->iptoLoc]];
+ $data1 = $locations[$locids[$link->ipfromLoc]];
+ $data2 = $locations[$locids[$link->iptoLoc]];
- $count[$data1->locid]=true;
- $count[$data2->locid]=true;
+ $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);
+ 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";
diff --git a/db.class.php b/db.class.php
index 0921bc8..1a3647f 100644
--- a/db.class.php
+++ b/db.class.php
@@ -13,7 +13,7 @@ function DB($user, $pass, $host, $dbname) {
}
function connect() {
- $this->db = mysql_connect($this->host, $this->user, $this->pass)
+ $this->db = mysql_connect($this->host, $this->user, $this->pass)
or $this->error("Verbindungsaufbau fehlgeschlagen");
mysql_select_db($this->dbname);
}