public function run()
    {
        global $_FANWE;
        $root = array();
        $root['return'] = 1;
        $share_id = (int) $_FANWE['requestData']['share_id'];
        $page = (int) $_FANWE['requestData']['page'];
        $page = max(1, $page);
        $sql_count = "SELECT COUNT(DISTINCT comment_id) FROM " . FDB::table("share_comment") . " WHERE share_id = " . $share_id;
        $total = FDB::resultFirst($sql_count);
        $page_size = PAGE_SIZE;
        $page_total = ceil($total / $page_size);
        if ($page > $page_total) {
            $page = $page_total;
        }
        $limit = ($page - 1) * $page_size . "," . $page_size;
        $sql = 'SELECT c.*,u.user_name,u.server_code FROM ' . FDB::table('share_comment') . ' AS c 
			INNER JOIN ' . FDB::table('user') . ' AS u ON u.uid = c.uid 
			WHERE c.share_id = ' . $share_id . ' ORDER BY c.comment_id DESC LIMIT ' . $limit;
        $res = FDB::query($sql);
        $list = array();
        while ($item = FDB::fetch($res)) {
            $item['user_avatar'] = avatar($item['uid'], 'm', $item['server_code'], 1, true);
            $item['time'] = getBeforeTimelag($item['create_time']);
            m_express(&$item, $item['content']);
            $list[] = $item;
        }
        $root['item'] = $list;
        $root['page'] = array("page" => $page, "page_total" => $page_total);
        m_display($root);
    }
 public function index()
 {
     $merchant_id = intval($GLOBALS['request']['merchant_id']);
     /*商家ID*/
     $page = intval($GLOBALS['request']['page']);
     /*分页*/
     //检查用户,用户密码
     $user = $GLOBALS['user_info'];
     $user_id = intval($user['id']);
     $root = array();
     $root['return'] = 1;
     $page = $page == 0 ? 1 : $page;
     $page_size = PAGE_SIZE;
     $limit = ($page - 1) * $page_size . "," . $page_size;
     $supplier_locationinfo = $GLOBALS['db']->getRow("select name,id,new_dp_count_time from " . DB_PREFIX . "supplier_location where id = " . $merchant_id);
     syn_supplier_locationcount($supplier_locationinfo);
     $condition = " dp.status = 1 and dp.supplier_location_id = " . $merchant_id . " ";
     $sql_count = "select count(*) from " . DB_PREFIX . "supplier_location_dp dp where " . $condition;
     $total = $GLOBALS['db']->getOne($sql_count);
     $page_total = ceil($total / $page_size);
     //$root['sql_count'] = $sql_count;
     $sql = "select dp.*,u.user_name from " . DB_PREFIX . "supplier_location_dp as dp left outer join " . DB_PREFIX . "user as u on u.id = dp.user_id  where " . $condition . " order by dp.is_top desc, dp.create_time desc limit " . $limit;
     $root['sql'] = $sql;
     $list = $GLOBALS['db']->getAll($sql);
     foreach ($list as $k => $v) {
         $list[$k]['merchant_id'] = $v['supplier_location_id'];
         $list[$k]['create_time_format'] = getBeforeTimelag($v['create_time']);
         $list[$k]['width'] = $v['point'] / 5 * 100;
     }
     //星级点评数
     $root['star_1'] = 0;
     $root['star_2'] = 0;
     $root['star_3'] = 0;
     $root['star_4'] = 0;
     $root['star_5'] = 0;
     $root['star_dp_width_1'] = 0;
     $root['star_dp_width_2'] = 0;
     $root['star_dp_width_3'] = 0;
     $root['star_dp_width_4'] = 0;
     $root['star_dp_width_5'] = 0;
     $buy_dp_sum = 0.0;
     $buy_dp_group = $GLOBALS['db']->getAll("select point,count(*) as num from " . DB_PREFIX . "supplier_location_dp where supplier_location_id = " . $merchant_id . " group by point");
     foreach ($buy_dp_group as $dp_k => $dp_v) {
         $star = intval($dp_v['point']);
         if ($star >= 1 && $star <= 5) {
             $root['star_' . $star] = $dp_v['num'];
             $buy_dp_sum += $star * $dp_v['num'];
             $root['star_dp_width_' . $star] = round($dp_v['num'] / $total, 1) * 100;
         }
     }
     //点评平均分
     $root['buy_dp_sum'] = $buy_dp_sum;
     $root['buy_dp_avg'] = round($buy_dp_sum / $total, 1);
     $root['buy_dp_width'] = round($buy_dp_sum / $total, 1) / 5 * 100;
     $root['page'] = array("page" => $page, "page_total" => $page_total, "page_size" => $page_size);
     $root['message_list'] = $list;
     $root['merchant_id'] = $merchant_id;
     $root['page_title'] = "点评列表";
     output($root);
 }
    public function run()
    {
        global $_FANWE;
        $root = array();
        $root['return'] = 0;
        $uid = $_FANWE['uid'];
        if ($uid == 0) {
            $root['info'] = "请先登陆";
            m_display($root);
        }
        $root['home_user'] = $_FANWE['user'];
        FDB::query("DELETE FROM " . FDB::table('user_notice') . " WHERE uid='{$uid}' AND type=3");
        $page = (int) $_FANWE['requestData']['page'];
        $page = max(1, $page);
        $sql = 'SELECT COUNT(sc.comment_id)
			FROM ' . FDB::table("share") . ' AS s
			INNER JOIN ' . FDB::table("share_comment") . ' AS sc ON sc.share_id = s.share_id
			WHERE  s.uid = ' . $uid;
        $total = FDB::resultFirst($sql);
        $page_size = PAGE_SIZE;
        $page_total = max(1, ceil($total / $page_size));
        if ($page > $page_total) {
            $page = $page_total;
        }
        $limit = ($page - 1) * $page_size . "," . $page_size;
        $comment_list = array();
        $sql = 'SELECT sc.*,s.content as scontent,u.user_name,u.server_code 
			FROM ' . FDB::table("share") . ' AS s
			INNER JOIN ' . FDB::table("share_comment") . ' AS sc ON sc.share_id = s.share_id 
			INNER JOIN ' . FDB::table("user") . ' AS u ON u.uid = sc.uid 
			WHERE s.uid = ' . $uid . '
			ORDER BY comment_id DESC LIMIT ' . $limit;
        $res = FDB::query($sql);
        while ($data = FDB::fetch($res)) {
            $data['user_avatar'] = FS("Image")->getImageUrl('.' . avatar($data['uid'], 'm', 1), 2);
            $data['time'] = getBeforeTimelag($data['create_time']);
            $data['url'] = FU('note/index', array('sid' => $data['share_id']), true);
            m_express(&$data, $data['content'] . $data['scontent']);
            $comment_list[] = $data;
        }
        $root['return'] = 1;
        $root['item'] = $comment_list;
        $root['page'] = array("page" => $page, "page_total" => $page_total);
        m_display($root);
    }
 public function run()
 {
     global $_FANWE;
     $root = array();
     $root['return'] = 1;
     //未登陆直接退出
     if ($_FANWE['uid'] == 0) {
         $root['status'] = -1;
         m_display($root);
     }
     $share_id = (int) $_FANWE['requestData']['share_id'];
     //没有分享ID直接退出
     if ($share_id == 0) {
         $root['status'] = -2;
         m_display($root);
     }
     $share = FS('Share')->getShareById($share_id);
     //没有分享直接退出
     if (empty($share)) {
         $root['status'] = -3;
         m_display($root);
     }
     $check_result = FS('Share')->checkWord($_FANWE['requestData']['content'], 'content');
     if ($check_result['error_code'] == 1) {
         $root['status'] = -4;
         $root['error'] = $check_result['error_msg'];
         m_display($root);
     }
     $comment_id = FS('Share')->saveComment($_FANWE['requestData']);
     $comment = FS('Share')->getShareComment($comment_id);
     $comment['time'] = getBeforeTimelag($comment['create_time']);
     $parses = m_express(&$item['content']);
     $comment['parse_users'] = $parses['users'];
     $comment['parse_events'] = $parses['events'];
     $comment['user_name'] = $_FANWE['user_name'];
     $comment['user_avatar'] = $_FANWE['user_avatar'];
     $root['status'] = 1;
     $root['item'] = $comment;
     m_display($root);
 }
