Removed notification work.

pull/270/head
Joe Prochazka 2016-12-01 13:42:34 -05:00
rodzic b5bd965a26
commit 44f7e72a26
9 zmienionych plików z 34 dodań i 451 usunięć

Wyświetl plik

@ -4,7 +4,6 @@ The following is a history of the changes made to this project.
## v2.5.0
* Twitter and email flight notifications ready for testing.
* Can now specify the unit of measurement for dump1090-mutability during setup.
* Users can now specify the repository branch they wish to use in the file install.sh.
* Possible fix for blog post containing characters not UTF-8 compatible. *(lite)*
@ -21,6 +20,9 @@ The following is a history of the changes made to this project.
* The path to the SQLite database is no longer hard coded in the portal PHP files.
* Pagination links now show first and last page links properly.
* When no patch is applied N\A is given for the patch version on the system page.
* Yes set to default when asked whether to bind dump1090-mutability to all IP addresses.
* Fixed issue with install script causing PiAware to not upgrade.
* Fixed collectd graph generation script so it works with newer versions of rrdtool.
## v2.4.0 *(September 27th, 2016)*

Wyświetl plik

@ -185,7 +185,7 @@ fi
exit 0
# Ask if dump1090-mutability should bind on all IP addresses.
if (whiptail --backtitle "$ADSB_PROJECTTITLE" --title "Bind Dump1090-mutability To All IP Addresses" --defaultno --yesno "By default dump1090-mutability is bound only to the local loopback IP address(s) for security reasons. However some people wish to make dump1090-mutability's data accessable externally by other devices. To allow this dump1090-mutability can be configured to listen on all IP addresses bound to this device. It is recommended that unless you plan to access this device from an external source that dump1090-mutability remain bound only to the local loopback IP address(s).\n\nWould you like dump1090-mutability to listen on all IP addesses?" 15 78) then
if (whiptail --backtitle "$ADSB_PROJECTTITLE" --title "Bind Dump1090-mutability To All IP Addresses" --yesno "By default dump1090-mutability is bound only to the local loopback IP address(s) for security reasons. However some people wish to make dump1090-mutability's data accessable externally by other devices. To allow this dump1090-mutability can be configured to listen on all IP addresses bound to this device. It is recommended that unless you plan to access this device from an external source that dump1090-mutability remain bound only to the local loopback IP address(s).\n\nWould you like dump1090-mutability to listen on all IP addesses?" 15 78) then
echo -e "\e[94m Binding dump1090-mutability to all available IP addresses...\e[97m"
CommentConfig "NET_BIND_ADDRESS" "/etc/default/dump1090-mutability"
else

Wyświetl plik

@ -520,16 +520,6 @@ if [ $? -ne 0 ]; then
exit 1
fi
# Execute the notifications setup script.
chmod +x $BASHDIRECTORY/portal/notifications.sh
$BASHDIRECTORY/portal/notifications.sh
if [ $? -ne 0 ]; then
echo ""
echo -e "\e[91m THE SCRIPT NOTIFICATIONS.SH ENCOUNTERED AND ERROR"
echo ""
exit 1
fi
## SETUP ADVANCED PORTAL FEATURES
if [ $ADVANCED = TRUE ]; then

Wyświetl plik

