Merge pull request #304 from Schrolli91/develop

new release
This commit is contained in:
Bastian Schroll 2017-09-19 17:59:55 +02:00 committed by GitHub
commit 84b944348e
36 changed files with 424 additions and 310 deletions

26
CHANGELOG.md Normal file
View file

@ -0,0 +1,26 @@
# Changelog
#### __[v2.2.1]__ - 19.09.2017
##### Added
- Neues Service Script
- Eigene Message fpr jeden Typ im Telegram Plugin
##### Changed
- Name der csv Dateien um überschreiben bei Update zu vermeiden
- Description Liste kann nun zusätzlich Einträge für jede Subric enthalten
- RegEX verbietet nun grundsätzlich alles - Es muss explizit zugelassen werden
##### Deprecated
##### Removed
##### Fixed
- Bug im SMS77 Plugin
##### Security
----------------------------
Zum schreiben des Changelog's siehe:
http://keepachangelog.com/de/1.0.0/

View file

@ -46,7 +46,7 @@ unless you are developer you can use the develop-Branch - may be unstable!
- other Ideas per Issues please
###Plugins
### Plugins
If you want to code your own Plugin, see `plugins/README.md`.
##### Implemented plugins:
@ -81,7 +81,7 @@ For the other functions see "Usage" below.
For the RegEX filter functions see Section `[Filters]`
http://www.regexr.com/ - RegEX test tool an documentation
No filter for a combination typ/plugin = all data will pass
If RegEX is enabled - only alloewd data will pass !
Syntax: `INDIVIDUAL_NAME = TYP;DATAFIELD;PLUGIN;FREQUENZ;REGEX` (separator `;`)
- `TYP` = the data typ (FMS|ZVEI|POC)

View file

@ -49,7 +49,7 @@ doubleFilter_ignore_time = 5
doubleFilter_check_msg = 0
# writes the multimon-ng raw data stream into a text file named mm_raw.txt
writeMultimonRaw = 1
writeMultimonRaw = 0
[NMAHandler]
# you can use a logging handler for sending logging records to NotifyMyAndroid
@ -169,6 +169,8 @@ tableSIG = bos_signal
[httpRequest]
# example URL http://example.com/remote.php?DESCR=%DESCR%
# multiple URLs can be separated by comma
# you can use the following wildcards in your URL as GET params:
# http://en.wikipedia.org/wiki/Query_string
@ -413,13 +415,46 @@ RICforLocationAPIKey =
# Required if you want to create a map based on location information received with the above RIC.
GoogleAPIKey =
# %FMS% = FMS Code
# %STATUS% = FMS Status
# %DIR% = Direction of the telegram (0/1)
# %DIRT% = Direction of the telegram (Text-String)
# %TSI% = Tactical Short Information (I-IV)
# %DESCR% = Description, if description-module is used
# %DATE% = Date (by script)
# %TIME% = Time (by script)
# %LPAR% = (
# %RPAR% = )
FMS_message = %DATE% %TIME%: %FMS%
# %ZVEI% = ZVEI 5-tone Code
# %DESCR% = Description, if description-module is used
# %DATE% = Date (by script)
# %TIME% = Time (by script)
# %LPAR% = (
# %RPAR% = )
ZVEI_message = %DATE% %TIME%: %ZVEI%
# %RIC% = POCSAG RIC
# %FUNC% = POCSAG function/Subric (1-4)
# %FUNCCHAR% = POCSAG function/Subric als character (a-d)
# %MSG% = Message of the POCSAG telegram
# %BITRATE% = Bitrate of the POCSAG telegram
# %DESCR% = Description, if description-module is used
# %DATE% = Date (by script)
# %TIME% = Time (by script)
# %LPAR% = (
# %RPAR% = )
POC_message = %MSG%
[yowsup]
# number or chat-number who whants to become the news
empfaenger =
empfaenger =
# WhatsApp-number of that the news comes
sender =
sender =
# password from this number
password=
password=
# %FMS% = FMS Code
# %STATUS% = FMS Status

View file

Can't render this file because it has a wrong number of fields in line 2.

View file

Can't render this file because it has a wrong number of fields in line 2.

View file

Can't render this file because it has a wrong number of fields in line 2.

View file

Can't render this file because it has a wrong number of fields in line 2.

View file

