mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-11-27 05:39:55 +08:00
add pages for update
This commit is contained in:
parent
7d7432a374
commit
8b586bddf6
@ -59,6 +59,12 @@ class Boot
|
||||
if (!is_dir(BASE_DIR.'/textures/')) {
|
||||
throw new E("检测到 `textures` 文件夹已被删除,请重新运行 <a href='./setup'>安装程序</a>,或者手动放置一个。", -1, true);
|
||||
}
|
||||
|
||||
if (Application::getVersion() != @Option::get('version')) {
|
||||
Http::redirect(Http::getBaseUrl().'/setup/update.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,6 @@
|
||||
|
|
||||
*/
|
||||
return [
|
||||
'version' => '3.0.1',
|
||||
'version' => '3.0.2',
|
||||
'locale' => 'zh-cn'
|
||||
];
|
||||
|
19
resources/views/setup/updates/master.tpl
Normal file
19
resources/views/setup/updates/master.tpl
Normal file
@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<title>Blessing Skin Server 升级程序</title>
|
||||
<link rel="shortcut icon" href="../../assets/images/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../../assets/dist/css/install.css">
|
||||
</head>
|
||||
|
||||
<body class="container">
|
||||
<p id="logo"><a href="https://github.com/printempw/blessing-skin-server" tabindex="-1">Blessing Skin Server</a></p>
|
||||
|
||||
@yield('content')
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
11
resources/views/setup/updates/success.tpl
Normal file
11
resources/views/setup/updates/success.tpl
Normal file
@ -0,0 +1,11 @@
|
||||
@extends('setup.updates.master')
|
||||
|
||||
@section('content')
|
||||
<h1>升级成功</h1>
|
||||
|
||||
<p>数据库升级成功,欢迎使用 Blessing Skin Server {{ App::getVersion() }}!</p>
|
||||
|
||||
<p class="step">
|
||||
<a href="../" class="button button-large">首页</a>
|
||||
</p>
|
||||
@endsection
|
12
resources/views/setup/updates/welcome.tpl
Normal file
12
resources/views/setup/updates/welcome.tpl
Normal file
@ -0,0 +1,12 @@
|
||||
@extends('setup.updates.master')
|
||||
|
||||
@section('content')
|
||||
<h1>还差一小步</h1>
|
||||
|
||||
<p>欢迎升级至 Blessing Skin Server {{ App::getVersion() }}!</p>
|
||||
<p>我们需要升级您的数据库,点击下一步以继续。</p>
|
||||
|
||||
<p class="step">
|
||||
<a href="update.php?step=2" class="button button-large">下一步</a>
|
||||
</p>
|
||||
@endsection
|
64
setup/update.php
Normal file
64
setup/update.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Migrations Bootstrap of Blessing Skin Server
|
||||
*/
|
||||
|
||||
// Define Base Directory
|
||||
define('BASE_DIR', dirname(dirname(__FILE__)));
|
||||
|
||||
// Register Composer Auto Loader
|
||||
require BASE_DIR.'/vendor/autoload.php';
|
||||
|
||||
// Boot Services
|
||||
App\Services\Boot::loadServices();
|
||||
Config::checkPHPVersion();
|
||||
Boot::loadDotEnv(BASE_DIR);
|
||||
Boot::registerErrorHandler(new \Whoops\Handler\PrettyPageHandler);
|
||||
Boot::startSession();
|
||||
|
||||
$db_config = Config::getDbConfig();
|
||||
|
||||
// Boot Eloquent to make Schema available
|
||||
if (Config::checkDbConfig($db_config)) {
|
||||
Boot::bootEloquent($db_config);
|
||||
}
|
||||
|
||||
$step = isset($_GET['step']) ? $_GET['step'] : '1';
|
||||
|
||||
switch ($step) {
|
||||
case '1':
|
||||
View::show('setup.updates.welcome');
|
||||
break;
|
||||
|
||||
case '2':
|
||||
$resource = opendir(BASE_DIR."/setup/update_scripts/");
|
||||
$update_script_exist = false;
|
||||
while($filename = @readdir($resource)) {
|
||||
if ($filename != "." && $filename != "..") {
|
||||
preg_match('/update-(.*)-to-(.*).php/', $filename, $matches);
|
||||
|
||||
if (isset($matches[2])) {
|
||||
$update_script_exist = ($matches[2] == App::getVersion());
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
include BASE_DIR."/setup/update_scripts/$filename";
|
||||
}
|
||||
}
|
||||
closedir($resource);
|
||||
|
||||
if (!$update_script_exist) {
|
||||
// if update script is not given
|
||||
Option::set('version', App::getVersion());
|
||||
}
|
||||
|
||||
View::show('setup.updates.success');
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new App\Exceptions\E('非法参数', 1, true);
|
||||
break;
|
||||
}
|
||||
|
9
setup/update_scripts/update-3.0.1-to-3.0.2.php
Normal file
9
setup/update_scripts/update-3.0.1-to-3.0.2.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @Author: printempw
|
||||
* @Date: 2016-08-11 13:08:13
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-08-11 13:15:35
|
||||
*/
|
||||
|
||||
echo "shit";
|
Loading…
Reference in New Issue
Block a user