Example #5
0
    /**
     * 热门有图活动主题
     * @return array
     */
    public function getHotImgEvent($num)
    {
        global $_FANWE;
        $list = array();
        $sql = 'SELECT e.id,e.title,e.uid,e.thread_count,e.create_time,e.last_share,e.last_time,e.share_id,
			s.content,s.cache_data 
			FROM ' . FDB::table('event') . ' AS e 
			INNER JOIN ' . FDB::table('share') . ' AS s ON s.share_id = e.share_id
				AND s.share_data IN (\'goods\',\'photo\',\'goods_photo\')
			WHERE e.is_event = 1 ORDER BY e.is_hot DESC,e.thread_count DESC LIMIT 0,' . $num;
        $res = FDB::query($sql);
        while ($data = FDB::fetch($res)) {
            $data['cache_data'] = fStripslashes(unserialize($data['cache_data']));
            $data['time'] = getBeforeTimelag($data['create_time']);
            $data['last_time'] = getBeforeTimelag($data['last_time']);
            $data['url'] = FU('event/detail', array('id' => $data['id']));
            FS('Share')->shareImageFormat($data);
            unset($data['cache_data']);
            $list[$data['share_id']] = $data;
        }
        return $list;
    }
Example #6
0
    public function index()
    {
        global $_FANWE;
        if ($_FANWE['setting']['second_status'] == 0) {
            fHeader("location: " . FU('index'));
        }
        $sid = (int) $_FANWE['request']['sid'];
        $cid = (int) $_FANWE['request']['cid'];
        $where = ' WHERE s.status = 1 AND sg.status = 1 ';
        $page_args = array();
        if ($sid > 0 && isset($_FANWE['cache']['seconds'][$sid])) {
            $where .= ' AND sg.sid = ' . $sid;
            $page_args['sid'] = $sid;
        } else {
            $sid = 0;
        }
        if ($cid > 0 && isset($_FANWE['cache']['citys']['all'][$cid])) {
            $where .= ' AND sg.city_id = ' . $cid;
            $page_args['cid'] = $cid;
        } else {
            $cid = 0;
        }
        $seconds = array();
        $citys = array();
        $temp_args = $page_args;
        foreach ($_FANWE['cache']['seconds'] as $second) {
            if ($second['sid'] == $sid) {
                $_FANWE['nav_title'] = $second['name'] . ' - ' . $_FANWE['nav_title'];
                $second['current'] = true;
            } else {
                $second['current'] = false;
            }
            $temp_args['sid'] = $second['sid'];
            $second['url'] = FU('second/index', $temp_args);
            $seconds[] = $second;
        }
        unset($temp_args['sid']);
        $second_all_url = FU('second/index', $temp_args);
        $temp_args = $page_args;
        foreach ($_FANWE['cache']['citys']['province'] as $province) {
            $province = $_FANWE['cache']['citys']['all'][$province];
            if ($province['id'] == $cid) {
                $_FANWE['nav_title'] = $province['name'] . $_FANWE['nav_title'];
                $province['current'] = true;
            } else {
                $province['current'] = false;
            }
            $temp_args['cid'] = $province['id'];
            $province['url'] = FU('second/index', $temp_args);
            $citys[] = $province;
        }
        unset($temp_args['cid']);
        $city_all_url = FU('second/index', $temp_args);
        $sql = 'SELECT COUNT(gid) FROM ' . FDB::table('second_goods') . ' AS sg 
			INNER JOIN ' . FDB::table('share') . ' AS s ON s.share_id = sg.share_id ' . $where;
        $goods_count = FDB::resultFirst($sql);
        $goods_list = array();
        if ($goods_count > 0) {
            $pager = buildPage('book/' . ACTION_NAME, $page_args, $count, $_FANWE['page'], 20);
            $sql = 'SELECT sg.*,s.collect_count,s.comment_count,relay_count,s.cache_data FROM ' . FDB::table('second_goods') . ' AS sg 
				INNER JOIN ' . FDB::table('share') . ' AS s ON s.share_id = sg.share_id ' . $where . ' ORDER BY sg.gid DESC LIMIT ' . $pager['limit'];
            $res = FDB::query($sql);
            while ($data = FDB::fetch($res)) {
                $data['url'] = FU('note/index', array('sid' => $data['share_id']));
                $data['cache_data'] = fStripslashes(unserialize($data['cache_data']));
                $data['time'] = getBeforeTimelag($data['create_time']);
                FS('Share')->shareImageFormat($data);
                unset($data['cache_data']);
                $goods_list[$data['share_id']] = $data;
            }
        }
        include template('page/second/second_index');
        display();
    }
Example #7
0
    /**
     * 获取分类下最新主题
     */
    public function getNowTopicList($tid, $aid, $num)
    {
        global $_FANWE;
        $where = ' WHERE 1';
        if ($aid > 0) {
            $where .= ' AND aid = ' . $aid;
        }
        $list = array();
        $sql = 'SELECT aid,tid,title,create_time,lastpost,lastposter,
			uid,post_count,share_id
			FROM ' . FDB::table('ask_thread') . '
			' . $where . ' AND tid <> ' . $tid . ' ORDER BY tid DESC LIMIT 0,' . $num;
        $res = FDB::query($sql);
        while ($data = FDB::fetch($res)) {
            $data['time'] = getBeforeTimelag($data['create_time']);
            $data['last_time'] = getBeforeTimelag($data['lastpost']);
            $data['url'] = FU('ask/detail', array('tid' => $data['tid']));
            $list[$data['share_id']] = $data;
        }
        return $list;
    }
 public function index()
 {
     $root = array();
     $root['return'] = 1;
     $yh_id = intval($GLOBALS['request']['yh_id']);
     $merchant_id = intval($GLOBALS['request']['merchant_id']);
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市分类ID
     //添加点评数据
     $content = addslashes(trim($GLOBALS['request']['content']));
     if ($GLOBALS['request']['from'] == "wap") {
         if ($content != null && $content != "") {
             //检查用户,用户密码
             $user = $GLOBALS['user_info'];
             $user_id = intval($user['id']);
             if ($merchant_id > 0) {
                 $supplier_location_id = $merchant_id;
                 $merchant_youhui_comment = array('user_id' => $user_id, 'supplier_location_id' => $supplier_location_id, 'title' => $content, 'content' => $content, 'status' => 1, 'create_time' => get_gmtime());
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "supplier_location_dp", $merchant_youhui_comment, 'INSERT');
             } else {
                 $rel_table = 'youhui';
                 $rel_id = $yh_id;
                 if ($yh_id == 0) {
                     //$rel_id = $merchant_id;
                     //rel_table = 'supplier_location';
                 } else {
                     //$supplier_location_id = intval($GLOBALS['db']->getOne("select supplier_location_id from ".DB_PREFIX."youhui where id='".$yh_id."'"));
                 }
                 $merchant_youhui_comment = array('user_id' => $user_id, 'rel_id' => $rel_id, 'rel_table' => $rel_table, 'title' => $content, 'content' => $content, 'is_effect' => 1, 'create_time' => get_gmtime());
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "message", $merchant_youhui_comment, 'INSERT');
             }
         }
     } else {
         if ($content) {
             //检查用户,用户密码
             $user = $GLOBALS['user_info'];
             $user_id = intval($user['id']);
             if ($merchant_id > 0) {
                 $supplier_location_id = $merchant_id;
                 $merchant_youhui_comment = array('user_id' => $user_id, 'supplier_location_id' => $supplier_location_id, 'title' => $content, 'content' => $content, 'status' => 1, 'create_time' => get_gmtime());
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "supplier_location_dp", $merchant_youhui_comment, 'INSERT');
             } else {
                 $rel_table = 'youhui';
                 $rel_id = $yh_id;
                 if ($yh_id == 0) {
                     //$rel_id = $merchant_id;
                     //rel_table = 'supplier_location';
                 } else {
                     //$supplier_location_id = intval($GLOBALS['db']->getOne("select supplier_location_id from ".DB_PREFIX."youhui where id='".$yh_id."'"));
                 }
                 $merchant_youhui_comment = array('user_id' => $user_id, 'rel_id' => $rel_id, 'rel_table' => $rel_table, 'title' => $content, 'content' => $content, 'is_effect' => 1, 'create_time' => get_gmtime());
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "message", $merchant_youhui_comment, 'INSERT');
             }
         }
         $id = $GLOBALS['db']->insert_id();
         $root['id'] = $id;
         if ($id > 0) {
             $root['status'] = 1;
             $root['info'] = "添加成功";
         } else {
             $root['status'] = 0;
             $root['info'] = "添加失败";
         }
     }
     // Fwb add 2014-08-27
     $page = intval($GLOBALS['request']['page']);
     //分页
     $page = $page == 0 ? 1 : $page;
     $page_size = PAGE_SIZE;
     $limit = ($page - 1) * $page_size . "," . $page_size;
     $youhui_comment_list = array();
     if ($merchant_id > 0) {
         $supplier_locationinfo = $GLOBALS['db']->getRow("select name,id,new_dp_count_time from " . DB_PREFIX . "supplier_location where id = " . $merchant_id);
         syn_supplier_locationcount($supplier_locationinfo);
         $condition = " dp.status = 1 and dp.supplier_location_id = " . $merchant_id . " ";
         $sql_count = "select count(*) from " . DB_PREFIX . "supplier_location_dp dp where " . $condition;
         $total = $GLOBALS['db']->getOne($sql_count);
         $page_total = ceil($total / $page_size);
         //$root['sql_count'] = $sql_count;
         $sql = "select dp.*,u.user_name from " . DB_PREFIX . "supplier_location_dp as dp left outer join " . DB_PREFIX . "user as u on u.id = dp.user_id  where " . $condition . " order by dp.is_top desc, dp.create_time desc limit " . $limit;
         $root['sql'] = $sql;
         $list = $GLOBALS['db']->getAll($sql);
         foreach ($list as $item) {
             $youhui_comment_list[] = array("id" => $item['id'], "merchant_id" => $item['supplier_location_id'], "content" => trim($item['content']), "point" => intval($item['point']), "user_name" => trim($item['user_name']), "create_time" => $item['create_time'], "create_time_format" => getBeforeTimelag($item['create_time']));
         }
     } else {
         $sql_count = "select count(*) from " . DB_PREFIX . "message as a " . " left outer join " . DB_PREFIX . "youhui as b on b.id = a.rel_id " . " left outer join " . DB_PREFIX . "user as c on c.id = a.user_id ";
         $sql = "select a.id, a.rel_id as yh_id, a.content,a.create_time, c.user_name from " . DB_PREFIX . "message as a " . " left outer join " . DB_PREFIX . "user as c on c.id = a.user_id ";
         $where = " a.is_effect = 1 and a.rel_table = 'youhui' and a.rel_id = {$yh_id}";
         $sql_count .= " where " . $where;
         $sql .= " where " . $where . " order by a.create_time desc";
         $sql .= " limit " . $limit;
         $total = $GLOBALS['db']->getOne($sql_count);
         $page_total = ceil($total / $page_size);
         $list = $GLOBALS['db']->getAll($sql);
         foreach ($list as $item) {
             /*
             			$title = trim($item['youhui_title']);
             			if ($title == "" || empty($title)){
             				$title = trim($item['m_name']);
             			}
             */
             $youhui_comment_list[] = array("id" => $item['id'], "yh_id" => $item['yh_id'], "content" => trim($item['content']), "user_name" => trim($item['user_name']), "create_time" => $item['create_time'], "create_time_format" => getBeforeTimelag($item['create_time']));
         }
     }
     //echo $sql; exit;
     $root['item'] = $youhui_comment_list;
     $root['page'] = array("page" => $page, "page_total" => $page_total, "page_size" => $page_size);
     $root['merchant_id'] = $merchant_id;
     //fwb add 2014-08-27
     $root['yh_id'] = $yh_id;
     $root['page_title'] = "评论详情";
     $root['city_name'] = $city_name;
     output($root);
 }
Example #9
0
    function best()
    {
        global $_FANWE;
        $forum_id = intval($_FANWE['request']['fid']);
        $forum = $_FANWE['cache']['forums']['all'][$forum_id];
        if (empty($forum)) {
            fHeader('location: ' . FU('club/index'));
        }
        $_FANWE['nav_title'] = $forum['name'] . ' - ' . lang('common', 'club');
        $is_root = true;
        $is_best = true;
        $root_forum = $forum;
        $fids = array();
        if ($forum['parent_id'] > 0) {
            $is_root = false;
            $root_forum = $_FANWE['cache']['forums']['all'][$forum['parent_id']];
        }
        if (isset($forum['childs'])) {
            $fids = $forum['childs'];
        }
        $fids[] = $forum_id;
        $where = ' WHERE s.status = 1 AND ft.is_best = 1';
        if (count($fids) == 1) {
            $where .= ' AND ft.fid = ' . $forum_id;
        } else {
            $where .= ' AND ft.fid IN (' . implode(',', $fids) . ')';
        }
        $sort = '';
        $order = 'ft.is_top DESC,ft.lastpost DESC,ft.tid DESC';
        if ($_FANWE['request']['sort'] == 'tid') {
            $order = 'ft.is_top DESC,ft.tid DESC';
            $sort = 'tid';
        }
        $page_args = array('fid' => $forum_id, 'sort' => $sort);
        if ($sort == '') {
            unset($page_args['sort']);
        }
        $count = FDB::resultFirst('SELECT COUNT(ft.tid) 
			FROM ' . FDB::table('forum_thread') . ' AS ft 
			INNER JOIN ' . FDB::table('share') . ' AS s ON s.share_id = ft.share_id ' . $where);
        $pager = buildPage('club/best', $page_args, $count, $_FANWE['page'], 20);
        $topic_list = array();
        $sql = 'SELECT ft.fid,ft.tid,ft.title,ft.create_time,ft.lastpost,ft.lastposter,
			ft.uid,ft.post_count,ft.share_id,s.cache_data,ft.is_top,ft.is_best 
			FROM ' . FDB::table('forum_thread') . ' AS ft 
			INNER JOIN ' . FDB::table('share') . ' AS s ON s.share_id = ft.share_id 
			' . $where . ' ORDER BY ' . $order . ' LIMIT ' . $pager['limit'];
        $res = FDB::query($sql);
        while ($data = FDB::fetch($res)) {
            if (!empty($data['lastposter'])) {
                $data['last_time'] = getBeforeTimelag($data['lastpost']);
            }
            $data['cache_data'] = fStripslashes(unserialize($data['cache_data']));
            $data['time'] = getBeforeTimelag($data['create_time']);
            $data['last_time'] = getBeforeTimelag($data['lastpost']);
            $data['url'] = FU('club/detail', array('tid' => $data['tid']));
            FS('Share')->shareImageFormat($data, 3);
            unset($data['cache_data']);
            $topic_list[$data['share_id']] = $data;
        }
        include template('page/club/club_forum');
        display();
    }
    public function fans()
    {
        global $_FANWE;
        $home_uid = $_FANWE['home_uid'];
        $home_user = FS('User')->getUserById($home_uid);
        if ($_FANWE['uid'] == $home_uid) {
            //将我的粉丝信息统计设置为0
            FDB::query("update " . FDB::table("user_notice") . " set num=0 where `type`=1 and uid=" . intval($_FANWE['uid']));
        }
        $page_args = array('uid' => $home_uid);
        Cache::getInstance()->loadCache('citys');
        $reside_province = $_FANWE['cache']['citys']['all'][$home_user['reside_province']]['name'];
        $reside_city = $_FANWE['cache']['citys']['all'][$home_user['reside_city']]['name'];
        $count = FDB::resultFirst('SELECT COUNT(uid) FROM ' . FDB::table('user_follow') . ' WHERE uid = ' . $home_uid);
        $pager = buildPage('u/' . ACTION_NAME, $page_args, $count, $_FANWE['page'], 20);
        $user_list = array();
        $res = FDB::query('SELECT u.uid,u.user_name,u.server_code,uc.fans,up.reside_province,up.reside_city
				FROM ' . FDB::table('user_follow') . ' AS uf
				INNER JOIN ' . FDB::table('user') . ' AS u ON u.uid = uf.f_uid
				INNER JOIN ' . FDB::table('user_count') . ' AS uc ON uc.uid = uf.f_uid
				INNER JOIN ' . FDB::table('user_profile') . ' AS up ON up.uid = uf.f_uid
				WHERE uf.uid = ' . $home_uid . ' ORDER BY uf.create_time DESC LIMIT ' . $pager['limit']);
        while ($data = FDB::fetch($res)) {
            $data['is_follow'] = FS('User')->getIsFollowUId($data['uid']);
            $data['reside_province'] = $_FANWE['cache']['citys']['all'][$data['reside_province']]['name'];
            $data['reside_city'] = $_FANWE['cache']['citys']['all'][$data['reside_city']]['name'];
            $data['share'] = FDB::fetchFirst('SELECT share_id,create_time,content
				FROM ' . FDB::table('share') . '
				WHERE uid = ' . $data['uid'] . '
				ORDER BY share_id DESC
				LIMIT 0,1');
            if ($data['share']) {
                $data['share']['url'] = FU('note/index', array('sid' => $data['share']['share_id']));
                $data['share']['time'] = getBeforeTimelag($data['share']['create_time']);
            }
            $user_list[] = $data;
        }
        include template('page/u/u_fans');
        display();
    }
/**
 * 分享列表详细数据
 * @param array $list 分享列表
 * @param bool $is_parent 是否获取转发信息
 * @param bool $is_collect 是否获取喜欢的会员
 * @param bool $is_parent 是否获取分享标签
 * @return array
 */
function mGetShareDetailList($list, $is_parent = false, $img_width = 160, $img_height = 160)
{
    global $_FANWE;
    $shares = array();
    $share_ids = array();
    $rec_shares_ids = array();
    $share_users = array();
    foreach ($list as $item) {
        $share_id = $item['share_id'];
        if ($item['share_data'] == 'default') {
            continue;
        }
        $share_ids[] = $share_id;
        $item['cache_data'] = fStripslashes(unserialize($item['cache_data']));
        $item['time'] = getBeforeTimelag($item['create_time']);
        $item['url'] = FU('note/index', array('sid' => $share_id), true);
        if ($item['source'] == 'web') {
            $item['source'] = $_FANWE['setting']['site_name'] . '网站';
        }
        $item['imgs'] = array();
        $img = array();
        $img_sql = 'select photo_id,img,img_width,img_height from ' . FDB::table('share_photo') . ' where share_id = ' . $share_id;
        $img_data = FDB::fetchFirst($img_sql);
        $img['share_id'] = $share_id;
        $img['id'] = $img_data['photo_id'];
        $img['name'] = '';
        $img['type'] = '';
        $img['price'] = '';
        $img['goods_url'] = '';
        $img['taoke_url'] = '';
        $img['price_format'] = '';
        $img['server_code'] = '';
        $img['img_width'] = $img_data['img_width'];
        $img['img'] = FS("Image")->getImageUrl($img_data['img'], 2);
        $img['img_height'] = $img_data['img_height'];
        $img['width'] = 160;
        $img['small_img'] = FS("Image")->getImageUrl(getImgName($img_data['img'], 160, 160, 0, true), 2);
        $item['imgs'][] = $img;
        m_express(&$item, $item['content']);
        $shares[$share_id] = $item;
        unset($shares[$share_id]['cache_data']);
        $shares[$share_id]['user'] =& $share_users[$item['uid']];
        $shares[$share_id]['is_relay'] = false;
        $shares[$share_id]['is_parent'] = false;
        if ($is_parent) {
            if ($item['base_id'] > 0) {
                $shares[$share_id]['is_relay'] = true;
                $rec_shares_ids[$item['base_id']] = false;
                $shares[$share_id]['relay_share'] =& $rec_shares_ids[$item['base_id']];
            } elseif ($item['parent_id'] > 0 && $item['parent_id'] != $item['base_id']) {
                $shares[$share_id]['is_parent'] = true;
                $rec_shares_ids[$item['parent_id']] = false;
                $shares[$share_id]['parent_share'] =& $rec_shares_ids[$item['parent_id']];
            }
        }
    }
    $rec_ids = array_keys($rec_shares_ids);
    if (count($rec_ids) > 0) {
        $intersects = array_intersect($share_ids, $rec_ids);
        $temp_ids = array();
        foreach ($intersects as $share_id) {
            $rec_shares_ids[$share_id] = $shares[$share_id];
            $temp_ids[] = $share_id;
        }
        $diffs = array_diff($rec_ids, $temp_ids);
        if (count($diffs) > 0) {
            $res = FDB::query('SELECT * FROM ' . FDB::table('share') . ' WHERE share_id IN (' . implode(',', $diffs) . ')');
            while ($item = FDB::fetch($res)) {
                $share_id = $item['share_id'];
                $share_ids[] = $share_id;
                $item['cache_data'] = fStripslashes(unserialize($item['cache_data']));
                $item['time'] = getBeforeTimelag($item['create_time']);
                $item['url'] = FU('note/index', array('sid' => $share_id), true);
                if ($item['source'] == 'web') {
                    $item['source'] = $_FANWE['setting']['site_name'] . '网站';
                }
                m_express(&$item, $item['content']);
                $item['imgs'] = array();
                $img = array();
                $img_sql = 'select photo_id,img,img_width,img_height from ' . FDB::table('share_photo') . ' where share_id = ' . $share_id;
                $img_data = FDB::fetchFirst($img_sql);
                $img['share_id'] = $share_id;
                $img['id'] = $img_data['photo_id'];
                $img['name'] = '';
                $img['type'] = '';
                $img['price'] = '';
                $img['goods_url'] = '';
                $img['taoke_url'] = '';
                $img['price_format'] = '';
                $img['server_code'] = '';
                $img['img_width'] = $img_data['img_width'];
                $img['img'] = FS("Image")->getImageUrl($img_data['img'], 2);
                $img['img_height'] = $img_data['img_height'];
                $img['width'] = 160;
                $img['small_img'] = FS("Image")->getImageUrl(getImgName($img_data['img'], 160, 160, 0, true), 2);
                $item['imgs'][] = $img;
                $rec_shares_ids[$share_id] = $item;
                unset($rec_shares_ids[$share_id]['cache_data']);
                $rec_shares_ids[$share_id]['user'] =& $share_users[$item['uid']];
            }
        }
    }
    $user_ids = array_keys($share_users);
    if (count($user_ids) > 0) {
        $res = FDB::query("SELECT uid,user_name,server_code FROM " . FDB::table('user') . ' WHERE uid IN (' . implode(',', $user_ids) . ')');
        while ($item = FDB::fetch($res)) {
            $item['user_avatar'] = FS("Image")->getImageUrl('.' . avatar($item['uid'], 'm', 1), 2);
            $share_users[$item['uid']] = $item;
        }
    }
    return $shares;
}
Example #12
0
    /**
     * 获取首页显示的分享最近最热标签
     * @return array
     */
    public function getIndexShareHotTags($num = 40)
    {
        global $_FANWE;
        $list = array();
        $sql = 'SELECT st.tag_name,(gt.tag_name IS NOT NULL) as gt_tag,COUNT(DISTINCT t.share_id) AS share_count,
			GROUP_CONCAT(DISTINCT t.share_id ORDER BY t.is_best DESC,t.collect_count DESC SEPARATOR \',\') AS share_ids
			FROM (SELECT DISTINCT(share_id),is_best,collect_count 
				FROM ' . FDB::table('share') . ' 
				WHERE share_data IN (\'photo\',\'goods\',\'goods_photo\') 
				ORDER BY share_id DESC LIMIT 0,2000) AS t
			STRAIGHT_JOIN ' . FDB::table('share_tags') . ' AS st ON st.share_id = t.share_id
			LEFT JOIN ' . FDB::table('goods_tags') . ' AS gt ON gt.tag_name = st.tag_name 
			GROUP BY st.tag_name
			ORDER BY gt_tag DESC,gt.sort ASC,share_count DESC LIMIT 0,' . $num;
        $res = FDB::query($sql);
        while ($data = FDB::fetch($res)) {
            $tag_encode = urlencode($data['tag_name']);
            $list['tags'][$data['tag_name']] = $tag_encode;
            $share_ids = explode(',', $data['share_ids']);
            $share_ids = array_slice($share_ids, 0, 11);
            if (count($share_ids) > 1) {
                array_pop($share_ids);
            }
            foreach ($share_ids as $share_id) {
                if (!isset($list['shares'][$share_id])) {
                    $list['share_list'][] = $share_id;
                    $list['shares'][$share_id] = array('tag_name' => $data['tag_name'], 'tag_encode' => $tag_encode);
                    break;
                }
            }
        }
        if (count($list['share_list']) > 0) {
            $list['uids'] = array();
            $sql = 'SELECT share_id,uid,collect_count,cache_data,create_time FROM ' . FDB::table('share') . ' 
				WHERE share_id IN (' . implode(',', $list['share_list']) . ')';
            $res = FDB::query($sql);
            while ($data = FDB::fetch($res)) {
                $share_id = $data['share_id'];
                $tag_name = $list['shares'][$share_id]['tag_name'];
                $tag_encode = $list['shares'][$share_id]['tag_encode'];
                $list['uids'][$data['uid']] = 1;
                $data['cache_data'] = fStripslashes(unserialize($data['cache_data']));
                $data['time'] = getBeforeTimelag($data['create_time']);
                $data['tag_name'] = $tag_name;
                $data['url'] = FU('book/shopping', array('sid' => $data['share_id'], 'tag' => $tag_encode));
                FS('Share')->shareImageFormat($data, 1);
                unset($data['cache_data']);
                $list['shares'][$share_id] = $data;
            }
            unset($list['share_list']);
            return $list;
        } else {
            return false;
        }
    }
 public function run()
 {
     global $_FANWE;
     $root = array();
     $root['return'] = 1;
     if ($_FANWE['uid'] == 0) {
         exit;
     }
     $page = (int) $_FANWE['requestData']['page'];
     $page = max(1, $page);
     $total = FS('Message')->getMsgCount($_FANWE['uid']);
     $page_size = PAGE_SIZE;
     $page_total = max(1, ceil($total / $page_size));
     if ($page > $page_total) {
         $page = $page_total;
     }
     $limit = ($page - 1) * $page_size . "," . $page_size;
     if ($page == 1) {
         $sys_msgs = FS('Message')->getSysMsgs($_FANWE['uid']);
         foreach ($sys_msgs as $msg) {
             unset($msg['message']);
             $msg['time'] = getBeforeTimelag($msg['dateline']);
             $root['sys_msgs'][] = $msg;
         }
         $sys_notices = FS('Notice')->getList($_FANWE['uid']);
         foreach ($sys_notices as $msg) {
             $msg['content'] = str_replace('href="/', 'href="' . $_FANWE['site_url'], $msg['content']);
             $msg['time'] = getBeforeTimelag($msg['create_time']);
             $root['sys_notices'][] = $msg;
         }
     }
     $msg_list = FS('Message')->getMsgList($_FANWE['uid'], $limit);
     //print_r($msg_list);exit;
     foreach ($msg_list as $msg) {
         $data = array();
         $data['content'] = $msg['message'];
         if ($msg['msg_fuid'] == $_FANWE['uid']) {
             $data['uid'] = $_FANWE['uid'];
             $data['user_name'] = '我';
             $data['user_avatar'] = $_FANWE['user']['user_avatar'];
             $data['tuid'] = $msg['msg_tuser']['uid'];
             $data['tuser_name'] = $msg['msg_tuser']['user_name'];
             $data['tuser_avatar'] = avatar($data['tuid'], 'm', $msg['msg_tuser']['server_code'], 1, true);
         } else {
             $data['uid'] = $msg['msg_tuser']['uid'];
             $data['user_name'] = $msg['msg_tuser']['user_name'];
             $data['user_avatar'] = avatar($data['uid'], 'm', $msg['msg_tuser']['server_code'], 1, true);
             $data['tuid'] = $_FANWE['uid'];
             $data['tuser_name'] = '我';
             $data['tuser_avatar'] = $_FANWE['user']['user_avatar'];
         }
         $data['time'] = getBeforeTimelag($msg['last_update']);
         $data['mlid'] = $msg['mlid'];
         $data['msg_count'] = $msg['num'];
         m_express(&$data, $msg['message']);
         $root['msg_list'][] = $data;
     }
     FDB::query("DELETE FROM " . FDB::table('user_notice') . " WHERE uid='" . $_FANWE['uid'] . "' AND type=5");
     $root['page'] = array("page" => $page, "page_total" => $page_total);
     m_display($root);
 }
Example #14
0
    public function getMsgsByMlid($mlid, $uid, $limit)
    {
        $list = array();
        if (empty($mlid)) {
            return $list;
        }
        $mlist = MessageService::getListByMlid($mlid, $uid);
        if (empty($mlist) || $mlist['type'] != 1) {
            return $list;
        }
        $where = '';
        if ($mlist['uid'] == $uid) {
            $where .= ' AND status IN (0,2)';
        } else {
            $where .= ' AND status IN (0,1)';
        }
        $query = FDB::query('SELECT * 
			FROM ' . MessageService::getTablaName($mlid) . " \r\n\t\t\tWHERE mlid='{$mlid}' {$where} ORDER BY dateline DESC LIMIT {$limit}");
        while ($data = FDB::fetch($query)) {
            $data['time'] = getBeforeTimelag($data['dateline']);
            $list[] = $data;
        }
        FDB::query("UPDATE " . FDB::table('user_msg_member') . " SET is_new=0 WHERE mlid='{$mlid}' AND uid='{$uid}' AND is_new=1");
        return array_reverse($list);
    }
Example #15
0
function m_youhuiItem($item)
{
    $is_sc = intval($item['is_sc']);
    if ($is_sc > 0) {
        $is_sc = 1;
    }
    //1:已收藏; 0:未收藏
    if (intval($item['begin_time']) > 0 && intval($item['end_time'])) {
        $days = round(($item['end_time'] - get_gmtime()) / 3600 / 24);
        if ($days < 0) {
            $ycq = to_date(get_gmtime(), 'Y-m-d') . '至' . to_date($item['end_time'], 'Y-m-d') . ',已过期';
        } else {
            $ycq = to_date(get_gmtime(), 'Y-m-d') . '至' . to_date($item['end_time'], 'Y-m-d') . ',还有' . $days . '天';
        }
    } else {
        $ycq = '';
    }
    $logo = get_spec_image($item['image_1'], $width = 160, $height = 0, $gen = 0, $is_preview = true);
    $merchant_logo = get_spec_image($item['merchant_logo'], $width = 160, $height = 0, $gen = 0, $is_preview = true);
    //$pattern = "/<img([^>]*)\/>/i";
    $pattern = "/<[img|IMG].*?src=[\\'|\"](.*?(?:[\\.gif|\\.jpg|\\.png]))[\\'|\"].*?[\\/]?>/i";
    //$replacement = "<img width=300 $1 />";
    $replacement = "<img src='\$1' width='300' />";
    $item['content'] = preg_replace($pattern, $replacement, $item['content']);
    return array("id" => $item['id'], "title" => $item['title'], "logo" => $item['image_1'], "logo_1" => get_abs_img_root($item['image_2']), "logo_2" => get_abs_img_root($item['image_3']), "image_3_w" => intval($item['image_3_w']), "image_3_h" => intval($item['image_3_h']), "merchant_logo" => get_abs_img_root(get_spec_image($item['merchant_logo'], 160, 0)), "create_time" => $item['create_time'], "create_time_format" => getBeforeTimelag($item['create_time']), "xpoint" => $item['xpoint'], "ypoint" => $item['ypoint'], "address" => $item['api_address'], "content" => get_abs_img_root($item['content']), "is_sc" => $is_sc, "distance" => round($item['distance']), "comment_count" => intval($item['comment_count']), "merchant_id" => intval($item['merchant_id']), "view_count" => intval($item['view_count']), "sms_count" => intval($item['sms_count']), "print_count" => intval($item['print_count']), "youhui_type" => intval($item['youhui_type']), "total_num" => intval($item['total_num']), "use_notice" => $item['use_notice'], "begin_time_format" => to_date($item['begin_time'], 'Y-m-d'), "end_time_format" => to_date($item['end_time'], 'Y-m-d'), "ycq" => $ycq, "adv_url" => $item['url'], "city_name" => $item['city_name']);
}
    public function feed()
    {
        global $_FANWE;
        $home_uid = $_FANWE['home_uid'];
        $home_user = FS('User')->getUserById($home_uid);
        FanweService::instance()->cache->loadCache('asks');
        FanweService::instance()->cache->loadCache('forums');
        $page_args = array('uid' => $home_uid);
        $current_menu = 'topic';
        $count = FDB::resultFirst('SELECT COUNT(DISTINCT parent_id)
			FROM ' . FDB::table('share') . '
			WHERE type IN (\'bar_post\',\'ask_post\') AND uid = ' . $home_uid);
        $pager = buildPage('u/' . ACTION_NAME, $page_args, $count, $_FANWE['page'], 10);
        $thread_list = array();
        $res = FDB::query('SELECT s1.share_id,s.rec_id,s1.cache_data,s.type
			FROM ' . FDB::table('share') . ' AS s
			INNER JOIN ' . FDB::table('share') . ' AS s1 ON s1.share_id = s.parent_id
			WHERE s.type IN (\'bar_post\',\'ask_post\') AND s.uid = ' . $home_uid . '
			GROUP BY s.parent_id
			ORDER BY s.parent_id DESC LIMIT ' . $pager['limit']);
        while ($data = FDB::fetch($res)) {
            if ($data['type'] == 'bar_post') {
                $sql = 'SELECT tid,fid,title,content,ft.uid,post_count,ft.create_time
					FROM ' . FDB::table('forum_thread') . ' AS ft
					WHERE ft.tid = ' . $data['rec_id'];
            } else {
                $sql = 'SELECT tid,aid,title,content,at.uid,post_count,at.create_time
					FROM ' . FDB::table('ask_thread') . ' AS at
					WHERE at.tid = ' . $data['rec_id'];
            }
            $thread = FDB::fetchFirst($sql);
            if ($data['type'] == 'bar_post') {
                $thread['url'] = FU('club/detail', array('tid' => $thread['tid']));
                $thread['cate'] = $_FANWE['cache']['forums']['all'][$thread['fid']];
            } else {
                $thread['url'] = FU('ask/detail', array('tid' => $thread['tid']));
                $thread['cate'] = $_FANWE['cache']['asks'][$thread['aid']];
            }
            $thread['cache_data'] = unserialize($data['cache_data']);
            $thread['time'] = getBeforeTimelag($thread['create_time']);
            FS('Share')->shareImageFormat($thread);
            unset($thread['cache_data']);
            $thread_list[$data['share_id']] = $thread;
        }
        include template('page/u/u_topic');
        display();
    }
    public function run()
    {
        global $_FANWE;
        $root = array();
        $root['return'] = 1;
        $share_id = (int) $_FANWE['requestData']['share_id'];
        $act2 = $_FANWE['requestData']['act_2'];
        $share = FS('Share')->getShareById($share_id);
        $max_width = 320;
        $max_height = 234;
        $scale = 2;
        if ($share) {
            switch ($act2) {
                case 'follow':
                    if ($_FANWE['uid'] > 0) {
                        FS('User')->followUser($share['uid']);
                    }
                    break;
                case 'collect':
                    if ($_FANWE['uid'] > 0 && $share['uid'] != $_FANWE['uid']) {
                        if (FS('Share')->getIsCollectByUid($share_id, $_FANWE['uid'])) {
                            FS('Share')->deleteShareCollectUser($share_id, $_FANWE['uid']);
                        } else {
                            FS('Share')->saveFav($share);
                        }
                        $share = FDB::fetchFirst('SELECT * FROM ' . FDB::table('share') . ' WHERE share_id = ' . $share_id);
                    }
                    break;
            }
            $cache_data = fStripslashes(unserialize($share['cache_data']));
            unset($share['cache_data']);
            $share['prev_share'] = (int) FDB::resultFirst('SELECT share_id FROM ' . FDB::table('share') . ' 
				WHERE share_id < ' . $share_id . " AND share_data IN ('goods','photo','goods_photo') ORDER BY share_id DESC LIMIT 1");
            $share['next_share'] = (int) FDB::resultFirst('SELECT share_id FROM ' . FDB::table('share') . ' 
				WHERE share_id > ' . $share_id . " AND share_data IN ('goods','photo','goods_photo') ORDER BY share_id ASC LIMIT 1");
            $share['time'] = getBeforeTimelag($share['create_time']);
            $share['url'] = FU('note/index', array('sid' => $share_id), true);
            $site_url = ';网址:' . $share['url'];
            $root['share_content'] = cutStr($share['content'], 140 - getStrLen($site_url) - 3) . $site_url;
            m_express(&$share, $share['content']);
            $share_user = FS('User')->getUserById($share['uid']);
            $share['user_name'] = $share_user['user_name'];
            $share['user_avatar'] = FS("Image")->getImageUrl('.' . avatar($share_user['uid'], 'm', 1), 2);
            if ($share['source'] == 'web') {
                $share['source'] = $_FANWE['setting']['site_name'] . '网站';
            }
            if ($_FANWE['uid'] == $share['uid']) {
                $share['is_follow_user'] = -1;
                $share['is_collect_share'] = -1;
            } else {
                if (FS('User')->getIsFollowUId($share['uid'], false)) {
                    $share['is_follow_user'] = 1;
                } else {
                    $share['is_follow_user'] = 0;
                }
                if (FS('Share')->getIsCollectByUid($share_id, $_FANWE['uid'])) {
                    $share['is_collect_share'] = 1;
                } else {
                    $share['is_collect_share'] = 0;
                }
            }
            $share['comments'] = array();
            $sql_count = "SELECT COUNT(DISTINCT comment_id) FROM " . FDB::table("share_comment") . " WHERE share_id = " . $share_id;
            $total = FDB::resultFirst($sql_count);
            $page_size = PAGE_SIZE;
            $page_total = ceil($total / $page_size);
            $limit = "0," . $page_size;
            $sql = 'SELECT c.*,u.user_name,u.server_code FROM ' . FDB::table('share_comment') . ' AS c 
				INNER JOIN ' . FDB::table('user') . ' AS u ON u.uid = c.uid 
				WHERE c.share_id = ' . $share_id . ' ORDER BY c.comment_id DESC LIMIT ' . $limit;
            $res = FDB::query($sql);
            $list = array();
            while ($item = FDB::fetch($res)) {
                $item['user_avatar'] = FS("Image")->getImageUrl('.' . avatar($item['uid'], 'm', 1), 2);
                $item['time'] = getBeforeTimelag($item['create_time']);
                m_express(&$item, $item['content']);
                $share['comments']['list'][] = $item;
            }
            $share['comments']['page'] = array("page" => 1, "page_total" => $page_total);
            $share['collects'] = array();
            if (!empty($cache_data['collects'])) {
                $collect_ids = array_slice($cache_data['collects'], 0, 20);
                if ($share['is_follow_user'] == 1) {
                    if ($ckey = array_search($_FANWE['uid'], $collect_ids) === FALSE) {
                        array_unshift($collect_ids, $_FANWE['uid']);
                        array_pop($collect_ids);
                    } else {
                        unset($collect_ids[$ckey]);
                        array_unshift($collect_ids, $_FANWE['uid']);
                    }
                }
                $collect_ids = implode(',', $collect_ids);
                $res = FDB::query("SELECT uid,user_name,server_code FROM " . FDB::table('user') . ' 
					WHERE uid IN (' . $collect_ids . ')');
                while ($item = FDB::fetch($res)) {
                    $item['user_avatar'] = FS("Image")->getImageUrl('.' . avatar($item['uid'], 'm', 1), 2);
                    unset($item['server_code']);
                    $share['collects'][] = $item;
                }
            }
            $share['imgs'] = array();
            $img = array();
            $img_sql = 'select photo_id,img,img_width,img_height from ' . FDB::table('share_photo') . ' where share_id = ' . $share_id;
            $img_data = FDB::fetchFirst($img_sql);
            $img['share_id'] = $share_id;
            $img['id'] = $img_data['photo_id'];
            $img['name'] = '';
            $img['type'] = '';
            $img['price'] = '';
            $img['goods_url'] = '';
            $img['taoke_url'] = '';
            $img['price_format'] = '';
            $img['server_code'] = '';
            if ($img_data['img_width'] > $img_data['img_height']) {
                if ($img_data['img_width'] > $max_width) {
                    $img['img_width'] = $max_width;
                    $img['img_height'] = $img_data['img_height'] * ($max_width / $img_data['img_width']);
                }
            } else {
                if ($img_data['img_height'] > $max_height) {
                    $img['img_height'] = $max_height;
                    $img['img_width'] = $img_data['img_width'] * ($max_height / $img_data['img_height']);
                }
            }
            $img['img'] = FS("Image")->getImageUrl($img_data['img'], 2);
            $img['small_img'] = FS("Image")->getImageUrl(getImgName($img_data['img'], $img['img_width'], $img['img_height'], 0, true), 2);
            $share['imgs'][] = $img;
        }
        $root['item'] = $share;
        m_display($root);
    }
Example #18
0
function m_youhuiItem($item)
{
    $is_sc = intval($item['is_sc']);
    if ($is_sc > 0) {
        $is_sc = 1;
    }
    //1:已收藏; 0:未收藏
    if (intval($item['begin_time']) > 0 && intval($item['end_time'])) {
        $days = round(($item['end_time'] - $item['begin_time']) / 3600 / 24);
        if ($days < 0) {
            $ycq = to_date($item['begin_time'], 'Y-m-d') . '至' . to_date($item['end_time'], 'Y-m-d') . ',已过期';
        } else {
            $ycq = to_date($item['begin_time'], 'Y-m-d') . '至' . to_date($item['end_time'], 'Y-m-d') . ',还有' . $days . '天';
        }
    } else {
        $ycq = '';
    }
    $logo = get_spec_image($item['image_1'], $width = 160, $height = 0, $gen = 0, $is_preview = true);
    $merchant_logo = get_spec_image($item['merchant_logo'], $width = 160, $height = 0, $gen = 0, $is_preview = true);
    return array("id" => $item['id'], "title" => $item['title'], "logo" => get_abs_img_root(get_spec_image($item['image_1'], 160, 0)), "logo_1" => get_abs_img_root($item['image_2']), "logo_2" => get_abs_img_root($item['image_3']), "image_3_w" => intval($item['image_3_w']), "image_3_h" => intval($item['image_3_h']), "merchant_logo" => get_abs_img_root(get_spec_image($item['merchant_logo'], 160, 0)), "create_time" => $item['create_time'], "create_time_format" => getBeforeTimelag($item['create_time']), "xpoint" => $item['xpoint'], "ypoint" => $item['ypoint'], "address" => $item['api_address'], "content" => $item['content'], "is_sc" => $is_sc, "distance" => round($item['distance']), "comment_count" => intval($item['comment_count']), "merchant_id" => intval($item['merchant_id']), "begin_time_format" => to_date($item['begin_time'], 'Y-m-d'), "end_time_format" => to_date($item['end_time'], 'Y-m-d'), "ycq" => $ycq, "adv_url" => $item['url'], "city_name" => $item['city_name']);
}
 function detail()
 {
     global $_FANWE;
     $id = intval($_FANWE['request']['tid']);
     if ($id == 0) {
         fHeader('location: ' . FU('ask/index'));
     }
     $topic = FS('Ask')->getTopicById($id);
     if (empty($topic)) {
         fHeader('location: ' . FU('ask/index'));
     }
     $_FANWE['nav_title'] = lang('common', 'ask');
     $_FANWE['nav_title'] = $topic['title'] . ' - ' . $_FANWE['nav_title'];
     FDB::query('UPDATE ' . FDB::table('share') . ' SET click_count = click_count + 1 WHERE share_id = ' . $topic['share_id']);
     $topic['time'] = getBeforeTimelag($topic['create_time']);
     $topic['share'] = FS('Share')->getShareDetail($topic['share_id']);
     $user_share_collect = FS('Share')->getShareCollectUser($topic['share_id']);
     if (!isset($user_share_collect[$_FANWE['uid']])) {
         if (FS('Share')->getIsCollectByUid($topic['share_id'], $_FANWE['uid'])) {
             $user_share_collect[$_FANWE['uid']] = $_FANWE['uid'];
         }
     }
     $ask_id = $topic['aid'];
     $ask = $_FANWE['cache']['asks'][$ask_id];
     FS('Ask')->updateTopicLooksCache($id);
     $topic_looks = FS('Ask')->getTopicLooks($id, 33);
     $is_follow = FS('Ask')->getIsFollowTid($id);
     $follow_count = FS('Ask')->getTopicFollowCount($id);
     $follow_users = FS('Ask')->getTopicFollows($id, 9);
     $ask_hot_topics = FS('Ask')->getHotAsk($ask_id, 9);
     $ask_hot_pics = FS('Ask')->getImgAsk('hot', 9);
     $new_events = FS('Event')->getHotNewEvent(10);
     $ask_new_topics = FS('Ask')->getNowTopicList($id, $ask_id, 10);
     $best_topics = FS('Topic')->getImgTopic('hot', 12, 1);
     $best_topics = array_chunk($best_topics, 3);
     $page_args = array('tid' => $id);
     $count = $topic['post_count'];
     $pager = buildPage('ask/' . ACTION_NAME, $page_args, $count, $_FANWE['page'], 10);
     $post_list = FS('Ask')->getTopicPostList($id, $pager['limit']);
     $args = array('share_list' => &$post_list, 'pager' => &$pager, 'current_share_id' => $topic['share_id']);
     $post_html = tplFetch("inc/share/post_share_list", $args);
     include template('page/ask/ask_detail');
     display();
 }
 public function run()
 {
     global $_FANWE;
     $root = array();
     $root['return'] = 1;
     if ($_FANWE['uid'] == 0) {
         exit;
     }
     //print_r($_FANWE['requestData']); exit;
     $mlid = (int) $_FANWE['requestData']['lid'];
     $mid = (int) $_FANWE['requestData']['mid'];
     if ($mlid == 0 && $mid == 0) {
         exit;
     }
     if ($mlid > 0) {
         $mlist = FS('Message')->getListByMlid($mlid, $_FANWE['uid']);
         if (empty($mlist)) {
             exit;
         }
         $act2 = $_FANWE['requestData']['act_2'];
         if ($act2 == 'reply') {
             $message = trim($_FANWE['requestData']['message']);
             if (!empty($message)) {
                 $message = cutStr($message, 200);
                 if (FS('Message')->replyMsg($mlid, $_FANWE['uid'], $_FANWE['user_name'], $message) > 0) {
                     $mlist['num']++;
                 }
             }
         }
         $root['lid'] = $mlid;
         $page = (int) $_FANWE['requestData']['page'];
         $page = max(1, $page);
         $total = $mlist['num'];
         $page_size = PAGE_SIZE;
         $page_total = max(1, ceil($total / $page_size));
         if ($page > $page_total) {
             $page = $page_total;
         }
         $limit = ($page - 1) * $page_size . "," . $page_size;
         $root['page'] = array("page" => $page, "page_total" => $page_total);
         $tuser = FS('User')->getUserById($mlist['tuid']);
         $tuser['user_avatar'] = FS("Image")->getImageUrl('.' . avatar($tuser['uid'], 'm', 1), 2);
         //$root['title'] = "共有{$total}封与{$tuser['user_name']}的交流信件";
         $root['title'] = "与{$tuser['user_name']}的交流";
         $root['t_name'] = $tuser['user_name'];
         $msg_list = FS('Message')->getMsgsByMlid($mlid, $_FANWE['uid'], $limit);
         foreach ($msg_list as $msg) {
             if ($msg['uid'] == $_FANWE['uid']) {
                 $user = $_FANWE['user'];
                 $user['user_name'] = '我';
                 $msg['tuid'] = $mlist['tuid'];
                 $msg['tuser_name'] = $tuser['user_name'];
                 $msg['tuser_avatar'] = $tuser['user_avatar'];
             } else {
                 $user = $tuser;
                 $msg['tuid'] = $_FANWE['uid'];
                 $msg['tuser_name'] = '我';
                 $msg['tuser_avatar'] = $_FANWE['user']['user_avatar'];
             }
             $msg['content'] = $msg['message'];
             $msg['user_name'] = $user['user_name'];
             $msg['user_avatar'] = $user['user_avatar'];
             m_express(&$msg, $msg['message']);
             $root['msg_list'][] = $msg;
         }
     } elseif ($mid) {
         $msg = FS('Message')->getSysMsgByMid($_FANWE['uid'], $mid);
         $msg['time'] = getBeforeTimelag($msg['dateline']);
         $msg['message'] = str_replace('href="/', 'href="' . $_FANWE['site_url'], $msg['message']);
         $root['msg'] = $msg;
     }
     m_display($root);
 }
function m_youhuiItem($item)
{
    global $_FANWE;
    $is_sc = intval($item['is_sc']);
    if ($is_sc > 0) {
        $is_sc = 1;
    }
    //1:已收藏; 0:未收藏
    if (intval($item['begin_time']) > 0 && intval($item['end_time'])) {
        $days = round(($item['end_time'] - $item['begin_time']) / 3600 / 24);
        if ($days < 0) {
            $ycq = fToDate($item['begin_time'], 'Y-m-d') . '至' . fToDate($item['end_time'], 'Y-m-d') . ',已过期';
        } else {
            $ycq = fToDate($item['begin_time'], 'Y-m-d') . '至' . fToDate($item['end_time'], 'Y-m-d') . ',还有' . $days . '天';
        }
    } else {
        $ycq = '';
    }
    return array("id" => $item['id'], "title" => $item['title'], "logo" => $_FANWE['site_url'] . $item['image_1'], "logo_1" => $_FANWE['site_url'] . $item['image_2'], "logo_2" => $_FANWE['site_url'] . $item['image_3'], "merchant_logo" => $_FANWE['site_url'] . $item['merchant_logo'], "create_time" => $item['create_time'], "create_time_format" => getBeforeTimelag($item['create_time']), "xpoint" => $item['merchant_xpoint'], "ypoint" => $item['merchant_ypoint'], "address" => $item['merchant_api_address'], "content" => $item['content'], "is_sc" => $is_sc, "comment_count" => intval($item['comment_count']), "merchant_id" => intval($item['merchant_id']), "begin_time_format" => fToDate($item['begin_time'], 'Y-m-d'), "end_time_format" => fToDate($item['end_time'], 'Y-m-d'), "ycq" => $ycq, "url" => $item['url'], "city_name" => $item['city_name']);
}
Example #22
0
    /**
     * 获取分类下热门主题
     */
    public function getHotTopicList($tid, $fid, $num)
    {
        global $_FANWE;
        $where = '';
        if ($fid > 0) {
            $fids = TopicService::getForumIDs($fid);
            if (count($fids) == 1) {
                $where .= ' AND fid = ' . $fid;
            } else {
                $where .= ' AND fid IN (' . implode(',', $fids) . ')';
            }
        }
        if ($tid > 0) {
            $where .= ' AND tid <> ' . $tid;
        }
        if (!empty($where)) {
            $where = 'WHERE' . $where;
            $where = str_replace('WHERE AND', 'WHERE', $where);
        }
        $list = array();
        $sql = 'SELECT fid,tid,title,create_time,lastpost,lastposter,
			uid,post_count,share_id
			FROM ' . FDB::table('forum_thread') . '
			' . $where . ' ORDER BY post_count DESC,tid DESC LIMIT 0,' . $num;
        $res = FDB::query($sql);
        while ($data = FDB::fetch($res)) {
            $data['time'] = getBeforeTimelag($data['create_time']);
            $data['last_time'] = getBeforeTimelag($data['lastpost']);
            $data['url'] = FU('club/detail', array('tid' => $data['tid']));
            $list[$data['share_id']] = $data;
        }
        return $list;
    }
Example #23
0
<?php

$mlid = intval($_FANWE['request']['lid']);
$message = trim($_FANWE['request']['message']);
if (empty($mlid) || empty($message)) {
    exit;
}
$message = cutStr($message, 200);
$result['status'] = FS('Message')->replyMsg($mlid, $_FANWE['uid'], $_FANWE['user_name'], $message);
if ($result['status'] > 0) {
    $result['time'] = getBeforeTimelag(TIME_UTC);
    express($message);
    $result['message'] = nl2br($message);
}
outputJson($result);
Example #24
0
}
$share = FS('Share')->getShareById($share_id);
//没有分享直接退出
if (empty($share)) {
    exit;
}
$result = array('status' => 1, 'html' => '', 'error' => '');
if (!checkIpOperation("add_comment", SHARE_INTERVAL_TIME)) {
    $result['status'] = 0;
    $result['error'] = lang('share', 'interval_tips');
    outputJson($result);
}
$check_result = FS('Share')->checkWord($_FANWE['request']['content'], 'content');
if ($check_result['error_code'] == 1) {
    $result['status'] = 0;
    $result['error'] = $check_result['error_msg'];
    outputJson($result);
}
$comment_id = FS('Share')->saveComment($_FANWE['request']);
//FS("User")->updateUserScore($_FANWE['uid'],'share','comments',$_FANWE['request']['content'],$comment_id);
$comment = FS('Share')->getShareComment($comment_id);
$comment['user'] = array('uid' => $_FANWE['uid'], 'user_name' => $_FANWE['user_name'], 'url' => FU('u/index', array('uid' => $_FANWE['uid'])));
$comment['time'] = getBeforeTimelag($comment['create_time']);
$is_remove_comment = FS('Share')->getIsRemoveComment($share);
$args = array('comment' => $comment, 'is_remove_comment' => $is_remove_comment);
if ($_FANWE['request']['comment_type'] == 'album') {
    $result['html'] = tplFetch('services/album/comment_item', $args);
} else {
    $result['html'] = tplFetch('inc/share/comment_item', $args);
}
outputJson($result);
    public function run()
    {
        global $_FANWE;
        $root = array();
        $root['return'] = 1;
        $share_id = (int) $_FANWE['requestData']['share_id'];
        $share = FS('Share')->getShareById($share_id);
        if ($share) {
            $cache_data = fStripslashes(unserialize($share['cache_data']));
            unset($share['cache_data']);
            $share['time'] = getBeforeTimelag($share['create_time']);
            $share['url'] = FU('note/index', array('sid' => $share_id), true);
            $parses = m_express(&$share['content']);
            $share['parse_users'] = $parses['users'];
            $share['parse_events'] = $parses['events'];
            $share_user = FS('User')->getUserById($share['uid']);
            $share['user_name'] = $share_user['user_name'];
            $share['user_avatar'] = avatar($share_user['uid'], 'm', $share_user['server_code'], 1, true);
            if ($_FANWE['uid'] == $share['uid']) {
                $share['is_follow_user'] = -1;
            } else {
                if (FS('User')->getIsFollowUId($share['uid'])) {
                    $share['is_follow_user'] = 1;
                } else {
                    $share['is_follow_user'] = 0;
                }
            }
            $share['collects'] = array();
            if (!empty($cache_data['collects'])) {
                $collect_ids = array_slice($cache_data['collects'], 0, 20);
                if ($share['is_follow_user'] == 1) {
                    if ($ckey = array_search($_FANWE['uid'], $collect_ids) === FALSE) {
                        array_unshift($collect_ids, $_FANWE['uid']);
                        array_pop($collect_ids);
                    } else {
                        unset($collect_ids[$ckey]);
                        array_unshift($collect_ids, $_FANWE['uid']);
                    }
                }
                $collect_ids = implode(',', $collect_ids);
                $res = FDB::query("SELECT uid,user_name,server_code FROM " . FDB::table('user') . ' 
					WHERE uid IN (' . $collect_ids . ')');
                while ($item = FDB::fetch($res)) {
                    $item['user_avatar'] = avatar($item['uid'], 'm', $item['server_code'], 1, true);
                    unset($item['server_code']);
                    $share['collects'][] = $item;
                }
            }
            $share['imgs'] = array();
            if (!empty($cache_data['imgs'])) {
                foreach ($cache_data['imgs']['all'] as $img) {
                    if ($img['type'] == 'g') {
                        $img['goods_url'] = $img['url'];
                        $img['price_format'] = priceFormat($img['price']);
                    } else {
                        $img['name'] = '';
                        $img['price'] = '';
                        $img['goods_url'] = '';
                        $img['taoke_url'] = '';
                        $img['price_format'] = '';
                    }
                    unset($img['url']);
                    $img['small_img'] = getImgName($img['img'], 468, 468, 0, true);
                    $share['imgs'][] = $img;
                }
            }
        }
        $root['item'] = $share;
        m_display($root);
    }