@ -1,97 +0,0 @@
#!/bin/bash
#####################################################################################
# ADS-B RECEIVER #
#####################################################################################
# #
# This script is not meant to be executed directly. #
# Instead execute install.sh to begin the installation process. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Copyright (c) 2015-2016 Joseph A. Prochazka #
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy #
# of this software and associated documentation files (the "Software"), to deal #
# in the Software without restriction, including without limitation the rights #
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell #
# copies of the Software, and to permit persons to whom the Software is #
# furnished to do so, subject to the following conditions: #
# #
# The above copyright notice and this permission notice shall be included in all #
# copies or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE #
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, #
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE #
# SOFTWARE. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## VARIABLES
PROJECTROOTDIRECTORY="$PWD"
BASHDIRECTORY="$PROJECTROOTDIRECTORY/bash"
BUILDDIRECTORY="$PROJECTROOTDIRECTORY/build"
PORTALBUILDDIRECTORY="$BUILDDIRECTORY/portal"
PORTALPYTHONDIRECTORY="$PORTALBUILDDIRECTORY/python"
PYTHONPATH=`which python`
## INCLUDE EXTERNAL SCRIPTS
source $BASHDIRECTORY/functions.sh
## CHECK FOR PREREQUISITE PACKAGES
echo -e "\e[95m Installing packages needed to build and fulfill dependencies...\e[97m"
echo ""
CheckPackage python-pip
echo -e "\e[94m Using pip to install python-twitter...\e[97m"
echo ""
sudo pip install python-twitter
## SETUP FLIGHT NOTIFICATIONS
echo ""
echo -e "\e[95m Setting up flight notifications...\e[97m"
echo ""
# Create and set permissions on the flight logging and maintenance maintenance scripts.
echo -e "\e[94m Creating the flight logging maintenance script...\e[97m"
tee $PORTALPYTHONDIRECTORY/notifications-maint.sh > /dev/null <<EOF
#!/bin/sh
while true
do
sleep 30
$PYTHONPATH $PORTALPYTHONDIRECTORY/notifications.py
done
EOF
echo -e "\e[94m Making the notifications maintenance script executable...\e[97m"
chmod +x $PORTALPYTHONDIRECTORY/notifications-maint.sh
# Add the flight notifications maintenance script to rc.local.
if ! grep -Fxq "$PORTALPYTHONDIRECTORY/notifications-maint.sh &" /etc/rc.local; then
echo -e "\e[94m Adding the flight notifications maintenance script startup line to /etc/rc.local...\e[97m"
LINENUMBER=($(sed -n '/exit 0/=' /etc/rc.local))
((LINENUMBER>0)) && sudo sed -i "${LINENUMBER[$((${#LINENUMBER[@]}-1))]}i $PORTALPYTHONDIRECTORY/notifications-maint.sh &\n" /etc/rc.local
fi
# Kill any previously running maintenance scripts.
echo -e "\e[94m Checking for any running notifications-maint.sh processes...\e[97m"
PIDS=`ps -efww | grep -w "notifications-maint.sh" | awk -vpid=$$ '$2 != pid { print $2 }'`
if [ ! -z "$PIDS" ]; then
echo -e "\e[94m Killing any running notifications-maint.sh processes...\e[97m"
sudo kill $PIDS
sudo kill -9 $PIDS
fi
# Start maintenance.
echo -e "\e[94m Executing the notifications maintenance script...\e[97m"
nohup $PORTALPYTHONDIRECTORY/notifications-maint.sh > /dev/null 2>&1 &
exit 0

Wyświetl plik

