public function modify()
 {
     convert_req($_REQUEST);
     $id = $_REQUEST['id'];
     $s_account_info = es_session::get("account_info");
     $location_ids = $s_account_info['location_ids'];
     $info = $GLOBALS['db']->getRow(" SELECT * FROM " . DB_PREFIX . "supplier_location WHERE id = " . intval($id) . " and id in (" . implode(",", $s_account_info['location_ids']) . ")");
     if (!$info) {
         showErr("门店不存在或者没有编辑该门店的权限");
     }
     $info['city_name'] = get_deal_city_name(intval($info['city_id']));
     $area_list = $GLOBALS['db']->getAll("SELECT * FROM " . DB_PREFIX . "area where city_id=" . intval($info['city_id']));
     foreach ($area_list as $k => $v) {
         if ($GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "supplier_location_area_link where area_id=" . $v['id'] . " and location_id = " . $id)) {
             $area_list[$k]['checked'] = true;
         }
     }
     $s_account_info = es_session::get("account_info");
     $location_ids = $s_account_info['location_ids'];
     if (count($location_ids) == 2) {
         $history_back = url("biz");
     } else {
         $history_back = url("biz", "profile#modify");
     }
     $GLOBALS['tmpl']->assign("history_back", $history_back);
     $GLOBALS['tmpl']->assign("info", $info);
     $GLOBALS['tmpl']->assign("area_list", $area_list);
     $GLOBALS['tmpl']->display("biz/biz_location_modify.html");
 }
Example #2
0
 public function index()
 {
     require_once APP_ROOT_PATH . "system/model/topic.php";
     global_run();
     init_app_page();
     $GLOBALS['tmpl']->assign("wrap_type", "1");
     //宽屏展示
     $GLOBALS['tmpl']->assign("no_nav", true);
     //无分类下拉
     convert_req($_REQUEST);
     $title = $GLOBALS['lang']['DISCOVER'];
     $site_nav[] = array('name' => $GLOBALS['lang']['HOME_PAGE'], 'url' => url("index"));
     $site_nav[] = array('name' => $title, 'url' => url("index", "discover"));
     $GLOBALS['tmpl']->assign("site_nav", $site_nav);
     $cid = intval($_REQUEST['cid']);
     $cate_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "topic_tag_cate where id = " . $cid);
     $GLOBALS['tmpl']->assign("cid", $cid);
     $tag = strim($_REQUEST['tag']);
     if ($tag) {
         $GLOBALS['tmpl']->assign("tag", $tag);
     }
     if ($GLOBALS['kw']) {
         $GLOBALS['tmpl']->assign("tag", $GLOBALS['kw']);
     }
     if ($cate_name) {
         $title = $title . $cate_name;
     }
     if ($tag) {
         $title = $title . $tag;
     }
     $GLOBALS['tmpl']->assign("page_title", $title);
     $GLOBALS['tmpl']->assign("page_keyword", $title . ",");
     $GLOBALS['tmpl']->assign("page_description", $title . ",");
     if ($cid == 0) {
         $tag_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "topic_tag where is_recommend = 1 order by sort desc limit 10");
     } else {
         $tag_list = $GLOBALS['db']->getAll("select t.* from " . DB_PREFIX . "topic_tag as t left join " . DB_PREFIX . "topic_tag_cate_link as l on l.tag_id = t.id where l.cate_id = " . $cid . " order by t.sort desc limit 10");
     }
     $GLOBALS['tmpl']->assign("tag_list", $tag_list);
     $cate_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "topic_tag_cate where showin_web = 1 order by sort desc limit 7");
     $GLOBALS['tmpl']->assign("cate_list", $cate_list);
     $page = intval($_REQUEST['p']);
     if ($page == 0) {
         $page = 1;
     }
     $GLOBALS['tmpl']->assign("page", $page);
     $condition = ' is_effect = 1 and is_delete = 0 ';
     $param['cid'] = $cid;
     $param['tag'] = $tag;
     $param_condition = build_topic_filter_condition($param);
     $condition .= " " . $param_condition;
     $condition .= " and fav_id = 0 and relay_id = 0 and has_image = 1 and type in ('share','sharedeal','shareyouhui','shareevent') ";
     $sql = "select count(*) from " . DB_PREFIX . "topic where " . $condition;
     $count = $GLOBALS['db']->getOne($sql);
     $page_size = PIN_PAGE_SIZE;
     $page = new Page($count, $page_size);
     //初始化分页对象
     $p = $page->show();
     $GLOBALS['tmpl']->assign('pages', $p);
     $remain_count = $count - ($page - 1) * $page_size;
     //从当前页算起剩余的数量
     $remain_page = ceil($remain_count / $page_size);
     //剩余的页数
     if ($remain_page == 1) {
         //末页
         $step_size = ceil($remain_count / PIN_SECTOR);
     } else {
         $step_size = ceil(PIN_PAGE_SIZE / PIN_SECTOR);
     }
     $GLOBALS['tmpl']->assign('step_size', $step_size);
     $GLOBALS['tmpl']->display("discover.html");
 }
 public function index()
 {
     convert_req($_REQUEST);
     $_REQUEST['cid'] = intval($_REQUEST['cid']);
     $keyword = addslashes(htmlspecialchars(trim($_REQUEST['keyword'])));
     $GLOBALS['tmpl']->assign("keyword", $keyword);
     $url_param = array("cid" => $_REQUEST['cid'], "aid" => intval($_REQUEST['aid']), "tid" => intval($_REQUEST['tid']), "qid" => intval($_REQUEST['qid']), "keyword" => $keyword);
     if (intval($_REQUEST['is_redirect']) == 1) {
         app_redirect(url("youhui", "fcate", $url_param));
     }
     $quan_id = intval($_REQUEST['qid']);
     //
     $city_id = intval($GLOBALS['deal_city']['id']);
     //分页
     $page = intval($_REQUEST['p']);
     if ($page == 0) {
         $page = 1;
     }
     $limit = ($page - 1) * app_conf("DEAL_PAGE_SIZE") . "," . app_conf("DEAL_PAGE_SIZE");
     $cid = intval($_REQUEST['cid']);
     if ($cid == 0) {
         $uname = addslashes(trim($_REQUEST['cid']));
     }
     $cate_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_cate where id = " . $cid . " or (uname = '" . $uname . "' and uname <> '')");
     $free_youhui_list = get_free_youhui_list(5, intval($cate_item['id']), " is_recommend = 1 ", "");
     $GLOBALS['tmpl']->assign("free_youhui_list", $free_youhui_list['list']);
     $condition = " 1=1 ";
     //条件
     unset($url_param['keyword']);
     $sub_nav[] = array("name" => $GLOBALS['lang']['FREE_YOUHUI'], "url" => url("youhui", "fcate", $url_param), "current" => 1);
     $sub_nav[] = array("name" => $GLOBALS['lang']['NEED_BUY_YOUHUI'], "url" => url("youhui", "ycate", $url_param), "current" => 0);
     $sub_nav[] = array("name" => $GLOBALS['lang']['TUAN'], "url" => url("youhui", "tuan", $url_param), "current" => 0);
     $GLOBALS['tmpl']->assign("sub_nav", $sub_nav);
     $GLOBALS['tmpl']->assign("url_param", $url_param);
     //将变量输出到模板
     $seo_title = $GLOBALS['lang']['FREE_YOUHUI'];
     $seo_keyword = $GLOBALS['lang']['FREE_YOUHUI'];
     $seo_description = $GLOBALS['lang']['FREE_YOUHUI'];
     $cache_param = array("city_id" => $city_id, "cid" => $cate_item['id'], "tid" => $url_param['tid'], "aid" => $url_param['aid'], "qid" => $url_param['qid']);
     $result = load_auto_cache("fyouhui_filter_nav_cache", $cache_param);
     //输出行政区
     $append_seo = "";
     $area_id = intval($_REQUEST['aid']);
     if ($area_id > 0) {
         $area_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area where id = " . $area_id);
         $append_seo = $area_name;
         if ($quan_id > 0) {
             $kw_unicode = str_to_unicode_string($area_name);
             //有筛选
             $condition .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE)) ";
         } else {
             $ids = load_auto_cache("deal_quan_ids", array("quan_id" => $area_id));
             $quan_list = $GLOBALS['db']->getAll("select `name` from " . DB_PREFIX . "area where id in (" . implode(",", $ids) . ")");
             $unicode_quans = array();
             foreach ($quan_list as $k => $v) {
                 $unicode_quans[] = str_to_unicode_string($v['name']);
             }
             $kw_unicode = implode(" ", $unicode_quans);
             $condition .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))";
         }
     }
     $GLOBALS['tmpl']->assign("area_list", $result['area_list']);
     if ($area_id > 0) {
         //输出商圈
         if ($quan_id > 0) {
             $area_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area where id = " . $quan_id);
             $kw_unicode = str_to_unicode_string($area_name);
             //有筛选
             $condition .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE)) ";
             $append_seo = $append_seo . $area_name;
         }
         $GLOBALS['tmpl']->assign("quan_list", $result['quan_list']);
     }
     //输出分类
     $cate_id = $cate_item['id'];
     $GLOBALS['tmpl']->assign("cate_list", $result['cate_list']);
     //输出小分类
     $deal_type_id = intval($_REQUEST['tid']);
     $deal_cate_id = $cate_id;
     if ($deal_cate_id > 0) {
         $GLOBALS['tmpl']->assign("scate_list", $result['scate_list']);
         if ($append_seo != "") {
             $append_seo .= " - ";
         }
         $append_seo .= $cate_item['name'];
     }
     if ($deal_type_id > 0) {
         $deal_type_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate_type where id = " . $deal_type_id);
         $deal_type_name_unicode = str_to_unicode_string($deal_type_name);
         $condition .= " and (match(deal_cate_match) against('" . $deal_type_name_unicode . "' IN BOOLEAN MODE)) ";
         $append_seo .= $deal_type_name;
     }
     $seo_title = $append_seo . $seo_title;
     $seo_keyword = $append_seo . $seo_keyword;
     $seo_description = $append_seo . $seo_keyword;
     if ($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(name_match) against('" . $ukeyword . "'  IN BOOLEAN MODE) or name like '%" . $keyword . "%') ";
         $seo_title = $keyword . " - " . $seo_title;
     }
     $result = get_free_youhui_list($limit, $cate_id, $condition, "");
     $GLOBALS['tmpl']->assign("list", $result['list']);
     $page = new Page($result['count'], app_conf("DEAL_PAGE_SIZE"));
     //初始化分页对象
     $p = $page->show();
     $GLOBALS['tmpl']->assign('pages', $p);
     //
     $site_nav[] = array('name' => $GLOBALS['lang']['HOME_PAGE'], 'url' => url("index", "index"));
     $site_nav[] = array('name' => $GLOBALS['lang']['FREE_YOUHUI'], 'url' => url("youhui", "fcate"));
     if ($_GET['model'] == "app") {
         echo json_encode(array('ret' => 1));
     } else {
         $GLOBALS['tmpl']->assign("site_nav", $site_nav);
         $GLOBALS['tmpl']->assign("page_title", $seo_title);
         $GLOBALS['tmpl']->assign("page_keyword", $seo_keyword . ",");
         $GLOBALS['tmpl']->assign("page_description", $seo_description . ",");
         $GLOBALS['tmpl']->display("youhui_fcate.html");
     }
 }
