/** * logout页面 */ function logout() { //更新用户退出时间 $log_record = new LoginRecordModel(); $current_time = date('Y-m-d H:i:s', time()); $log['logout_date'] = $current_time; //如果是ajax传来的值 if (!empty($_POST['record_id'])) { $log_record->where('id=' . $_POST['record_id'])->save($log); } else { //如果是点击logout退出 $log_record->where('id=' . $_SESSION['record_id'])->save($log); unset($_SESSION['username']); $this->assign('jumpUrl', __APP__ . '/Index/index'); $this->success('退出成功'); } }
/** * 首页,调用3个frame页面 */ function index() { //得到最新的7篇文章 $arts = new ArticleModel(); $list_arts_data = $arts->limit('7')->order('id desc')->select(); //动态缓存最新文章 if (!S('art_list')) { $art_list = $list_arts_data; S('art_list', $list_arts_data, 3600); } else { $art_list = S('art_list'); } $this->assign('art_list', $art_list); //得到最新的5次登陆记录 $logs = new LoginRecordModel(); $list_logs_data = $logs->limit('7')->order('id desc')->select(); //动态缓存登陆记录 if (!S('log_list')) { $log_list = $list_logs_data; S('log_list', $list_logs_data, 3600); } else { $log_list = S('log_list'); } $this->assign('log_list', $log_list); //得到最新的文章评论 $comments = D('Comment'); $list_com_data = $comments->limit('7')->order('id desc')->select(); //动态缓存留言记录 if (!S('com_list')) { $com_list = $list_com_data; S('com_list', $list_com_data, 3600); } else { $com_list = S('com_list'); } $this->assign('com_list', $com_list); $this->display(); }
/** * 发送邮件 页面 * 完成页面 */ function send_email() { $id = trim($_POST['id']); $email_to = trim($_POST['email_to']); $title = trim($_POST['title']); $message = trim($_POST['description']); if (empty($title) || empty($message)) { $this->error("发送失败,请填写完全内容!"); } else { if (SendMail($email_to, $title, $message) !== false) { //发送警告成功,则将用户的警告数加1 $log_record = new LoginRecordModel(); $userinfo = $log_record->getById($id); $warn_count = $userinfo['warn_count']; $data['warn_count'] = $warn_count + 1; $log_record->where('id=' . $id)->save($data); $this->assign("jumpUrl", "__APP__/Tool/log_record"); $this->success("发送成功!"); } else { $this->assign("jumpUrl", "__APP__/Tool/log_record"); $this->error("发送失败,请联系管理员!!!"); } } }