From 71bb7cac9c6580d575ec13addd872f0ec43ba32e Mon Sep 17 00:00:00 2001 From: Schrolli Date: Wed, 8 Apr 2015 08:01:12 +0200 Subject: [PATCH 1/6] more parsing in web frontend --- www/index.php | 6 ++-- www/parser.php | 79 ++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 76 insertions(+), 9 deletions(-) diff --git a/www/index.php b/www/index.php index b962b07..792ba95 100644 --- a/www/index.php +++ b/www/index.php @@ -38,8 +38,8 @@ $db_link = mysqli_connect ($dbhost, $dbuser, $dbpassword, $database); echo "". $time . ""; echo "". parse("service",$fms_id) . ""; echo "". parse("country",$fms_id) . ""; - echo "". $data['location'] . ""; - echo "". $data['vehicle'] . ""; + echo "". parse("location",$fms_id) . ""; + echo "". parse("vehicle",$fms_id) . ""; echo "". $data['status'] . ""; echo "". parse("direction",$fms_id) . ""; echo "". $data['tsi'] . ""; @@ -65,7 +65,7 @@ $db_link = mysqli_connect ($dbhost, $dbuser, $dbpassword, $database); echo ""; echo "". $data['id'] . ""; echo "". $time . ""; - echo "". $data['zvei'] . ""; + echo "". parse('zvei',$data['zvei']) . ""; echo ""; } echo ""; diff --git a/www/parser.php b/www/parser.php index e1242ad..5a8bb00 100644 --- a/www/parser.php +++ b/www/parser.php @@ -1,8 +1,7 @@ "Fernwirktelegramm", ); - //Data for Country Parsing + //Data for Country Parsing $country = array( "0" => "Sachsen", "1" => "Bund", @@ -43,21 +42,89 @@ "e" => "Meck-Pom/Sachsen-Anhalt", "f" => "Brandenburg/Thüringen", ); + + //Data for Location Parsing + $location = array( + "11" => "testLoc", + "22" => "testLoc", + "33" => "testLoc" + ); + + //Data for Vehicle Parsing + $vehicle = array( + "1111" => "testVeh", + "2222" => "testVeh", + "3333" => "testVeh" + ); + + + //Data for ZVEI Parsing + $country = array( + "12345" => "testZvei", + "23456" => "testZvei", + "34567" => "testZvei", + ); + switch ($mode) { + #Parse Service case "service": - return $service[substr($fms,0,1)]; + if (array_key_exists($data, $service)) { + return $service[substr($data,0,1)]; + }else + { + return $data; + } break; - + + #Parse Country case "country": - return $country[substr($fms,1,1)]; + if (array_key_exists($data, $country)) { + return $country[substr($data,1,1)]; + }else + { + return $data; + } break; + #Parse Location + case "location": + if (array_key_exists($data, $location)) { + return $location[substr($data,2,2)]; + }else + { + return $data; + } + break; + + #Parse Vehicle + case "vehicle": + if (array_key_exists($data, $vehicle)) { + return $vehicle[substr($data,4,4)]; + }else + { + return $data; + } + break; + + #Parse direction case "direction": if(substr($fms,9,1) == 1){ return "L->F"; }elseif(substr($fms,9,1) == 0){ return "F->L"; + }else + return "ERR!"; + } + break; + + #Parse Zvei + case "zvei": + if (array_key_exists($data, $zvei)) { + return $data ." - ". $zvei[$data]; + }else + { + return $data; } break; From 1560e04991e69b503d0fb146f093353d41935494 Mon Sep 17 00:00:00 2001 From: Schrolli Date: Wed, 8 Apr 2015 08:14:18 +0200 Subject: [PATCH 2/6] optic and (C) in web --- www/index.php | 6 +++++- www/parser.php | 21 ++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/www/index.php b/www/index.php index 792ba95..cf1a925 100644 --- a/www/index.php +++ b/www/index.php @@ -72,7 +72,11 @@ $db_link = mysqli_connect ($dbhost, $dbuser, $dbpassword, $database); ?> +

+ (C) BOSWatch - All rights reserved +

