Ejemplo n.º 1
0
 /**
  * 显示用户发送短信的界面
  */
 public function run()
 {
     $id = $this->getParameterFromPOST('id');
     $type = $this->getParameterFromPOST('type');
     if ($type != 'topic') {
         $type = 'topic';
     }
     //
     //拿到userid
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     $favor_dir = $this->getParameterFromPOST('favor_dir');
     $add_new_favor_dir = $this->getParameterFromPOST('add_new_favor_dir');
     if ($add_new_favor_dir) {
         //我们将添加一个收藏目录
         $sql = 'insert into favor_dir ( user_id, dir_name ) values (?, ?)';
         $stmt = $this->db->prepare($sql);
         $this->db->Execute($stmt, array($user_id, $add_new_favor_dir));
         $favor_dir = $this->db->Insert_ID();
     } else {
         //检查用户选择的收藏目录ID
         $sql = 'select count(*) as num from favor_dir where user_id=? and id=?';
         $stmt = $this->db->Prepare($sql);
         $res = $this->db->Execute($stmt, array($user_id, $favor_dir));
         $rows = $res->FetchRow();
         if (!$rows['num']) {
             $this->AlertAndBack(SF_FAVOR_DIR_NOT_BE_CHOICE);
             return;
         }
     }
     //检查用户传入的topic是否存在
     $sql = 'select count(*) as num from bbs_subject where id=?';
     $stmt = $this->db->prepare($sql);
     $res = $this->db->Execute($stmt, array($id));
     $rows = $res->FetchRow();
     if (!$rows['num']) {
         $this->AlertAndForward(SF_TOPIC_IS_NOT_EXISTS);
         return;
     }
     $back_url = $this->getParameterFromPOST('backurl');
     //检查是否已经添加了该收藏到指定的目录中了
     $sql = 'select count(*) as num from favor where user_id=? and dir_id=? and ' . ' type=? and favor_id=? ';
     $stmt = $this->db->prepare($sql);
     $res = $this->db->execute($stmt, array($user_id, $favor_dir, $type, $id));
     $rows = $res->FetchRow();
     if ($rows['num']) {
         $this->AlertAndForward(SF_FAVOR_HAD_BEEN_ADD, base64_decode($back_url));
         return;
     }
     //加入收藏
     $sql = 'insert into favor (user_id, dir_id, type, favor_id, add_date ) ' . ' values (?, ?, ?, ?, ?) ';
     $stmt = $this->db->prepare($sql);
     $this->db->Execute($stmt, array($user_id, $favor_dir, $type, $id, getNoFormateCurrentDate()));
     if ($this->db->ErrorNo()) {
         $this->AlertAndForward($this->db->ErrorMsg());
         return;
     } else {
         $this->TipsAndForward(SF_ADD_SUCCESS, base64_decode($back_url));
         return;
     }
 }
Ejemplo n.º 2
0
 /**
  * 改变外观
  */
 public function run()
 {
     //求得用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     //取得用户传入的参数
     $theme = $this->getParameterFromGET('id');
     if ($theme != 'default' && $theme != 'new' && $theme != 'newll') {
         $theme = 'new';
     }
     $this->db->debug = true;
     $sql = 'select count(*) as num from user_setting where user_id=?';
     $sth = $this->db->Prepare($sql);
     $res = $this->db->Execute($sth, array($user_id));
     $rows = $res->FetchRow();
     if ($rows['num']) {
         $sql = 'update user_setting set user_theme=? ' . ' where user_id=?';
         $sth = $this->db->Prepare($sql);
         $this->db->Execute($sth, array($theme, $user_id));
     } else {
         $sql = 'insert into user_setting (user_theme, ' . ' user_id ) values (?, ? ) ';
         $sth = $this->db->Prepare($sql);
         $this->db->Execute($sth, array($theme, $user_id));
     }
     //更新Session设置
     $_SESSION['user']['theme'] = $theme;
     //送cookie
     if ($_COOKIE['user']) {
         $str_user_info = serialize($_SESSION['user']);
         setcookie('user', $str_user_info, time() + 60 * 60 * 24 * 365, '/', $global_config_web_domain);
     }
     setcookie('5abb_cookie_theme', $theme, time() + 60 * 60 * 24 * 365, '/', $global_config_web_domain);
     $this->forward('index.php');
 }
Ejemplo n.º 3
0
 /**
  * 显示用户更改邮件和密码的界面
  * @param:  NULL
  * @return: NULL
  * @access: public
  */
 public function run()
 {
     //求得用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     $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']);
     //查询用户现在的情况
     $sql = 'select user_lang, user_theme, user_whether_receive_email, receive_system_message ' . ' from user_setting where user_id=?';
     $sth = $this->db->Prepare($sql);
     $res = $this->db->Execute($sth, array($user_id));
     $rows = $res->FetchRow();
     $user_lang = 'zh';
     $user_theme = 'default';
     $user_receive_email = 1;
     $user_receive_message = 1;
     if ($rows['user_lang']) {
         $user_lang = $rows['user_lang'];
     }
     if ($rows['user_theme']) {
         $user_theme = $rows['user_theme'];
     }
     if ($rows['user_whether_receive_email']) {
         $user_receive_email = $rows['user_whether_receive_email'];
     } else {
         $user_receive_email = 0;
     }
     if ($rows['receive_system_message']) {
         $user_receive_message = $rows['receive_system_message'];
     } else {
         $user_receive_message = 0;
     }
     $smarty->assign('user_email_1', $user_receive_email);
     $smarty->assign('user_message_1', $user_receive_message);
     $user_lang_option = '';
     foreach ($this->system_lang as $lang) {
         $user_lang_option .= "<option value=\"" . $lang . "\"";
         if ($user_lang == $lang) {
             $user_lang_option .= " selected ";
         }
         $user_lang_option .= ">{$lang}</option>\n";
     }
     $smarty->assign('user_lang_option', $user_lang_option);
     $user_theme_option = '';
     foreach ($this->system_theme as $theme_key => $theme_name) {
         $user_theme_option .= "<option value=\"" . $theme_key . "\"";
         if ($user_theme == $theme_key) {
             $user_theme_option .= " selected ";
         }
         $user_theme_option .= ">{$theme_name}</option>\n";
     }
     $smarty->assign('user_theme_option', $user_theme_option);
     $smarty->display('bbsoption.tmpl');
 }
Ejemplo n.º 4
0
 /**
  *  run this action
  *  @param:  NULL
  *  @return: NULL
  *  @access: public
  */
 public function run()
 {
     global $global_config_web_domain;
     $db = $this->getDB();
     if (!isset($_SESSION['user'])) {
         $this->forward('index.php');
     }
     setcookie('user', '', time() - 3600, '/', $global_config_web_domain);
     $user_name = $_SESSION['user']['name'];
     //user logout
     unset($_SESSION['user']);
     //记录用户的登出动作
     $user_id = UserUtil::getUserId($db, $user_name);
     $sql = 'select count(*) as num from user_last_time_logout where user_id=?';
     $sth = $db->Prepare($sql);
     $res = $db->Execute($sth, array($user_id));
     $rows = $res->FetchRow();
     $now = time();
     if ($rows['num']) {
         $update_sql = 'update user_last_time_logout set last_time=? where user_id=?';
         $update_sth = $db->Prepare($update_sql);
         $db->Execute($update_sth, array($now, $user_id));
     } else {
         $insert_sql = 'insert into user_last_time_logout (user_id, ' . ' last_time) values (?, ?)';
         $insert_sth = $db->Prepare($insert_sql);
         $db->Execute($insert_sth, array($user_id, $now));
     }
     $session_id = session_id();
     $sql = 'update online_user set user_name = ? where session_id=?';
     $stmt = $db->Prepare($sql);
     $db->Execute($stmt, array($session_id, $session_id));
     $this->forward('index.php');
     return;
 }
