Exemple #1
0
    $id = (int) $_POST['m_id'];
    $where = "customer_id={$c_id}  and id={$id}";
    $BottomMenu->delete($where);
} elseif ($_POST['act'] == "select") {
    $id = (int) $_POST['m_id'];
    $row = $BottomMenu->fetchRow("select * from bottom_menu where customer_id='{$c_id}' and id='{$id}'");
    $res = json_encode($row);
    header('Content-Type: application/json');
    echo $res;
} elseif ($_POST['act'] == "update") {
    $result = $BottomMenu->query("update bottom_menu set parent_id={$data[parent_id]},menu_name='{$data[menu_name]}',menu_type='{$data[menu_type]}',menu_key='{$data['menu_key']}',menu_order='{$data['menu_order']}' where id={$_POST['m_id']} and customer_id={$data[customer_id]}");
} elseif ($_POST['act'] == "pub_menu") {
    //向微信提交菜单信息
    $db_obj = new Model_CustomerConfig();
    $sql = "select c_value from customer_config where customer_id='{$c_id}' and c_type='appid' limit 1";
    $db_obj->query($sql);
    if ($db_obj->next_record()) {
        $c_value = $db_obj->f('c_value');
        $appid_info = explode(',', $c_value);
        $appid = $appid_info['0'];
        $secret = $appid_info['1'];
        $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}";
        $get_token = post_http($url, 'GET', '');
        //$get_token  = file_get_contents($url);
        if (strstr($get_token, 'errmsg')) {
            die('无效的Appld');
        } else {
            if (strstr($get_token, 'access_token')) {
                $token_array = json_decode($get_token, true);
                $access_token = $token_array['access_token'];
            } else {
Exemple #2
0
 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;
     }
 }