Merge pull request #173 from jprochazka/2.0.1

2.0.1
pull/186/head
Joe Prochazka 2016-04-29 23:17:18 -04:00
commit 6e74ee0812
24 zmienionych plików z 817 dodań i 236 usunięć

Wyświetl plik

@ -2,6 +2,29 @@
The following is a history of the changes made to this project.
## v2.0.1 *(April 29th, 2016)*
* Flight logging is now inserted properly into SQLite databases. *(advanced)*
* Remote MySQL database servers now handled properly by install scripts. *(advanced)*
* Separate flights now separated properly when viewing flight plots page. *(advanced)*
* Fixed issue where having the text ";&nbsp" was causing issues when stored in XML.
* Flights with no positions no longer display a PHP error when viewing plots. *(advanced)*
* Flight search box hidden on non advanced installations.
* All times are now stored as UTC time.
* Added the ability to specify the timezone the portal uses to display data.
* MySQL root password check added during script installation. *(advanced)*
* Directory where install/upgrade PHP files reside has been changed.
* Added warning not to remove the adsb-receiver directory after installation.
**Previous patches included in this release...**
* Added the version setting to be used to identifying the currently installed release.
* Added the patch setting to identify the current patch installed.
* Fixed issue with wireless bandwidth not being displayed on the system information page.
* The Python script flights.py should now import the proper libraries. *(advanced)*
* Wlan0 traffic now be displayed by the system gauges.
* Fixed issues pertaining to updating settings using the administration backend.
## v2.0.0 *(April 14th, 2016)*
* Versioning no longer going by date.

Wyświetl plik