Ejemplo n.º 5
0
 /**
  * 删除用户选定的短信
  */
 public function run()
 {
     //得到用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     //得到用户请求的id
     $id_array = $this->getParameterFromPOST('id');
     if (!is_array($id_array)) {
         $this->AlertAndBack(DM_SYSTEM_ERROR);
         return;
     }
     //进行身份的判断
     $sql = 'select count(*) as num from message_outbox where user_id=? and id=?';
     $sth = $this->db->Prepare($sql);
     foreach ($id_array as $id) {
         $res = $this->db->Execute($sth, array($user_id, $id));
         $rows = $res->FetchRow();
         if (!$rows['num']) {
             $this->AlertAndBack(DM_ID_IS_NOT_YOUR);
             return;
         }
     }
     //身份判断通过。
     //开始删除
     reset($id_array);
     $sql = 'delete from message_outbox where id in (' . implode(',', $id_array) . ')';
     $this->db->Execute($sql);
     $this->forward('index.php?module=message&action=send');
 }
Ejemplo n.º 6
0
 /**
  *  run this action
  *  @param:  NULL
  *  @return: NULL
  *  @access: public
  */
 public function run()
 {
     //取得参数
     $name = $this->getParameterFromPOST('username');
     $layout_id = $this->getParameterFromPOSt('id');
     if (!$name) {
         $this->AlertAndBack(USER_IS_EMPTY);
         return;
     }
     if (!$layout_id) {
         $this->AlertAndBack(LAYOUT_IS_EMPTY);
         return;
     }
     //检查用户名是否存在
     $sql = 'select count(*) as num from base_user_info where lower(user_name)=?';
     $sth = $this->db->Prepare($sql);
     $res = $this->db->Execute($sth, array(strtolower($name)));
     $rows = $res->FetchRow();
     if (!$rows['num']) {
         $this->AlertAndBack(USER_IS_NOT_EXISTS);
         return;
     }
     $user_id = UserUtil::getUserId($this->db, $name);
     //检查版块时候存在
     $sql = 'select count(*) as num from bbs_layout where id=?';
     $sth = $this->db->prepare($sql);
     $res = $this->db->Execute($sth, array($layout_id));
     $rows = $res->FetchRow();
     if (!$rows['num']) {
         $this->AlertAndBack(LAYOUT_IS_NOT_EXISTS);
         return;
     }
     //求该版块的parent id
     $sql = 'select parent_id from bbs_layout where id=?';
     $sth = $this->db->prepare($sql);
     $res = $this->db->Execute($sth, array($layout_id));
     $rows = $res->FetchRow();
     $parent_id = $rows['parent_id'];
     //检查用户是否已经是版主
     $sql = 'select count(*) as num from bbs_layout_manager where user_id=? and layout_id=?';
     $sth = $this->db->Prepare($sql);
     $res = $this->db->Execute($sth, array($user_id, $layout_id));
     $rows = $res->FetchRow();
     if ($rows['num']) {
         $this->AlertAndBack(USER_HAD_BEEN_ADDED_AS_MANAGER);
         return;
     }
     $sql = 'insert into bbs_layout_manager(user_id, layout_id) values (?, ?)';
     $sth = $this->db->Prepare($sql);
     $this->db->Execute($sth, array($user_id, $layout_id));
     $this->forward('index.php?action=layout&parent=' . $parent_id);
     return;
 }
Ejemplo n.º 7
0
 /**
  * 保存用户的个人签名
  * @param:  NULL
  * @return: NULL
  * @access: public
  */
 public function run()
 {
     //求得用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     //收集用户输入的个人签名
     $user_sign = $this->getParameterFromPOST('usersign');
     if (strlen($user_sign) > 250) {
         $this->AlertAndBack('SU_USER_SIGN_TOO_LONGER');
         return;
     }
     $sql = 'update base_user_info set user_sign=? where id=?';
     $sth = $this->db->Prepare($sql);
     $this->db->Execute($sth, array($user_sign, $user_id));
     $this->forward('index.php?module=user&action=sign');
 }
Ejemplo n.º 8
0
 /**
  * 显示用户的控制面板
  */
 public function run()
 {
     //求得用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     $smarty = $this->getSmarty();
     $user_name = $_SESSION['user']['name'];
     //取得用户正在访问的收藏目录
     $dir = $this->getParameterFromPOST('dir');
     if (!$dir) {
         $dir = 0;
     }
     $smarty->assign('dir', $dir);
     //取得用户正在访问的页面
     $page = $this->getParameterFromPOST('page');
     //得到用户请求的id
     $id_array = $this->getParameterFromPOST('id');
     if (!is_array($id_array)) {
         $this->AlertAndBack(DM_SYSTEM_ERROR);
         return;
     }
     //进行身份的判断
     $sql = 'select count(*) as num from favor where user_id=? and id=?';
     $sth = $this->db->Prepare($sql);
     foreach ($id_array as $id) {
         $res = $this->db->Execute($sth, array($user_id, $id));
         $rows = $res->FetchRow();
         if (!$rows['num']) {
             $this->AlertAndBack(DM_ID_IS_NOT_YOUR);
             return;
         }
     }
     //身份判断通过。
     //开始删除
     reset($id_array);
     $sql = 'delete from favor where id in (' . implode(',', $id_array) . ')';
     $this->db->Execute($sql);
     //删除成功
     if ($this->db->ErrorNo()) {
         $this->AlertAndBack($this->db->ErrorMsg());
     } else {
         $this->TipsAndForward(DM_DELETE_SUCCESS, 'index.php?module=favor&dir=' . $dir . '&page=' . $page);
     }
 }
Ejemplo n.º 9
0
 /**
  * 显示用户发送短信的界面
  */
 public function run()
 {
     $id = $this->getParameterFromGET('id');
     $type = $this->getParameterFromGET('type');
     if ($type != 'topic') {
         $type = 'topic';
     }
     //拿到userid
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     $sql = 'select id, dir_name from favor_dir where user_id=?';
     $stmt = $this->db->prepare($sql);
     $res = $this->db->Execute($stmt, array($user_id));
     $rows = $res->GetAll();
     $smarty = $this->getSmarty();
     $smarty->assign('favor_type', $type);
     $smarty->assign('id', $id);
     $smarty->assign('favor', $rows);
     $smarty->assign('backurl', $this->getParameter('backurl'));
     $smarty->display('showaddfavor.tmpl');
 }
Ejemplo n.º 10
0
 /**
  * 显示用户发送短信的界面
  */
 public function run()
 {
     //拿到userid
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     $favor_dir = $this->getParameterFromGET('dirname');
     $favor_dir_id = 0;
     if ($favor_dir) {
         //我们将添加一个收藏目录
         $sql = 'insert into favor_dir ( user_id, dir_name ) values (?, ?)';
         $stmt = $this->db->prepare($sql);
         $this->db->Execute($stmt, array($user_id, $favor_dir));
         $favor_dir_id = $this->db->Insert_ID();
     }
     if ($this->db->ErrorNo()) {
         $this->AlertAndForward($this->db->ErrorMsg());
         return;
     } else {
         $this->TipsAndForward(SF_ADD_SUCCESS, 'index.php?module=favor&dir=' . $favor_dir_id);
         return;
     }
 }
Ejemplo n.º 11
0
 /**
  * 显示用户的控制面板
  */
 public function run()
 {
     //求得用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     $smarty = $this->getSmarty();
     $user_name = $_SESSION['user']['name'];
     //取得用户要删除的收藏目录
     $dir = $this->getParameterFromGET('dir');
     if (!$dir) {
         $dir = 0;
     }
     //进行身份的判断
     $sql = 'select count(*) as num from favor_dir where user_id=? and id=?';
     $sth = $this->db->Prepare($sql);
     $res = $this->db->Execute($sth, array($user_id, $dir));
     $rows = $res->FetchRow();
     if (!$rows['num']) {
         $this->AlertAndBack(DM_ID_IS_NOT_YOUR);
         return;
     }
     //身份判断通过。
     //开始删除收藏
     $sql = 'select id from favor where dir_id=?';
     $stmt = $this->db->prepare($sql);
     $res = $this->db->Execute($stmt, array($dir));
     $id_array = array();
     while ($rows = $res->FetchRow()) {
         $id_array[] = $rows['id'];
     }
     $sql = 'delete from favor where id in (' . implode(',', $id_array) . ')';
     $this->db->Execute($sql);
     $sql = 'delete from favor_dir where id=?';
     $this->db->Execute($sql, array($dir));
     //删除成功
     if ($this->db->ErrorNo()) {
         $this->AlertAndBack($this->db->ErrorMsg());
     } else {
         $this->TipsAndForward(DM_DELETE_SUCCESS, 'index.php?module=favor');
     }
 }
