Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
webman-blog
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
魏洲
webman-blog
Commits
15dcf008
Commit
15dcf008
authored
May 16, 2022
by
wolfocde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
bfbcdef1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
1 deletion
+97
-1
InstallCheck.php
app/middleware/InstallCheck.php
+16
-1
database.sql
extend/database.sql
+81
-0
sqldata.sql
extend/sqldata.sql
+0
-0
No files found.
app/middleware/InstallCheck.php
View file @
15dcf008
...
...
@@ -15,7 +15,9 @@ class InstallCheck implements MiddlewareInterface
{
public
function
process
(
Request
$request
,
callable
$handler
)
:
Response
{
$lock_file
=
base_path
()
.
DIRECTORY_SEPARATOR
.
'extend'
.
DIRECTORY_SEPARATOR
.
'install.lock'
;
$base_path
=
base_path
()
.
DIRECTORY_SEPARATOR
.
'extend'
.
DIRECTORY_SEPARATOR
;
$lock_file
=
$base_path
.
'install.lock'
;
$sql_data
=
$base_path
.
'm_blog.sql'
;
if
(
!
file_exists
(
$lock_file
))
{
$dbHost
=
env
(
'db_host'
);
$dbUser
=
env
(
'db_username'
);
...
...
@@ -33,6 +35,19 @@ class InstallCheck implements MiddlewareInterface
return
response
(
$errorMsg
,
400
);
}
}
if
(
file_exists
(
$sql_data
))
{
$sql
=
file_get_contents
(
$sql_data
);
if
(
!
mysqli_select_db
(
$conn
,
$dbName
))
{
$errorMsg
=
"数据表
{
$dbName
}
不存在!"
;
return
response
(
$errorMsg
,
400
);
}
$exp
=
array_filter
(
explode
(
'INSERT INTO'
,
(
$sql
)));
foreach
(
$exp
as
$key
=>
$value
)
{
$query_sql
=
'INSERT INTO '
.
htmlspecialchars_decode
(
$value
);
$result
=
mysqli_query
(
$conn
,
$query_sql
);
}
mysqli_close
(
$conn
);
}
}
catch
(
\Exception
$e
)
{
$errorMsg
=
"连接 MySQL 失败: "
.
mysqli_connect_error
()
.
$e
->
getMessage
();
return
response
(
$errorMsg
,
400
);
...
...
extend/database.sql
0 → 100644
View file @
15dcf008
SET
FOREIGN_KEY_CHECKS
=
0
;
DROP
TABLE
IF
EXISTS
`article`
;
CREATE
TABLE
`article`
(
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`title`
varchar
(
100
)
NOT
NULL
DEFAULT
''
,
`desc`
varchar
(
255
)
NOT
NULL
DEFAULT
''
,
`c_id`
int
(
10
)
unsigned
NOT
NULL
DEFAULT
'0'
,
`img`
varchar
(
255
)
NOT
NULL
DEFAULT
''
,
`content`
longtext
,
`article_date`
date
DEFAULT
NULL
,
`click`
int
(
10
)
unsigned
NOT
NULL
DEFAULT
'0'
,
`status`
tinyint
(
3
)
unsigned
NOT
NULL
DEFAULT
'1'
,
`sort`
int
(
10
)
unsigned
NOT
NULL
DEFAULT
'0'
,
`c_time`
datetime
DEFAULT
NULL
,
`u_time`
datetime
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
,
KEY
`c_id`
(
`c_id`
)
USING
BTREE
,
KEY
`article_time`
(
`article_date`
)
USING
BTREE
,
KEY
`status`
(
`status`
)
USING
BTREE
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
;
DROP
TABLE
IF
EXISTS
`banner`
;
CREATE
TABLE
`banner`
(
`id`
int
(
10
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`title`
varchar
(
75
)
NOT
NULL
DEFAULT
''
,
`link`
varchar
(
255
)
NOT
NULL
DEFAULT
''
,
`target`
tinyint
(
3
)
unsigned
NOT
NULL
DEFAULT
'0'
,
`desc`
varchar
(
255
)
NOT
NULL
DEFAULT
''
,
`img`
varchar
(
255
)
NOT
NULL
DEFAULT
''
,
`status`
tinyint
(
3
)
unsigned
NOT
NULL
DEFAULT
'1'
,
`c_time`
datetime
DEFAULT
NULL
,
`u_time`
datetime
DEFAULT
NULL
,
`sort`
int
(
10
)
unsigned
NOT
NULL
DEFAULT
'0'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
,
KEY
`type`
(
`target`
)
USING
BTREE
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
;
DROP
TABLE
IF
EXISTS
`category`
;
CREATE
TABLE
`category`
(
`id`
int
(
10
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`title`
varchar
(
30
)
NOT
NULL
DEFAULT
''
,
`status`
tinyint
(
3
)
unsigned
NOT
NULL
DEFAULT
'1'
,
`c_time`
datetime
DEFAULT
NULL
,
`u_time`
datetime
DEFAULT
NULL
,
`sort`
int
(
10
)
unsigned
NOT
NULL
DEFAULT
'0'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
,
KEY
`status`
(
`status`
)
USING
BTREE
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
;
DROP
TABLE
IF
EXISTS
`options`
;
CREATE
TABLE
`options`
(
`id`
int
(
10
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`type`
varchar
(
30
)
NOT
NULL
DEFAULT
''
,
`content`
json
DEFAULT
NULL
,
`status`
tinyint
(
3
)
unsigned
NOT
NULL
DEFAULT
'1'
,
`c_time`
datetime
DEFAULT
NULL
,
`u_time`
datetime
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
,
UNIQUE
KEY
`type`
(
`type`
)
USING
BTREE
,
KEY
`status`
(
`status`
)
USING
BTREE
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
;
DROP
TABLE
IF
EXISTS
`system_admin`
;
CREATE
TABLE
`system_admin`
(
`id`
int
(
10
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`username`
varchar
(
64
)
NOT
NULL
DEFAULT
''
,
`password`
varchar
(
125
)
NOT
NULL
DEFAULT
''
,
`salt`
char
(
6
)
NOT
NULL
DEFAULT
''
,
`date_v`
date
DEFAULT
NULL
,
`status`
tinyint
(
3
)
unsigned
NOT
NULL
DEFAULT
'1'
,
`c_time`
datetime
DEFAULT
NULL
,
`u_time`
datetime
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
,
UNIQUE
KEY
`username`
(
`username`
)
USING
BTREE
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
;
\ No newline at end of file
extend/sqldata.sql
0 → 100644
View file @
15dcf008
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment