parent
af92f3d70a
commit
ea6b9a4ebb
6 changed files with 729 additions and 769 deletions
|
@ -18,11 +18,16 @@ class UpgradeController extends Controller
|
|||
*/
|
||||
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 {
|
||||
$json = $this->getApiJson();
|
||||
} catch (\RuntimeException $e) {
|
||||
$jsonResponse['message'] = $e->getMessage();
|
||||
return $response->withJson($jsonResponse, 503);
|
||||
$this->session->alert($e->getMessage(), 'danger');
|
||||
return redirect($response, 'system');
|
||||
}
|
||||
|
||||
if (version_compare($json[0]->tag_name, PLATFORM_VERSION, '<=')) {
|
||||
|
@ -42,21 +47,34 @@ class UpgradeController extends Controller
|
|||
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->open($tmpFile);
|
||||
|
||||
|
||||
for ($i = 0; $i < $updateZip->numFiles; $i++) {
|
||||
$nameIndex = $updateZip->getNameIndex($i);
|
||||
if (is_dir(BASE_DIR . $nameIndex)) {
|
||||
continue;
|
||||
|
||||
$updateZip->extractTo(BASE_DIR, $nameIndex);
|
||||
|
||||
if (($key = array_search(rtrim(BASE_DIR . $nameIndex, '/'), $currentFiles)) !== false) {
|
||||
unset($currentFiles[$key]);
|
||||
}
|
||||
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);
|
||||
}
|
||||
print_r($updateZip->getNameIndex($i) . '<br>');
|
||||
}
|
||||
|
||||
foreach ($currentFiles as $extraneous) {
|
||||
unlink($extraneous);
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
|
@ -259,4 +259,21 @@ if (!function_exists('queryParams')) {
|
|||
|
||||
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
|
||||
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);
|
||||
|
||||
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>{{ lang('username') }}</th>
|
||||
<th>{{ lang('user_code') }}</th>
|
||||
<th>{{ lang('token') }}</th>
|
||||
<th>{{ lang('active') }}</th>
|
||||
<th>{{ lang('admin') }}</th>
|
||||
<th>{{ lang('reg_date') }}</th>
|
||||
|
@ -35,9 +34,6 @@
|
|||
<td>
|
||||
<pre>{{ user.user_code|default(lang('none')) }}</pre>
|
||||
</td>
|
||||
<td>
|
||||
<pre>{{ user.token|default(lang('none')) }}</pre>
|
||||
</td>
|
||||
<td>
|
||||
{% if user.active %}
|
||||
<span class="badge badge-success"><i class="fas fa-check"></i></span>
|
||||
|
|
Loading…
Add table
Reference in a new issue