Example #4
0
function insert_load_filter_goods_list()
{
    convert_req($_REQUEST);
    //获取当前页的团购商品列表
    //分页
    $page = intval($_REQUEST['p']);
    if ($page == 0) {
        $page = 1;
    }
    $limit = ($page - 1) * app_conf("DEAL_PAGE_SIZE") . "," . app_conf("DEAL_PAGE_SIZE");
    $id = intval($_REQUEST['id']);
    if ($id == 0) {
        $uname = addslashes(trim($_REQUEST['id']));
    }
    $cate_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "shop_cate where id = " . $id . " or (uname = '" . $uname . "' and uname <> '')");
    $condition = " d.buy_type<>1 ";
    //条件
    $url_param = array("id" => addslashes(trim($_REQUEST['id'])), "b" => intval($_REQUEST['b']), "min_price" => doubleval($_REQUEST['min_price']), "max_price" => doubleval($_REQUEST['max_price']));
    $filter_req = $_REQUEST['f'];
    //筛选数组
    if (count($filter_req) > 0) {
        foreach ($filter_req as $k => $v) {
            $url_param['f[' . $k . ']'] = $v;
        }
    }
    if (intval($_REQUEST['is_redirect']) == 1) {
        app_redirect(url("shop", "cate", $url_param));
    }
    $GLOBALS['tmpl']->assign("url_param", $url_param);
    //将变量输出到模板
    $ids = load_auto_cache("shop_sub_parent_cate_ids", array("cate_id" => intval($cate_item['id'])));
    $add_title = "";
    //输出品牌
    $brand_id = intval($_REQUEST['b']);
    if ($brand_id > 0) {
        $condition .= " and d.brand_id = " . $brand_id;
        $add_title .= $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "brand where id = " . $brand_id);
    }
    $brand_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "brand where shop_cate_id in (" . implode(",", $ids) . ")");
    $brand_list[] = array("name" => $GLOBALS['lang']['ALL'], "id" => 0);
    foreach ($brand_list as $k => $v) {
        if ($brand_id == $v['id']) {
            $brand_list[$k]['act'] = 1;
        }
        $tmp_url_param = $url_param;
        $tmp_url_param['b'] = $v['id'];
        $brand_list[$k]['url'] = url("shop", "cate#index", $tmp_url_param);
    }
    $GLOBALS['tmpl']->assign("brand_list", $brand_list);
    //输出属性筛选
    $join_str = "";
    $unicode_tags = array();
    if ($filter_req) {
        foreach ($filter_req as $k => $v) {
            $k = intval($k);
            $filter_req[$k] = trim(addslashes(urldecode($v)));
            if ($filter_req[$k] != '' && $filter_req[$k] != 'all') {
                if ($add_title != '') {
                    $add_title .= " - ";
                }
                $add_title .= $filter_req[$k];
                $unicode_tags[] = "+" . str_to_unicode_string($filter_req[$k]);
            }
        }
    }
    if (count($unicode_tags) > 0) {
        $kw_unicode = implode(" ", $unicode_tags);
        //有筛选
        $condition .= " and (match(d.tag_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))";
    }
    $filter_group = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "filter_group where is_effect = 1 and cate_id in (" . implode(",", $ids) . ") order by sort desc");
    foreach ($filter_group as $k => $v) {
        $filter_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "filter where filter_group_id = " . $v['id'] . " limit 20");
        $filter_list[] = array("name" => $GLOBALS['lang']['ALL'], "id" => 0);
        foreach ($filter_list as $kk => $vv) {
            if ($filter_req[$v['id']] == $vv['name']) {
                $filter_list[$kk]['act'] = 1;
            }
            if ($vv['id'] == 0) {
                $url_name = 'all';
            } else {
                $url_name = $vv['name'];
            }
            if (($filter_req[$v['id']] == 'all' || $filter_req[$v['id']] == '') && $url_name == 'all') {
                $filter_list[$kk]['act'] = 1;
            }
            $tmp_url_param = $url_param;
            $tmp_url_param["f[" . $v['id'] . "]"] = $url_name;
            $filter_list[$kk]['url'] = url("shop", "cate#index", $tmp_url_param);
        }
        $filter_group[$k]['filter_list'] = $filter_list;
    }
    $GLOBALS['tmpl']->assign("filter_group", $filter_group);
    //输出价格区间
    $min_price = doubleval($_REQUEST['min_price']);
    $max_price = doubleval($_REQUEST['max_price']);
    $GLOBALS['tmpl']->assign("min_price", $min_price);
    $GLOBALS['tmpl']->assign("max_price", $max_price);
    if ($min_price > 0) {
        $condition .= " and d.current_price >= " . $min_price;
    }
    if ($max_price > 0) {
        $condition .= " and d.current_price <= " . $max_price;
    }
    $sort_field = es_cookie::get("shop_sort_field") ? es_cookie::get("shop_sort_field") : "sort";
    $sort_type = es_cookie::get("shop_sort_type") ? es_cookie::get("shop_sort_type") : "desc";
    $GLOBALS['tmpl']->assign('sort_field', $sort_field);
    $GLOBALS['tmpl']->assign('sort_type', $sort_type);
    $result = search_goods_list($limit, intval($cate_item['id']), $condition, "d." . $sort_field . " " . $sort_type, false, $join_str);
    $GLOBALS['tmpl']->assign("list", $result['list']);
    $page = new Page($result['count'], app_conf("DEAL_PAGE_SIZE"));
    //初始化分页对象
    $p = $page->show();
    $GLOBALS['tmpl']->assign('pages', $p);
    $GLOBALS['tmpl']->assign("cate_id", $cate_item['id']);
    if (es_cookie::get("list_type") === null) {
        $list_type = app_conf("LIST_TYPE");
    } else {
        $list_type = intval(es_cookie::get("list_type"));
    }
    $GLOBALS['tmpl']->assign("list_type", $list_type);
    return $GLOBALS['tmpl']->fetch("inc/insert/load_filter_goods_list.html");
}
function convert_req(&$req)
{
    foreach ($req as $k => $v) {
        if (is_array($v)) {
            convert_req($req[$k]);
        } else {
            if (!is_u8($v)) {
                $req[$k] = iconv("gbk", "utf-8", $v);
            }
        }
    }
}
 public function pick()
 {
     $url_param = array("id" => addslashes(trim($_REQUEST['id'])), "b" => intval($_REQUEST['b']), "min_price" => doubleval($_REQUEST['min_price']), "max_price" => doubleval($_REQUEST['max_price']), "keyword" => addslashes(trim($_REQUEST['keyword'])));
     $filter_req = $_REQUEST['f'];
     //筛选数组
     if (count($filter_req) > 0) {
         foreach ($filter_req as $k => $v) {
             $url_param['f[' . $k . ']'] = $v;
         }
     }
     if (intval($_REQUEST['is_redirect']) == 1) {
         app_redirect(url("shop", "ss#pick", $url_param));
     }
     //输出商城分类
     $cate_tree = get_cate_tree();
     $all_cate_tree = get_cate_tree(0, 1);
     $GLOBALS['tmpl']->assign("cate_tree", $cate_tree);
     $GLOBALS['tmpl']->assign("all_cate_tree", $all_cate_tree);
     convert_req($_REQUEST);
     //获取当前页的团购商品列表
     //分页
     $page = intval($_REQUEST['p']);
     if ($page == 0) {
         $page = 1;
     }
     $limit = ($page - 1) * app_conf("DEAL_PAGE_SIZE") . "," . app_conf("DEAL_PAGE_SIZE");
     $id = intval($_REQUEST['id']);
     if ($id == 0) {
         $uname = addslashes(trim($_REQUEST['id']));
     }
     $cate_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "shop_cate where id = " . $id . " or (uname = '" . $uname . "' and uname <> '')");
     $condition = " d.buy_type<>1 ";
     //条件
     $ids = load_auto_cache("shop_sub_cate_ids", array("cate_id" => intval($cate_item['id'])));
     $add_title = "";
     //输出品牌
     $brand_id = intval($_REQUEST['b']);
     if ($brand_id > 0) {
         $condition .= " and d.brand_id = " . $brand_id;
         $add_title .= $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "brand where id = " . $brand_id);
         $GLOBALS['tmpl']->assign("brand_id", $brand_id);
     }
     $brand_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "brand order by sort desc");
     $GLOBALS['tmpl']->assign("brand_list", $brand_list);
     //输出属性筛选
     $filter_req = $_REQUEST['f'];
     $join_str = "";
     $unicode_tags = array();
     foreach ($filter_req as $k => $v) {
         $filter_req[$k] = trim(addslashes(urldecode($v)));
         if ($filter_req[$k] != '' && $filter_req[$k] != 'all') {
             if ($add_title != '') {
                 $add_title .= " - ";
             }
             $add_title .= $filter_req[$k];
             //				//联表及条件
             //				$join_str.=" left join ".DB_PREFIX."deal_filter as df_".$k." on d.id=df_".$k.".deal_id and df_".$k.".filter_group_id = ".$k;
             //				$condition.=" and df_".$k.".filter like '%".$filter_req[$k]."%' ";
             $unicode_tags[] = "+" . str_to_unicode_string($filter_req[$k]);
         }
     }
     if (count($unicode_tags) > 0) {
         $kw_unicode = implode(" ", $unicode_tags);
         //有筛选
         $condition .= " and (match(d.tag_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))";
     }
     if (intval($_REQUEST['id']) != 0) {
         $filter_group = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "filter_group where is_effect = 1 and cate_id in (" . implode(",", $ids) . ") order by sort desc");
         foreach ($filter_group as $k => $v) {
             $filter_group[$k]['value'] = $filter_req[$v['id']];
         }
         $GLOBALS['tmpl']->assign("filter_group", $filter_group);
     }
     //输出价格区间
     $min_price = doubleval($_REQUEST['min_price']);
     $max_price = doubleval($_REQUEST['max_price']);
     $GLOBALS['tmpl']->assign("min_price", $min_price);
     $GLOBALS['tmpl']->assign("max_price", $max_price);
     if ($min_price > 0) {
         $condition .= " and d.current_price >= " . $min_price;
     }
     if ($max_price > 0) {
         $condition .= " and d.current_price <= " . $max_price;
     }
     $sort_field = es_cookie::get("shop_sort_field") ? es_cookie::get("shop_sort_field") : "sort";
     $sort_type = es_cookie::get("shop_sort_type") ? es_cookie::get("shop_sort_type") : "desc";
     $GLOBALS['tmpl']->assign('sort_field', $sort_field);
     $GLOBALS['tmpl']->assign('sort_type', $sort_type);
     if (es_cookie::get("list_type") === null) {
         $list_type = app_conf("LIST_TYPE");
     } else {
         $list_type = intval(es_cookie::get("list_type"));
     }
     $GLOBALS['tmpl']->assign("list_type", $list_type);
     $kw = addslashes(htmlspecialchars(trim($_REQUEST['keyword'])));
     if ($kw != '') {
         $GLOBALS['tmpl']->assign('keyword', $kw);
         if ($add_title != '') {
             $add_title .= "-";
         }
         $add_title .= $kw;
         $kws_div = div_str($kw);
         foreach ($kws_div as $k => $item) {
             $kws[$k] = str_to_unicode_string($item);
         }
         $ukeyword = implode(" ", $kws);
         $condition .= " and (match(d.tag_match,d.name_match,d.locate_match,d.shop_cate_match) against('" . $ukeyword . "' IN BOOLEAN MODE))";
         //$condition.=" and (d.name like '%".$kw."%' or d.sub_name like '%".$kw."%' or d.brief like '%".$kw."%' or d.description like '%".$kw."%')";
     }
     if ($add_title != '') {
         $add_title .= "-";
     }
     $add_title .= $GLOBALS['lang']['GOODS_SEARCH'];
     $result = search_goods_list($limit, intval($cate_item['id']), $condition, "d." . $sort_field . " " . $sort_type, false, $join_str);
     $GLOBALS['tmpl']->assign("list", $result['list']);
     $page = new Page($result['count'], app_conf("DEAL_PAGE_SIZE"));
     //初始化分页对象
     $p = $page->show();
     $GLOBALS['tmpl']->assign('pages', $p);
     $GLOBALS['tmpl']->assign("cate_id", $cate_item['id']);
     $GLOBALS['tmpl']->assign("page_title", $add_title . $cate_item['name']);
     $GLOBALS['tmpl']->assign("page_keyword", $add_title . $cate_item['name'] . ",");
     $GLOBALS['tmpl']->assign("page_description", $add_title . $cate_item['name'] . ",");
     $GLOBALS['tmpl']->assign("filter", true);
     //显示筛选框
     $GLOBALS['tmpl']->assign("show_list", true);
     $GLOBALS['tmpl']->display("ss_index.html");
 }
 public function index()
 {
     convert_req($_REQUEST);
     $_REQUEST['cid'] = intval($_REQUEST['cid']);
     $keyword = addslashes(htmlspecialchars(trim($_REQUEST['keyword'])));
     $GLOBALS['tmpl']->assign("keyword", $keyword);
     $url_param = array("cid" => $_REQUEST['cid'], "aid" => intval($_REQUEST['aid']), "tid" => intval($_REQUEST['tid']), "qid" => intval($_REQUEST['qid']), "min_price" => doubleval($_REQUEST['min_price']), "max_price" => doubleval($_REQUEST['max_price']), "keyword" => $keyword);
     if (intval($_REQUEST['is_redirect']) == 1) {
         app_redirect(url("youhui", "ycate", $url_param));
     }
     $site_nav[] = array('name' => $GLOBALS['lang']['HOME_PAGE'], 'url' => url("index", "index"));
     $site_nav[] = array('name' => $GLOBALS['lang']['NEED_BUY_YOUHUI'], 'url' => url("youhui", "ycate#index"));
     $GLOBALS['tmpl']->assign("site_nav", $site_nav);
     //输出当前的site_nav
     //输出热卖
     $res = search_youhui_list(app_conf("SIDE_DEAL_COUNT"), 0, "", "d.buy_count desc", true, "");
     $GLOBALS['tmpl']->assign("hot_sale_list", $res['list']);
     $seo_title = $GLOBALS['lang']['NEED_BUY_YOUHUI'];
     $seo_keyword = $GLOBALS['lang']['NEED_BUY_YOUHUI'];
     $seo_description = $GLOBALS['lang']['NEED_BUY_YOUHUI'];
     //
     $city_id = intval($GLOBALS['deal_city']['id']);
     //分页
     $page = intval($_REQUEST['p']);
     if ($page == 0) {
         $page = 1;
     }
     $limit = ($page - 1) * app_conf("DEAL_PAGE_SIZE") . "," . app_conf("DEAL_PAGE_SIZE");
     $id = intval($_REQUEST['cid']);
     if ($id == 0) {
         $uname = addslashes(trim($_REQUEST['id']));
     }
     $cate_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_cate where id = " . $id . " or (uname = '" . $uname . "' and uname <> '')");
     $condition = " d.is_shop = 2 ";
     //条件
     $tp_url_param = $url_param;
     unset($tp_url_param['min_price']);
     unset($tp_url_param['max_price']);
     unset($tp_url_param['keyword']);
     $sub_nav[] = array("name" => $GLOBALS['lang']['FREE_YOUHUI'], "url" => url("youhui", "fcate", $tp_url_param), "current" => 0);
     $sub_nav[] = array("name" => $GLOBALS['lang']['NEED_BUY_YOUHUI'], "url" => url("youhui", "ycate", $tp_url_param), "current" => 1);
     $sub_nav[] = array("name" => $GLOBALS['lang']['TUAN'], "url" => url("youhui", "tuan", $tp_url_param), "current" => 0);
     $GLOBALS['tmpl']->assign("sub_nav", $sub_nav);
     $GLOBALS['tmpl']->assign("url_param", $tp_url_param);
     //将变量输出到模板
     $ids = load_auto_cache("deal_sub_cate_ids", array("cate_id" => intval($cate_item['id'])));
     $cache_param = array("city_id" => $city_id, "cid" => $cate_item['id'], "tid" => $url_param['tid'], "aid" => $url_param['aid'], "qid" => $url_param['qid']);
     $result = load_auto_cache("byouhui_filter_nav_cache", $cache_param);
     //输出大区
     $append_seo = "";
     $area_id = intval($_REQUEST['aid']);
     $quan_id = intval($_REQUEST['qid']);
     if ($area_id > 0) {
         $area_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area where id = " . $area_id);
         $append_seo .= $area_name;
         if ($quan_id > 0) {
             $kw_unicode = str_to_unicode_string($area_name);
             //有筛选
             $condition .= " and (match(d.locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))";
         } else {
             $ids = load_auto_cache("deal_quan_ids", array("quan_id" => $area_id));
             $quan_list = $GLOBALS['db']->getAll("select `name` from " . DB_PREFIX . "area where id in (" . implode(",", $ids) . ")");
             $unicode_quans = array();
             foreach ($quan_list as $k => $v) {
                 $unicode_quans[] = str_to_unicode_string($v['name']);
             }
             $kw_unicode = implode(" ", $unicode_quans);
             $condition .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))";
         }
     }
     $GLOBALS['tmpl']->assign("area_list", $result['area_list']);
     if ($area_id > 0) {
         //输出商圈
         if ($quan_id > 0) {
             $area_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area where id = " . $quan_id);
             $kw_unicode = str_to_unicode_string($area_name);
             //有筛选
             $condition .= " and (match(d.locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE)) ";
             $append_seo = $append_seo . $area_name;
         }
         $GLOBALS['tmpl']->assign("quan_list", $result['quan_list']);
     }
     //输出分类
     $cate_id = $cate_item['id'];
     $GLOBALS['tmpl']->assign("cate_list", $result['cate_list']);
     //输出小分类
     $deal_type_id = intval($_REQUEST['tid']);
     $deal_cate_id = $cate_item['id'];
     $deal_quan_id = $area_id;
     if ($deal_cate_id > 0) {
         $GLOBALS['tmpl']->assign("scate_list", $result['scate_list']);
         if ($append_seo != "") {
             $append_seo .= " - ";
         }
         $append_seo .= $cate_item['name'];
     }
     //输出价格区间
     $min_price = doubleval($_REQUEST['min_price']);
     $max_price = doubleval($_REQUEST['max_price']);
     $GLOBALS['tmpl']->assign("min_price", $min_price);
     $GLOBALS['tmpl']->assign("max_price", $max_price);
     if ($min_price > 0) {
         $condition .= " and d.current_price >= " . $min_price;
     }
     if ($max_price > 0) {
         $condition .= " and d.current_price <= " . $max_price;
     }
     $sort_field = es_cookie::get("shop_sort_field") ? es_cookie::get("shop_sort_field") : "sort";
     $sort_type = es_cookie::get("shop_sort_type") ? es_cookie::get("shop_sort_type") : "desc";
     if ($sort_field != "update_time" && $sort_field != "current_price" && $sort_field != "buy_count" && $sort_field != "avg_point" && $sort_field != "sort") {
         $sort_field = "sort";
     }
     if ($sort_type != "desc" && $sort_type != "asc") {
         $sort_type = "desc";
     }
     $GLOBALS['tmpl']->assign('sort_field', $sort_field);
     $GLOBALS['tmpl']->assign('sort_type', $sort_type);
     if ($deal_type_id > 0) {
         $deal_type_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate_type where id = " . $deal_type_id);
         $deal_type_name_unicode = str_to_unicode_string($deal_type_name);
         $condition .= " and (match(d.deal_cate_match) against('" . $deal_type_name_unicode . "' IN BOOLEAN MODE)) ";
         $append_seo .= $deal_type_name;
     }
     $seo_title = $append_seo . $seo_title;
     $seo_keyword = $append_seo . $seo_keyword;
     $seo_description = $append_seo . $seo_keyword;
     if ($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(d.name_match) against('" . $ukeyword . "'  IN BOOLEAN MODE) or d.name like '%" . $keyword . "%') ";
         $seo_title = $keyword . " - " . $seo_title;
     }
     $result = search_youhui_list($limit, intval($cate_item['id']), $condition, "d." . $sort_field . " " . $sort_type, false, "");
     $GLOBALS['tmpl']->assign("list", $result['list']);
     $page = new Page($result['count'], app_conf("DEAL_PAGE_SIZE"));
     //初始化分页对象
     $p = $page->show();
     $GLOBALS['tmpl']->assign('pages', $p);
     $GLOBALS['tmpl']->assign("cate_id", $cate_item['id']);
     //
     $GLOBALS['tmpl']->assign("page_title", $seo_title);
     $GLOBALS['tmpl']->assign("page_keyword", $seo_keyword);
     $GLOBALS['tmpl']->assign("page_description", $seo_description);
     $GLOBALS['tmpl']->display("youhui_ycate.html");
 }
 public function index()
 {
     convert_req($_REQUEST);
     $_REQUEST['cid'] = intval($_REQUEST['cid']);
     $keyword = addslashes(htmlspecialchars(trim($_REQUEST['keyword'])));
     //获取当前页的团购商品列表
     require_once APP_ROOT_PATH . 'app/Lib/page.php';
     $city_id = intval($GLOBALS['deal_city']['id']);
     //分页
     $page = intval($_REQUEST['p']);
     if ($page == 0) {
         $page = 1;
     }
     $limit = ($page - 1) * app_conf("DEAL_PAGE_SIZE") . "," . app_conf("DEAL_PAGE_SIZE");
     $cate_list = load_auto_cache("cache_deal_cate");
     $cid = intval($_REQUEST['cid']);
     $uname = addslashes(trim($_REQUEST['cid']));
     //$cate_item = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."deal_cate where id = ".$cid." or (uname = '".$uname."' and uname <> '')");
     $cate_item = $cate_list[$cid];
     $condition = " 1=1 ";
     //条件
     $base_param = $url_param = array("cid" => $_REQUEST['cid'], "aid" => intval($_REQUEST['aid']), "tid" => intval($_REQUEST['tid']), "qid" => intval($_REQUEST['qid']), "keyword" => $keyword, "minprice" => $minprice = doubleval($_REQUEST['minprice']) > 0 ? doubleval($_REQUEST['minprice']) : 0, "maxprice" => $maxprice = doubleval($_REQUEST['maxprice']) > 0 ? doubleval($_REQUEST['maxprice']) : 0);
     //组装分组筛选
     if ($_REQUEST['g'] && is_array($_REQUEST['g'])) {
         foreach ($_REQUEST['g'] as $k => $v) {
             $url_param["g[" . $k . "]"] = addslashes(trim($v));
         }
     }
     if (intval($_REQUEST['is_redirect']) == 1) {
         app_redirect(url("youhui", "store", $url_param));
     }
     $GLOBALS['tmpl']->assign("url_param", $url_param);
     //将变量输出到模板
     unset($url_param['keyword']);
     unset($url_param['minprice']);
     unset($url_param['maxprice']);
     $cache_param = $url_param;
     $cache_param['cid'] = $cate_item['id'];
     $cache_param['city_id'] = $city_id;
     $result = load_auto_cache("store_filter_nav_cache", $cache_param);
     $filter_url_param = $base_param;
     $filter_url_param['has_tuan'] = intval($_REQUEST['has_tuan']);
     $filter_url_param['has_daijin'] = intval($_REQUEST['has_daijin']);
     $filter_url_param['has_youhui'] = intval($_REQUEST['has_youhui']);
     $filter_url_param['has_event'] = intval($_REQUEST['has_event']);
     $filter_url_param['has_goods'] = intval($_REQUEST['has_goods']);
     $filter_url_param['is_verify'] = intval($_REQUEST['is_verify']);
     $GLOBALS['tmpl']->assign("filter_url_param", $filter_url_param);
     $tmpfilter_url_param = $filter_url_param;
     if ($filter_url_param['has_tuan'] == 1) {
         $tmpfilter_url_param['has_tuan'] = 0;
     } else {
         $tmpfilter_url_param['has_tuan'] = 1;
     }
     $filter_url['has_tuan'] = url("youhui", "store", $tmpfilter_url_param);
     $tmpfilter_url_param = $filter_url_param;
     if ($filter_url_param['has_daijin'] == 1) {
         $tmpfilter_url_param['has_daijin'] = 0;
     } else {
         $tmpfilter_url_param['has_daijin'] = 1;
     }
     $filter_url['has_daijin'] = url("youhui", "store", $tmpfilter_url_param);
     $tmpfilter_url_param = $filter_url_param;
     if ($filter_url_param['has_youhui'] == 1) {
         $tmpfilter_url_param['has_youhui'] = 0;
     } else {
         $tmpfilter_url_param['has_youhui'] = 1;
     }
     $filter_url['has_youhui'] = url("youhui", "store", $tmpfilter_url_param);
     $tmpfilter_url_param = $filter_url_param;
     if ($filter_url_param['has_event'] == 1) {
         $tmpfilter_url_param['has_event'] = 0;
     } else {
         $tmpfilter_url_param['has_event'] = 1;
     }
     $filter_url['has_event'] = url("youhui", "store", $tmpfilter_url_param);
     $tmpfilter_url_param = $filter_url_param;
     if ($filter_url_param['has_goods'] == 1) {
         $tmpfilter_url_param['has_goods'] = 0;
     } else {
         $tmpfilter_url_param['has_goods'] = 1;
     }
     $filter_url['has_goods'] = url("youhui", "store", $tmpfilter_url_param);
     $tmpfilter_url_param = $filter_url_param;
     if ($filter_url_param['is_verify'] == 1) {
         $tmpfilter_url_param['is_verify'] = 0;
     } else {
         $tmpfilter_url_param['is_verify'] = 1;
     }
     $filter_url['is_verify'] = url("youhui", "store", $tmpfilter_url_param);
     $GLOBALS['tmpl']->assign("filter_url", $filter_url);
     //输出大区
     $seo_title = $GLOBALS['lang']['STORE_LIST'];
     $seo_keyword = $GLOBALS['lang']['STORE_LIST'];
     $seo_description = $GLOBALS['lang']['STORE_LIST'];
     $append_seo = "";
     $area_id = intval($_REQUEST['aid']);
     $quan_id = intval($_REQUEST['qid']);
     $area_result = load_auto_cache("cache_area", array("city_id" => $GLOBALS['deal_city']['id']));
     if ($area_id > 0) {
         // 			$area_name = $GLOBALS['db']->getOne("select name from ".DB_PREFIX."area where id = ".$area_id);
         $area_name = $area_result[$area_id]['name'];
         $append_seo = $area_name;
         if ($quan_id > 0) {
             $kw_unicode = str_to_unicode_string($area_name);
             //有筛选
             $condition .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))";
         } else {
             $ids = load_auto_cache("deal_quan_ids", array("quan_id" => $area_id));
             //$quan_list = $GLOBALS['db']->getAll("select `name` from ".DB_PREFIX."area where id in (".implode(",",$ids).")");
             $unicode_quans = array();
             foreach ($ids as $k => $v) {
                 $unicode_quans[] = str_to_unicode_string($area_result[$v]['name']);
             }
             $kw_unicode = implode(" ", $unicode_quans);
             $condition .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))";
         }
     }
     $GLOBALS['tmpl']->assign("area_list", $result['area_list']);
     if ($area_id > 0) {
         //输出商圈
         if ($quan_id > 0) {
             // 					$area_name = $GLOBALS['db']->getOne("select name from ".DB_PREFIX."area where id = ".$quan_id);
             $area_name = $area_result[$quan_id]['name'];
             $kw_unicode = str_to_unicode_string($area_name);
             //有筛选
             $condition .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE)) ";
             $append_seo = $append_seo . $area_name;
         }
         $GLOBALS['tmpl']->assign("quan_list", $result['quan_list']);
     }
     //输出分类
     $cate_id = $cate_item['id'];
     $GLOBALS['tmpl']->assign("cate_list", $result['cate_list']);
     //输出小分类
     $deal_type_id = intval($_REQUEST['tid']);
     $deal_cate_id = $cate_id;
     if ($deal_cate_id > 0) {
         $GLOBALS['tmpl']->assign("scate_list", $result['scate_list']);
         $GLOBALS['tmpl']->assign("tag_group", $result['tag_group']);
         //$deal_cate_name = $GLOBALS['db']->getOne("select name from ".DB_PREFIX."deal_cate where id = ".$deal_cate_id);
         $deal_cate_name = $cate_list[$deal_cate_id]['name'];
         $deal_cate_name_unicode = str_to_unicode_string($deal_cate_name);
         $condition .= " and (match(deal_cate_match) against('" . $deal_cate_name_unicode . "' IN BOOLEAN MODE)) ";
         $cate_condition = " (match(deal_cate_match) against('" . $deal_cate_name_unicode . "' IN BOOLEAN MODE)) ";
         if ($append_seo != "") {
             $append_seo .= " - ";
         }
         $append_seo .= $cate_item['name'];
     }
     if ($deal_type_id > 0) {
         $type_list = load_auto_cache("cache_deal_cate_type", array("cate_id" => $deal_cate_id));
         // 			$deal_type_name = $GLOBALS['db']->getOne("select name from ".DB_PREFIX."deal_cate_type where id = ".$deal_type_id);
         $deal_type_name = $type_list[$deal_type_id]['name'];
         $deal_type_name_unicode = str_to_unicode_string($deal_type_name);
         $condition .= " and (match(deal_cate_match) against('" . $deal_type_name_unicode . "' IN BOOLEAN MODE)) ";
         $append_seo .= $deal_type_name;
     }
     $seo_title = $append_seo . $seo_title;
     $seo_keyword = $append_seo . $seo_keyword;
     $seo_description = $append_seo . $seo_keyword;
     $supplier_id = intval($_REQUEST['id']);
     if ($supplier_id > 0) {
         $supplier_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier where id = " . $supplier_id);
         if ($supplier_info) {
             $GLOBALS['tmpl']->assign("supplier_info", $supplier_info);
             $condition .= " and supplier_id = " . $supplier_id;
         }
     }
     $url_param['tag'] = addslashes($_REQUEST['tag']);
     if ($url_param['tag']) {
         $kw_unicode = str_to_unicode_string($url_param['tag']);
         //有筛选
         $condition .= " and (match(tags_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))";
     }
     if ($_REQUEST['g'] && is_array($_REQUEST['g'])) {
         foreach ($_REQUEST['g'] as $k => $v) {
             if (trim($v) != "") {
                 $kw_unicode = str_to_unicode_string($v);
                 $condition .= " and (match(tags_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))";
             }
         }
     }
     if ($keyword) {
         $GLOBALS['tmpl']->assign("keyword", $keyword);
         $kws_div = div_str($keyword);
         foreach ($kws_div as $k => $item) {
             $kw[$k] = str_to_unicode_string($item);
         }
         $kw_unicode = implode(" ", $kw);
         //有筛选
         $condition .= " and (locate_match_row like '%" . $keyword . "%' or name like '%" . $keyword . "%') ";
     }
     if ($minprice > 0) {
         $condition .= " and ref_avg_price >= " . $minprice;
         $GLOBALS['tmpl']->assign("minprice", round($minprice));
     }
     if ($maxprice > 0) {
         $condition .= " and ref_avg_price <= " . $maxprice;
         $GLOBALS['tmpl']->assign("maxprice", round($maxprice));
     }
     if ($filter_url_param['has_tuan'] > 0) {
         $condition .= " and tuan_count > 0 ";
     }
     if ($filter_url_param['has_daijin'] > 0) {
         $condition .= " and daijin_count > 0 ";
     }
     if ($filter_url_param['has_youhui'] > 0) {
         $condition .= " and youhui_count > 0 ";
     }
     if ($filter_url_param['has_event'] > 0) {
         $condition .= " and event_count > 0 ";
     }
     if ($filter_url_param['has_goods'] > 0) {
         $condition .= " and shop_count > 0 ";
     }
     if ($filter_url_param['is_verify'] > 0) {
         $condition .= " and is_verify = 1 ";
     }
     $sort_field = es_cookie::get("store_sort_field");
     $sort_type = es_cookie::get("store_sort_type");
     if ($sort_type != "desc" && $sort_type != "asc") {
         $sort_type = "desc";
     }
     if ($sort_field != "default" && $sort_field != "dp_count" && $sort_field != "avg_point" && $sort_field != "ref_avg_price") {
         $sort_field = "default";
     }
     if ($sort_field == 'default') {
         $sortby = " sort desc, id desc,is_verify desc,dp_count desc ";
     } else {
         $sortby = $sort_field . " " . $sort_type;
     }
     $GLOBALS['tmpl']->assign('sort_field', $sort_field);
     $GLOBALS['tmpl']->assign('sort_type', $sort_type);
     $result = get_store_list($limit, 0, $condition, $sortby, false);
     $GLOBALS['tmpl']->assign("list", $result['list']);
     $page = new Page($result['count'], app_conf("DEAL_PAGE_SIZE"));
     //初始化分页对象
     $p = $page->show();
     $GLOBALS['tmpl']->assign('pages', $p);
     $site_nav[] = array('name' => $GLOBALS['lang']['HOME_PAGE'], 'url' => url("index", "index"));
     $site_nav[] = array('name' => $GLOBALS['lang']['STORE_LIST'], 'url' => url("youhui", "store"));
     $GLOBALS['tmpl']->assign("site_nav", $site_nav);
     //输出最新加入的商家
     $new_stores = get_store_list(5, 0, $cate_condition, " id desc ", false, false);
     $GLOBALS['tmpl']->assign("new_stores", $new_stores['list']);
     if (trim($cate_condition) != '') {
         $rec_stores = get_store_list(5, 0, $cate_condition . " and is_recommend = 1 ", " id desc ", false, false);
     } else {
         $rec_stores = get_store_list(5, 0, " is_recommend = 1 ", " id desc ", false, false);
     }
     $GLOBALS['tmpl']->assign("rec_stores", $rec_stores['list']);
     $GLOBALS['tmpl']->assign("page_title", $seo_title);
     $GLOBALS['tmpl']->assign("page_keyword", $seo_keyword . ",");
     $GLOBALS['tmpl']->assign("page_description", $seo_description . ",");
     $GLOBALS['tmpl']->display("store_index.html");
 }
