From d1cdc517985ee6232c5352172a8fa092b16b586f Mon Sep 17 00:00:00 2001 From: Karson Date: Fri, 17 Dec 2021 16:01:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=BB=98=E8=AE=A4=E7=9A=AE?= =?UTF-8?q?=E8=82=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 改进内置服务器 优化伪静态 --- application/admin/command/Install/fastadmin.sql | 2 +- application/admin/model/User.php | 11 ++++++----- application/admin/view/index/index.html | 2 +- public/.htaccess | 2 +- public/router.php | 4 +++- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/application/admin/command/Install/fastadmin.sql b/application/admin/command/Install/fastadmin.sql index e4b6a214..8e991bcf 100755 --- a/application/admin/command/Install/fastadmin.sql +++ b/application/admin/command/Install/fastadmin.sql @@ -63,7 +63,7 @@ CREATE TABLE `fa_area` ( `shortname` varchar(100) DEFAULT NULL COMMENT '简称', `name` varchar(100) DEFAULT NULL COMMENT '名称', `mergename` varchar(255) DEFAULT NULL COMMENT '全称', - `level` tinyint(4) DEFAULT NULL COMMENT '层级 0 1 2 省市区县', + `level` tinyint(4) DEFAULT NULL COMMENT '层级:1=省,2=市,3=区/县', `pinyin` varchar(100) DEFAULT NULL COMMENT '拼音', `code` varchar(100) DEFAULT NULL COMMENT '长途区号', `zip` varchar(100) DEFAULT NULL COMMENT '邮编', diff --git a/application/admin/model/User.php b/application/admin/model/User.php index 3f883d78..4a8f0c7e 100644 --- a/application/admin/model/User.php +++ b/application/admin/model/User.php @@ -48,10 +48,10 @@ class User extends Model self::beforeUpdate(function ($row) { $changedata = $row->getChangedData(); $origin = $row->getOriginData(); - if (isset($changedata['money']) && (function_exists('bccomp') ? bccomp($changedata['money'], $origin['money'], 2) !== 0 : (double) $changedata['money'] !== (double) $origin['money'])) { + if (isset($changedata['money']) && (function_exists('bccomp') ? bccomp($changedata['money'], $origin['money'], 2) !== 0 : (double)$changedata['money'] !== (double)$origin['money'])) { MoneyLog::create(['user_id' => $row['id'], 'money' => $changedata['money'] - $origin['money'], 'before' => $origin['money'], 'after' => $changedata['money'], 'memo' => '管理员变更金额']); } - if (isset($changedata['score']) && (int) $changedata['score'] !== (int) $origin['score']) { + if (isset($changedata['score']) && (int)$changedata['score'] !== (int)$origin['score']) { ScoreLog::create(['user_id' => $row['id'], 'score' => $changedata['score'] - $origin['score'], 'before' => $origin['score'], 'after' => $changedata['score'], 'memo' => '管理员变更积分']); } }); @@ -67,21 +67,22 @@ class User extends Model return ['normal' => __('Normal'), 'hidden' => __('Hidden')]; } + public function getPrevtimeTextAttr($value, $data) { - $value = $value ? $value : $data['prevtime']; + $value = $value ? $value : ($data['prevtime'] ?? ""); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } public function getLogintimeTextAttr($value, $data) { - $value = $value ? $value : $data['logintime']; + $value = $value ? $value : ($data['logintime'] ?? ""); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } public function getJointimeTextAttr($value, $data) { - $value = $value ? $value : $data['jointime']; + $value = $value ? $value : ($data['jointime'] ?? ""); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } diff --git a/application/admin/view/index/index.html b/application/admin/view/index/index.html index 8abaa048..011b0587 100644 --- a/application/admin/view/index/index.html +++ b/application/admin/view/index/index.html @@ -4,7 +4,7 @@ {include file="common/meta" /} - +
diff --git a/public/.htaccess b/public/.htaccess index e3df0009..cbc78689 100755 --- a/public/.htaccess +++ b/public/.htaccess @@ -4,5 +4,5 @@ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1] + RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] diff --git a/public/router.php b/public/router.php index 6ba1fabf..0acec8d6 100755 --- a/public/router.php +++ b/public/router.php @@ -10,8 +10,10 @@ // +---------------------------------------------------------------------- // $Id$ -if (is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["REQUEST_URI"])) { +if (is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SCRIPT_NAME"])) { return false; } else { + $_SERVER["SCRIPT_FILENAME"] = __DIR__ . '/index.php'; + require __DIR__ . "/index.php"; }