Пример #1
0
 private function _set_block($status)
 {
     $data = $this->get_data();
     $mobile = isset($data['mobile']) ? $data['mobile'] : '';
     if (!$mobile) {
         $this->send_response(400, NULL, Kohana::lang('graph.mobile_not_allow'));
     }
     $id = $this->user_id;
     if (empty($id)) {
         $id = isset($data['guid']) ? $data['guid'] : '';
         $id_type = 'guid';
         if (empty($id)) {
             $this->send_response(400, NULL, Kohana::lang('graph.guid_empty'));
         }
     } else {
         $id_type = 'uid';
     }
     if ($res = international::check_mobile($mobile)) {
         $result = $this->model->set_block($id, implode('', $res), $status, $id_type);
         if ($result === -1) {
             $this->send_response(400, NULL, Kohana::lang('graph.mobile_not_exist'));
         } else {
             $this->send_response(200, array('result' => (bool) $result));
         }
     } else {
         $this->send_response(400, NULL, Kohana::lang('graph.mobile_not_allow'));
     }
 }
Пример #2
0
 /**
  * 查询手机号码归属地
  * @param int  $tel 手机号码
  * @param int  $type 是否值类型 0 不返回运营商、1 返回运营商、2 只返回城市
  * @return string 归属地名
  */
 public function get_tel_location($tel, $type = 1)
 {
     $data = international::check_mobile($tel, 86, FALSE);
     $country_code = !empty($data['country_code']) ? $data['country_code'] : 86;
     $cell = isset($data['mobile']) ? $data['mobile'] : '';
     //中国归属地
     if ($country_code == 86) {
         $location = self::_get_location($cell, $type);
     } else {
         $location = self::_get_country($country_code, $cell);
     }
     return $location;
 }
Пример #3
0
 public function search()
 {
     $friends = $this->friend_model->get_user_link_cache($this->user_id);
     $data = $this->get_data();
     $mobiles = isset($data['mobiles']) ? $data['mobiles'] : array();
     $result = array();
     foreach ($mobiles as $mobile) {
         $res = international::check_mobile($mobile);
         if (!$res) {
             continue;
         }
         $user = $this->model->get_user_by_mobile($res['country_code'], $res['mobile']);
         if ($user) {
             $uuid = $this->user_id;
             $pos = array_search($user['id'], $friends);
             //已经是好友或者是登录者自己
             if ($pos !== False || $user['id'] == $this->user_id) {
                 continue;
             }
             $result[] = array('id' => $user['id'], 'name' => $user['username'], 'avatar' => sns::getavatar($user['id']));
         }
     }
     $this->send_response(200, $result);
 }