function m_getMConfig() { global $_FANWE; //FanweService::instance()->cache->loadCache("m_config"); $m_config = $_FANWE['cache']['m_config']; if ($m_config == false) { //init_config_data();//检查初始化数据 $m_config = array(); $list = FDB::fetchAll("select code,val from " . FDB::table("m_config")); foreach ($list as $item) { $m_config[$item['code']] = $item['val']; } //新闻公告 $sql = "select code as title, title as content from " . FDB::table("m_config_list") . " where `group` = 4 and is_verify = 1 order by id desc"; $list = FDB::fetchAll($sql); $newslist = array(); foreach ($list as $item) { $newslist[] = array("title" => $item['title'], "content" => str_replace("/public/upload/images/", $_FANWE['site_url'] . "public/upload/images/", $item['content'])); } $m_config['newslist'] = $newslist; //print_r($addrtlist);exit; FanweService::instance()->cache->saveCache("m_config", $m_config); } //print_r($m_config); return $m_config; }
public function detail() { global $_FANWE; $id = intval($_FANWE['request']['id']); if ($id == 0) { fHeader("location: " . FU('index/index')); } include fimport('dynamic/u'); //获取相关的分享ID $eventinfo = FDB::fetchFirst("select * from " . FDB::table("event") . " where id=" . $id); if (intval($eventinfo['share_id']) == 0) { fHeader("location: " . FU('index/index')); } $eventinfo['share'] = FS('Share')->getShareDetail($eventinfo['share_id']); if ($share_detail === false) { fHeader("location: " . FU('index')); } $user_share_collect = FS('Share')->getShareCollectUser($eventinfo['share_id']); $page_title = preg_replace("/\\[[^\\]]+\\]/i", "", $eventinfo['title']); $_FANWE['nav_title'] = $page_title . ' - ' . lang('common', 'event'); $_FANWE['seo_description'] = $page_title; $_FANWE['setting']['site_description'] = ''; //分享评论 $page_args = array('id' => $id); $count = $eventinfo['thread_count']; $post_list = array(); if ($count > 0) { $pager = buildPage('event/' . ACTION_NAME, $page_args, $count, $_FANWE['page'], 10); $sql = 'SELECT share_id FROM ' . FDB::table('event_share') . ' WHERE event_id = ' . $id . ' ORDER BY share_id DESC LIMIT ' . $pager['limit']; $ids = array(); $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $ids[] = $data['share_id']; } $ids = implode(',', $ids); $sql = 'SELECT * from ' . FDB::table('share') . ' where share_id IN (' . $ids . ') ORDER BY share_id'; $list = FDB::fetchAll($sql); $post_list = FS('Share')->getShareDetailList($list, true, true, true); } $args = array('share_list' => &$post_list, 'pager' => &$pager, 'current_share_id' => $eventinfo['share_id']); $post_html = tplFetch("inc/share/post_share_list", $args); //热门话题 $hot_event_list = FS("event")->getHotEvent(10); if (intval($_FANWE['uid']) > 0) { //我发布的 $me_event_list = FS("event")->getUserEvent($_FANWE['uid'], 5); //我参与的 $me_join_event_list = FS("event")->getUserJoinevent($_FANWE['uid'], 5); } if (intval($_FANWE['page']) == 1) { FDB::query('UPDATE ' . FDB::table('share') . ' SET click_count = click_count + 1 WHERE share_id = ' . $eventinfo['share_id']); } include template('page/event/event_detail'); display(); }
public function getList($uid) { $uid = (int) $uid; $list = FDB::fetchAll('SELECT * FROM ' . FDB::table('sys_notice') . ' WHERE uid = ' . $uid . ' ORDER BY id DESC'); FDB::query("UPDATE " . FDB::table('sys_notice') . " SET status = 1 WHERE uid='{$uid}' AND status = 0"); return $list; }
/** * */ function getUUIndexShop() { global $_FANWE; $args = array(); $cache_file = getTplCache('inc/index/shop', array(), 1); if (getCacheIsUpdate($cache_file, 600)) { $args['shop_list'] = FDB::fetchAll('SELECT * FROM ' . FDB::table('shop') . ' WHERE shop_logo <>\'\' ORDER BY sort desc, shop_id asc limit 0,30 '); } return tplFetch('inc/index/shop', $args, '', $cache_file); }
/** * 获取系统信件列表 * @return void */ public function getSysMsgs($uid) { $list = FDB::fetchAll('SELECT * FROM ' . FDB::table('sys_msg_member') . ' AS mm LEFT JOIN ' . FDB::table('sys_msg') . ' AS m ON m.mid = mm.mid WHERE mm.status < 2 AND mm.uid = ' . $uid . ' ORDER BY m.mid DESC'); FDB::query("UPDATE " . FDB::table('sys_msg_member') . " SET status = 1 WHERE uid='{$uid}' AND status = 0"); return $list; }
public function addgoods() { $share_module = FDB::fetchAll("select `name`,`class`,`icon`,`url` from " . FDB::table('sharegoods_module') . " where status = 1 and is_install = 1"); global $_FANWE; $cache_file = getTplCache('inc/shareutil/addgoods'); if (!@(include $cache_file)) { include template('inc/shareutil/addgoods'); } display($cache_file); }
function m_express($content) { global $_FANWE; $express = getCache('m_emotion_express_cache'); //缓存过的表情hash if (!$express) { $express_rs = FDB::fetchAll("select `emotion`,concat('" . $_FANWE['site_url'] . "public/expression/',`type`,'/',`filename`) as fname from " . FDB::table('expression')); foreach ($express_rs as $k => $row) { $express[0][] = $row['emotion']; $express[1][] = "<img src='" . $row['fname'] . "' title='" . preg_replace("/[\\[\\]]/", '', $row['emotion']) . "' />"; } setCache('m_emotion_express_cache', $express); } $content = str_replace($express[0], $express[1], $content); $parse_user = array(); preg_match_all("/@([^\f\n\r\t\v@<> ]{2,20}?)(?:\\:| )/", $content, $users); if (!empty($users[1])) { $patterns = array(); $replace = array(); $users = array_unique($users[1]); $arr = array(); foreach ($users as $user) { if (!empty($user)) { $arr[] = addslashes($user); } } $res = FDB::query('SELECT uid,user_name FROM ' . FDB::table('user') . ' WHERE user_name ' . FDB::createIN($arr)); while ($data = FDB::fetch($res)) { $parse_user[$data['user_name']] = $data['uid']; } } $parse_events = array(); preg_match_all("/#([^\f\n\r\t\v]{1,80}?)#/", $content, $events); if (!empty($events[1])) { $patterns = array(); $replace = array(); $events = array_unique($events[1]); $arr = array(); foreach ($events as $event) { if (!empty($event)) { $arr[] = addslashes($event); } } $res = FDB::query('SELECT id,title FROM ' . FDB::table('event') . ' WHERE title ' . FDB::createIN($arr)); while ($data = FDB::fetch($res)) { $parse_events[$data['title']] = $data['id']; } } return array("users" => $parse_user, "events" => $parse_events); }
/** * 热心排行榜 */ function getHotUser() { $cache_file = getTplCache('inc/ask/hot_user', array(), 1); if (getCacheIsUpdate($cache_file, 300)) { //热心排行榜 $sql = "SELECT uc.uid,u.user_name,uc.ask,ask_posts,uc.ask_best_posts \r\n\t\t\tFROM " . FDB::table("user_count") . " AS uc \r\n\t\t\tINNER JOIN " . FDB::table("user") . " AS u ON u.uid = uc.uid \r\n\t\t\tORDER BY uc.ask_best_posts DESC ,uc.ask_posts DESC limit 10"; $hot_users = FDB::fetchAll($sql); $args['hot_users'] =& $hot_users; } return tplFetch('inc/ask/hot_user', $args, '', $cache_file); }
public function searchShop() { vendor("common"); $kw = trim($_REQUEST['kw']); $result['kw'] = $kw; $shop_list = FDB::fetchAll("select * from " . FDB::table("shop") . " where shop_name like '%" . $kw . "%' order by rand() limit 20 "); $shop_count = intval(FDB::resultFirst("select count(*) from " . FDB::table("shop") . " where shop_name like '%" . $kw . "%'")); $result['shop_list'] = $shop_list; $result['shop_count'] = $shop_count; die(json_encode($result)); }
public function getAlbumListByUid($uid, $limit = '') { $uid = (int) $uid; if (!$uid) { return false; } if (empty($limit)) { return FDB::fetchAll('SELECT * FROM ' . FDB::table('album') . ' WHERE uid = ' . $uid . ' ORDER BY id DESC'); } else { return FDB::fetchAll('SELECT * FROM ' . FDB::table('album') . ' WHERE uid = ' . $uid . ' ORDER BY id DESC LIMIT ' . $limit); } }
function bindCacheUsercate() { $categorys = array(); $res = FDB::query("SELECT * FROM " . FDB::table('user_category') . " WHERE status = 1"); while ($data = FDB::fetch($res)) { $data['tags'] = FDB::fetchAll('SELECT ut.* FROM ' . FDB::table('user_category_tags') . ' AS uct INNER JOIN ' . FDB::table('user_tags') . ' AS ut ON ut.tag_id = uct.tag_id WHERE uct.cate_id = ' . $data['id'] . ' ORDER BY ut.sort ASC,ut.tag_id ASC'); $categorys[$data['id']] = $data; } FanweService::instance()->cache->saveCache('usertagcate', $categorys); }
public function run() { global $_FANWE; $root = array(); $root['return'] = 0; $uid = $_FANWE['uid']; if ($uid == 0) { $root['info'] = "请先登陆"; m_display($root); } $root['home_user'] = $_FANWE['user']; $page = (int) $_FANWE['requestData']['page']; $page = max(1, $page); $uids = array(); //获取我关注的会员编号 $sql = 'SELECT uid FROM ' . FDB::table('user_follow') . ' WHERE f_uid = ' . $uid; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $uids[] = (int) $data['uid']; } if (count($uids) > 0) { $sql = 'SELECT COUNT(share_id) FROM ' . FDB::table("share") . ' WHERE uid IN (' . implode(',', $uids) . ')'; $total = FDB::resultFirst($sql); $page_size = PAGE_SIZE; $page_total = max(1, ceil($total / $page_size)); if ($page > $page_total) { $page = $page_total; } $limit = ($page - 1) * $page_size . "," . $page_size; $share_list = array(); $sql = 'SELECT * FROM ' . FDB::table("share") . ' WHERE uid IN (' . implode(',', $uids) . ') ORDER BY share_id DESC LIMIT ' . $limit; $share_list = FDB::fetchAll($sql); $share_list = mGetShareDetailList($share_list, true); } else { $page_total = 0; $share_list = array(); } $root['return'] = 1; if (count($share_list) > 0) { $root['item'] = array_slice($share_list, 0); } else { $root['item'] = array(); } $root['page'] = array("page" => $page, "page_total" => $page_total); m_display($root); }
public function target() { define("ACTION_NAME", "target"); if (intval($GLOBALS['fanwe']->var['uid']) == 0) { fHeader("location: " . FU('user/login')); } global $_FANWE; $sql = "select f.f_uid as uid,u.user_name from " . FDB::table("user_follow") . " as f left join " . FDB::table("user") . " as u on f.f_uid = u.uid where f.uid = " . intval($GLOBALS['fanwe']->var['uid']); $sql_count = "select count(f.f_uid) from " . FDB::table("user_follow") . " as f left join " . FDB::table("user") . " as u on f.f_uid = u.uid where f.uid = " . intval($GLOBALS['fanwe']->var['uid']); $page_size = 21; $count = FDB::resultFirst($sql_count); $pager = buildPage('message/target', array(), $count, $_FANWE['page'], $page_size); $sql = $sql . " limit " . $pager['limit']; $follow_user = FDB::fetchAll($sql); include template('page/message_target'); display(); }
function getCatalogArray() { global $_FANWE; $categorylist = $_FANWE['cache']['merchant_category']; if ($categorylist == false) { //init_config_data();//检查初始化数据 $categorylist = array(); //$region_lv2 = array(); $list = FDB::fetchAll("select * from " . FDB::table("merchant_category") . " where status = 1"); //print_r($list);exit foreach ($list as $item) { $categorylist[] = array("id" => $item['id'], "name" => $item['name'], "icon" => $_FANWE['site_url'] . $item['icon']); } //print_r($categorylist);exit; FanweService::instance()->cache->saveCache("merchant_category", $categorylist); } return $categorylist; }
function syn_weibo($uid) { global $_FANWE; static $mods = array(); $_FANWE['uid'] = $uid; $weibos = FDB::fetchAll("select * from " . FDB::table("pub_schedule") . " where uid = " . $uid . " order by type"); FDB::query("delete from " . FDB::table("pub_schedule") . " where uid = " . $uid); foreach ($weibos as $weibo) { if (file_exists(FANWE_ROOT . "login/" . $weibo['type'] . ".php")) { if (!isset($mods[$weibo['type']])) { require_once FANWE_ROOT . "login/" . $weibo['type'] . ".php"; $class = $weibo['type']; $mods[$weibo['type']] = new $class(); } $data = unserialize(base64_decode($weibo['data'])); $mods[$weibo['type']]->sendMessage($data); } } }
public function run() { global $_FANWE; $root = array(); $root['return'] = 0; $uid = $_FANWE['uid']; if ($uid == 0) { $root['info'] = "请先登陆"; m_display($root); } $root['home_user'] = $_FANWE['user']; FDB::query("DELETE FROM " . FDB::table('user_notice') . " WHERE uid='{$uid}' AND type=4"); $page = (int) $_FANWE['requestData']['page']; $page = max(1, $page); $sql = 'SELECT COUNT(*) FROM ' . FDB::table("share") . ' AS s LEFT JOIN ' . FDB::table("atme") . ' as a on a.share_id=s.share_id WHERE a.uid = ' . $uid . ' and s.uid <> ' . $uid . ' and s.type<>\'fav\' '; $total = FDB::resultFirst($sql); $page_size = PAGE_SIZE; $page_total = max(1, ceil($total / $page_size)); if ($page > $page_total) { $page = $page_total; } $limit = ($page - 1) * $page_size . "," . $page_size; $share_list = array(); $sql = 'SELECT s.* FROM ' . FDB::table("share") . ' AS s LEFT JOIN ' . FDB::table("atme") . ' as a on a.share_id=s.share_id WHERE a.uid = ' . $uid . ' and s.uid <> ' . $uid . ' and s.type<>\'fav\' ORDER BY s.share_id DESC LIMIT ' . $limit; $share_list = FDB::fetchAll($sql); $share_list = mGetShareDetailList($share_list, true); $root['return'] = 1; if (count($share_list) > 0) { $root['item'] = array_slice($share_list, 0); } else { $root['item'] = array(); } $root['page'] = array("page" => $page, "page_total" => $page_total); m_display($root); }
public function run() { global $_FANWE; $root = array(); $root['return'] = 1; $city_id = intval($_FANWE['requestData']['city_id']); $quan_id = intval($_FANWE['requestData']['quan_id']); $cate_id = intval($_FANWE['requestData']['cate_id']); $page = intval($_FANWE['requestData']['page']); //分页 $page = $page == 0 ? 1 : $page; $page_size = PAGE_SIZE; $limit = ($page - 1) * $page_size . "," . $page_size; $sql_count = "select count(*) from " . FDB::table("merchant_youhui"); $sql = "select id,merchant_id,title,content,merchant_logo,create_time,merchant_xpoint,merchant_ypoint,merchant_api_address,image_1 from " . FDB::table("merchant_youhui"); $now = TIME_UTC; $where = "1 = 1 and status = 1 and begin_time<" . $now . " and (end_time = 0 or end_time > " . $now . ")"; if ($city_id > 0) { $where .= " and merchant_city_id = {$city_id}"; } if ($quan_id > 0) { $where .= " and merchant_quan_id = {$quan_id}"; } if ($cate_id > 0) { $where .= " and merchant_category_id = {$cate_id}"; } $sql_count .= " where " . $where; $sql .= " where " . $where; $sql .= " limit " . $limit; //echo $sql; exit; $total = FDB::resultFirst($sql_count); $page_total = ceil($total / $page_size); $list = FDB::fetchAll($sql); $youhui_list = array(); foreach ($list as $item) { $youhui_list[] = m_youhuiItem($item); } $root['item'] = $youhui_list; $root['page'] = array("page" => $page, "page_total" => $page_total); m_display($root); }
private function getList() { global $_FANWE; $_FANWE['user_click_share_id'] = (int) $_FANWE['request']['sid']; unset($_FANWE['request']['sid']); $cache_file = getTplCache('page/book/book_index', $_FANWE['request'], 2); if (getCacheIsUpdate($cache_file, BOOK_CACHE_PAGE_TIME)) { $category = urldecode($_FANWE['request']['cate']); $is_root = false; $page_args = array(); if (isset($_FANWE['cache']['goods_category']['cate_code'][$category])) { $page_args['cate'] = $_FANWE['request']['cate']; $cate_id = $_FANWE['cache']['goods_category']['cate_code'][$category]; $goods_cate_code = $category; } else { $is_root = true; $cate_id = $_FANWE['cache']['goods_category']['root']; } $sort = $_FANWE['request']['sort']; $sort = !empty($sort) ? $sort : "pop"; $category_data = $_FANWE['cache']['goods_category']['all'][$cate_id]; $category_tags = array(); $_FANWE['nav_title'] = $category_data['cate_name']; if (!empty($category_data['seo_keywords'])) { $_FANWE['seo_keywords'] = $category_data['seo_keywords']; $_FANWE['setting']['site_keywords'] = ''; } if (!empty($category_data['seo_desc'])) { $_FANWE['seo_description'] = $category_data['seo_desc']; $_FANWE['setting']['site_description'] = ''; } $child_ids = array(); if (isset($category_data['child'])) { $child_ids = $category_data['child']; if (!$is_root) { $tagurlpara['cate'] = urlencode($category_data['cate_code']); } foreach ($category_data['child'] as $child_id) { $child_cate = $_FANWE['cache']['goods_category']['all'][$child_id]; $tag_key = 'goods_category_tags_' . $child_id; FanweService::instance()->cache->loadCache($tag_key); foreach ($_FANWE['cache'][$tag_key] as $k => $tag) { $tagurlpara['tag'] = urlencode($tag['tag_name']); $tag['url'] = FU("book/" . ACTION_NAME, $tagurlpara); $child_cate['tags'][] = $tag; if ($k > 16) { break; } } $category_tags[] = $child_cate; } } $hot_tags = array(); if (!$is_root) { $child_ids[] = $cate_id; require fimport("function/share"); $hot_tags = getHotTags($child_ids, $category, 10); } $condition = " WHERE s.share_data IN ('goods','photo','goods_photo')"; if (!$is_root) { $cids = array(); FS('Share')->getChildCids($cate_id, $cids); $condition .= " AND sc.cate_id IN (" . implode(',', $cids) . ")"; } $title = $category_data['short_name']; $is_match = false; $tag = urldecode($_FANWE['request']['kw']); if (!empty($tag)) { $_FANWE['nav_title'] = $tag . ' - ' . $_FANWE['nav_title']; $title = htmlspecialchars($tag); $is_match = true; //$match_key = FS('Words')->segment($tag,10); //$match_key = tagToUnicode($match_key,'+'); $match_key = segmentToUnicode($tag, '+'); $condition .= " AND match(sm.content_match) against('" . $match_key . "' IN BOOLEAN MODE) "; $page_args['tag'] = urlencode($tag); } //输出排序URL $sort_page_args = $page_args; $sort_page_args['sort'] = 'hot7'; $hot7_url['url'] = FU('book/' . ACTION_NAME, $sort_page_args); if ($sort == 'hot7') { $hot7_url['act'] = 1; } $sort_page_args['sort'] = 'hot30'; $hot30_url['url'] = FU('book/' . ACTION_NAME, $sort_page_args); if ($sort == 'hot30') { $hot30_url['act'] = 1; } $sort_page_args['sort'] = 'new'; $new_url['url'] = FU('book/' . ACTION_NAME, $sort_page_args); if ($sort == 'new') { $new_url['act'] = 1; } $sort_page_args['sort'] = 'pop'; $pop_url['url'] = FU('book/' . ACTION_NAME, $sort_page_args); if ($sort == 'pop') { $pop_url['act'] = 1; } if (!empty($_FANWE['request']['sort'])) { $page_args['sort'] = $sort; } else { $page_args['sort'] = 'pop'; } $today_time = getTodayTime(); switch ($sort) { //7天最热 点击次数 case 'hot7': $day7_time = $today_time - 604800; $field = ",(s.create_time > {$day7_time}) AS time_sort "; $sort = " ORDER BY time_sort DESC,s.click_count DESC"; break; //30天最热 点击次数 //30天最热 点击次数 case 'hot30': $day30_time = $today_time - 2592000; $field = ",(s.create_time > {$day30_time}) AS time_sort "; $sort = " ORDER BY time_sort DESC,s.click_count DESC"; break; //最新 //最新 case 'new': $field = ''; $sort = " ORDER BY s.share_id DESC"; break; //潮流 喜欢人数 //潮流 喜欢人数 case 'pop': default: $day7_time = $today_time - 604800; $field = ",(s.create_time > {$day7_time}) AS time_sort "; $sort = " ORDER BY time_sort DESC,s.collect_count DESC"; break; } $sql = 'SELECT DISTINCT(s.share_id),s.uid,s.content,s.collect_count,s.comment_count,s.create_time,s.cache_data ' . $field . ' FROM ' . FDB::table('share') . ' AS s '; if (!$is_root) { $sql .= 'INNER JOIN ' . FDB::table('share_category') . ' AS sc ON s.share_id = sc.share_id '; } if ($is_match) { $sql .= 'INNER JOIN ' . FDB::table('share_match') . ' AS sm ON sm.share_id = s.share_id '; } $sql .= $condition . $sort; $sql_count = 'SELECT COUNT(DISTINCT s.share_id) FROM ' . FDB::table('share') . ' AS s '; if (!$is_root) { $sql_count .= 'INNER JOIN ' . FDB::table('share_category') . ' AS sc ON s.share_id = sc.share_id '; } if ($is_match) { $sql_count .= 'INNER JOIN ' . FDB::table('share_match') . ' AS sm ON sm.share_id = s.share_id '; } $sql_count .= $condition; $page_size = 50; $max_page = 100; $count = FDB::resultFirst($sql_count); if ($count > $max_page * $page_size) { $count = $max_page * $page_size; } if ($_FANWE['page'] > $max_page) { $_FANWE['page'] = $max_page; } $pager = buildPage('book/' . $action, $page_args, $count, $_FANWE['page'], $page_size, '', 3); $share_datas = array(); $sql = $sql . ' LIMIT ' . $pager['limit']; $share_list = FDB::fetchAll($sql); $share_list = FS('Share')->getShareDetailList($share_list, false, false, false, true, 2); $col = 4; $index = 0; $share_display = array(); foreach ($share_list as $share) { $mod = $index % $col; $share_display['col' . $mod][] = $share; $index++; } include template('page/book/book_index'); display($cache_file); exit; } else { include $cache_file; display(); } }
/** * 获取用户参与的话题 */ function getUserJoinevent($uid, $num) { $uid = (int) $uid; $num = (int) $num; $sql = 'SELECT DISTINCT event_id FROM ' . FDB::table('event_share') . ' WHERE uid = ' . $uid . " ORDER BY share_id DESC LIMIT 0,{$num}"; $ids = array(); $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $ids[] = $data['event_id']; } $list = array(); if (count($ids) > 0) { $ids = implode(',', $ids); $list = FDB::fetchAll("select * from " . FDB::table("event") . " where id IN (" . $ids . ") order by id desc limit {$num}"); } return $list; }
public function sendmsg() { global $_FANWE; $home_uid = $_FANWE['uid']; $home_user = FS('User')->getUserById($home_uid); $current_menu = 'message'; $count = FDB::resultFirst('SELECT COUNT(uid) FROM ' . FDB::table('user_follow') . ' WHERE uid = ' . $home_uid); $pager = buildPage('', array(), $count, $_FANWE['page'], 30); $user_list = FDB::fetchAll('SELECT u.uid,u.user_name,u.server_code FROM ' . FDB::table('user_follow') . ' AS uf INNER JOIN ' . FDB::table('user') . ' AS u ON u.uid = uf.f_uid WHERE uf.uid = ' . $home_uid . ' ORDER BY uf.create_time DESC LIMIT ' . $pager['limit']); include template('page/u/u_sendmsg'); display(); }
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 getTopicPostList($tid, $limit) { $tid = (int) $tid; if (!$tid) { return array(); } $sql = 'SELECT s.* FROM ' . FDB::table('forum_post') . ' AS fp INNER JOIN ' . FDB::table('share') . ' AS s ON s.share_id = fp.share_id WHERE s.status = 1 AND fp.tid = ' . $tid . ' ORDER BY pid DESC LIMIT ' . $limit; $list = FDB::fetchAll($sql); return FS('Share')->getShareDetailList($list, true, true, true); }
public function category() { global $_FANWE; $id = (int) $_FANWE['request']['id']; if (!$id) { fHeader("location: " . FU('album')); } if (!isset($_FANWE['cache']['albums']['category'][$id])) { fHeader("location: " . FU('album')); } $album_cate = $_FANWE['cache']['albums']['category'][$id]; $_FANWE['nav_title'] = $album_cate['name'] . $_FANWE['nav_title']; $page_args = array(); $page_args['id'] = $id; $sort = $_FANWE['request']['sort']; switch ($sort) { case 'new': $page_args['sort'] = 'new'; $order = " ORDER BY s.share_id DESC"; break; default: $sort = 'hot'; $page_args['sort'] = 'hot'; $order = " ORDER BY s.collect_count DESC"; break; } $where = ' WHERE a.cid = ' . $id; $sql = 'SELECT COUNT(DISTINCT share_id) FROM ' . FDB::table('album_share') . ' AS a ' . $where; $count = FDB::resultFirst($sql); $share_list = array(); $share_display = array(); if ($count > 0) { $pager = buildPage('album/' . ACTION_NAME, $page_args, $count, $_FANWE['page'], 40); $share_list = FDB::fetchAll('SELECT * FROM ' . FDB::table('album_share') . ' AS a INNER JOIN ' . FDB::table('share') . ' AS s ON s.share_id = a.share_id ' . $where . ' AND s.type = \'album_item\'' . $order . ' LIMIT ' . $pager['limit']); $share_list = FS('Share')->getShareDetailList($share_list, false, false, false, true, 2); $col = 4; $index = 0; $share_display = array(); foreach ($share_list as $share) { $share['empty_content'] = sprintf(lang('album', 'rel_album_empty_content'), $share['title']); $mod = $index % $col; $share_display['col' . $mod][] = $share; $index++; } } include template('page/album/album_category'); display(); }
/** * 首页分类推荐分享 */ function getIndexCateShare() { $args = array(); $cache_file = getTplCache('inc/index/index_cate_share', array(), 1); if (getCacheIsUpdate($cache_file, 600)) { global $_FANWE; FanweService::instance()->cache->loadCache('goods_category'); $cate_indexs = $_FANWE['cache']['goods_category']['all']; foreach ($cate_indexs as $k => $v) { if ($v['parent_id'] == 0 && $v['is_index'] == 1) { $cids = array(); FS('Share')->getChildCids($v['cate_id'], $cids); /*$tags = FDB::fetchAll("select gt.tag_name,gt.tag_code from ".FDB::table("goods_category_tags")." as gct INNER JOIN ".FDB::table("goods_tags")." as gt on gt.tag_id = gct.tag_id where gct.cate_id in (".implode(",",$cids).") order by gct.weight desc,gt.count desc,gt.tag_id desc limit 12"); foreach($tags as $tk=>$tv){ $tags[$tk]["encode"] = urlencode($tv['tag_code']); } $v['hot_tags'] = $tags ; */ $v['share_count'] = FDB::resultFirst("select count(DISTINCT s.uid) from " . FDB::table("share") . " as s INNER JOIN " . FDB::table("share_category") . " as sc ON sc.share_id = s.share_id where sc.cate_id in (" . implode(",", $cids) . ")"); $v['user'] = array(); $users = FDB::fetchAll("select DISTINCT(s.uid) as uid from " . FDB::table("share") . " as s INNER JOIN " . FDB::table("share_category") . " as sc ON sc.share_id = s.share_id where sc.cate_id in (" . implode(",", $cids) . ") order by s.share_id desc limit 10"); foreach ($users as $kk => $vv) { $user = FS("User")->getUserShowName($vv['uid']); $v['user'][$vv['uid']] = $user['name']; } $sql = "SELECT s.*,st.tag_name FROM " . FDB::table("share") . " as s \r\n\t\t\t\t\t\tINNER JOIN " . FDB::table("share_category") . " as sc ON sc.share_id = s.share_id \r\n\t\t\t\t\t\tINNER JOIN " . FDB::table("share_tags") . " as st ON st.share_id = s.share_id\r\n\t\t\t\t\t\tINNER JOIN " . FDB::table("goods_category_tags") . " as gct ON gct.cate_id = sc.cate_id\r\n\t\t\t\t\t\tWHERE gct.cate_id in (" . implode(",", $cids) . ") AND s.is_index=1 GROUP BY s.share_id ORDER BY s.sort desc,s.share_id desc limit 30"; $v['share_list'] = FDB::fetchAll($sql); foreach ($v['share_list'] as $kk => $vv) { $tag['tag_name'] = $vv['tag_name']; $tag['tag_code'] = $vv['tag_name']; $tag['encode'] = urlencode($vv['tag_name']); $v['hot_tags'][$vv['tag_name']] = $tag; } $v['share_list'] = FS("Share")->getShareDetailList($v['share_list']); $args['cate_list'][] = $v; } } unset($cate_indexs); } return tplFetch('inc/index/index_cate_share', $args, '', $cache_file); }
/** * 获取最新加入会员 * @return array */ public function getNewUsers($num) { $sql = 'SELECT uid,user_name,server_code FROM ' . FDB::table('user') . ' ORDER BY uid DESC LIMIT 0,' . $num; return FDB::fetchAll($sql); }
<?php $share_id = intval($_FANWE['request']['id']); if ($share_id == 0) { exit; } if (!checkAuthority('share', 'edit')) { exit; } $share = FS("Share")->getShareById($share_id); if (empty($share)) { deleteManageLock('share', $share_id); exit; } $manage_lock = checkIsManageLock('share', $share_id); if ($manage_lock === false) { createManageLock('share', $share_id); } else { exit; } $share['share_tags'] = FDB::resultFirst("select group_concat(tag_name SEPARATOR ' ') from " . FDB::table("share_tags") . " where share_id = " . $share['share_id']); $share_category = FDB::fetchAll("select c.cate_id,c.cate_name from " . FDB::table("share_category") . " as sc left join " . FDB::table("goods_category") . " as c on sc.cate_id = c.cate_id where sc.share_id = " . $share['share_id']); $fanwe->cache->loadCache("goods_category"); include template('manage/share/edit'); display();
function express(&$content) { global $_FANWE; $express = getCache('emotion_express_cache'); //缓存过的表情hash if (!$express) { $express_rs = FDB::fetchAll("select `emotion`,concat('./public/expression/',`type`,'/',`filename`) as fname from " . FDB::table('expression')); foreach ($express_rs as $k => $row) { $express[0][] = $row['emotion']; $express[1][] = "<img src='" . $row['fname'] . "' title='" . preg_replace("/[\\[\\]]/", '', $row['emotion']) . "' />"; } setCache('emotion_express_cache', $express); } preg_match("/(<html.*?>.*?<\\/head>)/s", $content, $data); $head_html = $data[1]; $content = str_replace($head_html, '<!--TAG_HEADER-->', $content); preg_match_all("/(<textarea.*?>.*?<\\/textarea>)/s", $content, $data); $textareas = $data[1]; if (count($textareas) > 0) { foreach ($textareas as $key => $textarea) { $content = str_replace($textarea, '<!--TAG_TEXTAREA_' . $key . '-->', $content); } } preg_match_all("/@([^\f\n\r\t\v@<> ]{2,20}?)(?:\\:| )/", $content, $users); if (!empty($users[1])) { $patterns = array(); $replace = array(); $users = array_unique($users[1]); $arr = array(); foreach ($users as $user) { if (!empty($user)) { $arr[] = addslashes($user); } } $res = FDB::query('SELECT uid,user_name FROM ' . FDB::table('user') . ' WHERE user_name ' . FDB::createIN($arr)); while ($data = FDB::fetch($res)) { $patterns[] = '/@' . preg_quote($data['user_name']) . '(\\:| )/'; $replace[] = '<a class="u_name GUID" uid="' . $data['uid'] . '" href="' . FU('u/index', array('uid' => $data['uid'])) . '">@' . $data['user_name'] . "</a>\$1"; } $content = preg_replace($patterns, $replace, $content); } preg_match_all("/#([^\f\n\r\t\v]{1,80}?)#/", $content, $events); if (!empty($events[1])) { $patterns = array(); $replace = array(); $events = array_unique($events[1]); $arr = array(); foreach ($events as $event) { if (!empty($event)) { $arr[] = addslashes($event); } } $res = FDB::query('SELECT id,title FROM ' . FDB::table('event') . ' WHERE title ' . FDB::createIN($arr)); while ($data = FDB::fetch($res)) { $patterns[] = '#' . $data['title'] . '#'; $replace[] = '<a href="' . FU("event/detail", array("id" => $data['id'])) . '" target="_blank">#' . $data['title'] . '#</a>'; } $content = str_replace($patterns, $replace, $content); } if (count($_FANWE['tpl_user_formats']) > 0) { $patterns = array(); $replace = array(); $user_ids = array_keys($_FANWE['tpl_user_formats']); $user_ids = implode(',', $user_ids); $user_ids = str_replace(',,', ',', $user_ids); if (!empty($user_ids)) { $res = FDB::query("SELECT uid,user_name,server_code,reg_time,credits,is_daren,is_buyer,follows,fans,collects,\r\n\t\t\t\tfavs,threads,photos,goods,ask,ask_posts,ask_best_posts,shares,forums,forum_posts,\r\n\t\t\t\tseconds,albums,referrals FROM " . FDB::table('user') . ' INNER JOIN ' . FDB::table('user_count') . ' AS uc USING(uid) WHERE uid IN (' . $user_ids . ')'); while ($user = FDB::fetch($res)) { $uid = $user['uid']; $user['url'] = FU('u/index', array('uid' => $uid)); foreach ($_FANWE['tpl_user_formats'][$uid] as $tuf_key => $tuf_val) { $patterns[] = "<!--USER_" . $uid . "_" . $tuf_key . "-->"; $replace[] = getUserFormatHtml($user, $tuf_val); } unset($_FANWE['tpl_user_formats'][$uid]); } $content = str_replace($patterns, $replace, $content); } } $content = str_replace($express[0], $express[1], $content); $content = str_replace('<!--TAG_HEADER-->', $head_html, $content); if (count($textareas) > 0) { foreach ($textareas as $key => $textarea) { $content = str_replace('<!--TAG_TEXTAREA_' . $key . '-->', $textarea, $content); } } return $content; }
$page = intval($_REQUEST['p']); $limit = ($page - 1) * $page_num . "," . "{$page_num}"; $next_limit = $page * $page_num . "," . "1"; $sql = 'SELECT * FROM ' . FDB::table("share") . ' WHERE share_data <> ' . " 'default' " . $share_condition . "\r\n\t\t\tORDER BY share_id DESC LIMIT " . $limit; $next_sql = 'SELECT * FROM ' . FDB::table("share") . ' WHERE share_data <> ' . " 'default' " . $share_condition . "\r\n\t\t\tORDER BY share_id DESC LIMIT " . $next_limit; $hasNextPage = FDB::fetchAll($next_sql); if ($hasNextPage) { $is_next = 1; } 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);
function forum() { global $_FANWE; $current_aid = intval($_FANWE['request']['aid']); $_FANWE['nav_title'] = lang('common', 'ask'); FanweService::instance()->cache->loadCache('forums'); $forum_list = array(); foreach ($_FANWE['cache']['forums']['root'] as $forum_rootid) { $forum_list[] = $_FANWE['cache']['forums']['all'][$forum_rootid]; } $type = !empty($_FANWE['request']['type']) ? $_FANWE['request']['type'] : "all"; $asks = $_FANWE['cache']['asks']; $user_where = ''; $page_args = array(); $where = ' WHERE at.status = 1 '; if ($current_aid > 0) { $current_ask = $asks[$current_aid]; if (!empty($current_ask)) { $_FANWE['nav_title'] = $current_ask['name'] . ' - ' . $_FANWE['nav_title']; $where .= ' AND at.aid = ' . $current_aid; $user_where .= ' AND at.aid = ' . $current_aid; $page_args['aid'] = $current_aid; } else { $current_aid = 0; } } switch ($type) { case 'best': $where .= ' AND at.is_best = 1'; $best_type = 'current'; $page_args['type'] = 'best'; break; case 'over': $where .= ' AND at.is_solve = 1'; $over_type = 'current'; $page_args['type'] = 'over'; break; case 'wait': $where .= ' AND at.is_solve = 0'; $wait_type = 'current'; $page_args['type'] = 'wait'; break; case 'none': $where .= ' AND at.post_count = 0'; $none_type = 'current'; $page_args['type'] = 'none'; break; default: $all_type = 'current'; break; } //热门主题 $hottopics = FS('Ask')->getHotAsk($current_aid); //本吧活跃分子 $sql = 'SELECT u.uid,u.user_name FROM ' . FDB::table('ask_thread') . ' AS at LEFT JOIN ' . FDB::table('user_count') . ' AS uc ON uc.uid = at.uid LEFT JOIN ' . FDB::table('user') . ' AS u ON u.uid = at.uid WHERE at.status = 1 ' . $user_where . ' GROUP BY at.uid ORDER BY uc.ask_posts DESC,uc.uid ASC LIMIT 0,9'; $hotusers = FDB::fetchAll($sql); $ask_count = FDB::resultFirst('SELECT count(at.tid) FROM ' . FDB::table('ask_thread') . ' AS at' . $where); $page_size = 30; $pager = buildPage('ask/' . ACTION_NAME, $page_args, $ask_count, $_FANWE['page'], $page_size); //获取数据列表 $sql = 'SELECT at.tid,at.title,at.uid,at.is_solve,at.is_top, at.is_best,at.post_count,at.create_time,at.lastpost,at.lastposter,COUNT(ua.rec_id) AS follow_count FROM ' . FDB::table('ask_thread') . ' AS at LEFT JOIN ' . FDB::table('user_attention') . ' AS ua ON ua.rec_id = at.tid AND type = \'ask\' ' . $where . ' GROUP BY at.tid ORDER BY at.is_top DESC,at.sort ASC,at.tid DESC LIMIT ' . $pager['limit']; $uids = array(); $users = array(); $lastposters = array(); $res = FDB::query($sql); $ask_threads = array(); while ($data = FDB::fetch($res)) { if (!empty($data['lastposter'])) { $data['last_time'] = fToDate($data['lastpost'], 'Y-m-d'); } $data['time'] = fToDate($data['create_time'], 'Y-m-d'); $ask_threads[$data['tid']] = $data; } include template('page/ask/ask_list'); display(); }
/** * 获取达人列表 * @return array */ public function getDarens($limit = '0,15') { $key = str_replace(',', '_', $limit); $list = getCache('daren/index/list_' . $key); if ($list === NULL) { $today_time = getTodayTime() + 86400; $sql = 'SELECT ud.uid,ud.reason,u.user_name FROM ' . FDB::table('user_daren') . ' AS ud INNER JOIN ' . FDB::table('user') . ' AS u ON u.uid = ud.uid WHERE ud.status = 1 AND ud.day_time < ' . $today_time . ' ORDER BY ud.id DESC LIMIT ' . $limit; $list = FDB::fetchAll($sql); setCache('daren/index/list_' . $key, $list); } return $list; }