@ -146,6 +146,17 @@ if [[ $ADVANCED =~ ^[yY]$ ]]; then
echo " 2) SQLLite"
echo -e "\033[37m"
read -p "Use portal with advanced features? [1] " DATABASEENGINE
# Check if the user is using a remote MySQL database.
if [[ $DATABASEENGINE == 1 ]]; then
echo -e "\033[31m"
echo "Will the database be hosted locally on this device or remotely?"
echo -e "\033[33m"
echo " 1) Locally"
echo " 2) Remotely"
echo -e "\033[37m"
read -p "Use portal with advanced features? [1] " LOCALDATABASE
fi
fi
# Check for prerequisite packages.
@ -158,8 +169,11 @@ if [[ $ADVANCED =~ ^[yY]$ ]]; then
CheckPackage sqlite3
CheckPackage php5-sqlite
else
CheckPackage mysql-server
CheckPackage mysql-client
if [[ $LOCALDATABASE != 2 ]]; then
# Install MySQL locally.
CheckPackage mysql-server
CheckPackage mysql-client
fi
CheckPackage php5-mysql
CheckPackage python-mysqldb
fi
@ -169,37 +183,54 @@ fi
if [[ $ADVANCED =~ ^[yY]$ ]]; then
if [[ $DATABASEENGINE != 2 ]]; then
echo -e "\033[31m"
echo "Create Database and User"
echo "Gathering Database Information"
echo -e "\033[33m"
echo "A database will now be created for you."
echo "Please supply the information pertaining to the new password when asked."
echo ""
echo "If the database will be hosted locally on this device a database will be"
echo "created automatically for you. If you are hosting your database remotely"
echo "you will need to manually create the database and user on the remote device."
echo -e "\033[37m"
if [[ $LOCALDATABASE == 2 ]]; then
# Ask for remote MySQL address if the database is hosted remotely.
read -p "Remote MySQL Server Address: " DATABASEHOST
else
DATABASEHOST="localhost"
fi
read -p "Password for MySQL root user: " MYSQLROOTPASSWORD
read -p "New Database Name: " DATABASENAME
read -p "New Database User Name: " DATABASEUSER
read -p "New Database User Password: " DATABASEPASSWORD
if [[ $DATABASEENGINE == 1 ]] || [[ $DATABASEENGINE == "" ]]; then
echo -e "\033[33m"
echo -e "Creating MySQL database and user...\033[37m"
mysql -uroot -p${MYSQLROOTPASSWORD} -e "CREATE DATABASE ${DATABASENAME};"
mysql -uroot -p${MYSQLROOTPASSWORD} -e "CREATE USER '${DATABASEUSER}'@'localhost' IDENTIFIED BY \"${DATABASEPASSWORD}\";";
mysql -uroot -p${MYSQLROOTPASSWORD} -e "GRANT ALL PRIVILEGES ON ${DATABASENAME}.* TO '${DATABASEUSER}'@'localhost';"
mysql -uroot -p${MYSQLROOTPASSWORD} -e "FLUSH PRIVILEGES;"
# Database creation can only be handled locally.
if [[ $LOCALDATABASE != 2 ]]; then
if [[ $DATABASEENGINE == 1 ]] || [[ $DATABASEENGINE == "" ]]; then
echo -e "\033[33m"
echo -e "Creating MySQL database and user...\033[37m"
mysql -uroot -p${MYSQLROOTPASSWORD} -e "CREATE DATABASE ${DATABASENAME};"
mysql -uroot -p${MYSQLROOTPASSWORD} -e "CREATE USER '${DATABASEUSER}'@'localhost' IDENTIFIED BY \"${DATABASEPASSWORD}\";";
mysql -uroot -p${MYSQLROOTPASSWORD} -e "GRANT ALL PRIVILEGES ON ${DATABASENAME}.* TO '${DATABASEUSER}'@'localhost';"
mysql -uroot -p${MYSQLROOTPASSWORD} -e "FLUSH PRIVILEGES;"
fi
fi
echo -e "\033[31m"
echo "BE SURE TO WRITE THIS INFORMATION DOWN."
echo -e "\033[33m"
echo "Ii will be needed in order to complete the installation of the portal."
echo "This information will be needed in order to complete the installation of the portal."
echo ""
echo "Database Server: localhost"
if [[ $LOCALDATABASE == 2 ]]; then
echo -e "\033[31mNOTE:"
echo "Being you are hosting your database remotely you will need this information to create"
echo "both the database and database user on your remote database server."
echo -e "\033[33m"
fi
echo "Database Server: ${DATABASEHOST}"
echo "Database User: ${DATABASEUSER}"
echo "Database Password: ${DATABASEPASSWORD}"
echo "Database Name: ${DATABASENAME}"
echo -e "\033[37m"
read -p "Press enter to continue..." CONTINUE
fi
# Setup the flight logging script.
@ -221,7 +252,7 @@ EOF
tee ~/adsb-receiver/build/portal/logging/config.json > /dev/null <<EOF
{
"database":{"type":"mysql",
"host":"localhost",
"host":"${DATABASEHOST}",
"user":"${DATABASEUSER}",
"passwd":"${DATABASEPASSWORD}",
"db":"${DATABASENAME}"}

Wyświetl plik

@ -58,28 +58,82 @@ read -p "Press enter to continue..." CONTINUE
clear
echo -e "\033[31m"
echo "Do you wish to enable advanced features?"
echo -e "\033[33m"
echo "ENABLING ADVANCED FEATURES ON DEVICES USING SD CARDS CAN SHORTEN THE LIFE OF THE SD CARD IMMENSELY"
echo -e "\033[33m"
echo "By enabling advanced features the portal will log all flights seen as well as the path of the flight."
echo "This data is stored in either a MySQL or SQLite database. This will result in a lot more data being"
echo "stored on your devices hard drive. Keep this and your devices hardware capabilities in mind before"
echo "selecting to enable these features."
echo ""
echo "You have been warned."
echo -e "\033[37m"
read -p "Use portal with advanced features? [y/N] " ADVANCED
## CHECK IF THE PORTAL HAS BEEN INSTALLED ALREADY
if [[ $ADVANCED =~ ^[yY]$ ]]; then
if [ -f $DOCUMENTROOT/classes/settings.class.php ]; then
echo -e "\033[31m"
echo "Select Database Engine"
echo "It appears a previous verison of the portal has been installled."
echo -e "\033[33m"
echo " 1) MySQL"
echo " 2) SQLLite"
echo "The files and packages making up your portal installation will"
echo "be updated. However you will still need to execute the PHP update"
echo "script to complete the upgrade process by simply visiting the portal"
echo -e "\033[37m"
read -p "Use portal with advanced features? [1] " DATABASEENGINE
read -p "Press enter to continue..." CONTINUE
# Set dome needed variables to be used shortly.
INSTALLED="y"
DRIVER=`grep 'db_driver' $DOCUMENTROOT/classes/settings.class.php | tail -n1 | cut -d\' -f2`
HOST=`grep 'db_host' $DOCUMENTROOT/classes/settings.class.php | tail -n1 | cut -d\' -f2`
if [ $DRIVER != "xml" ]; then
ADVANCED="y"
else
ADVANCED="n"
fi
if [ $DRIVER == "sqlite" ]; then
DATABASEENGINE=2
else
DATABASEENGINE=1
fi
if [ $HOST != "localhost" || $HOST != "127.0.0.1" ]; then
LOCALDATABASE=1
else
LOCALDATABASE=2
fi
else
## ASK IF ADVANCED FEATURES ARE TO BE USED
INSTALLED="n"
echo -e "\033[31m"
echo "Do you wish to enable advanced features?"
echo -e "\033[33m"
echo "ENABLING ADVANCED FEATURES ON DEVICES USING SD CARDS CAN SHORTEN THE LIFE OF THE SD CARD IMMENSELY"
echo ""
echo "By enabling advanced features the portal will log all flights seen as well as the path of the flight."
echo "This data is stored in either a MySQL or SQLite database. This will result in a lot more data being"
echo "stored on your devices hard drive. Keep this and your devices hardware capabilities in mind before"
echo "selecting to enable these features."
echo -e "\033[31m"
echo "You have been warned."
echo -e "\033[37m"
read -p "Use portal with advanced features? [y/N] " ADVANCED
if [[ $ADVANCED =~ ^[yY]$ ]]; then
echo -e "\033[31m"
echo "Select Database Engine"
echo -e "\033[33m"
echo " 1) MySQL"
echo " 2) SQLLite"
echo -e "\033[37m"
read -p "Use portal with advanced features? [1] " DATABASEENGINE
# Check if the user is using a remote MySQL database.
if [[ $DATABASEENGINE != 2 ]]; then
echo -e "\033[31m"
echo "Will the database be hosted locally on this device or remotely?"
echo -e "\033[33m"
echo " 1) Locally"
echo " 2) Remotely"
echo -e "\033[37m"
read -p "Use portal with advanced features? [1] " LOCALDATABASE
fi
fi
fi
## CHECK FOR PREREQUISITE PACKAGES
@ -98,104 +152,134 @@ if [[ $ADVANCED =~ ^[yY]$ ]]; then
CheckPackage sqlite3
CheckPackage php5-sqlite
else
CheckPackage mysql-server
CheckPackage mysql-client
if [[ $LOCALDATABASE != 2 ]]; then
# Install MySQL locally.
CheckPackage mysql-server
CheckPackage mysql-client
fi
CheckPackage php5-mysql
CheckPackage python-mysqldb
fi
fi
## CREATE THE DATABASE IF ADVANCED FEATURES WAS SELECTED
if [[ $INSTALLED == "n" ]]; then
if [[ $ADVANCED =~ ^[yY]$ ]]; then
if [[ $DATABASEENGINE != 2 ]]; then
echo -e "\033[31m"
echo "Create Database and User"
echo -e "\033[33m"
echo "A database will now be created for you."
echo "Please supply the information pertaining to the new password when asked."
echo -e "\033[37m"
read -p "Password for MySQL root user: " MYSQLROOTPASSWORD
read -p "New Database Name: " DATABASENAME
read -p "New Database User Name: " DATABASEUSER
read -p "New Database User Password: " DATABASEPASSWORD
## CREATE THE DATABASE IF ADVANCED FEATURES WAS SELECTED
if [[ $ADVANCED =~ ^[yY]$ ]]; then
if [[ $DATABASEENGINE != 2 ]]; then
echo -e "\033[31m"
echo "Gathering Database Information"
echo -e "\033[33m"
echo "Please supply the information pertaining to the new password when asked."
echo ""
echo "If the database will be hosted locally on this device a database will be"
echo "created automatically for you. If you are hosting your database remotely"
echo "you will need to manually create the database and user on the remote device."
echo -e "\033[37m"
DATABASEHOST="localhost"
if [[ $LOCALDATABASE == 2 ]]; then
# Ask for remote MySQL address if the database is hosted remotely.
read -p "Remote MySQL Server Address: " DATABASEHOST
fi
read -p "Password for MySQL root user: " MYSQLROOTPASSWORD
# Check that the supplied password is correct.
while ! mysql -u root -p$MYSQLROOTPASSWORD -h $DATABASEHOST -e ";" ; do
echo -e "\033[31m"
echo -e "Unable to connect to the MySQL server using the supplied password.\033[37m"
read -p "Password for MySQL root user: " MYSQLROOTPASSWORD
done
read -p "New Database Name: " DATABASENAME
read -p "New Database User Name: " DATABASEUSER
read -p "New Database User Password: " DATABASEPASSWORD
# Create the database and user as well as assign permissions.
if [[ $DATABASEENGINE == 1 ]] || [[ $DATABASEENGINE == "" ]]; then
echo -e "\033[33m"
echo -e "Creating MySQL database and user...\033[37m"
mysql -uroot -p${MYSQLROOTPASSWORD} -h $DATABASEHOST -e "CREATE DATABASE ${DATABASENAME};"
mysql -uroot -p${MYSQLROOTPASSWORD} -h $DATABASEHOST -e "CREATE USER '${DATABASEUSER}'@'localhost' IDENTIFIED BY \"${DATABASEPASSWORD}\";";
mysql -uroot -p${MYSQLROOTPASSWORD} -h $DATABASEHOST -e "GRANT ALL PRIVILEGES ON ${DATABASENAME}.* TO '${DATABASEUSER}'@'localhost';"
mysql -uroot -p${MYSQLROOTPASSWORD} -h $DATABASEHOST -e "FLUSH PRIVILEGES;"
fi
echo -e "\033[31m"
echo "BE SURE TO WRITE THIS INFORMATION DOWN."
echo -e "\033[33m"
echo "This information will be needed in order to complete the installation of the portal."
echo ""
if [[ $LOCALDATABASE == 2 ]]; then
echo -e "\033[31mNOTE:"
echo "Being you are hosting your database remotely you will need this information to create"
echo "both the database and database user on your remote database server."
echo -e "\033[33m"
fi
echo "Database Server: ${DATABASEHOST}"
echo "Database User: ${DATABASEUSER}"
echo "Database Password: ${DATABASEPASSWORD}"
echo "Database Name: ${DATABASENAME}"
echo -e "\033[37m"
read -p "Press enter to continue..." CONTINUE
if [[ $DATABASEENGINE == 1 ]] || [[ $DATABASEENGINE == "" ]]; then
echo -e "\033[33m"
echo -e "Creating MySQL database and user...\033[37m"
mysql -uroot -p${MYSQLROOTPASSWORD} -e "CREATE DATABASE ${DATABASENAME};"
mysql -uroot -p${MYSQLROOTPASSWORD} -e "CREATE USER '${DATABASEUSER}'@'localhost' IDENTIFIED BY \"${DATABASEPASSWORD}\";";
mysql -uroot -p${MYSQLROOTPASSWORD} -e "GRANT ALL PRIVILEGES ON ${DATABASENAME}.* TO '${DATABASEUSER}'@'localhost';"
mysql -uroot -p${MYSQLROOTPASSWORD} -e "FLUSH PRIVILEGES;"
fi
echo -e "\033[31m"
echo "BE SURE TO WRITE THIS INFORMATION DOWN."
## SETUP FLIGHT LOGGING SCRIPT
echo -e "\033[33m"
echo "Ii will be needed in order to complete the installation of the portal."
echo ""
echo "Database Server: localhost"
echo "Database User: ${DATABASEUSER}"
echo "Database Password: ${DATABASEPASSWORD}"
echo "Database Name: ${DATABASENAME}"
echo -e "\033[37m"
read -p "Press enter to continue..." CONTINUE
fi
## SETUP FLIGHT LOGGING SCRIPT
echo -e "\033[33m"
echo -e "Creating configuration file...\033[37m"
case $DATABASEENGINE in
"2")
tee $BUILDDIR/portal/logging/config.json > /dev/null <<EOF
echo -e "Creating configuration file...\033[37m"
case $DATABASEENGINE in
"2")
tee $BUILDDIR/portal/logging/config.json > /dev/null <<EOF
{
"database":{"type":"sqlite",
"host":"",
"user":"",
"passwd":"",
"db":"${HTMLDIR}/data/portal.sqlite"}
"db":"${DOCUMENTROOT}/data/portal.sqlite"}
}
EOF
;;
*)
tee $BUILDDIR/portal/logging/config.json > /dev/null <<EOF
;;
*)
tee $BUILDDIR/portal/logging/config.json > /dev/null <<EOF
{
"database":{"type":"mysql",
"host":"localhost",
"host":"${DATABASEHOST}",
"user":"${DATABASEUSER}",
"passwd":"${DATABASEPASSWORD}",
"db":"${DATABASENAME}"}
}
EOF
;;
esac
;;
esac
# Create and set permissions on the flight logging maintainance script.
PYTHONPATH=`which python`
tee $BUILDDIR/portal/logging/flights-maint.sh > /dev/null <<EOF
# Create and set permissions on the flight logging maintainance script.
PYTHONPATH=`which python`
tee $BUILDDIR/portal/logging/flights-maint.sh > /dev/null <<EOF
#!/bin/sh
while true
do
sleep 30
${PYTHONPATH} ${BUILDDIR}/portal/logging/flights.py
${PYTHONPATH} ${BUILDDIR}/portal/logging/flights.py
done
EOF
chmod +x $BUILDDIR/portal/logging/flights-maint.sh
chmod +x $BUILDDIR/portal/logging/flights-maint.sh
# Add flight logging maintainance script to rc.local.
if ! grep -Fxq "${BUILDDIR}/portal/logging/flights-maint.sh &" /etc/rc.local; then
# Add flight logging maintainance script to rc.local.
if ! grep -Fxq "${BUILDDIR}/portal/logging/flights-maint.sh &" /etc/rc.local; then
echo -e "\033[33m"
echo -e "Adding startup line to rc.local...\033[37m"
lnum=($(sed -n '/exit 0/=' /etc/rc.local))
((lnum>0)) && sudo sed -i "${lnum[$((${#lnum[@]}-1))]}i ${BUILDDIR}/portal/logging/flights-maint.sh &\n" /etc/rc.local
fi
# Start flight logging.
echo -e "\033[33m"
echo -e "Adding startup line to rc.local...\033[37m"
lnum=($(sed -n '/exit 0/=' /etc/rc.local))
((lnum>0)) && sudo sed -i "${lnum[$((${#lnum[@]}-1))]}i ${BUILDDIR}/portal/logging/flights-maint.sh &\n" /etc/rc.local
echo -e "Starting flight logging...\033[37m"
nohup ${BUILDDIR}/portal/logging/flights-maint.sh > /dev/null 2>&1 &
fi
# Start flight logging.
echo -e "\033[33m"
echo -e "Starting flight logging...\033[37m"
${BUILDDIR}/portal/logging/flights-maint.sh &
fi
## SETUP THE PORTAL WEBSITE
@ -207,9 +291,9 @@ sudo cp -R ${HTMLDIR}/* ${DOCUMENTROOT}
echo -e "\033[33m"
echo "Setting permissions on portal folders...\033[37m"
sudo chmod 777 ${DOCUMENTROOT}/graphs/
sudo chmod 777 ${DOCUMENTROOT}/classes/
sudo chmod 777 ${DOCUMENTROOT}/data/
sudo chmod 666 ${DOCUMENTROOT}/data/*
sudo chmod 666 ${DOCUMENTROOT}/classes/settings.class.php
echo -e "\033[33m"
echo "Setting up performance graphs..."
@ -325,7 +409,7 @@ echo -e "\033[37m"
read -p "Press enter to continue..." CONTINUE
# Display further portal setup instructions.
echo -e "\033[33m"
echo -e "\033[31m"
echo "PORTAL SETUP IS NOT YET COMPLETE"
echo -e "\033[33m"
echo "In order to complete the portal setup process visit the following URL in your favorite web browser."

Wyświetl plik

@ -56,6 +56,10 @@
// Get titles and dates for all blog posts.
$post = $blog->getPostByTitle(urldecode($_GET['title']));
// Properly format the date and convert to slected time zone.
$date = new DateTime($post['date'], new DateTimeZone('UTC'));
$date->setTimezone(new DateTimeZone($common->getSetting('timeZone')));
$postDate = $date->format($common->getSetting('dateFormat'));
////////////////
// BEGIN HTML
@ -67,7 +71,7 @@
<hr />
<h2>Delete Blog Post</h2>
<h3><?php echo $post['title']; ?></h3>
<p>Posted <strong><?php echo date_format(date_create($post['date']), "F jS, Y"); ?></strong> by <strong><?php echo $common->getAdminstratorName($post['author']); ?></strong>.</p>
<p>Posted <strong><?php echo $postDate; ?></strong> by <strong><?php echo $common->getAdminstratorName($post['author']); ?></strong>.</p>
<div class="alert alert-danger" role="alert">
<p>
<strong>Confirm Delete</strong><br />

Wyświetl plik

@ -59,6 +59,12 @@
// Get titles and dates for all blog posts.
$post = $blog->getPostByTitle(urldecode($_GET['title']));
// Properly format the date and convert to slected time zone.
$date = new DateTime($post['date'], new DateTimeZone('UTC'));
$date->setTimezone(new DateTimeZone($common->getSetting('timeZone')));
$postDate = $date->format($common->getSetting('dateFormat'));
////////////////
// BEGIN HTML
@ -80,7 +86,7 @@
<hr />
<h2>Edit Blog Post</h2>
<h3><?php echo $post['title']; ?></h3>
<p>Posted <strong><?php echo date_format(date_create($post['date']), "F jS, Y"); ?></strong> by <strong><?php echo $common->getAdminstratorName($post['author']); ?></strong>.</p>
<p>Posted <strong><?php echo $postDate; ?></strong> by <strong><?php echo $common->getAdminstratorName($post['author']); ?></strong>.</p>
<form id="edit-blog-post" method="post" action="edit.php?title=<?php echo urlencode($post['title']); ?>">
<div class="form-group">
<textarea id="contents" name="contents"><?php echo $post['contents']; ?></textarea>

Wyświetl plik

@ -76,7 +76,14 @@
<tr>
<td><a href="edit.php?title=<?php echo urlencode($post['title']); ?>">edit</a> <a href="delete.php?title=<?php echo urlencode($post['title']); ?>">delete</a></td>
<td><?php echo $post['title']; ?></td>
<td><?php echo $post['date']; ?></td>
<td>
<?php
// Properly format the date and convert to slected time zone.
$date = new DateTime($post['date'], new DateTimeZone('UTC'));
$date->setTimezone(new DateTimeZone($common->getSetting('timeZone')));
echo $date->format($common->getSetting('dateFormat'));
?>
</td>
</tr>
<?php
}
@ -104,4 +111,4 @@
</ul>
<?php
require_once('../includes/footer.inc.php');
?>
?>

Wyświetl plik

@ -9,22 +9,10 @@
<link rel="stylesheet" href="/admin/assets/css/bootstrap-theme.min.css">
<?php if (basename($_SERVER['PHP_SELF']) == "index.php") { ?>
<link rel="stylesheet" href="/admin/assets/css/jquery.datetimepicker.css">
<?php } ?>
<?php if (basename($_SERVER['PHP_SELF']) == "install.php") { ?>
<link rel="stylesheet" href="/admin/assets/css/jquery.steps.css">
<?php } ?>
<link rel="stylesheet" href="/admin/assets/css/admin.css">
<?php if (basename($_SERVER['PHP_SELF']) == "install.php") { ?>
<link rel="stylesheet" href="/admin/assets/css/install.css">
<?php } ?>
<script src="/admin/assets/js/jquery-2.2.1.min.js"></script>
<script src="/admin/assets/js/bootstrap.min.js"></script>
<?php if (basename($_SERVER['PHP_SELF']) == "install.php") { ?>
<script src="/admin/assets/js/jquery.steps.min.js"></script>
<script src="/admin/assets/js/js.cookie-2.1.0.min.js"></script>
<script src="/admin/assets/js/jquery.validate.min.js"></script>
<script src="/admin/assets/js/install.js"></script>
<?php } ?>
<?php if (basename($_SERVER['PHP_SELF']) == "index.php") { ?>
<script src="/admin/assets/js/index.js"></script>
<script src="/admin/assets/js/jquery.datetimepicker.full.min.js"></script>
@ -58,4 +46,4 @@
</div>
</div>
</nav>
<div class="container">
<div class="container">

Wyświetl plik

@ -171,6 +171,7 @@
$common->updateSetting("measurementTemperature", $_POST['measurementTemperature']);
$common->updateSetting("measurementBandwidth", $_POST['measurementBandwidth']);
$common->updateSetting("networkInterface", $_POST['networkInterface']);
$common->updateSetting("timeZone", $_POST['timeZone']);
// Purge older flight positions.
if (isset($_POST['purgepositions'])) {
@ -217,6 +218,7 @@
$currentTemplate = $common->getSetting("template");
$defaultPage = $common->getSetting("defaultPage");
$dateFormat = $common->getSetting("dateFormat");
$timeZone = $common->getSetting("timeZone");
// Get navigation settings from settings.xml.
$enableFlights = $common->getSetting("enableFlights");
@ -258,6 +260,13 @@
}
closedir($directoryHandle);
// Function used to format offsets of timezones.
function formatOffset($offset) {
return sprintf('%+03d:%02u', floor($offset / 3600), floor(abs($offset) % 3600 / 60));
}
$utc = new DateTimeZone('UTC');
$dt = new DateTime('now', $utc);
////////////////
// BEGIN HTML
@ -317,19 +326,35 @@
<div class="form-group">
<label for="defaultPage">Date Format</label>
<div class="radio">
<label><input type="radio" name="dateFormatSlelection" value="F jS, Y"<?php ($dateFormat == "F jS, Y" ? print ' checked' : ''); ?>>October 16, 2015</label>
<label><input type="radio" name="dateFormatSlelection" value="F jS, Y g:i A"<?php ($dateFormat == "F jS, Y g:i A" ? print ' checked' : ''); ?>>October 16, 2015 12:00 PM</label>
</div>
<div class="radio">
<label><input type="radio" name="dateFormatSlelection" value="Y-m-d"<?php ($dateFormat == "Y-m-d" ? print ' checked' : ''); ?>>2015-10-16</label>
<label><input type="radio" name="dateFormatSlelection" value="Y-m-d g:i A"<?php ($dateFormat == "Y-m-d g:i A" ? print ' checked' : ''); ?>>2015-10-16 12:00 PM</label>
</div>
<div class="radio">
<label><input type="radio" name="dateFormatSlelection" value="m/d/Y"<?php ($dateFormat == "m/d/Y" ? print ' checked' : ''); ?>>16/10/2015</label>
<label><input type="radio" name="dateFormatSlelection" value="m/d/Y g:i A"<?php ($dateFormat == "m/d/Y g:i A" ? print ' checked' : ''); ?>>16/10/2015 12:00 PM</label>
</div>
<div class="radio">
<label><input type="radio" name="dateFormatSlelection" value="d/m/Y"<?php ($dateFormat == "d/m/Y" ? print ' checked' : ''); ?>>10/16/2015</label>
<label><input type="radio" name="dateFormatSlelection" value="d/m/Y g:i A"<?php ($dateFormat == "d/m/Y g:i A" ? print ' checked' : ''); ?>>10/16/2015 12:00 PM</label>
</div>
<input type="text" class="form-control" id="dateFormat" name="dateFormat" value="<?php echo $dateFormat; ?>">
</div>
<div class="form-group">
<label for="timeZone">Time Zone</label>
<select class="form-control" id="timeZone" name="timeZone">
<?php
foreach (DateTimeZone::listIdentifiers() as $tz) {
$currentTimeZone = new DateTimeZone($tz);
$offSet = $currentTimeZone->getOffset($dt);
$transition = $currentTimeZone->getTransitions($dt->getTimestamp(), $dt->getTimeStamp());
$abbr = $transition[0]['abbr'];
?>
<option name="timeZone" value="<?php echo $tz; ?>"<?php ($tz == $timeZone ? print " selected" : ""); ?>><?php echo $tz; ?> [<?php echo $abbr; ?> <?php echo formatOffset($offSet);?>]</option>
<?php
}
?>
</select>
</div>
</div>
</div>
</div>
@ -385,7 +410,7 @@
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="enablePfclient" value="TRUE"<?php ($enablePfclient == 1 ? print ' checked' : ''); ?>> Enable Planfinder ADS-B Client link.
<input type="checkbox" name="enablePfclient" value="TRUE"<?php ($enablePfclient == 1 ? print ' checked' : ''); ?>> Enable Planefinder ADS-B Client link.
</label>
</div>
</div>

Wyświetl plik

@ -54,7 +54,11 @@
$post['contents'] = substr($post['contents'], 0, strpos($post['contents'], '{more}'));
}
$post['author'] = $common->getAdminstratorName($post['author']);
$post['date'] = date_format(date_create($post['date']), $common->getSetting('dateFormat'));
// Properly format the date and convert to slected time zone.
$date = new DateTime($post['date'], new DateTimeZone('UTC'));
$date->setTimezone(new DateTimeZone($common->getSetting('timeZone')));
$post['date'] = $date->format($common->getSetting('dateFormat'));
}
// Pagination.
@ -66,4 +70,4 @@
$pageData['pageLinks'] = count($allPosts) / $itemsPerPage;
$template->display($pageData);
?>
?>

Wyświetl plik

@ -115,7 +115,7 @@
$common = new common();
$dbh = $common->pdoOpen();
"SELECT COUNT(*) FROM ".$settings::db_prefix."blogPosts WHERE title = :title";
$sql = "SELECT COUNT(*) FROM ".$settings::db_prefix."blogPosts WHERE title = :title";
$sth = $dbh->prepare($sql);
$sth->bindParam(':title', $title, PDO::PARAM_STR, 100);
$sth->execute();
@ -192,7 +192,7 @@
$blogPosts = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."blogPosts.xml");
$blogPost = $blogPosts->addChild('blogPost', '');
$blogPost->addChild('title', $title);
$blogPost->addChild('date', date('Y-m-d H:i:s'));
$blogPost->addChild('date', gmdate('Y-m-d H:i:s', time()));
$blogPost->addChild('author', $author);
$blogPost->addChild('contents', $contents);
$dom = dom_import_simplexml($blogPosts)->ownerDocument;
@ -207,7 +207,7 @@
$sql = "INSERT INTO ".$settings::db_prefix."blogPosts (title, date, author, contents) VALUES (:title, :date, :author, :contents)";
$sth = $dbh->prepare($sql);
$sth->bindParam(':title', $title, PDO::PARAM_STR, 100);
$sth->bindParam(':date', date('Y-m-d H:i:s'), PDO::PARAM_STR, 20);
$sth->bindParam(':date', gmdate('Y-m-d H:i:s', time()), PDO::PARAM_STR, 20);
$sth->bindParam(':author', $author, PDO::PARAM_STR, 100);
$sth->bindParam(':contents', $contents, PDO::PARAM_STR, 20000);
$sth->execute();

Wyświetl plik

@ -69,6 +69,10 @@
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."settings.class.php");
$settings = new settings();
if ($name == "dataStorage") {
return $settings::db_driver;
}
if ($settings::db_driver == 'xml') {
// XML
$theseSettings = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."settings.xml");

Wyświetl plik

@ -31,18 +31,18 @@
class settings {
// Database Settings
const db_driver = 'mysql';
const db_database = 'adsb';
const db_username = 'adsbuser';
const db_password = 'password';
const db_host = 'localhost';
const db_driver = 'xml';
const db_database = '';
const db_username = '';
const db_password = '';
const db_host = '';
const db_prefix = 'adsb_';
// Security Settings
const sec_length = 6;
// PDO Settings
const pdo_debug = TRUE;
const pdo_debug = FALSE;
}
?>

Wyświetl plik

@ -35,8 +35,15 @@
function display(&$pageData) {
$common = new common($this);
// The Base URL of this page (needed for Plane Finder client link)
$pageData['baseurl'] = $common->getBaseUrl();
// Check if the portal is installed or needs upgraded.
if (!file_exists($_SERVER['DOCUMENT_ROOT']."/classes/settings.class.php")) {
header ("Location: /install/install.php");
} elseif ($common->getSetting("version") != "2.0.1"){
header ("Location: /install/upgrade.php");
}
// The Base URL of this page (needed for Plane Finder client link)
$pageData['baseurl'] = $common->getBaseUrl();
// Load the master template.
$master = $this->readTemplate('master.tpl');

Wyświetl plik

@ -45,17 +45,31 @@
// The title of this page.
$pageData['title'] = "Flights Seen";
// Add blog post data to the $pageData array.
// Add flight data to the $pageData array using the search string if available.
if (isset($_POST['flight'])) {
$searchString = $_POST['flight'];
} else {
$searchString = "";
}
$dbh = $common->pdoOpen();
$sql = "SELECT * FROM ".$settings::db_prefix."flights WHERE flight LIKE ? ORDER BY lastSeen DESC, flight";
$sth = $dbh->prepare($sql);
$sth->bindValue(1, "%".$_POST['flight']."%", PDO::PARAM_STR);
$sth->bindValue(1, "%".$searchString."%", PDO::PARAM_STR);
$sth->execute();
$flights = $sth->fetchAll();
$sth = NULL;
$dbh = NULL;
//$pageData['flights'] = $flights;
// Change dates to the proper timezone and format.
foreach ($flights as &$flight) {
$date = new DateTime($flight['firstSeen'], new DateTimeZone('UTC'));
$date->setTimezone(new DateTimeZone($common->getSetting('timeZone')));
$flight['firstSeen'] = $date->format($common->getSetting('dateFormat'));
$date = new DateTime($flight['lastSeen'], new DateTimeZone('UTC'));
$date->setTimezone(new DateTimeZone($common->getSetting('timeZone')));
$flight['lastSeen'] = $date->format($common->getSetting('dateFormat'));
}
// Pagination.
$itemsPerPage = 25;

Wyświetl plik

@ -31,16 +31,15 @@
require_once('../classes/common.class.php');
$common = new common();
// THE FOLLOWING COMMENTED LINES WILL BE USED IN FUTURE RELEASES
///////////////////////////////////////////////////////////////////
// The most current stable release.
//$currentRelease = "2016-02-18";
$thisVersion = "2.0.1";
// Begin the upgrade process if this release is newer than what is installed.
//if ($currentRelease > $common->getRelease) {
// header ("Location: upgrade.php");
//}
if (file_exists("../classes/settings.class.php")) {
header ("Location: upgrade.php");
}
// BEGIN FRESH INSTALLATION
$installed = FALSE;
//if ($common->postBack()) {
@ -73,9 +72,9 @@
if (isset($_POST['host']))
$dbHost = $_POST['host'];
$dbPrefix = "";
if (isset($_POST['prefix']))
$dbPrefix = $_POST['prefix'];
$dbPrefix = "adsb_";
//if (isset($_POST['prefix']))
// $dbPrefix = $_POST['prefix'];
// Create or edit the settings.class.php file.
$content = <<<EOF
@ -110,7 +109,6 @@
/////////////////////////////////////////////////////////////////////////////////////
class settings {
// Database Settings
const db_driver = '$_POST[driver]';
const db_database = '$dbDatabase';
@ -182,36 +180,36 @@ EOF;
switch ($_POST['driver']) {
case "mysql":
// MySQL
$administratorsSql = 'CREATE TABLE '.$dbPrifix.'administrators (
$administratorsSql = 'CREATE TABLE '.$dbPrefix.'administrators (
id INT(11) PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
email VARCHAR(75) NOT NULL,
login VARCHAR(25) NOT NULL,
password VARCHAR(255) NOT NULL);';
$aircraftSql = 'CREATE TABLE '.$dbPrifix.'aircraft(
$aircraftSql = 'CREATE TABLE '.$dbPrefix.'aircraft (
id INT(11) AUTO_INCREMENT PRIMARY KEY,
icao VARCHAR(24) NOT NULL,
firstSeen VARCHAR(100) NOT NULL,
lastSeen VARCHAR(100) NOT NULL);';
$blogPostsSql = 'CREATE TABLE '.$dbPrifix.'blogPosts (
firstSeen datetime NOT NULL,
lastSeen datetime NOT NULL);';
$blogPostsSql = 'CREATE TABLE '.$dbPrefix.'blogPosts (
id INT(11) PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(100) NOT NULL,
date VARCHAR(20) NOT NULL,
date datetime NOT NULL,
author VARCHAR(100) NOT NULL,
contents VARCHAR(20000) NOT NULL);';
$flightNotificationsSql = 'CREATE TABLE '.$dbPrifix.'flightNotifications (
$flightNotificationsSql = 'CREATE TABLE '.$dbPrefix.'flightNotifications (
id INT(11) PRIMARY KEY AUTO_INCREMENT,
flight VARCHAR(10) NOT NULL);';
$flightsSql = 'CREATE TABLE '.$dbPrifix.'flights(
$flightsSql = 'CREATE TABLE '.$dbPrefix.'flights(
id INT(11) AUTO_INCREMENT PRIMARY KEY,
aircraft INT(11) NOT NULL,
flight VARCHAR(100) NOT NULL,
firstSeen VARCHAR(100) NOT NULL,
lastSeen VARCHAR(100) NOT NULL);';
$positionsSql = 'CREATE TABLE adsb_positions(
firstSeen datetime NOT NULL,
lastSeen datetime NOT NULL);';
$positionsSql = 'CREATE TABLE '.$dbPrefix.'positions (
id INT(11) AUTO_INCREMENT PRIMARY KEY,
flight BIGINT NOT NULL,
time VARCHAR(100) NOT NULL,
time datetime NOT NULL,
message INT NOT NULL,
squawk INT(4) NULL,
latitude DOUBLE NOT NULL,
@ -220,7 +218,7 @@ EOF;
altitude INT(5) NOT NULL,
verticleRate INT(4) NOT NULL,
speed INT(4) NULL);';
$settingsSql = 'CREATE TABLE '.$dbPrifix.'settings (
$settingsSql = 'CREATE TABLE '.$dbPrefix.'settings (
id INT(11) PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50) NOT NULL,
value VARCHAR(100) NOT NULL);';
@ -233,27 +231,27 @@ EOF;
email VARCHAR(75) NOT NULL,
login VARCHAR(25) NOT NULL,
password VARCHAR(255) NOT NULL);';
$aircraftSql = 'CREATE TABLE '.$dbPrifix.'aircraft(
$aircraftSql = 'CREATE TABLE '.$dbPrefix.'aircraft (
id SERIAL PRIMARY KEY,
icao VARCHAR(24) NOT NULL,
firstSeen VARCHAR(100) NOT NULL,
lastSeen VARCHAR(100) NOT NULL);';
$blogPostsSql = 'CREATE TABLE '.$dbPrifix.'blogPosts (
$blogPostsSql = 'CREATE TABLE '.$dbPrefix.'blogPosts (
id SERIAL PRIMARY KEY,
title VARCHAR(100) NOT NULL,
date VARCHAR(20) NOT NULL,
author VARCHAR(100) NOT NULL,
contents VARCHAR(20000) NOT NULL);';
$flightNotificationsSql = 'CREATE TABLE '.$dbPrifix.'flightNotifications (
$flightNotificationsSql = 'CREATE TABLE '.$dbPrefix.'flightNotifications (
id SERIAL PRIMARY KEY,
flight VARCHAR(10) NOT NULL);';
$flightsSql = 'CREATE TABLE '.$dbPrifix.'flights(
$flightsSql = 'CREATE TABLE '.$dbPrefix.'flights (
id SERIAL PRIMARY KEY,
aircraft INT(11) NOT NULL,
flight VARCHAR(100) NOT NULL,
firstSeen VARCHAR(100) NOT NULL,
lastSeen VARCHAR(100) NOT NULL);';
$positionsSql = 'CREATE TABLE adsb_positions(
$positionsSql = 'CREATE TABLE '.$dbPrefix.'positions (
id SERIAL PRIMARY KEY,
flight BIGINT NOT NULL,
time VARCHAR(100) NOT NULL,
@ -265,7 +263,7 @@ EOF;
altitude INT(5) NOT NULL,
verticleRate INT(4) NOT NULL,
speed INT(4) NULL);';
$settingsSql = 'CREATE TABLE '.$dbPrifix.'settings (
$settingsSql = 'CREATE TABLE '.$dbPrefix.'settings (
id SERIAL PRIMARY KEY,
name VARCHAR(50) NOT NULL,
value VARCHAR(100) NOT NULL);';
@ -278,30 +276,30 @@ EOF;
email TEXT NOT NULL,
login TEXT NOT NULL,
password TEXT NOT NULL);';
$aircraftSql = 'CREATE TABLE '.$dbPrifix.'aircraft(
$aircraftSql = 'CREATE TABLE '.$dbPrefix.'aircraft (
id INTEGER PRIMARY KEY AUTOINCREMENT,
icao TEXT NOT NULL,
firstSeen TEXT NOT NULL,
lastSeen TEXT NOT NULL);';
$blogPostsSql = 'CREATE TABLE '.$dbPrifix.'blogPosts (
firstSeen DATETIME NOT NULL,
lastSeen DATETIME NOT NULL);';
$blogPostsSql = 'CREATE TABLE '.$dbPrefix.'blogPosts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
date TEXT NOT NULL,
date DATETIME NOT NULL,
author TEXT NOT NULL,
contents TEXT NOT NULL);';
$flightNotificationsSql = 'CREATE TABLE '.$dbPrifix.'flightNotifications (
$flightNotificationsSql = 'CREATE TABLE '.$dbPrefix.'flightNotifications (
id INTEGER PRIMARY KEY AUTOINCREMENT,
flight TEXT NOT NULL);';
$flightsSql = 'CREATE TABLE '.$dbPrifix.'flights(
$flightsSql = 'CREATE TABLE '.$dbPrefix.'flights (
id INTEGER PRIMARY KEY AUTOINCREMENT,
aircraft INTEGER NOT NULL,
flight TEXT NOT NULL,
firstSeen TEXT NOT NULL,
lastSeen TEXT NOT NULL);';
$positionsSql = 'CREATE TABLE adsb_positions(
firstSeen DATETIME NOT NULL,
lastSeen DATETIME NOT NULL);';
$positionsSql = 'CREATE TABLE '.$dbPrefix.'positions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
flight TEXT NOT NULL,
time TEXT NOT NULL,
time DATETIME NOT NULL,
message INTEGER NOT NULL,
squawk INTEGER NULL,
latitude INTEGER NOT NULL,
@ -310,7 +308,7 @@ EOF;
altitude INTEGER NOT NULL,
verticleRate INTEGER NOT NULL,
speed INTEGER NULL);';
$settingsSql = 'CREATE TABLE '.$dbPrifix.'settings (
$settingsSql = 'CREATE TABLE '.$dbPrefix.'settings (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
value TEXT NOT NULL);';
@ -351,10 +349,12 @@ EOF;
}
// Add settings.
$common->addSetting('version', $thisVersion);
$common->addSetting('patch', '');
$common->addSetting('siteName', 'ADS-B Receiver');
$common->addSetting('template', 'default');
$common->addSetting('defaultPage', 'blog.php');
$common->addSetting('dateFormat', 'F jS, Y');
$common->addSetting('dateFormat', 'F jS, Y g:i A');
$common->addSetting('enableBlog', TRUE);
$common->addSetting('enableInfo', TRUE);
$common->addSetting('enableGraphs', TRUE);
@ -376,6 +376,7 @@ EOF;
$common->addSetting('enableFlightNotifications', FALSE);
$common->addSetting('emailFrom', 'noreply@adsbreceiver.net');
$common->addSetting('emailReplyTo', 'noreply@adsbreceiver.net');
$common->addSetting('timeZone', $_POST['timeZone']);
if ($_POST['driver'] == "xml")
$common->addSetting('enableFlights', FALSE);
@ -400,30 +401,46 @@ EOF;
if (is_writable($applicationDirectory.'data'))
$writableData = TRUE;
$writeableClass = FALSE;
if (is_writable($applicationDirectory.'classes/settings.class.php'))
$writeableClass = TRUE;
$writeableClasses = FALSE;
if (is_writable($applicationDirectory.'classes'))
$writeableClasses = TRUE;
// Function used to format offsets of timezones.
///////////////////////////////////////////////////
function formatOffset($offset) {
return sprintf('%+03d:%02u', floor($offset / 3600), floor(abs($offset) % 3600 / 60));
}
$utc = new DateTimeZone('UTC');
$dt = new DateTime('now', $utc);
// Display HTML
//////////////////
require_once('includes/header.inc.php');
require_once('../admin/includes/header.inc.php');
// Display the instalation wizard.
if (!$installed) {
?>
<link rel="stylesheet" href="/admin/assets/css/jquery.steps.css">
<link rel="stylesheet" href="/admin/assets/css/install.css">
<script src="/admin/assets/js/jquery.steps.min.js"></script>
<script src="/admin/assets/js/js.cookie-2.1.0.min.js"></script>
<script src="/admin/assets/js/jquery.validate.min.js"></script>
<script src="/admin/assets/js/install.js"></script>
<h1>ADS-B Receiver Portal Setup</h1>
<p>The following wizard will guide you through the setup process.</p>
<div class="padding"></div>
<form id="install-form" method="post" action="install.php">
<form id="install-form" method="post" action="index.php">
<div class="form-group">
<h2>Directory Permissions</h2>
<section>
<div class="alert <?php echo ($writableData == TRUE ? 'alert-success' : 'alert-danger' ); ?>">The <strong>data</strong> directory is<?php echo ($writableData ? ' ' : ' not' ); ?> writable.</div>
<div class="alert <?php echo ($writeableClass ? 'alert-success' : 'alert-danger' ); ?>">The <strong>settings.class.php</strong> file is<?php echo ($writeableClass ? ' ' : ' not' ); ?> writable.</div>
<div class="alert <?php echo ($writeableClasses ? 'alert-success' : 'alert-danger' ); ?>">The <strong>classes</strong> directory is<?php echo ($writeableClasses ? ' ' : ' not' ); ?> writable.</div>
<input type="hidden" name="permissions" id="permissions" value="<?php echo $writableData; ?>">
<?php if (!$writableData || !$writeableClass) {?>
<?php if (!$writableData || !$writeableClasses) {?>
<p>
Please fix the permissions for the following directory and/or file to make sure they are writable before proceeding.
Once you have made the necessary changes please <a href="#" onclick="location.reload();">reload</a> this page to allow the installer to recheck permissions.
@ -434,7 +451,7 @@ EOF;
<h2>Data Storage</h2>
<section>
<label for="driver">Database Type</label>
<select class="form-control" name="driver" id="driver"> name="driver">
<select class="form-control" name="driver" id="driver">
<option value="xml">XML (Lite installation only)</option>
<option value="mysql">MySQL (Advanced installation only)</option>
<option value="sqlite">SQLite (Advanced installation only)</option>
@ -462,6 +479,24 @@ EOF;
<p id="required-p">(*) Required</p>
</section>
<h2>Portal Settings</h2>
<section>
<div class="form-group">
<label for="timeZone">Time Zone</label>
<select class="form-control" id="timeZone" name="timeZone">
<?php
foreach (DateTimeZone::listIdentifiers() as $timeZone) {
$currentTimeZone = new DateTimeZone($timeZone);
$offSet = $currentTimeZone->getOffset($dt);
$transition = $currentTimeZone->getTransitions($dt->getTimestamp(), $dt->getTimeStamp());
$abbr = $transition[0]['abbr'];
echo '<option name="timeZone" value="'.$timeZone.'">'.$timeZone.' ['.$abbr.' '.formatOffset($offSet).']</option>';
}
?>
</select>
</div>
</section>
<h2>Administrator Account</h2>
<section>
<div class="form-group">
@ -499,8 +534,8 @@ EOF;
At this time you should also ensure that the file containing the settings you specified is no longer writeable.
Please log into your device and run the following commands to accomplish these tasks.
</p>
<pre>sudo rm -f <?php echo $_SERVER['DOCUMENT_ROOT']; ?>/admin/install.php</pre>
<pre>sudo chmod -w <?php echo $_SERVER['DOCUMENT_ROOT']; ?>/classes/settings.class.php</pre>
<pre>sudo rm -f <?php echo $_SERVER["DOCUMENT_ROOT"]; ?>/install/</pre>
<pre>sudo chmod -w <?php echo $_SERVER["DOCUMENT_ROOT"]; ?>/classes/settings.class.php</pre>
<p>Once you have done so you can log in and administrate your portal <a href="/admin/">here</a>.</p>
<p>
If you experienced any issues or have any questions or suggestions you would like to make regarding this project
@ -508,5 +543,5 @@ EOF;
</p>
<?php
}
require_once('includes/footer.inc.php');
require_once("../admin/includes/footer.inc.php");
?>

Wyświetl plik

@ -0,0 +1,206 @@
<?php
/////////////////////////////////////////////////////////////////////////////////////
// ADS-B RECEIVER 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. //
/////////////////////////////////////////////////////////////////////////////////////
require_once('../classes/common.class.php');
require_once('../classes/settings.class.php');
$common = new common();
$settings = new settings();
// The most current stable release.
$thisVersion = "2.0.1";
// Begin the upgrade process if this release is newer than what is installed.
if ($common->getSetting("version") == $thisVersion) {
header ("Location: /");
}
$error = FALSE;
#errorMessage = "No error message returned.";
try {
// Change tables containing datetime data to datetime.
if ($settings::db_driver != "xml") {
// ALter MySQL tables.
if ($settings::db_driver != "mysql") {
$dbh = $common->pdoOpen();
$sql = "ALTER TABLE ".$settings::db_prefix."aircraft MODIFY firstSeen DATETIME NOT NULL";
$sth = $dbh->prepare($sql);
$sth->execute();
$sth = NULL;
$sql = "ALTER TABLE adsb_aircraft MODIFY lastSeen DATETIME NOT NULL";
$sth = $dbh->prepare($sql);
$sth->execute();
$sth = NULL;
$sql = "ALTER TABLE adsb_blogPosts MODIFY date DATETIME NOT NULL";
$sth = $dbh->prepare($sql);
$sth->execute();
$sth = NULL;
$sql = "ALTER TABLE adsb_flights MODIFY firstSeen DATETIME NOT NULL";
$sth = $dbh->prepare($sql);
$sth->execute();
$sth = NULL;
$sql = "ALTER TABLE adsb_flights MODIFY firstSeen DATETIME NOT NULL";
$sth = $dbh->prepare($sql);
$sth->execute();
$sth = NULL;
$sql = "ALTER TABLE adsb_positions MODIFY time DATETIME NOT NULL";
$sth = $dbh->prepare($sql);
$sth->execute();
$sth = NULL;
$dbh = NULL;
}
// Convert times to GMT.
// You may wish to uncomment this block of code in order to convert existing times
// stored in the database to UTC/GMT time. Before doing so it is recommended that
// you set the setting max_execution_time setting to a large amount of time in your
// php.ini file. Depending on the amount of flight data logged this may take quite
// some time for this upgrade script to complete so be patient and let it run it's
// course. Afterwards set the max_execution_time back to it previous setting.
/*
$dbh = $common->pdoOpen();
$sql = "SELECT id, firstSeen, lastSeen FROM ".$settings::db_prefix."aircraft";
$sth = $dbh->prepare($sql);
$sth->execute();
$aircraft = $sth->fetchAll();
$sth = NULL;
$dbh = NULL;
foreach ($aircraft as $airframe) {
$dbh = $common->pdoOpen();
$sql = "UPDATE ".$settings::db_prefix."aircraft SET firstSeen = :firstSeen, lastSeen = :lastSeen WHERE id = :id";
$sth = $dbh->prepare($sql);
$sth->bindParam(':firstSeen', gmdate("Y-m-d H:i:s", $airframe["firstSeen"]), PDO::PARAM_STR);
$sth->bindParam(':lastSeen', gmdate("Y-m-d H:i:s", $airframe["lastSeen"]), PDO::PARAM_STR);
$sth->bindParam(':id', $airframe["id"], PDO::PARAM_INT);
$sth->execute();
$sth = NULL;
$dbh = NULL;
}
$dbh = $common->pdoOpen();
$sql = "SELECT id, date FROM ".$settings::db_prefix."blogPosts";
$sth = $dbh->prepare($sql);
$sth->execute();
$blogPosts = $sth->fetchAll();
$sth = NULL;
$dbh = NULL;
foreach ($blogPosts as $post) {
$dbh = $common->pdoOpen();
$sql = "UPDATE ".$settings::db_prefix."blogPosts SET date = :date WHERE id = :id";
$sth = $dbh->prepare($sql);
$sth->bindParam(':date', gmdate("Y-m-d H:i:s", $post["date"]), PDO::PARAM_STR);
$sth->bindParam(':id', $post["id"], PDO::PARAM_INT);
$sth->execute();
$sth = NULL;
$dbh = NULL;
}
$dbh = $common->pdoOpen();
$sql = "SELECT id, firstSeen, lastSeen FROM ".$settings::db_prefix."flights";
$sth = $dbh->prepare($sql);
$sth->execute();
$flights = $sth->fetchAll();
$sth = NULL;
$dbh = NULL;
foreach ($flights as $flight) {
$dbh = $common->pdoOpen();
$sql = "UPDATE ".$settings::db_prefix."flights SET firstSeen = :firstSeen, lastSeen = lastSeen WHERE id = :id";
$sth = $dbh->prepare($sql);
$sth->bindParam(':firstSeen', gmdate("Y-m-d H:i:s", $flight["firstSeen"]), PDO::PARAM_STR);
$sth->bindParam(':lastSeen', gmdate("Y-m-d H:i:s", $flight["lastSeen"]), PDO::PARAM_STR);
$sth->bindParam(':id', $flight["id"], PDO::PARAM_INT);
$sth->execute();
$sth = NULL;
$dbh = NULL;
}
$dbh = $common->pdoOpen();
$sql = "SELECT id, time FROM ".$settings::db_prefix."positions";
$sth = $dbh->prepare($sql);
$sth->execute();
$positionss = $sth->fetchAll();
$sth = NULL;
$dbh = NULL;
foreach ($positions as $position) {
$dbh = $common->pdoOpen();
$sql = "UPDATE ".$settings::db_prefix."positions SET time = :time WHERE id = :id";
$sth = $dbh->prepare($sql);
$sth->bindParam(':time', gmdate("Y-m-d H:i:s", $position["time"]), PDO::PARAM_STR);
$sth->bindParam(':id', $position["id"], PDO::PARAM_INT);
$sth->execute();
$sth = NULL;
$dbh = NULL;
}
*/
}
// Add timezone setting.
$common->addSetting("timeZone", date_default_timezone_get());
// update version and patch settings.
$common->updateSetting("version", $thisVersion);
$common->updateSetting("patch", "");
} catch(Exception $e) {
$error = TRUE;
$errorMessage = $e->getMessage();
}
require_once('../admin/includes/header.inc.php');
// Display the instalation wizard.
if (!$error) {
?>
<h1>ADS-B Receiver Portal Updated</h1>
<p>Your portal has been upgraded to v<?php echo $thisVersion; ?>.</p>
<?php
} else {
?>
<h1>Error Encountered Upgrading Your ADS-B Receiver Portal</h1>
<p>There was an error encountered when upgrading your portal to v<?php echo $thisVersion; ?>.</p>
<?php echo $errorMessage; ?>
<?php
}
require_once('../admin/includes/footer.inc.php');
?>

