Compare commits

...

28 Commits

Author SHA1 Message Date
snyk-bot
5d23f558dd fix: package.json & package-lock.json to reduce vulnerabilities
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-LODASH-1018905
- https://snyk.io/vuln/SNYK-JS-LODASH-1040724
2021-02-23 02:34:06 +00:00
B.Fatih KOZ
baf63361a0 Fix findUsersOnleave Function (#1042)
Query was checking status field instead of state field to find active users.
2021-02-22 11:23:50 -05:00
B.Fatih KOZ
b4d5c0fbcd Weather METAR/TAF enhancements (#964)
* Update AviationWeather.php

Added the ability to fetch latest TAF report of given icao from ADDS/NOAA

* Update Weather.php

Used updated Metar\AviationWeather service to improve the widget ability and provide raw TAF data for the view

* Style Fix 1

* Update weather.blade.php

Updated blade to match updated Metar\AviationWeather service and the Weather widget controller.

Also fixed the order of temp - dewpoint - humidity - visibility display according to aviation usage.

Widget now displays raw TAF data just below raw METAR data.

* Update Metar inferface and wrap TAF retrieval in cache

* Styles fix

* Add call to getTaf. Don't call AviationWeather directly

* Fix cache lookup strings

* Fix recursion error

* Update weather.blade.php

Used latest weather.blade , added $taf['raw'] after raw metar.

* Compatibility Update

Updated the widget controller to match latest dev (added raw_only to config)

* Update Weather Widget Blade

Made the widget blade compatible with the TAF reports, widget will display raw metar and taf after the decoder, if no metar or taf recieved it will be displayed in its own row. Also added the new option of raw_only to blade, if it is true, metar decoding will be skipped and only raw values will be displayed. ( Useful when displaying multiple wx widgets at the same page for departure, destination and alternate etc )

Co-authored-by: Nabeel Shahzad <nshahzad@live.com>
Co-authored-by: Nabeel S <nabeelio@users.noreply.github.com>
2021-02-19 12:45:39 -05:00
B.Fatih KOZ
6b7eab05e2 Assign subfleets from ranks when there are no subfleets on a flight
If no subfleets are assigned to a flight, vmsacars was not allowing the flight to be loaded and used 'cause the subfleets was returning null. With this pr, users will be able to use the aircrafts which they have access to by their ranks. ( Same logic was used in SimBrief Controller to populate the aircraft list for flight plan generation )

Co-authored-by: Nabeel S <nabeelio@users.noreply.github.com>
2021-02-19 08:20:17 -05:00
Jannis D
4c8e31ac6f Update installer.php (#1038)
Co-authored-by: Jannis D <Mail@JannisD.de>
2021-02-19 08:13:08 -05:00
B.Fatih KOZ
fe41e61c02 Fix for SimBrief VATSIM Prefile errors (#1037)
Speed is now checked and leading zero is removed, also changed the initial altitude to full feet value like 23000 instead of just 230.
2021-02-18 18:02:33 -05:00
Nabeel Shahzad
bd85a04530 Fix internal event for ON_LEAVE 2021-02-17 18:57:16 -05:00
Nabeel S
cbb7d6e274 Fix pilot leave calculation #1022 (#1035)
* Fix pilot leave calculation #1022

* Remove unused imports

* Add logging where fares are being saved
2021-02-17 18:54:18 -05:00
Nabeel Shahzad
8907527872 Remove invalid bids #1034 2021-02-17 18:03:07 -05:00
Nabeel Shahzad
942c060c99 Added opcache package 2021-02-17 14:44:41 -05:00
Nabeel Shahzad
68a9421445 Shrink backup sizes 2021-02-17 14:38:47 -05:00
Nabeel Shahzad
4e652c91ae Account for localhost/testing sites in domain checks 2021-02-13 15:59:19 -05:00
Nabeel Shahzad
a6f62045c4 Extend cron check for 12 hours 2021-02-13 15:17:16 -05:00
Nabeel Shahzad
3f3b63da6f Fix session database configuration 2021-02-12 11:43:00 -05:00
Nabeel Shahzad
dd7812e5c5 Undo primary idx change 2021-02-11 08:57:43 -05:00
Nabeel S
447d02bd4f Update the sessions table (#1030)
* Update the sessions table

* Add index on user_id
2021-02-11 08:50:49 -05:00
Nabeel Shahzad
be9b698f14 Merge branch 'dev' of https://github.com/nabeelio/phpvms into dev 2021-02-10 15:47:42 -05:00
Nabeel S
d110c2d951 ACARS table vs int to double (#1028)
* mail config - "driver" to "default"

* Change VS type from int to double

* Migration fix

* Fix type
2021-02-10 13:39:40 -05:00
Nabeel Shahzad
4d20998368 mail config - "driver" to "default" 2021-02-10 13:18:02 -05:00
Nabeel Shahzad
4a20b41b25 Rename driver to default in mail config 2021-02-10 13:15:18 -05:00
Olli
8c2513eb3d Update style.css for better mobile experience (#1018)
This edit hides the dropdown menu while being closed on mobile view
2021-02-05 08:38:32 -05:00
Nabeel Shahzad
2dbd58e59e Merge branch 'dev' of https://github.com/nabeelio/phpvms into dev 2021-02-04 14:54:20 -05:00
Nabeel Shahzad
bf77f7dd96 Add 'phase' as response output, deprecate "status" 2021-02-04 14:54:16 -05:00
B.Fatih KOZ
5a570989de Failsafe for SimBrief random pax generation (#1015)
* Failsafe for SimBrief random pax generation

PR fixes the problem for 0 load generation where va admins do not set load factor and variance values for their flights and also leave the general settings empty. In such cases, both loadmin and loadmax was returning 0 , resulting zero load.

Thanks @macofallico for figuring this out.

* StyleFix
2021-02-01 15:27:22 -05:00
B.Fatih KOZ
6b3207377a Fix Profile Fields (#1013)
* Fix Profile Fields

PR fixes two issues ;

1. Profile Fields not showing up on user profile
2. Profile Fields not showing up on user.profile.edit

Profile.index was looking for "public" to be true, while controller was sending "private" and it was not boolean.

Also profile controller was not sending the fields to the blade. Both fixed and working now

* Update index.blade.php
2021-01-28 08:31:29 -05:00
B.Fatih KOZ
ac1d5e1555 Fix PilotHoursAwards (#1011)
!is_int was causing the check always return false even when user enters a proper value like 6000 or 30000 in admin/award settings.

We should use !is_numeric instead to see if it is a valid numeric value.
2021-01-26 19:48:43 -05:00
B.Fatih KOZ
0d45fc287b AwardController text correction (#1010)
Fixed the flash message texts
2021-01-26 16:31:54 -05:00
B.Fatih KOZ
4911f6799d Fix for ACARS config download button not working #919 (#1009)
* Fix For Acars Config Download Button No Working Bug #919

PR fixes the Acars Config Download button not showing up at user profile.

Also fixes the problem where Generate New Api Key button not following user selections and generating a new key even if user clicks cancel.

* Style Fix for ? and !

Fix the typo :)
2021-01-25 16:04:43 -05:00
38 changed files with 446 additions and 91 deletions

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -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();
});
}
}

View File

@@ -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');
});
}
}

View File

@@ -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'));
}

View File

@@ -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;
}

View File

@@ -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,

View File

@@ -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,

View File

@@ -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

View File

@@ -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';

View File

@@ -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

View File

@@ -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
}
}

View File

@@ -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();
}

View File

@@ -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;
}

View File

@@ -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 '';
}
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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'),

View File

@@ -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
View File

@@ -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",

View File

@@ -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

View File

@@ -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

View File

@@ -23,6 +23,7 @@ return [
'tokenizer',
'json',
'curl',
'dom',
],
// Make sure these are writable

View File

@@ -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'),
],
],
];

View File

@@ -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],

View File

@@ -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
View File

@@ -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",

View File

@@ -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",

View File

@@ -130,3 +130,11 @@
border-radius: 5px;
width: 250px;
}
/*
* fix the dropdown menu on mobile view
*/
.dropdown-menu:not(.show) {
display: none;
}

View File

@@ -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
],
];

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>
&nbsp;
@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>
&nbsp;
<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>

View File

@@ -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>

View File

@@ -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'));

View File

@@ -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));
}
/**

View File

@@ -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));
}
}

View File

@@ -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'));
}
}