Added link management and display.

pull/263/head
Joe Prochazka 2016-10-11 14:47:45 -04:00
rodzic 0acd631f7c
commit bd54220203
17 zmienionych plików z 690 dodań i 42 usunięć

Wyświetl plik

@ -31,9 +31,9 @@
session_start();
// Load the require PHP classes.
require_once('../../classes/common.class.php');
require_once('../../classes/account.class.php');
require_once('../../classes/blog.class.php');
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."common.class.php");
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."account.class.php");
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."blog.class.php");
$common = new common();
$account = new account();
@ -62,7 +62,7 @@
////////////////
// BEGIN HTML
require_once('../includes/header.inc.php');
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."header.inc.php");
?>
<h1>Blog Management</h1>
<hr />
@ -113,5 +113,5 @@
});
</script>
<?php
require_once('../includes/footer.inc.php');
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."footer.inc.php");
?>

Wyświetl plik

@ -64,8 +64,7 @@
////////////////
// BEGIN HTML
require_once('../includes/header.inc.php');
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."header.inc.php");
?>
<h1>Blog Management</h1>
<hr />
@ -83,5 +82,5 @@
<a href="/admin/blog/" class="btn btn-info" role="button">Cancel</a>
</form>
<?php
require_once('../includes/footer.inc.php');
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."footer.inc.php");
?>

Wyświetl plik

@ -68,7 +68,7 @@
////////////////
// BEGIN HTML
require_once('../includes/header.inc.php');
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."header.inc.php");
// Display the updated message if settings were updated.
if ($updated) {
@ -112,5 +112,5 @@
});
</script>
<?php
require_once('../includes/footer.inc.php');
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."footer.inc.php");
?>

Wyświetl plik

@ -31,9 +31,9 @@
session_start();
// Load the require PHP classes.
require_once('../../classes/common.class.php');
require_once('../../classes/account.class.php');
require_once('../../classes/blog.class.php');
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."common.class.php");
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."account.class.php");
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."blog.class.php");
$common = new common();
$account = new account();
@ -56,7 +56,7 @@
////////////////
// BEGIN HTML
require_once('../includes/header.inc.php');
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."header.inc.php");
?>
<h1>Blog Management</h1>
@ -110,5 +110,5 @@
?>
</ul>
<?php
require_once('../includes/footer.inc.php');
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."footer.inc.php");
?>

Wyświetl plik

@ -118,6 +118,10 @@
if (isset($_POST['enableGraphs']) && $_POST['enableGraphs'] == "TRUE")
$enableGraphs = TRUE;
$enableLinks = FALSE;
if (isset($_POST['enableLinks']) && $_POST['enableLinks'] == "TRUE")
$enableLinks = TRUE;
$enableDump1090 = FALSE;
if (isset($_POST['enableDump1090']) && $_POST['enableDump1090'] == "TRUE")
$enableDump1090 = TRUE;
@ -167,6 +171,7 @@
$common->updateSetting("enableBlog", $enableBlog);
$common->updateSetting("enableInfo", $enableInfo);
$common->updateSetting("enableGraphs", $enableGraphs);
$common->updateSetting("enableLinks", $enableLinks);
$common->updateSetting("enableDump1090", $enableDump1090);
$common->updateSetting("enableDump978", $enableDump978);
$common->updateSetting("enablePfclient", $enablePfclient);
@ -253,6 +258,7 @@
$enableBlog = $common->getSetting("enableBlog");
$enableInfo = $common->getSetting("enableInfo");
$enableGraphs = $common->getSetting("enableGraphs");
$enableLinks = $common->getSetting("enableLinks");
$enableDump1090 = $common->getSetting("enableDump1090");
$enableDump978 = $common->getSetting("enableDump978");
$enablePfclient = $common->getSetting("enablePfclient");
@ -464,6 +470,11 @@
<input type="checkbox" name="enableGraphs" value="TRUE"<?php ($enableGraphs == 1 ? print ' checked' : ''); ?>> Enable performance graphs link.
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="enableLinks" value="TRUE"<?php ($enableLinks == 1 ? print ' checked' : ''); ?>> Enable custom links.
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="enableDump1090" value="TRUE"<?php ($enableDump1090 == 1 ? print ' checked' : ''); ?>> Enable live dump1090 map link.