@ -54,21 +54,18 @@
if ($settings::db_driver == "xml") {
// XML
$notifications = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."notifications.xml");
$notifications = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."flightNotifications.xml");
unset($notifications->flight);
foreach ($notificationArray as $notification) {
$flight = $notifications->addChild('flight', '');
$flight->addChild('name', $notification);
$flight->addChild('lastMessageCount', -1);
$newNotification = $notifications->addChild('flight', $notification);
$dom = dom_import_simplexml($notifications)->ownerDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->formatOutput = TRUE;
file_put_contents($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."notifications.xml", $dom->saveXML());
file_put_contents($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."flightNotifications.xml", $dom->saveXML());
}
} else {
// PDO
$dbh = $common->pdoOpen();
$sql = "SELECT * FROM ".$settings::db_prefix."notifications";
$sql = "SELECT * FROM ".$settings::db_prefix."flightNotifications";
$sth = $dbh->prepare($sql);
$sth->execute();
$savedFlights = $sth->fetchAll();
@ -78,7 +75,7 @@
// Remove flight if not in list.
if (!in_array($flight, $notificationArray)) {
$dbh = $common->pdoOpen();
$sql = "DELETE FROM ".$settings::db_prefix."notifications WHERE flight = :flight";
$sql = "DELETE FROM ".$settings::db_prefix."flightNotifications WHERE flight = :flight";
$sth = $dbh->prepare($sql);
$sth->bindParam(':flight', $flight['flight'], PDO::PARAM_STR, 10);
$sth->execute();
@ -90,10 +87,9 @@
// Add flight if not saved already.
if (!in_array($flight, $savedFlights)) {
$dbh = $common->pdoOpen();
$sql = "INSERT INTO ".$settings::db_prefix."notifications (flight, lastMessageCount) VALUES (:flight, :lastMessageCount)";
$sql = "INSERT INTO ".$settings::db_prefix."flightNotifications (flight) VALUES (:flight)";
$sth = $dbh->prepare($sql);
$sth->bindParam(':flight', $flight, PDO::PARAM_STR, 10);
$sth->bindParam(':lastMessageCount', $a = 0, PDO::PARAM_INT);
$sth->execute();
$sth = NULL;
$dbh = NULL;
@ -154,14 +150,6 @@
if (isset($_POST['enableWebNotifications']) && $_POST['enableWebNotifications'] == "TRUE")
$enableWebNotifications = TRUE;
$enableEmailNotifications = FALSE;
if (isset($_POST['enableEmailNotifications']) && $_POST['enableEmailNotifications'] == "TRUE")
$enableEmailNotifications = TRUE;
$enableTwitterNotifications = FALSE;
if (isset($_POST['enableTwitterNotifications']) && $_POST['enableTwitterNotifications'] == "TRUE")
$enableTwitterNotifications = TRUE;
// Update settings using those supplied by the form.
$common->updateSetting("siteName", $_POST['siteName']);
$common->updateSetting("template", $_POST['template']);
@ -189,14 +177,6 @@
$common->updateSetting("networkInterface", $_POST['networkInterface']);
$common->updateSetting("timeZone", $_POST['timeZone']);
$common->updateSetting("enableWebNotifications", $enableWebNotifications);
$common->updateSetting("enableEmailNotifications", $enableEmailNotifications);
$common->updateSetting("enableTwitterNotifications", $enableTwitterNotifications);
$common->updateSetting("emailNotificationAddresses", $_POST['emailNotificationAddresses']);
$common->updateSetting("twitterUserName", $_POST['twitterUserName']);
$common->updateSetting("twitterConsumerKey", $_POST['twitterConsumerKey']);
$common->updateSetting("twitterConsumerSecret", $_POST['twitterConsumerSecret']);
$common->updateSetting("twitterAccessToken", $_POST['twitterAccessToken']);
$common->updateSetting("twitterAccessTokenSecret", $_POST['twitterAccessTokenSecret']);
$common->updateSetting("googleMapsApiKey", $_POST['googleMapsApiKey']);
// Purge older flight positions.
@ -237,14 +217,6 @@
}
}
$enableWebNotifications = $common->getSetting("enableWebNotifications");
$enableEmailNotifications = $common->getSetting("enableEmailNotifications");
$enableTwitterNotifications = $common->getSetting("enableTwitterNotifications");
$emailNotificationAddresses = $common->getSetting("emailNotificationAddresses");
$twitterUserName = $common->getSetting("twitterUserName");
$twitterConsumerKey = $common->getSetting("twitterConsumerKey");
$twitterConsumerSecret = $common->getSetting("twitterConsumerSecret ");
$twitterAccessToken = $common->getSetting("twitterAccessToken");
$twitterAccessTokenSecret = $common->getSetting("twitterAccessTokenSecret");
// Get general settings from settings.xml.
$siteName = $common->getSetting("siteName");
@ -305,7 +277,7 @@
////////////////
// BEGIN HTML
require_once('includes/header.inc.php');
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."includes/header.inc.php");
// Display the updated message if settings were updated.
if ($updated) {
@ -430,79 +402,10 @@
<input type="checkbox" name="enableWebNotifications" value="TRUE"<?php ($enableWebNotifications == 1 ? print ' checked' : ''); ?>> Enable web based flight notifications.
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="enableEmailNotifications" value="TRUE"<?php ($enableEmailNotifications == 1 ? print ' checked' : ''); ?>> Enable email flight notifications.
</label>
</div>
<div class="form-group">
<label for="emailNotificationAddresses"">Email addresses to be notified. (coma delimited)</label>
<input type="text" class="form-control" id="emailNotificationAddresses" name="emailNotificationAddresses" value="<?php echo $emailNotificationAddresses; ?>">
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="enableTwitterNotifications" value="TRUE"<?php ($enableTwitterNotifications == 1 ? print ' checked' : ''); ?>> Enable Twitter flight notifications.
</label>
</div>
<div class="form-group">
<label for="twitterUserName">Twitter User Name</label>
<input type="text" class="form-control" id="twitterUserName" name="twitterUserName" value="<?php echo $twitterUserName; ?>">
</div>
<div class="form-group">
<label for="twitterConsumerKey">Twitter Consumer Key</label>
<input type="text" class="form-control" id="twitterConsumerKey" name="twitterConsumerKey" value="<?php echo $twitterConsumerKey; ?>">
</div>
<div class="form-group">
<label for="twitterConsumerSecret">Twitter</label>
<input type="text" class="form-control" id="twitterConsumerSecret" name="twitterConsumerSecret" value="<?php echo $twitterConsumerSecret; ?>">
</div>
<div class="form-group">
<label for="twitterAccessToken">Twitter</label>
<input type="text" class="form-control" id="twitterAccessToken" name="twitterAccessToken" value="<?php echo $twitterAccessToken; ?>">
</div>
<div class="form-group">
<label for="twitterAccessTokenSecret">Twitter</label>
<input type="text" class="form-control" id="twitterAccessTokenSecret" name="twitterAccessTokenSecret" value="<?php echo $twitterAccessTokenSecret; ?>">
</div>
</div>
</div>
</div>
<div role="tabpanel" class="tab-pane fade" id="navigation">
<div class="panel panel-default">
<div class="panel-heading">API Key</div>
<div class="panel-body">
<div class="form-group">
<label for="BingMapsAPI">Bing Maps API Key</label>
<input type="text" class="form-control" id="bingMapAPIKey" name="bingMapAPIKey"
value="<?php if(!empty($_POST['bingMapAPIKey'])){
$apikey = $_POST['bingMapAPIKey'];
$path_to_file = '/usr/share/dump1090-mutability/html/config.js';
$file_contents = file_get_contents($path_to_file);
$file_contents = preg_replace('/BingMapsAPIKey = ([a-zA-Z0-9"]+)/', "BingMapsAPIKey = '" . $_POST['bingMapAPIKey'] . "'" , $file_contents);
file_put_contents($path_to_file,$file_contents);
}
else {
echo file_get_contents('/usr/share/dump1090-mutability/html/config.js');
}
?>">
</div>
<div class="form-group">
<label for="mapzenAPIKey">Mapzen Maps API Key</label>
<input type="text" class="form-control" id="mapzenAPIKey" name="mapzenAPIKey"
value="<?php if(!empty($_POST['mapzenAPIKey'])){
$apikey = $_POST['mapzenAPIKey'];
$path_to_file = '/usr/share/dump1090-mutability/html/config.js';
$file_contents = file_get_contents($path_to_file);
$file_contents = preg_replace('/MapzenAPIKey = ([a-zA-Z0-9"]+)/', "MapzenAPIKey = '" . $_POST['mapzenAPIKey'] . "'" , $file_contents);
file_put_contents($path_to_file,$file_contents);
}
else {
echo file_get_contents('/usr/share/dump1090-mutability/html/config.js');
}
?>">
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">Enable/Disable Navigation Links</div>
<div class="panel-body">
@ -678,5 +581,5 @@
<input type="submit" class="btn btn-default" value="Save Settings">
</form>
<?php
require_once('includes/footer.inc.php');
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."includes/footer.inc.php");
?>

