public function index() { global_run(); init_app_page(); $GLOBALS['tmpl']->assign("no_nav", true); //无分类下拉 $GLOBALS['tmpl']->caching = true; $GLOBALS['tmpl']->cache_lifetime = 600; //缓存10分钟 $cache_id = md5(MODULE_NAME . ACTION_NAME); if (!$GLOBALS['tmpl']->is_cached('daren_index.html', $cache_id)) { require_once APP_ROOT_PATH . 'system/model/topic.php'; $title = $GLOBALS['lang']['DAREN_SHOW']; $site_nav[] = array('name' => $GLOBALS['lang']['HOME_PAGE'], 'url' => url("index", "index")); $site_nav[] = array('name' => $title, 'url' => url("index", "daren")); $GLOBALS['tmpl']->assign("site_nav", $site_nav); $user_id = intval($GLOBALS['user_info']['id']); //输出所有达人推荐 $rnd_daren_list = get_rand_user(42, 1); $GLOBALS['tmpl']->assign("rnd_daren_list", $rnd_daren_list); $daren_list = get_rand_user(8, 1); foreach ($daren_list as $kk => $vv) { $focus_uid = intval($vv['id']); $focus_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_id . " and focused_user_id = " . $focus_uid); if ($focus_data) { $daren_list[$kk]['focused'] = 1; } } $GLOBALS['tmpl']->assign("daren_list", $daren_list); //获取推荐的 达人分享6条 $topic_list = get_topic_list(6, array("cid" => 0, "tag" => ""), "", "is_recommend = 1"); $topic_list = $topic_list['list']; //$topic_list = $GLOBALS['db']->getAll("select t.* from ".DB_PREFIX."topic as t where t.is_effect = 1 and t.is_delete = 0 and t.is_recommend = 1 order by t.create_time desc limit 6"); foreach ($topic_list as $kk => $vv) { $vv['content'] = msubstr($vv['content'], 0, 30); $topic_list[$kk] = format_topic_item($vv); $topic_list[$kk]['content'] = decode_topic($topic_list[$kk]['content']); $topic_user_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . $vv['user_id'] . " and is_effect =1 and is_delete = 0"); $focus_uid = intval($topic_user_info['id']); $focus_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_id . " and focused_user_id = " . $focus_uid); if ($focus_data) { $topic_user_info['focused'] = 1; } $topic_list[$kk]['user_info'] = $topic_user_info; } $GLOBALS['tmpl']->assign("topic_list", $topic_list); $cate_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "topic_tag_cate where showin_web = 1 order by sort asc limit 7"); foreach ($cate_list as $k => $v) { //获取分类下的推荐分享 $cate_list[$k]['topic_list'] = get_topic_list(4, array("cid" => 0, "tag" => ""), " left join " . DB_PREFIX . "topic_cate_link as l on l.topic_id = t.id ", "l.cate_id = " . $v['id'] . " and t.is_recommend = 1"); $cate_list[$k]['topic_list'] = $cate_list[$k]['topic_list']['list']; //$cate_list[$k]['topic_list'] = $GLOBALS['db']->getAll("select t.* from ".DB_PREFIX."topic as t left join ".DB_PREFIX."topic_cate_link as l on l.topic_id = t.id where l.cate_id = ".$v['id']." and t.is_effect = 1 and t.is_delete = 0 and t.is_recommend = 1 order by t.create_time desc limit 4"); foreach ($cate_list[$k]['topic_list'] as $kk => $vv) { $vv['content'] = msubstr($vv['content'], 0, 30); $cate_list[$k]['topic_list'][$kk] = format_topic_item($vv); $cate_list[$k]['topic_list'][$kk]['content'] = decode_topic($cate_list[$k]['topic_list'][$kk]['content']); $topic_user_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . $vv['user_id'] . " and is_effect =1 and is_delete = 0"); $focus_uid = intval($topic_user_info['id']); $focus_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_id . " and focused_user_id = " . $focus_uid); if ($focus_data) { $topic_user_info['focused'] = 1; } $cate_list[$k]['topic_list'][$kk]['user_info'] = $topic_user_info; } $cate_list[$k]['daren_list'] = $GLOBALS['db']->getAll("select u.* from " . DB_PREFIX . "user as u left join " . DB_PREFIX . "user_cate_link as l on l.user_id = u.id where l.cate_id = " . $v['id'] . " and u.is_effect = 1 and u.is_delete = 0 and u.is_daren = 1 order by rand() limit 8"); foreach ($cate_list[$k]['daren_list'] as $kk => $vv) { $focus_uid = intval($vv['id']); $focus_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_id . " and focused_user_id = " . $focus_uid); if ($focus_data) { $cate_list[$k]['daren_list'][$kk]['focused'] = 1; } } //print_r($cate_list);exit; } $GLOBALS['tmpl']->assign("cate_list", $cate_list); $GLOBALS['tmpl']->assign("page_title", $title); $GLOBALS['tmpl']->assign("page_keyword", $title . ","); $GLOBALS['tmpl']->assign("page_description", $title . ","); } $GLOBALS['tmpl']->display("daren_index.html", $cache_id); }
public function randuser() { $user_id = intval($GLOBALS['user_info']['id']); $user_list = get_rand_user(24, 0, $user_id); $GLOBALS['tmpl']->assign("user_list", $user_list); $GLOBALS['tmpl']->display("inc/uc/randuser.html"); }
public function index() { $GLOBALS['tmpl']->caching = true; $GLOBALS['tmpl']->cache_lifetime = 600; //缓存10分钟 $cache_id = md5(MODULE_NAME . ACTION_NAME . $GLOBALS['deal_city']['id']); if (!$GLOBALS['tmpl']->is_cached('daren_index.html', $cache_id)) { $title = $GLOBALS['lang']['DAREN_SHOW']; $site_nav[] = array('name' => $GLOBALS['lang']['HOME_PAGE'], 'url' => APP_ROOT . "/"); $site_nav[] = array('name' => $title, 'url' => url("shop", "daren")); $GLOBALS['tmpl']->assign("site_nav", $site_nav); $GLOBALS['tmpl']->assign("page_title", $title); $GLOBALS['tmpl']->assign("page_keyword", $title . ","); $GLOBALS['tmpl']->assign("page_description", $title . ","); $user_id = intval($GLOBALS['user_info']['id']); //输出所有达人推荐 $rnd_daren_list = get_rand_user(42, 1); $GLOBALS['tmpl']->assign("rnd_daren_list", $rnd_daren_list); $daren_list = get_rand_user(8, 1); foreach ($daren_list as $kk => $vv) { $focus_uid = intval($vv['id']); $focus_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_id . " and focused_user_id = " . $focus_uid); if ($focus_data) { $daren_list[$kk]['focused'] = 1; } } $GLOBALS['tmpl']->assign("daren_list", $daren_list); $topic_list = $GLOBALS['db']->getAll("select t.* from " . DB_PREFIX . "topic as t where t.is_effect = 1 and t.is_delete = 0 and t.is_recommend = 1 order by t.create_time desc limit 6"); foreach ($topic_list as $kk => $vv) { $vv['content'] = msubstr($vv['content'], 0, 30); $topic_list[$kk] = get_topic_item($vv); $topic_user_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . $vv['user_id'] . " and is_effect =1 and is_delete = 0"); $focus_uid = intval($topic_user_info['id']); $focus_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_id . " and focused_user_id = " . $focus_uid); if ($focus_data) { $topic_user_info['focused'] = 1; } $topic_list[$kk]['user_info'] = $topic_user_info; } $GLOBALS['tmpl']->assign("topic_list", $topic_list); $cate_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "topic_tag_cate where showin_web = 1 order by sort desc limit 7"); foreach ($cate_list as $k => $v) { //获取分类下的推荐分享 $cate_list[$k]['topic_list'] = $GLOBALS['db']->getAll("select t.* from " . DB_PREFIX . "topic as t left join " . DB_PREFIX . "topic_cate_link as l on l.topic_id = t.id where l.cate_id = " . $v['id'] . " and t.is_effect = 1 and t.is_delete = 0 and t.is_recommend = 1 order by t.create_time desc limit 4"); foreach ($cate_list[$k]['topic_list'] as $kk => $vv) { $vv['content'] = msubstr($vv['content'], 0, 30); $cate_list[$k]['topic_list'][$kk] = get_topic_item($vv); $topic_user_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . $vv['user_id'] . " and is_effect =1 and is_delete = 0"); $focus_uid = intval($topic_user_info['id']); $focus_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_id . " and focused_user_id = " . $focus_uid); if ($focus_data) { $topic_user_info['focused'] = 1; } $cate_list[$k]['topic_list'][$kk]['user_info'] = $topic_user_info; } $cate_list[$k]['daren_list'] = $GLOBALS['db']->getAllCached("select u.* from " . DB_PREFIX . "user as u left join " . DB_PREFIX . "user_cate_link as l on l.user_id = u.id where l.cate_id = " . $v['id'] . " and u.is_effect = 1 and u.is_delete = 0 and u.is_daren = 1 order by rand() limit 8"); foreach ($cate_list[$k]['daren_list'] as $kk => $vv) { $focus_uid = intval($vv['id']); $focus_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_id . " and focused_user_id = " . $focus_uid); if ($focus_data) { $cate_list[$k]['daren_list'][$kk]['focused'] = 1; } } } $GLOBALS['tmpl']->assign("cate_list", $cate_list); $daren_html = decode_topic($GLOBALS['tmpl']->fetch("inc/daren_show_item.html")); $GLOBALS['tmpl']->assign("daren_html", $daren_html); } $GLOBALS['tmpl']->display("daren_index.html", $cache_id); }
public function search() { //获取可以相关的用户 $user_list = get_rand_user(4); $user_id = intval($GLOBALS['user_info']['id']); $ids = array(0); foreach ($user_list as $k => $v) { $ids[] = $v['id']; } $focus_data = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_id . " and focused_user_id in (" . implode(",", $ids) . ")"); foreach ($user_list as $k => $v) { foreach ($focus_data as $kk => $vv) { if ($vv['focused_user_id'] == $v['id']) { $user_list[$k]['focused'] = 1; break; } } if ($v['city_id'] != 0 && $v['city_id'] == $GLOBALS['deal_city']['id']) { $user_list[$k]['same_city'] = 1; } else { $user_list[$k]['same_city'] = 0; } } $GLOBALS['tmpl']->assign("user_list", $user_list); convert_req($_REQUEST); $type = intval($_REQUEST['type']); $filter = intval($_REQUEST['filter']); $keyword = addslashes(htmlspecialchars(trim($_REQUEST['keyword']))); $GLOBALS['tmpl']->assign("keyword", $keyword); $GLOBALS['tmpl']->assign("type", $type); $GLOBALS['tmpl']->assign("filter", $filter); $url_param = array("type" => $type, "filter" => $filter, "keyword" => $keyword); if ($type == 0) { unset($url_param['type']); } if ($filter == 0) { unset($url_param['filter']); } if (intval($_REQUEST['is_redirect']) == 1) { if ($type > 0) { app_redirect(url("shop", "topic#search", $url_param)); } else { app_redirect(url("shop", "topic#search", $url_param)); } } $type_navs = array(array("type" => 0, "name" => $GLOBALS['lang']['TOPIC_TYPE_ALL']), array("type" => 1, "name" => $GLOBALS['lang']['TOPIC_TYPE_DEAL']), array("type" => 2, "name" => $GLOBALS['lang']['TOPIC_TYPE_STORE']), array("type" => 3, "name" => $GLOBALS['lang']['TOPIC_TYPE_RECOMMEND'])); foreach ($type_navs as $k => $v) { $tmp_url_param = $url_param; if ($v['type'] != 0) { $tmp_url_param['type'] = $v['type']; } else { unset($tmp_url_param['type']); } $type_navs[$k]['url'] = url("shop", "topic#search", $tmp_url_param); if ($v['type'] == $type) { $type_navs[$k]['act'] = true; } } $filter_navs = array(array("filter" => 0, "name" => $GLOBALS['lang']['TOPIC_FILTER_ALL']), array("filter" => 1, "name" => $GLOBALS['lang']['TOPIC_FILTER_MYFOCUS']), array("filter" => 2, "name" => $GLOBALS['lang']['TOPIC_FILTER_DAREN']), array("filter" => 3, "name" => $GLOBALS['lang']['TOPIC_FILTER_MERCHANT'])); foreach ($filter_navs as $k => $v) { $tmp_url_param = $url_param; if ($v['filter'] != 0) { $tmp_url_param['filter'] = $v['filter']; } else { unset($tmp_url_param['filter']); } $filter_navs[$k]['url'] = url("shop", "topic#search", $tmp_url_param); if ($v['filter'] == $filter) { $filter_navs[$k]['act'] = true; } } $condition = " 1=1 "; if ($type == 0) { //所有分享 $condition .= ""; $search_title = $GLOBALS['lang']['TOPIC_TYPE_ALL']; } elseif ($type == 1) { $condition .= " and (t.type='tuancomment' or t.type='shopcomment' or t.type='youhuicomment' ) "; $search_title = $GLOBALS['lang']['TOPIC_TYPE_DEAL']; } elseif ($type == 2) { $condition .= " and t.type='slocationcomment' "; $search_title = $GLOBALS['lang']['TOPIC_TYPE_STORE']; } elseif ($type == 3) { $condition .= " and t.title like '" . $keyword . "' "; $search_title = $GLOBALS['lang']['TOPIC_TYPE_RECOMMEND']; } if ($filter == 0) { //全部 //$search_title.= " - ".$GLOBALS['lang']['TOPIC_FILTER_ALL']; } elseif ($filter == 1) { $search_title .= " - " . $GLOBALS['lang']['TOPIC_FILTER_MYFOCUS']; $condition .= " and uf.focus_user_id = " . intval($GLOBALS['user_info']['id']); } elseif ($filter == 2) { $search_title .= " - " . $GLOBALS['lang']['TOPIC_FILTER_DAREN']; $condition .= " and u.is_daren = 1 "; } elseif ($filter == 3) { $search_title .= " - " . $GLOBALS['lang']['TOPIC_FILTER_MERCHANT']; $condition .= " and u.is_merchant = 1 "; } if ($keyword) { $search_title .= " - " . $keyword; $kws_div = div_str($keyword); foreach ($kws_div as $k => $item) { $kw[$k] = str_to_unicode_string($item); } $ukeyword = implode(" ", $kw); $condition .= " and match(t.keyword_match) against('" . $ukeyword . "' IN BOOLEAN MODE) "; } $GLOBALS['tmpl']->assign("kws_div", $kws_div); $GLOBALS['tmpl']->assign("page_title", $search_title); $GLOBALS['tmpl']->assign("page_keyword", $search_title . ","); $GLOBALS['tmpl']->assign("page_description", $search_title . ","); //分页 $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * app_conf("PAGE_SIZE") . "," . app_conf("PAGE_SIZE"); // $result = get_topic_list($limit,$condition,"",$kws_div); $orderby = 't.create_time desc'; $condition = " and " . $condition; $list = $GLOBALS['db']->getAll("select t.* from " . DB_PREFIX . "topic as t left join " . DB_PREFIX . "user as u on t.user_id = u.id left join " . DB_PREFIX . "user_focus as uf on uf.focused_user_id = t.user_id where t.is_effect = 1 and t.is_delete = 0 " . $condition . " group by t.id order by " . $orderby . " limit " . $limit); $total = $GLOBALS['db']->getOne("select count(distinct(t.id)) from " . DB_PREFIX . "topic as t left join " . DB_PREFIX . "user as u on t.user_id = u.id left join " . DB_PREFIX . "user_focus as uf on uf.focused_user_id = t.user_id where t.is_effect = 1 and t.is_delete = 0 " . $condition); foreach ($list as $k => $v) { $list[$k] = get_topic_item($v, $kws_div); if (msubstr(preg_replace("/<[^>]+>/i", "", $list[$k]['content']), 0, 50) != preg_replace("/<[^>]+>/i", "", $list[$k]['content'])) { $list[$k]['short_content'] = msubstr(preg_replace("/<[^>]+>/i", "", $list[$k]['content']), 0, 50); } else { $list[$k]['short_content'] = preg_replace("/<br[^>]+>/i", "", $list[$k]['content']); } if ($list[$k]['origin']) { if (msubstr(preg_replace("/<[^>]+>/i", "", $list[$k]['origin']['content']), 0, 50) != preg_replace("/<[^>]+>/i", "", $list[$k]['origin']['content'])) { $list[$k]['origin']['short_content'] = msubstr(preg_replace("/<[^>]+>/i", "", $list[$k]['origin']['content']), 0, 50); } else { $list[$k]['origin']['short_content'] = preg_replace("/<br[^>]+>/i", "", $list[$k]['origin']['content']); } } } $result = array('list' => $list, 'total' => $total); if ($result['total'] > 0) { if (check_ipop_limit(get_client_ip(), "topic_search", 10, $keyword)) { $GLOBALS['db']->query("update " . DB_PREFIX . "topic_tag set count = count + 1 where name = '" . $keyword . "'"); } } //$result['list'] = div_to_col($result['list']); $GLOBALS['tmpl']->assign("topic_list", $result['list']); $page = new Page($result['total'], app_conf("PAGE_SIZE")); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->assign('user_auth', get_user_auth()); $list_html = load_topic_list(); //$list_html = decode_topic_without_img($GLOBALS['tmpl']->fetch("inc/topic_col_list.html")); $GLOBALS['tmpl']->assign("list_html", $list_html); $GLOBALS['tmpl']->assign("type_navs", $type_navs); $GLOBALS['tmpl']->assign("filter_navs", $filter_navs); $res = load_dynamic_cache("topic_search_hot"); if ($res === false) { $res['hot_tag_list'] = $GLOBALS['db']->getAll("select name,color from " . DB_PREFIX . "topic_tag where is_recommend = 1 order by sort desc, count desc limit 10"); $res['hot_title_list'] = $GLOBALS['db']->getAll("select name,color from " . DB_PREFIX . "topic_title where is_recommend = 1 order by sort desc,count desc limit 10"); set_dynamic_cache("topic_search_hot", $res); } //输出搜索热词 $GLOBALS['tmpl']->assign("hot_tag_list", $res['hot_tag_list']); $GLOBALS['tmpl']->assign("hot_title_list", $res['hot_title_list']); //输出推荐分享 $recommend_topic = load_auto_cache("recommend_uc_topic"); $GLOBALS['tmpl']->assign("recommend_topic", $recommend_topic); $GLOBALS['tmpl']->display("topic_search.html"); }
/** * 输出推荐达人 */ function load_index_daren_list() { $rnd_daren_list = get_rand_user(20, 1); $GLOBALS['tmpl']->assign("rnd_daren_list", $rnd_daren_list); return $GLOBALS['tmpl']->fetch("index/index_daren_list.html"); }
function set_uc_right() { //获取可以相关的用户 $user_id = intval($GLOBALS['user_info']['id']); $user_list = get_rand_user(5, 0, $user_id); $GLOBALS['tmpl']->assign("user_list", $user_list); //输出粉丝 $fans_list = $GLOBALS['db']->getAll("select focus_user_id as id,focus_user_name as user_name from " . DB_PREFIX . "user_focus where focused_user_id = " . $user_id . " limit 5"); $ids = array(0); foreach ($fans_list as $k => $v) { $ids[] = $v['id']; } $focus_data = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_id . " and focused_user_id in (" . implode(",", $ids) . ")"); foreach ($fans_list as $k => $v) { foreach ($focus_data as $kk => $vv) { if ($vv['focused_user_id'] == $v['id']) { $fans_list[$k]['focused'] = 1; break; } } } $GLOBALS['tmpl']->assign("fans_list", $fans_list); //输出我的关注 $focus_list = $GLOBALS['db']->getAll("select focused_user_id as id,focused_user_name as user_name from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_id . " limit 5"); $ids = array(0); foreach ($focus_list as $k => $v) { $ids[] = $v['id']; } $focus_data = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_id . " and focused_user_id in (" . implode(",", $ids) . ")"); foreach ($focus_list as $k => $v) { foreach ($focus_data as $kk => $vv) { if ($vv['focused_user_id'] == $v['id']) { $focus_list[$k]['focused'] = 1; break; } } } $GLOBALS['tmpl']->assign("focus_list", $focus_list); $res = load_dynamic_cache("topic_search_hot"); if ($res === false) { $res['hot_tag_list'] = $GLOBALS['db']->getAll("select name,color from " . DB_PREFIX . "topic_tag where is_recommend = 1 order by sort desc, count desc limit 10"); $res['hot_title_list'] = $GLOBALS['db']->getAll("select name,color from " . DB_PREFIX . "topic_title where is_recommend = 1 order by sort desc,count desc limit 10"); set_dynamic_cache("topic_search_hot", $res); } //输出搜索热词 $GLOBALS['tmpl']->assign("hot_tag_list", $res['hot_tag_list']); $GLOBALS['tmpl']->assign("hot_title_list", $res['hot_title_list']); //输出推荐分享 $recommend_topic = load_auto_cache("recommend_uc_topic"); $GLOBALS['tmpl']->assign("recommend_topic", $recommend_topic); $GLOBALS['tmpl']->assign("has_right", 1); }
/** * 加载推荐用户 */ public function load_best_user() { global_run(); $count = intval($_REQUEST['count']); if ($GLOBALS['user_info']) { $uid = $GLOBALS['user_info']['id']; } else { $uid = 0; } $rand_user_list = get_rand_user($count, 0, $uid); $GLOBALS['tmpl']->assign("uc_u_list", $rand_user_list); $data = $GLOBALS['tmpl']->fetch("inc/best_user_list.html"); ajax_return($data); }