Wyświetl plik

@ -57,7 +57,7 @@
$flightId = $row['id'];
$dbh = $common->pdoOpen();
$sql = "SELECT latitude, longitude, track FROM ".$settings::db_prefix."positions WHERE flight = :flight ORDER BY message";
$sql = "SELECT time, message, latitude, longitude, track FROM ".$settings::db_prefix."positions WHERE flight = :flight ORDER BY time";
$sth = $dbh->prepare($sql);
$sth->bindParam(':flight', $flightId, PDO::PARAM_STR, 50);
$sth->execute();
@ -65,13 +65,65 @@
$sth = NULL;
$dbh = NULL;
$pageData['startingLatitude'] = array_values($positions)[0]['latitude'];
$pageData['startingLongitude'] = array_values($positions)[0]['longitude'];
$pageData['startingDegrees'] = array_values($positions)[0]['track'];
$pageData['finishingLatitude'] = array_values($positions)[count(array_values($positions)) - 1]['latitude'];
$pageData['finishingLongitude'] = array_values($positions)[count(array_values($positions)) - 1]['longitude'];
$pageData['finishingDegrees'] = array_values($positions)[count(array_values($positions)) - 1]['track'];
$pageData['positions'] = $positions;
$thisPath = array();
$flightPath = array();
$flightPaths = array();
$lastMessage = 0;
$firstPass = TRUE;
$firstPosition = TRUE;
$totalPositions = count($positions);
$counter = 0;
foreach ($positions as $position) {
$counter++;
if ($position["message"] < $lastMessage || $counter == $totalPositions) {
if ($firstPass == TRUE) {
$flightPath["startingLatitude"] = $startingLatitude;
$flightPath["startingLongitude"] = $startingLongitude;
$flightPath["startingTrack"] = $startingTrack;
$firstPass = FALSE;
} else {
$flightPath["startingLatitude"] = $position["latitude"];
$flightPath["startingLongitude"] = $position["longitude"];
$flightPath["startingTrack"] = $position["track"];
}
$flightPath["finishingLatitude"] = $lastLatitude;
$flightPath["finishingLongitude"] = $lastLongitude;
$flightPath["finishingTrack"] = $lastTrack;
$flightPath["positions"] = json_encode($thisPath);
$flightPaths[] = $flightPath;
unset($thisPath);
unset($flightPath);
$thisPath = array();
$flightPath = array();
}
if ($firstPosition == TRUE) {
$startingLatitude = $position["latitude"];
$startingLongitude = $position["longitude"];
$startingTrack = $position["track"];
$firstPosition = FALSE;
}
$thisPosition["time"] = $position["time"];
$thisPosition["latitude"] = $position["latitude"];
$thisPosition["longitude"] = $position["longitude"];
$thisPosition["track"] = $position["track"];
$thisPosition["message"] = $position["message"];
$thisPath[] = $thisPosition;
$lastMessage = $position["message"];
$lastLatitude = $position["latitude"];
$lastLongitude = $position["longitude"];
$lastTrack = $position["track"];
}
if (count($flightPaths) > 0) {
$pageData['flightPathsAvailable'] = "TRUE";
$pageData['flightPaths'] = $flightPaths;
} else {
$pageData['flightPathsAvailable'] = "FALSE";
}
$template->display($pageData);
?>