Wyświetl plik

@ -32,8 +32,8 @@
$thisVersion = "2.5.0";
// Begin the upgrade process if this release is newer than what is installed.
if (file_exists("../classes/settings.class.php")) {
require('../classes/common.class.php');
if (file_exists($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."settings.class.php")) {
require($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."common.class.php");
$common = new common();
if ($common-> getSetting("version") < $thisVersion) {
@ -50,7 +50,7 @@
$installed = FALSE;
//if ($common->postBack()) {
if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') {
require_once('../classes/account.class.php');
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."account.class.php");
$account = new account();
// Validate the submited form.
@ -136,7 +136,7 @@
EOF;
file_put_contents($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."settings.class.php", $content);
require('../classes/common.class.php');
require($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."common.class.php");
$common = new common();
// Setup data storage.
@ -169,7 +169,7 @@ EOF;
$xml->startDocument('1.0','UTF-8');
$xml->startElement("flights");
$xml->endElement();
file_put_contents($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."notifications.xml", $xml->flush(true));
file_put_contents($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."flightNotifications.xml", $xml->flush(true));
// Create XML files used to store links data.
$xml = new XMLWriter();
@ -227,10 +227,9 @@ EOF;
id INT(11) AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
address VARCHAR(250) NOT NULL);';
$notificationsSql = 'CREATE TABLE '.$dbPrefix.'notifications (
$flightNotificationsSql = 'CREATE TABLE '.$dbPrefix.'flightNotifications (
id INT(11) PRIMARY KEY AUTO_INCREMENT,
flight VARCHAR(10) NOT NULL,
lastMessageCount INT(11) NOT NULL);';
flight VARCHAR(10) NOT NULL);';
$positionsSql = 'CREATE TABLE '.$dbPrefix.'positions (
id INT(11) AUTO_INCREMENT PRIMARY KEY,
flight BIGINT NOT NULL,
@ -279,10 +278,9 @@ EOF;
id INT(11) AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
address VARCHAR(250) NOT NULL);';
$notificationsSql = 'CREATE TABLE '.$dbPrefix.'notifications (
$flightNotificationsSql = 'CREATE TABLE '.$dbPrefix.'flightNotifications (
id SERIAL PRIMARY KEY,
flight VARCHAR(10) NOT NULL,
lastMessageCount INT(11) NOT NULL);';
flight VARCHAR(10) NOT NULL);';
$positionsSql = 'CREATE TABLE '.$dbPrefix.'positions (
id SERIAL PRIMARY KEY,
flight BIGINT NOT NULL,
@ -330,10 +328,9 @@ EOF;
id INT(11) AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
address VARCHAR(250) NOT NULL);';
$notificationsSql = 'CREATE TABLE '.$dbPrefix.'notifications (
$flightNotificationsSql = 'CREATE TABLE '.$dbPrefix.'flightNotifications (
id INTEGER PRIMARY KEY AUTOINCREMENT,
flight TEXT NOT NULL,
lastMessageCount INTEGER NOT NULL);';
flight TEXT NOT NULL);';
$positionsSql = 'CREATE TABLE '.$dbPrefix.'positions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
flight INTEGER NOT NULL,
@ -376,7 +373,7 @@ EOF;
$sth->execute();
$sth = NULL;
$sth = $dbh->prepare($notificationsSql);
$sth = $dbh->prepare($flightNotificationsSql);
$sth->execute();
$sth = NULL;
@ -426,14 +423,6 @@ EOF;
$common->addSetting('emailReplyTo', 'noreply@adsbreceiver.net');
$common->addSetting('timeZone', $_POST['timeZone']);
$common->addSetting('enableWebNotifications', FALSE);
$common->addSetting('enableEmailNotifications', FALSE);
$common->addSetting('enableTwitterNotifications', FALSE);
$common->addSetting('emailNotificationAddresses', '');
$common->addSetting('twitterUserName', '');
$common->addSetting('twitterConsumerKey', '');
$common->addSetting('twitterConsumerSecret', '');
$common->addSetting('twitterAccessToken', '');
$common->addSetting('twitterAccessTokenSecret', '');
$common->addSetting('googleMapsApiKey', '');
if ($_POST['driver'] == "xml")
@ -442,7 +431,7 @@ EOF;
$common->addSetting('enableFlights', TRUE);
// Add the administrator account.
require_once('../classes/account.class.php');
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."account.class.php");
$account->addAdministrator($_POST['name'], $_POST['email'], $_POST['login'], password_hash($_POST['password1'], PASSWORD_DEFAULT));
// Mark the installation as complete.
@ -475,7 +464,7 @@ EOF;
// Display HTML
//////////////////
require_once('../admin/includes/header.inc.php');
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."header.inc.php");
// Display the instalation wizard.
if (!$installed) {
@ -601,5 +590,5 @@ EOF;
</p>
<?php
}
require_once("../admin/includes/footer.inc.php");
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."footer.inc.php");
?>

