/** * 检查是否登录 */ protected function check_login() { return; $session = $this->session(); $member = $session->member(); try { if (!$member->id > 0) { throw new \Exception(\__('Please login')); } # 超时时间 if (($admin_login_expired_time = \Core::config('admin.core.admin_login_expired_time')) > 0 && \TIME - $admin_login_expired_time > $session->last_actived_time()) { throw new \Exception(\__('Login timeout, please log in again')); } if ($member->password != $_SESSION['member_password']) { throw new \Exception(\__('This account password has been updated, please re-login')); } if ($member->setting['only_self_login'] && $session->id() != $member->last_login_session_id) { # 如果设置为仅仅可单人登录,若发现最后登录session id和当前登录session不一致,则取消此用户登录,并输出相应信息 throw new \Exception(\__('This account has been elsewhere login, log the IP: :ip - :iplocal, login time: :time', array(':ip' => $member->last_login_ip, ':iplocal' => \IpSource::get($member->last_login_ip), ':time' => $member->last_login_time))); } } catch (\Exception $e) { if (\HttpIO::IS_AJAX) { # AJAX 请求 self::message($e->getMessage(), -1); } else { # 正常页面请求 # 记录错误消息 $session->set_flash('admin_member_login_message', $e->getMessage()); # 页面跳转 $this->redirect(\Core::url('login/?forward=' . \urlencode($_SERVER['REQUEST_URI'] . ($_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '')))); } exit; } }
/** * 检查是否登录 */ protected function check_login() { $session = $this->session(); $member = $session->member(); try { if (!$member->id > 0) { throw new Exception('请先登录'); } # 超时时间 if (($admin_login_expired_time = Core::config('admin.core.admin_login_expired_time')) > 0 && TIME - $admin_login_expired_time > $session->last_actived_time()) { throw new Exception('登录超时,请重新登录'); } if ($member->password != $_SESSION['member_password']) { throw new Exception('此号密码已更新,请重新登录'); } if (!$member->setting['only_self_login'] && $session->id() != $member->last_login_session_id) { # 如果设置为仅仅可单人登录,若发现最后登录session id和当前登录session不一致,则取消此用户登录,并输出相应信息 throw new Exception('此号已在其它地方登录,登录IP:' . $member->last_login_ip . ' (' . IpSource::get($member->last_login_ip) . '),登录时间:' . date('Y-m-d H:i:s', $member->last_login_time)); } } catch (Exception $e) { if (HttpIO::IS_AJAX) { # AJAX 请求 $this->message($e->getMessage(), -1); } else { # 正常页面请求 # 记录错误消息 $session->set_flash('admin_member_login_message', $e->getMessage()); # 页面跳转 $this->redirect(Core::url('login/?forward=' . urlencode($_SERVER['REQUEST_URI'] . ($_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '')))); } exit; } }
/** * 获取天气信息 */ public function action_weather_data() { $city = $_GET['city']; if (!$city) { $city = \PinYIn::get(\IpSource::get()); if (\in_array($city, array('LAN', 'Local IP', 'Invalid IP Address'))) { $city = 'shanghai'; } } $view = new \View('admin/desktop/weather_data'); $view->weather = Weather::get($city); $view->city = $city; $view->render(); }