Wyświetl plik

@ -0,0 +1,93 @@
<?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. //
/////////////////////////////////////////////////////////////////////////////////////
session_start();
// Load the require PHP classes.
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."common.class.php");
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."account.class.php");
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."links.class.php");
$common = new common();
$account = new account();
$links = new links();
// Check if the user is logged in.
if (!$account->isAuthenticated()) {
// The user is not logged in so forward them to the login page.
header ("Location: login.php");
}
$nameExists = FALSE;
if ($common->postBack()) {
// Check if the name already exists.
$nameExists = $links->nameExists($_POST['name']);
if (!$nameExists) {
// Add this link..
$links->addLink($_SESSION['name'], $_POST['address']);
// Forward the user to the link management index page.
header ("Location: /admin/links/");
}
}
////////////////
// BEGIN HTML
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."header.inc.php");
?>
<h1>Links Management</h1>
<hr />
<h2>Add Link</h2>
<form id="add-link" method="post" action="add.php">
<div class="form-group">
<label for="name">Name</label>
<input type="text" id="name" name="name" class="form-control"<?php echo (isset($_POST['name']) ? ' value="'.$_POST['name'].'"' : '')?> required>
<?php
if ($nameExists) {
?>
<div class="alert alert-danger" role="alert" id="failure-alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
Name already exists.
</div>
<?php
}
?>
</div>
<div class="form-group">
<label for="address">Address</label>
<input type="text" id="address" name="address" class="form-control"<?php echo (isset($_POST['address']) ? ' value="'.$_POST['address'].'"' : '')?> required>
</div>
<?php
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."footer.inc.php");
?>

Wyświetl plik

@ -0,0 +1,81 @@
<?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. //
/////////////////////////////////////////////////////////////////////////////////////
session_start();
// Load the require PHP classes.
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."common.class.php");
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."account.class.php");
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."links.class.php");
$common = new common();
$account = new account();
$links = new links();
// Check if the user is logged in.
if (!$account->isAuthenticated()) {
// The user is not logged in so forward them to the login page.
header ("Location: login.php");
}
if ($common->postBack()) {
// Delete the selected link.
$links->deleteLinkByName(urldecode($_GET['name']));
// Forward the user to the link management index page.
header ("Location: /admin/links/");
}
// Get the data for this link.
$link = $links->getLinkByName(urldecode($_GET['name']));
////////////////
// BEGIN HTML
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."header.inc.php");
?>
<h1>Links Management</h1>
<hr />
<h2>Delete Link</h2>
<h3><?php echo $link['name']; ?></h3>
<p>With the address of <strong><?php echo $link['address']); ?></strong>.</p>
<div class="alert alert-danger" role="alert">
<p>
<strong>Confirm Delete</strong><br />
Are you sure you want to delete this link?
</p>
</div>
<form id="delete-link" method="post" action="delete.php?name=<?php echo urlencode($link['name']); ?>">
<input type="submit" class="btn btn-default" value="Delete Post">
<a href="/admin/links/" class="btn btn-info" role="button">Cancel</a>
</form>
<?php
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."footer.inc.php");
?>

Wyświetl plik

@ -0,0 +1,94 @@
<?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. //
/////////////////////////////////////////////////////////////////////////////////////
session_start();
// Load the require PHP classes.
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."common.class.php");
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."account.class.php");
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."links.class.php");
$common = new common();
$account = new account();
$links = new links();
// Check if the user is logged in.
if (!$account->isAuthenticated()) {
// The user is not logged in so forward them to the login page.
header ("Location: login.php");
}
if ($common->postBack()) {
// Update the contents of the blog post.
$links->editLinkByName(urldecode($_POST['originalName']), $_POST['name'], $_POST['address']);
// Forward the user to the link management index page.
header ("Location: /admin/links/");
}
// Get the link data.
$link = $links->getLinkByName(urldecode($_GET['name']));
////////////////
// BEGIN HTML
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."header.inc.php");
// Display the updated message if settings were updated.
if ($updated) {
?>
<div id="contents-saved" class="alert alert-success fade in" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
Link has been updated.
</div>
<?php
}
?>
<h1>Links Management</h1>
<hr />
<h2>Edit Link</h2>
<h3><?php echo $link['name']; ?></h3>
<form id="edit-link" method="post" action="edit.php">
<div class="form-group">
<label for="name">Name</label>
<input type="text" id="name" name="name" class="form-control"<?php echo $link['name']; ?> required>
</div>
<div class="form-group">
<label for="address">Address</label>
<input type="text" id="address" name="address" class="form-control"<?php echo $link['address']; ?> required>
</div>
<input type="hidden" name="originalName" value="<?php echo $link['name']; ?>">
<input type="submit" class="btn btn-default" value="Commit Changes">
</form>
<?php
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."footer.inc.php");
?>

