parent
af92f3d70a
commit
ea6b9a4ebb
|
@ -18,11 +18,16 @@ class UpgradeController extends Controller
|
||||||
*/
|
*/
|
||||||
public function upgrade(Request $request, Response $response): Response
|
public function upgrade(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
|
if (!is_writable(BASE_DIR)) {
|
||||||
|
$this->session->alert(lang('path_not_writable', BASE_DIR), 'warning');
|
||||||
|
return redirect($response, 'system');
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$json = $this->getApiJson();
|
$json = $this->getApiJson();
|
||||||
} catch (\RuntimeException $e) {
|
} catch (\RuntimeException $e) {
|
||||||
$jsonResponse['message'] = $e->getMessage();
|
$this->session->alert($e->getMessage(), 'danger');
|
||||||
return $response->withJson($jsonResponse, 503);
|
return redirect($response, 'system');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version_compare($json[0]->tag_name, PLATFORM_VERSION, '<=')) {
|
if (version_compare($json[0]->tag_name, PLATFORM_VERSION, '<=')) {
|
||||||
|
@ -42,21 +47,34 @@ class UpgradeController extends Controller
|
||||||
return redirect($response, 'system');
|
return redirect($response, 'system');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$currentFiles = array_merge(
|
||||||
|
glob_recursive(BASE_DIR . 'app/*'),
|
||||||
|
glob_recursive(BASE_DIR . 'bin/*'),
|
||||||
|
glob_recursive(BASE_DIR . 'bootstrap/*'),
|
||||||
|
glob_recursive(BASE_DIR . 'resources/templates/*'),
|
||||||
|
glob_recursive(BASE_DIR . 'resources/lang/*'),
|
||||||
|
glob_recursive(BASE_DIR . 'resources/schemas/*'),
|
||||||
|
glob_recursive(BASE_DIR . 'static/*')
|
||||||
|
);
|
||||||
|
|
||||||
|
removeDirectory(BASE_DIR . 'vendor/');
|
||||||
|
|
||||||
|
|
||||||
$updateZip = new ZipArchive();
|
$updateZip = new ZipArchive();
|
||||||
$updateZip->open($tmpFile);
|
$updateZip->open($tmpFile);
|
||||||
|
|
||||||
|
|
||||||
for ($i = 0; $i < $updateZip->numFiles; $i++) {
|
for ($i = 0; $i < $updateZip->numFiles; $i++) {
|
||||||
$nameIndex = $updateZip->getNameIndex($i);
|
$nameIndex = $updateZip->getNameIndex($i);
|
||||||
if (is_dir(BASE_DIR . $nameIndex)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (file_exists(BASE_DIR . $nameIndex) && md5($updateZip->getFromIndex($i)) !== md5_file(BASE_DIR . $nameIndex)) {
|
|
||||||
$updateZip->extractTo(BASE_DIR, $nameIndex);
|
|
||||||
} elseif (!file_exists(BASE_DIR . $nameIndex)) {
|
|
||||||
$updateZip->extractTo(BASE_DIR, $nameIndex);
|
$updateZip->extractTo(BASE_DIR, $nameIndex);
|
||||||
|
|
||||||
|
if (($key = array_search(rtrim(BASE_DIR . $nameIndex, '/'), $currentFiles)) !== false) {
|
||||||
|
unset($currentFiles[$key]);
|
||||||
}
|
}
|
||||||
print_r($updateZip->getNameIndex($i) . '<br>');
|
}
|
||||||
|
|
||||||
|
foreach ($currentFiles as $extraneous) {
|
||||||
|
unlink($extraneous);
|
||||||
}
|
}
|
||||||
|
|
||||||
$updateZip->close();
|
$updateZip->close();
|
||||||
|
|
15
app/Exceptions/MaintenanceException.php
Normal file
15
app/Exceptions/MaintenanceException.php
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class MaintenanceException extends Exception
|
||||||
|
{
|
||||||
|
public function __construct(string $message = 'Under Maintenance', int $code = 503, Throwable $previous = null)
|
||||||
|
{
|
||||||
|
parent::__construct($message, $code, $previous);
|
||||||
|
}
|
||||||
|
}
|
|
@ -260,3 +260,20 @@ if (!function_exists('queryParams')) {
|
||||||
return !empty($params) ? '?' . http_build_query($params) : '';
|
return !empty($params) ? '?' . http_build_query($params) : '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!function_exists('glob_recursive')) {
|
||||||
|
/**
|
||||||
|
* Does not support flag GLOB_BRACE
|
||||||
|
* @param $pattern
|
||||||
|
* @param int $flags
|
||||||
|
* @return array|false
|
||||||
|
*/
|
||||||
|
function glob_recursive($pattern, $flags = 0)
|
||||||
|
{
|
||||||
|
$files = glob($pattern, $flags);
|
||||||
|
foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
|
||||||
|
$files = array_merge($files, glob_recursive($dir . '/' . basename($pattern), $flags));
|
||||||
|
}
|
||||||
|
return $files;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
require __DIR__ . '/vendor/autoload.php';
|
require __DIR__ . '/vendor/autoload.php';
|
||||||
|
|
||||||
define('BASE_DIR', __DIR__ . '/');
|
define('BASE_DIR', __DIR__ . DIRECTORY_SEPARATOR);
|
||||||
define('PLATFORM_VERSION', json_decode(file_get_contents('composer.json'))->version);
|
define('PLATFORM_VERSION', json_decode(file_get_contents('composer.json'))->version);
|
||||||
|
|
||||||
require 'bootstrap/app.php';
|
require 'bootstrap/app.php';
|
||||||
|
|
1420
package-lock.json
generated
1420
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -19,7 +19,6 @@
|
||||||
<th>Email</th>
|
<th>Email</th>
|
||||||
<th>{{ lang('username') }}</th>
|
<th>{{ lang('username') }}</th>
|
||||||
<th>{{ lang('user_code') }}</th>
|
<th>{{ lang('user_code') }}</th>
|
||||||
<th>{{ lang('token') }}</th>
|
|
||||||
<th>{{ lang('active') }}</th>
|
<th>{{ lang('active') }}</th>
|
||||||
<th>{{ lang('admin') }}</th>
|
<th>{{ lang('admin') }}</th>
|
||||||
<th>{{ lang('reg_date') }}</th>
|
<th>{{ lang('reg_date') }}</th>
|
||||||
|
@ -35,9 +34,6 @@
|
||||||
<td>
|
<td>
|
||||||
<pre>{{ user.user_code|default(lang('none')) }}</pre>
|
<pre>{{ user.user_code|default(lang('none')) }}</pre>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
|
||||||
<pre>{{ user.token|default(lang('none')) }}</pre>
|
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
{% if user.active %}
|
{% if user.active %}
|
||||||
<span class="badge badge-success"><i class="fas fa-check"></i></span>
|
<span class="badge badge-success"><i class="fas fa-check"></i></span>
|
||||||
|
|
Loading…
Reference in a new issue