Wyświetl plik

@ -34,12 +34,8 @@
// ------------------------------------------------------------------------------------------
// If using SQLite creates a new settings.class.php file containing the path to the database.
// Renames flightNotifications.xml to notifications.xml.
// Renames the flightNotifications table to notifications on MySQL and SQLite databases.
// Adds the lastMessageCount column to the notifications table on MySQL and SQLite databases.
// Renames the enableFlightNotifications setting to enableNotifications.
// Adds new Twitter API settings.
// Updates the version setting to 2.4.0.
// Updates the version setting to 2.5.0.
// Removes and current patch version from the patch setting.
// ------------------------------------------------------------------------------------------
@ -55,9 +51,6 @@
try {
if ($settings::db_driver == "xml") {
// Rename the file flightNotifications.xml to notifications.xml
rename($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."flightNotifications.xml", $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."notifications.xml");
// Create XML files used to store links data.
$xml = new XMLWriter();
$xml->openMemory();
@ -71,18 +64,6 @@
if ($settings::db_driver == "mysql") {
$dbh = $common->pdoOpen();
// Rename the flightNotifications table to notifications.
$sql = "RENAME TABLE ".$settings::db_prefix."flightNotifications TO ".$settings::db_prefix."notifications";
$sth = $dbh->prepare($sql);
$sth->execute();
$sth = NULL;
// Add the lastMessageCount column to the flightNotifications table.
$sql = "ALTER TABLE ".$settings::db_prefix."notifications ADD COLUMN lastMessageCount INT";
$sth = $dbh->prepare($sql);
$sth->execute();
$sth = NULL;
// Add the links table.
$sql = "CREATE TABLE ".$settings::db_prefix."links(id INT(11) AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) NOT NULL, address VARCHAR(250) NOT NULL);";
$sth = $dbh->prepare($sql);
@ -148,19 +129,6 @@ EOF;
// Open a connection to the database.
$dbh = $common->pdoOpen();
// Rename the flightNotifications table to notifications.
$sql = "ALTER TABLE ".$settings::db_prefix."flightNotifications RENAME TO ".$settings::db_prefix."notifications";
$sth = $dbh->prepare($sql);
$sth->execute();
$sth = NULL;
// Add the lastMessageCount column to the notifications table.
$sql = "ALTER TABLE ".$settings::db_prefix."notifications ADD COLUMN lastMessageCount DATETIME";
$sth = $dbh->prepare($sql);
$sth->execute();
$sth = NULL;
// Add the links table.
$sql = "CREATE TABLE ".$dbPrefix."links(id INT(11) AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) NOT NULL, address VARCHAR(250) NOT NULL);";
$sth = $dbh->prepare($sql);
@ -175,18 +143,6 @@ EOF;
$common->addSetting('enableWebNotifications', $enableWebNotifications);
$common->deleteSetting('enableFlightNotifications');
// Add new flight notification settings.
$common->addSetting('enableEmailNotifications', FALSE);
$common->addSetting('enableTwitterNotifications', FALSE);
$common->addSetting('emailNotificationAddresses', '');
// Add Twitter API settings.
$common->addSetting('twitterUserName', '');
$common->addSetting('twitterConsumerKey', '');
$common->addSetting('twitterConsumerSecret', '');
$common->addSetting('twitterAccessToken', '');
$common->addSetting('twitterAccessTokenSecret', '');
// Add Google Maps API Key setting.
$common->addSetting('googleMapsApiKey', '');

Wyświetl plik

@ -1,161 +0,0 @@
#!/usr/bin/python
#================================================================================#
# ADS-B FEEDER PORTAL #
# ------------------------------------------------------------------------------ #
# Copyright and Licensing Information: #
# #
# The MIT License (MIT) #
# #
# Copyright (c) 2015-2016 Joseph A. Prochazka #
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy #
# of this software and associated documentation files (the "Software"), to deal #
# in the Software without restriction, including without limitation the rights #
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell #
# copies of the Software, and to permit persons to whom the Software is #
# furnished to do so, subject to the following conditions: #
# #
# The above copyright notice and this permission notice shall be included in all #
# copies or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE #
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, #
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE #
# SOFTWARE. #
#================================================================================#
##############################################################
# TODO: #
#------------------------------------------------------------#
# When no flights are seen a JSON error is encountered. #
# Send a tweet to Twitter when a flight is seen. #
# Update the lastMessageCount using the API. #
# Add support for MySQL. #
# Add support for SQLite. #
##############################################################
import json
import urllib
import urllib2
import socket
import smtplib
import twitter
from xml.dom import minidom
import xml.etree.ElementTree as ET
# Temporary variables for testing.
portal_url = "http://localhost"
debug_script = "true"
send_email = "false"
send_tweet = "false"
###############################################
## GATHER XML DATA
# Get the portal settings from the settings.xml file.
config_tree = ET.parse("/var/www/html/data/settings.xml")
config_root = config_tree.getroot()
for setting in config_root.findall('setting'):
if setting.find('name').text == "enableEmailNotifications":
setting_enable_email_notifications = setting.find('value').text
if setting.find('name').text == "emailNotificationAddresses":
setting_enable_email_notifications = setting.find('value').text
if setting.find('name').text == "enableTwitterNotifications":
setting_enable_twitter_notifications = setting.find('value').text
if setting.find('name').text == "twitterUserName":
setting_twitter_user_name = setting.find('value').text
if setting.find('name').text == "twitterConsumerKey":
setting_twitter_cosumer_key = setting.find('value').text
if setting.find('name').text == "twitterConsumerSecret":
setting_twitter_consumer_secret = setting.find('value').text
if setting.find('name').text == "twitterAccessToken":
setting_twitter_access_token = setting.find('value').text
if setting.find('name').text == "twitterAccessTokenSecret":
setting_twitter_access_token_secret = setting.find('value').text
# Display setting variables if script debuging is turned on.
if debug_script == "true":
print "setting_enable_email_notifications: ",setting_enable_email_notifications
print "setting_email_notification_addressees: ",setting_email_notification_addressees
print "setting_enable_twitter_notifications: ",setting_enable_twitter_notifications
print "setting_twitter_user_name: ",setting_twitter_user_name
print "setting_twitter_cosumer_key: ",setting_twitter_cosumer_key
print "setting_twitter_consumer_secret: ",setting_twitter_consumer_secret
print "setting_twitter_access_token: ",setting_twitter_access_token
print "setting_twitter_access_token_secret: ",setting_twitter_access_token_secret
print "--------------------------------------------------"
# Get flights to send notifications for from the notifications.xml file.
doc = minidom.parse("/var/www/html/data/notifications.xml")
flights = doc.getElementsByTagName("flight")
# Get notification JSON from the portal.
response = urllib2.urlopen(portal_url,"/api/notifications.php?type=flights")
flights_seen = json.load(response)
for flight in flights:
name = flight.getElementsByTagName("name")[0]
lastMessageCount = flight.getElementsByTagName("lastMessageCount")[0]
for i in flights_seen['tracking']:
if name.firstChild.data.strip() == i['flight'] and lastMessageCount.firstChild.data.strip() > i['lastMessageCount']:
if send_emails == "true":
# Send emails to the administrators telling them this flight is being tracked.
sender = 'noreply@adsbreceiver.net'
receivers = ['joe@swiftbyte.com']
message = """From: From ADS-B Receiver <noreply@adsbreceiver.net>
To: To Administrator <joe@swiftbyte.com>
MIME-Version: 1.0
Content-type: text/html
Subject: ADS-B Receiver Flight Notification
<h1>ADS-B Receiver Flight Notification</h1>
<b>The following flight is currently being tracked.</b>
<p>{flight}</p>
<a href="http://{ip_address}/dump1090.php">Click here</a> to view this and any other flights currently being tracked by this receiver.
""".format(flight=name.firstChild.data.strip(), ip_address=socket.gethostbyname(socket.gethostname()))
try:
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail(sender, receivers, message)
if debug_script == "true":
### ADD EMAIL TO THIS LINE
print "Successfully sent a notification for flight",name.firstChild.data.strip()," to email address --- ADD EMAIL ADDRESS HERE ---."
except SMTPException:
print "Error: unable to send email"
if send_tweet == "true":
# Send a tweet to Twitter saying this flight is being tracked.
# https://github.com/bear/python-twitter
message = "The following flight is currently being tracked: {flight}".format(flight=name.firstChild.data.strip())
api = twitter.Api(consumer_key=setting_twitter_cosumer_key, consumer_secret=setting_twitter_consumer_secret, access_token_key=setting_twitter_access_token, access_token_secret=setting_twitter_access_token_secret)
try:
status = api.PostUpdate(message)
print "Successfully sent tweet"
except UnicodeDecodeError:
print "Error: unable to send tweet"
if name.firstChild.data.strip() == i['flight']:
update_data = [('flight',i['flight']),('messages','0')]
update_data = urllib.urlencode(update_data)
request = urllib2.Request(portal_url,"/api/notifications.php?type=update", update_data)
request.add_header("Content-type", "application/x-www-form-urlencoded")
response = urllib2.urlopen(request)
json_response = json.load(response)
### READ JSON FOR RESPONSE
if debug_script == "true":
print "lastMessage count for ",i['flight']," updated to ",i['lastMessageCount'],"."

Wyświetl plik

@ -76,23 +76,25 @@ function AptUpdate() {
echo -e "\e[93m----------------------------------------------------------------------------------------------------\e[97m"
echo ""
sudo apt-get update
echo ""
echo -e "\e[93m----------------------------------------------------------------------------------------------------"
echo -e "\e[92m Finished downloading and updating package lists.\e[39m"
echo ""
read -p "Press enter to continue..." CONTINUE
}
function CheckWhiptail() {
function CheckPrerequisites() {
clear
echo -e "\n\e[91m $ADSB_PROJECTTITLE"
echo ""
echo -e "\e[92m Checking to make sure the whiptail package is installed..."
echo -e "\e[92m Checking to make sure the whiptail and git packages are installed..."
echo -e "\e[93m----------------------------------------------------------------------------------------------------\e[97m"
echo ""
CheckPackage whiptail
CheckPackage git
echo ""
echo -e "\e[93m----------------------------------------------------------------------------------------------------"
echo -e "\e[92m The whiptail package is installed.\e[39m"
echo -e "\e[92m The whiptail and git packages are installed.\e[39m"
echo ""
read -p "Press enter to continue..." CONTINUE
}
@ -106,7 +108,6 @@ function UpdateRepository() {
echo -e "\e[92m Pulling the latest version of the ADS-B Receiver Project repository..."
echo -e "\e[93m----------------------------------------------------------------------------------------------------\e[97m"
echo ""
CheckPackage git
echo -e "\e[94m Switching to branch $PROJECTBRANCH...\e[97m"
echo ""
git checkout $PROJECTBRANCH
@ -138,7 +139,7 @@ function UpdateOperatingSystem() {
}
AptUpdate
CheckWhiptail
CheckPrerequisites
UpdateRepository
## DISPLAY WELCOME SCREEN