diff --git a/admin/login.php b/admin/login.php index 353f7ab5..3c49bd36 100644 --- a/admin/login.php +++ b/admin/login.php @@ -28,7 +28,9 @@ include 'header.php';
- +
diff --git a/var/Typecho/Response.php b/var/Typecho/Response.php index 6e816b5c..57f19fae 100644 --- a/var/Typecho/Response.php +++ b/var/Typecho/Response.php @@ -203,7 +203,8 @@ class Response [$key, $value, $timeout, $path, $domain] = $cookie; if ($timeout > 0) { - $timeout += time(); + $now = time(); + $timeout += $timeout > $now - 86400 ? 0 : $now; } elseif ($timeout < 0) { $timeout = 1; } diff --git a/var/Widget/Archive.php b/var/Widget/Archive.php index 6e3a6eca..ffde9a6c 100644 --- a/var/Widget/Archive.php +++ b/var/Widget/Archive.php @@ -1749,8 +1749,7 @@ class Archive extends Contents $this->security->protect(); Cookie::set( 'protectPassword_' . $this->request->filter('int')->protectCID, - $this->request->protectPassword, - 0 + $this->request->protectPassword ); $isPasswordPosted = true; diff --git a/var/Widget/Feedback.php b/var/Widget/Feedback.php index f0f4635f..b8de4c61 100644 --- a/var/Widget/Feedback.php +++ b/var/Widget/Feedback.php @@ -216,7 +216,7 @@ class Feedback extends Comments implements ActionInterface } } - $expire = $this->options->time + $this->options->timezone + 30 * 24 * 3600; + $expire = 30 * 24 * 3600; Cookie::set('__typecho_remember_author', $comment['author'], $expire); Cookie::set('__typecho_remember_mail', $comment['mail'], $expire); Cookie::set('__typecho_remember_url', $comment['url'], $expire); diff --git a/var/Widget/Login.php b/var/Widget/Login.php index 140c469d..860f121e 100644 --- a/var/Widget/Login.php +++ b/var/Widget/Login.php @@ -41,6 +41,14 @@ class Login extends Users implements ActionInterface $validator = new Validate(); $validator->addRule('name', 'required', _t('请输入用户名')); $validator->addRule('password', 'required', _t('请输入密码')); + $expire = 30 * 24 * 3600; + + /** 记住密码状态 */ + if ($this->request->remember) { + Cookie::set('__typecho_remember_remember', 1, $expire); + } elseif (Cookie::get('__typecho_remember_remember')) { + Cookie::delete('__typecho_remember_remember'); + } /** 截获验证异常 */ if ($error = $validator->run($this->request->from('name', 'password'))) { @@ -56,7 +64,7 @@ class Login extends Users implements ActionInterface $this->request->name, $this->request->password, false, - 1 == $this->request->remember ? $this->options->time + $this->options->timezone + 30 * 24 * 3600 : 0 + 1 == $this->request->remember ? $expire : 0 ); /** 比对密码 */ diff --git a/var/Widget/Notice.php b/var/Widget/Notice.php index c14ff29e..6ccb47e3 100644 --- a/var/Widget/Notice.php +++ b/var/Widget/Notice.php @@ -33,8 +33,7 @@ class Notice extends Widget $this->highlight = $theId; Cookie::set( '__typecho_notice_highlight', - $theId, - Options::alloc()->time + Options::alloc()->timezone + 86400 + $theId ); } @@ -64,13 +63,11 @@ class Notice extends Widget Cookie::set( '__typecho_notice', - json_encode($notice), - Options::alloc()->time + Options::alloc()->timezone + 86400 + json_encode($notice) ); Cookie::set( '__typecho_notice_type', - $type, - Options::alloc()->time + Options::alloc()->timezone + 86400 + $type ); } }