public function index() { $msg = new MsgModel(); $str = ""; $p = isset($_GET['p']) ? $_GET['p'] : 1; $pageSize = 12; $curPage = ($p - 1) * $pageSize; $limit = $curPage . ',' . $pageSize; $message = $msg->getMsg($limit); if (isset($_SESSION['user'])) { $mark = 1; $user = new UserModel(); $uerinfo = $user->userInfo($_SESSION['user']); $this->assign('info', $uerinfo); } else { $mark = 0; } $counts = $msg->msgCount(); if ($counts > $pageSize) { $page = new Page($counts, $p, $pageSize); $str = $page->show('themeuk.php'); } $this->assign('page', $str); $this->assign('msg', $message); $this->assign('mark', $mark); $this->display(); }
protected function checkStatus() { if (isset($_SESSION['user'])) { $mark = 1; $user = new UserModel(); $uerinfo = $user->userInfo($_SESSION['user']); $this->assign('info', $uerinfo); } else { $mark = 0; } $this->assign('mark', $mark); }
public function __construct($pathinfo, $controller) { $this->sitename = "OurCoders (我们程序员)"; $this->short_sitename = "OurCoders"; $this->pathinfo = $pathinfo; parent::__construct($pathinfo, $controller); $this->begintime = microtime(true); $this->_layout = "index"; $this->cas[] = array('name' => 'index', 'title' => '首页'); $this->cas[] = array('name' => 'app', 'title' => '应用列表'); $this->cas[] = array('name' => 'user', 'title' => '用户'); $this->cas[] = array('name' => 'group', 'title' => '群组'); $mainMenu = $this->createMainMenu(); $title = $this->findTitle(); $this->_view->assign("sitename", $this->sitename); $this->_view->assign("short_sitename", $this->short_sitename); if ($title) { $this->title = "{$title} - {$this->sitename}"; } else { $this->title = "{$this->sitename}"; } $controller = $this->_controller['name']; if ($controller == 'index') { $this->breadCrumb = ''; } else { $this->breadCrumb = "<a href='/'>首页</a>-><a href='/{$controller}/'>{$title}</a>"; } $this->_view->assign('mainMenu', $mainMenu); $this->_view->assign('title', $this->title); $this->_view->assign('breadCrumb', $this->breadCrumb); $controller = ucwords($this->_controller['name']); $action = $this->_controller['action']; $mainContentFile = "{$controller}/{$action}.html"; if (file_exists($this->_pathinfo['views'] . '/' . $mainContentFile)) { $this->viewFile = $mainContentFile; } $this->_mainContent->assign("retUrl", $_SERVER['REQUEST_URI']); $this->_view->assign("retUrl", $_SERVER['REQUEST_URI']); $this->_view->assign("navsel", $controller); $userModel = new UserModel(); $this->userid = $userModel->checklogin(); if ($this->userid) { $this->username = $userModel->username($this->userid); $this->isEmailValidated = $userModel->isEmailValidated($this->userid); $userinfo = $userModel->userInfo($this->userid); } $toplinkadsModel = new ToplinkadsModel(); $toplink = $toplinkadsModel->toplink(); if ($toplink) { $alerttype = array(); $alerttype[] = "alert-info"; $alerttype[] = "alert-success"; $alerttype[] = ""; $toplink["alert"] = $alerttype[rand(0, 2)]; } $this->_view->assign("toplink", $toplink); $this->_view->assign("userid", $this->userid); $this->_view->assign("username", $this->username); if (isset($this->isEmailValidated)) { $this->_view->assign("isEmailValidated", $this->isEmailValidated); } if (isset($userinfo)) { $this->_view->assign("userinfo", $userinfo); } $iPhone = ToolModel::is_iPhone(); $this->_view->assign("iPhone", $iPhone); $this->_mainContent->assign("userid", $this->userid); $this->_mainContent->assign("iPhone", $iPhone); }
public function emailsettingAction() { if ($this->userid == 0) { header("location: /user/login/"); die; } $userModel = new UserModel(); if ($_POST) { if ($_POST["atnotify"] == 1) { $emailatnotification = 1; } else { $emailatnotification = 0; } if ($_POST["dailynews"] == 1) { $emaildailynotification = 1; } else { $emaildailynotification = 0; } if ($_POST["weeklynews"] == 1) { $emailweeklynotification = 1; } else { $emailweeklynotification = 0; } $userModel->updateEmailSetting($this->userid, $emailatnotification, $emaildailynotification, $emailweeklynotification); $this->_mainContent->assign("warnning", "设置成功更新"); } $userInfo = $userModel->userInfo($this->userid); $this->_mainContent->assign("emailatnotification", $userInfo["emailatnotification"]); $this->_mainContent->assign("emaildailynotification", $userInfo["emaildailynotification"]); $this->_mainContent->assign("emailweeklynotification", $userInfo["emailweeklynotification"]); $this->display(); }
public function banuserAction() { $userModel = new UserModel(); $threadModel = new ThreadModel(); if ($_POST) { $userid = $_POST["userid"]; if ($userid <= 0 || $userid == 2) { header('HTTP/1.1 301 Moved Permanently'); header("location:/home/"); die; } $userModel->banUser($userid); if ($_POST["delallthread"]) { $threadModel->delUserAllThread($userid); } if ($_POST["delallreply"]) { $threadModel->delUserAllReply($userid); } header('HTTP/1.1 301 Moved Permanently'); header("location:/user/show/{$userid}/"); die; } $id = $this->intVal(3); if ($id == 0 || $id == 2 || $this->userid != 2) { header('HTTP/1.1 301 Moved Permanently'); header("location:/home/"); } $userinfo = $userModel->userInfo($id); $userinfo["image"] = DiscuzModel::get_avatar($id, "middle"); $userinfo["threadscreate"] = $threadModel->threadsByUserid($id, 5); $this->_mainContent->assign("user", $userinfo); $this->display(); }
public function voteAction() { if ($this->userid == 0) { die("no_login"); } $userModel = new UserModel(); $userInfo = $userModel->userInfo($this->userid); $reputation = $userInfo["reputation"]; if ($reputation < 20) { die("reputation_too_low"); } $threadid = $_POST["threadid"]; $vote = $_POST["vote"]; $threadModel = new ThreadModel(); $result = $threadModel->vote($threadid, $this->userid, $vote); echo json_encode($result); }
public function replyNotify($data, $own = 1) { if ($own == 1) { $thread = $this->threadById($data["threadid"]); $userid = $thread["createbyid"]; if ($userid == $data["userid"]) { return; } $userModel = new UserModel(); $user = $userModel->userInfo($userid); $this->replyNotifyMailToOwner($user["username"], $user["email"], $data["name"], $data["content"], $thread["title"], $data["threadid"]); } else { $users = $this->getThreadUsers($data["threadid"]); if (($key = array_search($data["userid"], $users)) !== false) { unset($users[$key]); } if (count($users) == 0) { return; } $usersStr = join(",", $users); $sql = "SELECT `username`,`email` FROM `cocoabbs_uc_members` WHERE `uid` in ({$usersStr});"; $result = $this->fetchArray($sql); $thread = $this->threadById($data["threadid"]); foreach ($result as $user) { $this->replyNotifyMail($user["username"], $user["email"], $data["name"], $data["content"], $thread["title"], $data["threadid"]); } } }