Skip to content

Commit

Permalink
完成主体框架
Browse files Browse the repository at this point in the history
  • Loading branch information
Tokyo-Lei committed Oct 11, 2020
1 parent 378dc8b commit d2c8b5d
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 301 deletions.
14 changes: 11 additions & 3 deletions App/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand All @@ -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);
}
}

2 changes: 2 additions & 0 deletions App/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
29 changes: 24 additions & 5 deletions App/admin/controller/conn/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, "<?php\n\nreturn " . var_export($content, true) . ';');

}

public function index() {
$this->_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, "<?php\n\nreturn " . var_export($content, true) . ';');
}
saveConfig($file_path, $file_path_post);
$this->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/';
Expand Down
230 changes: 0 additions & 230 deletions App/admin/view/article/index copy.html

This file was deleted.

38 changes: 0 additions & 38 deletions App/admin/view/conn/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,44 +47,6 @@ <h3>站点设置</h3>
<hr>


<h3>数据库配置</h3>

<div class="form-group row mt-4">
<label class="col-sm-2 col-form-label">数据库类型</label>
<div class="col-sm-10">
<input type="text" class="form-control" value="{{Web_Config['database_type']}}" name="database_type">
</div>
</div>
<div class="form-group row mt-4">
<label class="col-sm-2 col-form-label">数据库名称</label>
<div class="col-sm-10">
<input type="text" class="form-control" value="{{Web_Config['database_name']}}" name="database_name">
</div>
</div>
<div class="form-group row mt-4">
<label class="col-sm-2 col-form-label">数据库地址</label>
<div class="col-sm-10">
<input type="text" class="form-control" value="{{Web_Config['server']}}" name="server">
</div>
</div>
<div class="form-group row mt-4">
<label class="col-sm-2 col-form-label">数据库账号</label>
<div class="col-sm-10">
<input type="text" class="form-control" value="{{Web_Config['username']}}" name="username">
</div>
</div>
<div class="form-group row mt-4">
<label class="col-sm-2 col-form-label">数据库密码</label>
<div class="col-sm-10">
<input type="text" class="form-control" value="{{Web_Config['password']}}" name="password">
</div>
</div>


<hr>




<h3>缓存配置</h3>

Expand Down
Loading

0 comments on commit d2c8b5d

Please sign in to comment.