Ejemplo n.º 1
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');
     $user_data['id'] = intval($user_data['id']);
     $uid = intval($user_data['id']);
     if ($uid == 0) {
         $root['return'] = 0;
         $root['info'] = "请先登陆";
         output($root);
     }
     $page = intval($GLOBALS['request']['page']);
     if ($page == 0) {
         $page = 1;
     }
     $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE;
     //输出回复
     $sql = "select r.* from " . DB_PREFIX . "topic_reply as r left join " . DB_PREFIX . "topic as t on r.topic_id = t.id \r\n\t\t\t\twhere (t.user_id = " . $uid . " or r.user_id = " . $uid . ") and r.is_effect = 1 and r.is_delete = 0 \r\n\t\t\t\torder by r.create_time desc limit " . $limit;
     $sql_count = "select count(*) from " . DB_PREFIX . "topic_reply as r left join " . DB_PREFIX . "topic as t on r.topic_id = t.id \r\n\t\t\t\twhere (t.user_id = " . $uid . " or r.user_id = " . $uid . ") and r.is_effect = 1 and r.is_delete = 0";
     $list = $GLOBALS['db']->getAll($sql);
     $total = $GLOBALS['db']->getOne($sql_count);
     $comment_list = array();
     foreach ($list as $k => $v) {
         $comment_list[$k]['comment_id'] = $v['id'];
         $comment_list[$k]['share_id'] = $v['topic_id'];
         $comment_list[$k]['uid'] = $v['user_id'];
         $comment_list[$k]['parent_id'] = $v['reply_id'];
         $comment_list[$k]['content'] = $v['content'];
         $comment_list[$k]['create_time'] = $v['create_time'];
         $topic = $GLOBALS['db']->getRow("select user_name,content from " . DB_PREFIX . "topic where id = " . $v['topic_id']);
         $comment_list[$k]['scontent'] = "//@" . $topic['user_name'] . ":" . $topic['content'];
         $comment_list[$k]['user_name'] = $v['user_name'];
         $comment_list[$k]['user_avatar'] = get_abs_img_root(get_muser_avatar($v['user_id'], "big"));
         $comment_list[$k]['time'] = pass_date($v['create_time']);
         $comment_list[$k]['parse_expres'] = get_parse_expres($comment_list[$k]['content'] . $comment_list[$k]['scontent']);
         $comment_list[$k]['parse_user'] = get_parse_user($comment_list[$k]['content'] . $comment_list[$k]['scontent']);
     }
     $root['item'] = $comment_list;
     $root['page'] = array("page" => $page, "page_total" => ceil($total / PAGE_SIZE));
     $root['return'] = 1;
     output($root);
 }
Ejemplo n.º 2
0
function m_get_topic_item($topic)
{
    $share_item['share_id'] = $topic['id'];
    $share_item['uid'] = $topic['user_id'];
    $share_item['user_name'] = $topic['user_name'];
    if ($topic['fav_id'] > 0) {
        $share_item['content'] = "我喜欢这个,谢谢你的分享[爱心]";
    } else {
        $share_item['content'] = $topic['content'];
    }
    $share_item['share_content'] = msubstr($topic['content']) . get_domain() . str_replace("sjmapi/", "", url("index", "topic", array("id" => $topic['id'])));
    $share_item['collect_count'] = $topic['fav_count'];
    $share_item['comment_count'] = $topic['reply_count'];
    $share_item['relay_count'] = $topic['relay_count'];
    $share_item['click_count'] = $topic['click_count'];
    $share_item['title'] = $topic['title'];
    $share_item['type'] = 'default';
    $share_item['share_data'] = 'photo';
    if ($topic['source_type'] == 0) {
        $source_name = "来自" . app_conf("SHOP_TITLE") . $topic['source_name'];
    } else {
        $source_name = "来自" . $topic['source_name'];
    }
    $share_item['source'] = $source_name;
    $share_item['time'] = pass_date($topic['create_time']);
    $share_item['parse_expres'] = get_parse_expres($topic['content']);
    $share_item['parse_user'] = get_parse_user($topic['content']);
    $share_item['user_avatar'] = get_abs_img_root(get_muser_avatar($topic['user_id'], "big"));
    $share_item['imgs'] = m_get_topic_list_img($topic);
    if ($topic['fav_id'] > 0 || $topic['relay_id'] > 0) {
        $share_item['is_relay'] = 1;
    }
    $share_item['user'] = array("uid" => $topic['user_id'], "user_name" => $topic['user_name'], "user_avatar" => $share_item['user_avatar']);
    return $share_item;
}