public function arealist() { $sql = "select id,name,city_id,pid from " . DB_PREFIX . "area "; $flag = 0; if (!empty($_POST['city_id'])) { $city_id = $_POST['city_id']; $sql .= " where ciyt_id =" . $city_id; $flag = 1; } if (!empty($_POST['pid'])) { $pid = $_POST['pid']; if ($flag == 1) { $sql .= " and pid = " . $pid; } else { $sql .= " where pid=" . $pid; } } $sql .= " order by sort"; $result = $GLOBALS['db']->getAll($sql); array_recursive($result, 'strval'); echo json_encode($result); }
/** * 根据 merchant_name 获取默认门店详情 */ public function get_def_location_with_account_name() { if (empty($_POST['merchant_name'])) { echo json_encode(array('ret' => '102')); exit; } $merchant_name = $_POST['merchant_name']; $sql = "select * from " . DB_PREFIX . "supplier_location where is_main=1 and supplier_id=(select supplier_id from " . DB_PREFIX . "supplier_account where account_name='" . $merchant_name . "')"; $detail = $GLOBALS['db']->getRow($sql); if ($detail !== false) { $sql = "select name from " . DB_PREFIX . "supplier where id =" . $detail['supplier_id']; $detail['supplier_name'] = $GLOBALS['db']->getOne($sql); $detail['lng'] = $detail['xpoint']; $detail['lat'] = $detail['ypoint']; $detail['ret'] = '0'; array_recursive($detail, 'strval', true); echo json_encode($detail); } else { echo json_encode(array('ret' => '102')); } }
/** * * 使用特定function对数组中所有元素做处理 * @param string &$array 要处理的字符串 * @param string $function 要执行的函数 * @return boolean $apply_to_keys_also 是否也应用到key上 * @access public * */ function array_recursive(&$array, $function, $apply_to_keys_also = false) { static $recursive_counter = 0; if (++$recursive_counter > 1000) { die('possible deep recursion attack'); } foreach ($array as $key => $value) { if (is_array($value)) { array_recursive($array[$key], $function, $apply_to_keys_also); } else { $array[$key] = $function($value); } if ($apply_to_keys_also && is_string($key)) { $new_key = $function($key); if ($new_key != $key) { $array[$new_key] = $array[$key]; unset($array[$key]); } } } $recursive_counter--; }
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 detail() { $sql = "select * from tb_taoxin where id=" . $_GET['id']; $result = $GLOBALS['db']->getRow($sql); if (!empty($result)) { //获取城市名 $sql = "select name from " . DB_PREFIX . "deal_city where id = " . $result['city_id']; $city = $GLOBALS['db']->getOne($sql); //获取地区名 $sql = "select name from " . DB_PREFIX . "area where id = " . $result['area_id']; $result['area'] = $GLOBALS['db']->getOne($sql); //获取分类名 $sql = "select name from " . DB_PREFIX . "taoxin_cate where id = " . $result['cate_id']; $result['cate_name'] = $GLOBALS['db']->getOne($sql); //获取发布人姓名 $sql = "select user_name from " . DB_PREFIX . "user where id=" . $result['uid']; $result['uname'] = $GLOBALS['db']->getOne($sql); $result['city'] = $city; $result['cityid'] = $result['city_id']; $result['city_name'] = $city; $result['photos'] = empty($result['goods_photos']) ? array() : json_decode($result['goods_photos'], true); $result['create_time'] = date("Y-m-d H:i:s", $result['create_time']); if (!empty($_POST['plat']) && $_POST['plat'] === APP_PLAT) { $result['lng'] = $result['longitude']; $result['lat'] = $result['latitude']; if (isset($result['cate_id'])) { $sql = "select pid from tb_taoxin_cate where id = " . $result['cate_id']; $pid = $GLOBALS['db']->getOne($sql); if ($pid != 0) { $result['subcate_id'] = $result['cate_id']; $result['cate_id'] = $pid; } } $result['pl_uid'] = $GLOBALS['db']->getOne("select pl_user_id from " . DB_PREFIX . "user where id=" . $result['uid']); $result['ret'] = "0"; array_recursive($result, "strval", true); echo json_encode($result); } else { $GLOBALS['tmpl']->assign("taoxin", $result); $GLOBALS['tmpl']->display("taoxin_detail.html"); } } else { header("Location:index.php?ctl=taoxin"); } }
public function get_phone_by_order() { //file_put_contents("/tmp/test.log", '########giftlist start#######'."\n",FILE_APPEND); $order_sn = $_POST['order_sn']; if (!$order_sn) { echo json_encode(array('ret' => '158', 'msg' => '请求参数为空')); return; } $contact = $GLOBALS['db']->getRow("select mobile,consignee from " . DB_PREFIX . "deal_order where order_sn=" . $order_sn, TRUE); if ($contact) { $result = array('ret' => '0', 'phone' => $contact['mobile'], 'consignee' => $contact['consignee']); } else { $result = array('ret' => '-1', 'msg' => '获取数据失败'); } array_recursive($result, "strval"); //file_put_contents("/tmp/test.log", '########jsonres='.json_encode($result).'#######'."\n",FILE_APPEND); echo json_encode($result); }
public function app_search() { // //file_put_contents("/tmp/ss.log", "\n".date("Y-m-d H:i:s")." post:".json_encode($_POST)."\n",FILE_APPEND); // $_POST['keyword'] = "电台灯"; // $_POST['s_type'] = "taoxin,deal"; // if (empty($_POST['keyword']) || empty($_POST['s_type'])) { echo json_encode(array('ret' => '102')); } else { // 搜索类型,all为搜索所有 $s_type = $_POST['s_type']; $s_type_arr = explode(",", $s_type); $kw = addslashes(htmlspecialchars(trim($_POST['keyword']))); $kws_div = div_str($kw); // $kws = array(); foreach ($kws_div as $k => $item) { $kws_div[] = str_to_unicode_string($item); } $ukeyword = implode(" ", $kws_div); $num = empty($_POST['num']) ? 10 : $_POST['num']; // page size $prepage = empty($_POST['prepage']) ? 0 : $_POST['prepage']; $start = $prepage * $num + 0; $limit = $start . "," . $num; if (!empty($_POST['lng']) && !empty($_POST['lat'])) { $distance = !empty($_POST['distance']) ? $_POST['distance'] : 1000000; $lng = $_POST['lng']; $lat = $_POST['lat']; } if (in_array("deal", $s_type_arr)) { $sort_type = intval($_POST['price_sort']) === 1 ? "ASC" : "desc"; // 搜索商品 $sql = "select id,name,shop_cate_id,current_price,origin_price,icon,is_delivery,is_cash_pay from " . DB_PREFIX . "deal where is_effect=1 and supplier_id<>0 "; $sql_count = "select count(*) from " . DB_PREFIX . "deal where is_effect=1 and supplier_id<>0 "; $condition = "and match(`name_match`,`deal_cate_match`,`locate_match`,`tag_match`,`shop_cate_match`) against('" . $ukeyword . "') and is_delete=0 "; if (!empty($_POST['lng']) && !empty($_POST['lat'])) { $condition .= "and id in ( select deal_id from " . DB_PREFIX . "deal_location_link as dll left join " . DB_PREFIX . "deal as d on d.id=dll.deal_id where dll.location_id in (select id from " . DB_PREFIX . "supplier_location where " . search_where_radius($distance, $lng, $lat, "location") . ") and d.is_effect=1 and d.is_delete=0)"; } $condition .= " order by current_price " . $sort_type; $condition .= " limit " . $limit; $sql = $sql . $condition; $sql_count = $sql_count . $condition; //file_put_contents("/tmp/ss.log", "\n".date("Y-m-d H:i:s")." sql:".$sql."\n",FILE_APPEND); $result['deal_list'] = $GLOBALS['db']->getAll($sql); $result['deal_count'] = $GLOBALS['db']->getOne($sql_count); if ($result['deal_list'] !== false) { foreach ($result['deal_list'] as $index => $v) { $sql = "select id,name,address,tel from " . DB_PREFIX . "supplier_location where id in (select location_id from " . DB_PREFIX . "deal_location_link where deal_id=" . $v['id'] . ")"; $result['deal_list'][$index]['location_list'] = $GLOBALS['db']->getAll($sql); $sql = "select id,name from " . DB_PREFIX . "supplier where id =" . $v['supplier_id']; $result['deal_list'][$index]['supplier'] = $GLOBALS['db']->getRow($sql); $result['deal_list'][$index]['is_can_buy'] = is_can_buy($v['shop_cate_id']) ? '1' : '0'; } } } if (in_array("taoxin", $s_type_arr)) { // 搜索淘信 $sql = "select id,title,price,contact,address,longitude as lng,latitude as lat from " . DB_PREFIX . "taoxin where match(title,detail) against('" . $ukeyword . "') and verify=1 limit " . $limit; $sql_count = "select count(*) from " . DB_PREFIX . "taoxin where verify=1 and match(title,detail) against('" . $ukeyword . "')"; $result['taoxin_list'] = $GLOBALS['db']->getAll($sql); if (empty($result['taoxin_list'])) { $result['taoxin_list'] = array(); } else { foreach ($result['taoxin_list'] as $i => $v) { $result['taoxin_list'][$i]['photos'] = empty($v['goods_photos']) ? array() : json_decode($v['goods_photos'], true); $result['taoxin_list'][$i]['create_time'] = date("Y-m-d H:i:s", $v['create_time']); $pcate = $GLOBALS['db']->getRow("select id,name from " . DB_PREFIX . "taoxin_cate where id=(select pid from " . DB_PREFIX . "taoxin_cate where id=" . $v['cate_id'] . ")"); if (intval($pcate['id']) == 1) { // 如果已经是一级分类,请求自己作为一级分类 $pcate = $GLOBALS['db']->getRow("select id,name from " . DB_PREFIX . "taoxin_cate where id=" . $v['cate_id']); } $result['taoxin_list'][$i]['pcate_name'] = $pcate['name']; $result['taoxin_list'][$i]['pcate_id'] = strval($pcate['id']); } } $result['taoxin_count'] = $GLOBALS['db']->getOne($sql_count); } if (in_array("supplier", $s_type_arr)) { // 搜索商家 $sql = "select id,name from " . DB_PREFIX . "supplier where match(name_match) against('" . $ukeyword . "') and is_effect=1 limit " . $limit; $sql_count = "select count(*) from " . DB_PREFIX . "supplier where match(name_match) against('" . $ukeyword . "') and is_effect=1"; $result['supplier_list'] = $GLOBALS['db']->getAll($sql); $result['supplier_count'] = $GLOBALS['db']->getOne($sql_count); if (empty($result['supplier_list'])) { $result['supplier_list'] = array(); } } if (in_array("location", $s_type_arr)) { //搜索未认证商家,即网络商家 $sql = "select id,name from " . DB_PREFIX . "supplier_location where match(name_match) against('" . $ukeyword . "') and is_verify=0 and is_effect=1 limit " . $limit; $sql_count = "select count(*) from " . DB_PREFIX . "supplier_location where match(name_match) against('" . $ukeyword . "') and is_verify=0 and is_effect=1"; $result['location_list'] = $GLOBALS['db']->getAll($sql); $result['location_count'] = $GLOBALS['db']->getOne($sql_count); if (empty($result['location_list'])) { $result['location_list'] = array(); } } if (in_array("event", $s_type_arr)) { // 搜索活动 $sql = "select id,name,address,icon from " . DB_PREFIX . "event where match(`locate_match`,`cate_match`,`name_match`) against('" . $ukeyword . "') and is_effect=1 limit " . $limit; $sql_count = "select count(*) from " . DB_PREFIX . "event where match(`locate_match`,`cate_match`,`name_match`) against('" . $ukeyword . "') and is_effect=1"; $result['event_list'] = $GLOBALS['db']->getAll($sql); $result['event_count'] = $GLOBALS['db']->getOne($sql_count); if (empty($result['event_list'])) { $result['event_list'] = array(); } } $result['ret'] = '0'; array_recursive($result, 'strval', true); //file_put_contents("/tmp/xiao.log", "\n result ".json_encode($result)."\n",FILE_APPEND); echo json_encode($result); } }