Skip to content

A free open source IT asset/license management system

Check for minimum PHP version in setup

snipe1a660911e7c3
diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php
index 80ec5a4c64..798d866983 100755
--- a/app/Http/Controllers/SettingsController.php
+++ b/app/Http/Controllers/SettingsController.php
@@ -1,6 +1,7 @@
<?php
namespace App\Http\Controllers;
+use App\Notifications\MailTest;
use Input;
use Lang;
use Illuminate\Http\Request;
@@ -43,7 +44,11 @@ class SettingsController extends Controller
*/
public function getSetupIndex()
{
+ $start_settings['php_version_min'] = false;
+ if (version_compare(PHP_VERSION, config('app.min_php'), '<')) {
+ return response('<center><h1>This software requires PHP version '.config('app.min_php').' or greater. This server is running '.PHP_VERSION.'. </h1><h2>Please upgrade PHP on this server and try again. </h2></center>', 500);
+ }
try {
$conn = DB::select('select 2 + 2');
@@ -69,6 +74,7 @@ class SettingsController extends Controller
$start_settings['url_config'] = url('/');
$start_settings['real_url'] = $pageURL;
+ $start_settings['php_version_min'] = true;
// Curl the .env file to make sure it's not accessible via a browser
$ch = curl_init($protocol . $host.'/.env');
@@ -80,7 +86,7 @@ class SettingsController extends Controller
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
- if ($httpcode == 404 || $httpcode == 403) {
+ if ($httpcode == 404 || $httpcode == 403 || $httpcode == 0) {
$start_settings['env_exposed'] = false;
} else {
$start_settings['env_exposed'] = true;
@@ -195,11 +201,6 @@ class SettingsController extends Controller
$data['password'] = $request->input('password');
$user->notify(new FirstAdminNotification($data));
- /*Mail::send(['text' => 'emails.firstadmin'], $data, function ($m) use ($data) {
- $m->to($data['email'], $data['first_name']);
- $m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
- $m->subject(trans('mail.your_credentials'));
- });*/
}
@@ -1092,11 +1093,14 @@ class SettingsController extends Controller
public function ajaxTestEmail()
{
try {
- Mail::send('emails.test', [], function ($m) {
- $m->to(config('mail.from.address'), config('mail.from.name'));
- $m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
- $m->subject(trans('mail.test_email'));
- });
+
+ (new User)->forceFill([
+ 'name' => config('mail.from.name'),
+ 'email' => config('mail.from.address')
+ ])->notify(new MailTest());
+
+
+
return response()->json(Helper::formatStandardApiResponse('success', null, 'Maiol sent!'));
} catch (Exception $e) {
return response()->json(Helper::formatStandardApiResponse('success', null, $e->getMessage()));
diff --git a/config/app.php b/config/app.php
index 3d66ad6a6c..d55b96eeee 100755
--- a/config/app.php
+++ b/config/app.php
@@ -195,6 +195,18 @@ return [
'lock_passwords' => env('APP_LOCKED', false),
+ /*
+ |--------------------------------------------------------------------------
+ | Minimum PHP version
+ |--------------------------------------------------------------------------
+ |
+ | Do not change this variable.
+ |
+ */
+
+ 'min_php' => '7.1.3',
+
+
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
diff --git a/resources/views/notifications/Test.blade.php b/resources/views/notifications/Test.blade.php
index a7e2be1c58..e4e479846f 100644
--- a/resources/views/notifications/Test.blade.php
+++ b/resources/views/notifications/Test.blade.php
@@ -2,10 +2,6 @@
{{ trans('mail.test_mail_text') }}
-Thanks,<br>
- @if ($snipeSettings->show_url_in_emails=='1')
- <p><a href="{{ url('/') }}">{{ $snipeSettings->site_name }}</a></p>
- @else
- <p>{{ $snipeSettings->site_name }}</p>
- @endif
+Thanks,
+Snipe-IT
@endcomponent
diff --git a/resources/views/setup/index.blade.php b/resources/views/setup/index.blade.php
index 033d2da058..83c7351302 100644
--- a/resources/views/setup/index.blade.php
+++ b/resources/views/setup/index.blade.php
@@ -20,6 +20,26 @@ Create a User ::
</tr>
</thead>
<tbody>
+ <tr {!! ($start_settings['php_version_min']) ? ' class="success"' : ' class="danger"' !!}>
+ <td>PHP</td>
+ <td>
+ @if ($start_settings['php_version_min'])
+ <i class="fa fa-check preflight-success"></i>
+ @else
+ <i class="fa fa-times preflight-error"></i>
+ @endif
+ </td>
+ <td>
+ @if ($start_settings['php_version_min'])
+ Yay!
+ @else
+ Oh no!
+ @endif
+
+ You're running PHP version {{ PHP_VERSION }}. ({{ config('app.min_php') }} or greater is required.)
+ </td>
+ </tr>
+
<tr {!! ($start_settings['url_valid']) ? ' class="success"' : ' class="danger"' !!}>
<td>URL</td>
<td>
@@ -70,7 +90,7 @@ Create a User ::
@if (!$start_settings['env_exposed'])
Sweet. It doesn't look like your <code>.env</code> file is exposed to the outside world. (You should double check this in a browser though. You don't ever want anyone able to see that file. Ever. Ever ever.) <a href="../../.env">Click here to check now</a> (This should return a file not found or forbidden error.)
@else
- Please make sure your <code>.env</code> is not readable by the outside world via web browser. You don't ever want anyone able to see that file. Ever. Ever ever. An exposed <code>.env</code> file can disclose sensitive data about your system and database. <a href="../../.env">Click here to check now</a> (This should return a file not found or forbidden error.)
+ We cannot determine if your config file is exposed to the outside world, so you will have to manually verify this. You don't ever want anyone able to see that file. Ever. Ever ever. An exposed <code>.env</code> file can disclose sensitive data about your system and database.
@endif
</td>
</tr>