fix table prefix at installation
This commit is contained in:
parent
7b0dc771ba
commit
d24bd761b8
@ -47,7 +47,7 @@ class Config
|
||||
$tables = ['users', 'closets', 'players', 'textures', 'options'];
|
||||
|
||||
foreach ($tables as $table_name) {
|
||||
$table_name = $config['prefix'].$table_name;
|
||||
// prefix will be added automatically
|
||||
if (!Schema::hasTable($table_name)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -4,9 +4,14 @@ namespace App\Services;
|
||||
|
||||
class Migration
|
||||
{
|
||||
public static function creatTables($prefix = "")
|
||||
/**
|
||||
* Create tables, prefix will be added automatically
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function creatTables()
|
||||
{
|
||||
Schema::create($prefix.'users', function($table) {
|
||||
Schema::create('users', function($table) {
|
||||
$table->increments('uid');
|
||||
$table->string('email', 100);
|
||||
$table->string('nickname', 50);
|
||||
@ -19,12 +24,12 @@ class Migration
|
||||
$table->dateTime('register_at');
|
||||
});
|
||||
|
||||
Schema::create($prefix.'closets', function($table) {
|
||||
Schema::create('closets', function($table) {
|
||||
$table->increments('uid');
|
||||
$table->longText('textures');
|
||||
});
|
||||
|
||||
Schema::create($prefix.'players', function($table) {
|
||||
Schema::create('players', function($table) {
|
||||
$table->increments('pid');
|
||||
$table->integer('uid');
|
||||
$table->string('player_name', 50);
|
||||
@ -35,7 +40,7 @@ class Migration
|
||||
$table->dateTime('last_modified');
|
||||
});
|
||||
|
||||
Schema::create($prefix.'textures', function($table) {
|
||||
Schema::create('textures', function($table) {
|
||||
$table->increments('tid');
|
||||
$table->string('name', 50);
|
||||
$table->string('type', 10);
|
||||
@ -47,7 +52,7 @@ class Migration
|
||||
$table->dateTime('upload_at');
|
||||
});
|
||||
|
||||
Schema::create($prefix.'options', function($table) {
|
||||
Schema::create('options', function($table) {
|
||||
$table->increments('id');
|
||||
$table->string('option_name', 50);
|
||||
$table->longText('option_value');
|
||||
|
@ -9,17 +9,12 @@ define('BASE_DIR', dirname(dirname(__FILE__)));
|
||||
// Register Composer Auto Loader
|
||||
require BASE_DIR.'/vendor/autoload.php';
|
||||
|
||||
// Load Aliases
|
||||
// Boot Services
|
||||
App\Services\Boot::loadServices();
|
||||
|
||||
// Check Runtime Environment
|
||||
Boot::checkRuntimeEnv();
|
||||
|
||||
// Load dotenv Configuration
|
||||
Boot::loadDotEnv(BASE_DIR);
|
||||
|
||||
// Register Error Handler
|
||||
Boot::registerErrorHandler();
|
||||
Boot::startSession();
|
||||
|
||||
$db_config = Config::getDbConfig();
|
||||
|
||||
@ -28,8 +23,6 @@ if (Config::checkDbConfig($db_config)) {
|
||||
Boot::bootEloquent($db_config);
|
||||
}
|
||||
|
||||
Boot::startSession();
|
||||
|
||||
// If already installed
|
||||
if (Config::checkTableExist($db_config)) {
|
||||
View::show('setup.locked');
|
||||
@ -72,39 +65,27 @@ switch ($step) {
|
||||
} else {
|
||||
Http::redirect('index.php?step=2', '邮箱格式不正确。');
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Http::redirect('index.php?step=2', '表单信息不完整。');
|
||||
}
|
||||
|
||||
// create tables
|
||||
Migration::creatTables($db_config['prefix']);
|
||||
|
||||
$options = [
|
||||
'site_url' => Http::getBaseUrl(),
|
||||
'site_name' => $_POST['sitename'],
|
||||
'site_description' => '开源的 PHP Minecraft 皮肤站',
|
||||
'user_can_register' => '1',
|
||||
'regs_per_ip' => '3',
|
||||
'api_type' => '0',
|
||||
'announcement' => '欢迎使用 Blessing Skin Server 3.0!',
|
||||
'color_scheme' => 'skin-blue',
|
||||
'home_pic_url' => './assets/images/bg.jpg',
|
||||
'current_version' => '3.0-beta',
|
||||
'custom_css' => '',
|
||||
'custom_js' => '',
|
||||
'update_url' => 'https://work.prinzeugen.net/update.json',
|
||||
'allow_chinese_playername' => '1',
|
||||
'show_footer_copyright' => '1',
|
||||
'comment_script' => '',
|
||||
'user_initial_score' => '1000',
|
||||
'sign_gap_time' => '24'
|
||||
];
|
||||
// import options
|
||||
$options = require "options.php";
|
||||
$options['site_name'] = $_POST['sitename'];
|
||||
$options['site_url'] = Http::getBaseUrl();
|
||||
|
||||
foreach ($options as $key => $value) {
|
||||
Option::add($key, $value);
|
||||
}
|
||||
|
||||
// register super admin
|
||||
$user = new App\Models\User($_POST['email']);
|
||||
$user->register($_POST['password'], Http::getRealIP());
|
||||
$user->setPermission('2');
|
||||
|
||||
if (!is_dir(BASE_DIR.'/textures/')) {
|
||||
if (!mkdir(BASE_DIR.'/textures/'))
|
||||
|
31
setup/options.php
Normal file
31
setup/options.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* @Author: printempw
|
||||
* @Date: 2016-07-29 11:53:11
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-07-29 12:06:38
|
||||
*/
|
||||
|
||||
return [
|
||||
'site_url' => '',
|
||||
'site_name' => 'Blessing Skin Server',
|
||||
'site_description' => '开源的 PHP Minecraft 皮肤站',
|
||||
'user_can_register' => '1',
|
||||
'regs_per_ip' => '3',
|
||||
'api_type' => '0',
|
||||
'announcement' => '欢迎使用 Blessing Skin Server 3.0!',
|
||||
'color_scheme' => 'skin-blue',
|
||||
'home_pic_url' => './assets/images/bg.jpg',
|
||||
'current_version' => '3.0-beta',
|
||||
'custom_css' => '',
|
||||
'custom_js' => '',
|
||||
'update_url' => 'https://work.prinzeugen.net/update.json',
|
||||
'allow_chinese_playername' => '1',
|
||||
'show_footer_copyright' => '1',
|
||||
'comment_script' => '',
|
||||
'user_initial_score' => '1000',
|
||||
'sign_gap_time' => '24',
|
||||
'sign_score' => '10,100',
|
||||
'score_per_storage' => '1',
|
||||
'score_per_player' => '100'
|
||||
];
|
Loading…
Reference in New Issue
Block a user