/** * 数据获取 **/ public function get() { $key_word = check_empty($this->input->get('keyword'), ''); $city_id = input_int($this->input->get('city'), 100000, FALSE, '530700'); //默认丽江 $page = input_int($this->input->get('page'), 1, FALSE, 1); $perpage = input_int($this->input->get('perpage'), 1, 20, 10); $category = input_int($this->input->get('cid'), 0, FALSE, 0); $category_id = input_int($this->input->get('ccid'), 0, FALSE, 0); $dest_id = input_int($this->input->get('dest'), 0, FALSE, 0); $local_id = input_int($this->input->get('local'), 0, FALSE, 0); $sort = input_string($this->input->get('sort'), array('time', 'local', 'highp', 'lowp'), 'time'); $today = input_int($this->input->get('today'), 0, 2, 0); $order_by = array('time' => 'update_time DESC', 'local' => 'local', 'highp' => 'bought_count DESC', 'lowp' => 'price ASC'); $type = input_string($this->input->get('type'), array('item', 'inn'), 'item'); if ($order_by[$sort] == 'local') { $search['lat'] = checkLocationPoint($this->input->get('lat'), 'lat', 0); $search['lon'] = checkLocationPoint($this->input->get('lon'), 'lon', 0); } $search = array('category' => $category, 'category_id' => $category_id, 'city_id' => $city_id, 'local_id' => $local_id, 'dest_id' => $dest_id, 'state' => 'T', 'today' => $today, 'type' => $type, 'key_word' => $key_word); if ($type == 'item') { $data = $this->model->get_products($search, $order_by[$sort], build_limit($page, $perpage)); } else { $data = $this->model->get_inns($search, $order_by[$sort], build_limit($page, $perpage)); } response_json('1', $data); }
/** * 部落首页数据 **/ public function groupForum() { $group_id = input_int($this->input->get('group'), 1000, FALSE, FALSE, '6001'); $type = input_string($this->input->get('type'), array('hot', 'near', 'live', 'manage'), 'hot'); $page = input_int($this->input->get('page'), 1, FALSE, 1); $perpage = input_int($this->input->get('perpage'), 10, 50, 10); $list = array(); $top_forumn = array(); $limit = build_limit($page, $perpage); $last_id = 0; $search = array('type' => $type, 'group_id' => $group_id, 'last_id' => $last_id); switch ($type) { case 'hot': if ($page == '1') { $top_forumn = $this->model->get_top_forum($group_id); } $order_by = 'look DESC'; break; case 'near': $lat = checkLocationPoint($this->input->get('lat'), 'lat', 0); if (!$lat) { $lat = $this->get_current_data('lat'); } if (!$lat) { response_json('1', $list); } $lon = checkLocationPoint($this->input->get('lon'), 'lon', 0); if (!$lon) { $lat = $this->get_current_data('lon'); } if (!$lon) { response_json('1', $list); } $search['lat'] = $lat; $search['lon'] = $lon; $order_by = 'local'; break; case 'live': $order_by = 'create_time DESC'; $search['last_id'] = input_int($this->input->get('lastid'), 1000, FALSE, 0); $limit = 'LIMIT 0,' . $perpage; break; case 'manage': $order_by = 'create_time DESC'; $search['last_id'] = input_int($this->input->get('lastid'), 1000, FALSE, 0); if (!$search['last_id']) { $top_forumn = $this->model->get_top_forum($group_id); } $limit = 'LIMIT 0,' . $perpage; break; } if ($top_forumn) { $forum_detail = $this->model->get_forum_detail($top_forumn); //获取列表所需数据 用户信息等 foreach ($top_forumn as $key => $row) { $row['create_time'] = showTime($row['create_time']); $list[] = array_merge($row, $forum_detail[$row['forum_id']]); } } $forum_index = $this->model->get_forum_list($search, $order_by, $limit); if ($forum_index) { $forum_detail = $this->model->get_forum_detail($forum_index); //获取列表所需数据 用户信息等 foreach ($forum_index as $key => $row) { $row['create_time'] = showTime($row['create_time']); $list[] = array_merge($row, $forum_detail[$row['forum_id']]); } } response_json('1', $list); }
private function check_forum_post($type) { $forum = array(); $forum['city'] = check_empty(trimall(strip_tags($this->input->post('city'))), ''); $forum['lat'] = checkLocationPoint($this->input->post('lat'), 'lat', ''); //坐标可不传 $forum['lon'] = checkLocationPoint($this->input->post('lon'), 'lon', ''); if (empty($forum['lat']) || empty($forum['lon'])) { $forum = array(); } $forum['forum_name'] = check_empty(trimall(strip_tags($this->input->post('title'))), '', '6014'); $forum['type'] = $type; $tags = check_empty(trimall(strip_tags($this->input->post('tags'))), ''); if ($tags) { $detail['tags'] = array(); $tags = explode(',', $tags); foreach ($tags as $key => $row) { if (!$row) { continue; } if (mb_strlen($row) > 6) { response_json('6033', '标签:"' . $row . '" 字数过长'); } $detail['tags'][] = $row; } if (count($detail['tags']) > 3) { response_code('6032'); } $detail['tags'] = implode(',', $detail['tags']); } else { $detail['tags'] = ''; } $detail['note'] = check_empty(strip_tags($this->input->post('note')), ''); $detail['pictures'] = trimall(strip_tags($this->input->post('images', TRUE))); if ($type == 'jianren') { $detail['line'] = check_empty(trimall(strip_tags($this->input->post('line', TRUE))), FALSE, '6016'); if (empty($forum['forum_name'])) { $forum['forum_name'] = $detail['line']; } $start_time = check_empty($this->input->post('start_time'), FALSE, '6017'); if (substr_count($start_time, '-') != 2) { response_code('6024'); } list($year, $month, $day) = explode('-', $start_time); if (!$year || !$month || !$day || !checkdate($month, $day, $year)) { response_code('6024'); } $start_time = strtotime($start_time); if (!$start_time || $start_time < TIME_NOW - 86500 || $start_time > TIME_NOW + 31536000) { response_code('6024'); } $detail['start_time'] = $start_time; $detail['day'] = input_int($this->input->post('day'), 0, 250, FAlSE, '6015'); } else { $detail['pictures'] = check_empty($detail['pictures'], FALSE, '6013'); } if (empty($forum['forum_name'])) { response_code('6014'); } return array('forum' => $forum, 'detail' => $detail); }