Skip to content

Commit

Permalink
Merge branch 'v1-2-0'
Browse files Browse the repository at this point in the history
  • Loading branch information
velocity23 committed Jun 1, 2021
2 parents 90aab2f + ed22160 commit 7171b9c
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 64 deletions.
99 changes: 52 additions & 47 deletions admin/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

$user = new User();

Page::setTitle('Plugins - '.Config::get('va/name'));
Page::setTitle('Plugins - ' . Config::get('va/name'));

if (!$user->isLoggedIn()) {
Redirect::to('/index.php');
Expand All @@ -23,9 +23,11 @@
?>
<!DOCTYPE html>
<html>

<head>
<?php include '../includes/header.php'; ?>
</head>

<body>
<nav class="navbar navbar-dark navbar-expand-lg bg-custom">
<?php include '../includes/navbar.php'; ?>
Expand All @@ -35,27 +37,29 @@
<div class="row m-0 p-0">
<?php include '../includes/sidebar.php'; ?>
<div class="col-lg-9 main-content">
<div id="loader-wrapper"><div id="loader" class="spinner-border spinner-border-sm spinner-custom"></div></div>
<div id="loader-wrapper">
<div id="loader" class="spinner-border spinner-border-sm spinner-custom"></div>
</div>
<div class="loaded">
<?php
if (file_exists(__DIR__.'/../install/install.php') && !file_exists(__DIR__.'/../.development')) {
if (file_exists(__DIR__ . '/../install/install.php') && !file_exists(__DIR__ . '/../.development')) {
echo '<div class="alert alert-danger text-center">The Install Folder still Exists! Please delete it immediately, it poses a severe security risk.</div>';
}

if (Session::exists('error')) {
echo '<div class="alert alert-danger text-center">Error: '.Session::flash('error').'</div>';
echo '<div class="alert alert-danger text-center">Error: ' . Session::flash('error') . '</div>';
}
if (Session::exists('success')) {
echo '<div class="alert alert-success text-center">'.Session::flash('success').'</div>';
echo '<div class="alert alert-success text-center">' . Session::flash('success') . '</div>';
}
?>
<h3>Manage Plugins</h3>
<?php
$tab = "store";
if (!empty(Input::get('tab'))) {
$tab = Input::get('tab');
}
$ACTIVE_CATEGORY = 'plugins';
$tab = "store";
if (!empty(Input::get('tab'))) {
$tab = Input::get('tab');
}
$ACTIVE_CATEGORY = 'plugins';
?>
<script>
$(document).ready(function() {
Expand Down Expand Up @@ -88,30 +92,30 @@
</thead>
<tbody>
<?php
$url = "https://raw.githubusercontent.com/va-net/flare-plugins/master/plugins.tsv";
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"User-Agent: va-net\r\n"
)
);
$context = stream_context_create($opts);
$plugins = file_get_contents($url, false, $context);
preg_match_all('/\n.*/m', $plugins, $lines);
foreach ($lines[0] as $l) {
$segments = explode("\t", $l);
$segments = array_map(function($x) {
return trim($x);
}, $segments);
echo '<tr><td class="align-middle" data-toggle="tooltip" title="'.escape($segments[6]).'">';
echo $segments[0];
echo '</td><td class="align-middle">';
$tags = implode('</span><span class="badge badge-light mx-1">', explode(",", $segments[5]));
echo '<span class="badge badge-light mx-1">'.$tags.'</span>';
echo '</td><td class="align-middle">';
echo '<button class="btn bg-custom installBtn" data-slug="'.$segments[1].'" data-name="'.$segments[0].'"><i class="fa fa-cloud-download-alt"></i></button>';
echo '</td></tr>';
}
$url = "https://raw.githubusercontent.com/va-net/flare-plugins/v1/plugins.tsv";
$opts = array(
'http' => array(
'method' => "GET",
'header' => "User-Agent: va-net\r\n"
)
);
$context = stream_context_create($opts);
$plugins = file_get_contents($url, false, $context);
preg_match_all('/\n.*/m', $plugins, $lines);
foreach ($lines[0] as $l) {
$segments = explode("\t", $l);
$segments = array_map(function ($x) {
return trim($x);
}, $segments);
echo '<tr><td class="align-middle" data-toggle="tooltip" title="' . escape($segments[6]) . '">';
echo $segments[0];
echo '</td><td class="align-middle">';
$tags = implode('</span><span class="badge badge-light mx-1">', explode(",", $segments[5]));
echo '<span class="badge badge-light mx-1">' . $tags . '</span>';
echo '</td><td class="align-middle">';
echo '<button class="btn bg-custom installBtn" data-slug="' . $segments[1] . '" data-name="' . $segments[0] . '"><i class="fa fa-cloud-download-alt"></i></button>';
echo '</td></tr>';
}
?>
</tbody>
</table>
Expand All @@ -133,15 +137,15 @@
</thead>
<tbody>
<?php
foreach ($INSTALLED_PLUGINS as $p) {
echo '<tr><td class="align-middle">';
echo $p["name"];
echo '</td><td class="align-middle">';
echo $p["version"]["tag"];
echo '</td><td class="align-middle">';
echo '<button class="btn btn-danger removeBtn" data-name="'.$p["name"].'"><i class="fa fa-trash"></i></button>';
echo '</td></tr>';
}
foreach ($INSTALLED_PLUGINS as $p) {
echo '<tr><td class="align-middle">';
echo $p["name"];
echo '</td><td class="align-middle">';
echo $p["version"]["tag"];
echo '</td><td class="align-middle">';
echo '<button class="btn btn-danger removeBtn" data-name="' . $p["name"] . '"><i class="fa fa-trash"></i></button>';
echo '</td></tr>';
}
?>
</tbody>
</table>
Expand All @@ -150,7 +154,7 @@

<style>
.nav-tabs .nav-link {
color: #000!important;
color: #000 !important;
}
</style>
<script>
Expand All @@ -165,7 +169,7 @@
$(".installBtn").click(function() {
var name = $(this).data('name');
var slug = $(this).data('slug');

var conf = confirm('Are you sure you want to install the plugin "' + name + '"?');
if (conf) {
$("#installplugin-plugin").val(slug);
Expand All @@ -174,7 +178,7 @@
});
$(".removeBtn").click(function() {
var name = $(this).data('name');

var conf = confirm('Are you sure you want to Remove the plugin "' + name + '"?');
if (conf) {
$("#removeplugin-name").val(name);
Expand All @@ -196,4 +200,5 @@
});
</script>
</body>

</html>
2 changes: 1 addition & 1 deletion classes/Aircraft.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static function fetchActiveAircraft()
public static function findAircraft($liveryId)
{
self::init();
$result = self::$_db->get('aircraft', array('ifliveryid', '=', $liveryId));
$result = self::$_db->query("SELECT * FROM aircraft WHERE `ifliveryid`=? AND `status`=1", [$liveryId]);
if ($result->count() === 0) return false;
return $result->first();
}
Expand Down
2 changes: 1 addition & 1 deletion classes/VANet.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public static function sendPirep($fields)
return false;
}

if (!$response || Json::decode($response)['status'] != 0) return false;
if (!$response || $response['status'] != 0) return false;

return true;
}
Expand Down
4 changes: 2 additions & 2 deletions update.php
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@
$slash = "\\";
}

$GH_BRANCH = "master";
$GH_BRANCH = "v1";

$url = "https://raw.githubusercontent.com/va-net/flare-plugins/{$GH_BRANCH}/plugins.tsv";
$opts = array(
Expand Down Expand Up @@ -900,7 +900,7 @@
}
}
foreach ($pluginadv["installation"]["files"] as $f) {
$data = file_get_contents("https://raw.githubusercontent.com/va-net/flare-plugins/master/" . $pluginbasic["slug"] . "/" . $f, false, $context);
$data = file_get_contents("https://raw.githubusercontent.com/va-net/flare-plugins/v1/" . $pluginbasic["slug"] . "/" . $f, false, $context);
$f = str_replace("/", $slash, $f);
file_put_contents(__DIR__ . $slash . $f, $data);
}
Expand Down
26 changes: 16 additions & 10 deletions updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,22 @@
}
echo "Updated Database Successfully<br />";

// Delete Files to Delete
if (!($current["prerelease"] && !$next["prerelease"])) {
foreach ($nextUpdate["deletedFiles"] as $delFile) {
if (is_dir(__DIR__ . $slash . $delFile)) {
if (!rmdir(__DIR__ . $slash . $delFile)) {
echo "There was an error deleting " . $delFile;
}
} else {
if (!unlink(__DIR__ . $slash . $delFile)) {
echo "There was an error deleting " . $delFile;
}
}
}
echo "Deleted Removed Files Successfully<br />";
}

// Add Directories
if (array_key_exists('newFolders', $nextUpdate)) {
foreach ($nextUpdate['newFolders'] as $dir) {
Expand All @@ -147,16 +163,6 @@
}
echo "Updated Files Successfully<br />";

// Delete Files to Delete
if (!($current["prerelease"] && !$next["prerelease"])) {
foreach ($nextUpdate["deletedFiles"] as $delFile) {
if (!unlink(__DIR__ . $slash . $delFile)) {
echo "There was an error deleting " . $delFile;
}
}
echo "Deleted Removed Files Successfully<br />";
}

// Update Version File
$vData = file_get_contents($RAW_URL . urlencode($nextTag["commit"]["sha"]) . "/version.json");
file_put_contents(__DIR__ . $slash . "version.json", $vData);
Expand Down
18 changes: 18 additions & 0 deletions updates.json
Original file line number Diff line number Diff line change
Expand Up @@ -609,5 +609,23 @@
"queries": [],
"deletedFiles": [],
"newFolders": []
},
{
"tag": "v1.2.9",
"name": "Version 1.2.9",
"date": "2021-05-30",
"notes": "Fixed rare ACARS issue, restructured updater, changed plugins branch",
"prerelease": false,
"useUpdater": true,
"files": [
"updater.php",
"admin/plugins.php",
"update.php",
"vanet.php",
"classes/Aircraft.php"
],
"queries": [],
"deletedFiles": [],
"newFolders": []
}
]
2 changes: 1 addition & 1 deletion vanet.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
</div>
<div class="form-group">
<label for="multi">Multiplier Number (if applicable)</label>
<label for="multi">Multiplier Code (if applicable)</label>
<input type="number" class="form-control" maxlength="6" minlength="6" id="multi" name="multi">
</div>
Expand Down
4 changes: 2 additions & 2 deletions version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tag": "v1.2.8",
"name": "Version 1.2.8",
"tag": "v1.2.9",
"name": "Version 1.2.9",
"prerelease": false
}

0 comments on commit 7171b9c

Please sign in to comment.