Example #9
0
if (!file_exists(APP_ROOT_PATH . 'public/runtime/app/tpl_caches/biz/')) {
    mkdir(APP_ROOT_PATH . 'public/runtime/app/tpl_caches/biz/', 0777);
}
if (!file_exists(APP_ROOT_PATH . 'public/runtime/app/tpl_compiled/biz/')) {
    mkdir(APP_ROOT_PATH . 'public/runtime/app/tpl_compiled/biz/', 0777);
}
$GLOBALS['tmpl']->cache_dir = APP_ROOT_PATH . 'public/runtime/app/tpl_caches/biz';
$GLOBALS['tmpl']->compile_dir = APP_ROOT_PATH . 'public/runtime/app/tpl_compiled/biz';
$GLOBALS['tmpl']->template_dir = APP_ROOT_PATH . 'app/Tpl/biz';
//定义模板路径
$tmpl_path = SITE_DOMAIN . APP_ROOT . "/app/Tpl/";
$GLOBALS['tmpl']->assign("TMPL", $tmpl_path . "biz");
$GLOBALS['tmpl']->assign("TMPL_REAL", APP_ROOT_PATH . "app/Tpl/biz");
$GLOBALS['tmpl']->assign("APP_INDEX", APP_INDEX);
$GLOBALS['tmpl']->assign("APP_ROOT", APP_ROOT);
convert_req($_REQUEST);
//为main应用解析url
if (app_conf("URL_MODEL") == 1) {
    //重写模式
    $current_url = APP_ROOT . "/biz";
    $rewrite_param = strim($_REQUEST['rewrite_param']);
    $rewrite_param = str_replace(array("\"", "'"), array("", ""), $rewrite_param);
    $rewrite_param = explode("/", $rewrite_param);
    foreach ($rewrite_param as $k => $param_item) {
        if ($param_item != '') {
            $rewrite_param_array[] = $param_item;
        }
    }
    foreach ($rewrite_param_array as $k => $v) {
        if ($k == 0) {
            //解析ctl
 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");
 }
 public function index()
 {
     convert_req($_REQUEST);
     $_REQUEST['cid'] = intval($_REQUEST['cid']);
     $keyword = addslashes(htmlspecialchars(trim($_REQUEST['keyword'])));
     $GLOBALS['tmpl']->assign("keyword", $keyword);
     $url_param = array("cid" => addslashes(trim($_REQUEST['cid'])), "aid" => intval($_REQUEST['aid']), "qid" => intval($_REQUEST['qid']), "keyword" => $keyword);
     if (intval($_REQUEST['is_redirect']) == 1) {
         app_redirect(url("youhui", "event", $url_param));
     }
     $site_nav[] = array('name' => $GLOBALS['lang']['HOME_PAGE'], 'url' => url("index", "index"));
     $site_nav[] = array('name' => $GLOBALS['lang']['YOUHUI_EVENT'], 'url' => url("youhui", "event#index"));
     $GLOBALS['tmpl']->assign("site_nav", $site_nav);
     //输出当前的site_nav
     //输出热卖
     $seo_title = $GLOBALS['lang']['YOUHUI_EVENT'];
     $seo_keyword = $GLOBALS['lang']['YOUHUI_EVENT'];
     $seo_description = $GLOBALS['lang']['YOUHUI_EVENT'];
     //
     $city_id = intval($GLOBALS['deal_city']['id']);
     $quan_id = intval($_REQUEST['qid']);
     //分页
     $page = intval($_REQUEST['p']);
     if ($page == 0) {
         $page = 1;
     }
     $limit = ($page - 1) * app_conf("DEAL_PAGE_SIZE") . "," . app_conf("DEAL_PAGE_SIZE");
     if ($_REQUEST['plat'] == APP_PLAT) {
         $num = empty($_POST['num']) ? 12 : $_POST['num'];
         // page size
         $prepage = empty($_POST['prepage']) ? 0 : $_POST['prepage'];
         $start = $prepage * $num + 0;
         $limit = $start . "," . $num;
     }
     $id = intval($_REQUEST['cid']);
     $cate_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "event_cate where id = " . $id);
     $condition = " 1=1 ";
     //条件
     $tp_url_param = $url_param;
     unset($tp_url_param['keyword']);
     $sub_nav[] = array("name" => $GLOBALS['lang']['YOUHUI_EVENT'], "url" => url("youhui", "event", $tp_url_param), "current" => 1);
     $GLOBALS['tmpl']->assign("sub_nav", $sub_nav);
     $GLOBALS['tmpl']->assign("url_param", $tp_url_param);
     //将变量输出到模板
     $append_seo = "";
     //输出大区
     $area_id = intval($_REQUEST['aid']);
     if ($area_id > 0) {
         $area_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area where id = " . $area_id);
         $append_seo .= $area_name;
         if ($quan_id > 0) {
             $kw_unicode = str_to_unicode_string($area_name);
             //有筛选
             $condition .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))";
         } else {
             $ids = load_auto_cache("deal_quan_ids", array("quan_id" => $area_id));
             $quan_list = $GLOBALS['db']->getAll("select `name` from " . DB_PREFIX . "area where id in (" . implode(",", $ids) . ")");
             $unicode_quans = array();
             foreach ($quan_list as $k => $v) {
                 $unicode_quans[] = str_to_unicode_string($v['name']);
             }
             $kw_unicode = implode(" ", $unicode_quans);
             $condition .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))";
         }
     }
     $area_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "area where city_id = " . $city_id . " and pid = 0 order by sort desc");
     $area_list[] = array("name" => $GLOBALS['lang']['ALL'], "id" => 0);
     foreach ($area_list as $k => $v) {
         if ($area_id == $v['id']) {
             $area_list[$k]['act'] = 1;
         }
         $tmp_url_param = $url_param;
         unset($tmp_url_param['qid']);
         $tmp_url_param['aid'] = $v['id'];
         $area_list[$k]['url'] = url("youhui", "event", $tmp_url_param);
     }
     $GLOBALS['tmpl']->assign("area_list", $area_list);
     if ($area_id > 0) {
         //输出商圈
         if ($quan_id > 0) {
             $area_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area where id = " . $quan_id);
             $kw_unicode = str_to_unicode_string($area_name);
             //有筛选
             $condition .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE)) ";
             $append_seo = $append_seo . $area_name;
         }
         $quan_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "area where city_id = " . $city_id . " and pid = " . $area_id . " order by sort desc");
         $quan_list[] = array("name" => $GLOBALS['lang']['ALL'], "id" => 0);
         foreach ($quan_list as $k => $v) {
             if ($quan_id == $v['id']) {
                 $quan_list[$k]['act'] = 1;
             }
             $tmp_url_param = $url_param;
             $tmp_url_param['qid'] = $v['id'];
             $quan_list[$k]['url'] = url("youhui", "event", $tmp_url_param);
         }
         $GLOBALS['tmpl']->assign("quan_list", $quan_list);
     }
     //输出分类
     $cate_id = $cate_item['id'];
     $cate_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "event_cate where is_effect = 1 order by sort desc");
     $cate_list[] = array("name" => $GLOBALS['lang']['ALL'], "cid" => 0);
     foreach ($cate_list as $k => $v) {
         if ($cate_id == $v['id']) {
             $cate_list[$k]['act'] = 1;
         }
         $tmp_url_param = $url_param;
         $tmp_url_param['cid'] = $v['id'];
         $cate_list[$k]['url'] = url("youhui", "event", $tmp_url_param);
     }
     $GLOBALS['tmpl']->assign("cate_list", $cate_list);
     $deal_cate_id = $cate_item['id'];
     $deal_quan_id = $area_id;
     if ($deal_cate_id > 0) {
         $append_seo .= $cate_item['name'];
     }
     $sort_field = es_cookie::get("event_sort_field") ? es_cookie::get("event_sort_field") : "sort";
     $sort_type = es_cookie::get("event_sort_type") ? es_cookie::get("event_sort_type") : "desc";
     if ($sort_field != "event_end_time" && $sort_field != "submit_count" && $sort_field != "sort") {
         $sort_field = "sort";
     }
     if ($sort_type != "desc" && $sort_type != "asc") {
         $sort_type = "desc";
     }
     $GLOBALS['tmpl']->assign('sort_field', $sort_field);
     $GLOBALS['tmpl']->assign('sort_type', $sort_type);
     $sort_by = $sort_field . " " . $sort_type;
     $seo_title = $append_seo . $seo_title;
     $seo_keyword = $append_seo . $seo_keyword;
     $seo_description = $append_seo . $seo_keyword;
     if ($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(name_match) against('" . $ukeyword . "'  IN BOOLEAN MODE)  or name like '%" . $keyword . "%') ";
         $seo_title = $keyword . " - " . $seo_title;
     }
     $result = search_event_list($limit, intval($cate_item['id']), $city_id, $condition, $sort_by);
     if ($_REQUEST['plat'] == APP_PLAT) {
         foreach ($result['list'] as $i => $v) {
             $result['list'][$i]['lng'] = !empty($v['xpoint']) ? $v['xpoint'] : '119.025595';
             $result['list'][$i]['lat'] = !empty($v['ypoint']) ? $v['ypoint'] : '33.596043';
         }
         $ret = array('ret' => '0', 'hb_list' => $result['list'], 'num' => $num, 'page' => $prepage + 1);
         array_recursive($ret, 'strval');
         echo json_encode($ret);
         exit;
     }
     $GLOBALS['tmpl']->assign("list", $result['list']);
     $page = new Page($result['count'], app_conf("DEAL_PAGE_SIZE"));
     //初始化分页对象
     $p = $page->show();
     $GLOBALS['tmpl']->assign('pages', $p);
     $GLOBALS['tmpl']->assign("cate_id", $cate_item['id']);
     //
     $GLOBALS['tmpl']->assign("page_title", $seo_title);
     $GLOBALS['tmpl']->assign("page_keyword", $seo_keyword);
     $GLOBALS['tmpl']->assign("page_description", $seo_description);
     $GLOBALS['tmpl']->display("youhui_event.html");
 }
 public function index()
 {
     convert_req($_REQUEST);
     $title = $GLOBALS['lang']['DISCOVER'];
     $site_nav[] = array('name' => $GLOBALS['lang']['HOME_PAGE'], 'url' => APP_ROOT . "/");
     $site_nav[] = array('name' => $title, 'url' => url("shop", "discover"));
     $GLOBALS['tmpl']->assign("site_nav", $site_nav);
     $cid = intval($_REQUEST['cid']);
     $cate_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "topic_tag_cate where id = " . $cid);
     $GLOBALS['tmpl']->assign("cid", $cid);
     $tag = addslashes(htmlspecialchars(trim($_REQUEST['tag'])));
     $GLOBALS['tmpl']->assign("tag", $tag);
     if ($cate_name) {
         $title = $title . $cate_name;
     }
     if ($tag) {
         $title = $title . $tag;
     }
     $GLOBALS['tmpl']->assign("page_title", $title);
     $GLOBALS['tmpl']->assign("page_keyword", $title . ",");
     $GLOBALS['tmpl']->assign("page_description", $title . ",");
     if ($cid == 0) {
         $tag_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "topic_tag where is_recommend = 1 order by sort desc limit 10");
     } else {
         $tag_list = $GLOBALS['db']->getAll("select t.* from " . DB_PREFIX . "topic_tag as t left join " . DB_PREFIX . "topic_tag_cate_link as l on l.tag_id = t.id where l.cate_id = " . $cid . " order by t.sort desc limit 10");
     }
     $GLOBALS['tmpl']->assign("tag_list", $tag_list);
     $cate_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "topic_tag_cate where showin_web = 1 order by sort desc limit 7");
     $GLOBALS['tmpl']->assign("cate_list", $cate_list);
     $page = intval($_REQUEST['p']);
     if ($page == 0) {
         $page = 1;
     }
     $GLOBALS['tmpl']->assign("page", $page);
     if ($cid > 0) {
         if ($cate_name) {
             $unicode_cate_name = str_to_unicode_string($cate_name);
             $condition .= " and match(cate_match) against('" . $unicode_cate_name . "'  IN BOOLEAN MODE) ";
         }
     }
     if ($tag != "") {
         $unicode_tag = str_to_unicode_string($tag);
         $condition .= " and match(keyword_match) against('" . $unicode_tag . "'  IN BOOLEAN MODE) ";
     }
     $sql = "select count(*) from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and fav_id = 0 and relay_id = 0 and type in ('share','sharetuan','sharegoods','sharefyouhui','sharebyouhui','shareevent')  " . $condition;
     $count = $GLOBALS['db']->getOne($sql);
     $page_size = PAGE_SIZE;
     $page = new Page($count, $page_size);
     //初始化分页对象
     $p = $page->show();
     $GLOBALS['tmpl']->assign('pages', $p);
     $remain_count = $count - ($page - 1) * $page_size;
     //从当前页算起剩余的数量
     $remain_page = ceil($remain_count / $page_size);
     //剩余的页数
     if ($remain_page == 1) {
         //末页
         $step_size = ceil($remain_count / SECTOR);
     } else {
         $step_size = ceil(PAGE_SIZE / SECTOR);
     }
     $GLOBALS['tmpl']->assign('step_size', $step_size);
     $GLOBALS['tmpl']->display("discover_index.html");
 }