Wyświetl plik

@ -0,0 +1,83 @@
<?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. //
/////////////////////////////////////////////////////////////////////////////////////
session_start();
// Load the require PHP classes.
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."common.class.php");
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."account.class.php");
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."links.class.php");
$common = new common();
$account = new account();
$links = new links();
// Check if the user is logged in.
if (!$account->isAuthenticated()) {
// The user is not logged in so forward them to the login page.
header ("Location: login.php");
}
// Get all links.
$allLinks = $links->getAllLinks();
////////////////
// BEGIN HTML
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."header.inc.php");
?>
<h1>Links Management</h1>
<hr />
<h2>Links</h2>
<a href="add.php" class="btn btn-info" style="margin-bottom: 10px;" role="button">Add Link</a>
<div class="table-responsive">
<table class="table table-striped table-condensed">
<tr>
<th></th>
<th>Name</th>
<th>Address</th>
</tr>
<?php
foreach ($links as $link) {
?>
<tr>
<td><a href="edit.php?name=<?php echo urlencode($link['name']); ?>">edit</a> <a href="delete.php?title=<?php echo urlencode($link['name']); ?>">delete</a></td>
<td><?php echo $link['name']; ?></td>
<td><a href="<?php echo $link['address']; ?>" target="_blank"><?php echo $link['address']; ?></a></td>
</tr>
<?php
}
?>
</table>
</div>
<?php
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."footer.inc.php");
?>

Wyświetl plik

