Browse Source

安装数据库

lizhen 6 ngày trước cách đây
mục cha
commit
3ec6038244

+ 21 - 21
application/admin/command/Install.php

@@ -173,7 +173,7 @@ class Install extends Command
             throw new Exception(__('Please input correct website'));
         }
 
-        $sql = file_get_contents(INSTALL_PATH . 'fastadmin.sql');
+        $sql = file_get_contents(INSTALL_PATH . 'shequ.sql');
 
         $sql = str_replace("`fa_", "`{$mysqlPrefix}", $sql);
 
@@ -204,10 +204,10 @@ class Install extends Command
             throw new Exception($e->getMessage());
         }
         // 后台入口文件
-        $adminFile = ROOT_PATH . 'public' . DS . 'admin.php';
+//        $adminFile = ROOT_PATH . 'public' . DS . 'admin.php';
 
         // 数据库配置文件
-        $dbConfigFile = APP_PATH . 'database.php';
+        /*$dbConfigFile = APP_PATH . 'database.php';
         $dbConfigText = @file_get_contents($dbConfigFile);
         $callback = function ($matches) use ($mysqlHostname, $mysqlHostport, $mysqlUsername, $mysqlPassword, $mysqlDatabase, $mysqlPrefix) {
             $field = "mysql" . ucfirst($matches[1]);
@@ -217,16 +217,16 @@ class Install extends Command
             }
             return "'{$matches[1]}'{$matches[2]}=>{$matches[3]}Env::get('database.{$matches[1]}', '{$replace}'),";
         };
-        $dbConfigText = preg_replace_callback("/'(hostname|database|username|password|hostport|prefix)'(\s+)=>(\s+)Env::get\((.*)\)\,/", $callback, $dbConfigText);
+        $dbConfigText = preg_replace_callback("/'(hostname|database|username|password|hostport|prefix)'(\s+)=>(\s+)Env::get\((.*)\)\,/", $callback, $dbConfigText);*/
 
         // 检测能否成功写入数据库配置
-        $result = @file_put_contents($dbConfigFile, $dbConfigText);
+        /*$result = @file_put_contents($dbConfigFile, $dbConfigText);
         if (!$result) {
             throw new Exception(__('The current permissions are insufficient to write the file %s', 'application/database.php'));
-        }
+        }*/
 
         // 设置新的Token随机密钥key
-        $oldTokenKey = config('token.key');
+        /*$oldTokenKey = config('token.key');
         $newTokenKey = \fast\Random::alnum(32);
         $coreConfigFile = CONF_PATH . 'config.php';
         $coreConfigText = @file_get_contents($coreConfigFile);
@@ -237,29 +237,29 @@ class Install extends Command
             throw new Exception(__('The current permissions are insufficient to write the file %s', 'application/config.php'));
         }
 
-        $avatar = request()->domain() . '/assets/img/avatar.png';
+        $avatar = request()->domain() . '/assets/img/avatar.png';*/
         // 变更默认管理员密码
-        $adminPassword = $adminPassword ? $adminPassword : Random::alnum(8);
+        /*$adminPassword = $adminPassword ? $adminPassword : Random::alnum(8);
         $adminEmail = $adminEmail ? $adminEmail : "admin@admin.com";
         $newSalt = substr(md5(uniqid(true)), 0, 6);
         $newPassword = md5(md5($adminPassword) . $newSalt);
         $data = ['username' => $adminUsername, 'email' => $adminEmail, 'avatar' => $avatar, 'password' => $newPassword, 'salt' => $newSalt];
-        $instance->name('admin')->where('username', 'admin')->update($data);
+        $instance->name('admin')->where('username', 'admin')->update($data);*/
 
         // 变更前台默认用户的密码,随机生成
-        $newSalt = substr(md5(uniqid(true)), 0, 6);
+        /*$newSalt = substr(md5(uniqid(true)), 0, 6);
         $newPassword = md5(md5(Random::alnum(8)) . $newSalt);
-        $instance->name('user')->where('username', 'admin')->update(['avatar' => $avatar, 'password' => $newPassword, 'salt' => $newSalt]);
+        $instance->name('user')->where('username', 'admin')->update(['avatar' => $avatar, 'password' => $newPassword, 'salt' => $newSalt]);*/
 
         // 修改后台入口
-        $adminName = '';
+        /*$adminName = '';
         if (is_file($adminFile)) {
             $adminName = Random::alpha(10) . '.php';
             rename($adminFile, ROOT_PATH . 'public' . DS . $adminName);
-        }
+        }*/
 
         //修改站点名称
-        if ($siteName != config('site.name')) {
+        /*if ($siteName != config('site.name')) {
             $instance->name('config')->where('name', 'name')->update(['value' => $siteName]);
             $siteConfigFile = CONF_PATH . 'extra' . DS . 'site.php';
             $siteConfig = include $siteConfigFile;
@@ -275,23 +275,23 @@ class Install extends Command
             }
             $siteConfig['name'] = $siteName;
             file_put_contents($siteConfigFile, '<?php' . "\n\nreturn " . var_export_short($siteConfig) . ";\n");
-        }
+        }*/
 
-        $installLockFile = INSTALL_PATH . "install.lock";
+        /*$installLockFile = INSTALL_PATH . "install.lock";
         //检测能否成功写入lock文件
         $result = @file_put_contents($installLockFile, 1);
         if (!$result) {
             throw new Exception(__('The current permissions are insufficient to write the file %s', 'application/admin/command/Install/install.lock'));
-        }
+        }*/
 
-        try {
+        /*try {
             //删除安装脚本
             @unlink(ROOT_PATH . 'public' . DS . 'install.php');
         } catch (\Exception $e) {
 
-        }
+        }*/
 
-        return $adminName;
+        return 'admin.php';
     }
 
     /**

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 84 - 0
application/admin/command/Install/shequ.sql


+ 30 - 0
public/install.php

@@ -0,0 +1,30 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +----------------------------------------------------------------------
+// | Author: liu21st <liu21st@gmail.com>
+// +----------------------------------------------------------------------
+// [ 安装文件 ]
+// 建议安装完成后移除此文件
+// 定义应用目录
+define('APP_PATH', __DIR__ . '/../application/');
+
+// 加载框架引导文件
+require __DIR__ . '/../thinkphp/base.php';
+
+// 绑定到安装控制器
+\think\Route::bind('\app\admin\command\Install', 'controller');
+
+// 开启路由
+\think\App::route(true);
+
+// 设置根url
+\think\Url::root('');
+
+// 执行应用
+\think\App::run()->send();

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác