public function run() { global $_FANWE; $root = array(); $root['return'] = 1; $is_hot = (int) $_FANWE['requestData']['is_hot']; $is_new = (int) $_FANWE['requestData']['is_new']; $page = (int) $_FANWE['requestData']['page']; $page = max(1, $page); $today_time = getTodayTime(); $field = ''; $whrer = ''; $book_photo_goods = (int) $_FANWE['setting']['book_photo_goods']; if ($book_photo_goods == 0) { $whrer = " WHERE share_data IN ('goods','photo','goods_photo')"; } elseif ($book_photo_goods == 1) { $whrer = " WHERE share_data IN ('photo','goods_photo')"; } elseif ($book_photo_goods == 2) { $whrer = " WHERE share_data IN ('goods','goods_photo')"; } if ($is_hot == 1) { $day7_time = $today_time - 604800; $field = ",(create_time > {$day7_time}) AS time_sort "; $sort = " ORDER BY time_sort DESC,collect_count DESC"; } if ($is_new == 1) { $sort = " ORDER BY share_id DESC"; } $sql_count = "SELECT COUNT(DISTINCT share_id) FROM " . FDB::table("share"); $total = FDB::resultFirst($sql_count); $page_size = PAGE_SIZE; $max_page = 100; if ($total > $max_page * $page_size) { $total = $max_page * $page_size; } if ($page > $max_page) { $page = $max_page; } $page_total = ceil($total / $page_size); $limit = ($page - 1) * $page_size . "," . $page_size; $sql = 'SELECT DISTINCT(share_id),cache_data ' . $field . ' FROM ' . FDB::table('share') . $whrer . $sort . ' LIMIT ' . $limit; $res = FDB::query($sql); $share_list = array(); while ($item = FDB::fetch($res)) { $cache_data = fStripslashes(unserialize($item['cache_data'])); $img = current($cache_data['imgs']['all']); $data = array(); $data['share_id'] = $item['share_id']; $data['img'] = getImgName($img['img'], 100, 999, 0, true); $data['height'] = $img['height'] * (100 / $img['width']); $share_list[] = $data; } $root['item'] = $share_list; $root['page'] = array("page" => $page, "page_total" => $page_total); m_display($root); }
public function run() { global $_FANWE; $root = array(); $root['return'] = 0; $uid = (int) $_FANWE['requestData']['uid']; if ($uid > 0) { if (!FS('User')->getUserExists($uid)) { $uid = 0; } } if ($uid == 0) { $uid = $_FANWE['uid']; $root['home_user'] = $_FANWE['user']; } if ($uid == 0) { $root['info'] = "请选择要查看的会员"; m_display($root); } if (!isset($root['home_user'])) { $root['home_user'] = FS("User")->getUserById($uid); unset($root['home_user']['user_name_match'], $root['home_user']['password'], $root['home_user']['active_hash'], $root['home_user']['reset_hash']); $root['home_user']['user_avatar'] = avatar($uid, 'm', $root['home_user']['server_code'], 1, true); } $page = (int) $_FANWE['requestData']['page']; $page = max(1, $page); $is_spare_flow = (int) $_FANWE['requestData']['is_spare_flow']; $img_size = 200; $scale = 2; if ($is_spare_flow == 1) { $img_size = 100; $scale = 1; } $total = FDB::resultFirst('SELECT COUNT(photo_id) FROM ' . FDB::table('share_photo') . ' WHERE uid = ' . $uid); $page_size = 20; //PAGE_SIZE; $page_total = max(1, ceil($total / $page_size)); if ($page > $page_total) { $page = $page_total; } $limit = ($page - 1) * $page_size . "," . $page_size; $photo_list = array(); $res = FDB::query('SELECT photo_id,share_id,img FROM ' . FDB::table('share_photo') . ' WHERE uid = ' . $uid . ' ORDER BY photo_id DESC LIMIT ' . $limit); while ($photo = FDB::fetch($res)) { $photo['img'] = getImgName($photo['img'], $img_size, $img_size, 1, true); $photo['height'] = round($img_size / $scale); $photo['url'] = FU('note/m', array('sid' => $photo['share_id'], 'id' => $photo['photo_id']), true); $photo_list[] = $photo; } $root['return'] = 1; $root['item'] = $photo_list; $root['page'] = array("page" => $page, "page_total" => $page_total); m_display($root); }
public function run() { global $_FANWE; $root = array(); $root['return'] = 1; $key = 'm/sharecate'; $cache_list = getCache($key); if ($cache_list !== NULL || TIME_UTC - $cache_list['cache_time'] > 600) { $cate_list = array(); $min_time = $this->getQuarterMinTime(); $max_time = getTodayTime(); FanweService::instance()->cache->loadCache('albums'); $album_cate = $_FANWE['cache']['albums']['category']; foreach ($album_cate as $k => $v) { $cate = array(); $cate['cate_id'] = $v['id']; $cate['cate_name'] = $v['name']; $cate['short_name'] = $v['name']; $cate['cate_code'] = $v['cate_code']; $cate['cate_icon'] = FS("Image")->getImageUrl($v['img'], 2); $cate['desc'] = $v['desc']; $cate['create_time'] = $v['create_time']; //获取本季分享数量 $share_count_sql = 'select count(DISTINCT s.share_id) from ' . FDB::table("share") . ' as s INNER JOIN ' . FDB::table("album_share") . ' as al on s.share_id = al.share_id where al.cid = ' . $v['id'] . " and s.day_time >= {$min_time} AND s.day_time <= {$max_time} "; $cate['share_count'] = FDB::resultFirst($share_count_sql); $cate['img_tags'] = array(); $img_size = 320; $sql = 'select s.share_id,al.title,sp.img from ' . FDB::table("share") . ' as s INNER JOIN ' . FDB::table("album_share") . ' as als ON s.share_id = als.share_id INNER JOIN ' . FDB::table("album") . ' as al ON als.album_id = al.id INNER JOIN ' . FDB::table("share_photo") . " as sp ON s.share_id = sp.share_id \r\n\t\t\t\t\tWHERE s.day_time >= {$min_time} AND s.day_time <= {$max_time} AND als.cid = " . $v['id'] . " GROUP BY s.share_id ORDER BY s.share_id desc limit 5"; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $img_data = array(); $img_data['share_id'] = $data['share_id']; $img_data['tag_name'] = $data['title']; $img_data['is_tag'] = 0; $img_data['img'] = FS("Image")->getImageUrl(getImgName($data['img'], $img_size, $img_size, 1, true), 2); $img_data['url_tag'] = urlencode($data['title']); $cate['img_tags'][] = $img_data; $img_size = 160; } $cate['txt_tags'] = array(); $cate_list[] = $cate; } $cache_list = array(); $cache_list['cate_list'] = $cate_list; $cache_list['cache_time'] = TIME_UTC; setCache($key, $cache_list); } else { $cate_list = $cache_list['cate_list']; } $root['item'] = $cate_list; m_display($root); }
public function run() { global $_FANWE; $root = array(); $root['return'] = 0; $uid = (int) $_FANWE['requestData']['uid']; if ($uid > 0) { if (!FS('User')->getUserExists($uid)) { $uid = 0; } } if ($uid == 0) { $uid = $_FANWE['uid']; $root['home_user'] = $_FANWE['user']; } if ($uid == 0) { $root['info'] = "请选择要查看的会员"; m_display($root); } if ($uid == $_FANWE['uid']) { FDB::query("DELETE FROM " . FDB::table('user_notice') . " WHERE uid='{$uid}' AND type=2"); } if (!isset($root['home_user'])) { $root['home_user'] = FS("User")->getUserById($uid); unset($root['home_user']['user_name_match'], $root['home_user']['password'], $root['home_user']['active_hash'], $root['home_user']['reset_hash']); $root['home_user']['user_avatar'] = FS("Image")->getImageUrl('.' . avatar($uid, 'm', 1), 2); } $page = (int) $_FANWE['requestData']['page']; $page = max(1, $page); $is_spare_flow = (int) $_FANWE['requestData']['is_spare_flow']; $img_width = 200; $max_height = 400; $scale = 2; if ($is_spare_flow == 1) { $img_width = 100; $scale = 1; } $sql = 'SELECT COUNT(DISTINCT share_id) FROM ' . FDB::table("user_collect") . ' WHERE c_uid = ' . $uid; $total = FDB::resultFirst($sql); $page_size = 20; //PAGE_SIZE; $page_total = max(1, ceil($total / $page_size)); if ($page > $page_total) { $page = $page_total; } $limit = ($page - 1) * $page_size . "," . $page_size; $sql = 'SELECT DISTINCT(s.share_id),s.cache_data,s.collect_count,s.comment_count,s.content,u.user_name,u.server_code FROM ' . FDB::table("user_collect") . ' AS uc INNER JOIN ' . FDB::table("share") . ' as s on s.share_id=uc.share_id INNER JOIN ' . FDB::table("user") . ' as u on u.uid=uc.uid WHERE uc.c_uid = ' . $uid . ' ORDER BY s.share_id DESC LIMIT ' . $limit; $res = FDB::query($sql); $share_list = array(); while ($data = FDB::fetch($res)) { $img_sql = 'select img,img_width,img_height from ' . FDB::table('share_photo') . " where share_id = " . $data['share_id']; $img_data = FDB::fetchFirst($img_sql); unset($data['cache_data']); $data['user_avatar'] = FS("Image")->getImageUrl('.' . avatar($data['uid'], 'm', 1), 2); $data['img'] = FS("Image")->getImageUrl(getImgName($img_data['img'], $img_width, $max_height, 2, true), 2); $data['big_img'] = FS("Image")->getImageUrl(getImgName($img_data['img'], 468, 468, 1, true), 2); $data['height'] = $img_data['img_height'] * ($img_width / $img_data['img_width']); $data['height'] = $data['height'] > $max_height ? $max_height : $data['height']; $data['height'] = round($data['height'] / $scale); $data['width'] = $img_data['img_width']; m_express(&$data, $data['content']); $share_list[] = $data; } $root['return'] = 1; $root['item'] = $share_list; $root['page'] = array("page" => $page, "page_total" => $page_total); m_display($root); }
$is_next = 1; } else { $is_next = 0; } $share_list = FDB::fetchAll($sql); if ($share_list) { $share_list = FS('Share')->getShareDetailList($share_list, false, false, false, true, 2); $list = array(); $current_user = array(); $current_user['u_url'] = FU('u/index', array('uid' => $_FANWE['uid'])); $current_user['avt'] = avatar($_FANWE['uid'], 's', $is_src = 1); $i = 0; foreach ($share_list as $k => $v) { $list[$i] = $v; $img = FDB::resultFirst("select img from " . FDB::table("share_photo") . " where share_id = " . $v['share_id'] . " and img <> '' "); $img = getImgName($img, $img_width, 999); $list[$i]['share_img'] = $img; $height_img = $_FANWE['site_url'] . substr($img, 2); $img_size = getimagesize($height_img); $height = $img_size[1]; $list[$i]['avt'] = avatar($v['uid'], 's', $is_src = 1); $list[$i]['height'] = $height; $list[$i]['width'] = $img_width; $parent_id = FDB::resultFirst("select parent_id from " . FDB::table("share") . " where share_id = " . $v['share_id']); if ($parent_id == 0) { $list[$i]['isOriginal'] = 1; } else { $list[$i]['isOriginal'] = 0; } $list[$i]['likeStatus'] = FS('Share')->getIsCollectByUid($v['share_id'], $_FANWE['uid']) ? 1 : 0; $list[$i]['isMe'] = $v['uid'] == $_FANWE['uid'] ? 1 : 0;
/** * 会员最新动态日志获取 * by fishsword * @param uid 会员ID num 取出指定数量 * @return array * */ public function getUserActivityLog($uid, $num = 10) { if (!$uid) { return; } $sql = 'select * from ' . FDB::table('user_activity_log') . ' where uid = ' . $uid . ' order by create_time desc limit ' . $num; $res = FDB::query($sql); $log_data = array(); while ($data = FDB::fetch($res)) { $mes = array(); switch ($data['type']) { case 1: $f_name = FDB::resultFirst("select user_name from " . FDB::table("user") . " where uid = " . $data['object_id']); $u_url = FU('u/index', array('uid' => $data['object_id'])); $user_info = '<a href="' . $u_url . '">' . $f_name . '</a>'; $mes['message'] = printf(lang('user', 'user_follow_log'), $user_info); break; case 2: $c_uid = FDB::resultFirst("select c_uid from " . FDB::table("user_collect") . " where uid = " . $uid . " and share_id = " . $data['object_id']); $share_name = FDB::resultFirst("select title from " . FDB::talbe("share") . " where share_id = " . $data['object_id']); $user_name = FDB::resultFirst("select user_name from " . FDB::table("user") . " where uid = " . $c_uid); $u_url = FU('u/index', array('uid' => $c_uid)); $user_info = '<a href="' . $u_url . '">' . $user_name . '</a>'; $share_url = FU('note/index', array('sid' => $data['object_id'])); $share_info = '<a href="' . $share_url . '">' . $share_name . '</a>'; $mes['message'] = printf(lang('user', 'user_collect_log'), $user_info, $share_info); break; case 3: $comment_id = $data['object_id']; $comment_data = FDB::fetchFirst("select * from " . FDB::table('share_comment') . " where comment_id = " . $comment_id); $user_name = FDB::resultFirst("select user_name from " . FDB::table('user') . " where uid = " . $comment_data['uid']); $share_name = FDB::resultFirst("select title from " . FDB::table('share') . " where share_id = " . $comment_data['share_id']); $mes['uid'] = $comment_data['uid']; $u_url = FU('u/index', array('uid' => $comment_data['uid'])); $user_info = '<a href="' . $u_url . '">' . $user_name . '</a>'; $share_url = FU('note/index', array('sid' => $comment_data['share_id'])); $share_info = '<a href="' . $share_url . '">' . $share_name . '</a>'; if ((int) $comment_data['parent_id'] > 0) { $mes['message'] = printf(lang('user', 'user_repeate_comment_log'), $user_name, $share_info); } else { $mes['message'] = printf(lang('user', 'user_comment_log'), $user_name, $share_info); } break; case 4: //预留 break; case 5: //预留 break; case 6: $share_id = $data['object_id']; $sql = 'select sp.img as img,al.id as album_id,al.title as album_name from ' . FDB::table("share") . ' as s left join ' . FDB::table('album_share') . ' as als on als.share_id = s.share_id left join ' . FDB::table('album') . ' as al on als.album_id = al.id where s.share_id = ' . $share_id; $share_info = FDB::fetchFirst($share_info); $img_url = getImgName($share_info['img'], 38, 38, 1, true); $img_info = '<a href="' . FU('note/index', array('sid' => $share_id['share_id'])) . '" class="img"><img src="' . $img_url . '" width = 38 height = 38 /></a>'; $album_info = '<a href="' . FU("album/show", array('id' => $album['id'])) . '">' . $share_info['album_name'] . '</a>'; $mes['message'] = printf(lang('user', 'user_share_log'), $img_info, $album_info); break; case 7: $album_follow_id = $data['object_id']; $sql = 'select u.uid as uid, u.user_name as user_name,al.title as album_name,alf.album_id as album_id from ' . FDB::table('album_follow') . ' as alf left join ' . FDB::table('album') . ' as al on alf.album_id = al.id left join ' . FDB::table('user') . ' as u on alf.uid = u.f_uid where alf.id = ' . $album_follow_id; $album_info = FDB::fetchFirst($sql); $u_url = FU('u/index', array('uid' => $album_info['uid'])); $album_url = FU("album/show", array('id' => $album_info['album_id'])); $user_info = '<a href="' . $u_url . '">' . $album_info['user_name'] . '</a>'; $album_info = '<a href="' . $album_url . '">' . $album_info['album_name'] . '</a>'; $mes['message'] = printf(lang('user', 'user_album_log'), $user_info, $album_info); break; } $log_data[] = $mes; } return $log_data; }
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); }
} ?> </ul> </div> <div class="mb25 hot_event"> <h3 class="mb10">热门活动</h3> <ul><?php if (is_array($hot_events)) { foreach ($hot_events as $hot_event) { ?> <li> <a target="_blank" href="<?php echo $hot_event['url']; ?> "><img class="hot_pic" width="50" height="50" src="<?php echo getImgName($hot_event['imgs'][0]['img'], 100, 100, 0); ?> " /></a> <div class="hot_title"> <p><a target="_blank" href="<?php echo $hot_event['url']; ?> "><?php echo cutStr($hot_event['title'], 46, '...'); ?> </a></p> <?php echo $hot_event['thread_count']; ?> 回应 </div>
<img class="big_book" style="right:37px" src="./tpl/images/book_13x13.png"> <a class="big_detail" ref="nofollow" style="right:10px" target="_blank" href="<?php echo $share_item_img['url']; ?> ">详情</a> </div> <?php } else { ?> <div class="pic_b_bd"> <a class="add_to_album_btn" href="javascript:;" style="display: none;" onclick="$.Show_Rel_Album(<?php echo $share_item_img['id']; ?> ,'photo');"></a> <img class="lazyload" original="<?php echo getImgName($share_item_img['img'], 468, 468, 0); ?> " src="./tpl/images/lazyload.gif"> </div> <div class="show_big"> <img class="big_book" src="./tpl/images/book_13x13.png"> <a class="big_detail" ref="nofollow" target="_blank" href="<?php echo $share_item_img['url']; ?> ">详情</a> <img class="big_cur" src="./tpl/images/big_13x13.png"> <a class="bigimg" ref="nofollow" target="_blank" href="<?php echo $share_item_img['img']; ?> ">查看原图</a> </div>
/** * 当前模板用到的相关函数 */ function getHotCate() { global $_FANWE; $args = array(); FanweService::instance()->cache->loadCache('albums'); $category_id = urldecode($_FANWE['request']['hot']); $tag = $_FANWE['request']['tag']; $sort = $_FANWE['request']['sort']; $link_url = $_FANWE['site_url'] . "services/service.php?m=index&a=share&width=190&p=2"; $json_url = $_FANWE['site_url'] . "services/service.php?m=index&a=share&width=190"; //判断排序 if ($sort) { if ($sort == 'hot') { $link_url .= "&sort=collect_count"; $json_url .= "&sort=collect_count"; } } //判断分类 if ($category_id) { $args['category_id'] = $category_id; $link_url .= "&cate=" . $category_id; $json_url .= "&cate=" . $category_id; } if ($tag) { $link_url .= "&tag=" . $tag; $json_url .= "&tag=" . $tag; } $is_cate = false; $today_time = getTodayTime(); $day7_time = $today_time - 604800; $img_width = 190; $cate_id = $category_id; $sort_field = $_FANWE['request']['sort']; $page_num = intval($_FANWE['setting']['share_index_page']) ? intval($_FANWE['setting']['share_index_page']) : 30; $is_cate = false; if ($cate_id) { $is_cate = true; } if ($is_cate) { $condition .= " AND als.cid = " . $cate_id; $join_sql = ' LEFT JOIN ' . FDB::table('album_share') . ' AS als ON als.share_id = s.share_id '; } $audit_index = intval($_FANWE['setting']['audit_index']); if ($audit_index) { $condition .= " AND s.status =1 "; } $page = intval($_REQUEST['p']); $field = ",(s.create_time > {$day7_time}) AS time_sort "; $sort = " "; if ($sort_field == 'hot') { $sort = " ORDER BY s.collect_count DESC "; } else { $sort = " ORDER BY s.share_id DESC "; } $sql = 'SELECT DISTINCT(s.share_id),s.uid,s.content,s.collect_count,s.comment_count,s.create_time,s.cache_data ,s.parent_id ' . $field . ' FROM ' . FDB::table('share') . ' AS s ' . $join_sql . ' where s.share_data <> ' . " 'default' " . $condition . $sort . ' LIMIT ' . $page_num; $is_next = 1; $share_list = FDB::fetchAll($sql); $scale = 1; if ($share_list) { $share_list = FS('Share')->getShareDetailList($share_list, false, false, false, true, 2); $list = array(); $current_user = array(); $current_user['u_url'] = FU('u/index', array('uid' => $_FANWE['uid'])); $current_user['avt'] = avatar($_FANWE['uid'], 's', $is_src = 1); $i = 0; foreach ($share_list as $k => $v) { $list[$i] = $v; $img = FDB::fetchFirst("select img,img_height,img_width,is_animate,video from " . FDB::table("share_photo") . " where share_id = " . $v['share_id'] . " and img <> '' "); if ($img['is_animate'] == 1) { $img_url = $img['img']; } else { $img_url = getImgName($img['img'], $img_width, 999, 2, true); } $is_video = 0; if (!empty($img['video'])) { $is_video = 1; $vedio_url = $img['video']; } $list[$i]['is_video'] = $is_video; $list[$i]['video'] = $vedio_url; //$img_url = getImgName($img['img'],$img_width,999,2,true); $list[$i]['share_img'] = $img_url; $list[$i]['height'] = $img['img_height'] * ($img_width / $img['img_width']); /*获取play图标的位置*/ $list[$i]['video_style_top'] = ($list[$i]['height'] - 33) / 2; $list[$i]['video_style_right'] = (254 - 33) / 2; $list[$i]['height'] = round($list[$i]['height'] / $scale); $list[$i]['is_animate'] = $img['is_animate']; $list[$i]['width'] = $img_width; $list[$i]['avt'] = avatar($v['uid'], 's', $is_src = 1); $parent_id = FDB::resultFirst("select parent_id from " . FDB::table("share") . " where share_id = " . $v['share_id']); if ($parent_id == 0) { $list[$i]['isOriginal'] = 1; } else { $list[$i]['isOriginal'] = 0; } $list[$i]['likeStatus'] = FS('Share')->getIsCollectByUid($v['share_id'], $_FANWE['uid']) ? 1 : 0; $list[$i]['isMe'] = $v['uid'] == $_FANWE['uid'] ? 1 : 0; $list[$i]['is_relay'] = $v['is_relay']; //分享评论 $share_comments = FS('Share')->getShareCommentList($v['share_id'], '0,2'); if ($share_comments) { $share_comments_data = array(); $idxj = 0; foreach ($share_comments as $vv) { $share_comments_data[$idxj]['comment_id'] = $vv['comment_id']; $share_comments_data[$idxj]['parent_id'] = $vv['parent_id']; $share_comments_data[$idxj]['user_url'] = FU('u/album', array('uid' => $vv['user']['uid'])); $share_comments_data[$idxj]['user_name'] = $vv['user']['user_name']; $share_comments_data[$idxj]['avt'] = avatar($vv['uid'], 's', $is_src = 1); $share_comments_data[$idxj]['comment'] = cutStr($vv['content'], 20); $idxj++; } $list[$i]['comments'] = $share_comments_data; } $list[$i]['share_url'] = FU('note/index', array('sid' => $v['share_id'])); $list[$i]['u_url'] = FU('u/album', array('uid' => $v['uid'])); $list[$i]['relay_count'] = FDB::resultFirst("select relay_count from " . FDB::table("share") . " where share_id = " . $v['share_id']); $album_sql = "select a.id,a.title from " . FDB::table('album_share') . " as ah left join " . FDB::table('album') . " as a on ah.album_id = a.id where ah.share_id = " . $v['share_id']; $album = FDB::fetchFirst($album_sql); if ($album) { $list[$i]['album_title'] = $album['title']; $list[$i]['is_album'] = 1; $list[$i]['album_url'] = FU("album/show", array('id' => $album['id'])); } else { $list[$i]['album_title'] = ""; $list[$i]['is_album'] = 0; $list[$i]['album_url'] = ""; } $list[$i]['user_name'] = FDB::resultFirst("select user_name from " . FDB::table('user') . " where uid =" . $v['uid']); $i++; } $args['list'] = $list; } $args['current_user'] = $current_user; $args['link_url'] = $link_url; $args['json_url'] = $json_url; return tplFetch('inc/index/index_cate', $args); }
private function getShare() { global $_FANWE; $kwy_word = urldecode($_REQUEST['kw']); $page_title = preg_replace("/\\[[^\\]]+\\]/i", "", $kwy_word); $_FANWE['nav_title'] = $page_title . ' - ' . lang('common', 'share'); $_FANWE['seo_description'] = $page_title; $_FANWE['setting']['site_description'] = ''; $count_result = BookModule::searchInfo(); $count = $count_result['share_count']; if ($count_result['user_count'] > 0) { $match_key = segmentToUnicode($kwy_word, '+'); $user_sql = "SELECT u.*, uc.*, us.*, up.* FROM " . FDB::table('user') . " u \r\n\t\t\tLEFT JOIN " . FDB::table('user_count') . " uc USING(uid)\r\n\t\t\tLEFT JOIN " . FDB::table('user_status') . " us USING(uid)\r\n\t\t\tLEFT JOIN " . FDB::table('user_profile') . " up USING(uid)\r\n\t\t\tWHERE match(u.user_name_match) against('" . $match_key . "' IN BOOLEAN MODE) limit 10"; $user_list = FDB::fetchAll($user_sql); if ($user_list) { foreach ($user_list as $k => $v) { $is_follow = FS("User")->getIsFollowUId($v['uid']); $user_list[$k]['is_follow'] = $is_follow; } } } $page_num = intval($_FANWE['setting']['share_search_page']) ? intval($_FANWE['setting']['share_search_page']) : 30; $is_root = false; $img_width = 190; $kwy_word = urldecode($_FANWE['request']['kw']); if (!empty($kwy_word)) { $match_key = segmentToUnicode($kwy_word, '+'); $share_condition = " AND match(share_content_match) against('" . $match_key . "' IN BOOLEAN MODE) "; } $limit = $page_num; $sql = 'SELECT * FROM ' . FDB::table("share") . ' WHERE share_data <> ' . " 'default' " . $share_condition . "\r\n\t\t\t\tORDER BY share_id DESC LIMIT " . $limit; $share_list = FDB::fetchAll($sql); $scale = 1; if ($share_list) { $share_list = FS('Share')->getShareDetailList($share_list, false, false, false, true, 2); $list = array(); $current_user = array(); $current_user['u_url'] = FU('u/index', array('uid' => $_FANWE['uid'])); $current_user['avt'] = avatar($_FANWE['uid'], 's', $is_src = 1); $i = 0; foreach ($share_list as $k => $v) { $list[$i] = $v; $img = FDB::fetchFirst("select img,img_height,img_width from " . FDB::table("share_photo") . " where share_id = " . $v['share_id'] . " and img <> '' "); $img_url = getImgName($img['img'], $img_width, 999, 2, true); $list[$i]['share_img'] = $img_url; $list[$i]['height'] = $img['img_height'] * ($img_width / $img['img_width']); $list[$i]['height'] = round($list[$i]['height'] / $scale); $list[$i]['width'] = $img_width; $list[$i]['avt'] = avatar($v['uid'], 's', $is_src = 1); $parent_id = FDB::resultFirst("select parent_id from " . FDB::table("share") . " where share_id = " . $v['share_id']); if ($parent_id == 0) { $list[$i]['isOriginal'] = 1; } else { $list[$i]['isOriginal'] = 0; } $list[$i]['likeStatus'] = FS('Share')->getIsCollectByUid($v['share_id'], $_FANWE['uid']) ? 1 : 0; $list[$i]['isMe'] = $v['uid'] == $_FANWE['uid'] ? 1 : 0; //分享评论 $share_comments = FS('Share')->getShareCommentList($v['share_id'], '0,2'); if ($share_comments) { $share_comments_data = array(); $idxj = 0; foreach ($share_comments as $vv) { $share_comments_data[$idxj]['comment_id'] = $vv['comment_id']; $share_comments_data[$idxj]['parent_id'] = $vv['parent_id']; $share_comments_data[$idxj]['user_url'] = FU('u/index', array('uid' => $vv['user']['uid'])); $share_comments_data[$idxj]['user_name'] = $vv['user']['user_name']; $share_comments_data[$idxj]['avt'] = avatar($vv['uid'], 's', $is_src = 1); $share_comments_data[$idxj]['comment'] = cutStr($vv['content'], 20); $idxj++; } $list[$i]['comments'] = $share_comments_data; } $list[$i]['share_url'] = FU('note/index', array('sid' => $v['share_id'])); $list[$i]['u_url'] = FU('u/index', array('uid' => $v['uid'])); $list[$i]['relay_count'] = FDB::resultFirst("select relay_count from " . FDB::table("share") . " where share_id = " . $v['share_id']); $album_sql = "select a.id,a.title from " . FDB::table('album_share') . " as ah left join " . FDB::table('album') . " as a on ah.album_id = a.id where ah.share_id = " . $v['share_id']; $album = FDB::fetchFirst($album_sql); if ($album) { $list[$i]['album_title'] = $album['title']; $list[$i]['is_album'] = 1; $list[$i]['album_url'] = FU("album/show", array('id' => $album['id'])); } else { $list[$i]['album_title'] = ""; $list[$i]['is_album'] = 0; $list[$i]['album_url'] = ""; } $list[$i]['zf_count'] = 10; $list[$i]['xh_count'] = 20; $list[$i]['user_name'] = FDB::resultFirst("select user_name from " . FDB::table('user') . " where uid =" . $v['uid']); $i++; } } $link_url = $_FANWE['site_url'] . "services/service.php?m=search&a=share&width=190&p=2&kwy_word=" . $kwy_word; $json_url = $_FANWE['site_url'] . "services/service.php?m=search&a=share&width=190&kwy_word=" . $kwy_word; include template('page/book/book_index'); display(); }
public function fav() { global $_FANWE; Cache::getInstance()->loadCache('citys'); $home_uid = $_FANWE['home_uid']; $home_user = FS('User')->getUserById($home_uid); $current_menu = 'fav'; $reside_province = $_FANWE['cache']['citys']['all'][$home_user['reside_province']]['name']; $reside_city = $_FANWE['cache']['citys']['all'][$home_user['reside_city']]['name']; $page_size = 30; $pageargs = array(); $pageargs['uid'] = $home_uid; $fav_share_ids = array(); $sql = 'SELECT parent_id FROM ' . FDB::table("share") . ' WHERE type = \'fav\' AND uid = ' . $home_uid . ' GROUP BY parent_id'; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $fav_share_ids[] = $data['parent_id']; } $count = count($fav_share_ids); if ($count > 0) { $sql = 'SELECT uid FROM ' . FDB::table("share") . ' WHERE share_id ' . FDB::createIN($fav_share_ids) . ' GROUP BY uid'; $fav_uids = array(); $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $fav_uids[] = $data['uid']; } $fav_share_ids = array(); $sql = 'SELECT parent_id FROM ' . FDB::table("share") . ' WHERE type = \'fav\' AND uid ' . FDB::createIN($fav_uids) . ' GROUP BY parent_id ORDER BY parent_id DESC LIMIT 0,100'; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $fav_share_ids[] = $data['parent_id']; } $sql = 'SELECT * FROM ' . FDB::table("share") . ' WHERE share_id ' . FDB::createIN($fav_share_ids) . ' AND share_data IN (\'goods\',\'goods_photo\',\'photo\') AND uid <> ' . $home_uid . ' GROUP BY share_id ORDER BY share_id DESC LIMIT 0,10'; $fav_list = FDB::fetchAll($sql); $fav_list = FS('Share')->getShareDetailList($fav_list); } $pager = buildPage('u/' . ACTION_NAME, $pageargs, $count, $_FANWE['page'], $page_size); $fav_share_ids = array(); $sql = 'SELECT parent_id FROM ' . FDB::table("share") . ' WHERE type = \'fav\' AND uid = ' . $home_uid . ' GROUP BY parent_id ORDER BY parent_id DESC LIMIT ' . $pager['limit']; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $fav_share_ids[] = $data['parent_id']; } $share_list = array(); if (count($fav_share_ids) > 0) { $sql = 'SELECT * FROM ' . FDB::table("share") . ' WHERE share_id ' . FDB::createIN($fav_share_ids) . ' GROUP BY share_id ORDER BY share_id DESC LIMIT 0,10'; $share_list = FDB::fetchAll($sql); $share_list = FS('Share')->getShareDetailList($share_list, true, true, true); } $args = array('share_list' => &$share_list, 'pager' => &$pager); $share_list_html = tplFetch("inc/u/u_share_list", $args); $hot_events = FS('Event')->getHotImgEvent(3); $today_daren = FS('Daren')->getIndexTodayDaren(); //获取我关注的会员编号 $uids = FS("User")->getUserFollowsCache($home_uid); //获取我关注的会员编号 $fav_ids = FS('User')->getUserFans($home_uid, 12); $is_show_follow = false; if ($home_uid != $_FANWE['uid']) { if (!FS('User')->getIsFollowUId($home_uid)) { $is_show_follow = true; } } $page_num = intval($_FANWE['setting']['share_self_page']) ? intval($_FANWE['setting']['share_self_page']) : 30; $is_root = false; $img_width = 190; $page = intval($_REQUEST['p']); $limit = $page_num; $fav_share_ids = array(); $sql = 'SELECT parent_id FROM ' . FDB::table("share") . ' WHERE type = \'fav\' AND uid = ' . $home_uid . ' GROUP BY parent_id ORDER BY parent_id DESC LIMIT ' . $limit; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $fav_share_ids[] = $data['parent_id']; } $share_list = array(); if (count($fav_share_ids) > 0) { $sql = 'SELECT * FROM ' . FDB::table("share") . ' WHERE share_id ' . FDB::createIN($fav_share_ids) . ' and share_data <> ' . " 'default' \r\n\t\t\t\tGROUP BY share_id ORDER BY share_id DESC LIMIT 0,10"; $share_list = FDB::fetchAll($sql); $share_list = FS('Share')->getShareDetailList($share_list, true, true, true); } $share_list = FDB::fetchAll($sql); $scale = 1; if ($share_list) { $share_list = FS('Share')->getShareDetailList($share_list, false, false, false, true, 2); $list = array(); $current_user = array(); $current_user['u_url'] = FU('u/index', array('uid' => $_FANWE['uid'])); $current_user['avt'] = avatar($_FANWE['uid'], 's', $is_src = 1); $i = 0; foreach ($share_list as $k => $v) { $list[$i] = $v; $img = FDB::fetchFirst("select img,img_height,img_width,is_animate,video from " . FDB::table("share_photo") . " where share_id = " . $v['share_id'] . " and img <> '' "); if ($img['is_animate']) { $img_url = $img['img']; } else { $img_url = getImgName($img['img'], $img_width, 999, 2, true); } $is_video = 0; if (!empty($img['video'])) { $is_video = 1; $vedio_url = $img['video']; } $list[$i]['is_video'] = $is_video; $list[$i]['video'] = $vedio_url; $list[$i]['share_img'] = $img_url; $list[$i]['height'] = $img['img_height'] * ($img_width / $img['img_width']); /*获取play图标的位置*/ $list[$i]['video_style_top'] = ($list[$i]['height'] - 33) / 2; $list[$i]['video_style_right'] = (254 - 33) / 2; $list[$i]['height'] = round($list[$i]['height'] / $scale); $list[$i]['width'] = $img_width; $list[$i]['avt'] = avatar($v['uid'], 's', $is_src = 1); $parent_id = FDB::resultFirst("select parent_id from " . FDB::table("share") . " where share_id = " . $v['share_id']); if ($parent_id == 0) { $list[$i]['isOriginal'] = 1; } else { $list[$i]['isOriginal'] = 0; } $list[$i]['likeStatus'] = FS('Share')->getIsCollectByUid($v['share_id'], $_FANWE['uid']) ? 1 : 0; $list[$i]['isMe'] = $v['uid'] == $_FANWE['uid'] ? 1 : 0; //分享评论 $share_comments = FS('Share')->getShareCommentList($v['share_id'], '0,2'); if ($share_comments) { $share_comments_data = array(); $idxj = 0; foreach ($share_comments as $vv) { $share_comments_data[$idxj]['comment_id'] = $vv['comment_id']; $share_comments_data[$idxj]['parent_id'] = $vv['parent_id']; $share_comments_data[$idxj]['user_url'] = FU('u/index', array('uid' => $vv['user']['uid'])); $share_comments_data[$idxj]['user_name'] = $vv['user']['user_name']; $share_comments_data[$idxj]['avt'] = avatar($vv['uid'], 's', $is_src = 1); $share_comments_data[$idxj]['comment'] = cutStr($vv['content'], 20); $idxj++; } $list[$i]['comments'] = $share_comments_data; } $list[$i]['share_url'] = FU('note/index', array('sid' => $v['share_id'])); $list[$i]['u_url'] = FU('u/index', array('uid' => $v['uid'])); $list[$i]['relay_count'] = FDB::resultFirst("select relay_count from " . FDB::table("share") . " where share_id = " . $v['share_id']); $album_sql = "select a.id,a.title from " . FDB::table('album_share') . " as ah left join " . FDB::table('album') . " as a on ah.album_id = a.id where ah.share_id = " . $v['share_id']; $album = FDB::fetchFirst($album_sql); if ($album) { $list[$i]['album_title'] = $album['title']; $list[$i]['is_album'] = 1; $list[$i]['album_url'] = FU("album/show", array('id' => $album['id'])); } else { $list[$i]['album_title'] = ""; $list[$i]['is_album'] = 0; $list[$i]['album_url'] = ""; } $list[$i]['user_name'] = FDB::resultFirst("select user_name from " . FDB::table('user') . " where uid =" . $v['uid']); $i++; } } $link_url = $_FANWE['site_url'] . "services/service.php?m=user&a=sharefav&width=190&p=2&home_uid=" . $home_uid; $json_url = $_FANWE['site_url'] . "services/service.php?m=user&a=sharefav&width=190&home_uid=" . $home_uid; include template('page/u/u_fav'); display(); }
</span><i></i></span> <a class="add_to_album_btn" href="javascript:;" style="display: none;" onclick="$.Show_Rel_Album(<?php echo $share_img['id']; ?> ,'goods');"></a> </li> <?php } else { ?> <li> <a style="width:200px;" href="<?php echo $share_img['url']; ?> " target="_blank"> <img class="book_img lazyload" original="<?php echo getImgName($share_img['img'], 200, 999, 0); ?> " width=200 src="./tpl/images/lazyload.gif"/> </a> <a class="add_to_album_btn" href="javascript:;" style="display: none;" onclick="$.Show_Rel_Album(<?php echo $share_img['id']; ?> ,'photo');"></a> </li> <?php } } } ?> </ul> <div class="favorite">
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); }
echo $relay_share_img['url']; ?> ">详情</a> </div> </li> <?php } else { ?> <li class="pic_b_f r5" style="display: none;"> <div class="pic_b_bd"> <a class="add_to_album_btn" href="javascript:;" style="display: none;" onclick="$.Show_Rel_Album(<?php echo $relay_share_img['id']; ?> ,'photo');"></a> <img class="lazyload" original="<?php echo getImgName($relay_share_img['img'], 468, 468, 0); ?> " src="./tpl/images/lazyload.gif"> </div> <div class="show_big"> <img class="big_book" src="./tpl/images/book_13x13.png"> <a class="big_detail" ref="nofollow" target="_blank" href="<?php echo $relay_share_img['url']; ?> ">详情</a> <img class="big_cur" src="./tpl/images/big_13x13.png"> <a class="bigimg" ref="nofollow" target="_blank" href="<?php echo $relay_share_img['img']; ?> ">查看原图</a> </div>
} else { $is_next = 0; } $share_list = FDB::fetchAll($sql); $scale = 1; if ($share_list) { $share_list = FS('Share')->getShareDetailList($share_list, false, false, false, true, 2); $list = array(); $current_user = array(); $current_user['u_url'] = FU('u/index', array('uid' => $_FANWE['uid'])); $current_user['avt'] = avatar($_FANWE['uid'], 's', $is_src = 1); $i = 0; foreach ($share_list as $k => $v) { $list[$i] = $v; $img = FDB::fetchFirst("select img,img_height,img_width from " . FDB::table("share_photo") . " where share_id = " . $v['share_id'] . " and img <> '' "); $img_url = getImgName($img['img'], $img_width, 999, 2, true); $list[$i]['share_img'] = $img_url; $list[$i]['height'] = $img['img_height'] * ($img_width / $img['img_width']); $list[$i]['height'] = round($list[$i]['height'] / $scale); $list[$i]['width'] = $img_width; $list[$i]['avt'] = avatar($v['uid'], 's', $is_src = 1); $parent_id = FDB::resultFirst("select parent_id from " . FDB::table("share") . " where share_id = " . $v['share_id']); if ($parent_id == 0) { $list[$i]['isOriginal'] = 1; } else { $list[$i]['isOriginal'] = 0; } $list[$i]['likeStatus'] = FS('Share')->getIsCollectByUid($v['share_id'], $_FANWE['uid']) ? 1 : 0; $list[$i]['isMe'] = $v['uid'] == $_FANWE['uid'] ? 1 : 0; //分享评论 $share_comments = FS('Share')->getShareCommentList($v['share_id'], '0,2');
/** * 分享列表详细数据 * @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; }
public function run() { global $_FANWE; $root = array(); $root['return'] = 1; $is_hot = (int) $_FANWE['requestData']['is_hot']; $is_new = (int) $_FANWE['requestData']['is_new']; $cid = (int) $_FANWE['requestData']['cid']; $tag = trim($_FANWE['requestData']['tag']); $is_spare_flow = (int) $_FANWE['requestData']['is_spare_flow']; $page = (int) $_FANWE['requestData']['page']; $page = max(1, $page); $img_width = 200; $max_height = 400; $scale = 2; if ($is_spare_flow == 1) { $img_width = 100; $scale = 1; } $today_time = getTodayTime(); $field = ''; $whrer = ''; $joins = ''; $book_photo_goods = (int) $_FANWE['setting']['book_photo_goods']; if ($book_photo_goods == 0) { $whrer = " WHERE s.share_data IN ('goods','photo','goods_photo')"; } elseif ($book_photo_goods == 1) { $whrer = " WHERE s.share_data IN ('photo','goods_photo')"; } elseif ($book_photo_goods == 2) { $whrer = " WHERE s.share_data IN ('goods','goods_photo')"; } if ($cid > 0 && isset($_FANWE['cache']['goods_category']['all'][$cid])) { if ($_FANWE['cache']['goods_category']['all'][$cid]['is_root'] == 0) { $is_cate = true; $whrer .= " AND sc.cid = " . $cid; $joins .= ' INNER JOIN ' . FDB::table('album_share') . ' AS sc ON s.share_id = sc.share_id '; } else { $cid = 0; } } else { $cid = 0; } if (!empty($tag)) { $is_match = true; $match_key = segmentToUnicode($tag, '+'); $whrer .= " AND match(s.share_content_match) against('" . $match_key . "' IN BOOLEAN MODE) "; } $joins .= ' INNER JOIN ' . FDB::table('share_photo') . ' as sp ON sp.share_id = s.share_id '; if ($is_hot == 1) { $day7_time = $today_time - 604800; $field = ",(s.create_time > {$day7_time}) AS time_sort "; $sort = " ORDER BY time_sort DESC,s.collect_count DESC"; } if ($is_new == 1) { $sort = " ORDER BY s.share_id DESC"; } $args = md5($is_hot . '/' . $is_new . '/' . $cid . '/t' . $tag . '/' . $is_spare_flow . '/' . $page); $key = 'm/sharelist/' . substr($args, 0, 2) . '/' . substr($args, 2, 2) . '/' . $args; $cache_list = getCache($key); if ($cache_list === NULL || TIME_UTC - $cache_list['cache_time'] > 600) { $sql_count = "SELECT COUNT(DISTINCT s.share_id) FROM " . FDB::table("share") . ' AS s' . $joins . $whrer; $total = FDB::resultFirst($sql_count); $page_size = 20; //PAGE_SIZE; $max_page = 100; if ($total > $max_page * $page_size) { $total = $max_page * $page_size; } if ($page > $max_page) { $page = $max_page; } $page_total = max(ceil($total / $page_size), 1); if ($page > $page_total) { $page = $page_total; } $limit = ($page - 1) * $page_size . "," . $page_size; $sql = 'SELECT DISTINCT(s.share_id),sp.img_width,sp.img_height,sp.img ' . $field . ' FROM ' . FDB::table('share') . ' AS s' . $joins . $whrer . $sort . ' LIMIT ' . $limit; $res = FDB::query($sql); $share_list = array(); while ($item = FDB::fetch($res)) { $cache_data = fStripslashes(unserialize($item['cache_data'])); $img = current($cache_data['imgs']['all']); $data = array(); $data['share_id'] = $item['share_id']; $data['img'] = FS("Image")->getImageUrl(getImgName($item['img'], $img_width, $max_height, 2, true), 2); $data['height'] = $item['img_height'] * ($img_width / $item['img_width']); $data['height'] = $data['height'] > $max_height ? $max_height : $data['height']; $data['height'] = round($data['height'] / $scale); $share_list[] = $data; } $cache_list = array(); $cache_list['page_total'] = $page_total; $cache_list['share_list'] = $share_list; $cache_list['cache_time'] = TIME_UTC; setCache($key, $cache_list); } else { $page_total = $cache_list['page_total']; $share_list = $cache_list['share_list']; } $root['tag'] = $tag; $root['cid'] = $cid; $root['item'] = $share_list; $root['page'] = array("page" => $page, "page_total" => $page_total); if ($page == 1) { FanweService::instance()->cache->loadCache('madv'); $advs = $_FANWE['cache']['madv']['sharelist']; if ($advs) { foreach ($advs as $adv) { $adv['img'] = FS("Image")->getImageUrl($adv['img'], 2); if ($adv['type'] == 1) { $tag_count = count($adv['data']['tags']); unset($adv['data']); $adv['data']['count'] = $tag_count; } elseif ($adv['type'] != 2 && $adv['type'] != 8) { unset($adv['data']); } unset($adv['sort'], $adv['status'], $adv['page']); $root['advs'][] = $adv; } } } m_display($root); }
public function show() { global $_FANWE; $id = (int) $_FANWE['request']['id']; if (!$id) { exit; } $album_url = FU('album/show', array('id' => $id)); $album = FS("Album")->getAlbumById($id); $is_follow_album = FS('album')->getIsFollow($id, $_FANWE['uid']); if (empty($album)) { fHeader("location: " . FU('album')); } $home_uid = $album['uid']; $home_user = FS("User")->getUserById($home_uid); $is_show_follow = false; if ($home_uid != $_FANWE['uid']) { if (!FS('User')->getIsFollowUId($home_uid)) { $is_show_follow = true; } } $is_manage_album = false; if ($_FANWE['uid'] == $album['uid']) { $is_manage_album = true; } $sql = 'SELECT * FROM ' . FDB::table('album') . ' WHERE uid = ' . $home_uid . ' and id <> ' . $id . ' ORDER BY id DESC '; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $data['imgs'] = array(); if (!empty($data['cache_data'])) { $cache_data = unserialize($data['cache_data']); $data['imgs'] = $cache_data['imgs']; unset($data['cache_data']); } $data['img_count'] = count($data['imgs']); $data['url'] = FU('album/show', array('id' => $data['id'])); $album_list[] = $data; } $page_num = intval($_FANWE['setting']['share_self_page']) ? intval($_FANWE['setting']['share_self_page']) : 30; $is_root = false; $img_width = 190; $limit = $page_num; $share_ids = array(); $res = FDB::query('SELECT share_id FROM ' . FDB::table('album_share') . ' WHERE album_id = ' . $id . ' ORDER BY share_id DESC '); while ($data = FDB::fetch($res)) { $share_ids[] = $data['share_id']; } $share_ids = implode(',', $share_ids); if ($share_ids) { $sql = 'SELECT * FROM ' . FDB::table("share") . ' WHERE share_data <> ' . " 'default' and share_id IN (" . $share_ids . ") \r\n\t\t\tORDER BY share_id DESC LIMIT " . $limit; $share_list = FDB::fetchAll($sql); } if ($share_list) { $share_list = FS('Share')->getShareDetailList($share_list, false, false, false, true, 2); $list = array(); $current_user = array(); $current_user['u_url'] = FU('u/index', array('uid' => $_FANWE['uid'])); $current_user['avt'] = avatar($_FANWE['uid'], 's', $is_src = 1); $i = 0; foreach ($share_list as $k => $v) { $list[$i] = $v; $img_info = FDB::fetchFirst("select img,img_width,img_height,is_animate,video from " . FDB::table("share_photo") . " where share_id = " . $v['share_id'] . " and img <> '' "); if ($img_info['is_animate']) { $img = $img_info['img']; } else { $img = getImgName($img_info['img'], $img_width, 999); } $is_video = 0; $vedio_url = ''; if (!empty($img_info['video'])) { $is_video = 1; $vedio_url = $img_info['video']; } $list[$i]['is_video'] = $is_video; $list[$i]['video'] = $vedio_url; $list[$i]['share_img'] = $img; $list[$i]['avt'] = avatar($v['uid'], 's', $is_src = 1); $list[$i]['height'] = $img_info['img_height'] * ($img_width / $img_info['img_width']); /*获取play图标的位置*/ $list[$i]['video_style_top'] = ($list[$i]['height'] - 33) / 2; $list[$i]['video_style_right'] = (254 - 33) / 2; $list[$i]['width'] = $img_width; $list[$i]['share_img_org'] = $img_info['img']; $parent_id = FDB::resultFirst("select parent_id from " . FDB::table("share") . " where share_id = " . $v['share_id']); if ($parent_id == 0) { $list[$i]['isOriginal'] = 1; } else { $list[$i]['isOriginal'] = 0; } $list[$i]['likeStatus'] = FS('Share')->getIsCollectByUid($v['share_id'], $_FANWE['uid']) ? 1 : 0; $list[$i]['isMe'] = $v['uid'] == $_FANWE['uid'] ? 1 : 0; //分享评论 $share_comments = FS('Share')->getShareCommentList($v['share_id'], '0,2'); if ($share_comments) { $share_comments_data = array(); $idxj = 0; foreach ($share_comments as $vv) { $share_comments_data[$idxj]['comment_id'] = $vv['comment_id']; $share_comments_data[$idxj]['parent_id'] = $vv['parent_id']; $share_comments_data[$idxj]['user_url'] = FU('u/index', array('uid' => $vv['user']['uid'])); $share_comments_data[$idxj]['user_name'] = $vv['user']['user_name']; $share_comments_data[$idxj]['avt'] = avatar($vv['uid'], 's', $is_src = 1); $share_comments_data[$idxj]['comment'] = cutStr($vv['content'], 20); $idxj++; } $list[$i]['comments'] = $share_comments_data; } $list[$i]['share_url'] = FU('note/index', array('sid' => $v['share_id'])); $list[$i]['u_url'] = FU('u/index', array('uid' => $v['uid'])); $list[$i]['relay_count'] = FDB::resultFirst("select relay_count from " . FDB::table("share") . " where share_id = " . $v['share_id']); $album_sql = "select a.id,a.title from " . FDB::table('album_share') . " as ah left join " . FDB::table('album') . " as a on ah.album_id = a.id where ah.share_id = " . $v['share_id']; $album = FDB::fetchFirst($album_sql); if ($album) { $list[$i]['album_title'] = $album['title']; $list[$i]['is_album'] = 1; $list[$i]['album_url'] = FU("album/show", array('id' => $album['id'])); } else { $list[$i]['album_title'] = ""; $list[$i]['is_album'] = 0; $list[$i]['album_url'] = ""; } $list[$i]['user_name'] = FDB::resultFirst("select user_name from " . FDB::table('user') . " where uid =" . $v['uid']); $i++; } } if ($list) { $share_detail = $list[0]; } $link_url = $_FANWE['site_url'] . "services/service.php?m=user&a=album_share&width=190&p=2&home_uid=" . $home_uid . "&album_id=" . $id; $json_url = $_FANWE['site_url'] . "services/service.php?m=user&a=album_share&width=190&home_uid=" . $home_uid . "&album_id=" . $id; include template('page/album/album_show'); display(); }
echo $share['url']; } ?> " target="_blank"><?php $index_img = $share['index_img']; if ($index_img) { ?> <img class="img" src="<?php echo getImgName($index_img, "{$img_w}", "{$img_h}", 1); ?> " /> <?php } else { ?> <img class="img" src="<?php echo getImgName($share['imgs'][0]['img'], "{$img_w}", "{$img_h}", 1); ?> " /> <?php } ?> </a> <a class="trsp_bg w<?php echo $img_w; ?> " href="<?php if ($share['imgs']['0']['url']) { echo $share['imgs']['0']['url']; } else { echo $share['url']; }