Wyświetl plik

@ -50,9 +50,13 @@
// Add blog post data to the $pageData array.
$pageData['postTitle'] = $post['title'];
$pageData['postDate'] = date_format(date_create($post['date']), $common->getSetting('dateFormat'));
$pageData['postAuthor'] = $common->getAdminstratorName($post['author']);
$pageData['postContents'] = $post['contents'];
// Properly format the date and convert to slected time zone.
$date = new DateTime($post['date'], new DateTimeZone('UTC'));
$date->setTimezone(new DateTimeZone($common->getSetting('timeZone')));
$pageData['postDate'] = $date->format($common->getSetting('dateFormat'));
$template->display($pageData);
?>

Wyświetl plik

@ -28,12 +28,14 @@
<tr>
<th>Flight</th>
<th>Last Seen</th>
<th>First Seen</th>
<th>Links</th>
</tr>
{foreach page:flights as flight}
<tr>
<td><a href="plot.php?flight={flight->flight}">{flight->flight}</a></td>
<td>{flight->lastSeen}</td>
<td>{flight->firstSeen}</td>
<td>
<a href="http://flightaware.com/live/flight/{flight->flight}" target="_blank">FlightAware</a> |
<a href="https://planefinder.net/flight/{flight->flight}" target="_blank">Planefinder</a> |

Wyświetl plik

@ -47,20 +47,22 @@
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
{if setting:enableflights eq TRUE}<li id="flights-link"><a href="/flights.php">Flights</a></li>{/if}
{if setting:enableFlights eq TRUE}<li id="flights-link"><a href="/flights.php">Flights</a></li>{/if}
{if setting:enableBlog eq TRUE}<li id="blog-link"><a href="/blog.php">Blog</a></li>{/if}
{if setting:enableInfo eq TRUE}<li id="system-link"><a href="/system.php">System Information</a></li>{/if}
{if setting:enableGraphs eq TRUE}<li id="graphs-link"><a href="/graphs.php">Performance Graphs</a></li>{/if}
{if setting:enableDump1090 eq TRUE}<li id="dump1090-link"><a href="/dump1090.php">Live Dump1090 Map</a></li>{/if}
{if setting:enableDump978 eq TRUE}<li id="dump978-link"><a href="/dump978.php">Live Dump978 Map</a></li>{/if}
{if setting:enablePfclient eq TRUE}<li id="planefinder-link"><a href="{page:baseurl}:30053" target="_blank">Plane Finder Client</a></li>{/if}
</ul>
<form name="search" method="post" action="flights.php" class="navbar-form navbar-right">
<div class="form-group">
<input type="text" name="flight" placeholder="Flight" class="form-control">
</div>
<button type="submit" class="btn btn-success">Search</button>
</ul>
{if setting:dataStorage neq xml}
<form name="search" method="post" action="flights.php" class="navbar-form navbar-right">
<div class="form-group">
<input type="text" name="flight" placeholder="Flight" class="form-control">
</div>
<button type="submit" class="btn btn-success">Search</button>
</form>
{/if}
</div>
</div>
</nav>