Ejemplo n.º 12
0
 /**
  * 显示用户的基本信息
  * @param:  NULL
  * @return: NULL
  * @access: public
  */
 public function run()
 {
     //求得用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     $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']);
     //查询用户的个人信息
     $sql = 'select user_gender, user_birthday, public_birthday, user_website, public_website, ' . '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 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_gender', $rows['user_gender']);
     $smarty->assign('user_birthday', $rows['user_birthday']);
     $smarty->assign('public_birthday', $rows['public_birthday']);
     $smarty->assign('user_website', $rows['user_website']);
     $smarty->assign('public_website', $rows['public_website']);
     $smarty->assign('user_icq', $rows['user_icq']);
     $smarty->assign('public_icq', $rows['public_user_icq']);
     $smarty->assign('user_aim', $rows['user_AIM']);
     $smarty->assign('public_aim', $rows['public_user_AIM']);
     $smarty->assign('user_msn', $rows['user_msn']);
     $smarty->assign('public_msn', $rows['public_user_msn']);
     $smarty->assign('user_yahoo', $rows['user_yahoo']);
     $smarty->assign('public_yahoo', $rows['public_user_yahoo']);
     $smarty->assign('user_skype', $rows['user_skype']);
     $smarty->assign('public_skype', $rows['public_user_skype']);
     $smarty->assign('user_qq', $rows['user_qq']);
     $smarty->assign('public_qq', $rows['public_user_qq']);
     $smarty->assign('user_hometown', $rows['user_hometown']);
     $smarty->assign('user_favor', $rows['user_favor']);
     $smarty->display('baseinfo.tmpl');
 }
Ejemplo n.º 13
0
 /**
  * 保存用户的个人签名
  * @param:  NULL
  * @return: NULL
  * @access: public
  */
 public function run()
 {
     //求得用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     //取得用户传入的参数
     $user_lang = $this->getParameterFromPOST('user_lang');
     if (!$user_lang) {
         $user_lang = 'zh';
     }
     $user_theme = $this->getParameterFromPOST('user_theme');
     if (!$user_theme) {
         $user_theme = 'default';
     }
     $user_recieve_email = $this->getParameterFromPOST('receive_email');
     if ($user_recieve_email != 0) {
         $user_recieve_email = 1;
     }
     $user_recieve_message = $this->getParameterFromPOST('receive_message');
     if ($user_recieve_message != 0) {
         $user_recieve_message = 1;
     }
     $sql = 'select count(*) as num from user_setting where user_id=?';
     $sth = $this->db->Prepare($sql);
     $res = $this->db->Execute($sth, array($user_id));
     $rows = $res->FetchRow();
     if ($rows['num']) {
         $sql = 'update user_setting set user_lang=?, user_theme=?, user_whether_receive_email=?, ' . 'receive_system_message=? where user_id=?';
         $sth = $this->db->Prepare($sql);
         $this->db->Execute($sth, array($user_lang, $user_theme, $user_recieve_email, $user_recieve_message, $user_id));
     } else {
         $sql = 'insert into user_setting (user_lang, user_theme, user_whether_receive_email, ' . 'receive_system_message, user_id ) values (?, ?, ?, ?, ? ) ';
         $sth = $this->db->Prepare($sql);
         $this->db->Execute($sth, array($user_lang, $user_theme, $user_recieve_email, $user_recieve_message, $user_id));
     }
     //更新Session设置
     $_SESSION['user']['lang'] = $user_lang;
     $_SESSION['user']['theme'] = $user_theme;
     $this->forward('index.php?module=user&action=bbsoption');
 }
Ejemplo n.º 14
0
 /**
  * 显示用户更改邮件和密码的界面
  * @param:  NULL
  * @return: NULL
  * @access: public
  */
 public function run()
 {
     //求得用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     $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']);
     //查询用户现在的邮件
     $sql = 'select user_email, public_user_email 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_email', $rows['user_email']);
     $smarty->assign('public_email', $rows['public_user_email']);
     $smarty->display('passwd.tmpl');
 }
Ejemplo n.º 15
0
 public function __construct()
 {
     parent::__construct();
     if (!UserUtil::getUserId()) {
         ResponseUtil::redirect(UrlUtil::createBackendUrl('login'));
     }
     $controller = strtolower($this->router->class);
     $method = strtolower($this->router->method);
     if (UserUtil::isShopKeeper()) {
         if (!array_key_exists($controller, $this->shopKeeperPermissions)) {
             $this->message('你没有权限执行本步骤!');
         }
         $methods = $this->shopKeeperPermissions[$controller];
         if ($methods == '*') {
             return true;
         } else {
             if (!in_array($method, $methods)) {
                 $this->message('你没有权限执行本步骤!');
             } else {
                 return true;
             }
         }
     }
 }
Ejemplo n.º 16
0
 /**
  *  user's access log
  *  @param:  $module access module
  *  @param:  $actoin access action
  *  @return: NULL
  *  @access; private
  */
 private function recordUserAction($module = 'bbs', $action = 'default')
 {
     $ip = getenv('REMOTE_ADDR');
     if (!$ip) {
         $ip = 'not get';
     }
     $username = $_SESSION['user']['name'];
     if (!$username) {
         $username = $ip;
     }
     $now = time();
     $db = DB::getConnection();
     if (!$db) {
         header("Content-type:text/html;charset=UTF-8");
         die("Can't not connection the database");
     }
     // update online user status
     // after 45 minitues, if user have not any action, we must
     // beleive this guys had gnone aways.
     //记录访问计数器
     $sql = 'select count(*) as num from online_user where session_id=?';
     $sth = $db->prepare($sql);
     $res = $db->Execute($sth, array(session_id()));
     $rows = $res->FetchRow();
     if (!$rows['num']) {
         //如果没有记录则我们需要记录该用户的反问计数器
         $count = $rows['num'];
         $sql = 'update total_count set total_count=total_count + 1 where id=1';
         $db->execute($sql);
         //记录当天的访问数
         $sql = 'select count(*) as num from web_count where count_date=?';
         $date_array = getdate();
         $now_date = $date_array['year'] . '-' . $date_array['mon'] . '-' . $date_array['mday'];
         $sth = $db->prepare($sql);
         $res = $db->Execute($sth, array($now_date));
         $rows = $res->FetchRow();
         if (!$rows['num']) {
             $sql = 'insert into web_count (count_date, access_number ) values (?, ? ) ';
             $sth = $db->prepare($sql);
             $db->execute($sth, array($now_date, 1));
         } else {
             $sql = 'update web_count set access_number = access_number + 1 where ' . ' count_date=? ';
             $sth = $db->prepare($sql);
             $db->execute($sth, array($now_date));
         }
     }
     $session_id = session_id();
     $sql = 'select count(*) as num from online_user where lower(user_name)=?';
     $stmt = $db->prepare($sql);
     $res = $db->Execute($stmt, array(isset($_SESSION['user']) ? strtolower($_SESSION['user']['name']) : strtolower($session_id)));
     $rows = $res->FetchRow();
     if ($rows['num']) {
         $update_sql = 'update online_user set access_time=? where session_id=?';
         $update_stmt = $db->prepare($update_sql);
         $db->Execute($update_stmt, array(time(), $session_id));
     } else {
         $user_name = $session_id;
         if (isset($_SESSION['user'])) {
             $user_name = $_SESSION['user']['name'];
         }
         $ip = getenv('REMOTE_ADDR');
         $insert_sql = 'insert into online_user (user_name, user_ip, connect_time, 
         access_time, session_id) values (?, ?, ?, ?, ? )';
         $insert_stmt = $db->prepare($insert_sql);
         $db->Execute($insert_sql, array($user_name, $ip, time(), time(), $session_id));
     }
     // recored these user for logout
     $now = time();
     $sql = 'select user_name from online_user where access_time + 2700 < ? ';
     $sth = $db->Prepare($sql);
     $res = $db->Execute($sth, array($now));
     while ($rows = $res->FetchRow()) {
         $user_id = UserUtil::getUserId($db, $rows['user_name']);
         $temp_sql = 'select count(*) as num from user_last_time_logout where user_id=?';
         $temp_sth = $db->Prepare($temp_sql);
         $temp_res = $db->Execute($temp_sth, array($user_id));
         $temp_rows = $temp_res->FetchRow();
         if ($temp_rows['num']) {
             $update_sql = 'update user_last_time_logout set last_time=? where user_id=?';
             $update_sth = $db->Prepare($update_sql);
             $db->Execute($update_sth, array($now, $user_id));
         } else {
             $insert_sql = 'insert into user_last_time_logout (user_id, ' . ' last_time) values (?, ?)';
             $insert_sth = $db->Prepare($insert_sql);
             $db->Execute($insert_sth, array($user_id, $now));
         }
     }
     // delte all user that had gnone away.
     $sql = 'delete from online_user where access_time + 2700 < ? ';
     $stmt = $db->prepare($sql);
     $db->Execute($stmt, array($now));
     //记录最大同时在线的人数
     $sql = 'select count(*) as num from online_user ';
     $res = $db->Execute($sql);
     $rows = $res->FetchRow();
     $online_user_number = $rows['num'];
     //看看目前最大的用户同时在线数
     $sql = 'select online from max_online_user where id=1';
     $res = $db->Execute($sql);
     $rows = $res->FetchRow();
     if (!$rows['online']) {
         $sql = 'insert into max_online_user (id, online, online_date ) values (?, ?, ?)';
         $sth = $db->prepare($sql);
         $db->Execute($sth, array(1, $online_user_number, getNoFormateCurrentDate()));
     } else {
         if ($rows['online'] < $online_user_number) {
             $sql = 'update max_online_user set online=?, online_date=? where id=?';
             $sth = $db->prepare($sql);
             $db->Execute($sth, array($online_user_number, getNoFormateCurrentDate(), 1));
         }
     }
     return;
 }
Ejemplo n.º 17
0
 /**
  * 显示用户的基本信息
  * @param:  NULL
  * @return: NULL
  * @access: public
  */
 public function run()
 {
     //求得用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     //取得各种参数
     //然后在对各个参数进行判断。
     //性别
     $user_gender = $this->getParameterFromPOST('gender');
     if (!$user_gender) {
         $user_gender = 'male';
     }
     if ($user_gender != 'male' and $user_gender != 'female') {
         $user_gender = 'male';
     }
     //用户的生日
     $user_birthday = $this->getParameterFromPOST('user_birthday');
     $public_birthday = $this->getParameterFromPOST('public_birthday');
     if ($public_birthday != 1 and $public_birthday != 0) {
         $public_birthday = 1;
     }
     //这里对于日期的判断需要做严格一些,但是我现在真的没有那么多的时间。
     //以后再补回来好了。
     $user_website = $this->getParameterFromPOST('user_website');
     $public_website = $this->getParameterFromPOST('public_website');
     if ($public_website != 1 and $public_website != 0) {
         $public_website = 1;
     }
     $user_icq = $this->getParameterFromPOST('user_icq');
     $public_icq = $this->getParameterFromPOST('public_icq');
     if ($public_icq != 1 and $public_icq != 0) {
         $public_icq = 1;
     }
     $user_aim = $this->getParameterFromPOST('user_aim');
     $public_aim = $this->getParameterFromPOST('public_aim');
     if ($public_aim != 1 and $public_aim != 0) {
         $public_aim = 1;
     }
     $user_msn = $this->getParameterFromPOST('user_msn');
     $public_msn = $this->getParameterFromPOST('public_msn');
     if ($public_msn != 1 and $public_msn != 0) {
         $public_msn = 1;
     }
     $user_yahoo = $this->getParameterFromPOST('user_yahoo');
     $public_yahoo = $this->getParameterFromPOST('public_yahoo');
     if ($public_yahoo != 1 and $public_yahoo != 0) {
         $public_yahoo = 1;
     }
     $user_skype = $this->getParameterFromPOST('user_skype');
     $public_skype = $this->getParameterFromPOST('public_skype');
     if ($public_skype != 1 and $public_skype != 0) {
         $public_skype = 1;
     }
     $user_qq = $this->getParameterFromPOST('user_qq');
     $public_qq = $this->getParameterFromPOST('public_qq');
     if ($public_qq != 1 and $public_qq != 0) {
         $public_qq = 1;
     }
     $user_hometown = $this->getParameterFromPOST('user_hometown');
     if (strlen($user_hometown) > 80) {
         $this->AlertAndBack(SB_HOMETOWN_TOO_LONGER);
         return;
     }
     //爱好
     $user_favor = $this->getParameterFromPOST('favor');
     if (strlen($user_favor) > 150) {
         $this->AlertAndBack(SB_USER_FAVOR_TOO_LONGER);
         return;
     }
     //更新用户的基本资料
     $update_sql = 'update base_user_info set user_gender=?,user_birthday=?, ' . 'public_birthday=?, user_website=?, public_website=?, 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=? where id=?';
     $this->db->debug = 1;
     $sth = $this->db->Prepare($update_sql);
     $this->db->Execute($sth, array($user_gender, $user_birthday, $public_birthday, $user_website, $public_website, $user_icq, $public_icq, $user_aim, $public_aim, $user_msn, $public_msn, $user_yahoo, $public_yahoo, $user_skype, $public_skype, $user_qq, $public_qq, $user_hometown, $user_favor, $user_id));
     if ($this->db->ErrorNo()) {
         $this->AlertAndBack($this->db->ErrorMsg());
         return;
     }
     $this->forward('index.php?module=user&action=baseinfo');
 }
Ejemplo n.º 18
0
 /**
  * 显示版面的情况
  * @param:  NULL
  * @return: NULL
  * @access: public
  */
 public function run()
 {
     //取得用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     $smarty = $this->getSmarty();
     //取得站点的公告,并显示在页面上
     $is_have_post = false;
     $post_str = '';
     if (PostUtil::haveNotExpirePost($this->getDB())) {
         $is_have_post = true;
         $post_array = PostUtil::getPost($this->getDB(), 3);
         foreach ($post_array as $post_rows) {
             $post_str .= '<a href=\'index.php?module=post&action=view&id=' . $post_rows['id'] . '\' title=\'' . $post_rows['title'] . '\'>' . utf8_substr($post_rows['title'], 0, 35) . '</a>' . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
         }
     }
     $smarty->assign('have_system_post', $is_have_post);
     $smarty->assign('post_str', $post_str);
     //公告显示结束
     $q = $this->getParameterFromGET('q');
     $encode_q = $q;
     //取得查询字符串
     if (!$q) {
         //取得用户最后一次的动作时间
         $last_time = UserUtil::getUserLastLogoutTime($this->db, $user_id);
         //生成一个where语句
         $q = " where last_access_date >='" . $last_time . "'";
         $encode_q = base64_encode($q);
     } else {
         $q = base64_decode($q);
     }
     $smarty->assign('encode_q', $encode_q);
     //生成所有的记录数
     $sql = 'select count(*) as num from bbs_subject ' . $q;
     $res = $this->db->Execute($sql);
     $rows = $res->FetchRow();
     $total_number = $rows['num'];
     //求总公的页面
     $total_page = ceil($total_number / $this->page_number);
     //取得当前的页面
     $page = $this->getParameter('page');
     if (!$page || $page < 0) {
         $page = 1;
     }
     if ($page > $total_page && $total_page > 0) {
         $page = $total_page;
     }
     $begin_page = 1;
     $end_page = $total_page;
     if ($page <= 10 && $total_page >= 10) {
         $end_page = 10;
     } else {
         if ($page > 10) {
             if ($page % 10 == 0) {
                 //向前翻
                 $end_page = $page;
                 $begin_page = $end_page - 9;
             } else {
                 if ($page % 10 == 1) {
                     //向后翻
                     //确定开始的页数
                     $begin_page = $page;
                     if ($begin_page > $total_page) {
                         $begin_page = $page - 9;
                     }
                     if ($begin_page + 9 > $total_page) {
                         $end_page = $total_page;
                     } else {
                         $end_page = $begin_page + 9;
                     }
                 } else {
                     $num = $page % 10;
                     $pre_num = floor($page / 10);
                     $begin_page = $pre_num * 10 + 1;
                     $end_page = $begin_page + 9;
                 }
             }
         }
     }
     if ($end_page > $total_page) {
         $end_page = $total_page;
     }
     $nav_page_array = array();
     for ($i = $begin_page; $i <= $end_page; $i++) {
         array_push($nav_page_array, $i);
     }
     //帖子导航栏
     $smarty->assign('nav_page', $nav_page_array);
     //当前的页面
     $smarty->assign('now_page', $page);
     //共有的页面
     $smarty->assign('total_page', $total_page);
     //显示搜索结果
     //求出偏移
     $offset_number = ($page - 1) * $this->page_number;
     $subject_array = LayoutUtil::getCacheSubjectInfo($this->db, $this->page_number, $offset_number, $q);
     if ($total_page > 0) {
         $smarty->assign('subject', $subject_array);
         $smarty->assign('have_subject', 1);
     }
     $smarty->display('viewnew.tmpl');
 }
Ejemplo n.º 19
0
 /**
  * 显示用户更改邮件和密码的界面
  * @param:  NULL
  * @return: NULL
  * @access: public
  */
 public function run()
 {
     //求得用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     $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']);
     //显示默认的头像
     $image_array = "";
     for ($i = 1; $i <= 37; $i++) {
         $image_array .= "<option value=" . $i . ">第" . $i . "个头像</option>\n";
     }
     $smarty->assign('image_options', $image_array);
     $smarty->display('userheader.tmpl');
 }
Ejemplo n.º 20
0
 /**
  * 取得帖子的信息
  * @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;
 }
Ejemplo n.º 21
0
 /**
  * 显示用户的短消息收件箱
  * @param:  NULL
  * @return: NULL
  * @access: public
  */
 public function run()
 {
     //求得用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     $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 = '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();
     $total_number = $rows['num'];
     //求总公的页面
     $total_page = ceil($total_number / $this->page_number);
     //取得当前的页面
     $page = $this->getParameter('page');
     if (!$page || $page < 0) {
         $page = 1;
     }
     if ($page > $total_page && $total_page > 0) {
         $page = $total_page;
     }
     $begin_page = 1;
     $end_page = $total_page;
     if ($page <= 10 && $total_page >= 10) {
         $end_page = 10;
     } else {
         if ($page > 10) {
             if ($page % 10 == 0) {
                 //向前翻
                 $end_page = $page;
                 $begin_page = $end_page - 9;
             } else {
                 if ($page % 10 == 1) {
                     //向后翻
                     //确定开始的页数
                     $begin_page = $page;
                     if ($begin_page > $total_page) {
                         $begin_page = $page - 9;
                     }
                     if ($begin_page + 9 > $total_page) {
                         $end_page = $total_page;
                     } else {
                         $end_page = $begin_page + 9;
                     }
                 } else {
                     $num = $page % 10;
                     $pre_num = floor($page / 10);
                     $begin_page = $pre_num * 10 + 1;
                     $end_page = $begin_page + 9;
                 }
             }
         }
     }
     $nav_page_array = array();
     for ($i = $begin_page; $i <= $end_page; $i++) {
         array_push($nav_page_array, $i);
     }
     //帖子导航栏
     $smarty->assign('nav_page', $nav_page_array);
     //当前的页面
     $smarty->assign('now_page', $page);
     //共有的页面
     $smarty->assign('total_page', $total_page);
     //求用户的信息
     $offset_page = ($page - 1) * $this->page_number;
     $sql = 'select a.id, a.send_user_id, b.user_name, a.title, a.receive_time, ' . ' a.is_read from message_inbox ' . ' as a  left join base_user_info as b on a.send_user_id = b.id ' . '  where user_id=? order by a.id desc ';
     $res = $this->db->SelectLimit($sql, $this->page_number, $offset_page, array($user_id));
     $temp_array = array();
     while ($rows = $res->FetchRow()) {
         if ($rows['send_user_id'] == 0) {
             $send_user_name = 'system';
         } else {
             $send_user_name = $rows['user_name'];
         }
         $temp_array[] = array('id' => $rows['id'], 'is_read' => $rows['is_read'], 'send_user_id' => $rows['send_user_id'], 'send_user_name' => $send_user_name, 'title' => $rows['title'], 'short_title' => utf8_substr($rows['title'], 0, 18), 'send_date' => $rows['receive_time']);
     }
     $smarty->assign('msg', $temp_array);
     $smarty->display('userinbox.tmpl');
 }
Ejemplo n.º 22
0
 /**
  * 保存用户的编辑后的资料
  * @param:  NULL
  * @return: NULL
  * @access: public
  */
 public function run()
 {
     //求得用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     //取得用户传入的参数
     $user_lang = $this->getParameterFromPOST('user_lang');
     if (!$user_lang) {
         $user_lang = 'zh';
     }
     $user_theme = $this->getParameterFromPOST('user_theme');
     if (!$user_theme) {
         $user_theme = 'new';
     }
     $user_recieve_email = $this->getParameterFromPOST('receive_email');
     if ($user_recieve_email != 0) {
         $user_recieve_email = 1;
     }
     $user_recieve_message = $this->getParameterFromPOST('receive_message');
     if ($user_recieve_message != 0) {
         $user_recieve_message = 1;
     }
     $sql = 'select count(*) as num from user_setting where user_id=?';
     $sth = $this->db->Prepare($sql);
     $res = $this->db->Execute($sth, array($user_id));
     $rows = $res->FetchRow();
     if ($rows['num']) {
         $sql = 'update user_setting set user_lang=?, user_theme=?, user_whether_receive_email=?, ' . 'receive_system_message=? where user_id=?';
         $sth = $this->db->Prepare($sql);
         $this->db->Execute($sth, array($user_lang, $user_theme, $user_recieve_email, $user_recieve_message, $user_id));
     } else {
         $sql = 'insert into user_setting (user_lang, user_theme, user_whether_receive_email, ' . 'receive_system_message, user_id ) values (?, ?, ?, ?, ? ) ';
         $sth = $this->db->Prepare($sql);
         $this->db->Execute($sth, array($user_lang, $user_theme, $user_recieve_email, $user_recieve_message, $user_id));
     }
     //更新Session设置
     $_SESSION['user']['lang'] = $user_lang;
     $_SESSION['user']['theme'] = $user_theme;
     //取得原始密码
     $old_password = $this->getParameterFromPOST('olduserpass');
     $old_password = md5($old_password);
     $sql = 'select count(*) as num from base_user_info where id=? and ' . 'user_password = ? ';
     $stmt = $this->db->prepare($sql);
     $res = $this->db->Execute($stmt, array($user_id, $old_password));
     $rows = $res->FetchRow();
     if ($rows['num']) {
         $new_password = $this->getParameterFromPOST('userpass');
         $re_password = $this->getParameterFromPOST('userpasscheck');
         if (strlen($new_password) > 6 && strlen($new_password) < 16 && $new_password == $re_password) {
             $update_sql = 'update base_user_info set user_password=? where id=?';
             $stmt = $this->db->prepare($update_sql);
             $this->db->Execute($stmt, array(md5($new_password), $user_id));
         }
     }
     //取得用户其他的参数
     //是否公开邮件
     $public_email = $this->getParameterFromPOST('public_email');
     if ($public_email) {
         $public_email = 1;
     } else {
         $public_email = 0;
     }
     //性别
     $user_gender = $this->getParameterFromPOST('register_gender');
     //家乡
     $user_hometown = $this->getParameterFromPOST('user_hometown');
     //生日
     $birthday_year = $this->getParameterFromPost('birthday_year');
     $birthday_month = $this->getParameterFromPost('birthday_month');
     $birthday_day = $this->getParameterFromPost('birthday_day');
     //检查日期的合法性
     $check_time = mktime(0, 0, 0, $birthday_month, $birthday_day, $birthday_year);
     if (!$check_time || $check_time == -1) {
         $this->AlertAndForward(RE_CHECK_BIRTHDAY_NOT_VALIDATE, 'index.php?module=user&action=register');
         return;
     }
     $birthday_date = $birthday_year . '-' . $birthday_month . '-' . $birthday_day;
     //是否公开生日
     $public_birthday = $this->getParameterFromPOST('public_birthday');
     if ($public_birthday) {
         $public_birthday = 1;
     } else {
         $public_birthday = 0;
     }
     //QQ
     $user_qq = $this->getParameterFromPOST('user_qq');
     //是否公开qq
     $public_user_qq = $this->getParameterFromPOST('public_user_qq');
     if ($public_user_qq) {
         $public_user_qq = 1;
     } else {
         $public_user_qq = 0;
     }
     //MSN
     $user_msn = $this->getParameterFromPOST('user_msn');
     $public_user_msn = $this->getParameterFromPOST('public_user_msn');
     if ($public_user_msn) {
         $public_user_msn = 1;
     } else {
         $public_user_msn = 0;
     }
     //skype
     $user_skype = $this->getParameterFromPOST('user_skype');
     $public_user_skype = $this->getParameterFromPOST('public_user_skype');
     if ($public_user_skype) {
         $public_user_msn = 1;
     } else {
         $public_user_skype = 0;
     }
     //个人网站
     $user_website = $this->getParameterFromPOST('user_website');
     $public_website = $this->getParameterFromPOST('public_website');
     if ($public_website) {
         $public_website = 1;
     } else {
         $public_website = 0;
     }
     //签名
     $user_sign = $this->getParameterFromPOST('user_sign');
     $update_sql = 'update base_user_info set public_user_email=?, user_gender=?, user_hometown=?, ' . 'user_birthday=?, public_birthday=?, user_qq=?, public_user_qq=?, user_msn=?, ' . 'public_user_msn=?, user_skype=?, public_user_skype=?, user_website=?, public_website=?, ' . 'user_sign=? where id=?';
     $stmt = $this->db->prepare($update_sql);
     $this->db->Execute($stmt, array($public_email, $user_gender, $user_hometown, $birthday_date, $public_birthday, $user_qq, $public_user_qq, $user_msn, $public_user_msn, $user_skype, $public_user_skype, $user_website, $public_website, $user_sign, $user_id));
     if ($this->db->ErrorNo()) {
         $this->AlertAndBack(SUI_SAVE_INFO_WARNING);
         return;
     }
     //更新成功
     $this->TipsAndForward(SUI_UPDATE_SUCCESS, 'index.php?module=user&action=editinfo');
     return;
 }
Ejemplo n.º 23
0
 /**
  * 显示用户的控制面板
  */
 public function run()
 {
     //求得用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     $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']);
     $show_best = $this->getParameter('best');
     if ($show_best) {
         $show_best = 1;
     } else {
         $show_best = 0;
     }
     //取得导航栏菜单
     //开始检查帖子。
     $total_number = LayoutUtil::getTotalNumberTopicByUser($this->db, $user_name, $show_best);
     //求总公的页面
     $total_page = ceil($total_number / $this->page_number);
     //取得当前的页面
     $page = $this->getParameter('page');
     if (!$page || $page < 0) {
         $page = 1;
     }
     if ($page > $total_page && $total_page > 0) {
         $page = $total_page;
     }
     $begin_page = 1;
     $end_page = $total_page;
     if ($page <= 10 && $total_page >= 10) {
         $end_page = 10;
     } else {
         if ($page > 10) {
             if ($page % 10 == 0) {
                 //向前翻
                 $end_page = $page;
                 $begin_page = $end_page - 9;
             } else {
                 if ($page % 10 == 1) {
                     //向后翻
                     //确定开始的页数
                     $begin_page = $page;
                     if ($begin_page > $total_page) {
                         $begin_page = $page - 9;
                     }
                     if ($begin_page + 9 > $total_page) {
                         $end_page = $total_page;
                     } else {
                         $end_page = $begin_page + 9;
                     }
                 } else {
                     $num = $page % 10;
                     $pre_num = floor($page / 10);
                     $begin_page = $pre_num * 10 + 1;
                     $end_page = $begin_page + 9;
                 }
             }
         }
     }
     if ($end_page > $total_page) {
         $end_page = $total_page;
     }
     $nav_page_array = array();
     for ($i = $begin_page; $i <= $end_page; $i++) {
         array_push($nav_page_array, $i);
     }
     //帖子导航栏
     $smarty->assign('nav_page', $nav_page_array);
     //当前的页面
     $smarty->assign('now_page', $page);
     //共有的页面
     $smarty->assign('total_page', $total_page);
     //最新5条发表的主题
     $subject_array = LayoutUtil::getSubjectInfoByUser($this->db, $user_name, $this->page_number, ($page - 1) * $this->page_number, $show_best);
     $smarty->assign('subject', $subject_array);
     $smarty->assign('view_my_best_topic', $show_best);
     $smarty->display('listmytopic.tmpl');
 }
Ejemplo n.º 24
0
 /**
  * 查看帖子
  * @param:  NULL
  * @return: NULL
  * @access: public
  */
 public function run()
 {
     //取得帖子的id
     $topic_id = $this->getParameterFromGET('id');
     $topic_id = (int) $topic_id;
     if (!$topic_id || $topic_id < 1) {
         $this->AlertAndBack(VT_TOPIC_ID_IS_NOT_VALID);
         return;
     }
     //验证帖子的id是否存在
     if (!TopicUtil::isExists($this->db, $topic_id)) {
         $this->AlertAndBack(VT_TOPIC_ID_IS_NOT_EXISTS);
         return;
     }
     //查询帖子的版块id
     $layout_id = TopicUtil::getLayoutId($this->db, $topic_id);
     //验证论坛的版块
     if (!LayoutUtil::isExists($this->db, $layout_id)) {
         $this->AlertAndBack(VT_LAYOUT_IS_NOT_EXISTS);
         return;
     }
     //得出论坛版块的状态
     $layout_status = LayoutUtil::getLayoutStatus($this->db, $layout_id);
     //状态为0则为全部开放
     //状态为1则为需要验证
     //状态为2则为关闭
     //如果为2
     if ($layout_status == 2) {
         $this->AlertAndBack(VT_LAYOUT_IS_CLOSED);
         return;
     } else {
         if ($layout_status == 1) {
             if (!$_SESSION['user']['name']) {
                 $this->AlertAndBack(VT_LAYOUT_NEED_AUTHOR);
                 return;
             }
         }
     }
     //取得帖子的状态
     $topic_status = TopicUtil::getTopicStatus($this->db, $topic_id);
     /**
      * 为0, 则开放
      * 为1, 则需要认证
      * 为2,则关闭
      */
     if ($topic_status == 1) {
         if (!$_SESSION['user']['name']) {
             $this->AlertAndBack(VT_TOPIC_NEED_AUTHOR);
             return;
         }
     }
     //增加帖子的浏览次数
     TopicUtil::updateViewNumber($this->db, $topic_id);
     //取得Smarty的对象
     $smarty = $this->getSmarty();
     //先删除已经不存在的用户
     LayoutUtil::delNotExistsUser($this->db);
     //取得站点的公告,并显示在页面上
     $is_have_post = false;
     $post_str = '';
     if (PostUtil::haveNotExpirePost($this->getDB())) {
         $is_have_post = true;
         $post_array = PostUtil::getPost($this->getDB(), 3);
         foreach ($post_array as $post_rows) {
             $post_str .= '<a href=\'index.php?module=post&action=view&id=' . $post_rows['id'] . '\' title=\'' . $post_rows['title'] . '\'>' . utf8_substr($post_rows['title'], 0, 35) . '</a>' . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
         }
     }
     $smarty->assign('have_system_post', $is_have_post);
     $smarty->assign('post_str', $post_str);
     //求帖子的访问的导航菜单
     $nav_array = LayoutUtil::getParentLayoutInfo($this->db, $layout_id);
     //导航栏
     $smarty->assign('nav_array', $nav_array);
     //求帖子的标题
     $title = TopicUtil::getTitle($this->db, $topic_id);
     $smarty->assign('topic_title', $title);
     $smarty->assign('clone_title', ' -> ' . $title);
     //取得页面
     $page = $this->getParameterFromGET('page');
     if (!$page || $page <= 0) {
         $page = 1;
     }
     //求总的页面
     $total_page = TopicUtil::getTotalPage($this->db, $topic_id, $this->pre_page);
     if ($page > $total_page && $total_page > 0) {
         $page = $total_page;
     }
     //帖子的id和版块的id
     $smarty->assign('topic_id', $topic_id);
     $smarty->assign('bbs_id', $layout_id);
     //页面
     $smarty->assign('now_page', $page);
     $smarty->assign('total_page', $total_page);
     $begin_page = 1;
     $end_page = $total_page;
     if ($page <= 10 && $total_page >= 10) {
         $end_page = 10;
     } else {
         if ($page > 10) {
             if ($page % 10 == 0) {
                 //向前翻
                 $end_page = $page;
                 $begin_page = $end_page - 9;
             } else {
                 if ($page % 10 == 1) {
                     //向后翻
                     //确定开始的页数
                     $begin_page = $page;
                     if ($begin_page > $total_page) {
                         $begin_page = $page - 9;
                     }
                     if ($begin_page + 9 > $total_page) {
                         $end_page = $total_page;
                     } else {
                         $end_page = $begin_page + 9;
                     }
                 } else {
                     $num = $page % 10;
                     $pre_num = floor($page / 10);
                     $begin_page = $pre_num * 10 + 1;
                     $end_page = $begin_page + 9;
                 }
             }
         }
     }
     if ($end_page > $total_page) {
         $end_page = $total_page;
     }
     $nav_page_array = array();
     for ($i = $begin_page; $i <= $end_page; $i++) {
         array_push($nav_page_array, $i);
     }
     //帖子导航栏
     $smarty->assign('nav_page', $nav_page_array);
     $offset_page = ($page - 1) * $this->pre_page;
     $topic_array = TopicUtil::getTopicInfo($this->db, $topic_id, $this->pre_page, $offset_page);
     $smarty->assign('topic', $topic_array);
     //取得当前用户的身份
     $user_name = $_SESSION['user']['name'];
     $user_id = UserUtil::getUserId($this->db, $user_name);
     if (strlen($user_name)) {
         //验证用户的身份
         $sql = 'select group_dep from base_user_info where lower(user_name) =?';
         $sth = $this->db->prepare($sql);
         $res = $this->db->Execute($sth, array(strtolower($user_name)));
         $rows = $res->FetchRow();
         $user_group = $rows['group_dep'];
         if ($user_group == 1 || $user_group == 2) {
             $smarty->assign('can_be_close', 1);
         } else {
             if ($user_group == 3) {
                 $layout_id = TopicUtil::getLayoutId($this->db, $topic_id);
                 $sql = 'select count(*) as num from bbs_layout_manager where user_id=? and ' . ' layout_id=?';
                 $sth = $this->db->prepare($sql);
                 $res = $this->db->Execute($sth, array($user_id, $layout_id));
                 $rows = $res->FetchRow();
                 if (!$rows['num']) {
                     $smarty->assign('can_be_close', 0);
                 } else {
                     $smarty->assign('can_be_close', 1);
                 }
             }
         }
     } else {
         $smarty->assign('can_be_close', 0);
     }
     //加密一个返回的url
     $backurl = 'index.php?module=bbs&action=viewtopic&id=' . $topic_id . '&page=' . $page;
     $backurl = base64_encode($backurl);
     $smarty->assign('backurl', $backurl);
     $smarty->display('viewtopic.tmpl');
 }
Ejemplo n.º 25
0
 /**
  * 显示版面的情况
  * @param:  NULL
  * @return: NULL
  * @access: public
  */
 public function run()
 {
     //取得用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     $smarty = $this->getSmarty();
     //取得站点的公告,并显示在页面上
     $is_have_post = false;
     $post_str = '';
     if (PostUtil::haveNotExpirePost($this->getDB())) {
         $is_have_post = true;
         $post_array = PostUtil::getPost($this->getDB(), 3);
         foreach ($post_array as $post_rows) {
             $post_str .= '<a href=\'index.php?module=post&action=view&id=' . $post_rows['id'] . '\' title=\'' . $post_rows['title'] . '\'>' . utf8_substr($post_rows['title'], 0, 35) . '</a>' . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
         }
     }
     $smarty->assign('have_system_post', $is_have_post);
     $smarty->assign('post_str', $post_str);
     //公告显示结束
     $q = $this->getParameterFromGET('q');
     $encode_q = urlencode($q);
     //取得查询字符串
     if (!$q) {
         $where_sql = '';
         //收集查询的变量
         //按关键字查询
         $word = $this->getParameter('word');
         //按用户名来查询
         $find_user = $this->getParameter('user');
         if (!$find_user && !$word) {
             $this->AlertAndBack(SR_NO_FIND_KEYWORD);
             return;
         }
         $word = ltrim($word);
         $word = rtrim($word);
         //按空格拆分关键字
         $word_array = preg_split("/[\\s,]+/", $word);
         //看用户的搜索是按关键字,还是按帖子的内容
         $is_topic = $this->getParameter('wordtarget');
         if ($is_topic != 1 && $is_topic != 2) {
             $is_topic = 1;
         }
         $i = 0;
         if (count($word_array) > 1) {
             $where_sql .= " and ( ";
             foreach ($word_array as $value) {
                 if ($is_topic == 1) {
                     $where_sql .= " title like '%" . $value . "%' ";
                     if ($i < count($word_array) - 1) {
                         $where_sql .= " or ";
                     }
                 } else {
                     if ($is_topic == 2) {
                         $where_sql .= " MATCH(content) AGAINST('" . $value . "') ";
                         if ($i < count($word_array) - 1) {
                             $where_sql .= " or ";
                         }
                     }
                 }
                 $i = $i + 1;
             }
             $where_sql .= " )  ";
         } else {
             if (count($word_array) == 1 && $word) {
                 if ($is_topic == 1) {
                     $where_sql .= " and title like '%" . $word . "%' ";
                 } else {
                     if ($is_topic == 2) {
                         $where_sql .= " and match(content) against('" . $word . "')";
                     }
                 }
             }
         }
         //是按用户名来搜索的
         //收集用户名
         $find_user = ltrim($find_user);
         $find_user = rtrim($find_user);
         $find_user_array = preg_split("/[\\s,]+/", $find_user);
         $is_match = $this->getParameter('usermatch');
         $i = 0;
         if (count($find_user_array) > 1) {
             $where_sql .= " and ( ";
             foreach ($find_user_array as $value) {
                 if ($is_match) {
                     $where_sql .= " author='" . $value . "' ";
                     if ($i < count($find_user_array) - 1) {
                         $where_sql .= " or ";
                     }
                 } else {
                     $where_sql .= " author like '%" . $value . "%' ";
                     if ($i < count($find_user_array) - 1) {
                         $where_sql .= " or ";
                     }
                 }
                 $i = $i + 1;
             }
             $where_sql .= " )  ";
         } else {
             if (count($find_user_array) == 1 && $find_user) {
                 if ($is_match) {
                     $where_sql .= " and author ='" . $find_user . "' ";
                 } else {
                     $where_sql .= " and author like '%" . $find_user . "%' ";
                 }
             }
         }
         //再收集用户是否选择了论坛进行搜索。
         $layout = $this->getParameterFromPOST('layout');
         if ($layout && !is_array($layout)) {
             $this->AlertAndBack(SR_SYSTEM_REQUEST_ERROR);
             return;
         }
         $i = 0;
         if (count($layout) > 1) {
             $where_sql .= " and ( ";
             foreach ($layout as $value) {
                 $where_sql .= " layout_id='" . $value . "' ";
                 if ($i < count($layout) - 1) {
                     $where_sql .= " or ";
                 }
                 $i = $i + 1;
             }
             $where_sql .= " ) ";
         } else {
             if (count($layout) == 1) {
                 $where_sql .= " and layout_id='" . $layout . "' ";
             }
         }
         $q = ' where 1 ' . $where_sql;
         $encode_q = base64_encode($q);
         $encode_q = urlencode($encode_q);
     } else {
         //         $q = urldecode($q);
         $q = base64_decode($q);
     }
     //求总的total number
     $smarty->assign('encode_q', $encode_q);
     //生成所有的记录数
     $sql = 'select count(*) as num from bbs_subject ' . $q;
     $res = $this->db->Execute($sql);
     $rows = $res->FetchRow();
     $total_number = $rows['num'];
     //求总公的页面
     $total_page = ceil($total_number / $this->page_number);
     //取得当前的页面
     $page = $this->getParameter('page');
     if (!$page || $page < 0) {
         $page = 1;
     }
     if ($page > $total_page && $total_page > 0) {
         $page = $total_page;
     }
     $begin_page = 1;
     $end_page = $total_page;
     if ($page <= 10 && $total_page >= 10) {
         $end_page = 10;
     } else {
         if ($page > 10) {
             if ($page % 10 == 0) {
                 //向前翻
                 $end_page = $page;
                 $begin_page = $end_page - 9;
             } else {
                 if ($page % 10 == 1) {
                     //向后翻
                     //确定开始的页数
                     $begin_page = $page;
                     if ($begin_page > $total_page) {
                         $begin_page = $page - 9;
                     }
                     if ($begin_page + 9 > $total_page) {
                         $end_page = $total_page;
                     } else {
                         $end_page = $begin_page + 9;
                     }
                 } else {
                     $num = $page % 10;
                     $pre_num = floor($page / 10);
                     $begin_page = $pre_num * 10 + 1;
                     $end_page = $begin_page + 9;
                 }
             }
         }
     }
     if ($end_page > $total_page) {
         $end_page = $total_page;
     }
     $nav_page_array = array();
     for ($i = $begin_page; $i <= $end_page; $i++) {
         array_push($nav_page_array, $i);
     }
     //帖子导航栏
     $smarty->assign('nav_page', $nav_page_array);
     //当前的页面
     $smarty->assign('now_page', $page);
     //共有的页面
     $smarty->assign('total_page', $total_page);
     //显示搜索结果
     //求出偏移
     $offset_number = ($page - 1) * $this->page_number;
     $subject_array = LayoutUtil::getCacheSubjectInfo($this->db, $this->page_number, $offset_number, $q);
     if ($total_page > 0) {
         $smarty->assign('subject', $subject_array);
         $smarty->assign('have_subject', 1);
     }
     $smarty->display('bbssearchresult.tmpl');
 }
Ejemplo n.º 26
0
 /**
  * 显示用户发送短信的界面
  */
 public function run()
 {
     //求得用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     $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']);
     $fck = new FCKeditor("content");
     $fck->BasePath = FCKEDITOR_BASEPATH;
     $fck->ToolbarSet = 'Basic';
     $fck->Height = '400';
     $fck->Width = '98%';
     $smarty->assign('fck', $fck);
     //检查用户是否传入了id
     //如果传入了id,则为其预填需要
     //发送的的用户名
     $send_user_id = $this->getParameter('id');
     $send_user_name = UserUtil::getUserNameById($this->db, $send_user_id);
     $smarty->assign('send_user_name', $send_user_name);
     $smarty->assign('backurl', $this->getParameter('backurl'));
     $smarty->display('showsend.tmpl');
 }
Ejemplo n.º 27
0
 /**
  * 取得查询后的帖子的情况
  * @param:  &$id Database Connection
  * @param:  $id 论坛板块的id
  * @return; array
  * @acess:  public
  * @static
  */
 public static function &getCacheSubjectInfo(&$db, $pre_page, $offset_page, $q)
 {
     /*{{{*/
     $sql = 'select id, title, author, subject_status, express, is_best, click_number, reply_number,' . ' last_access_date from bbs_subject ' . $q . ' order by last_access_date desc';
     $info_array = array();
     $res = $db->CacheSelectLimit(1800, $sql, $pre_page, $offset_page);
     $now_user_id = UserUtil::getUserId($db, $_SESSION['user']['name']);
     while ($rows = $res->FetchRow()) {
         $user_id = UserUtil::getUserId($db, $rows['author']);
         //看状态。
         //==0, 开放
         //==1, 需要验证
         //==2, 帖子被关闭
         //如果被关闭,则不需看是否有新帖
         $status_image = 'no_topic.gif';
         if ($rows['subject_status'] == 2) {
             $status_image = 'topic_lock.gif';
         } else {
             if (!isset($_SESSION['user'])) {
                 $status_iamge = 'no_topic.gif';
             } else {
                 if (TopicUtil::haveNewReply($db, $rows['id'], $now_user_id)) {
                     $status_image = 'new_topic.gif';
                 } else {
                     $status_image = 'no_topic.gif';
                 }
             }
         }
         $last_user_name = '';
         $last_user_id = '';
         $total_page = 0;
         $find_number = 0;
         if ($rows['reply_number'] > 0) {
             $temp_sql = 'select author from bbs_reply where subject_id=? order by id desc ';
             $temp_res = $db->SelectLimit($temp_sql, 1, 0, array($rows['id']));
             $temp_rows = $temp_res->FetchRow();
             $last_user_name = $temp_rows['author'];
             $last_user_id = UserUtil::getUserId($db, $last_user_name);
             $temp_sql = 'select count(*) as num from bbs_reply where subject_id=?';
             $temp_sth = $db->Prepare($temp_sql);
             $temp_res = $db->Execute($temp_sth, array($rows['id']));
             $temp_rows = $temp_res->FetchRow();
             $total_number = $temp_rows['num'];
             $total_page = ceil(($total_number + 1) / 10);
             if ($total_page > 10) {
                 $find_number = ($total_number + 1) % 10;
             } else {
                 $find_number = $total_number + 1;
             }
         }
         $temp_sql = 'select count(*) as num from bbs_subject_attach where subject_id=?';
         $temp_sth = $db->Prepare($temp_sql);
         $temp_res = $db->Execute($temp_sth, array($rows['id']));
         $temp_rows = $temp_res->FetchRow();
         $is_have_attach = $temp_rows['num'];
         $title = "";
         if ($rows['is_best']) {
             $title .= "&nbsp;<font color=red>[" . LU_IS_BEST . "]</font>";
         }
         $title .= $rows['title'];
         $info_array[] = array('image' => $status_image, 'id' => $rows['id'], 'title' => $title, 'have_new_reply' => $status_image == 'new_topic.gif' ? 1 : 0, 'userid' => $user_id, 'username' => $rows['author'], 'clicks_number' => $rows['click_number'], 'reply_number' => $rows['reply_number'], 'last_time' => set_locale_time($rows['last_access_date']), 'last_username' => $last_user_name, 'last_userid' => $last_user_id, 'last_page' => $total_page, 'last_number' => $find_number, 'have_attach' => $is_have_attach, 'express' => $rows['express']);
     }
     return $info_array;
 }
Ejemplo n.º 28
0
 /**
  * 显示用户的控制面板
  */
 public function run()
 {
     //求得用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     $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 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 = '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']);
     //最新的5条短消息
     $sql = 'select a.id, a.user_id, b.user_name,a.send_user_id, ' . 'a.title, a.receive_time, a.is_read ' . ' from message_inbox as a, base_user_info as b  where a.send_user_id = b.id and a.user_id=? ' . ' order by a.id desc';
     $stmt = $this->db->prepare($sql);
     $res = $this->db->CacheSelectLimit(20, $stmt, 5, 1, array($user_id));
     $rows = $res->GetArray();
     $smarty->assign('msg', $rows);
     //最新5条发表的主题
     $subject_array = LayoutUtil::getSubjectInfoByUser($this->db, $user_name);
     $smarty->assign('subject', $subject_array);
     //最新参与的5条主题
     $reply_array = LayoutUtil::getReplyInfoByUser($this->db, $user_name);
     $smarty->assign('reply', $reply_array);
     //最新的5条收藏
     $favor_array = LayoutUtil::getSubjectInfoByFavor($this->db, $user_id);
     $smarty->assign('favor', $favor_array);
     $smarty->display('usercontrol.tmpl');
 }
Ejemplo n.º 29
0
?>
">首页</a></li>
                <li><a href="<?php 
echo UrlUtil::createUrl('project/index');
?>
" target="_blank">网站首页</a></li>
            </ul>
        </div>
        <div class="top-info-wrap">
            <ul class="top-info-list clearfix">
                <li><a><?php 
echo UserUtil::getUserName();
?>
</a></li>
                <li><a href="<?php 
echo UrlUtil::createBackendUrl('user/changePassword/' . UserUtil::getUserId());
?>
">修改密码</a></li>
                <li><a href="<?php 
echo UrlUtil::createBackendUrl('login/logout');
?>
">退出</a></li>
            </ul>
        </div>
    </div>
</div>
<div class="container clearfix">
    <div class="sidebar-wrap">
        <div class="sidebar-title">
            <h1>菜单</h1>
        </div>
Ejemplo n.º 30
0
 /**
  * 显示短消息的内容
  * @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');
 }