From 435c7d48c9aa74d8c260a654f256181c5ac418b0 Mon Sep 17 00:00:00 2001 From: pengda <10266652509@qq.com> Date: Fri, 20 Sep 2024 10:37:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=95=E6=96=B9=E5=90=8E=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/define.php | 7 +++-- control/index.php | 27 ++++++----------- model/mFormula.php | 2 -- model/mPage.php | 2 +- model/mUser.php | 11 +++++-- view/templates/index/home.html | 2 +- view/templates/index/login.html | 64 ++++++++++++++++++++--------------------- 7 files changed, 55 insertions(+), 60 deletions(-) diff --git a/config/define.php b/config/define.php index f47dff2..8ef72c8 100644 --- a/config/define.php +++ b/config/define.php @@ -51,10 +51,13 @@ //后台账号密码缓存 define('_QR_ADMIN_USER_INFO', '_rq_admin_user_info'); - define('_QR_ADMIN_LOGIN_USER_INFO', '_rq_admin_login_user_info'); - define('ADMIN_PASSWORD_GET_EMAIL', '2115531468@qq.com'); + $GLOBALS['admin_list'] = array( + '2115531468@qq.com', +// '1225425695@qq.com', + ); + $GLOBALS['num_list'] = array( 'num' => array( '半'=>0.5, diff --git a/control/index.php b/control/index.php index 9ffb1bc..4776b25 100644 --- a/control/index.php +++ b/control/index.php @@ -10,8 +10,6 @@ include_once(SERVER_ROOT . "/model/mPage.php"); class index extends publicBase { private function _check_login() { - return array('uid' => $this->post('uid')); - $uid = $this->post('uid'); $token = $this->post('token'); if ($uid < 0 || !$token) $this->ajax_json(false, '参数错误', array('code' => CODE_LOGIN_EXIPRE)); @@ -28,7 +26,6 @@ class index extends publicBase { } public function login() { - $name = trim($this->get('name')); $password = trim($this->get('password')); @@ -44,29 +41,25 @@ class index extends publicBase { } public function home() { - $mformula = new mFormula(); - $robj = $mformula->initRedis(); - $user_info = $robj->get(_QR_ADMIN_LOGIN_USER_INFO); - $user_info = json_decode($user_info, true); - if (empty($user_info)) header('Location: /index/login'); + if ($_COOKIE['uid'] !== 0 && empty($_COOKIE['token'])) header('Location: /index/login'); - $this->view['uid'] = $user_info['uid']; - $this->view['token'] = $user_info['token']; + $this->view['uid'] = $_COOKIE['uid']; + $this->view['token'] = $_COOKIE['token']; $is_all = $this->get('is_all') + 0; $name = trim($this->get('name')); $condition = array(); - $url = "/index/home"; + $url = "/index/home/is_all/{$is_all}"; if ($name) { $condition['name'] = $name; $url .= "/name/{$name}"; } if (!$is_all) { $condition['uid'] = 0; - $url .= "/is_all/{$is_all}"; } + $mformula = new mFormula(); $total = $mformula->getFormulaTotal($condition); // 分页 @@ -89,14 +82,10 @@ class index extends publicBase { } public function formula_add() { - $mformula = new mFormula(); - $robj = $mformula->initRedis(); - $user_info = $robj->get(_QR_ADMIN_LOGIN_USER_INFO); - $user_info = json_decode($user_info, true); - if (empty($user_info)) header('Location: /index/login'); + if ($_COOKIE['uid'] !== 0 && empty($_COOKIE['token'])) header('Location: /index/login'); - $this->view['uid'] = $user_info['uid']; - $this->view['token'] = $user_info['token']; + $this->view['uid'] = $_COOKIE['uid']; + $this->view['token'] = $_COOKIE['token']; $id = $this->get('id'); if ($id) { diff --git a/model/mFormula.php b/model/mFormula.php index d7865de..36d77a5 100644 --- a/model/mFormula.php +++ b/model/mFormula.php @@ -55,8 +55,6 @@ class mFormula extends mBase { $formula_arr = $this->getFormulaHerbData($formula_ids); foreach ($data as &$da) { - //格式化日期 - $da['create_time'] = date('Y-m-d', strtotime($da['create_time'])); if (isset($formula_arr[$da['id']])) $da['formula'] = $formula_arr[$da['id']]; //原方信息 diff --git a/model/mPage.php b/model/mPage.php index 1501ee5..908a653 100644 --- a/model/mPage.php +++ b/model/mPage.php @@ -5,7 +5,7 @@ class Page extends publicBase { public $totalnum; // 总记录数[必填],例:$page->setTotalnum(100); public $page; // 当前页码[必填] public $url; // 分页URL[必填] - public $pagesize=100; // 每页记录数 + public $pagesize=50; // 每页记录数 public $viewpagenum=7; // 每页看到的页码数 public $virtualpage='...'; // 省略或跨越页码 diff --git a/model/mUser.php b/model/mUser.php index ffebb44..97af21f 100644 --- a/model/mUser.php +++ b/model/mUser.php @@ -30,7 +30,8 @@ class mUser extends mBase { } //设置登录状态 - $robj->setex(_QR_ADMIN_LOGIN_USER_INFO, 12 * 60 * 60, json_encode(array('uid' => 0, 'token' => $this->getToken(0)))); + setcookie("uid", 0, time() + 7200, '/'); + setcookie("token", $this->getToken(0), time() + 7200, '/'); return true; } @@ -38,11 +39,15 @@ class mUser extends mBase { $robj = $this->initRedis(); $user_info = $robj->get(_QR_ADMIN_USER_INFO); if (empty($user_info)) { - $email = ADMIN_PASSWORD_GET_EMAIL; + $email = $GLOBALS['admin_list']; $pass = bin2hex(openssl_random_pseudo_bytes(8)); $robj->setex(_QR_ADMIN_USER_INFO, 12 * 60 * 60, json_encode(array('name' => 'admin', 'password' => $pass))); - $this->sendMail(array($email), '医案录入后台', '新密码是:' . $pass); + $content = "后台地址:" . TCM_DOMAIN . "/index/login
"; + $content .= "用户名:admin" . "
"; + $content .= "密码:" . $pass; + + $this->sendMail($email, '医案录入后台', $content); return true; } diff --git a/view/templates/index/home.html b/view/templates/index/home.html index e339394..e562766 100644 --- a/view/templates/index/home.html +++ b/view/templates/index/home.html @@ -14,7 +14,7 @@
-
+