Wyświetl plik

@ -23,11 +23,40 @@
<link rel="stylesheet" href="templates/{setting:template}/assets/css/dump1090.css">
{/area}
{area:contents}
{if page:flightPathsAvailable eq FALSE}
<div class="modal fade in" id="no-data-modal" tabindex="-1" role="dialog" aria-labelledby="no-data-modal-label">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="no-data-modal-label">No Position Data</h4>
</div>
<div class="modal-body">
<p>There is no position data for this flight.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
{/if}
<div id="iframe-wrapper">
<div id="map"></div>
</div>
<div> id="slide-panel">
<a href="#" class="btn btn-danger" id="opener"><i class="glyphicon glyphicon-align-justify"></i></a>
Panel Content
</div>
{/area}
{area:scripts}
{if page:flightPathsAvailable eq FALSE}
<script type="text/javascript">
$(window).load(function(){
$('#no-data-modal').modal('show');
});
</script>
{/if}
<script>
var genericPlaneSvg = "M 0,0 " +
"M 1.9565564,41.694305 C 1.7174505,40.497708 1.6419973,38.448747 " +
@ -68,8 +97,9 @@
mapTypeId: google.maps.MapTypeId.TERRAIN
});
{foreach page:flightPaths as flightPath}
var marker = new google.maps.Marker({
position: {lat: {page:startingLatitude}, lng: {page:startingLongitude}},
position: {lat: {flightPath->startingLatitude}, lng: {flightPath->startingLongitude}},
map: map,
icon: {
path: genericPlaneSvg,
@ -78,12 +108,12 @@
fillColor: "green",
fillOpacity: 1,
strokeWeight: 2,
rotation: {page:startingDegrees}
rotation: {flightPath->startingTrack}
}
});
var marker = new google.maps.Marker({
position: {lat: {page:finishingLatitude}, lng: {page:finishingLongitude}},
position: {lat: {flightPath->finishingLatitude}, lng: {flightPath->finishingLongitude}},
map: map,
icon: {
path: genericPlaneSvg,
@ -92,17 +122,18 @@
fillColor: "red",
fillOpacity: 1,
strokeWeight: 2,
rotation: {page:finishingDegrees}
rotation: {flightPath->finishingTrack}
}
});
var flightPlanCoordinates = [
{foreach page:positions as position}
{lat: {position->latitude}, lng: {position->longitude}},
{/foreach}
];
json = {flightPath->positions};
var thisPath = new Array();
for (var i = 0; i < json.length; i++) {
thisPath.push(new google.maps.LatLng(json[i].latitude, json[i].longitude));
}
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
path: thisPath,
geodesic: true,
strokeColor: 'blue',
strokeOpacity: 1.0,
@ -110,6 +141,7 @@
});
flightPath.setMap(map);
{/foreach}
// Retain map state.
loadMapState();
@ -166,6 +198,6 @@
}
}
</script>
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAibOqEH7XseMCHOPQUdBon6LHKSlbGHj4&callback=initMap"></script>
{/area}