@ -103,6 +103,7 @@
if ($settings::db_driver == "xml") {
// XML
$blogPosts = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."blogPosts.xml");
foreach ($blogPosts as $blogPost) {
if ($blogPost->title == $newTitle) {
return TRUE;

Wyświetl plik

@ -0,0 +1,208 @@
<?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. //
/////////////////////////////////////////////////////////////////////////////////////
class links {
function getAllLinks() {
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."settings.class.php");
$settings = new settings();
if ($settings::db_driver == "xml") {
// XML
$links = array();
$xmlLinks = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."links.xml");
foreach ($xmlLinks as $xmlLink) {
$links[] = array("name"=>$xmlLink->name, "address"=>$xmlLink->address);
}
} else {
// PDO
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."common.class.php");
$common = new common();
$dbh = $common->pdoOpen();
$sql = "SELECT name, address FROM ".$settings::db_prefix."links ORDER BY name";
$sth = $dbh->prepare($sql);
$sth->execute();
$links = $sth->fetchAll();
$sth = NULL;
$dbh = NULL;
}
return $links;
}
function getLinkByName($name) {
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."settings.class.php");
$settings = new settings();
if ($settings::db_driver == "xml") {
// XML
$links = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."links.xml");
foreach ($links as $link) {
if (strtolower($link->name) == strtolower($name)) {
return (array)$link;
}
}
} else {
// PDO
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."common.class.php");
$common = new common();
$dbh = $common->pdoOpen();
$sql = "SELECT * FROM ".$settings::db_prefix."links WHERE name = :name";
$sth = $dbh->prepare($sql);
$sth->bindParam(':name', $name, PDO::PARAM_STR, 100);
$sth->execute();
$link = $sth->fetch();
$sth = NULL;
$dbh = NULL;
return $link;
}
}
function nameExists($newName) {
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."settings.class.php");
$settings = new settings();
if ($settings::db_driver == "xml") {
// XML
$links = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."links.xml")
foreach ($links as $link) {
if ($link->name == $name) {
return TRUE;
}
}
return FALSE;
} else {
// PDO
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."common.class.php");
$common = new common();
$dbh = $common->pdoOpen();
$sql = "SELECT COUNT(*) FROM ".$settings::db_prefix."links WHERE name = :name";
$sth = $dbh->prepare($sql);
$sth->bindParam(':name', $name, PDO::PARAM_STR, 100);
$sth->execute();
$count = $sth->fetchColumn();
$sth = NULL;
$dbh = NULL;
if ($count > 0)
return TRUE;
return FALSE;
}
}
function addLink($name, $address) {
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."settings.class.php");
$settings = new settings();
if ($settings::db_driver == "xml") {
// XML
$links = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."links.xml");
$link = $blogPosts->addChild('blogPost', '');
$link->addChild('name', $title);
$link->addChild('address', $address);
$dom = dom_import_simplexml($links)->ownerDocument;
$dom->formatOutput = TRUE;
file_put_contents($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."links.xml", $dom->saveXML());
} else {
// PDO
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."common.class.php");
$common = new common();
$dbh = $common->pdoOpen();
$sql = "INSERT INTO ".$settings::db_prefix."links (name, address) VALUES (:name, :address)";
$sth = $dbh->prepare($sql);
$sth->bindParam(':name', $title, PDO::PARAM_STR, 100);
$sth->bindParam(':address', $author, PDO::PARAM_STR, 250);
$sth->execute();
$sth = NULL;
$dbh = NULL;
}
}
function editLinkByName($originalName, $name, $address) {
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."settings.class.php");
$settings = new settings();
if ($settings::db_driver == "xml") {
// XML
$links = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."links.xml");
foreach ($links->xpath("link[name='".$originalName."']") as $link) {
$link->name = $name;
$link->address = $address;
}
file_put_contents($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."links.xml", $links->asXML());
} else {
// PDO
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."common.class.php");
$common = new common();
$dbh = $common->pdoOpen();
$sql = "UPDATE ".$settings::db_prefix."links SET name = :name, address = :address WHERE name = :originalName";
$sth = $dbh->prepare($sql);
$sth->bindParam(':originalName', $originalName, PDO::PARAM_STR, 100);
$sth->bindParam(':name', $name, PDO::PARAM_STR, 100);
$sth->bindParam(':address', $address, PDO::PARAM_STR, 250);
$sth->execute();
$sth = NULL;
$dbh = NULL;
}
}
function deleteLinkByName($name) {
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."settings.class.php");
$settings = new settings();
if ($settings::db_driver == "xml") {
$blogPosts = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."links.xml");
foreach($linkss as $link) {
if($link->name == $name) {
$dom = dom_import_simplexml($link);
$dom->parentNode->removeChild($dom);
}
}
file_put_contents($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."links.xml", $blogPosts->asXml());
} else {
// PDO
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."common.class.php");
$common = new common();
$dbh = $common->pdoOpen();
$sql = "DELETE FROM ".$settings::db_prefix."links WHERE name = :name";
$sth = $dbh->prepare($sql);
$sth->bindParam(':name', $name, PDO::PARAM_STR, 100);
$sth->execute();
$sth = NULL;
$dbh = NULL;
}
}
}
?>

Wyświetl plik

