From 3233be847c5d155147392a77be34b6e8c60aa608 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Wed, 8 Apr 2015 20:50:46 +0200 Subject: [PATCH 01/13] update readme --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d113932..86a1ba7 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,9 @@ 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.** - -**The intercept of the German BOS radio is strictly prohibited !!!** +#### Notice: +The intercept of the German BOS radio is **strictly prohibited** and will be prosecuted. the use is **only authorized** personnel permitted. +The software was developed using the Multimon-NG code, a function in the real operation can not be guaranteed. **Please** only use Code from **master**-Branch - thats **the only stable!** From 7aa9165ba2f8a5cc5a0c2eb2d3276fc12fd23496 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Wed, 8 Apr 2015 21:21:50 +0200 Subject: [PATCH 02/13] check and log the HTTP response --- boswatch.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/boswatch.py b/boswatch.py index 42326cc..8f1a9bf 100644 --- a/boswatch.py +++ b/boswatch.py @@ -20,6 +20,7 @@ import argparse #for parse the args import ConfigParser #for parse the config file import re #Regex for validation + # Functions def curtime(format="%Y-%m-%d %H:%M:%S"): return time.strftime(format) @@ -238,7 +239,7 @@ try: fms_time_old = timestamp #save last time if useMySQL: #only if MySQL is active - log("insert FMS into MySQL") + log("FMS to MySQL") try: connection = mysql.connector.connect(host = str(dbserver), user = str(dbuser), passwd = str(dbpassword), db = str(database)) cursor = connection.cursor() @@ -246,19 +247,22 @@ try: cursor.close() connection.commit() except: - log("FMS cannot insert into MySQL","error") + log("FMS to MySQL failed","error") finally: connection.close() #Close connection in every case if useHTTPrequest: #only if HTTPrequest is active - log("FMS to HTTP request") + log("FMS to HTTP") try: httprequest = httplib.HTTPConnection(url) httprequest.request("HEAD", "/") httpresponse = httprequest.getresponse() - #if args.verbose: print httpresponse.status, httpresponse.reason + if str(httpresponse.status) == "200": #Check HTTP Response an print a Log or Error + log("HTTP response: "+str(httpresponse.status)+" - "+str(httpresponse.reason)) + else: + log("HTTP response: "+str(httpresponse.status)+" - "+str(httpresponse.reason),"error") except: - log("FMS HTTP request failed","error") + log("FMS to HTTP failed","error") else: log("No valid FMS: "+fms_id) else: @@ -281,7 +285,7 @@ try: zvei_time_old = timestamp #save last time if useMySQL: #only if MySQL is active - log("insert ZVEI into MySQL") + log("ZVEI to MySQL") try: connection = mysql.connector.connect(host = str(dbserver), user = str(dbuser), passwd = str(dbpassword), db = str(database)) cursor = connection.cursor() @@ -289,22 +293,28 @@ try: cursor.close() connection.commit() except: - log("ZVEI cannot insert into MySQL","error") + log("ZVEI to MySQL failed","error") finally: connection.close() #Close connection in every case if useHTTPrequest: #only if HTTPrequest is active - log("ZVEI to HTTP request") + log("ZVEI to HTTP") try: httprequest = httplib.HTTPConnection(url) httprequest.request("HEAD", "/") httpresponse = httprequest.getresponse() - #if args.verbose: print httpresponse.status, httpresponse.reason + if str(httpresponse.status) == "200": #Check HTTP Response an print a Log or Error + log("HTTP response: "+str(httpresponse.status)+" - "+str(httpresponse.reason)) + else: + log("HTTP response: "+str(httpresponse.status)+" - "+str(httpresponse.reason),"error") + except: + log("ZVEI to HTTP failed","error") except: - log("ZVEI HTTP request failed","error") + log("ZVEI to HTTP failed","error") else: log("No valid ZVEI: "+zvei_id) + except KeyboardInterrupt: log("Keyboard Interrupt","error") except: From 3f2d2b85ab6a61fe40fc45c51621b20c67a41b6a Mon Sep 17 00:00:00 2001 From: Schrolli Date: Thu, 9 Apr 2015 13:23:40 +0200 Subject: [PATCH 03/13] prepare for small and simple template system --- www/content.overview.php | 19 ++++++++++++ www/template.overview.php | 64 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 www/content.overview.php create mode 100644 www/template.overview.php diff --git a/www/content.overview.php b/www/content.overview.php new file mode 100644 index 0000000..ca622b9 --- /dev/null +++ b/www/content.overview.php @@ -0,0 +1,19 @@ +query("SELECT id, time, service, country, location, vehicle, status, direction, tsi FROM ".$tableFMS." ORDER BY id DESC LIMIT 50"); + $Rows = array(); + while ($daten = $db->fetchAssoc()) + { + $Rows[] = $daten; + } + $tpl['fms'] = $Rows; + + //read ZVEI + $db->query("SELECT id, time, zvei FROM ".$tableZVEI." ORDER BY id DESC LIMIT 50"); + $Rows = array(); + while ($daten = $db->fetchAssoc()) + { + $Rows[] = $daten; + } + $tpl['zvei'] = $Rows; +?> \ No newline at end of file diff --git a/www/template.overview.php b/www/template.overview.php new file mode 100644 index 0000000..ca9287c --- /dev/null +++ b/www/template.overview.php @@ -0,0 +1,64 @@ +Last alarms for FMS and ZVEI (max. 50)

