diff --git a/web/admin/common.php b/web/admin/common.php index f12be76..9de209c 100644 --- a/web/admin/common.php +++ b/web/admin/common.php @@ -17,9 +17,12 @@ * get/set/del memvar 从SaaS内存表中读写变量 */ -$tokenfield = "ciyadm"; -$tokensalt = "ast34h$3"; //做数据加解密时的加密因子,每个项目都不要相同。 -$logpath = PATH_ROOT . 'log/'; +$_token = array(); +$_token['type'] = 'cookie'; //cookie(更安全) 、 localstorage(兼容性好) +$_token['swapsec'] = 10; //更换JWT时间 +$_token['expsec'] = 86400; //过期退出时间 +$_token['field'] = 'ciyadm'; +$_token['salt'] = 'ast34h$3'; //做数据加解密时的加密因子,每个项目都不要相同。 function verifyfast() { $rsuser = verifyuser(); @@ -29,13 +32,14 @@ function verifyfast() { } function verifyuser() { global $db; - global $tokensalt; - global $tokenfield; - if (isset($_SERVER['HTTP_' . strtoupper($tokenfield)])) - $ciyauth = $_SERVER['HTTP_' . strtoupper($tokenfield)]; + global $_token; + if (isset($_COOKIE[$_token['field']])) + $ciyauth = $_COOKIE[$_token['field']]; + else if (isset($_SERVER['HTTP_CIYAUTH'])) + $ciyauth = $_SERVER['HTTP_CIYAUTH']; else - $ciyauth = get('_' . $tokenfield); - $auth = json_decode(encrypt($ciyauth, 'D', $tokensalt), true); + $ciyauth = get('_ciyauth'); + $auth = json_decode(encrypt($ciyauth, 'D', $_token['salt']), true); if ($auth == null) return null; $csql = new \ciy\sql('zc_online'); //弃用redis集群 @@ -47,6 +51,8 @@ function verifyuser() { return null; if ($onlinerow['sid'] != $auth['_s']) return null; + if ($onlinerow['exptimes'] < time() - $_token['expsec']) + return null; if ($onlinerow['usrchg'] == 9) { $csql = new \ciy\sql('zc_admin'); $csql->where('id', $auth['id']); @@ -57,18 +63,27 @@ function verifyuser() { return null; } if ($onlinerow['usrchg'] == 2) { - header($tokenfield . 're: true'); + header('_re: true'); } if ($onlinerow['exptimes'] > time()) return $auth; - $exp = time() + 86400; + $exp = time() + $_token['swapsec']; $sid = randstr(10); $auth['_s'] = $sid; if ($db->execute('update zc_online set exptimes=?,sid=? where id=?', array($exp, $sid, $auth['_o'])) === false) return null; $authstr = json_encode($auth, JSON_PARTIAL_OUTPUT_ON_ERROR); - $enauth = encrypt($authstr, 'E', $tokensalt); - header($tokenfield . ': ' . $enauth); + $enauth = encrypt($authstr, 'E', $_token['salt']); + + if ($_token['type'] == 'cookie') { + $headercookie = 'Set-Cookie: ' . $_token['field'] . '=' . $enauth . '; expires=' . gmdate('D, d-M-Y H:i:s T', time() + $_token['swapsec'] + $_token['expsec']) . '; path=/; httponly'; + if (ishttps()) + $headercookie .= '; SameSite=None; Secure'; + header($headercookie); //Cookie方式,安全性好 + } else { + $_token['__ciyauth'] = $enauth; //Localstorage方式,兼容性更好 + //header('_ciyauth: ' . $enauth); + } return $auth; } //true无权限,false有权限 @@ -81,7 +96,7 @@ function nopower($db, $userid, $chkpower) { return true; if (strlen($chkpower) < 3) return true; - if($userid == 10) + if ($userid == 10) return false; $pows = explode('.', $mepower); foreach ($pows as $p) { @@ -216,10 +231,10 @@ function delmemvar($db, $types) { function addcats($cat, $val) { $cats = explode(',', $cat); - $cats = array_filter($cats, function($value) { + $cats = array_filter($cats, function ($value) { return !empty($value); }); if (!in_array($val, $cats)) - $cats[] = $val; + $cats[] = $val; return ',' . implode(',', $cats) . ','; } diff --git a/web/admin/demo/demo_css.html b/web/admin/demo/demo_css.html index 37e8450..99eb8fa 100644 --- a/web/admin/demo/demo_css.html +++ b/web/admin/demo/demo_css.html @@ -139,13 +139,12 @@ fieldset/legend box tips
原子css
txt-sm/smm/smmm txt-lg/lgg/lggg txt-left/center/right/just -txt-wb 加粗 txt-wl 细线 txt-un 下划线 txt-un-hover 悬停下划线 +txt-wb 加粗 txt-wl 细线 txt-un 下划线 txt[1-9] bg[1-9] px[1-4] py[1-4] r[1-5] cursor-p/d txt-nowrap txt-over flex flex-center flex-top flex1 flexnone -auto-w auto-wmin -hide noselect tran5 tran1 +hide noselect tran5 sta abs fix rel sti r0 l0 t0 b0 r1 l1 t1 b1diff --git a/web/admin/index.html b/web/admin/index.html index 64f2f88..4fc1559 100644 --- a/web/admin/index.html +++ b/web/admin/index.html @@ -586,10 +586,6 @@ html += '