@ -37,7 +37,7 @@
// Check if the portal is installed or needs upgraded.
$thisVersion = "2.4.0";
$thisVersion = "2.5.0";
if (!file_exists($_SERVER['DOCUMENT_ROOT']."/classes/settings.class.php")) {
header ("Location: /install/install.php");
@ -48,9 +48,13 @@
// The Base URL of this page (needed for Plane Finder client link)
$pageData['baseurl'] = $common->getBaseUrl();
// Load the master template.
// Load the master template along with required data for the master template..
$master = $this->readTemplate('master.tpl');
require_once($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR."links.class.php");
$links = new links();
$pageData['links'] = $links->getAllLinks();
// Load the template for the requested page.
$page = $this->readTemplate($common->removeExtension($_SERVER["SCRIPT_NAME"]).'.tpl');

Wyświetl plik

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<links/>

Wyświetl plik

@ -29,7 +29,7 @@
/////////////////////////////////////////////////////////////////////////////////////
// The most current stable release.
$thisVersion = "2.4.0";
$thisVersion = "2.5.0";
// Begin the upgrade process if this release is newer than what is installed.
if (file_exists("../classes/settings.class.php")) {
@ -171,6 +171,15 @@ EOF;
$xml->endElement();
file_put_contents($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."notifications.xml", $xml->flush(true));
// Create XML files used to store links data.
$xml = new XMLWriter();
$xml->openMemory();
$xml->setIndent(true);
$xml->startDocument('1.0','UTF-8');
$xml->startElement("links");
$xml->endElement();
file_put_contents($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."links.xml", $xml->flush(true));
// Create XML files used to store settings data.
$xml = new XMLWriter();
$xml->openMemory();
@ -208,16 +217,20 @@ EOF;
date datetime NOT NULL,
author VARCHAR(100) NOT NULL,
contents VARCHAR(20000) NOT NULL);';
$notificationsSql = 'CREATE TABLE '.$dbPrefix.'notifications (
id INT(11) PRIMARY KEY AUTO_INCREMENT,
flight VARCHAR(10) NOT NULL,
lastMessageCount INT(11) NOT NULL);';
$flightsSql = 'CREATE TABLE '.$dbPrefix.'flights(
id INT(11) AUTO_INCREMENT PRIMARY KEY,
aircraft INT(11) NOT NULL,
flight VARCHAR(100) NOT NULL,
firstSeen datetime NOT NULL,
lastSeen datetime NOT NULL);';
$linksSql = 'CREATE TABLE '.$dbPrefix.'links(
id INT(11) AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
address VARCHAR(250) NOT NULL);';
$notificationsSql = 'CREATE TABLE '.$dbPrefix.'notifications (
id INT(11) PRIMARY KEY AUTO_INCREMENT,
flight VARCHAR(10) NOT NULL,
lastMessageCount INT(11) NOT NULL);';
$positionsSql = 'CREATE TABLE '.$dbPrefix.'positions (
id INT(11) AUTO_INCREMENT PRIMARY KEY,
flight BIGINT NOT NULL,
@ -256,16 +269,20 @@ EOF;
date VARCHAR(20) NOT NULL,
author VARCHAR(100) NOT NULL,
contents VARCHAR(20000) NOT NULL);';
$notificationsSql = 'CREATE TABLE '.$dbPrefix.'notifications (
id SERIAL PRIMARY KEY,
flight VARCHAR(10) NOT NULL,
lastMessageCount INT(11) NOT NULL);';
$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);';
$linksSql = 'CREATE TABLE '.$dbPrefix.'links(
id INT(11) AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
address VARCHAR(250) NOT NULL);';
$notificationsSql = 'CREATE TABLE '.$dbPrefix.'notifications (
id SERIAL PRIMARY KEY,
flight VARCHAR(10) NOT NULL,
lastMessageCount INT(11) NOT NULL);';
$positionsSql = 'CREATE TABLE '.$dbPrefix.'positions (
id SERIAL PRIMARY KEY,
flight BIGINT NOT NULL,
@ -303,16 +320,20 @@ EOF;
date DATETIME NOT NULL,
author TEXT NOT NULL,
contents TEXT NOT NULL);';
$notificationsSql = 'CREATE TABLE '.$dbPrefix.'notifications (
id INTEGER PRIMARY KEY AUTOINCREMENT,
flight TEXT NOT NULL,
lastMessageCount INTEGER NOT NULL);';
$flightsSql = 'CREATE TABLE '.$dbPrefix.'flights (
id INTEGER PRIMARY KEY AUTOINCREMENT,
aircraft INTEGER NOT NULL,
flight TEXT NOT NULL,
firstSeen DATETIME NOT NULL,
lastSeen DATETIME NOT NULL);';
$linksSql = 'CREATE TABLE '.$dbPrefix.'links(
id INT(11) AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
address VARCHAR(250) NOT NULL);';
$notificationsSql = 'CREATE TABLE '.$dbPrefix.'notifications (
id INTEGER PRIMARY KEY AUTOINCREMENT,
flight TEXT NOT NULL,
lastMessageCount INTEGER NOT NULL);';
$positionsSql = 'CREATE TABLE '.$dbPrefix.'positions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
flight INTEGER NOT NULL,
@ -347,11 +368,15 @@ EOF;
$sth->execute();
$sth = NULL;
$sth = $dbh->prepare($notificationsSql);
$sth = $dbh->prepare($flightsSql);
$sth->execute();
$sth = NULL;
$sth = $dbh->prepare($flightsSql);
$sth = $dbh->prepare($linksSql);
$sth->execute();
$sth = NULL;
$sth = $dbh->prepare($notificationsSql);
$sth->execute();
$sth = NULL;
@ -380,7 +405,8 @@ EOF;
$common->addSetting('dateFormat', 'F jS, Y g:i A');
$common->addSetting('enableBlog', TRUE);
$common->addSetting('enableInfo', TRUE);
$common->addSetting('enableGraphs', TRUE);
$common->addSetting('enableLinks', TRUE);
$common->addSetting('enableGraphs', FALSE);
$common->addSetting('enableDump1090', TRUE);
$common->addSetting('enableDump978', FALSE);
$common->addSetting('enablePfclient', FALSE);

