diff --git a/App/Bootstrap.php b/App/Bootstrap.php index 10caa03..a809125 100644 --- a/App/Bootstrap.php +++ b/App/Bootstrap.php @@ -34,6 +34,15 @@ public static function Web_Config($key = null) { } return self::$app; } + public static function sql_Config($key = null) { + if (self::$app == null) { + self::$app = require APP_PATH . 'config/Mysql.php'; + } + if (!is_null($key)) { + return array_key_exists($key, self::$app) ? self::$app[$key] : null; + } + return self::$app; + } public static function Run() { $baseUrl = ''; $baseDir = str_replace(basename($_SERVER['SCRIPT_NAME']) , '', $_SERVER['SCRIPT_NAME']); @@ -45,8 +54,7 @@ public static function Run() { require APP_PATH . 'Router.php'; } public static function _Medoo() { - require APP_PATH . 'Config/Mysql.php'; - return $_DB = New medoo($Config['DB']); + $key = require APP_PATH . 'Config/Mysql.php'; + return $_DB = New medoo($key); } } - diff --git a/App/Router.php b/App/Router.php index c4df5fa..429166c 100644 --- a/App/Router.php +++ b/App/Router.php @@ -26,7 +26,9 @@ Route::get('/'.$admin.'/article', 'App\admin\controller\index\ArticleController@index'); Route::post('/'.$admin.'/upload', 'App\admin\controller\index\ArticleController@upload'); Route::get('/'.$admin.'/config', 'App\admin\controller\conn\ConfigController@index'); +Route::get('/'.$admin.'/sql', 'App\admin\controller\conn\ConfigController@sql'); Route::post('/'.$admin.'/config_update', 'App\admin\controller\conn\ConfigController@update'); +Route::post('/'.$admin.'/config_sql', 'App\admin\controller\conn\ConfigController@update_sql'); Route::get('/'.$admin.'/cache', 'App\admin\controller\conn\ConfigController@cache'); Route::dispatch(); diff --git a/App/admin/controller/conn/ConfigController.php b/App/admin/controller/conn/ConfigController.php index 4bf4465..2fff774 100644 --- a/App/admin/controller/conn/ConfigController.php +++ b/App/admin/controller/conn/ConfigController.php @@ -4,23 +4,42 @@ use App\Bootstrap; use File; class ConfigController extends CommonController { - public function index() { + + private function _session(){ if (!isset($_SESSION['session_name'])) { header('Location:' . '/admin/login'); exit; } + } + private function saveConfig($filename, $content){ + file_put_contents($filename, "_session(); echo $this->render('conn/index.html', ['PUBLIC_ADMIN' => PUBLIC_ADMIN, 'Web_Config' => Bootstrap::Web_Config() ]); } + public function sql() { + $this->_session(); + echo $this->render('conn/sql.html', ['PUBLIC_ADMIN' => PUBLIC_ADMIN, 'sql_Config' => Bootstrap::sql_Config() ]); + } public function update() { $file_path = ROOT_PATH . '/App/config/Webconfig.php'; $file_path_post = str_replace(" ", '', $_POST); - function saveConfig($filename, $content) { - file_put_contents($filename, "saveConfig($file_path, $file_path_post); header('Location:' . '/admin/config'); exit; } + public function update_sql() { + $file_path = ROOT_PATH . '/App/config/Mysql.php'; + $file_path_post = str_replace(" ", '', $_POST); + $this->saveConfig($file_path, $file_path_post); + header('Location:' . '/admin/sql'); + exit; + } + + public function cache() { $admin_cache_path = ROOT_PATH . '/App/file/cache_admin/'; $home_cache_path = ROOT_PATH . '/App/file/cache_home/'; diff --git a/App/admin/view/article/index copy.html b/App/admin/view/article/index copy.html deleted file mode 100644 index b3569fa..0000000 --- a/App/admin/view/article/index copy.html +++ /dev/null @@ -1,230 +0,0 @@ -{{ include('/include/head.html') }} -
- -
-
- 快速撰写 - -
- - - We'll never share your email with anyone else. -
-
- - -
-
- - -
-
- - -
-
- -
-
- - - This is some placeholder block-level help text for the above input. It's a bit lighter and easily wraps to a new line. -
- - - -
-
- -
- - -{{ include('include/js.html') }} - - - - -{{ include('include/footer.html') }} \ No newline at end of file diff --git a/App/admin/view/conn/index.html b/App/admin/view/conn/index.html index 9681d61..d709290 100644 --- a/App/admin/view/conn/index.html +++ b/App/admin/view/conn/index.html @@ -47,44 +47,6 @@

站点设置


-

数据库配置

- -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- - -
- - -

缓存配置

diff --git a/App/admin/view/conn/sql.html b/App/admin/view/conn/sql.html new file mode 100644 index 0000000..ec8d40d --- /dev/null +++ b/App/admin/view/conn/sql.html @@ -0,0 +1,58 @@ +{{ include('/include/head.html') }} +
+ +
+ + + + +

数据库配置

+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + +
+ + + + +
+
+ +
+
+
+ +
+ +{{ include('include/js.html') }} +{{ include('include/footer.html') }} \ No newline at end of file diff --git a/App/admin/view/include/head.html b/App/admin/view/include/head.html index 2de7d58..ca5cc35 100644 --- a/App/admin/view/include/head.html +++ b/App/admin/view/include/head.html @@ -28,7 +28,9 @@ - +