Compare commits
28 Commits
1007-csv-i
...
snyk-fix-0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d23f558dd | ||
|
|
baf63361a0 | ||
|
|
b4d5c0fbcd | ||
|
|
6b7eab05e2 | ||
|
|
4c8e31ac6f | ||
|
|
fe41e61c02 | ||
|
|
bd85a04530 | ||
|
|
cbb7d6e274 | ||
|
|
8907527872 | ||
|
|
942c060c99 | ||
|
|
68a9421445 | ||
|
|
4e652c91ae | ||
|
|
a6f62045c4 | ||
|
|
3f3b63da6f | ||
|
|
dd7812e5c5 | ||
|
|
447d02bd4f | ||
|
|
be9b698f14 | ||
|
|
d110c2d951 | ||
|
|
4d20998368 | ||
|
|
4a20b41b25 | ||
|
|
8c2513eb3d | ||
|
|
2dbd58e59e | ||
|
|
bf77f7dd96 | ||
|
|
5a570989de | ||
|
|
6b3207377a | ||
|
|
ac1d5e1555 | ||
|
|
0d45fc287b | ||
|
|
4911f6799d |
@@ -12,13 +12,24 @@ abstract class Metar
|
||||
{
|
||||
/**
|
||||
* Implement retrieving the METAR - return the METAR string. Needs to be protected,
|
||||
* since this shouldn't be directly called. Call `get_metar($icao)` instead
|
||||
* since this shouldn't be directly called. Call `metar($icao)`. If not implemented,
|
||||
* return a blank string
|
||||
*
|
||||
* @param $icao
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract protected function metar($icao): string;
|
||||
abstract protected function get_metar($icao): string;
|
||||
|
||||
/**
|
||||
* Implement retrieving the TAF - return the string. Call `taf($icao)`. If not implemented,
|
||||
* return a blank string
|
||||
*
|
||||
* @param $icao
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract protected function get_taf($icao): string;
|
||||
|
||||
/**
|
||||
* Download the METAR, wrap in caching
|
||||
@@ -27,9 +38,9 @@ abstract class Metar
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_metar($icao): string
|
||||
public function metar($icao): string
|
||||
{
|
||||
$cache = config('cache.keys.WEATHER_LOOKUP');
|
||||
$cache = config('cache.keys.METAR_WEATHER_LOOKUP');
|
||||
$key = $cache['key'].$icao;
|
||||
|
||||
if (Cache::has($key)) {
|
||||
@@ -40,7 +51,7 @@ abstract class Metar
|
||||
}
|
||||
|
||||
try {
|
||||
$raw_metar = $this->metar($icao);
|
||||
$raw_metar = $this->get_metar($icao);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Error getting METAR: '.$e->getMessage(), $e->getTrace());
|
||||
return '';
|
||||
@@ -52,4 +63,37 @@ abstract class Metar
|
||||
|
||||
return $raw_metar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the TAF, wrap in caching
|
||||
*
|
||||
* @param $icao
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function taf($icao): string
|
||||
{
|
||||
$cache = config('cache.keys.TAF_WEATHER_LOOKUP');
|
||||
$key = $cache['key'].$icao;
|
||||
|
||||
if (Cache::has($key)) {
|
||||
$taf = Cache::get($key);
|
||||
if ($taf !== '') {
|
||||
return $taf;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$taf = $this->get_taf($icao);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Error getting TAF: '.$e->getMessage(), $e->getTrace());
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($taf !== '') {
|
||||
Cache::put($key, $taf, $cache['time']);
|
||||
}
|
||||
|
||||
return $taf;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,8 @@ namespace App\Cron\Nightly;
|
||||
|
||||
use App\Contracts\Listener;
|
||||
use App\Events\CronNightly;
|
||||
use App\Models\Enums\UserState;
|
||||
use App\Models\User;
|
||||
use App\Services\UserService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Determine if any pilots should be set to ON LEAVE status
|
||||
@@ -18,6 +16,8 @@ class PilotLeave extends Listener
|
||||
|
||||
/**
|
||||
* PilotLeave constructor.
|
||||
*
|
||||
* @param UserService $userSvc
|
||||
*/
|
||||
public function __construct(UserService $userSvc)
|
||||
{
|
||||
@@ -34,14 +34,7 @@ class PilotLeave extends Listener
|
||||
*/
|
||||
public function handle(CronNightly $event): void
|
||||
{
|
||||
if (setting('pilots.auto_leave_days') === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$date = Carbon::now()->subDay(setting('pilots.auto_leave_days'));
|
||||
$users = User::where('status', UserState::ACTIVE)
|
||||
->whereDate('updated_at', '<', $date);
|
||||
|
||||
$users = $this->userSvc->findUsersOnLeave();
|
||||
foreach ($users as $user) {
|
||||
Log::info('Setting user '.$user->ident.' to ON LEAVE status');
|
||||
$this->userSvc->setStatusOnLeave($user);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Change the vertical speed for the acars table to a double
|
||||
*/
|
||||
class ChangeAcarsVsType extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('acars', function (Blueprint $table) {
|
||||
$table->float('vs')->change()->default(0.0)->nullable();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Bring the sessions table in line with the latest
|
||||
*/
|
||||
class UpdateSessionsTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('sessions', function (Blueprint $table) {
|
||||
$table->index('user_id');
|
||||
$table->index('last_activity');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -186,13 +186,13 @@ class AwardController extends Controller
|
||||
{
|
||||
$award = $this->awardRepository->findWithoutFail($id);
|
||||
if (empty($award)) {
|
||||
Flash::error('Fare not found');
|
||||
Flash::error('Award not found');
|
||||
|
||||
return redirect(route('admin.awards.index'));
|
||||
}
|
||||
|
||||
$this->awardRepository->delete($id);
|
||||
Flash::success('Fare deleted successfully.');
|
||||
Flash::success('Award deleted successfully.');
|
||||
|
||||
return redirect(route('admin.awards.index'));
|
||||
}
|
||||
|
||||
@@ -147,6 +147,12 @@ class FlightController extends Controller
|
||||
$flights = collect();
|
||||
$saved_flights = [];
|
||||
foreach ($user->bids as $bid) {
|
||||
// Remove any invalid bids (flight doesn't exist or something)
|
||||
if (!$bid->flight) {
|
||||
$bid->delete();
|
||||
continue;
|
||||
}
|
||||
|
||||
$flights->add($bid->flight);
|
||||
$saved_flights[] = $bid->flight->id;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class ProfileController extends Controller
|
||||
{
|
||||
// Is the ACARS module enabled?
|
||||
$acars_enabled = false;
|
||||
$acars = Module::find('VMSACARS');
|
||||
$acars = Module::find('VMSAcars');
|
||||
if ($acars) {
|
||||
$acars_enabled = $acars->isEnabled();
|
||||
}
|
||||
@@ -95,6 +95,7 @@ class ProfileController extends Controller
|
||||
'user' => $user,
|
||||
'userFields' => $userFields,
|
||||
'airports' => $airports,
|
||||
'acars' => $this->acarsEnabled(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -121,7 +122,7 @@ class ProfileController extends Controller
|
||||
|
||||
$airlines = $this->airlineRepo->selectBoxList();
|
||||
$airports = $this->airportRepo->selectBoxList(false, setting('pilots.home_hubs_only'));
|
||||
$userFields = $this->userRepo->getUserFields($user, false);
|
||||
$userFields = $this->userRepo->getUserFields($user, true);
|
||||
|
||||
return view('profile.edit', [
|
||||
'user' => $user,
|
||||
|
||||
@@ -110,6 +110,12 @@ class SimBriefController
|
||||
$loadmax = $lfactor + $lfactorv;
|
||||
$loadmax = $loadmax > 100 ? 100 : $loadmax;
|
||||
|
||||
// Failsafe for admins not defining load values for their flights
|
||||
// and also leave the general settings empty, set loadmax to 100
|
||||
if ($loadmax === 0) {
|
||||
$loadmax = 100;
|
||||
}
|
||||
|
||||
// Show the main simbrief form
|
||||
return view('flights.simbrief_form', [
|
||||
'flight' => $flight,
|
||||
|
||||
@@ -27,6 +27,7 @@ class Pirep extends Resource
|
||||
{
|
||||
$res = parent::toArray($request);
|
||||
$res['ident'] = $this->ident;
|
||||
$res['phase'] = $this->status;
|
||||
$res['status_text'] = PirepStatus::label($this->status);
|
||||
|
||||
// Set these to the response units
|
||||
|
||||
@@ -4,6 +4,14 @@ namespace App\Models;
|
||||
|
||||
use App\Contracts\Model;
|
||||
|
||||
/**
|
||||
* @property int id
|
||||
* @property string pirep_id
|
||||
* @property int fare_id
|
||||
* @property int count
|
||||
* @property Pirep pirep
|
||||
* @property Fare fare
|
||||
*/
|
||||
class PirepFare extends Model
|
||||
{
|
||||
public $table = 'pirep_fares';
|
||||
|
||||
@@ -46,12 +46,32 @@ class AirportService extends Service
|
||||
return;
|
||||
}
|
||||
|
||||
$raw_metar = $this->metarProvider->get_metar($icao);
|
||||
$raw_metar = $this->metarProvider->metar($icao);
|
||||
if ($raw_metar && $raw_metar !== '') {
|
||||
return new Metar($raw_metar);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the METAR for a given airport
|
||||
*
|
||||
* @param $icao
|
||||
*
|
||||
* @return Metar|null
|
||||
*/
|
||||
public function getTaf($icao)
|
||||
{
|
||||
$icao = trim($icao);
|
||||
if ($icao === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$raw_taf = $this->metarProvider->taf($icao);
|
||||
if ($raw_taf && $raw_taf !== '') {
|
||||
return new Metar($raw_taf, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup an airport's information from a remote provider. This handles caching
|
||||
* the data internally
|
||||
|
||||
@@ -92,6 +92,6 @@ class CronService extends Service
|
||||
|
||||
// More than 5 minutes... there's a problem
|
||||
$diff = $dt_now->diff($dt);
|
||||
return $diff->i > 5;
|
||||
return $diff->i > 60 * 12; // Hasn't run for 12 hours
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,9 +286,7 @@ class FareService extends Service
|
||||
*/
|
||||
public function getForPirep(Pirep $pirep)
|
||||
{
|
||||
$found_fares = PirepFare::where('pirep_id', $pirep->id)->get();
|
||||
|
||||
return $found_fares;
|
||||
return PirepFare::where('pirep_id', $pirep->id)->get();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -313,6 +311,8 @@ class FareService extends Service
|
||||
$fare['pirep_id'] = $pirep->id;
|
||||
// other fields: ['fare_id', 'count']
|
||||
|
||||
Log::info('Saving fare pirep='.$pirep->id.', fare='.$fare['count']);
|
||||
|
||||
$field = new PirepFare($fare);
|
||||
$field->save();
|
||||
}
|
||||
|
||||
@@ -137,6 +137,13 @@ class FlightService extends Service
|
||||
{
|
||||
/** @var \Illuminate\Support\Collection $subfleets */
|
||||
$subfleets = $flight->subfleets;
|
||||
|
||||
// If no subfleets assigned to a flight get users allowed subfleets
|
||||
if ($subfleets === null || $subfleets->count() === 0) {
|
||||
$subfleets = $this->userSvc->getAllowableSubfleets($user);
|
||||
}
|
||||
|
||||
// If subfleets are still empty return the flight
|
||||
if ($subfleets === null || $subfleets->count() === 0) {
|
||||
return $flight;
|
||||
}
|
||||
|
||||
@@ -9,13 +9,16 @@ use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Return the raw METAR string from the NOAA Aviation Weather Service
|
||||
* Return the raw METAR/TAF string from the NOAA Aviation Weather Service
|
||||
*/
|
||||
class AviationWeather extends Metar
|
||||
{
|
||||
private const METAR_URL =
|
||||
'https://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=';
|
||||
|
||||
private const TAF_URL =
|
||||
'https://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=tafs&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=';
|
||||
|
||||
private $httpClient;
|
||||
|
||||
public function __construct(HttpClient $httpClient)
|
||||
@@ -33,7 +36,7 @@ class AviationWeather extends Metar
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function metar($icao): string
|
||||
protected function get_metar($icao): string
|
||||
{
|
||||
if ($icao === '') {
|
||||
return '';
|
||||
@@ -67,7 +70,53 @@ class AviationWeather extends Metar
|
||||
return $xml->data->METAR->raw_text->__toString();
|
||||
} catch (Exception $e) {
|
||||
Log::error('Error reading METAR: '.$e->getMessage());
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the actual retrieval of the TAF
|
||||
*
|
||||
* @param $icao
|
||||
*
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get_taf($icao): string
|
||||
{
|
||||
if ($icao === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$tafurl = static::TAF_URL.$icao;
|
||||
|
||||
try {
|
||||
$tafres = $this->httpClient->get($tafurl, []);
|
||||
$tafxml = simplexml_load_string($tafres);
|
||||
|
||||
$tafattrs = $tafxml->data->attributes();
|
||||
if (!isset($tafattrs['num_results'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$tafnum_results = $tafattrs['num_results'];
|
||||
if (empty($tafnum_results)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$tafnum_results = (int) $tafnum_results;
|
||||
if ($tafnum_results === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (count($tafxml->data->TAF->raw_text) === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $tafxml->data->TAF->raw_text->__toString();
|
||||
} catch (Exception $e) {
|
||||
Log::error('Error reading TAF: '.$e->getMessage());
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ use App\Repositories\SubfleetRepository;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\Support\Units\Time;
|
||||
use App\Support\Utils;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use function is_array;
|
||||
@@ -254,6 +255,41 @@ class UserService extends Service
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the users that are determined to be on leave. Only goes through the
|
||||
* currently active users. If the user doesn't have a PIREP, then the creation date
|
||||
* of the user record is used to determine the difference
|
||||
*/
|
||||
public function findUsersOnLeave(): array
|
||||
{
|
||||
$leave_days = setting('pilots.auto_leave_days');
|
||||
if ($leave_days === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$return_users = [];
|
||||
|
||||
$date = Carbon::now('UTC');
|
||||
$users = User::with(['last_pirep'])->where('state', UserState::ACTIVE)->get();
|
||||
|
||||
/** @var User $user */
|
||||
foreach ($users as $user) {
|
||||
// If they haven't submitted a PIREP, use the date that the user was created
|
||||
if (!$user->last_pirep) {
|
||||
$diff_date = $user->created_at;
|
||||
} else {
|
||||
$diff_date = $user->last_pirep->submitted_at;
|
||||
}
|
||||
|
||||
// See if the difference is larger than what the setting calls for
|
||||
if ($date->diffInDays($diff_date) > $leave_days) {
|
||||
$return_users[] = $user;
|
||||
}
|
||||
}
|
||||
|
||||
return $return_users;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the subfleets this user is allowed access to,
|
||||
* based on their current rank
|
||||
@@ -426,7 +462,7 @@ class UserService extends Service
|
||||
$user->state = UserState::ON_LEAVE;
|
||||
$user->save();
|
||||
|
||||
event(new UserStateChanged($user, UserState::ACTIVE));
|
||||
event(new UserStateChanged($user, UserState::ON_LEAVE));
|
||||
|
||||
$user->refresh();
|
||||
return $user;
|
||||
|
||||
@@ -123,6 +123,10 @@ class Utils
|
||||
return $val;
|
||||
}
|
||||
|
||||
if ($result->hostname === 'localhost') {
|
||||
return 'localhost';
|
||||
}
|
||||
|
||||
// Couldn't validate a domain, see if this is an IP address?
|
||||
if (filter_var($url, FILTER_VALIDATE_IP)) {
|
||||
return $url;
|
||||
|
||||
@@ -11,7 +11,8 @@ use App\Services\AirportService;
|
||||
class Weather extends Widget
|
||||
{
|
||||
protected $config = [
|
||||
'icao' => null,
|
||||
'icao' => null,
|
||||
'raw_only' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -22,10 +23,12 @@ class Weather extends Widget
|
||||
/** @var \App\Services\AirportService $airportSvc */
|
||||
$airportSvc = app(AirportService::class);
|
||||
$metar = $airportSvc->getMetar($this->config['icao']);
|
||||
$taf = $airportSvc->getTaf($this->config['icao']);
|
||||
|
||||
return view('widgets.weather', [
|
||||
'config' => $this->config,
|
||||
'metar' => $metar,
|
||||
'taf' => $taf,
|
||||
'unit_alt' => setting('units.altitude'),
|
||||
'unit_dist' => setting('units.distance'),
|
||||
'unit_temp' => setting('units.temperature'),
|
||||
|
||||
@@ -58,7 +58,8 @@
|
||||
"webpatser/laravel-uuid": "~3.0",
|
||||
"oomphinc/composer-installers-extender": "^1.1",
|
||||
"laravel/ui": "^2.0",
|
||||
"madnest/madzipper": "^1.0"
|
||||
"madnest/madzipper": "^1.0",
|
||||
"elcobvg/laravel-opcache": "^0.4.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"barryvdh/laravel-debugbar": "^3.0",
|
||||
|
||||
59
composer.lock
generated
59
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "6f5fb0bd12dc789b1ad1613ddf907a80",
|
||||
"content-hash": "5bd282b9602f7922883277e45c82603e",
|
||||
"packages": [
|
||||
{
|
||||
"name": "akaunting/money",
|
||||
@@ -1655,6 +1655,63 @@
|
||||
],
|
||||
"time": "2020-08-08T21:28:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "elcobvg/laravel-opcache",
|
||||
"version": "0.4.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/elcobvg/laravel-opcache.git",
|
||||
"reference": "a9af6d12f8bda562dd187f6d5368c647c1f02a44"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/elcobvg/laravel-opcache/zipball/a9af6d12f8bda562dd187f6d5368c647c1f02a44",
|
||||
"reference": "a9af6d12f8bda562dd187f6d5368c647c1f02a44",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "1.0",
|
||||
"orchestra/testbench": "3.5",
|
||||
"phpunit/phpunit": "6.5",
|
||||
"squizlabs/php_codesniffer": "3.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"ElcoBvg\\Opcache\\ServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"ElcoBvg\\Opcache\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Elco Brouwer von Gonzenbach",
|
||||
"email": "elco.brouwer@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Custom OPcache Cache Driver for Laravel. Faster than Redis or memcached.",
|
||||
"homepage": "https://github.com/elcobvg/laravel-opcache",
|
||||
"keywords": [
|
||||
"Opcache",
|
||||
"cache",
|
||||
"driver",
|
||||
"laravel",
|
||||
"webprofiler"
|
||||
],
|
||||
"time": "2020-05-16T00:51:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "facade/flare-client-php",
|
||||
"version": "1.3.5",
|
||||
|
||||
@@ -135,7 +135,7 @@ return [
|
||||
*/
|
||||
'monitor_backups' => [
|
||||
[
|
||||
'name' => config(config('app.name'), 'phpvms-backup'),
|
||||
'name' => config('app.name'),
|
||||
'disks' => ['local'],
|
||||
'health_checks' => [
|
||||
MaximumAgeInDays::class => 1,
|
||||
@@ -172,27 +172,27 @@ return [
|
||||
/*
|
||||
* The number of days for which backups must be kept.
|
||||
*/
|
||||
'keep_all_backups_for_days' => 7,
|
||||
'keep_all_backups_for_days' => 3,
|
||||
|
||||
/*
|
||||
* The number of days for which daily backups must be kept.
|
||||
*/
|
||||
'keep_daily_backups_for_days' => 7,
|
||||
'keep_daily_backups_for_days' => 2,
|
||||
|
||||
/*
|
||||
* The number of weeks for which one weekly backup must be kept.
|
||||
*/
|
||||
'keep_weekly_backups_for_weeks' => 4,
|
||||
'keep_weekly_backups_for_weeks' => 2,
|
||||
|
||||
/*
|
||||
* The number of months for which one monthly backup must be kept.
|
||||
*/
|
||||
'keep_monthly_backups_for_months' => 4,
|
||||
'keep_monthly_backups_for_months' => 1,
|
||||
|
||||
/*
|
||||
* The number of years for which one yearly backup must be kept.
|
||||
*/
|
||||
'keep_yearly_backups_for_years' => 2,
|
||||
'keep_yearly_backups_for_years' => 1,
|
||||
|
||||
/*
|
||||
* After cleaning up the backups remove the oldest backup until
|
||||
|
||||
@@ -9,14 +9,18 @@ return [
|
||||
'key' => 'airports.lookup:',
|
||||
'time' => 60 * 30,
|
||||
],
|
||||
'WEATHER_LOOKUP' => [
|
||||
'key' => 'airports.weather.', // append icao
|
||||
'METAR_WEATHER_LOOKUP' => [
|
||||
'key' => 'airports.weather.metar.', // append icao
|
||||
'time' => 60 * 60, // Cache for 60 minutes
|
||||
],
|
||||
'RANKS_PILOT_LIST' => [
|
||||
'key' => 'ranks.pilot_list',
|
||||
'time' => 60 * 10,
|
||||
],
|
||||
'TAF_WEATHER_LOOKUP' => [
|
||||
'key' => 'airports.weather.taf.', // append icao
|
||||
'time' => 60 * 60, // Cache for 60 minutes
|
||||
],
|
||||
'USER_API_KEY' => [
|
||||
'key' => 'user.apikey',
|
||||
'time' => 60 * 5, // 5 min
|
||||
|
||||
@@ -23,6 +23,7 @@ return [
|
||||
'tokenizer',
|
||||
'json',
|
||||
'curl',
|
||||
'dom',
|
||||
],
|
||||
|
||||
// Make sure these are writable
|
||||
|
||||
@@ -15,8 +15,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => env('MAIL_DRIVER', 'smtp'),
|
||||
|
||||
'default' => env('MAIL_DRIVER', 'smtp'),
|
||||
'mailers' => [
|
||||
'smtp' => [
|
||||
'transport' => 'smtp',
|
||||
@@ -71,4 +70,21 @@ return [
|
||||
'address' => env('MAIL_FROM_ADDRESS', 'no-reply@phpvms.net'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Markdown Mail Settings
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If you are using Markdown based email rendering, you may configure your
|
||||
| theme and component paths here, allowing you to customize the design
|
||||
| of the emails. Or, you may simply stick with the Laravel defaults!
|
||||
|
|
||||
*/
|
||||
|
||||
'markdown' => [
|
||||
'theme' => 'default',
|
||||
'paths' => [
|
||||
resource_path('views/vendor/mail'),
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@@ -20,7 +20,7 @@ return [
|
||||
'expire_on_close' => false,
|
||||
'encrypt' => false,
|
||||
'files' => storage_path('framework/sessions'),
|
||||
'connection' => null,
|
||||
'connection' => 'mysql',
|
||||
'table' => 'sessions',
|
||||
'store' => null,
|
||||
'lottery' => [1, 100],
|
||||
|
||||
@@ -42,7 +42,7 @@ class PilotHoursAwards extends Award
|
||||
*/
|
||||
public function check($flight_minutes = null): bool
|
||||
{
|
||||
if (!is_int($flight_minutes)) {
|
||||
if (!is_numeric($flight_minutes)) {
|
||||
Log::error('PilotHourAwards: Flight time "'.$flight_minutes.'" is not a valid flight time');
|
||||
return false;
|
||||
}
|
||||
|
||||
11
package-lock.json
generated
11
package-lock.json
generated
@@ -1983,11 +1983,6 @@
|
||||
"resolved": "https://registry.npmjs.org/bootstrap-sass/-/bootstrap-sass-3.4.1.tgz",
|
||||
"integrity": "sha512-p5rxsK/IyEDQm2CwiHxxUi0MZZtvVFbhWmyMOt4lLkA4bujDA1TGoKT0i1FKIWiugAdP+kK8T5KMDFIKQCLYIA=="
|
||||
},
|
||||
"bootstrap3": {
|
||||
"version": "npm:bootstrap@3.4.1",
|
||||
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-3.4.1.tgz",
|
||||
"integrity": "sha512-yN5oZVmRCwe5aKwzRj6736nSmKDX7pLYwsXiCj/EYmo16hODaBiT4En5btW/jhBF/seV+XMx3aYwukYC3A49DA=="
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
@@ -5817,9 +5812,9 @@
|
||||
}
|
||||
},
|
||||
"lodash": {
|
||||
"version": "4.17.20",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz",
|
||||
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA=="
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||
},
|
||||
"lodash.memoize": {
|
||||
"version": "4.1.2",
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
"leaflet-providers": "1.0.*",
|
||||
"leaflet-rotatedmarker": "^0.2.0",
|
||||
"leaflet.geodesic": "^2.5.2",
|
||||
"lodash": ">=4.17.19",
|
||||
"lodash": ">=4.17.21",
|
||||
"marked": "^1.2.2",
|
||||
"minimist": "^1.2.2",
|
||||
"moment": "^2.29.1",
|
||||
|
||||
@@ -130,3 +130,11 @@
|
||||
border-radius: 5px;
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
/*
|
||||
* fix the dropdown menu on mobile view
|
||||
*/
|
||||
.dropdown-menu:not(.show) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ return [
|
||||
|
||||
// Overrides config/mail.php
|
||||
'mail' => [
|
||||
'driver' => 'mail', # Default is to use the mail() fn
|
||||
'default' => 'mail', # Default is to use the mail() fn
|
||||
'mailers' => [
|
||||
'smtp' => [
|
||||
'transport' => 'smtp',
|
||||
@@ -107,7 +107,8 @@ return [
|
||||
|
||||
// Overrides config/session.php
|
||||
'session' => [
|
||||
'default' => 'file',
|
||||
'driver' => 'database',
|
||||
'connection' => 'mysql',
|
||||
'lifetime' => 60 * 24, # 24 hours
|
||||
],
|
||||
];
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<div class="content">
|
||||
@if($cron_problem_exists)
|
||||
<div class="alert alert-danger" role="alert">
|
||||
There was a problem running the cron; make sure it's setup and check logs at
|
||||
The cron has not run in more than 12 hours; make sure it's setup and check logs at
|
||||
<span class="text-monospace bg-gradient-dark">storage/logs/cron.log</span>.
|
||||
<a href="{{ docs_link('cron') }}" target="_blank">See the docs</a>
|
||||
</div>
|
||||
|
||||
@@ -223,8 +223,8 @@
|
||||
<form action="https://my.vatsim.net/pilots/flightplan" method="GET" target="_blank">
|
||||
<input type="hidden" name="raw" value="{{ $simbrief->xml->atc->flightplan_text }}">
|
||||
<input type="hidden" name="fuel_time" value="@secstohhmm($simbrief->xml->times->endurance)">
|
||||
<input type="hidden" name="speed" value="{{ $simbrief->xml->atc->initial_spd }}">
|
||||
<input type="hidden" name="altitude" value="{{ $simbrief->xml->atc->initial_alt }}">
|
||||
<input type="hidden" name="speed" value="@if(substr($simbrief->xml->atc->initial_spd,0,1) === '0') {{ substr($simbrief->xml->atc->initial_spd,1) }} @else {{ $simbrief->xml->atc->initial_spd }} @endif">
|
||||
<input type="hidden" name="altitude" value="{{ $simbrief->xml->general->initial_altitude }}">
|
||||
<input id="vatsim_prefile" type="submit" class="btn btn-primary" value="File ATC on VATSIM"/>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -133,11 +133,11 @@
|
||||
<div class="text-right">
|
||||
@if (isset($acars) && $acars === true)
|
||||
<a href="{{ route('frontend.profile.acars') }}" class="btn btn-primary"
|
||||
onclick="alert('Save to \'My Documents/phpVMS\'')">ACARS Config</a>
|
||||
onclick="alert('Copy or Save to \'My Documents/phpVMS\'')">ACARS Config</a>
|
||||
|
||||
@endif
|
||||
<a href="{{ route('frontend.profile.regen_apikey') }}" class="btn btn-warning"
|
||||
onclick="return confirm({{ __('Are you sure? This will reset your API key.') }})">@lang('profile.newapikey')</a>
|
||||
onclick="return confirm('Are you sure? This will reset your API key!')">@lang('profile.newapikey')</a>
|
||||
|
||||
<a href="{{ route('frontend.profile.edit', [$user->id]) }}"
|
||||
class="btn btn-primary">@lang('common.edit')</a>
|
||||
@@ -171,7 +171,7 @@
|
||||
<div class="col-sm-12">
|
||||
<table class="table table-full-width">
|
||||
@foreach($userFields as $field)
|
||||
@if($field->public === true)
|
||||
@if(!$field->private)
|
||||
<tr>
|
||||
<td>{{ $field->name }}</td>
|
||||
<td>{{ $field->value }}</td>
|
||||
|
||||
@@ -4,10 +4,8 @@ If you want to edit this, you can reference the CheckWX API docs:
|
||||
https://api.checkwx.com/#metar-decoded
|
||||
|
||||
--}}
|
||||
@if(!$metar)
|
||||
<p>@lang('widgets.weather.nometar')</p>
|
||||
@else
|
||||
<table class="table table-striped">
|
||||
<table class="table table-striped">
|
||||
@if($config['raw_only'] != true && $metar)
|
||||
<tr>
|
||||
<td>@lang('widgets.weather.conditions')</td>
|
||||
<td>{{ $metar['category'] }}</td>
|
||||
@@ -20,35 +18,35 @@ https://api.checkwx.com/#metar-decoded
|
||||
</td>
|
||||
</tr>
|
||||
@if($metar['visibility'])
|
||||
<tr>
|
||||
<td>Visibility</td>
|
||||
<td>{{ $metar['visibility'][$unit_dist] }} {{$unit_dist}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Visibility</td>
|
||||
<td>{{ $metar['visibility'][$unit_dist] }} {{$unit_dist}}</td>
|
||||
</tr>
|
||||
@endif
|
||||
@if($metar['runways_visual_range'])
|
||||
<tr>
|
||||
<tr>
|
||||
<td>Runway Visual Range</td>
|
||||
<td>
|
||||
@foreach($metar['runways_visual_range'] as $rvr)
|
||||
<b>RWY{{ $rvr['runway'] }}</b>; {{ $rvr['report'] }}<br>
|
||||
@endforeach
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
@endif
|
||||
@if($metar['present_weather_report'] <> 'Dry')
|
||||
<tr>
|
||||
<tr>
|
||||
<td>Phenomena</td>
|
||||
<td>{{ $metar['present_weather_report'] }}</td>
|
||||
</tr>
|
||||
</tr>
|
||||
@endif
|
||||
@if($metar['clouds'] || $metar['cavok'])
|
||||
<tr>
|
||||
<tr>
|
||||
<td>@lang('widgets.weather.clouds')</td>
|
||||
<td>
|
||||
@if($unit_alt === 'ft') {{ $metar['clouds_report_ft'] }} @else {{ $metar['clouds_report'] }} @endif
|
||||
@if($metar['cavok'] == 1) Ceiling and Visibility OK @endif
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
@endif
|
||||
<tr>
|
||||
<td>Temperature</td>
|
||||
@@ -63,20 +61,20 @@ https://api.checkwx.com/#metar-decoded
|
||||
<td>{{ number_format($metar['barometer']['hPa']) }} hPa / {{ number_format($metar['barometer']['inHg'], 2) }} inHg</td>
|
||||
</tr>
|
||||
@if($metar['recent_weather_report'])
|
||||
<tr>
|
||||
<tr>
|
||||
<td>Recent Phenomena</td>
|
||||
<td>{{ $metar['recent_weather_report'] }}</td>
|
||||
</tr>
|
||||
</tr>
|
||||
@endif
|
||||
@if($metar['runways_report'])
|
||||
<tr>
|
||||
<tr>
|
||||
<td>Runway Condition</td>
|
||||
<td>
|
||||
@foreach($metar['runways_report'] as $runway)
|
||||
<b>RWY{{ $runway['runway'] }}</b>; {{ $runway['report'] }}<br>
|
||||
@endforeach
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
@endif
|
||||
@if($metar['remarks'])
|
||||
<tr>
|
||||
@@ -88,9 +86,13 @@ https://api.checkwx.com/#metar-decoded
|
||||
<td>@lang('widgets.weather.updated')</td>
|
||||
<td>{{$metar['observed_time']}} ({{$metar['observed_age']}})</td>
|
||||
</tr>
|
||||
@endif
|
||||
<tr>
|
||||
<td>@lang('common.metar')</td>
|
||||
<td>{{ $metar['raw'] }}</td>
|
||||
<td>@if($metar) {{ $metar['raw'] }} @else @lang('widgets.weather.nometar') @endif</td>
|
||||
</tr>
|
||||
</table>
|
||||
@endif
|
||||
<tr>
|
||||
<td>TAF</td>
|
||||
<td>@if($taf) {{ $taf['raw'] }} @else @lang('widgets.weather.nometar') @endif</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -168,6 +168,8 @@ class MetarTest extends TestCase
|
||||
public function testHttpCallSuccess()
|
||||
{
|
||||
$this->mockXmlResponse('aviationweather/kjfk.xml');
|
||||
|
||||
/** @var AirportService $airportSvc */
|
||||
$airportSvc = app(AirportService::class);
|
||||
|
||||
$this->assertInstanceOf(Metar::class, $airportSvc->getMetar('kjfk'));
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
namespace Tests;
|
||||
|
||||
use App\Models\Aircraft;
|
||||
use App\Models\Enums\UserState;
|
||||
use App\Models\Flight;
|
||||
use App\Models\Pirep;
|
||||
use App\Models\Subfleet;
|
||||
use App\Models\User;
|
||||
use Exception;
|
||||
@@ -21,34 +23,37 @@ trait TestData
|
||||
{
|
||||
$subfleet = $this->createSubfleetWithAircraft(1);
|
||||
$rank = $this->createRank(2, [$subfleet['subfleet']->id]);
|
||||
$user = factory(User::class)->create(array_merge([
|
||||
|
||||
return factory(User::class)->create(array_merge([
|
||||
'flight_time' => 1000,
|
||||
'rank_id' => $rank->id,
|
||||
'state' => UserState::ACTIVE,
|
||||
], $attrs));
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new PIREP with a proper subfleet/rank/user and an
|
||||
* aircraft that the user is allowed to fly
|
||||
*
|
||||
* @param array $user_attrs Additional attributes for the user
|
||||
* @param array $pirep_attrs Additional attributes for the PIREP
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return \App\Models\Pirep
|
||||
*/
|
||||
protected function createPirep()
|
||||
protected function createPirep(array $user_attrs = [], array $pirep_attrs = [])
|
||||
{
|
||||
$subfleet = $this->createSubfleetWithAircraft(2);
|
||||
$rank = $this->createRank(10, [$subfleet['subfleet']->id]);
|
||||
$this->user = factory(\App\Models\User::class)->create([
|
||||
$this->user = factory(\App\Models\User::class)->create(array_merge([
|
||||
'rank_id' => $rank->id,
|
||||
]);
|
||||
], $user_attrs));
|
||||
|
||||
// Return a Pirep model
|
||||
$pirep = factory(\App\Models\Pirep::class)->make([
|
||||
return factory(Pirep::class)->make(array_merge([
|
||||
'aircraft_id' => $subfleet['aircraft']->random()->id,
|
||||
]);
|
||||
|
||||
return $pirep;
|
||||
], $pirep_attrs));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,11 +5,14 @@ namespace Tests;
|
||||
use App\Exceptions\PilotIdNotFound;
|
||||
use App\Exceptions\UserPilotIdExists;
|
||||
use App\Models\Airline;
|
||||
use App\Models\Enums\UserState;
|
||||
use App\Models\Fare;
|
||||
use App\Models\Pirep;
|
||||
use App\Models\User;
|
||||
use App\Repositories\SettingRepository;
|
||||
use App\Services\FareService;
|
||||
use App\Services\UserService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class UserTest extends TestCase
|
||||
@@ -324,4 +327,48 @@ class UserTest extends TestCase
|
||||
$this->assertEquals($expected, $user->name_private);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testUserLeave(): void
|
||||
{
|
||||
$this->createUser(['status' => UserState::ACTIVE]);
|
||||
|
||||
$users_on_leave = $this->userSvc->findUsersOnLeave();
|
||||
$this->assertEquals(0, count($users_on_leave));
|
||||
|
||||
$this->updateSetting('pilots.auto_leave_days', 1);
|
||||
$user = $this->createUser([
|
||||
'status' => UserState::ACTIVE,
|
||||
'created_at' => Carbon::now('UTC')->subDays(5),
|
||||
]);
|
||||
|
||||
$users_on_leave = $this->userSvc->findUsersOnLeave();
|
||||
$this->assertEquals(1, count($users_on_leave));
|
||||
$this->assertEquals($user->id, $users_on_leave[0]->id);
|
||||
|
||||
// Give that user a new PIREP, still old
|
||||
/** @var \App\Models\Pirep $pirep */
|
||||
$pirep = factory(Pirep::class)->create(['submitted_at' => Carbon::now('UTC')->subDays(5)]);
|
||||
|
||||
$user->last_pirep_id = $pirep->id;
|
||||
$user->save();
|
||||
$user->refresh();
|
||||
|
||||
$users_on_leave = $this->userSvc->findUsersOnLeave();
|
||||
$this->assertEquals(1, count($users_on_leave));
|
||||
$this->assertEquals($user->id, $users_on_leave[0]->id);
|
||||
|
||||
// Create a new PIREP
|
||||
/** @var \App\Models\Pirep $pirep */
|
||||
$pirep = factory(Pirep::class)->create(['submitted_at' => Carbon::now('UTC')]);
|
||||
|
||||
$user->last_pirep_id = $pirep->id;
|
||||
$user->save();
|
||||
$user->refresh();
|
||||
|
||||
$users_on_leave = $this->userSvc->findUsersOnLeave();
|
||||
$this->assertEquals(0, count($users_on_leave));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,5 +100,6 @@ class UtilsTest extends TestCase
|
||||
$this->assertEquals('phpvms.co.uk', Utils::getRootDomain('http://phpvms.co.uk'));
|
||||
$this->assertEquals('phpvms.co.uk', Utils::getRootDomain('http://www.phpvms.co.uk'));
|
||||
$this->assertEquals('127.0.0.1', Utils::getRootDomain('http://127.0.0.1'));
|
||||
$this->assertEquals('localhost', Utils::getRootDomain('http://localhost'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user