Wyświetl plik

@ -26,7 +26,7 @@
<h2>Aggregate Sites Statistics</h2>
<ul>
{if setting:enableFlightAwareLink eq TRUE}<li><a href="{page:flightAwareLink}">FlightAware Stats</a></li>{/if}
{if setting:enablePlaneFinderLink eq TRUE}<li><a href="{page:planeFinderLink}">Planfinder Stats</a></li>{/if}
{if setting:enablePlaneFinderLink eq TRUE}<li><a href="{page:planeFinderLink}">Planefinder Stats</a></li>{/if}
{if setting:enableFlightRadar24Link eq TRUE}<li><a href="{page:flightRadar24Link}">Flightradar24 Stats</a></li>{/if}
{if setting:enableAdsbExchangeLink eq TRUE}<li><a href="{page:adsbExchangeLink}">ADS-B Exchange</a></li>{/if}
</ul>

Wyświetl plik

@ -37,10 +37,6 @@
import datetime
import json
if config["database"]["type"] == "mysql":
import MySQLdb
if config["database"]["type"] == "sqlite":
import sqlite3
import time
import os
#import urllib2
@ -51,6 +47,12 @@ while True:
with open(os.path.dirname(os.path.realpath(__file__)) + '/config.json') as config_file:
config = json.load(config_file)
# Import the needed database library.
if config["database"]["type"] == "mysql":
import MySQLdb
if config["database"]["type"] == "sqlite":
import sqlite3
# Read dump1090-mutability's aircraft.json.
with open('/run/dump1090-mutability/aircraft.json') as data_file:
data = json.load(data_file)
@ -66,22 +68,38 @@ while True:
db = MySQLdb.connect(host=config["database"]["host"], user=config["database"]["user"], passwd=config["database"]["passwd"], db=config["database"]["db"])
# Assign the time to a variable.
time_now = datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S")
time_now = datetime.datetime.utcnow().strftime("%Y/%m/%d %H:%M:%S")
cursor = db.cursor()
for aircraft in data["aircraft"]:
# Check if this aircraft was already seen.
cursor.execute("SELECT COUNT(*) FROM adsb_aircraft WHERE icao = %s", aircraft["hex"])
if config["database"]["type"] == "sqlite":
params = (aircraft["hex"],)
cursor.execute("SELECT COUNT(*) FROM adsb_aircraft WHERE icao = ?", params)
else:
cursor.execute("SELECT COUNT(*) FROM adsb_aircraft WHERE icao = %s", aircraft["hex"])
row_count = cursor.fetchone()
if row_count[0] == 0:
# Insert the new aircraft.
#print("Added Aircraft: " + aircraft["hex"])
cursor.execute("INSERT INTO adsb_aircraft (icao, firstSeen, lastSeen) VALUES (%s, %s, %s)", (aircraft["hex"], time_now, time_now))
if config["database"]["type"] == "sqlite":
params = (aircraft["hex"], time_now, time_now,)
cursor.execute("INSERT INTO adsb_aircraft (icao, firstSeen, lastSeen) VALUES (?, ?, ?)", params)
else:
cursor.execute("INSERT INTO adsb_aircraft (icao, firstSeen, lastSeen) VALUES (%s, %s, %s)", (aircraft["hex"], time_now, time_now))
else:
# Update the existing aircraft.
cursor.execute("UPDATE adsb_aircraft SET lastSeen = %s WHERE icao = %s", (time_now, aircraft["hex"]))
if config["database"]["type"] == "sqlite":
params = (time_now, aircraft["hex"],)
cursor.execute("UPDATE adsb_aircraft SET lastSeen = ? WHERE icao = ?", params)
else:
cursor.execute("UPDATE adsb_aircraft SET lastSeen = %s WHERE icao = %s", (time_now, aircraft["hex"]))
# Get the ID of this aircraft.
cursor.execute("SELECT id FROM adsb_aircraft WHERE icao = %s", aircraft["hex"])
if config["database"]["type"] == "sqlite":
params = (aircraft["hex"],)
cursor.execute("SELECT id FROM adsb_aircraft WHERE icao = ?", params)
else:
cursor.execute("SELECT id FROM adsb_aircraft WHERE icao = %s", aircraft["hex"])
rows = cursor.fetchall()
for row in rows:
aircraft_id = row[0]
@ -89,17 +107,33 @@ while True:
# Check that a flight is tied to this track.
if aircraft.has_key('flight'):
# Check to see if the flight already exists in the database.
cursor.execute("SELECT COUNT(*) FROM adsb_flights WHERE flight = %s", aircraft["flight"].strip())
if config["database"]["type"] == "sqlite":
params = (aircraft["flight"].strip(),)
cursor.execute("SELECT COUNT(*) FROM adsb_flights WHERE flight = ?", params)
else:
cursor.execute("SELECT COUNT(*) FROM adsb_flights WHERE flight = %s", aircraft["flight"].strip())
row_count = cursor.fetchone()
if row_count[0] == 0:
# If the flight does not exist in the database add it.
cursor.execute("INSERT INTO adsb_flights (aircraft, flight, firstSeen, lastSeen) VALUES (%s, %s, %s, %s)", (aircraft_id, aircraft["flight"].strip(), time_now, time_now))
if config["database"]["type"] == "sqlite":
params = (aircraft_id, aircraft["flight"].strip(), time_now, time_now,)
cursor.execute("INSERT INTO adsb_flights (aircraft, flight, firstSeen, lastSeen) VALUES (?, ?, ?, ?)", params)
else:
cursor.execute("INSERT INTO adsb_flights (aircraft, flight, firstSeen, lastSeen) VALUES (%s, %s, %s, %s)", (aircraft_id, aircraft["flight"].strip(), time_now, time_now))
#print("Added Flight: " + aircraft["flight"].strip())
else:
# If it already exists pdate the time it was last seen.
cursor.execute("UPDATE adsb_flights SET aircraft = %s, lastSeen = %s WHERE flight = %s", (aircraft_id, time_now, aircraft["flight"].strip()))
if config["database"]["type"] == "sqlite":
params =(aircraft_id, time_now, aircraft["flight"].strip(),)
cursor.execute("UPDATE adsb_flights SET aircraft = ?, lastSeen = ? WHERE flight = ?", params)
else:
cursor.execute("UPDATE adsb_flights SET aircraft = %s, lastSeen = %s WHERE flight = %s", (aircraft_id, time_now, aircraft["flight"].strip()))
# Get the ID of this flight.
cursor.execute("SELECT id FROM adsb_flights WHERE flight = %s", aircraft["flight"].strip())
if config["database"]["type"] == "sqlite":
params = (aircraft["flight"].strip(),)
cursor.execute("SELECT id FROM adsb_flights WHERE flight = ?", params)
else:
cursor.execute("SELECT id FROM adsb_flights WHERE flight = %s", aircraft["flight"].strip())
rows = cursor.fetchall()
for row in rows:
flight_id = row[0]
@ -107,17 +141,30 @@ while True:
# Check if position data is available.
if aircraft.has_key('lat') and aircraft.has_key('lon') and aircraft.has_key('altitude') and aircraft.has_key('speed') and aircraft.has_key('track') and aircraft.has_key('vert_rate') and aircraft["altitude"] != "ground":
# Check that this message has not already been added to the database.
cursor.execute("SELECT message FROM adsb_positions WHERE flight = %s AND message = %s ORDER BY time DESC", (flight_id, aircraft["messages"]))
if config["database"]["type"] == "sqlite":
params = (flight_id, aircraft["messages"],)
cursor.execute("SELECT message FROM adsb_positions WHERE flight = ? AND message = ? ORDER BY time DESC", params)
else:
cursor.execute("SELECT message FROM adsb_positions WHERE flight = %s AND message = %s ORDER BY time DESC", (flight_id, aircraft["messages"]))
rows = cursor.fetchall()
row_count = cursor.rowcount
last_message = 0
for row in rows:
last_message = row[0]
if row_count == 0 or last_message != aircraft["messages"]:
# Add this position to the database.
if aircraft.has_key('squawk'):
cursor.execute("INSERT INTO adsb_positions (flight, time, message, squawk, latitude, longitude, track, altitude, verticleRate, speed) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", (flight_id, time_now, aircraft["messages"], aircraft["squawk"], aircraft["lat"], aircraft["lon"], aircraft["track"], aircraft["altitude"], aircraft["vert_rate"], aircraft["speed"]))
if config["database"]["type"] == "sqlite":
params = (flight_id, time_now, aircraft["messages"], aircraft["squawk"], aircraft["lat"], aircraft["lon"], aircraft["track"], aircraft["altitude"], aircraft["vert_rate"], aircraft["speed"],)
cursor.execute("INSERT INTO adsb_positions (flight, time, message, squawk, latitude, longitude, track, altitude, verticleRate, speed) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", params)
else:
cursor.execute("INSERT INTO adsb_positions (flight, time, message, squawk, latitude, longitude, track, altitude, verticleRate, speed) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", (flight_id, time_now, aircraft["messages"], aircraft["squawk"], aircraft["lat"], aircraft["lon"], aircraft["track"], aircraft["altitude"], aircraft["vert_rate"], aircraft["speed"]))
else:
cursor.execute("INSERT INTO adsb_positions (flight, time, message, latitude, longitude, track, altitude, verticleRate, speed) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)", (flight_id, time_now, aircraft["messages"], aircraft["lat"], aircraft["lon"], aircraft["track"], aircraft["altitude"], aircraft["vert_rate"], aircraft["speed"]))
if config["database"]["type"] == "sqlite":
params = (flight_id, time_now, aircraft["messages"], aircraft["lat"], aircraft["lon"], aircraft["track"], aircraft["altitude"], aircraft["vert_rate"], aircraft["speed"],)
cursor.execute("INSERT INTO adsb_positions (flight, time, message, latitude, longitude, track, altitude, verticleRate, speed) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", params)
else:
cursor.execute("INSERT INTO adsb_positions (flight, time, message, latitude, longitude, track, altitude, verticleRate, speed) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)", (flight_id, time_now, aircraft["messages"], aircraft["lat"], aircraft["lon"], aircraft["track"], aircraft["altitude"], aircraft["vert_rate"], aircraft["speed"]))
# Close the database connection.
db.commit()

Wyświetl plik

@ -251,6 +251,10 @@ NOTHINGTODO="Nothing has been selected to be installed so the script will exit n
read -d '' INSTALLATIONCOMPLETE <<"EOF"
INSTALLATION COMPLETE
DO NOT DELETE THIS DIRECTORY!
Files needed for certain items to run properly are contained within this directory. Deleting this directory may result in your receiver not working properly.
It is hoped these scripts and files were found useful while setting up your ADS-B Receiver. Feedback regarding this software is always welcome. If you ran into any problems or wish to submit feed back feel free to do so on the project's GitHub site.
https://github.com/jprochazka/adsb-receiver
@ -564,7 +568,7 @@ fi
## INSTALLATION COMPLETE
# Display the installation complete message box.
whiptail --backtitle "$BACKTITLE" --title "Software Installation Complete" --msgbox "$INSTALLATIONCOMPLETE" 16 65
whiptail --backtitle "$BACKTITLE" --title "Software Installation Complete" --msgbox "$INSTALLATIONCOMPLETE" 19 65
# Once again cannot make the whiptail checkbox not create this file and still work...
# Will work on figuring this out at a later date but until then we will delete the file created.