include_once "../../includes/login_check.php"; //var $id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : ''; $act = isset($_REQUEST['act']) ? $_REQUEST['act'] : ''; $customer_id = (int) $_SESSION['customer_id']; $info_type = 'lbs'; $data = array(); //delete if ($act == 'del' && $id) { Model_Table::get('InfoLbs')->delete("id='{$id}' and customer_id='{$customer_id}'"); Model_Table::get('KeywordList')->delete("info_id='{$id}' and customer_id='{$customer_id}' and info_type='{$info_type}'"); header("location:/home/info/index.php?type=<{$info_type}>"); } //method:add||modify if ($id) { $music_table = new Model_InfoLbs(); $data = $music_table->fetchRow("select * from info_lbs where id='{$id}' and customer_id='{$customer_id}'"); $smarty->assign('infoRow', $data); } //submit if (method_is('post')) { $data['customer_id'] = $customer_id; $data['create_date'] = date('Y-m-d H:i:s', $_WGT['TIME']); $data['location_name'] = isset($_POST['location_name']) ? str_inmysql($_POST['location_name']) : ''; $data['location_intro'] = isset($_POST['location_intro']) ? str_inmysql($_POST['location_intro']) : ''; $data['location_desc'] = isset($_POST['location_desc']) ? str_inmysql($_POST['location_desc']) : ''; $data['location_pic'] = isset($_POST['location_pic']) ? str_inmysql($_POST['location_pic']) : ''; $data['state'] = isset($_POST['state']) ? str_inmysql($_POST['state']) : ''; $data['x_dian'] = isset($_POST['x_dian']) ? str_inmysql($_POST['x_dian']) : ''; $data['y_dian'] = isset($_POST['y_dian']) ? str_inmysql($_POST['y_dian']) : ''; if (!$data['location_name']) {
public function getLocation() { $i = 0; $push_num = 1; $infolbsModel = new Model_InfoLbs(); $filter['where'] = " customer_id='{$this->customer_id}' and state='1' and x_dian!='' "; $sql = $infolbsModel->select($filter); $inforesult = $infolbsModel->fetchAll($sql); $infocount = count($inforesult); for ($i = 0; $i < $infocount; $i++) { $inforesult[$i]['location_desc'] = strip_tags($inforesult[$i]['location_desc']); $short_intro = cut_str(strip_tags($inforesult[$i]['location_intro']), 120, $start = 0, $code = 'UTF-8'); $inforesult[$i]['location_desc'] = $inforesult[$i]['location_desc'] != '' ? $inforesult[$i]['location_desc'] : $short_intro; $inforesult[$i]['faraway'] = $this->get_distance($this->location_x, $this->location_y, $inforesult[$i]['x_dian'], $inforesult[$i]['y_dian']); } $newlocallist = multi_array_sort($inforesult, 'faraway', $sort = SORT_ASC); $customerconfigModel = new Model_CustomerConfig(); $filter['where'] = " customer_id='{$this->customer_id}' and c_type='lbs_push' "; $sql = $customerconfigModel->select($filter); $inforesult = $customerconfigModel->fetchRow($sql); if ($inforesult['c_value']) { $push_num = $inforesult['c_value']; } else { if ($i >= 2) { $push_num = 2; } } $push_num = $push_num <= $i ? $push_num : $i; for ($j = 0; $j < $push_num; $j++) { if ($j >= 10) { $push_num = 10; break; } $sql = "update info_lbs set push_num=push_num+1 where id='" . $newlocallist[$j]['id'] . "' limit 1"; $customerconfigModel->query($sql); $infolbsrecordModel = new Model_InfoLbsRecord(); $row['lbs_id'] = $newlocallist[$j]['id']; $row['customer_id'] = $this->customer_id; $row['fromuser'] = $this->fromuser; $row['fromwhere'] = $this->fromwhere; $row['ip'] = $_WGT['IP']; $row['create_date'] = date("Y-m-d H:i:s"); $infolbsrecordModel->insert($row); $url = 'http://' . $_SERVER['HTTP_HOST'] . "/mobile/info.php?t=location&id=" . $newlocallist[$j]['id']; $itemlist .= "<item>\n\t\t <Title><![CDATA[[" . $newlocallist[$j]['faraway'] . "公里]" . $newlocallist[$j]['location_name'] . "]]></Title>\n\t\t <Description><![CDATA[" . $newlocallist[$j]['location_desc'] . "]]></Description>\n\t\t <PicUrl><![CDATA[http://" . $_SERVER['HTTP_HOST'] . "/data/image_c/" . $newlocallist[$j]['location_pic'] . "]]></PicUrl>\n\t\t <Url><![CDATA[{$url}]]></Url>\n\t\t </item>"; } if ($i > 0) { $Bodystr = "\n\t\t\t <ArticleCount>{$push_num}</ArticleCount>\n\t\t\t <Articles>\n\t\t\t {$itemlist}\n\t\t\t </Articles>"; $data['msgtype'] = 'news'; $data['bodystr'] = $Bodystr; return $data; } }