mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-13 17:14:10 -08:00
Check for minimum PHP version in setup
This commit is contained in:
parent
84f20b6287
commit
1a660911e7
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Notifications\MailTest;
|
||||||
use Input;
|
use Input;
|
||||||
use Lang;
|
use Lang;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
@ -43,7 +44,11 @@ class SettingsController extends Controller
|
||||||
*/
|
*/
|
||||||
public function getSetupIndex()
|
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 {
|
try {
|
||||||
$conn = DB::select('select 2 + 2');
|
$conn = DB::select('select 2 + 2');
|
||||||
|
@ -69,6 +74,7 @@ class SettingsController extends Controller
|
||||||
|
|
||||||
$start_settings['url_config'] = url('/');
|
$start_settings['url_config'] = url('/');
|
||||||
$start_settings['real_url'] = $pageURL;
|
$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
|
// Curl the .env file to make sure it's not accessible via a browser
|
||||||
$ch = curl_init($protocol . $host.'/.env');
|
$ch = curl_init($protocol . $host.'/.env');
|
||||||
|
@ -80,7 +86,7 @@ class SettingsController extends Controller
|
||||||
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
if ($httpcode == 404 || $httpcode == 403) {
|
if ($httpcode == 404 || $httpcode == 403 || $httpcode == 0) {
|
||||||
$start_settings['env_exposed'] = false;
|
$start_settings['env_exposed'] = false;
|
||||||
} else {
|
} else {
|
||||||
$start_settings['env_exposed'] = true;
|
$start_settings['env_exposed'] = true;
|
||||||
|
@ -195,11 +201,6 @@ class SettingsController extends Controller
|
||||||
$data['password'] = $request->input('password');
|
$data['password'] = $request->input('password');
|
||||||
$user->notify(new FirstAdminNotification($data));
|
$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()
|
public function ajaxTestEmail()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
Mail::send('emails.test', [], function ($m) {
|
|
||||||
$m->to(config('mail.from.address'), config('mail.from.name'));
|
(new User)->forceFill([
|
||||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
'name' => config('mail.from.name'),
|
||||||
$m->subject(trans('mail.test_email'));
|
'email' => config('mail.from.address')
|
||||||
});
|
])->notify(new MailTest());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', null, 'Maiol sent!'));
|
return response()->json(Helper::formatStandardApiResponse('success', null, 'Maiol sent!'));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', null, $e->getMessage()));
|
return response()->json(Helper::formatStandardApiResponse('success', null, $e->getMessage()));
|
||||||
|
|
|
@ -195,6 +195,18 @@ return [
|
||||||
'lock_passwords' => env('APP_LOCKED', false),
|
'lock_passwords' => env('APP_LOCKED', false),
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Minimum PHP version
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Do not change this variable.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'min_php' => '7.1.3',
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Autoloaded Service Providers
|
| Autoloaded Service Providers
|
||||||
|
|
|
@ -2,10 +2,6 @@
|
||||||
|
|
||||||
{{ trans('mail.test_mail_text') }}
|
{{ trans('mail.test_mail_text') }}
|
||||||
|
|
||||||
Thanks,<br>
|
Thanks,
|
||||||
@if ($snipeSettings->show_url_in_emails=='1')
|
Snipe-IT
|
||||||
<p><a href="{{ url('/') }}">{{ $snipeSettings->site_name }}</a></p>
|
|
||||||
@else
|
|
||||||
<p>{{ $snipeSettings->site_name }}</p>
|
|
||||||
@endif
|
|
||||||
@endcomponent
|
@endcomponent
|
||||||
|
|
|
@ -20,6 +20,26 @@ Create a User ::
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<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"' !!}>
|
<tr {!! ($start_settings['url_valid']) ? ' class="success"' : ' class="danger"' !!}>
|
||||||
<td>URL</td>
|
<td>URL</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -70,7 +90,7 @@ Create a User ::
|
||||||
@if (!$start_settings['env_exposed'])
|
@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.)
|
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
|
@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
|
@endif
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Reference in a new issue