From 34a9dcaede6e86f8f11dca261107bfc11c5fd36b Mon Sep 17 00:00:00 2001 From: Christian Dresel Date: Wed, 24 Oct 2018 16:10:41 +0200 Subject: [PATCH 1/4] Add IP Check Signed-off-by: Christian Dresel --- index.php | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 98 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 6eeb31b..eb7af3d 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,57 @@ + 255) { + + die("Ein Teilstück der IP Adresse ist grö&szli;ger als 255."); + + } + + } + + } + + } + + } + + // Noch nicht abgebrochen? -> True zurückliefern + return true; + +} +?> + @@ -22,7 +76,7 @@ '.$file.''); - while (1) { +/* while (1) { $read = socket_read($sock, 1024, PHP_NORMAL_READ); if (preg_match("/interface\b/", $read)) { $interface[] = $read; } if (preg_match("/neighbour\b/", $read)) { $neighbour[] = $read; } @@ -50,6 +107,25 @@ if (preg_match("/ok/", $read)){ break 1; } } socket_close($sock); +*/ + $file_handle = fopen($file, 'r'); + $set=0; + $i=0; + while (1) { + $line = fgets($file_handle); + if ($i <= 5) { + $data[] = $line; + $i++; + } + if (preg_match("/interface\b/", $line)) { $interface[] = $line; } + if (preg_match("/neighbour\b/", $line)) { $neighbour[] = $line; } + if (preg_match("/xroute\b/", $line)) { $xroute[] = $line; } + #if (preg_match("/\broute\b/", $read)){ break 1; } + if (preg_match("/\broute\b/", $line)){ $route[] = $line; } + if (preg_match("/ok/", $line)){ $set++; } + if ($set == 2) { break; } + } + fclose($file_handle); $output['data'] = array( 'name' => $data[0], @@ -119,6 +195,7 @@ +

Babel information

"; } + + if($_GET['lg'] == '1') { + ?> +
+ IPv4 Adresse: + +
+
";
+					echo shell_exec('ping '.$IP.' -c 3');
+					echo "
Traceroute $IP
";
+					echo shell_exec('traceroute '.$IP.'');
+					echo "
"; + } + } + } ?>
From 4d4c4cd4546cc36c2cc59a1881ba671b19867557 Mon Sep 17 00:00:00 2001 From: Christian Dresel Date: Wed, 24 Oct 2018 16:13:28 +0200 Subject: [PATCH 2/4] Remove old socket don't work with to much data --- index.php | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/index.php b/index.php index eb7af3d..e6cd04b 100644 --- a/index.php +++ b/index.php @@ -76,38 +76,9 @@ function checkip($ip) { '.$file.''); -/* while (1) { - $read = socket_read($sock, 1024, PHP_NORMAL_READ); - if (preg_match("/interface\b/", $read)) { $interface[] = $read; } - if (preg_match("/neighbour\b/", $read)) { $neighbour[] = $read; } - if (preg_match("/xroute\b/", $read)) { $xroute[] = $read; } - #if (preg_match("/\broute\b/", $read)){ break 1; } - if (preg_match("/\broute\b/", $read)){ $route[] = $read; } - if (preg_match("/ok/", $read)){ break 1; } - } - socket_close($sock); -*/ $file_handle = fopen($file, 'r'); $set=0; $i=0; From 1af8652e11f6e040459f6692398ad4e9562bce5d Mon Sep 17 00:00:00 2001 From: Christian Dresel Date: Wed, 24 Oct 2018 16:27:28 +0200 Subject: [PATCH 3/4] Use filter_var to check for IP adress Signed-off-by: Christian Dresel --- index.php | 63 ++++++------------------------------------------------- 1 file changed, 6 insertions(+), 57 deletions(-) diff --git a/index.php b/index.php index e6cd04b..97192c9 100644 --- a/index.php +++ b/index.php @@ -1,57 +1,3 @@ - 255) { - - die("Ein Teilstück der IP Adresse ist grö&szli;ger als 255."); - - } - - } - - } - - } - - } - - // Noch nicht abgebrochen? -> True zurückliefern - return true; - -} -?> - @@ -329,18 +275,21 @@ function checkip($ip) { if($_GET['lg'] == '1') { ?>
- IPv4 Adresse: + IP Adresse (v4 und v6):
";
 					echo shell_exec('ping '.$IP.' -c 3');
 					echo "
Traceroute $IP
";
 					echo shell_exec('traceroute '.$IP.'');
 					echo "
"; + + } else { + echo("$ip1 is not a valid IP address"); } } From 68f5004b1cae9a64fb01f91d4dc2438f76c42956 Mon Sep 17 00:00:00 2001 From: Christian Dresel Date: Wed, 24 Oct 2018 16:29:34 +0200 Subject: [PATCH 4/4] Kleinigkeiten... Signed-off-by: Christian Dresel --- index.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/index.php b/index.php index 97192c9..67129f2 100644 --- a/index.php +++ b/index.php @@ -279,13 +279,12 @@
";
-					echo shell_exec('ping '.$IP.' -c 3');
-					echo "
Traceroute $IP
";
-					echo shell_exec('traceroute '.$IP.'');
+				$ip =$_POST['IP'];
+				if (filter_var($ip, FILTER_VALIDATE_IP)) {
+					echo "Pinge $ip: 
";
+					echo shell_exec('ping '.$ip.' -c 3');
+					echo "
Traceroute $ipP
";
+					echo shell_exec('traceroute '.$ip.'');
 					echo "
"; } else {