Beispiel #1
0
 public function handle_request_internal()
 {
     $token = $this->_params['token'];
     $result = Bll_TokenBiz::get_instance()->delete_by_token($token);
     $ret = array('status' => 'ok', 'data' => '');
     if (!$result) {
         $ret = Util_MobileAPI::error(Const_APIStatus::E_LOGOUT_FAILED);
     }
     return $ret;
 }
Beispiel #2
0
 public function handle_request_internal()
 {
     $token = $this->_params['token'];
     $obj = Bll_TokenBiz::get_instance();
     $token_info = $obj->get_by_token($token);
     if (empty($token_info)) {
         $ret = Util_MobileAPI::error(Const_APIStatus::E_TOKEN_INVALID);
     } else {
         if ($_SERVER['REQUEST_TIME'] + 86400 * 5 > $token_info['expired']) {
             //比数据库实际过期时间早五天
             $obj->delete_by_token($token);
             $ret = Util_MobileAPI::error(Const_APIStatus::E_TOKEN_EXPIRED);
         } else {
             $ret = array('status' => 'ok', 'data' => '');
         }
     }
     return $ret;
 }
Beispiel #3
0
 public function handle_request_internal()
 {
     $params["j_username"] = trim($this->_params["username"]);
     $params["j_password"] = trim($this->_params["password"]);
     $params["channel"] = 3;
     $api_url = '/service-internal/rest/brokers/login';
     $broker = Util_CallAPI::get_data_from_java_api($api_url, $params);
     if ($broker['data']['status'] != 'ok') {
         if ($broker['data']['code'] == 398213) {
             return Util_MobileAPI::error(Const_APIStatus::E_BROKER_USERPWD_ERR);
         } else {
             return Util_MobileAPI::error(Const_APIStatus::E_CALL_API_ERROR);
         }
     }
     $broker_id = $broker['data']['broker']['brokerId'];
     //获取经纪人信息
     $api_url = "/service-internal/rest/brokers/{$broker_id}";
     $broker_info = Util_CallAPI::get_data_from_java_api($api_url);
     if (empty($broker_info)) {
         $broker_info = array();
     }
     if ($broker_info['data']['status'] == 'error') {
         return Util_MobileAPI::error(Const_APIStatus::E_CALL_API_ERROR);
     }
     $broker_info = $broker_info['data'];
     $cityId = isset($broker_info['broker']['cityId']) ? $broker_info['broker']['cityId'] : "";
     if ($cityId > 229) {
         return array('status' => 'error', 'errcode' => "", 'message' => "您所在的城市暂不支持APP服务");
     }
     $broker_return = array('id' => isset($broker_info['broker']['brokerId']) ? $broker_info['broker']['brokerId'] : "", 'city_id' => isset($broker_info['broker']['cityId']) ? $broker_info['broker']['cityId'] : "", 'email' => isset($broker_info['broker']['userEmail']) ? $broker_info['broker']['userEmail'] : "", 'last_log_date' => isset($broker_info['broker']['lastLogDate']) ? $broker_info['broker']['lastLogDate'] : "", 'name' => isset($broker_info['broker']['trueName']) ? $broker_info['broker']['trueName'] : "", 'username' => isset($broker_info['broker']['userName']) ? $broker_info['broker']['userName'] : "", 'phone' => isset($broker_info['broker']['userMobile']) ? $broker_info['broker']['userMobile'] : "", 'use_photo' => isset($broker_info['broker']['userPhoto']) ? $broker_info['broker']['userPhoto'] : "", 'user_type' => isset($broker_info['broker']['userType']) ? $broker_info['broker']['userType'] : "", 'user_id' => isset($broker_info['broker']['userId']) ? $broker_info['broker']['userId'] : "");
     $sid = APF::get_instance()->get_config("sid", "login");
     //单点登录
     $registerBll = new Bll_Register();
     $registerBll->singleSignon($broker_return['user_id'], $broker_return['username'], $sid, $broker_return['user_type']);
     // 生成token
     $token = self::createToken(array($broker_return["id"], $broker_return['username'], time()));
     $broker_return['use_photo'] = Util_ImageUtils::get_broker_photo_url($broker_return['use_photo']);
     $insert_data["token"] = $token;
     $insert_data["user_id"] = $broker_return["id"];
     $insert_data["expired"] = Bll_TokenBiz::get_instance()->get_expire_time();
     $insert_data["app"] = APF::get_instance()->get_config('java_api_from');
     Bll_TokenBiz::get_instance()->insert($insert_data);
     $device_data = array();
     $device_data["user_id"] = $broker_return["id"];
     $device_data["app"] = APF::get_instance()->get_config('java_api_from');
     $device_data["device"] = "";
     $device_data["ismi"] = trim(@$this->_params["imsi"]);
     $device_data["ip"] = APF::get_instance()->get_request()->get_client_ip();
     $device_data["i"] = "";
     $device_data["m"] = "";
     $device_data["o"] = "";
     $device_data["v"] = "";
     $device_data["cv"] = "";
     $device_data["cid"] = "";
     $device_data["pm"] = "";
     $device_data["created"] = date("Y-m-d H:i:s");
     Bll_DeviceBiz::get_instance()->save($device_data);
     $dwStatsBiz = new Bll_DwStatsBiz();
     if (!empty($this->_params["macid"])) {
         $guid = md5(trim($this->_params["macid"]));
         $dwStatsBiz->saveGuid($guid);
     }
     if (!empty($this->_params["uuid"])) {
         $guid = md5(trim($this->_params["uuid"]));
         $dwStatsBiz->saveGuid($guid);
     }
     if (!empty($this->_params["i"])) {
         $guid = md5(trim($this->_params["i"]));
         $dwStatsBiz->saveGuid($guid);
     }
     if (!empty($this->_params["uuid2"])) {
         //ios7兼容
         $guid = md5(trim($this->_params["uuid2"]));
         $dwStatsBiz->saveGuid($guid);
     }
     if (!empty($this->_params["udid2"])) {
         //ios7兼容
         $guid = md5(trim($this->_params["udid2"]));
         $dwStatsBiz->saveGuid($guid);
     }
     $return = array();
     $return["status"] = "ok";
     $return['data']["token"] = $token;
     $return['data']['broker'] = $broker_return;
     //缓存信息到redis
     $redisInfo = array('brokerId' => $broker_info['broker']['brokerId'], 'username' => $broker_info['broker']['trueName'], 'userPhoto' => $broker_return['use_photo'], 'cityId' => $broker_info['broker']['cityId']);
     Bll_Commsign::redisBrokerInfo($broker_info['broker']['brokerId'], $redisInfo);
     return $return;
 }
Beispiel #4
0
 /**
  * 生成token
  *
  * @param $brokerId
  * @param $username
  * @return string
  */
 public function createBrokerToken($brokerId, $username)
 {
     $appName = APF::get_instance()->get_config('java_api_from');
     $string = implode('\\t', array($brokerId, $username, time()));
     $token = md5($appName . $string . microtime() . mt_rand());
     //写一条token的记录
     $objMoblieBrokerToken = new Model_Mobile_BrokerToken();
     $objMoblieBrokerToken->userId = $brokerId;
     $objMoblieBrokerToken->app = $appName;
     $objMoblieBrokerToken->token = $token;
     $objMoblieBrokerToken->expired = Bll_TokenBiz::get_instance()->get_expire_time();
     $objMoblieBrokerToken->save();
     return $token;
 }