Wyświetl plik

@ -124,13 +124,18 @@ EOF;
$sth->execute();
$sth = NULL;
// Add the lastMessageCount column to the notifications table.
$sql = "ALTER TABLE ".$settings::db_prefix."flightNotifications ADD COLUMN lastMessageCount DATETIME";
$sth = $dbh->prepare($sql);
$sth->execute();
$sth = NULL;
// Add the links table.
$linksSql = '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);
$sth->execute();
$sth = NULL;
$dbh = NULL;
}
@ -149,9 +154,27 @@ EOF;
$sth->execute();
$sth = NULL;
// Add the links table.
$linksSql = '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);
$sth->execute();
$sth = NULL;
$dbh = NULL;
}
if ($settings::db_driver == "xml") {
// Create XML files used to store links data.
$xml = new XMLWriter();
$xml->openMemory();
$xml->setIndent(true);
$xml->startDocument('1.0','UTF-8');
$xml->startElement("links");
$xml->endElement();
file_put_contents($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."links.xml", $xml->flush(true));
}
// Rename the enableFlightNotifications to enableWebNotifications.
$enableWebNotifications = $common->getSetting('enableFlightNotifications')
$common->addSetting('enableWebNotifications', $enableWebNotifications);
@ -172,6 +195,9 @@ EOF;
// Add Google Maps API Key setting.
$common->addSetting('googleMapsApiKey', '');
// Add enable custom links setting.
$common->addSetting('eableLinks', FALSE);
// Update the version and patch settings..
$common->updateSetting("version", "2.5.0");
$common->updateSetting("patch", "");

Wyświetl plik

@ -33,7 +33,7 @@
$common = new common();
// The most current stable release.
$thisVersion = "2.4.0";
$thisVersion = "2.5.0";
// Begin the upgrade process if this release is newer than what is installed.
if ($common->getSetting("version") == $thisVersion) {

Wyświetl plik

@ -47,14 +47,34 @@
</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: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>
{if setting:enableFlights eq TRUE}<li id="flights-link"><a href="/flights.php">Flights</a></li>{/if}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">System <span class="caret"></span></a>
<ul class="dropdown-menu">
{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>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Maps <span class="caret"></span></a>
<ul class="dropdown-menu">
{if setting:enableGraphs eq TRUE}<li id="graphs-link"><a href="/graphs.php">Performance Graphs</a></li>{/if}
{if setting:enableInfo eq TRUE}<li id="system-link"><a href="/system.php">System Information</a></li>{/if}
</ul>
</li>
{if setting:enableLinks eq TRUE}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Links <span class="caret"></span></a>
<ul class="dropdown-menu">
{foreach page:links as link}
<li><a href="{link->address}">{link->name}</a></li>
{/foreach}
</ul>
</li>
{/if}
</nav>
{if setting:dataStorage neq xml}
<form name="search" method="post" action="flights.php" class="navbar-form navbar-right">
<div class="form-group">