+ +
+ Last FMS alarms + + + + + + + + + + + + + "; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + ?> +
IDDatum - ZeitBOSBundeslandOrtFahrzeugStat.Richt.TKI
". $fms['id'] . "". $time . "". parse("service",$fms_id) . "". parse("country",$fms_id) . "". parse("location",$fms_id) . "". parse("vehicle",$fms_id) . "". $fms['status'] . "". parse("direction",$fms_id) . "". $fms['tsi'] . "
+
+ +
+ Last ZVEI alarms + + + + + + + "; + echo ""; + echo ""; + echo ""; + echo ""; + } + ?> +
IDDatum - ZeitSchleife
". $zvei['id'] . "". $time . "". parse('zvei',$zvei['zvei']) . "
+
\ No newline at end of file From f068a7592654c44b3bee6cf7076c0c52c76618a8 Mon Sep 17 00:00:00 2001 From: Schrolli Date: Thu, 9 Apr 2015 13:23:58 +0200 Subject: [PATCH 04/13] insert a mysql class --- www/mysql.class.php | 134 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 www/mysql.class.php diff --git a/www/mysql.class.php b/www/mysql.class.php new file mode 100644 index 0000000..9343fdd --- /dev/null +++ b/www/mysql.class.php @@ -0,0 +1,134 @@ +show_error = $show_error; + @$this->conn = mysql_connect($host, $user, $password); + if ($this->conn == false) + { + $this->error("Keine Verbindung zum Datenbank Server!", mysql_error()); + return false; + } + + if (!@mysql_select_db($database, $this->conn)) + { + $this->error("Datenbank nicht gefunden!", mysql_error()); + return false; + } + return true; + } + + /** + * Database::query() + * + * Führt einen MySQL Query aus + * + * @param mixed $query Auszuführender Query + * @return Result-Handler/FALSE + */ + function query($query) + { + $this->result = @mysql_query($query, $this->conn); + if ($this->result == false) + { + $this->error("Fehlerhafte Datenbank Anfrage!", mysql_error()); + return false; + } + return $this->result; + } + + /** + * Database::fetchAssoc() + * + * Liefert alle gefundnen Datensätze als Assoc + * + * @param mixed $result Externer Result-Handler + * @return gefundene Datensätze als Assoc + */ + function fetchAssoc($result = null) + { + if ($result != null) + { + return @mysql_fetch_assoc($result); + } else + { + return @mysql_fetch_assoc($this->result); + } + } + + /** + * Database::count() + * + * Zählt alle gefundenen Datensätze + * + * @param mixed $result Externer Result-Handler + * @return Anzahl gefundener Datensätze + */ + function count($result = null) + { + if ($result != null) + { + return @mysql_num_rows($result); + } else + { + return @mysql_num_rows($this->result); + } + } + + /** + * Database::closeConnection() + * + * Schließt die bestehende MySQL Verbindung + * + * @return TRUE/FALSE + */ + function closeConnection() + { + if (!@mysql_close($this->conn)) + { + $this->error("Verbindung zur Datenbank konnte nicht getrennt werden!", mysql_error()); + return false; + } + return true; + } + + /** + * Database::error() + * + * Gibt eine Interne Fehlermeldung aus + * + * @param mixed $error_msg Text der Fehlermeldung + * @param mixed $sql_err MySQL Fehlermeldung per mysql_error() + * @return NULL + */ + private function error($error_msg, $sql_err) + { + if ($this->show_error) + { + echo "
MySQL Error: $error_msg
$sql_err"; + return true; + //exit(); + } + } + +} ?> \ No newline at end of file From fef8c4c26503d5f46b10624e35b7fd07fc5a8146 Mon Sep 17 00:00:00 2001 From: Schrolli Date: Thu, 9 Apr 2015 13:24:15 +0200 Subject: [PATCH 05/13] use mysql class and template system --- www/index.php | 82 ++++++++++----------------------------------------- 1 file changed, 15 insertions(+), 67 deletions(-) diff --git a/www/index.php b/www/index.php index c0495ba..a817e2b 100644 --- a/www/index.php +++ b/www/index.php @@ -2,7 +2,9 @@ @@ -15,78 +17,24 @@ $db_link = mysqli_connect ($dbhost, $dbuser, $dbpassword, $database);
- BOSWatch
- Last alarms for FMS and ZVEI (max. 50)

+ BOSWatch
+ [Übersicht] - [Parser] -
- Last FMS alarms - - - - - - - - - - - - -
+ "; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + include("content.overview.php"); + include("template.overview.php"); } - ?> -
IDDatum - ZeitBOSBundeslandOrtFahrzeugStat.Richt.TKI
". $data['id'] . "". $time . "". parse("service",$fms_id) . "". parse("country",$fms_id) . "". parse("location",$fms_id) . "". parse("vehicle",$fms_id) . "". $data['status'] . "". parse("direction",$fms_id) . "". $data['tsi'] . "
-
- -
- Last ZVEI alarms - - - - - - - "; - echo ""; - echo ""; - echo ""; - echo ""; + include("content.overview.php"); + include("template.overview.php"); } - ?> -
IDDatum - ZeitSchleife
". $data['id'] . "". $time . "". parse('zvei',$data['zvei']) . "
-
+ ?>
From b7a5439dd3bee4553b8d2a0bdf3e698dde0226ca Mon Sep 17 00:00:00 2001 From: Schrolli Date: Thu, 9 Apr 2015 13:34:52 +0200 Subject: [PATCH 06/13] insert the empty parser page --- www/content.parser.php | 3 +++ www/index.php | 5 +++++ www/template.parser.php | 0 3 files changed, 8 insertions(+) create mode 100644 www/content.parser.php create mode 100644 www/template.parser.php diff --git a/www/content.parser.php b/www/content.parser.php new file mode 100644 index 0000000..15c5adc --- /dev/null +++ b/www/content.parser.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/www/index.php b/www/index.php index a817e2b..d80247c 100644 --- a/www/index.php +++ b/www/index.php @@ -28,6 +28,11 @@ $db = new Database($dbhost, $dbuser, $dbpassword, $database, 1); //Show Error = include("content.overview.php"); include("template.overview.php"); } + elseif(isset($_GET['parser'])) + { + include("content.parser.php"); + include("template.parser.php"); + } else { include("content.overview.php"); diff --git a/www/template.parser.php b/www/template.parser.php new file mode 100644 index 0000000..e69de29 From 57245374ff75061c16d12f4c65cd5788a19d28a9 Mon Sep 17 00:00:00 2001 From: Schrolli Date: Fri, 10 Apr 2015 07:12:48 +0200 Subject: [PATCH 07/13] alls 8 FMS blocks to one --- boswatch.py | 4 ++-- boswatch.sql | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/boswatch.py b/boswatch.py index 8f1a9bf..f371907 100644 --- a/boswatch.py +++ b/boswatch.py @@ -234,7 +234,7 @@ try: log("FMS double alarm: "+fms_id_old) fms_time_old = timestamp #in case of double alarm, fms_double_ignore_time set new else: - log("BOS:"+fms_service+" Bundesland:"+fms_country+" Ort:"+fms_location+" Fahrzeug:"+fms_vehicle+" Status:"+fms_status+" Richtung:"+fms_direction+" TKI:"+fms_tsi,"info") + log("FMS:"+fms_id[0:8]+" Status:"+fms_status+" Richtung:"+fms_direction+" TKI:"+fms_tsi,"info") fms_id_old = fms_id #save last id fms_time_old = timestamp #save last time @@ -243,7 +243,7 @@ try: try: connection = mysql.connector.connect(host = str(dbserver), user = str(dbuser), passwd = str(dbpassword), db = str(database)) cursor = connection.cursor() - cursor.execute("INSERT INTO "+tableFMS+" (time,service,country,location,vehicle,status,direction,tsi) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)",(curtime(),fms_service,fms_country,fms_location,fms_vehicle,fms_status,fms_direction,fms_tsi)) + cursor.execute("INSERT INTO "+tableFMS+" (time,fms,status,direction,tsi) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)",(curtime(),fms_id[0:8],fms_status,fms_direction,fms_tsi)) cursor.close() connection.commit() except: diff --git a/boswatch.sql b/boswatch.sql index 489eecd..735804b 100644 --- a/boswatch.sql +++ b/boswatch.sql @@ -29,10 +29,7 @@ SET time_zone = "+00:00"; CREATE TABLE IF NOT EXISTS `bos_fms` ( `id` int(11) NOT NULL AUTO_INCREMENT, `time` datetime NOT NULL, - `service` varchar(1) NOT NULL, - `country` varchar(2) NOT NULL, - `location` varchar(2) NOT NULL, - `vehicle` varchar(4) NOT NULL, + `fms` varchar(8) NOT NULL, `status` varchar(1) NOT NULL, `direction` varchar(1) NOT NULL, `tsi` varchar(3) NOT NULL, From 49fa43bd5450a2ca9a0e6039e707008d29b289b1 Mon Sep 17 00:00:00 2001 From: Schrolli Date: Fri, 10 Apr 2015 07:16:56 +0200 Subject: [PATCH 08/13] all 8 FMS blocks to one in webend --- www/parser.php | 148 -------------------------------------- www/template.overview.php | 15 ++-- 2 files changed, 4 insertions(+), 159 deletions(-) delete mode 100644 www/parser.php diff --git a/www/parser.php b/www/parser.php deleted file mode 100644 index 4393f95..0000000 --- a/www/parser.php +++ /dev/null @@ -1,148 +0,0 @@ - "Unbekannt", - "1" => "Polizei", - "2" => "Bundesgrenzschutz", - "3" => "Bundeskriminalamt", - "4" => "Katastrophenschutz", - "5" => "Zoll", - "6" => "Feuerwehr", - "7" => "Technisches Hilfswerk", - "8" => "Arbeiter-Samariter-Bund", - "9" => "Deutsches Rotes Kreuz", - "a" => "Johanniter-Unfall-Hilfe", - "b" => "Malteser-Hilfsdienst", - "c" => "Deutsche Lebensrettungsgesellschaft", - "d" => "Rettungsdienst", - "e" => "Zivilschutz", - "f" => "Fernwirktelegramm", - ); - - //Data for Country Parsing - $country = array( - "0" => "Sachsen", - "1" => "Bund", - "2" => "Baden-Württemberg", - "3" => "Bayern I", - "4" => "Berlin", - "5" => "Bremen", - "6" => "Hamburg", - "7" => "Hessen", - "8" => "Niedersachsen", - "9" => "Nordrhein-Westfalen", - "a" => "Rheinland-Pflaz", - "b" => "Schleswig-Holstein", - "c" => "Saarland", - "d" => "Bayern II", - "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 - $zvei = array( - "12345" => "testZvei", - "23456" => "testZvei", - "34567" => "testZvei", - ); - - - switch ($mode) { - //Parse Service - case "service": - $data = substr($data,0,1); - if (array_key_exists($data, $service)) - { - return $service[$data]; - }else - { - return $data; - } - break; - - //Parse Country - case "country": - $data = substr($data,1,1); - if (array_key_exists($data, $country)) - { - return $country[$data]; - }else - { - return $data; - } - break; - - //Parse Location - case "location": - $data = substr($data,2,2); - if (array_key_exists($data, $location)) - { - return $location[$data]; - }else - { - return $data; - } - break; - - //Parse Vehicle - case "vehicle": - $data = substr($data,4,4); - if (array_key_exists($data, $vehicle)) - { - return $vehicle[$data]; - }else - { - return $data; - } - break; - - //Parse direction - case "direction": - if (substr($data,9,1) == 1) - { - return "L->F"; - }elseif (substr($data,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; - - default: - return "Parser: mode error!"; - } - } - -?> \ No newline at end of file diff --git a/www/template.overview.php b/www/template.overview.php index ca9287c..e1c973a 100644 --- a/www/template.overview.php +++ b/www/template.overview.php @@ -6,10 +6,7 @@ Last alarms for FMS and ZVEI (max. 50)

ID Datum - Zeit - BOS - Bundesland - Ort - Fahrzeug + FMS Stat. Richt. TKI @@ -21,16 +18,12 @@ Last alarms for FMS and ZVEI (max. 50)

$time = strtotime($fms['time']); $time = date("d.m.Y H:i:s", $time); - $fms_id = $fms['service'].$fms['country'].$fms['location'].$fms['vehicle'].$fms['status'].$fms['direction']; echo ""; echo "". $fms['id'] . ""; echo "". $time . ""; - echo "". parse("service",$fms_id) . ""; - echo "". parse("country",$fms_id) . ""; - echo "". parse("location",$fms_id) . ""; - echo "". parse("vehicle",$fms_id) . ""; + echo "". $fms['fms'] . ""; echo "". $fms['status'] . ""; - echo "". parse("direction",$fms_id) . ""; + echo "". $fms['direction'] . ""; echo "". $fms['tsi'] . ""; echo ""; } @@ -56,7 +49,7 @@ Last alarms for FMS and ZVEI (max. 50)

echo ""; echo "". $zvei['id'] . ""; echo "". $time . ""; - echo "". parse('zvei',$zvei['zvei']) . ""; + echo "". $zvei['zvei'] . ""; echo ""; } ?> From 0bb92fafaccc868f1bcb234f8d7ad717ccfc007c Mon Sep 17 00:00:00 2001 From: Schrolli Date: Fri, 10 Apr 2015 07:43:00 +0200 Subject: [PATCH 09/13] move template files in own folder --- www/index.php | 12 +-- www/parser.php | 111 ++++++++++++++++++++++++++++ www/{ => tpl}/content.overview.php | 0 www/{ => tpl}/content.parser.php | 0 www/{ => tpl}/template.overview.php | 0 www/{ => tpl}/template.parser.php | 0 6 files changed, 117 insertions(+), 6 deletions(-) create mode 100644 www/parser.php rename www/{ => tpl}/content.overview.php (100%) rename www/{ => tpl}/content.parser.php (100%) rename www/{ => tpl}/template.overview.php (100%) rename www/{ => tpl}/template.parser.php (100%) diff --git a/www/index.php b/www/index.php index d80247c..e7146ec 100644 --- a/www/index.php +++ b/www/index.php @@ -25,18 +25,18 @@ $db = new Database($dbhost, $dbuser, $dbpassword, $database, 1); //Show Error = if(isset($_GET['overview'])) { - include("content.overview.php"); - include("template.overview.php"); + include("tpl/content.overview.php"); + include("tpl/template.overview.php"); } elseif(isset($_GET['parser'])) { - include("content.parser.php"); - include("template.parser.php"); + include("tpl/content.parser.php"); + include("tpl/template.parser.php"); } else { - include("content.overview.php"); - include("template.overview.php"); + include("tpl/content.overview.php"); + include("tpl/template.overview.php"); } ?> diff --git a/www/parser.php b/www/parser.php new file mode 100644 index 0000000..37bb708 --- /dev/null +++ b/www/parser.php @@ -0,0 +1,111 @@ + "Unbekannt", + "1" => "Polizei", + "2" => "Bundesgrenzschutz", + "3" => "Bundeskriminalamt", + "4" => "Katastrophenschutz", + "5" => "Zoll", + "6" => "Feuerwehr", + "7" => "Technisches Hilfswerk", + "8" => "Arbeiter-Samariter-Bund", + "9" => "Deutsches Rotes Kreuz", + "a" => "Johanniter-Unfall-Hilfe", + "b" => "Malteser-Hilfsdienst", + "c" => "Deutsche Lebensrettungsgesellschaft", + "d" => "Rettungsdienst", + "e" => "Zivilschutz", + "f" => "Fernwirktelegramm", + ); + + //Data for Country Parsing + $country = array( + "0" => "Sachsen", + "1" => "Bund", + "2" => "Baden-Württemberg", + "3" => "Bayern I", + "4" => "Berlin", + "5" => "Bremen", + "6" => "Hamburg", + "7" => "Hessen", + "8" => "Niedersachsen", + "9" => "Nordrhein-Westfalen", + "a" => "Rheinland-Pflaz", + "b" => "Schleswig-Holstein", + "c" => "Saarland", + "d" => "Bayern II", + "e" => "Meck-Pom/Sachsen-Anhalt", + "f" => "Brandenburg/Thüringen", + ); + + + //Data for ZVEI Parsing + $zvei = array( + "12345" => "testZvei", + "23456" => "testZvei", + "34567" => "testZvei", + ); + + + switch ($mode) { + //Parse Service + case "service": + $data = substr($data,0,1); + if (array_key_exists($data, $service)) + { + return $service[$data]; + }else + { + return $data; + } + break; + + //Parse Country + case "country": + $data = substr($data,1,1); + if (array_key_exists($data, $country)) + { + return $country[$data]; + }else + { + return $data; + } + break; + + //Parse direction + case "direction": + if (substr($data,9,1) == 1) + { + return "L->F"; + }elseif (substr($data,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; + + default: + return "Parser: mode error!"; + } + } + +?> \ No newline at end of file diff --git a/www/content.overview.php b/www/tpl/content.overview.php similarity index 100% rename from www/content.overview.php rename to www/tpl/content.overview.php diff --git a/www/content.parser.php b/www/tpl/content.parser.php similarity index 100% rename from www/content.parser.php rename to www/tpl/content.parser.php diff --git a/www/template.overview.php b/www/tpl/template.overview.php similarity index 100% rename from www/template.overview.php rename to www/tpl/template.overview.php diff --git a/www/template.parser.php b/www/tpl/template.parser.php similarity index 100% rename from www/template.parser.php rename to www/tpl/template.parser.php From 6c31238a78292d13624fbe9993ad51533e63ca8d Mon Sep 17 00:00:00 2001 From: Schrolli Date: Fri, 10 Apr 2015 07:46:26 +0200 Subject: [PATCH 10/13] edit FMS validation --- boswatch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boswatch.py b/boswatch.py index f371907..e04ebdf 100644 --- a/boswatch.py +++ b/boswatch.py @@ -229,7 +229,7 @@ try: if "CRC correct" in decoded: #check CRC is correct fms_id = fms_service+fms_country+fms_location+fms_vehicle+fms_status+fms_direction #build FMS id - if re.search("[0-9a-f]{2}[0-9]{6}[0-9a-f]{1}[01]{1}", fms_id): #if FMS is valid + if re.search("[0-9a-f]{5}[0-9]{3}[0-9a-f]{1}[01]{1}", fms_id): #if FMS is valid if fms_id == fms_id_old and timestamp < fms_time_old + fms_double_ignore_time: #check for double alarm log("FMS double alarm: "+fms_id_old) fms_time_old = timestamp #in case of double alarm, fms_double_ignore_time set new From 67103eb0b524365cec352733e0617baf4e4b8bba Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Sat, 11 Apr 2015 17:10:55 +0200 Subject: [PATCH 11/13] edit FMS validation the first 8 blocks 0-9 and a-f --- boswatch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boswatch.py b/boswatch.py index e04ebdf..ff20a6d 100644 --- a/boswatch.py +++ b/boswatch.py @@ -229,7 +229,7 @@ try: if "CRC correct" in decoded: #check CRC is correct fms_id = fms_service+fms_country+fms_location+fms_vehicle+fms_status+fms_direction #build FMS id - if re.search("[0-9a-f]{5}[0-9]{3}[0-9a-f]{1}[01]{1}", fms_id): #if FMS is valid + if re.search("[0-9a-f]{8}[0-9a-f]{1}[01]{1}", fms_id): #if FMS is valid if fms_id == fms_id_old and timestamp < fms_time_old + fms_double_ignore_time: #check for double alarm log("FMS double alarm: "+fms_id_old) fms_time_old = timestamp #in case of double alarm, fms_double_ignore_time set new From 84892c09e09d4a4a733d9ed1f361181203725580 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Sat, 11 Apr 2015 20:28:07 +0200 Subject: [PATCH 12/13] fixed little errors --- boswatch.py | 2 -- www/tpl/content.overview.php | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/boswatch.py b/boswatch.py index ff20a6d..0b5ed13 100644 --- a/boswatch.py +++ b/boswatch.py @@ -307,8 +307,6 @@ try: log("HTTP response: "+str(httpresponse.status)+" - "+str(httpresponse.reason)) else: log("HTTP response: "+str(httpresponse.status)+" - "+str(httpresponse.reason),"error") - except: - log("ZVEI to HTTP failed","error") except: log("ZVEI to HTTP failed","error") else: diff --git a/www/tpl/content.overview.php b/www/tpl/content.overview.php index ca622b9..8d2f141 100644 --- a/www/tpl/content.overview.php +++ b/www/tpl/content.overview.php @@ -1,6 +1,6 @@ query("SELECT id, time, service, country, location, vehicle, status, direction, tsi FROM ".$tableFMS." ORDER BY id DESC LIMIT 50"); + $db->query("SELECT id, time, fms, status, direction, tsi FROM ".$tableFMS." ORDER BY id DESC LIMIT 50"); $Rows = array(); while ($daten = $db->fetchAssoc()) { From 80833396586fc67ff2fcae493ce87ed237077dca Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Sat, 11 Apr 2015 20:49:31 +0200 Subject: [PATCH 13/13] litte error in FMS MySQL --- boswatch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boswatch.py b/boswatch.py index 0b5ed13..de771e1 100644 --- a/boswatch.py +++ b/boswatch.py @@ -243,7 +243,7 @@ try: try: connection = mysql.connector.connect(host = str(dbserver), user = str(dbuser), passwd = str(dbpassword), db = str(database)) cursor = connection.cursor() - cursor.execute("INSERT INTO "+tableFMS+" (time,fms,status,direction,tsi) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)",(curtime(),fms_id[0:8],fms_status,fms_direction,fms_tsi)) + cursor.execute("INSERT INTO "+tableFMS+" (time,fms,status,direction,tsi) VALUES (%s,%s,%s,%s,%s)",(curtime(),fms_id[0:8],fms_status,fms_direction,fms_tsi)) cursor.close() connection.commit() except: