示例#1
0
 public function index()
 {
     require_once APP_ROOT_PATH . "system/model/user.php";
     $email = strim($GLOBALS['request']['email']);
     $pwd = strim($GLOBALS['request']['pwd']);
     $root = array();
     $user_data = $GLOBALS['user_info'];
     $user_data['id'] = intval($user_data['id']);
     $uid = intval($user_data['id']);
     if ($uid == 0) {
         $root['info'] = "请先登陆";
         $root['return'] = 2;
         output($root);
     }
     $page = intval($GLOBALS['request']['page']);
     if ($page == 0) {
         $page = 1;
     }
     $user_info['uid'] = $user_data['id'];
     $user_info['email'] = $user_data['email'];
     $user_info['user_name'] = $user_data['user_name'];
     $user_info['user_avatar'] = get_abs_img_root(get_muser_avatar($user_data['id'], "big"));
     $root['home_user'] = $root['user'] = $user_info;
     //关注的用户ID
     $uids = $GLOBALS['db']->getOne("select group_concat(focused_user_id) from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_data['id'] . " order by rand() limit 50");
     if ($uids) {
         $uids .= ",0";
     } else {
         $uids = "0";
     }
     $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE;
     $topic_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and user_id in (" . $uids . ") order by create_time desc limit " . $limit);
     $total = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and user_id in (" . $uids . ") ");
     foreach ($topic_list as $k => $v) {
         $topic_list[$k] = m_get_topic_item($v);
         if ($v['fav_id'] > 0 || $v['relay_id'] > 0) {
             $relay_share = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and id = " . $v['origin_id']);
         }
         if ($relay_share) {
             $topic_list[$k]['relay_share'] = m_get_topic_item($relay_share);
         }
     }
     $root['return'] = 1;
     $root['item'] = $topic_list;
     $root['page'] = array("page" => $page, "page_total" => ceil($total / PAGE_SIZE), "page_size" => PAGE_SIZE);
     output($root);
 }
示例#2
0
 public function index()
 {
     require_once APP_ROOT_PATH . "system/libs/user.php";
     $email = strim($GLOBALS['request']['email']);
     $pwd = strim($GLOBALS['request']['pwd']);
     $result = do_login_user($email, $pwd);
     $user_data = es_session::get('user_info');
     $uid = intval($user_data['id']);
     if ($uid == 0) {
         $root['info'] = "请先登陆";
         output($root);
     }
     $page = intval($GLOBALS['request']['page']);
     if ($page == 0) {
         $page = 1;
     }
     $user_info['uid'] = $user_data['id'];
     $user_info['email'] = $user_data['email'];
     $user_info['user_name'] = $user_data['user_name'];
     $user_info['user_avatar'] = get_abs_img_root(get_muser_avatar($user_data['id'], "big"));
     $root['home_user'] = $root['user'] = $user_info;
     $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE;
     $user_name = $user_data['user_name'];
     $user_name_unicode = str_to_unicode_string($user_name);
     $condition = " match(user_name_match) against('" . $user_name_unicode . "' IN BOOLEAN MODE) ";
     $topic_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and " . $condition . " order by create_time desc limit " . $limit);
     $total = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and " . $condition);
     foreach ($topic_list as $k => $v) {
         $topic_list[$k] = m_get_topic_item($v);
         if ($v['fav_id'] > 0 || $v['relay_id'] > 0) {
             $relay_share = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and id = " . $v['origin_id']);
         }
         if ($relay_share) {
             $topic_list[$k]['relay_share'] = m_get_topic_item($relay_share);
         }
     }
     $root = array();
     $root['return'] = 1;
     $root['item'] = $topic_list;
     $root['page'] = array("page" => $page, "page_total" => ceil($total / PAGE_SIZE));
     output($root);
 }
示例#3
0
文件: u.action.php 项目: macall/jsd
 public function index()
 {
     require_once APP_ROOT_PATH . "system/model/user.php";
     $root = array();
     $user_data = $GLOBALS['user_info'];
     if (!$user_data) {
         $root['info'] = "非法的会员1";
         output($root);
     }
     $uid = intval($user_data['id']);
     $home_uid = intval($GLOBALS['request']['uid']);
     if ($home_uid == 0) {
         $home_uid = $uid;
     }
     $sql = "select * from " . DB_PREFIX . "user where id = " . $home_uid . " and is_effect = 1 and is_delete = 0";
     $home_user_info_data = $GLOBALS['db']->getRow($sql);
     if (!$home_user_info_data) {
         $root['info'] = "非法的会员2" . $sql;
         output($root);
     }
     if (strim($GLOBALS['request']['from'] == 'wap')) {
         if (!$email) {
             $root['info'] = "请先登陆";
             output($root);
         }
     }
     $page = intval($GLOBALS['request']['page']);
     if ($page == 0) {
         $page = 1;
     }
     $root = array();
     $user_info['uid'] = $user_data['id'] = intval($user_data['id']);
     $user_info['email'] = $user_data['email'];
     $user_info['user_name'] = $user_data['user_name'];
     $user_info['user_avatar'] = get_abs_img_root(get_muser_avatar($user_data['id'], "small"));
     $root['user'] = $user_info;
     $home_user_info['uid'] = $home_user_info_data['id'];
     $home_user_info['email'] = $home_user_info_data['email'];
     $home_user_info['user_name'] = $home_user_info_data['user_name'];
     $home_user_info['user_avatar'] = get_abs_img_root(get_muser_avatar($home_user_info_data['id'], "small"));
     $home_user_info['fans'] = $home_user_info_data['focused_count'];
     $home_user_info['follows'] = $home_user_info_data['focus_count'];
     $home_user_info['photos'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic_image where user_id = " . $home_user_info_data['id']);
     $home_user_info['favs'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic where user_id = " . $home_user_info_data['id'] . " and fav_id <> 0 and is_delete = 0 and is_effect = 1");
     $home_user_info['goods'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic where user_id = " . $home_user_info_data['id'] . " and topic_group = 'Fanwe' and is_delete = 0 and is_effect = 1");
     $home_user_info['bfavs'] = $GLOBALS['db']->getOne("select sum(fav_count) from " . DB_PREFIX . "topic where user_id = " . $home_user_info_data['id'] . " and is_delete = 0 and is_effect = 1");
     if ($user_info['uid'] == $home_user_info['uid']) {
         $home_user_info['is_follow'] = -1;
     } else {
         $focus_uid = intval($home_user_info['uid']);
         $focus_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_info['uid'] . " and focused_user_id = " . $focus_uid);
         if ($focus_data) {
             $home_user_info['is_follow'] = 1;
         } else {
             $home_user_info['is_follow'] = 0;
         }
     }
     $root['home_user'] = $home_user_info;
     //关注的用户ID
     $uids = $GLOBALS['db']->getOne("select group_concat(focused_user_id) from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_data['id'] . " order by rand() limit 50");
     $uids .= ",0";
     $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE;
     $topic_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and user_id =" . $home_user_info_data['id'] . " order by create_time desc limit " . $limit);
     $total = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and user_id =" . $home_user_info_data['id']);
     foreach ($topic_list as $k => $v) {
         $topic_list[$k] = m_get_topic_item($v);
         if ($v['fav_id'] > 0 || $v['relay_id'] > 0) {
             $relay_share = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and id = " . $v['origin_id']);
         }
         if ($relay_share) {
             $topic_list[$k]['relay_share'] = m_get_topic_item($relay_share);
         }
     }
     $root['return'] = 1;
     $root['item'] = $topic_list;
     $root['page'] = array("page" => $page, "page_total" => ceil($total / PAGE_SIZE), "page_size" => PAGE_SIZE);
     output($root);
 }
示例#4
0
 public function index()
 {
     require_once APP_ROOT_PATH . "system/libs/user.php";
     $email = strim($GLOBALS['request']['email']);
     $pwd = strim($GLOBALS['request']['pwd']);
     $id = intval($GLOBALS['request']['share_id']);
     $result = do_login_user($email, $pwd);
     $GLOBALS['user_info'] = $user_data = es_session::get('user_info');
     $user_data['id'] = intval($user_data['id']);
     $act2 = strim($GLOBALS['request']['act_2']);
     $source = strim($GLOBALS['request']['source']);
     $source = str_replace("来自", "", $source);
     $topic = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "topic where id = " . $id);
     if ($topic) {
         switch ($act2) {
             case 'follow':
                 //开始关注
                 $user_id = intval($user_data['id']);
                 $focus_uid = intval($topic['user_id']);
                 if ($user_id != $focus_uid) {
                     $focus_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_id . " and focused_user_id = " . $focus_uid);
                     if (!$focus_data && $user_id > 0 && $focus_uid > 0) {
                         $focused_user_name = $GLOBALS['db']->getOne("select user_name from " . DB_PREFIX . "user where id = " . $focus_uid);
                         $focus_data = array();
                         $focus_data['focus_user_id'] = $user_id;
                         $focus_data['focused_user_id'] = $focus_uid;
                         $focus_data['focus_user_name'] = $GLOBALS['user_info']['user_name'];
                         $focus_data['focused_user_name'] = $focused_user_name;
                         $GLOBALS['db']->autoExecute(DB_PREFIX . "user_focus", $focus_data, "INSERT");
                         $GLOBALS['db']->query("update " . DB_PREFIX . "user set focus_count = focus_count + 1 where id = " . $user_id);
                         $GLOBALS['db']->query("update " . DB_PREFIX . "user set focused_count = focused_count + 1 where id = " . $focus_uid);
                     } elseif ($focus_data && $user_id > 0 && $focus_uid > 0) {
                         $GLOBALS['db']->query("delete from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_id . " and focused_user_id = " . $focus_uid);
                         $GLOBALS['db']->query("update " . DB_PREFIX . "user set focus_count = focus_count - 1 where id = " . $user_id);
                         $GLOBALS['db']->query("update " . DB_PREFIX . "user set focused_count = focused_count - 1 where id = " . $focus_uid);
                     }
                 }
                 //开始关注
                 break;
             case 'collect':
                 //开始喜欢
                 if ($topic['user_id'] != intval($user_data['id'])) {
                     $fav_topic = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "topic where fav_id = " . $id . " and user_id = " . intval($user_data['id']));
                     if ($fav_topic) {
                         $GLOBALS['db']->query("delete from " . DB_PREFIX . "topic where id = " . $fav_topic['id']);
                         $GLOBALS['db']->query("update " . DB_PREFIX . "topic set fav_count = fav_count - 1 where id = " . $id);
                         if ($id != $topic['origin_id']) {
                             $GLOBALS['db']->query("update " . DB_PREFIX . "topic set fav_count = fav_count - 1 where id = " . $topic['origin_id']);
                         }
                         $GLOBALS['db']->query("delete from " . DB_PREFIX . "topic_image where topic_id = " . $fav_topic['id']);
                         $topic['fav_count'] -= 1;
                     } else {
                         $tid = insert_topic($cnt = "", $title = "", $type = "", $group = "", $r = 0, $f = $id);
                         if ($tid) {
                             $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '" . $source . "' where id = " . intval($tid));
                         }
                         $topic['fav_count'] += 1;
                     }
                 }
                 //end喜欢
                 break;
         }
         $share_item = m_get_topic_item($topic);
         if ($topic['user_id'] == $user_data['id']) {
             $share_item['is_follow_user'] = -1;
         } else {
             $focus_uid = intval($topic['user_id']);
             $focus_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_data['id'] . " and focused_user_id = " . $focus_uid);
             if ($focus_data) {
                 $share_item['is_follow_user'] = 1;
             } else {
                 $share_item['is_follow_user'] = 0;
             }
             $share_item['is_collect_share'] = $GLOBALS['db']->getOne("select count(id) from " . DB_PREFIX . "topic where fav_id = " . $topic['id'] . " and user_id = " . $user_data['id']);
         }
         $share_item['comments'] = m_get_topic_reply($topic['id'], 1);
         $share_item['collects'] = m_get_topic_fav($topic['id']);
         $share_item['imgs'] = m_get_topic_img($topic);
         $root = array();
         $root['return'] = 1;
         $root['item'] = $share_item;
     } else {
         $root['return'] = 0;
     }
     output($root);
 }