update v 1.0.7.5
This commit is contained in:
43
app/Http/Middleware/CheckBoard.php
Normal file
43
app/Http/Middleware/CheckBoard.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use Closure;
|
||||
|
||||
/**
|
||||
* CheckBoard.
|
||||
* Checking if the system board is online or offline
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class CheckBoard {
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return type Mixed
|
||||
*/
|
||||
public function handle($request, Closure $next) {
|
||||
if ($this->checkBoard() == '1') {
|
||||
return $next($request);
|
||||
} else {
|
||||
return redirect()->route('board.offline')->with('offline', 'the system seems to be offline please try later');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the system offline details
|
||||
* @return type Mixed
|
||||
*/
|
||||
public function checkBoard() {
|
||||
$res = 0;
|
||||
$system = new System;
|
||||
if ($system->first()) {
|
||||
$res = $system->first()->status;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
125
app/Http/Middleware/CheckUpdate.php
Normal file
125
app/Http/Middleware/CheckUpdate.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Http\Controllers\Update\UpgradeController;
|
||||
use App\Http\Controllers\Utility\LibraryController as Utility;
|
||||
use App\Model\Update\BarNotification;
|
||||
use Closure;
|
||||
|
||||
class CheckUpdate
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$check = $this->process();
|
||||
//dd($check);
|
||||
if ($check == true) {
|
||||
//$this->notificationBar();
|
||||
$this->checkNewUpdate();
|
||||
if (Utility::getFileVersion() > Utility::getDatabaseVersion()) {
|
||||
return redirect('database-update');
|
||||
}
|
||||
if (Utility::getFileVersion() < Utility::getDatabaseVersion()) {
|
||||
return redirect('file-update');
|
||||
}
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
public function notificationBar()
|
||||
{
|
||||
$notify = new BarNotification();
|
||||
$path = base_path('UPDATES');
|
||||
if (is_dir($path)) {
|
||||
$notify->create(['key' => 'update-ready', 'value' => 'New version has downloaded, click <a href='.url('file-update').'>here</a> to update now']);
|
||||
}
|
||||
}
|
||||
|
||||
public function checkNewUpdate()
|
||||
{
|
||||
$notify = new BarNotification();
|
||||
if(!\Schema::hasTable('bar_notifications')){
|
||||
$url = url('database-upgrade');
|
||||
//$string = "Your Database is outdated please upgrade <a href=$url>Now !</a>";
|
||||
echo view('themes.default1.update.database', compact('url'));
|
||||
exit;
|
||||
}
|
||||
$not = $notify->get();
|
||||
if ($not->count() > 0) {
|
||||
$now = \Carbon\Carbon::now();
|
||||
$yesterday = \Carbon\Carbon::now(-24);
|
||||
$notifications = $notify->whereBetween('created_at', [$yesterday, $now])->lists('value', 'key');
|
||||
$todelete = $notify->where('created_at', '<', $yesterday)->get();
|
||||
if ($todelete->count() > 0) {
|
||||
foreach ($todelete as $delete) {
|
||||
$delete->delete();
|
||||
}
|
||||
}
|
||||
if (count($notifications) > 0) {
|
||||
if (!array_key_exists('new-version', $notifications)) {
|
||||
$check_version = $this->checkNewVersion();
|
||||
if ($check_version == true) {
|
||||
$notify->create(['key' => 'new-version', 'value' => 'new version found please click <a href='.url('file-update').'><b>here to download</b></a>']);
|
||||
}
|
||||
} else {
|
||||
$n = $notify->where('key', 'new-version')->first();
|
||||
$last = $n->created_at;
|
||||
$now = \Carbon\Carbon::now();
|
||||
$difference = $now->diffInHours($last);
|
||||
if ($difference >= 24) {
|
||||
$n->delete();
|
||||
$this->checkNewUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$check_version = $this->checkNewVersion();
|
||||
|
||||
if ($check_version == true) {
|
||||
//dd('if');
|
||||
$notify->create(['key' => 'new-version', 'value' => 'new version found please click <a href='.url('file-update').'><b>here to download</b></a>', 'created_at' => \Carbon\Carbon::now()]);
|
||||
} else {
|
||||
//dd('else');
|
||||
$notify->create(['key' => 'new-version', 'value' => '', 'created_at' => \Carbon\Carbon::now()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function checkNewVersion()
|
||||
{
|
||||
$controller = new UpgradeController();
|
||||
$version_from_billing = $controller->getLatestVersion();
|
||||
$app_version = Utility::getFileVersion();
|
||||
if ($version_from_billing > $app_version) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
$notify = new BarNotification();
|
||||
$not = $notify->get();
|
||||
if ($not->count() > 0) {
|
||||
$n = $notify->where('key', 'new-version')->first();
|
||||
|
||||
if ($n) {
|
||||
$now = \Carbon\Carbon::now();
|
||||
$yesterday = \Carbon\Carbon::now(-24);
|
||||
$notifications = $notify->where('key', 'new-version')->whereBetween('created_at', [$yesterday, $now])->lists('value', 'key');
|
||||
if ($notifications->count() > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
17
app/Http/Middleware/EncryptCookies.php
Normal file
17
app/Http/Middleware/EncryptCookies.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;
|
||||
|
||||
class EncryptCookies extends BaseEncrypter
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
@@ -4,11 +4,11 @@ namespace App\Http\Middleware;
|
||||
|
||||
use Cache;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Routing\Middleware;
|
||||
// use Illuminate\Contracts\Routing\Middleware;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class LanguageMiddleware implements Middleware
|
||||
class LanguageMiddleware
|
||||
{
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
|
@@ -4,7 +4,6 @@ namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
@@ -38,7 +37,7 @@ class RedirectIfAuthenticated
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->check()) {
|
||||
return new RedirectResponse(url('dashboard'));
|
||||
return redirect(url('dashboard'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
Reference in New Issue
Block a user