@ -36,7 +36,7 @@ CREATE TABLE `login` (
LOCK TABLES `login` WRITE;
/*!40000 ALTER TABLE `login` DISABLE KEYS */;
INSERT INTO `login` VALUES ,(1,'Test','098f6bcd4621d373cade4e832627b4f6');
INSERT INTO `login` VALUES (1,'admin',md5('admin'));
/*!40000 ALTER TABLE `login` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

View file

@ -1,8 +1,8 @@
<?php
$dbhost = "localhost";
$dbuser = "USERNAME";
$dbpassword = "PASSWORD";
$dbuser = "boswatch";
$dbpassword = "boswatch";
$database = "boswatch";
$tableFMS = "bos_fms";

View file

@ -0,0 +1,57 @@
<?php
session_start();
?>
<?php
if(($_SESSION["username"])!="admin")
{
echo "Sie sind nicht berechtigt fuer diesen Bereich";
exit;
}
?>
<?php
@require_once("config.php");
$verbindung = mysqli_connect($dbhost, $dbuser , $dbpassword, $database)
or die("Verbindung zur Datenbank konnte nicht hergestellt werden");
$username = $_POST["username"];
$passwort = $_POST["passwort"];
$passwort2 = $_POST["passwort2"];
if($passwort != $passwort2 OR $username == "" OR $passwort == "")
{
echo "Eingabefehler. Bitte alle Felder korekt ausfüllen. <a href=\"eintragen.html\">Zurück</a>";
exit;
}
$passwort = md5($passwort);
$result = mysqli_query($verbindung, "SELECT id FROM login WHERE username LIKE '$username'");
$menge = mysqli_num_rows($result);
if($menge == 0)
{
$eintrag = "INSERT INTO login (username, passwort) VALUES ('$username', '$passwort')";
$eintragen = mysqli_query($verbindung, $eintrag);
if($eintragen == true)
{
echo "Benutzername <b>$username</b> wurde erstellt. <a href=\"index.php\">Login</a>";
}
else
{
echo "Fehler beim Speichern des Benutzernames. <a href=\"eintragen.html\">Zurück</a>";
}
}
else
{
echo "Benutzername schon vorhanden. <a href=\"eintragen.html\">Zurück</a>";
}
?>

View file

@ -1,111 +0,0 @@
<!DOCTYPE HTML>
<!--
Escape Velocity by HTML5 UP
html5up.net | @n33co
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<?php
session_start();
?>
<?php
if(!isset($_SESSION["username"]))
{
echo "Bitte erst <a href=\"login.html\">einloggen</a>";
exit;
}
?>
<?php
require_once ("config.php");
require_once ("tpl/parser.php");
require_once ("tpl/mysql.class.php");
$db = new Database($dbhost, $dbuser, $dbpassword, $database, 1); //Show Error = 1!
?>
<html>
<head>
<title>BOSwatch</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<!--[if lte IE 8]><script src="css/ie/html5shiv.js"></script><![endif]-->
<script src="js/jquery.min.js"></script>
<script src="js/jquery.dropotron.min.js"></script>
<script src="js/skel.min.js"></script>
<script src="js/skel-layers.min.js"></script>
<script src="js/init.js"></script>
<noscript>
<link rel="stylesheet" href="css/skel.css" />
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/style-desktop.css" />
</noscript>
<!--[if lte IE 8]><link rel="stylesheet" href="css/ie/v8.css" /><![endif]-->
</head>
<body class="no-sidebar">
<!-- Header -->
<div id="header-wrapper" class="wrapper">
<div id="header">
<!-- Nav -->
<nav id="nav">
<ul>
<li><a href="show_pocsag.php">POCSAG</a></li>
<li><a href="show_fms.php">FMS</a></li>
<li><a href="show_zvei.php">ZVEI</a></li>
<li><a href="prefs.php">Einstellungen</a></li>
<li><a href="eintragen.html">Nutzer anlegen</a></li>
</ul>
</nav>
</div>
</div>
<!-- Highlights -->
<div class="wrapper style1">
<div class="title">Usermanagment</div>
<div class="container">
<div style="width: 400px;margin-left:auto;margin-right:auto;text-align:center;">
<form action="eintragen.php" method="post">
Username:<br>
<input type="text" size="12"
name="username"><br>
Passwort:<br>
<input type="password" size="24" maxlength="50"
name="passwort"><br>
Passwort wiederholen:<br>
<input type="password" size="24" maxlength="50"
name="passwort2"><br>
<input type="submit" value="Abschicken">
</form>
</div>
</div>
</div>
</div>
</div>
<div id="copyright">
<ul>
<li style="color:grey;">&copy; BOSWatch</li><li style="color:grey;">Design: <a href="http://html5up.net">HTML5 UP</a></li>
</ul>
</div>
</div>
</body>
</html>

View file

@ -1,58 +1,111 @@
<!DOCTYPE HTML>
<!--
Escape Velocity by HTML5 UP
html5up.net | @n33co
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<?php
session_start();
?>
<?php
if(($_SESSION["username"])!="Kevin")
if(!isset($_SESSION["username"]))
{
echo "Sie sind nicht berechtigt fuer diesen Bereich";
echo "Bitte erst <a href='login.html'>einloggen</a>";
exit;
}
?>
<?php
require_once ("config.php");
require_once ("tpl/parser.php");
<?php
$verbindung = mysql_connect("localhost", "root" , "kevin21")
or die("Verbindung zur Datenbank konnte nicht hergestellt werden");
mysql_select_db("login") or die ("Datenbank konnte nicht ausgewählt werden");
$username = $_POST["username"];
$passwort = $_POST["passwort"];
$passwort2 = $_POST["passwort2"];
if($passwort != $passwort2 OR $username == "" OR $passwort == "")
{
echo "Eingabefehler. Bitte alle Felder korekt ausfüllen. <a href=\"eintragen.html\">Zurück</a>";
exit;
}
$passwort = md5($passwort);
$result = mysql_query("SELECT id FROM login WHERE username LIKE '$username'");
$menge = mysql_num_rows($result);
if($menge == 0)
{
$eintrag = "INSERT INTO login (username, passwort) VALUES ('$username', '$passwort')";
$eintragen = mysql_query($eintrag);
if($eintragen == true)
{
echo "Benutzername <b>$username</b> wurde erstellt. <a href=\"login.html\">Login</a>";
}
else
{
echo "Fehler beim Speichern des Benutzernames. <a href=\"eintragen.html\">Zurück</a>";
}
}
else
{
echo "Benutzername schon vorhanden. <a href=\"eintragen.html\">Zurück</a>";
}
require_once ("tpl/mysql.class.php");
$db = new Database($dbhost, $dbuser, $dbpassword, $database, 1); //Show Error = 1!
?>
<html>
<head>
<title>BOSwatch</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<!--[if lte IE 8]><script src="css/ie/html5shiv.js"></script><![endif]-->
<script src="js/jquery.min.js"></script>
<script src="js/jquery.dropotron.min.js"></script>
<script src="js/skel.min.js"></script>
<script src="js/skel-layers.min.js"></script>
<script src="js/init.js"></script>
<noscript>
<link rel="stylesheet" href="css/skel.css" />
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/style-desktop.css" />
</noscript>
<!--[if lte IE 8]><link rel="stylesheet" href="css/ie/v8.css" /><![endif]-->
</head>
<body class="no-sidebar">
<!-- Header -->
<div id="header-wrapper" class="wrapper">
<div id="header">
<!-- Nav -->
<nav id="nav">
<ul>
<li><a href="show_pocsag.php">POCSAG</a></li>
<li><a href="show_fms.php">FMS</a></li>
<li><a href="show_zvei.php">ZVEI</a></li>
<li><a href="prefs.php">Einstellungen</a></li>
<li><a href="eintragen.php">Nutzer anlegen</a></li>
</ul>
</nav>
</div>
</div>
<!-- Highlights -->
<div class="wrapper style1">
<div class="title">Usermanagment</div>
<div class="container">
<div style="width: 400px;margin-left:auto;margin-right:auto;text-align:center;">
<form action="do_eintragen.php" method="post">
Username:<br>
<input type="text" size="12"
name="username"><br>
Passwort:<br>
<input type="password" size="24" maxlength="50"
name="passwort"><br>
Passwort wiederholen:<br>
<input type="password" size="24" maxlength="50"
name="passwort2"><br>
<input type="submit" value="Abschicken">
</form>
</div>
</div>
</div>
</div>
</div>
<div id="copyright">
<ul>
<li style="color:grey;">&copy; BOSWatch</li><li style="color:grey;">Design: <a href="http://html5up.net">HTML5 UP</a></li>
</ul>
</div>
</div>
</body>
</html>

View file

@ -40,7 +40,7 @@ $db = new Database($dbhost, $dbuser, $dbpassword, $database, 1); //Show Error =
<!-- Logo -->
<div id="logo">
<h1><a href="index.html">Willkommen bei BOSWatch</a></h1>
<h1><a href="index.php">Willkommen bei BOSWatch</a></h1>
</div>
<!-- Nav -->
@ -75,6 +75,14 @@ Dein Passwort:<br>
<input type="password" size="24" maxlength="50"
name="password"><br>
Startanzeige:<br>
<select name="view">
<option value="pocsag">POCSAG</option>
<option value="fms">FMS</option>
<option value="zvei">ZVEI</option>
</select><br>
<input type="submit" value="Login">
</form>
@ -100,4 +108,4 @@ name="password"><br>
</div>
</body>
</html>
</html>

View file

@ -4,25 +4,44 @@ session_start();
<?php
require_once ("config.php");
$verbindung = mysql_connect($dbhost, $dbuser , $dbpassword)
$verbindung = mysqli_connect($dbhost, $dbuser , $dbpassword)
or die("Verbindung zur Datenbank konnte nicht hergestellt werden");
mysql_select_db($tableLOG) or die ("Datenbank konnte nicht ausgewählt werden");
mysqli_select_db($verbindung, $database) or die ("Datenbank konnte nicht ausgewählt werden");
if (!isset($_POST["username"]) XOR !isset($_POST["password"]))
{
echo "Fehlende Eingaben - <a href='index.php'>Login</a>";
exit;
}
$username = $_POST["username"];
$passwort = md5($_POST["password"]);
$abfrage = "SELECT username, passwort FROM" $tableLOG "WHERE username LIKE '$username' LIMIT 1";
$ergebnis = mysql_query($abfrage);
$row = mysql_fetch_object($ergebnis);
$abfrage = "SELECT username, passwort FROM ".$tableLOG." WHERE username LIKE '$username' LIMIT 1";
$ergebnis = mysqli_query($verbindung, $abfrage);
$row = mysqli_fetch_object($ergebnis);
if($row->passwort == $passwort)
{
$_SESSION["username"] = $username;
header("Location: /show_pocsag.php");
switch ($_POST["view"]) {
case 'pocsag':
header("Location: show_pocsag.php");
break;
case 'zvei':
header("Location: show_zvei.php");
break;
case 'fms':
header("Location: show_fms.php");
break;
default:
header("Location: show_pocsag.php");
}
}
else
{
echo "Benutzername und/oder Passwort waren falsch. <a href=\"login.html\">Login</a>";
echo "Benutzername und/oder Passwort waren falsch. <a href=\"index.php\">Login</a>";
}
?>

View file

@ -0,0 +1,6 @@
<?php
session_unset();
header("Location: index.php");
?>

View file

@ -11,7 +11,7 @@ session_start();
?>
<?php
if(($_SESSION["username"])!="Test")
if(($_SESSION["username"])!="admin")
{
echo "Sie sind nicht berechtigt fuer diesen Bereich";
exit;
@ -27,7 +27,7 @@ include("tpl/a_header.php");
<div class="wrapper style3">
<div class="title">Einstellungen</div>
<div id="highlights" class="container" style="">
<!--
<tr>
<td>Filter Range Start:</td><td>
<input type="text" size="24" maxlength="50" value="
@ -43,7 +43,7 @@ $ini_array = parse_ini_file("config.ini");
echo($ini_array['filter_range_end']);
?>
"></td>
</tr>
</tr>-->
</div>
</div>
@ -60,4 +60,4 @@ echo($ini_array['filter_range_end']);
</div>
</body>
</html>
</html>

View file

@ -41,7 +41,8 @@
<li><a href="show_fms.php">FMS</a></li>
<li><a href="show_zvei.php">ZVEI</a></li>
<li><a href="prefs.php">Einstellungen</a></li>
<li><a href="eintragen.html">Nutzer anlegen</a></li>
<li><a href="eintragen.php">Nutzer anlegen</a></li>
<li><a href="logout.php">Ausloggen</a></li>
</ul>
</nav>

View file

@ -23,16 +23,16 @@ Simple Database Class (C) by Bastian Schroll
function __construct($host, $user, $password, $database, $show_error = 1)
{
$this->show_error = $show_error;
@$this->conn = mysql_connect($host, $user, $password);
@$this->conn = mysqli_connect($host, $user, $password);
if ($this->conn == false)
{
$this->error("Keine Verbindung zum Datenbank Server!", mysql_error());
$this->error("Keine Verbindung zum Datenbank Server!", mysqli_error($this->conn));
return false;
}
if (!@mysql_select_db($database, $this->conn))
if (!@mysqli_select_db($this->conn, $database))
{
$this->error("Datenbank nicht gefunden!", mysql_error());
$this->error("Datenbank nicht gefunden!", mysqli_error($this->conn));
return false;
}
return true;
@ -48,10 +48,10 @@ Simple Database Class (C) by Bastian Schroll
*/
function query($query)
{
$this->result = @mysql_query($query, $this->conn);
$this->result = @mysqli_query($this->conn, $query);
if ($this->result == false)
{
$this->error("Fehlerhafte Datenbank Anfrage!", mysql_error());
$this->error("Fehlerhafte Datenbank Anfrage!", mysqli_error($this->conn));
return false;
}
return $this->result;
@ -69,10 +69,10 @@ Simple Database Class (C) by Bastian Schroll
{
if ($result != null)
{
return @mysql_fetch_assoc($result);
return @mysqli_fetch_assoc($result);
} else
{
return @mysql_fetch_assoc($this->result);
return @mysqli_fetch_assoc($this->result);
}
}

View file

@ -10,7 +10,7 @@
</tr>
<?php
$db->query("SELECT id, time, ric, funktion, text, description FROM ".$tablePOC." ORDER BY id DESC LIMIT 100");
$db->query("SELECT id, time, ric, function, msg, description FROM ".$tablePOC." ORDER BY id DESC LIMIT 100");
$Rows = array();
while ($daten = $db->fetchAssoc())
{
@ -29,11 +29,11 @@
// echo "<td>". $poc['id'] . "</td>";
//
echo "<td>". $poc['description'] . "</td>";
echo "<td>". $poc['text'] . "</td>";
echo "<td>". $poc['msg'] . "</td>";
echo "<td>". $time . "</td>";
echo "<td>". $poc['ric'] . "</td>";
echo "<td>". $poc['funktion'] . "</td>";
echo "<td>". $poc['function'] . "</td>";
echo "</tr>";
}
?>
</table>
</table>

View file

@ -126,7 +126,7 @@ def decode(freq, decoded):
# If enabled, look up description
if globalVars.config.getint("POC", "idDescribed"):
from includes import descriptionList
data["description"] = descriptionList.getDescription("POC", poc_id)
data["description"] = descriptionList.getDescription("POC", poc_id+data["functionChar"])
# processing the alarm
try:
from includes import alarmHandler

View file

@ -11,6 +11,7 @@ Function to expand the dataset with a description.
import logging # Global logger
import csv # for loading the description files
import re # for matching IDs with a regular expression
from includes import globalVars # Global variables
from includes.helper import stringConverter
@ -41,10 +42,10 @@ def loadCSV(typ, idField):
reader = csv.DictReader(csvfile)
for row in reader:
logging.debug(row)
# only import rows with an integer as id
if row[idField].isdigit() == True:
# only import rows with an integer as id, allow subrics though
if re.match("^[0-9]+[A-D]?$", row[idField], re.IGNORECASE):
try:
resultList[row[idField]] = stringConverter.convertToUTF8(row['description'])
resultList[row[idField].lower()] = stringConverter.convertToUTF8(row['description'])
except:
# skip entry in case of an exception
pass
@ -105,14 +106,12 @@ def getDescription(typ, data):
logging.debug("look up description lists")
try:
if typ == "FMS":
global fmsDescribtionList
resultStr = fmsDescribtionList[data]
elif typ == "ZVEI":
global zveiDescribtionList
resultStr = zveiDescribtionList[data]
elif typ == "POC":
global ricDescribtionList
resultStr = ricDescribtionList[data]
resultStr = ricDescribtionList[data[:-1]] # MainRIC
resultStr += " " + ricDescribtionList[data] # SubRIC
else:
logging.warning("Invalid Typ: %s", typ)

View file

@ -31,12 +31,10 @@ def checkID(typ, data, msg=""):
@return: True if check was OK
@return: False if double was found
"""
global doubleList
timestamp = int(time.time()) # Get Timestamp
logging.debug("checkID: %s (%s)", data, msg)
for i in range(len(doubleList)):
(xID, xTimestamp, xMsg) = doubleList[i]
for (xID, xTimestamp, xMsg) in doubleList:
# given ID found?
# return False if the first entry in double_ignore_time is found, we will not check for younger ones...
if data == xID and timestamp < xTimestamp + globalVars.config.getint("BOSWatch", "doubleFilter_ignore_time"):

View file

@ -9,8 +9,9 @@ Global variables
"""
# version info
versionNr = "2.2-beta"
buildDate = "2017/03/30"
versionNr = "2.2.1-beta"
buildDate = "2017/09/19"
# Global variables
config = 0

View file

@ -17,7 +17,7 @@ from includes import globalVars
from includes.helper import timeHandler
def replaceWildcards(text, data, lineBrakeAllowed=False):
def replaceWildcards(text, data):
"""
Replace all official Wildcards with the Information from the data[] var
@ -25,8 +25,6 @@ def replaceWildcards(text, data, lineBrakeAllowed=False):
@param text: Input text with wildcards
@type data: map
@param data: map of data (structure see readme.md in plugin folder)
@type lineBrakeAllowed: Boolean
@param lineBrakeAllowed: switch to allow lineBreak (%BR%) as wildcard
@return: text with replaced wildcards
@exception: Exception if Error at replace
@ -36,8 +34,7 @@ def replaceWildcards(text, data, lineBrakeAllowed=False):
text = text.replace("%TIME%", timeHandler.getTime(data["timestamp"])).replace("%DATE%", timeHandler.getDate(data["timestamp"]))
# replace some special chars
if lineBrakeAllowed == True:
text = text.replace("%BR%", "\r\n")
text = text.replace("%BR%", "\r\n")
text = text.replace("%LPAR%", "(")
text = text.replace("%RPAR%", ")")

View file

@ -39,16 +39,16 @@ takes 2 optional arguments:
self._developerkey = None
self.developerkey(developerkey)
if apikey:
if type(apikey) == str:
if isinstance(apikey, str):
apikey = [apikey]
self._apikey = uniq(apikey)
def addkey(self, key):
"Add a key (register ?)"
if type(key) == str:
if isinstance(key, str):
if not key in self._apikey:
self._apikey.append(key)
elif type(key) == list:
elif isinstance(key, list):
for k in key:
if not k in self._apikey:
self._apikey.append(k)
@ -65,7 +65,7 @@ takes 2 optional arguments:
def developerkey(self, developerkey):
"Sets the developer key (and check it has the good length)"
if type(developerkey) == str and len(developerkey) == 48:
if isinstance(developerkey, str) and len(developerkey) == 48:
self._developerkey = developerkey
def pushWithAPIKey(self, apikey=[], application="", event="", description="", url="", contenttype=None, priority=0, batch_mode=False, html=False):

View file

@ -28,7 +28,6 @@ def loadFilters():
@return: nothing
"""
global filterList
try:
logging.debug("loading filters")
# For each entry in config.ini [Filters] section
@ -89,7 +88,7 @@ def checkFilters(typ, data, plugin, freq):
return False
else:
logging.debug("no Filter found")
return True
return False
except:
logging.error("Error in filter checking")

View file

@ -111,9 +111,9 @@ def run(typ,freq,data):
elif typ == "POC":
if isSignal(data["ric"]):
cursor.execute("UPDATE "+globalVars.config.get("MySQL","tableSIG")+" SET time = NOW() WHERE ric = "+data["ric"])
cursor.execute("UPDATE "+globalVars.config.get("MySQL","tableSIG")+" SET time = NOW() WHERE ric = '"+data["ric"]+"';")
if cursor.rowcount == 0:
cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableSIG")+" (time,ric) VALUES (NOW(),"+data["ric"]+")")
cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableSIG")+" (time,ric) VALUES (NOW(), '"+data["ric"]+"');")
else:
cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tablePOC")+" (time, ric, function, functionChar, msg, bitrate, description) VALUES (FROM_UNIXTIME(%s),%s,%s,%s,%s,%s,%s)", (data["timestamp"], data["ric"], data["function"], data["functionChar"], data["msg"], data["bitrate"], data["description"]))

View file

@ -104,44 +104,6 @@ CREATE TABLE IF NOT EXISTS `bos_signal` (
PRIMARY KEY (`ID`)
) ENGINE=MYISAM DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Schedule für Tabelle `bos_pocsag`
--
CREATE EVENT IF NOT EXISTS `Delete POCSAG Entries > 3 Months`
ON SCHEDULE EVERY 1 DAY
STARTS '2016-01-01 00:00:00'
ON COMPLETION PRESERVE ENABLE
DO
DELETE FROM bos_pocsag WHERE time < DATE_SUB(NOW(),INTERVAL 3 MONTH);
-- --------------------------------------------------------
--
-- Schedule für Tabelle `bos_fms`
--
CREATE EVENT IF NOT EXISTS `Delete FMS Entries > 3 Months`
ON SCHEDULE EVERY 1 DAY
STARTS '2016-01-01 00:00:00'
ON COMPLETION PRESERVE ENABLE
DO
DELETE FROM bos_fms WHERE time < DATE_SUB(NOW(),INTERVAL 3 MONTH);
-- --------------------------------------------------------
--
-- Schedule für Tabelle `bos_zvei`
--
CREATE EVENT IF NOT EXISTS `Delete ZVEI Entries > 3 Months`
ON SCHEDULE EVERY 1 DAY
STARTS '2016-01-01 00:00:00'
ON COMPLETION PRESERVE ENABLE
DO
DELETE FROM bos_zvei WHERE time < DATE_SUB(NOW(),INTERVAL 3 MONTH);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;

View file

@ -0,0 +1,40 @@
-- Cleanup-routines for boswatch-tables
use boswatch;
-- --------------------------------------------------------
--
-- Schedule für Tabelle `bos_pocsag`
--
CREATE EVENT IF NOT EXISTS `Delete POCSAG Entries > 3 Months`
ON SCHEDULE EVERY 1 DAY
STARTS '2016-01-01 00:00:00'
ON COMPLETION PRESERVE ENABLE
DO
DELETE FROM bos_pocsag WHERE time < DATE_SUB(NOW(),INTERVAL 3 MONTH);
-- --------------------------------------------------------
--
-- Schedule für Tabelle `bos_fms`
--
CREATE EVENT IF NOT EXISTS `Delete FMS Entries > 3 Months`
ON SCHEDULE EVERY 1 DAY
STARTS '2016-01-01 00:00:00'
ON COMPLETION PRESERVE ENABLE
DO
DELETE FROM bos_fms WHERE time < DATE_SUB(NOW(),INTERVAL 3 MONTH);
-- --------------------------------------------------------
--
-- Schedule für Tabelle `bos_zvei`
--
CREATE EVENT IF NOT EXISTS `Delete ZVEI Entries > 3 Months`
ON SCHEDULE EVERY 1 DAY
STARTS '2016-01-01 00:00:00'
ON COMPLETION PRESERVE ENABLE
DO
DELETE FROM bos_zvei WHERE time < DATE_SUB(NOW(),INTERVAL 3 MONTH);

View file

@ -58,6 +58,20 @@ def run(typ,freq,data):
"""
try:
if configHandler.checkConfig("Sms77"): #read and debug the config
# create an empty message an fill it with the required information
message = "Alarm"
if typ == "FMS":
logging.debug("FMS detected, building message")
message = data["description"]+"<br>"+data["status"]
elif typ == "ZVEI":
logging.debug("ZVEI detected, building message")
message = data["zvei"]+" - "+data["description"]
elif typ == "POC":
logging.debug("POC detected, building message")
message = data["description"]+"<br>"+data["msg"].replace(";", "<br>")
else:
logging.warning("Invalid typ - use empty message")
try:
@ -66,15 +80,15 @@ def run(typ,freq,data):
#
logging.debug("send Sms77 %s", typ)
conn = httplib.HTTPSConnection("gateway.sms77.de:443")
conn.request("POST", "",
conn = httplib.HTTPSConnection("gateway.sms77.io",443)
conn.request("POST", "/api/sms",
urllib.urlencode({
"u": globalVars.config.get("Sms77", "user"),
"p": globalVars.config.get("Sms77", "password"),
"to": globalVars.config.get("Sms77", "to"),
"from": globalVars.config.get("Sms77", "from"),
"type": globalVars.config.get("Sms77", "type"),
"text": data["description"]+"<br>"+data["msg"].replace(";", "<br>")
"text": message
}),{"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"})
except:

View file

@ -16,8 +16,8 @@ from telegram.error import (TelegramError, Unauthorized, BadRequest, NetworkErro
from includes import globalVars # Global variables
# Helper function, uncomment to use
from includes.helper import wildcardHandler
from includes.helper import configHandler
from includes.helper import timeHandler
# local variables
BOTTokenAPIKey = None
@ -78,20 +78,21 @@ def run(typ,freq,data):
try:
########## User Plugin CODE ##########
try:
if typ == "POC":
logging.debug("Compose output from POCSAG-message")
if typ in ("POC", "FMS", "ZVEI"):
logging.debug("Read format and compose output for %s-message" % typ)
# compose message content
output = timeHandler.curtime()+"\n"+data["ric"]+"("+data["functionChar"]+")\n"+data["description"]+"\n"+data["msg"]
text = globalVars.config.get("Telegram", "%s_message" % typ)
text = wildcardHandler.replaceWildcards(text, data)
# Initiate Telegram Bot
logging.debug("Initiate Telegram BOT")
bot = telegram.Bot(token='%s' % BOTTokenAPIKey)
# Send message to chat via Telegram BOT API
logging.debug("Send message to chat via Telegram BOT API")
bot.sendMessage('%s' % BOTChatIDAPIKey, output)
bot.sendMessage('%s' % BOTChatIDAPIKey, text)
# Generate location information only for specific RIC
if data["ric"] == RICforLocationAPIKey:
if typ == "POC" and data["ric"] == RICforLocationAPIKey:
# Generate map
logging.debug("Extract address from POCSAG message")
address = "+".join(data["msg"].split(')')[0].split('/',1)[1].replace('(',' ').split())
@ -113,28 +114,6 @@ def run(typ,freq,data):
gcode_result = gcode.geocode(address)
logging.debug("Send location via Telegram BOT API")
bot.sendLocation('%s' % BOTChatIDAPIKey, gcode_result[0]['geometry']['location']['lat'], gcode_result[0]['geometry']['location']['lng'], disable_notification='true')
elif typ == "FMS":
logging.debug("Compose output from FMS-message")
# compose message content
output = timeHandler.curtime()+"\n"+data["fms"]+"\n"+data["description"]+"\n"+data["status"]
# Initiate Telegram Bot
logging.debug("Initiate Telegram BOT")
bot = telegram.Bot(token='%s' % BOTTokenAPIKey)
# Send message to chat via Telegram BOT API
logging.debug("Send message to chat via Telegram BOT API")
bot.sendMessage('%s' % BOTChatIDAPIKey, output)
elif typ == "ZVEI":
logging.debug("Compose output from ZVEI-message")
# compose message content
output = timeHandler.curtime()+"\n"+data["zvei"]+"\n"+data["description"]
# Initiate Telegram Bot
logging.debug("Initiate Telegram BOT")
bot = telegram.Bot(token='%s' % BOTTokenAPIKey)
# Send message to chat via Telegram BOT API
logging.debug("Send message to chat via Telegram BOT API")
bot.sendMessage('%s' % BOTChatIDAPIKey, output)
else:
logging.warning("Invalid Typ: %s", typ)
except Unauthorized:

View file

@ -137,7 +137,7 @@ def run(typ,freq,data):
# read mailtext-structure from config.ini
mailtext = globalVars.config.get("eMail", "fms_message")
# replace wildcards with helper function
mailtext = wildcardHandler.replaceWildcards(mailtext, data, lineBrakeAllowed=True)
mailtext = wildcardHandler.replaceWildcards(mailtext, data)
# send eMail
doSendmail(server, subject, mailtext)
@ -157,7 +157,7 @@ def run(typ,freq,data):
# read mailtext-structure from config.ini
mailtext = globalVars.config.get("eMail", "zvei_message")
# replace wildcards with helper function
mailtext = wildcardHandler.replaceWildcards(mailtext, data, lineBrakeAllowed=True)
mailtext = wildcardHandler.replaceWildcards(mailtext, data)
# send eMail
doSendmail(server, subject, mailtext)
@ -177,7 +177,7 @@ def run(typ,freq,data):
# read mailtext-structure from config.ini
mailtext = globalVars.config.get("eMail", "poc_message")
# replace wildcards with helper function
mailtext = wildcardHandler.replaceWildcards(mailtext, data, lineBrakeAllowed=True)
mailtext = wildcardHandler.replaceWildcards(mailtext, data)
# send eMail
doSendmail(server, subject, mailtext)

View file

@ -14,6 +14,7 @@ httpRequest-Plugin to dispatch FMS-, ZVEI- and POCSAG - messages to an URL
#
# Imports
#
import urllib
import urllib2
import logging # Global logger
from includes import globalVars # Global variables
@ -67,36 +68,41 @@ def run(typ,freq,data):
try:
#
# Create URL
# Replace special characters in data Strings for URL
#
for key in data:
if isinstance(data[key], basestring):
data[key] = urllib.quote(data[key])
#
# Get URLs
#
if typ == "FMS":
url = globalVars.config.get("httpRequest", "fms_url") #Get URL
url = wildcardHandler.replaceWildcards(url, data) # replace wildcards with helper function
url = url.replace(" ","%20") # replace space with %20 to be a vaild http request
urls = globalVars.config.get("httpRequest", "fms_url").split(",")
elif typ == "ZVEI":
url = globalVars.config.get("httpRequest", "zvei_url") #Get URL
url = wildcardHandler.replaceWildcards(url, data) # replace wildcards with helper function
url = url.replace(" ","%20") # replace space with %20 to be a vaild http request
urls = globalVars.config.get("httpRequest", "zvei_url").split(",")
elif typ == "POC":
url = globalVars.config.get("httpRequest", "poc_url") #Get URL
url = wildcardHandler.replaceWildcards(url, data) # replace wildcards with helper function
url = url.replace(" ","%20") # replace space with %20 to be a vaild http request
urls = globalVars.config.get("httpRequest", "poc_url").split(",")
else:
logging.warning("Invalid Typ: %s", typ)
return
#
# replace wildcards
#
for (i, url) in enumerate(urls):
urls[i] = wildcardHandler.replaceWildcards(urls[i].strip(), data)
#
# HTTP-Request
#
logging.debug("send %s HTTP request", typ)
logging.debug("send %s HTTP requests", typ)
try:
#resp = urllib2.urlopen(url)
urllib2.urlopen(url)
except urllib2.HTTPError as e:
logging.warning("HTTP response: %s", e.code)
except urllib2.URLError as e:
logging.warning("HTTP-specific error: %s", e.args)
for url in urls:
try:
urllib2.urlopen(url)
except urllib2.HTTPError as e:
logging.warning("HTTP response: %s", e.code)
except urllib2.URLError as e:
logging.warning("HTTP-specific error: %s", e.args)
except:
logging.error("cannot send HTTP request")

View file

@ -173,9 +173,6 @@ def run(typ,freq,data):
@return: nothing
"""
# local variables
global fmsAPIKeyList
global zveiAPIKeyList
global pocAPIKeyList
try:
try:

View file

@ -1,3 +1,20 @@
### Use BOSWatch as service ###
Old description below
We assume that BOSWatch is installed to /opt/boswatch! Otherwise you need to adapt all the pathes in this description and in the service-file itself.
#### Adapt the script
Enter the frequency and the decoder(s) you want to use in line 7; you can add more specific switches if you need to
### Install the service
1. Copy the file to /lib/systemd/system: sudo cp /opt/boswatch/service/boswatch.service /lib/systemd/system/
2. Change the rights: sudo chmod 644 /lib/systemd/system/boswatch.service
3. Enable the service: sudo systemcl enable boswatch.service
4. Start the service: sudo systemcl start boswatch.service
---
### Start BOSWatch as a daemon
##### Changing the init script

11
service/boswatch.service Normal file
View file

@ -0,0 +1,11 @@
[Unit]
Description=BOSWatch
After=multi-user.target
[Service]
Type=simple
ExecStart=/usr/bin/python /opt/boswatch/boswatch.py -f 123.45M -a POC512
Restart=on-abort
[Install]
WantedBy=multi-user.target