From 13a0113e8e3bbaf0b3fbc238ac980304fdaa6c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Duli=C3=A7i?= Date: Mon, 24 Aug 2020 17:45:29 +0300 Subject: [PATCH] more php version check --- app/Http/Controllers/Modules/Item.php | 8 ++++++++ app/Utilities/Console.php | 13 ++++++++++++- bootstrap/autoload.php | 10 +++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Modules/Item.php b/app/Http/Controllers/Modules/Item.php index 9fa93887b..158b2b81d 100644 --- a/app/Http/Controllers/Modules/Item.php +++ b/app/Http/Controllers/Modules/Item.php @@ -159,6 +159,8 @@ class Item extends Controller $message = trans('modules.installed', ['module' => $json['data']['name']]); flash($message)->success(); + } else { + flash($json['message'])->error(); } return response()->json($json); @@ -172,6 +174,8 @@ class Item extends Controller $message = trans('modules.uninstalled', ['module' => $json['data']['name']]); flash($message)->success(); + } else { + flash($json['message'])->error(); } return redirect()->route('apps.app.show', $alias)->send(); @@ -185,6 +189,8 @@ class Item extends Controller $message = trans('modules.enabled', ['module' => $json['data']['name']]); flash($message)->success(); + } else { + flash($json['message'])->error(); } return redirect()->route('apps.app.show', $alias)->send(); @@ -198,6 +204,8 @@ class Item extends Controller $message = trans('modules.disabled', ['module' => $json['data']['name']]); flash($message)->success(); + } else { + flash($json['message'])->error(); } return redirect()->route('apps.app.show', $alias)->send(); diff --git a/app/Utilities/Console.php b/app/Utilities/Console.php index dccab67f1..8aac02f90 100644 --- a/app/Utilities/Console.php +++ b/app/Utilities/Console.php @@ -2,6 +2,7 @@ namespace App\Utilities; +use Exception; use Illuminate\Console\Application; use Illuminate\Support\Str; use Symfony\Component\Process\Exception\InvalidArgumentException; @@ -9,6 +10,7 @@ use Symfony\Component\Process\Exception\LogicException; use Symfony\Component\Process\Exception\ProcessFailedException; use Symfony\Component\Process\Exception\RuntimeException; use Symfony\Component\Process\Process; +use Throwable; class Console { @@ -29,12 +31,21 @@ class Console if (static::isValidOutput($output)) { return true; } - } catch (InvalidArgumentException | LogicException | ProcessFailedException | RuntimeException $e) { + } catch (Exception | InvalidArgumentException | LogicException | ProcessFailedException | RuntimeException | Throwable $e) { $output = $e->getMessage(); } logger('Console output:: ' . $output); + return static::formatOutput($output); + } + + public static function formatOutput($output) + { + $output = nl2br($output); + $output = str_replace(['"', "'"], '', $output); + $output = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $output); + return $output; } diff --git a/bootstrap/autoload.php b/bootstrap/autoload.php index 8c7d3df97..2349d1ae3 100644 --- a/bootstrap/autoload.php +++ b/bootstrap/autoload.php @@ -5,7 +5,15 @@ define('AKAUNTING_PHP', '7.2.5'); // Check PHP version if (version_compare(PHP_VERSION, AKAUNTING_PHP, '<')) { - die('Error: Ask your hosting provider to use PHP ' . AKAUNTING_PHP . ' or higher for both HTTP and CLI.'); + $message = 'Error: Ask your hosting provider to use PHP ' . AKAUNTING_PHP . ' or higher for both HTTP and CLI.' . PHP_EOL . PHP_EOL . 'Current PHP version: ' . PHP_VERSION . PHP_EOL; + + if (defined('STDOUT')) { + fwrite(STDOUT, $message); + } else { + echo($message); + } + + die(1); } define('LARAVEL_START', microtime(true));