+ - + \ No newline at end of file diff --git a/www/parser.php b/www/parser.php index 5a8bb00..ac055af 100644 --- a/www/parser.php +++ b/www/parser.php @@ -69,7 +69,8 @@ switch ($mode) { #Parse Service case "service": - if (array_key_exists($data, $service)) { + if (array_key_exists($data, $service)) + { return $service[substr($data,0,1)]; }else { @@ -79,7 +80,8 @@ #Parse Country case "country": - if (array_key_exists($data, $country)) { + if (array_key_exists($data, $country)) + { return $country[substr($data,1,1)]; }else { @@ -89,7 +91,8 @@ #Parse Location case "location": - if (array_key_exists($data, $location)) { + if (array_key_exists($data, $location)) + { return $location[substr($data,2,2)]; }else { @@ -99,7 +102,8 @@ #Parse Vehicle case "vehicle": - if (array_key_exists($data, $vehicle)) { + if (array_key_exists($data, $vehicle)) + { return $vehicle[substr($data,4,4)]; }else { @@ -109,9 +113,11 @@ #Parse direction case "direction": - if(substr($fms,9,1) == 1){ + if(substr($fms,9,1) == 1 + { return "L->F"; - }elseif(substr($fms,9,1) == 0){ + }elseif(substr($fms,9,1) == 0 + { return "F->L"; }else return "ERR!"; @@ -120,7 +126,8 @@ #Parse Zvei case "zvei": - if (array_key_exists($data, $zvei)) { + if (array_key_exists($data, $zvei)) + { return $data ." - ". $zvei[$data]; }else { From f4a0c59e63ecba985de095af7e12894ac3a4ac2c Mon Sep 17 00:00:00 2001 From: Schrolli Date: Wed, 8 Apr 2015 08:18:53 +0200 Subject: [PATCH 3/6] false comment sign in parser.php --- www/parser.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/www/parser.php b/www/parser.php index ac055af..4a11b25 100644 --- a/www/parser.php +++ b/www/parser.php @@ -4,6 +4,7 @@ function parse($mode, $data) { //Data for Service Parsing + $service = array( "0" => "Unbekannt", "1" => "Polizei", @@ -67,7 +68,7 @@ switch ($mode) { - #Parse Service + //Parse Service case "service": if (array_key_exists($data, $service)) { @@ -78,7 +79,7 @@ } break; - #Parse Country + //Parse Country case "country": if (array_key_exists($data, $country)) { @@ -89,7 +90,7 @@ } break; - #Parse Location + //Parse Location case "location": if (array_key_exists($data, $location)) { @@ -100,7 +101,7 @@ } break; - #Parse Vehicle + //Parse Vehicle case "vehicle": if (array_key_exists($data, $vehicle)) { @@ -111,7 +112,7 @@ } break; - #Parse direction + //Parse direction case "direction": if(substr($fms,9,1) == 1 { @@ -124,7 +125,7 @@ } break; - #Parse Zvei + //Parse Zvei case "zvei": if (array_key_exists($data, $zvei)) { From a137e958a0e4a237c4226698fc84dbe79f4741c3 Mon Sep 17 00:00:00 2001 From: Schrolli Date: Wed, 8 Apr 2015 08:24:02 +0200 Subject: [PATCH 4/6] edit readme --- README.md | 11 ++++++----- boswatch.py | 2 +- www/parser.php | 1 - 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 20c64b4..d113932 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![# BOSWatch](/www/gfx/logo.png) -Python Script to Recive and Decode German BOS Information with rtl_fm and multimon-NG +Python Script to receive and decode German BOS Information with rtl_fm and multimon-NG #### Note: **This software is for illustrative purposes only and may be used only by authorized persons.** @@ -19,9 +19,10 @@ unless you are developer you can use the develop-Branch - may be unstable! - FMS and ZVEI validation (plausibility test) - MySQL Database Support for FMS and ZVEI - simple HTTP request at alarm to URL you want -- All configurations in seperate File "config.ini" +- All configurations in seperate config File - simple Web Frontend with Data Parsing - Logfiles for better Troubleshooting +- verbose/quiet Mode for more/none information ##### Features for the Future: - extensive filtering options @@ -41,11 +42,11 @@ For the other Functions see "Usage" below. ##### Web Frontend Put the Files in Folder /wwww/ into your local Webserver Folder (/var/www/). Now you must edit the "config.php" with your Userdata to your local Database. +For the Parsing Functions take a look into the parser.php ### Usage -`sudo python boswatch.py -f 85.235M -a FMS ZVEI -s 50` +`sudo python boswatch.py -f 85.235M -a FMS ZVEI` Starts boswatch at Frequency 85.235 MHz with the Demodulation Functions FMS and ZVEI. -Squelch level is set to 50 Help to all usable Parameters with `sudo python boswatch.py -h` @@ -77,7 +78,7 @@ You can easy install BOSWatch with the install.sh Script. - And use the script `sudo sh install.sh` Now the script downloads and compile all needed data. -At the end you can find the Programm in `~/bos/BOSWatch` +At the end you can find BOSWatch in `~/bos/BOSWatch/` Caution, script don't install a Webserver with PHP and MySQL. So you have to make up manually if you want to use MySQL support. diff --git a/boswatch.py b/boswatch.py index 04242cf..42326cc 100644 --- a/boswatch.py +++ b/boswatch.py @@ -4,7 +4,7 @@ ##### Info ##### # BOSWatch # Autor: Bastian Schroll -# Python Script to Recive and Decode German BOS Information with rtl_fm and multimon-NG +# Python Script to receive and decode German BOS Information with rtl_fm and multimon-NG # For more Information see the README.md ##### Info ##### diff --git a/www/parser.php b/www/parser.php index 4a11b25..d557b6e 100644 --- a/www/parser.php +++ b/www/parser.php @@ -4,7 +4,6 @@ function parse($mode, $data) { //Data for Service Parsing - $service = array( "0" => "Unbekannt", "1" => "Polizei", From b5941529d3dfb901d9ea039c3dba3822d025d331 Mon Sep 17 00:00:00 2001 From: Schrolli Date: Wed, 8 Apr 2015 10:17:50 +0200 Subject: [PATCH 5/6] fix the parser.php --- www/parser.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/www/parser.php b/www/parser.php index d557b6e..4393f95 100644 --- a/www/parser.php +++ b/www/parser.php @@ -59,7 +59,7 @@ //Data for ZVEI Parsing - $country = array( + $zvei = array( "12345" => "testZvei", "23456" => "testZvei", "34567" => "testZvei", @@ -69,9 +69,10 @@ switch ($mode) { //Parse Service case "service": + $data = substr($data,0,1); if (array_key_exists($data, $service)) { - return $service[substr($data,0,1)]; + return $service[$data]; }else { return $data; @@ -80,9 +81,10 @@ //Parse Country case "country": + $data = substr($data,1,1); if (array_key_exists($data, $country)) { - return $country[substr($data,1,1)]; + return $country[$data]; }else { return $data; @@ -91,9 +93,10 @@ //Parse Location case "location": + $data = substr($data,2,2); if (array_key_exists($data, $location)) { - return $location[substr($data,2,2)]; + return $location[$data]; }else { return $data; @@ -102,9 +105,10 @@ //Parse Vehicle case "vehicle": + $data = substr($data,4,4); if (array_key_exists($data, $vehicle)) { - return $vehicle[substr($data,4,4)]; + return $vehicle[$data]; }else { return $data; @@ -113,13 +117,14 @@ //Parse direction case "direction": - if(substr($fms,9,1) == 1 + if (substr($data,9,1) == 1) { return "L->F"; - }elseif(substr($fms,9,1) == 0 + }elseif (substr($data,9,1) == 0) { return "F->L"; }else + { return "ERR!"; } break; From 0ffabe6b8064612b64255115872302f8c3666c8b Mon Sep 17 00:00:00 2001 From: Schrolli Date: Wed, 8 Apr 2015 10:31:27 +0200 Subject: [PATCH 6/6] insert headers for table --- www/index.php | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/www/index.php b/www/index.php index cf1a925..c0495ba 100644 --- a/www/index.php +++ b/www/index.php @@ -16,16 +16,26 @@ $db_link = mysqli_connect ($dbhost, $dbuser, $dbpassword, $database);
BOSWatch
- Last alarms for FMS and ZVEI (max. 50)

Last FMS alarms + + + + + + + + + + + + '; + while ($data = mysqli_fetch_array( $db_erg, MYSQL_ASSOC)) { @@ -45,17 +55,22 @@ $db_link = mysqli_connect ($dbhost, $dbuser, $dbpassword, $database); echo ""; echo ""; } - echo "
IDDatum - ZeitBOSBundeslandOrtFahrzeugStat.Richt.TKI
". $data['tsi'] . "
"; ?> +
Last ZVEI alarms + + + + + + '; + while ($data = mysqli_fetch_array( $db_erg, MYSQL_ASSOC)) { @@ -68,14 +83,10 @@ $db_link = mysqli_connect ($dbhost, $dbuser, $dbpassword, $database); echo ""; echo ""; } - echo "
IDDatum - ZeitSchleife
". parse('zvei',$data['zvei']) . "
"; ?> +
-

- (C) BOSWatch - All rights reserved -

-