Commit 564341a9 authored by wolfocde's avatar wolfocde

update

parent 58ae7c14
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label required">分类</label> <label class="layui-form-label required">分类</label>
<div class="layui-input-block"> <div class="layui-input-block">
<select class="layui-select" name="c_id"> <select class="layui-select" name="category_id">
{volist name='category' id='vo'} {volist name='category' id='vo'}
<option value="{$key}">{$vo}</option> <option value="{$key}">{$vo}</option>
{/volist} {/volist}
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-form-label">分类</label> <label class="layui-form-label">分类</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<select class="layui-select" name="c_id" data-search-op="="> <select class="layui-select" name="category_id" data-search-op="=">
<option value="">- 全部 -</option> <option value="">- 全部 -</option>
{volist name='category' id='vo'} {volist name='category' id='vo'}
<option value="{$key}">{$vo}</option> <option value="{$key}">{$vo}</option>
...@@ -88,9 +88,9 @@ ...@@ -88,9 +88,9 @@
{field: 'id', width: 80, title: 'ID'}, {field: 'id', width: 80, title: 'ID'},
{field: 'title', minWidth: 200, title: '标题'}, {field: 'title', minWidth: 200, title: '标题'},
{ {
field: 'c_id', minWidth: 100, title: '分类', templet: function (res) { field: 'category_id', minWidth: 100, title: '分类', templet: function (res) {
let category = JSON.parse(category_json) let category = JSON.parse(category_json)
return category[res.c_id] return category[res.category_id]
} }
}, },
{ {
......
...@@ -20,7 +20,7 @@ class BlogBase ...@@ -20,7 +20,7 @@ class BlogBase
$template = $controller . '/' . $action; $template = $controller . '/' . $action;
$category = Category::getColumn(['status' => 1], 'title', 'id', 'sort desc,id asc'); $category = Category::getColumn(['status' => 1], 'title', 'id', 'sort desc,id asc');
$map[] = ['status', '=', 1]; $map[] = ['status', '=', 1];
$popular_list = Article::getList($map, 'id,title,img,desc,c_time,article_date,c_id', 'click desc,id desc', 1, 10); $popular_list = Article::getList($map, 'id,title,img,desc,c_time,article_date,category_id', 'click desc,id desc', 1, 10);
$assign = $assign + compact('category', 'controller', 'action', 'popular_list'); $assign = $assign + compact('category', 'controller', 'action', 'popular_list');
return view($template, $assign); return view($template, $assign);
} }
......
...@@ -19,8 +19,8 @@ class Category extends BlogBase ...@@ -19,8 +19,8 @@ class Category extends BlogBase
if (empty($categoryInfo)) return $this->jump404(); if (empty($categoryInfo)) return $this->jump404();
$limit = 10; $limit = 10;
$where[] = ['status', '=', 1]; $where[] = ['status', '=', 1];
$where[] = ['c_id', '=', $id]; $where[] = ['category_id', '=', $id];
$list = Article::getList($where, 'id,title,img,desc,c_time,article_date,c_id', 'id desc', $page, $limit); $list = Article::getList($where, 'id,title,img,desc,c_time,article_date,category_id', 'id desc', $page, $limit);
if (empty($list)) return redirect("/category/{$id}/"); if (empty($list)) return redirect("/category/{$id}/");
$paginator = new Paginator(Article::getCount($where), $limit, $page, "/category/{$id}/page/(:num)/"); $paginator = new Paginator(Article::getCount($where), $limit, $page, "/category/{$id}/page/(:num)/");
$paginator->setPreviousText('上页'); $paginator->setPreviousText('上页');
......
...@@ -15,7 +15,7 @@ class Index extends BlogBase ...@@ -15,7 +15,7 @@ class Index extends BlogBase
{ {
$limit = 10; $limit = 10;
$where[] = ['status', '=', 1]; $where[] = ['status', '=', 1];
$list = Article::getList($where, 'id,title,img,desc,c_time,article_date,c_id', 'article_date desc,id desc', $page, $limit); $list = Article::getList($where, 'id,title,img,desc,c_time,article_date,category_id', 'article_date desc,id desc', $page, $limit);
if (empty($list)) return redirect('/'); if (empty($list)) return redirect('/');
$banner = Banner::getList($where, 'id,title,img,link,target,desc', 'id desc', 1, 10); $banner = Banner::getList($where, 'id,title,img,link,target,desc', 'id desc', 1, 10);
$paginator = new Paginator(Article::getCount($where), $limit, $page, '/page/(:num)/'); $paginator = new Paginator(Article::getCount($where), $limit, $page, '/page/(:num)/');
......
...@@ -14,13 +14,13 @@ class Info extends BlogBase ...@@ -14,13 +14,13 @@ class Info extends BlogBase
if (empty($id)) return $this->jump404(); if (empty($id)) return $this->jump404();
$where[] = ['status', '=', 1]; $where[] = ['status', '=', 1];
$where[] = ['id', '=', $id]; $where[] = ['id', '=', $id];
$info = Article::getOne($where, 'id,title,img,desc,c_time,article_date,c_id,content,click'); $info = Article::getOne($where, 'id,title,img,desc,c_time,article_date,category_id,content,click');
if (empty($info)) return $this->jump404(); if (empty($info)) return $this->jump404();
Article::incClick($id); // 增加 点击 次数 Article::incClick($id); // 增加 点击 次数
$map[] = ['status', '=', 1]; $map[] = ['status', '=', 1];
$map[] = ['id', '<>', $id]; $map[] = ['id', '<>', $id];
$map[] = ['c_id', '=', $info['c_id']]; $map[] = ['category_id', '=', $info['category_id']];
$more = Article::getList($map, 'id,title,img,desc,c_time,article_date,c_id', 'article_date desc,id desc', 1, 6); $more = Article::getList($map, 'id,title,img,desc,c_time,article_date,category_id', 'article_date desc,id desc', 1, 6);
return $this->blog_tpl(compact('info', 'more')); return $this->blog_tpl(compact('info', 'more'));
} }
......
...@@ -15,71 +15,66 @@ class InstallCheck implements MiddlewareInterface ...@@ -15,71 +15,66 @@ class InstallCheck implements MiddlewareInterface
{ {
public function process(Request $request, callable $handler): Response public function process(Request $request, callable $handler): Response
{ {
$base_path = base_path() . DIRECTORY_SEPARATOR . 'extend' . DIRECTORY_SEPARATOR;
$lock_file = $base_path . 'install.lock';
if (file_exists($lock_file)) {
return $handler($request); return $handler($request);
// $base_path = base_path() . DIRECTORY_SEPARATOR . 'extend' . DIRECTORY_SEPARATOR; }
// $lock_file = $base_path . 'install.lock'; if (version_compare(PHP_VERSION, '7.4.0', '<')) {
// if (file_exists($lock_file)) { $errorMsg = "PHP版本需要7.4或者以上,推荐8.1+";
// return $handler($request); return response($errorMsg, 400);
// } }
// if (version_compare(PHP_VERSION, '7.1.0', '<')) { $db_base_data = $base_path . 'database.sql';
// $errorMsg = "PHP版本需要7.4或者以上,推荐8.1+"; $sql_data = $base_path . 'sqldata.sql';
// return response($errorMsg, 400); if (file_exists($db_base_data) === false) {
// } $errorMsg = "数据库基础获取异常,请确认{$db_base_data}文件是否存在";
// $db_base_data = $base_path . 'database.sql'; return response($errorMsg, 400);
// $sql_data = $base_path . 'my_blog.sql'; }
// if (file_exists($db_base_data) === false) { if (file_exists($sql_data) === false) {
// $errorMsg = "数据库基础获取异常,请确认{$db_base_data}文件是否存在"; $errorMsg = "数据库基础获取异常,请确认{$sql_data}文件是否存在";
// return response($errorMsg, 400); return response($errorMsg, 400);
// } }
// if (file_exists($sql_data) === false) { $dbHost = env('db_host');
// $errorMsg = "数据库基础获取异常,请确认{$sql_data}文件是否存在"; $dbUser = env('db_username');
// return response($errorMsg, 400); $dbPwd = env('db_password');
// } $dbPort = env('db_port');
// $dbHost = env('db_host'); $dbCharset = env('db_charset');
// $dbUser = env('db_username'); $dbName = env('db_database');
// $dbPwd = env('db_password'); try {
// $dbPort = env('db_port'); $conn = mysqli_connect($dbHost, $dbUser, $dbPwd, null, $dbPort);
// $dbCharset = env('db_charset'); mysqli_query($conn, "SET NAMES {$dbCharset}");
// $dbName = env('db_database'); $initDb = mysqli_select_db($conn, $dbName);
// try { if (!$initDb) {
// $conn = mysqli_connect($dbHost, $dbUser, $dbPwd, null, $dbPort); if (!mysqli_query($conn, "CREATE DATABASE IF NOT EXISTS `{$dbName}` DEFAULT CHARACTER SET {$dbCharset};")) {
// mysqli_query($conn, "SET NAMES {$dbCharset}"); $errorMsg = "数据库{$dbName} 不存在,也没权限创建新的数据库!";
// $initDb = mysqli_select_db($conn, $dbName); mysqli_close($conn);
// if (!$initDb) { return response($errorMsg, 400);
// if (!mysqli_query($conn, "CREATE DATABASE IF NOT EXISTS `{$dbName}` DEFAULT CHARACTER SET {$dbCharset};")) { }
// $errorMsg = "数据库{$dbName} 不存在,也没权限创建新的数据库!"; }
// mysqli_close($conn); // 先建表
// return response($errorMsg, 400); $db_data = file_get_contents($db_base_data);
// } $sqlFormat = sql_split($db_data);
// } $counts = count($sqlFormat);
// // 先建表 mysqli_select_db($conn, $dbName);
// $db_data = file_get_contents($db_base_data); for ($index = 0; $index < $counts; $index++) {
// $sqlFormat = sql_split($db_data); $sql = trim($sqlFormat[$index]);
// $counts = count($sqlFormat); if (strstr($sql, 'CREATE TABLE')) {
// mysqli_select_db($conn, $dbName); mysqli_query($conn, $sql);
// for ($index = 0; $index < $counts; $index++) { }
// $sql = trim($sqlFormat[$index]); $index++;
// if (strstr($sql, 'CREATE TABLE')) { }
// mysqli_query($conn, $sql); $sql2 = file_get_contents($sql_data);
// } $exp = array_filter(explode('INSERT INTO', ($sql2)));
// $index++; foreach ($exp as $value) {
// } $query_sql = 'INSERT INTO ' . htmlspecialchars_decode($value);
mysqli_query($conn, $query_sql);
}
mysqli_close($conn);
// @touch($base_path . 'install.lock'); // @touch($base_path . 'install.lock');
// // $sql = file_get_contents($sql_data); return $handler($request);
// // if (!mysqli_select_db($conn, $dbName)) { } catch (\Exception $e) {
// // $errorMsg = "数据表{$dbName}不存在!"; $errorMsg = "连接 MySQL 失败: " . mysqli_connect_error() . $e->getMessage();
// // return response($errorMsg, 400); return response($errorMsg, 400);
// // } }
// // $exp = array_filter(explode('INSERT INTO', ($sql)));
// // foreach ($exp as $value) {
// // $query_sql = 'INSERT INTO ' . htmlspecialchars_decode($value);
// // mysqli_query($conn, $query_sql);
// // }
// return $handler($request);
// } catch (\Exception $e) {
// $errorMsg = "连接 MySQL 失败: " . mysqli_connect_error() . $e->getMessage();
// return response($errorMsg, 400);
// }
} }
} }
\ No newline at end of file
...@@ -18,7 +18,7 @@ class Article extends Model ...@@ -18,7 +18,7 @@ class Article extends Model
public function categoryInfo(): HasOne public function categoryInfo(): HasOne
{ {
return $this->hasOne(Category::class, 'id', 'c_id')->field('id,title'); return $this->hasOne(Category::class, 'id', 'category_id')->field('id,title');
} }
public static function incClick(int $id = 0, int $i = 1) public static function incClick(int $id = 0, int $i = 1)
......
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
<a href="/info/{$vo.id}/">{$vo.article_date}</a> <a href="/info/{$vo.id}/">{$vo.article_date}</a>
</div> </div>
<div class="gdlr-core-blog-info gdlr-core-blog-info-font gdlr-core-skin-caption gdlr-core-blog-info-category"> <div class="gdlr-core-blog-info gdlr-core-blog-info-font gdlr-core-skin-caption gdlr-core-blog-info-category">
<a href="/category/{$vo.c_id}/" rel="tag"> <a href="/category/{$vo.category_id}/" rel="tag">
{$category[$vo['c_id']]|default='-'} {$category[$vo['category_id']]|default='-'}
</a> </a>
</div> </div>
</div> </div>
......
...@@ -55,8 +55,8 @@ ...@@ -55,8 +55,8 @@
<a href="/info/{$vo.id}/">{$vo.article_date}</a> <a href="/info/{$vo.id}/">{$vo.article_date}</a>
</div> </div>
<div class="gdlr-core-blog-info gdlr-core-blog-info-font gdlr-core-skin-caption gdlr-core-blog-info-category"> <div class="gdlr-core-blog-info gdlr-core-blog-info-font gdlr-core-skin-caption gdlr-core-blog-info-category">
<a href="/category/{$vo.c_id}/" rel="tag"> <a href="/category/{$vo.category_id}/" rel="tag">
{$category[$vo['c_id']]|default='-'} {$category[$vo['category_id']]|default='-'}
</a> </a>
</div> </div>
</div> </div>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="gdlr-core-page-builder-body"> <div class="gdlr-core-page-builder-body">
<div class="gdlr-core-pbf-sidebar-wrapper "> <div class="gdlr-core-pbf-sidebar-wrapper ">
<div class="gdlr-core-pbf-sidebar-container gdlr-core-line-height-0 clearfix gdlr-core-js gdlr-core-container"> <div class="gdlr-core-pbf-sidebar-container gdlr-core-line-height-0 clearfix gdlr-core-js gdlr-core-container">
<div class="sitemap">当前位置:<a href="/">首页</a> &gt;<a href="/category/{$info.c_id}/">{$category[$info.c_id]|default='-'}</a> &gt; {$info.title}</div> <div class="sitemap">当前位置:<a href="/">首页</a> &gt;<a href="/category/{$info.category_id}/">{$category[$info.category_id]|default='-'}</a> &gt; {$info.title}</div>
<div class="gdlr-core-pbf-sidebar-content gdlr-core-column-40 gdlr-core-pbf-sidebar-padding gdlr-core-line-height gdlr-core-column-extend-left"> <div class="gdlr-core-pbf-sidebar-content gdlr-core-column-40 gdlr-core-pbf-sidebar-padding gdlr-core-line-height gdlr-core-column-extend-left">
<div class="gdlr-core-pbf-sidebar-content-inner" data-skin="Blog List"> <div class="gdlr-core-pbf-sidebar-content-inner" data-skin="Blog List">
<div class="gdlr-core-pbf-element"> <div class="gdlr-core-pbf-element">
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<a href="javascript:;">{$info.article_date}</a> <a href="javascript:;">{$info.article_date}</a>
</div> </div>
<div class="akea-blog-info akea-blog-info-font akea-blog-info-tag "> <div class="akea-blog-info akea-blog-info-font akea-blog-info-tag ">
<a href="/category/{$info.c_id}">{$category[$info.c_id]}</a> <a href="/category/{$info.category_id}">{$category[$info.category_id]}</a>
</div> </div>
<div class="akea-blog-info akea-blog-info-font akea-blog-info-comment-number"> <div class="akea-blog-info akea-blog-info-font akea-blog-info-comment-number">
<span class="akea-head"><i class="fa fa-clipboard"></i></span>{$info.click} <span class="akea-head"><i class="fa fa-clipboard"></i></span>{$info.click}
......
...@@ -6,7 +6,7 @@ CREATE TABLE `article` ...@@ -6,7 +6,7 @@ CREATE TABLE `article`
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(100) NOT NULL DEFAULT '', `title` varchar(100) NOT NULL DEFAULT '',
`desc` varchar(255) NOT NULL DEFAULT '', `desc` varchar(255) NOT NULL DEFAULT '',
`c_id` int(10) unsigned NOT NULL DEFAULT '0', `category_id` int(10) unsigned NOT NULL DEFAULT '0',
`img` varchar(255) NOT NULL DEFAULT '', `img` varchar(255) NOT NULL DEFAULT '',
`content` longtext, `content` longtext,
`article_date` date DEFAULT NULL, `article_date` date DEFAULT NULL,
...@@ -16,7 +16,7 @@ CREATE TABLE `article` ...@@ -16,7 +16,7 @@ CREATE TABLE `article`
`c_time` datetime DEFAULT NULL, `c_time` datetime DEFAULT NULL,
`u_time` datetime DEFAULT NULL, `u_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
KEY `c_id` (`c_id`) USING BTREE, KEY `category_id` (`category_id`) USING BTREE,
KEY `article_time` (`article_date`) USING BTREE, KEY `article_time` (`article_date`) USING BTREE,
KEY `status` (`status`) USING BTREE KEY `status` (`status`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
......
...@@ -25,7 +25,7 @@ CREATE TABLE `article` ( ...@@ -25,7 +25,7 @@ CREATE TABLE `article` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '', `title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '', `desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`c_id` int UNSIGNED NOT NULL DEFAULT 0, `category_id` int UNSIGNED NOT NULL DEFAULT 0,
`img` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '', `img` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL, `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
`article_date` date NULL DEFAULT NULL, `article_date` date NULL DEFAULT NULL,
...@@ -35,7 +35,7 @@ CREATE TABLE `article` ( ...@@ -35,7 +35,7 @@ CREATE TABLE `article` (
`c_time` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, `c_time` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`u_time` datetime NULL DEFAULT NULL, `u_time` datetime NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
INDEX `c_id`(`c_id`) USING BTREE, INDEX `category_id`(`category_id`) USING BTREE,
INDEX `article_time`(`article_date`) USING BTREE, INDEX `article_time`(`article_date`) USING BTREE,
INDEX `status`(`status`) USING BTREE INDEX `status`(`status`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; ) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment