/** * 显示版面的情况 * @param: NULL * @return: NULL * @access: public */ public function run() { $id = $this->getParameterFromGET('id'); if (!$id) { $this->AlertAndBack(POST_IS_EMPTY); return; } $sql = 'select count(*) as num from site_post where id=? and expires>?'; $sth = $this->db->Prepare($sql); $res = $this->db->Execute($sth, array($id, time())); $rows = $res->FetchRow(); if (!$rows['num']) { $this->AlertAndBack(POST_IS_NOT_EXISTS); return; } $sql = 'select title, content, begin_date from site_post where id=?'; $sth = $this->db->Prepare($sql); $res = $this->db->Execute($sth, array($id)); $rows = $res->FetchRow(); $smarty = $this->getSmarty(); $smarty->assign('clone_title', $rows['title']); $smarty->assign('title', $rows['title']); $smarty->assign('content', ConvertString($rows['content'], ROOT_URL, IMAGE_URL . 'express/')); $smarty->assign('begin_date', $rows['begin_date']); $smarty->display('viewpost.tmpl'); }
/** * 返回子论坛的信息 * @param: $id, 论坛ID * @param: $db, 数据库的连接 * @reurn: Array * @access; public */ public static function &getSubBBS(&$db, $id) { /*{{{*/ //查询所有下级子论坛 $sub_bbs_layout_id = LayoutUtil::getLayoutInfoByParentId($db, $id); $sub_array = array(); foreach ($sub_bbs_layout_id as $sub_rows) { $sub_id = $sub_rows['id']; //注意:$sub_bbs_id是一个数组 $sub_bbs_id = array(); LayoutUtil::getChildId($db, $sub_id, $sub_bbs_id); array_push($sub_bbs_id, $sub_id); /** * 如果已经将论坛锁住,则不判断是否有新帖 */ /** * $layout_status == 0 || $layout_status is null 则为开放 * $layout_status == 1 则需要验证 * $layout_status == 2 则为关闭 */ $layout_status = LayoutUtil::getLayoutStatus($db, $sub_id); /** * 判断是否有新帖子 * 判断有新帖子的流程是: * 如果用户已经登录,则找出用户的作后动作的时间 * 如果用户没有登录,则显示没有新帖子 */ $image = 'nonewtopic.gif'; if ($layout_status == 2) { $image = 'lock.gif'; } else { if (isset($_SESSION['user'])) { if (LayoutUtil::haveNewTopic($db, $_SESSION['user']['name'], $sub_bbs_id)) { /** * 求出最后时间后,需要我们找出当前子论坛下各个子论坛的id */ $image = 'havenewtopic.gif'; } } } //求出论坛及子论坛下面的查看的人数 $view_number = LayoutUtil::getViewNumber($db, $sub_bbs_id); //求出论坛和子论坛下的所有的主题 $topic_number = LayoutUtil::getTopicNumber($db, $sub_bbs_id); //求出论坛下所有的回复数 $reply_number = LayoutUtil::getReplyNumber($db, $sub_bbs_id); //求论坛里最后发表的帖子 $temp_rows = LayoutUtil::getLastPostTopic($db, $sub_id); $last_id = $temp_rows['id']; $last_title = $temp_rows['title']; $last_time = $temp_rows['last_access_date']; $last_time = set_locale_time($last_time); $short_title = utf8_substr($last_title, 0, 10); //求版主列表的字符串 $manager_list_array = LayoutUtil::getManagerList($db, $sub_id); $manager_str = ""; foreach ($manager_list_array as $temp_rows) { $manager_str .= "<option value=" . $temp_rows['user_id'] . ">"; $manager_str .= $temp_rows['user_name'] . "</option>\n"; } $sub_array[] = array('id' => $sub_rows['id'], 'title' => $sub_rows['title'], 'content' => ConvertString(stripslashes($sub_rows['description']), ROOT_URL, IMAGE_URL . 'express/'), 'image' => $image, 'viewnumber' => $view_number, 'topic_number' => $topic_number, 'reply_number' => $reply_number, 'topicid' => $last_id, 'topic_title' => $last_title, 'short_title' => $short_title, 'last_time' => $last_time, 'managerlist' => $manager_str); } return $sub_array; }
/** * 显示短消息的内容 * @param: NULL * @return: NULL * @access: public */ public function run() { //读取用户传入的id $id = $this->getParameterFromGET('id'); if (!$id) { $this->AlertAndBack(SR_ID_IS_EMPTY); return; } //求得用户的id $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']); //验证id是否存在 $sql = 'select count(*) as num from message_inbox where id=? and user_id=?'; $sth = $this->db->Prepare($sql); $res = $this->db->Execute($sth, array($id, $user_id)); $rows = $res->FetchRow(); if (!$rows['num']) { $this->AlertAndBack(SR_ID_IS_NOT_EXISTS_OR_NOT_BELONE_USER); return; } $smarty = $this->getSmarty(); $smarty = $this->getSmarty(); $user_name = $_SESSION['user']['name']; $smarty->assign('view_user_name', $user_name); //用户的所在组 $sql = 'select b.group_name from base_user_info as a join sys_group as b on ' . ' a.group_dep = b.id where a.id=?'; $sth = $this->db->Prepare($sql); $res = $this->db->Execute($sth, array($user_id)); $rows = $res->FetchRow(); $smarty->assign('user_roles', $rows['group_name']); //加入统计信息 $user_header = UserUtil::getUserHeader($this->db, $user_id); $smarty->assign('head_url', $user_header); //查询新的短消息的数量 $sql = 'select count(*) as num from message_inbox where user_id=? and is_read = 0 '; $sth = $this->db->Prepare($sql); $res = $this->db->Execute($sth, array($user_id)); $rows = $res->FetchRow(); $smarty->assign('new_message_label', $rows['num']); //共有短消息数 $sql = 'select count(*) as num from message_inbox where user_id=? '; $sth = $this->db->Prepare($sql); $res = $this->db->Execute($sth, array($user_id)); $rows = $res->FetchRow(); $smarty->assign('total_message_number', $rows['num']); //取得用户注册时间 $sql = 'select register_date from base_user_info where id=?'; $stmt = $this->db->prepare($sql); $res = $this->db->CacheExecute(60 * 60, $stmt, array($user_id)); $rows = $res->FetchRow(); $smarty->assign('user_register_date', $rows['register_date']); //取得用户最后的登录时间 $sql = 'SELECT from_unixtime(last_time) as lastlogout FROM `user_last_time_logout` where user_id=?'; $stmt = $this->db->prepare($sql); $res = $this->db->CacheExecute(60 * 60, $stmt, array($user_id)); $rows = $res->FetchRow(); $smarty->assign('user_last_logout', $rows['lastlogout']); //发表的主题数 $sql = 'select count(*) as num from bbs_subject where author = ?'; $stmt = $this->db->Prepare($sql); $res = $this->db->CacheExecute(10, $stmt, array($user_name)); $rows = $res->FetchRow(); $smarty->assign('all_topic_number', $rows['num']); //参与的帖子数 $sql = 'select count(*) as num from bbs_reply where author=?'; $stmt = $this->db->Prepare($sql); $res = $this->db->CacheExecute(10, $stmt, array($user_name)); $rows = $res->FetchRow(); $smarty->assign('all_reply_number', $rows['num']); ///拥有的短消息的数量 $sql = 'select count(*) as num from message_inbox where user_id=?'; $stmt = $this->db->prepare($sql); $res = $this->db->CacheExecute(20, $stmt, array($user_id)); $rows = $res->FetchRow(); $number_inbox = $rows['num']; $sql = 'select count(*) as num from message_outbox where user_id=?'; $stmt = $this->db->prepare($sql); $res = $this->db->CacheExecute(20, $stmt, array($user_id)); $rows = $res->FetchRow(); $smarty->assign('message_all_number', $number_inbox + $rows['num']); //拥有的收藏数 $sql = 'select count(*) as num from favor where user_id=?'; $stmt = $this->db->prepare($sql); $res = $this->db->CacheExecute(10, $stmt, array($user_id)); $rows = $res->FetchRow(); $smarty->assign('favor_amount', $rows['num']); //使得短消息成为已读 $sql = 'update message_inbox set is_read = 1 where id=?'; $sth = $this->db->Prepare($sql); $this->db->Execute($sth, array($id)); //查询短消息的内容 $sql = 'select a.title, a.send_user_id, a.receive_time, a.content, ' . ' b.user_name from message_inbox a ' . ' left join base_user_info b on a.send_user_id = b.id where a.id=?'; $sth = $this->db->Prepare($sql); $res = $this->db->Execute($sth, array($id)); $rows = $res->FetchRow(); if ($rows['send_user_id'] == 0) { $sender = 'system'; } else { $sender = $rows['user_name']; } $smarty->assign('title', $rows['title']); $smarty->assign('sender', $rows['user_name']); $smarty->assign('send_time', $rows['receive_time']); $smarty->assign('content', ConvertString($rows['content'], ROOT_URL, IMAGE_URL . 'express/')); $smarty->display('showmsg.tmpl'); }
/** * 查看用户的个人信息 * @param: NULL * @return: NULL * @access: public */ public function run() { //取得用户的id $user_id = $this->getParameterFromGET('id'); if (!$user_id && $user_id != 0) { $this->AlertAndBack(VU_USER_ID_IS_EMPTY); return; } if ($user_id == 0) { $this->AlertAndBack(VU_USER_IS_SYSTEM); return; } if (!UserUtil::isExists($this->db, $user_id)) { $this->AlertAndBack(VU_USER_IS_NOT_EXISTS); return; } $smarty = $this->getSmarty(); //back url $back_url = 'index.php?module=user&action=view&id=' . $user_id; $back_url = base64_encode($back_url); $smarty->assign('backurl', $back_url); //assign user id $smarty->assign('user_id', $user_id); //用户名 $user_name = UserUtil::getUserNameById($this->db, $user_id); $smarty->assign('view_user_name', $user_name); //用户所在的组 $sql = 'select b.group_name from base_user_info as a join sys_group as b on ' . ' a.group_dep = b.id where a.id=?'; $sth = $this->db->Prepare($sql); $res = $this->db->Execute($sth, array($user_id)); $rows = $res->FetchRow(); $smarty->assign('user_roles', $rows['group_name']); //判断用户是否在线 $sql = 'select count(*) as num from online_user where user_name =? '; $sth = $this->db->Prepare($sql); $res = $this->db->Execute($sth, array($user_name)); $rows = $res->FetchRow(); if ($rows['num']) { $smarty->assign('user_is_online', 1); } else { $smarty->assign('user_is_online', 0); } //求用户的头像 $user_header = UserUtil::getUserHeader($this->db, $user_id); $smarty->assign('head_url', $user_header); $sql = 'select user_gender,user_birthday, public_birthday, user_email, public_user_email, ' . 'user_website, public_website, register_date, user_icq, public_user_icq, user_AIM, ' . 'public_user_AIM, user_msn, public_user_msn, user_yahoo, public_user_yahoo,user_skype, ' . ' public_user_skype, user_qq, public_user_qq, user_hometown, user_favor, user_sign ' . ' from base_user_info where id=?'; $sth = $this->db->Prepare($sql); $res = $this->db->Execute($sth, array($user_id)); $rows = $res->FetchRow(); //性别 $smarty->assign('user_sex', $rows['user_gender']); //生日 if ($rows['public_birthday']) { $smarty->assign('user_birthday', $rows['user_birthday']); } else { $smarty->assign('user_birthday', VU_NOT_PUBLIC); } //电子邮件 if ($rows['public_user_email']) { $smarty->assign('user_email', $rows['user_email']); } else { $smarty->assign('user_email', VU_NOT_PUBLIC); } //个人网站 if ($rows['public_website']) { $smarty->assign('user_website', $rows['user_website']); } else { $smarty->assign('user_website', VU_NOT_PUBLIC); } //注册日期 $smarty->assign('user_register_date', $rows['register_date']); //ICQ if ($rows['public_user_icq']) { $smarty->assign('user_icq', $rows['user_icq']); } else { $smarty->assign('user_icq', VU_NOT_PUBLIC); } //AIM if ($rows['public_user_AIM']) { $smarty->assign('user_aim', $rows['user_AIM']); } else { $smarty->assign('user_aim', VU_NOT_PUBLIC); } //MSN if ($rows['public_user_msn']) { $smarty->assign('user_msn', $rows['user_msn']); } else { $smarty->assign('user_msn', VU_NOT_PUBLIC); } //Yahoo if ($rows['public_user_yahoo']) { $smarty->assign('user_yahoo', $rows['user_yahoo']); } else { $smarty->assign('user_yahoo', VU_NOT_PUBLIC); } //skype if ($rows['public_user_skype']) { $smarty->assign('user_skype', $rows['user_skype']); } else { $smarty->assign('user_skype', VU_NOT_PUBLIC); } //QQ if ($rows['public_user_qq']) { $smarty->assign('user_qq', $rows['user_qq']); } //hometown $smarty->assign('user_home_town', $rows['user_hometown']); //user favor $smarty->assign('user_favor', $rows['user_favor']); //user sign $smarty->assign('user_sign', ConvertString($rows['user_sign'], ROOT_URL, IMAGE_URL . 'express/')); //用户的发帖数 $topic_number = UserUtil::getUserCreateTopicNumber($this->db, $user_id); $smarty->assign('user_topic_number', $topic_number); $smarty->display('viewuser.tmpl'); }
/** * 取得帖子的信息 * @param: &$db * @param: $id * @param: $pre_page * @param: $offset_page * @return: $topic_array * @access: public * @static */ public static function getTopicInfo(&$db, $id, $pre_page = 10, $offset_page = 0) { /*{{{*/ $topic_array = array(); $topic_status = self::getTopicStatus($db, $id); //如果显示第一页,则必须给出主题 if ($offset_page == 0) { $sql = 'select title, express, author, content, post_date, is_edit, ' . ' edit_user, edit_time, subject_status, is_best, is_top from bbs_subject where id=?'; $sth = $db->Prepare($sql); $res = $db->Execute($sth, array($id)); $rows = $res->FetchRow(); $posttime = set_locale_time($rows['post_date']); $user_name = $rows['author']; $user_id = UserUtil::getUserId($db, $user_name); $user_header = UserUtil::getUserHeader($db, $user_id); $user_info = UserUtil::getUserInfo($db, $user_id); $register_date = $user_info['register_date']; $user_level = $user_info['user_level']; $user_address = $user_info['user_hometown']; $user_topic_number = $user_info['user_topic']; $user_sign = ConvertString($user_info['user_sign'], ROOT_URL, IMAGE_URL . 'express/'); $is_edit = 0; $edit_user = ''; $edit_time = ''; if ($rows['is_edit']) { $is_edit = 1; $edit_user = $rows['edit_user']; $edit_time = $rows['edit_time']; } $user_online = UserUtil::isOnline($db, $user_id); $user_can_be_edit = 0; if (!$_SESSION['user']['name']) { $user_can_be_edit = 0; } else { if (strtolower($_SESSION['user']['name']) == strtolower($user_name)) { $user_can_be_edit = 1; } else { if (strtolower($_SESSION['user']['name']) != strtolower($user_name)) { //判断用户是否是这个版块的版主。 $dep = UserUtil::getUserDep($db, $_SESSION['user']['name']); if ($dep == 1 || $dep == 2) { $user_can_be_edit = 1; } else { if ($dep == 3) { $temp_layout_id = self::getLayoutId($db, $id); $user_can_be_edit = UserUtil::isThisLayoutAdmin($db, $id, $temp_layout_id, $_SESSION['user']['name']); } } } } } //判断是否有附件 //如果有附件,则使用代码替换 $content = ''; if ($topic_status == 2) { $content = TU_TOPIC_WAS_LOCKED; } else { $content = $rows['content'] . self::haveAttach($db, $id); if ($is_edit) { $attach_string = TU_SUB_TITLE . $edit_user . TU_FROM . $edit_time . TU_EDIT; $content .= "\n\n" . $attach_string; } } $title = $rows['title']; $title = htmlspecialchars($title); if ($rows['is_best']) { $title = "<font color=red>[" . BEST_LABEL . "]</font>" . $title; } if ($rows['is_top']) { $title = "<font color=red>[" . TOP_LABEL . "]</font>" . $title; } $topic_array[] = array('id' => $id, 'posttime' => $posttime, 'sort_number' => 1, 'user_name' => $user_name, 'user_id' => $user_id, 'user_header' => $user_header, 'user_sign' => $user_sign, 'register_date' => $register_date, 'user_level' => $user_level, 'user_address' => $user_address, 'user_topic_number' => $user_topic_number, 'title' => $title, 'content' => ConvertString($content, ROOT_URL, IMAGE_URL . 'express/'), 'online' => $user_online, 'can_be_edit' => $user_can_be_edit, 'is_topic' => 1, 'express' => $rows['express']); $pre_page = $pre_page - 1; } else { if ($offset_page >= 1) { $offset_page = $offset_page - 1; } } //再查回复的帖子 $sql = 'select id, title, express,author, content, post_date, is_edit, edit_user, ' . ' edit_time, reply_status from bbs_reply where subject_id=? ' . ' order by id asc'; $res = $db->SelectLimit($sql, $pre_page, $offset_page, array($id)); while ($rows = $res->FetchRow()) { $posttime = set_locale_time($rows['post_date']); $sort_number = $sort_begin; $user_name = $rows['author']; $user_id = UserUtil::getUserId($db, $user_name); $user_header = UserUtil::getUserHeader($db, $user_id); $user_info = UserUtil::getUserInfo($db, $user_id); $register_date = $user_info['register_date']; $user_level = $user_info['user_level']; $user_address = $user_info['user_hometown']; $user_topic_number = $user_info['user_topic']; $user_sign = ConvertString($user_info['user_sign'], ROOT_URL, IMAGE_URL . 'express/'); $is_edit = 0; $edit_user = ''; $edit_time = ''; if ($rows['is_edit']) { $is_edit = 1; $edit_user = $rows['edit_user']; $edit_time = $rows['edit_time']; } $user_online = UserUtil::isOnline($db, $user_id); $user_can_be_edit = 0; if (!$_SESSION['user']['name']) { $user_can_be_edit = 0; } else { if (strtolower($_SESSION['user']['name']) == strtolower($user_name)) { $user_can_be_edit = 1; } else { if (strtolower($_SESSION['user']['name']) != strtolower($user_name)) { //判断用户是否是这个版块的版主。 $dep = UserUtil::getUserDep($db, $_SESSION['user']['name']); if ($dep == 1 || $dep == 2) { $user_can_be_edit = 1; } else { if ($dep == 3) { $temp_layout_id = self::getLayoutId($db, $id); $user_can_be_edit = UserUtil::isThisLayoutAdmin($db, $id, $temp_layout_id, $_SESSION['user']['name']); } } } } } $sort_number = self::getSortNumber($db, $id, $rows['id']); $content = ''; $had_closed = 0; if ($rows['reply_status']) { $had_closed = 1; } if ($rows['reply_status'] || $topic_status == 2) { //如果回帖状态被设定,则表示改帖被关闭或者屏蔽 $content = TU_TOPIC_WAS_LOCKED; } else { $content = $rows['content'] . self::haveReplyAttach($db, $rows['id']); if ($is_edit) { $attach_string = TU_SUB_TITLE . $edit_user . TU_FROM . $edit_time . TU_EDIT; $content .= "\n\n" . $attach_string; } } $title = htmlspecialchars($rows['title']); $topic_array[] = array('id' => $rows['id'], 'posttime' => $posttime, 'sort_number' => $sort_number, 'user_name' => $user_name, 'user_id' => $user_id, 'user_header' => $user_header, 'user_sign' => $user_sign, 'register_date' => $register_date, 'user_level' => $user_level, 'user_address' => $user_address, 'user_topic_number' => $user_topic_number, 'title' => $title, 'content' => ConvertString($content, ROOT_URL, IMAGE_URL . 'express/'), 'online' => $user_online, 'can_be_edit' => $user_can_be_edit, 'is_topic' => 0, 'express' => $rows['express'], 'had_closed' => $had_closed); } return $topic_array; }