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); }
/** * 获取带图片或商品分享的主题 * @return array */ public function getImgTopic($type, $num, $pic_num, $fid = 0, $begin = 0, $ids = array()) { global $_FANWE; $where = 'WHERE s.status = 1'; if ($fid > 0) { $fids = TopicService::getForumIDs($fid); if (count($fids) == 1) { $where .= ' AND ft.fid = ' . $fid; } else { $where .= ' AND ft.fid IN (' . implode(',', $fids) . ')'; } } if (!empty($ids)) { $ids = implode(',', $ids); if (!empty($ids)) { $where .= ' AND ft.tid NOT IN (' . $ids . ')'; } } $order = 'ft.tid DESC'; switch ($type) { case 'top': $order = 'ft.is_top DESC,ft.tid DESC'; break; case 'best': $order = 'ft.is_best DESC,ft.tid DESC'; break; case 'hot': $order = 'ft.post_count DESC,ft.tid DESC'; break; } $list = array(); $sql = 'SELECT ft.fid,ft.tid,ft.title,ft.content,ft.create_time,ft.lastpost,ft.lastposter, ft.uid,ft.post_count,ft.share_id,s.cache_data FROM ' . FDB::table('forum_thread') . ' AS ft INNER JOIN ' . FDB::table('share') . ' AS s ON s.share_id = ft.share_id AND s.share_data IN (\'goods\',\'photo\',\'goods_photo\') ' . $where . ' ORDER BY ' . $order . ' LIMIT ' . $begin . ',' . $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['lastpost']); $data['url'] = FU('club/detail', array('tid' => $data['tid'])); FS('Share')->shareImageFormat($data, $pic_num); unset($data['cache_data']); $list[$data['share_id']] = $data; } return $list; }
public function show() { global $_FANWE; $id = (int) $_FANWE['request']['id']; if (!$id) { exit; } $shop = FDB::fetchFirst('SELECT * FROM ' . FDB::table('shop') . ' WHERE shop_id = ' . $id); if (!$shop) { fHeader("location: " . FU('shop/index')); } $_FANWE['nav_title'] = $shop['shop_name'] . ' - ' . $_FANWE['nav_title']; $cache_data = fStripslashes(unserialize($shop['data'])); $shop['tags'] = $cache_data['tags']; if (empty($shop['taoke_url'])) { $shop['to_url'] = FU('tgo', array('url' => $shop['shop_url'])); } else { $shop['to_url'] = FU('tgo', array('url' => $shop['taoke_url'])); } $page_args['id'] = $id; $sql = 'SELECT COUNT(DISTINCT sg.share_id) FROM ' . FDB::table('share_goods') . ' AS sg INNER JOIN ' . FDB::table('share') . ' AS s ON s.share_id = sg.share_id WHERE s.status = 1 AND sg.shop_id = ' . $id; $share_count = FDB::resultFirst($sql); $page_size = 20; $pager = buildPage('shop/show', $page_args, $share_count, $_FANWE['page'], $page_size); $share_ids = array(); $sql = 'SELECT DISTINCT sg.share_id FROM ' . FDB::table('share_goods') . ' AS sg INNER JOIN ' . FDB::table('share') . ' AS s ON s.share_id = sg.share_id WHERE s.status = 1 AND sg.shop_id = ' . $id . ' ORDER BY sg.share_id DESC LIMIT ' . $pager['limit']; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $share_ids[] = $data['share_id']; } $share_list = array(); if (count($share_ids) > 0) { $share_ids = implode(',', $share_ids); $sql = 'SELECT * FROM ' . FDB::table('share') . ' WHERE share_id IN (' . $share_ids . ') ORDER BY share_id DESC'; $share_list = FDB::fetchAll($sql); $share_list = FS('Share')->getShareDetailList($share_list, false, true, true, false, 0, 10); } $shops_tags = FS('Shop')->getUserOtherShopAndTags($id); include template('page/shop/shop_show'); display(); }
/** * 热门有图活动主题 * @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; }
/** * 获取带图片或商品分享的问题 * @return array */ public function getImgAsk($type, $num, $pic_num, $aid = 0, $begin = 0) { global $_FANWE; $where = ' WHERE s.status = 1 '; if ($aid > 0) { $where .= ' AND at.aid = ' . $aid; } $order = 'at.tid DESC'; switch ($type) { case 'solve': $where .= ' AND at.is_solve = 1'; $order = 'at.is_solve DESC,at.tid DESC'; break; case 'hot': $order = 'at.post_count DESC,at.tid DESC'; break; } $list = array(); $share_users = array(); $sql = 'SELECT at.aid,at.tid,at.title,at.content,at.create_time,at.lastpost,at.lastposter, at.uid,at.post_count,at.share_id,s.cache_data FROM ' . FDB::table('ask_thread') . ' AS at INNER JOIN ' . FDB::table('share') . ' AS s ON s.share_id = at.share_id AND s.share_data IN (\'goods\',\'photo\',\'goods_photo\') ' . $where . ' ORDER BY ' . $order . ' LIMIT ' . $begin . ',' . $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['lastpost']); $data['url'] = FU('ask/detail', array('tid' => $data['tid'])); FS('Share')->shareImageFormat($data, $pic_num); unset($data['cache_data']); $list[$data['share_id']] = $data; } return $list; }
public function getUserBindList($uid) { $uid = (int) $uid; if (!$uid) { return false; } static $binds = array(); if (!isset($binds[$uid])) { $res = FDB::query('SELECT * FROM ' . FDB::table('user_bind') . ' WHERE uid = ' . $uid); while ($data = FDB::fetch($res)) { $bind = fStripslashes(unserialize($data['info'])); $bind['keyid'] = $data['keyid']; $bind['uid'] = $data['uid']; $bind['sync'] = unserialize($data['sync']); $binds[$uid][$data['type']] = $bind; } } return $binds[$uid]; }
/** * 分享列表详细数据 * @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; }
/** * 字符转义 * @return string */ function fStripslashes($string) { if (is_array($string)) { foreach ($string as $key => $val) { unset($string[$key]); $string[stripslashes($key)] = fStripslashes($val); } } else { $string = stripslashes($string); } return $string; }
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(); }
<?php $id = (int) $_REQUEST['id']; if ($id == 0) { exit; } else { define('GOODS_ID', $id); } require "init.php"; $goods = FDB::fetchFirst('SELECT sg.*,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 sg.gid = ' . GOODS_ID); if ($goods) { header('Content-type: text/xml; charset=utf-8'); $goods['cache_data'] = fStripslashes(unserialize($goods['cache_data'])); FS('Share')->shareImageFormat($goods); unset($goods['cache_data']); $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"; $xml .= "<goods>\r\n"; $xml .= "<ID>" . GOODS_ID . "</ID>\r\n"; $xml .= "<title><![CDATA[{$goods['name']}]]></title>\r\n"; $xml .= "<description><![CDATA[{$goods['content']}]]></description>\r\n"; $xml .= "<price>{$goods['price']}</price>\r\n"; $xml .= "<totalNumber>{$goods['num']}</totalNumber>\r\n"; $valid_time = fToDate($goods['valid_time'], 'Ymd') . '000000'; $xml .= "<validTime>{$valid_time}</validTime>\r\n"; $xml .= "<transportFee>{$goods['transport_fee']}</transportFee>\r\n"; $xml .= "<picPath>\r\n"; foreach ($goods['imgs'] as $img) { $xml .= "<path>" . str_replace('./', $_FANWE['site_url'], $img['img']) . "</path>\r\n"; }
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 show() { global $_FANWE; $id = (int) $_FANWE['request']['id']; if (!$id) { exit; } $album = FS("Album")->getAlbumById($id); if (empty($album)) { fHeader("location: " . FU('album')); } $album_share = FS("Share")->getShareById($album['share_id']); $album_comments = FS('Share')->getShareCommentList($album['share_id'], '0,5'); $album_cate = $_FANWE['cache']['albums']['category'][$album['cid']]; $_FANWE['nav_title'] = $album['title'] . ' - ' . $album_cate['name'] . $_FANWE['nav_title']; $album_user = FS('User')->getUserById($album['uid']); $is_follow_user = false; $is_best_album = false; if ($_FANWE['uid'] > 0 && $_FANWE['uid'] != $album['uid']) { $is_best_album = FS('Album')->getIsBest($id, $_FANWE['uid']); } $is_manage_album = false; if ($_FANWE['uid'] == $album['uid']) { $is_manage_album = true; } $show_types = array(1, 2, 3); $show_type = (int) $_FANWE['request']['type']; if (!in_array($show_type, $show_types)) { $show_type = $album['show_type']; } switch ($show_type) { case 1: $page_size = 39; $page_col_num = 4; $page_col_class = ''; break; case 3: $page_size = 19; $page_col_num = 2; $page_col_class = 'two_c'; break; case 2: default: $page_size = 29; $page_col_num = 3; $page_col_class = 'three_c'; break; } $page_args = array(); $page_args['id'] = $id; $page_args['type'] = $show_type; $count = $album['share_count']; $share_display = array(); if ($count > 0) { $sid = (int) $_FANWE['request']['sid']; $pager = buildPage('album/show', $page_args, $count, $_FANWE['page'], $page_size); $share_ids = array(); if ($sid > 0) { $sql = 'SELECT share_id FROM ' . FDB::table('album_share') . ' WHERE album_id = ' . $id . ' AND share_id = ' . $sid; $sid = (int) FDB::resultFirst($sql); $share_ids[] = $sid; } $res = FDB::query('SELECT share_id FROM ' . FDB::table('album_share') . ' WHERE album_id = ' . $id . ' ORDER BY share_id DESC LIMIT ' . $pager['limit']); while ($data = FDB::fetch($res)) { if ($data['share_id'] != $sid) { $share_ids[] = $data['share_id']; } } if (count($share_ids) > 0) { $share_ids = implode(',', $share_ids); $share_list = FDB::fetchAll('SELECT * FROM ' . FDB::table('share') . ' WHERE share_id IN (' . $share_ids . ') ORDER BY share_id DESC'); $share_list = FS('Share')->getShareDetailList($share_list, false, false, false, true, 2); if ($sid > 0) { $share = $share_list[$sid]; unset($share_list[$sid]); array_unshift($share_list, $share); } $index = 0; foreach ($share_list as $share) { $share['empty_content'] = sprintf(lang('album', 'rel_album_empty_content'), $share['title']); $mod = $index % $page_col_num; $share_display['col' . $mod][] = $share; $index++; } } } $other_album = array(); if ($album_user['albums'] > 1) { $sql = 'SELECT * FROM ' . FDB::table('album') . ' WHERE uid = ' . $album_user['uid'] . ' AND img_count > 0 AND id <> ' . $id . ' LIMIT 0,3'; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $data['imgs'] = array(); if (!empty($data['cache_data'])) { $cache_data = fStripslashes(unserialize($data['cache_data'])); $data['imgs'] = $cache_data['imgs']; unset($data['cache_data']); } $data['url'] = FU('album/show', array('id' => $data['id'])); $other_album[] = $data; } } include template('page/album/album_show'); display(); }
public function getUserOtherShopAndTags($shop_id, $shop_num = 4, $tag_num = 12) { $sql = 'SELECT DISTINCT uid FROM ' . FDB::table('share_goods') . ' WHERE shop_id = ' . $shop_id . ' ORDER BY goods_id DESC LIMIT 0,5000'; $uids = array(); $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $uids[] = $data['uid']; } $uids = implode(',', $uids); if (!$uids) { return; } $shop_count = FDB::resultFirst('SELECT COUNT(DISTINCT shop_id) FROM ' . FDB::table('share_goods') . ' WHERE uid IN (' . $uids . ') AND shop_id <> ' . $shop_id); $list['shops'] = array(); $list['tags'] = array(); if ($shop_count > 0) { $begin = 0; if ($shop_count > $shop_num) { $begin = mt_rand(0, $shop_count - $shop_num); } $sql = 'SELECT DISTINCT shop_id FROM ' . FDB::table('share_goods') . ' WHERE uid IN (' . $uids . ') AND shop_id <> ' . $shop_id . ' ORDER BY shop_id DESC LIMIT ' . $begin . ',' . $shop_num; $shop_ids = array(); $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $shop_ids[] = $data['shop_id']; } $shop_ids = implode(',', $shop_ids); $sql = 'SELECT * FROM ' . FDB::table('shop') . ' WHERE shop_id IN (' . $shop_ids . ')'; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $cache_data = fStripslashes(unserialize($data['data'])); $data['tags'] = array(); if ($cache_data) { if ($cache_data['tags'] && is_array($cache_data['tags'])) { $data['tags'] = $cache_data['tags']; } } unset($data['data']); $list['tags'] = array_merge($list['tags'], $data['tags']); $data['url'] = FU('shop/show', array('id' => $data['shop_id'])); $list['shops'][] = $data; } $list['tags'] = array_slice(array_unique($list['tags']), 0, $tag_num); } return $list; }
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); }
/** * 获取首页显示的分享最近最热标签 * @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; } }
@set_time_limit(0); if (function_exists('ini_set')) { ini_set('max_execution_time', 0); } if ($step == 1) { $limit = 50; $list = FDB::fetchAll('SELECT share_id,cache_data FROM ' . FDB::table('share') . " WHERE share_data IN ('goods','photo','goods_photo') ORDER BY share_id DESC LIMIT " . $index . ',' . $limit); if (count($list) == 0) { echo "<h1>更新分享图片缓存完成,开始更新专辑图片缓存</h1>"; echo "<script type=\"text/javascript\">var fun = function(){location.href='update_share.php?step=2&time=" . time() . "';}; setTimeout(fun,1000);</script>" . "\r\n"; flush(); ob_flush(); exit; } foreach ($list as $data) { $cache_data = fStripslashes(unserialize($data['cache_data'])); $imgs = $cache_data['imgs']; include_once fimport('class/image'); $image = new Image(); foreach ($imgs['all'] as $img) { $update = array(); $update['img_width'] = 0; $update['img_height'] = 0; if (empty($img['server_code'])) { $path = FANWE_ROOT . $img['img']; $info = $image->getImageInfo($path); if ($info['type'] != 'jpg' && $info['type'] != 'jpeg') { @$image->convertType($path, $path); } $update['img_width'] = $info[0]; $update['img_height'] = $info[1];
/** * 获取推荐专辑 * @return void */ public function getBestAlbums($num = 6) { global $_FANWE; $album_list = array(); $sql = 'SELECT * FROM ' . FDB::table('album') . ' WHERE is_best = 1 AND img_count > 0 ORDER BY sort ASC,id DESC LIMIT 0,' . $num; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $data['img'] = array(); if (!empty($data['best_img'])) { $data['img']['img'] = $data['best_img']; } else { if (!empty($data['cache_data'])) { $cache_data = fStripslashes(unserialize($data['cache_data'])); $data['img'] = current($cache_data['imgs']); unset($data['cache_data']); } } $data['url'] = FU('album/show', array('id' => $data['id'])); $album_list[$data['id']] = $data; } return $album_list; }
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); }
public function album() { global $_FANWE; $home_uid = $_FANWE['home_uid']; $home_user = FS('User')->getUserById($home_uid); $current_menu = 'album'; $album_list = array(); $pager = array(); $type = (int) $_FANWE['request']['type']; switch ($type) { case '2': $uids = array(); //获取我关注的会员编号 $sql = 'SELECT uid FROM ' . FDB::table('user_follow') . ' WHERE f_uid = ' . $home_uid; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $uids[] = (int) $data['uid']; } if (count($uids) > 0) { $sql = 'SELECT COUNT(id) FROM ' . FDB::table("album") . ' WHERE uid IN (' . implode(',', $uids) . ')'; $count = FDB::resultFirst($sql); $args['type'] = 2; $pager = buildPage('u/album', $args, $count, $_FANWE['page'], 10); $sql = 'SELECT * FROM ' . FDB::table('album') . ' WHERE uid IN (' . implode(',', $uids) . ') ORDER BY id DESC LIMIT ' . $pager['limit']; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $data['imgs'] = array(); if (!empty($data['cache_data'])) { $cache_data = fStripslashes(unserialize($data['cache_data'])); $data['imgs'] = $cache_data['imgs']; unset($data['cache_data']); } $data['url'] = FU('album/show', array('id' => $data['id'])); $album_list[$data['id']] = $data; } } break; case '3': $aids = array(); $sql = 'SELECT album_id FROM ' . FDB::table('album_best') . ' WHERE uid = ' . $home_uid; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $aids[] = (int) $data['album_id']; } if (count($aids) > 0) { $sql = 'SELECT COUNT(id) FROM ' . FDB::table("album") . ' WHERE id IN (' . implode(',', $aids) . ')'; $count = FDB::resultFirst($sql); $args['type'] = 3; $pager = buildPage('u/album', $args, $count, $_FANWE['page'], 10); $sql = 'SELECT * FROM ' . FDB::table('album') . ' WHERE id IN (' . implode(',', $aids) . ') ORDER BY id DESC LIMIT ' . $pager['limit']; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $data['imgs'] = array(); if (!empty($data['cache_data'])) { $cache_data = fStripslashes(unserialize($data['cache_data'])); $data['imgs'] = $cache_data['imgs']; unset($data['cache_data']); } $data['url'] = FU('album/show', array('id' => $data['id'])); $album_list[$data['id']] = $data; } } break; default: $type = 1; if ($home_user['albums'] > 0) { $args['type'] = 1; $pager = buildPage('u/album', $args, $home_user['albums'], $_FANWE['page'], 10); $sql = 'SELECT * FROM ' . FDB::table('album') . ' WHERE uid = ' . $home_uid . ' ORDER BY id DESC LIMIT ' . $pager['limit']; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $data['imgs'] = array(); if (!empty($data['cache_data'])) { $cache_data = fStripslashes(unserialize($data['cache_data'])); $data['imgs'] = $cache_data['imgs']; unset($data['cache_data']); } $data['url'] = FU('album/show', array('id' => $data['id'])); $album_list[] = $data; } } break; } include template('page/u/u_album'); display(); }
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); }