Exemplo n.º 1
0
 static function getVerifyUrl($UserId, $UserName, $userType, $sid = 'anjukemy')
 {
     $time = time();
     $keytime = $time + 3600;
     $systemtime = $time;
     $memberKey = APF::get_instance()->get_config('member_key', 'login');
     $key = Bll_Security_Member::get_md5_key($UserId, $UserName, $memberKey['wechat'], $time, $keytime);
     if ($userType == 2) {
         $location = AnjukeController::getWechatURL('/mbroker/data/overview');
     } else {
         $location = AnjukeController::getWechatURL('/mbroker/data/overview');
         //            $location = AnjukeController::getWechatURL('/mbroker/data/weiliaodata');
     }
     $params = APF::get_instance()->get_request()->get_parameters();
     $history = AnjukeController::getWechatURL('/mbroker/data/login', $params);
     $arr = array('keytime' => $keytime, 'key' => $key, 'sid' => $sid, 'location' => base64_encode($location), 'time' => $time, 'uid' => $UserId, 'name' => $UserName, 'utype' => $userType, 'remember' => '0', 'loginpost' => '1', 'systemtime' => $systemtime, 'frombroker' => '1', 'act' => 'login', 'history' => base64_encode($history), 'no_redirect' => '0');
     return AnjukeController::getWechatURL('/verify', $arr);
 }
Exemplo n.º 2
0
 public function handle_request_internal()
 {
     $apf = APF::get_instance();
     $response = $apf->get_response();
     $request = APF::get_instance()->get_request();
     $params = $request->get_parameters();
     //加密公钥
     $member_key = $apf->get_config("member_key");
     //加密字符串
     $key = $params['key'];
     //用户ID
     $uid = $params['uid'];
     //用户NAME
     $username = $params['name'];
     //用户类型
     $usertype = $params['utype'];
     //$response->set_cookie("uid",$uid);
     $response->set_cookie("usertype", $usertype);
     //成功跳转页面
     $location = base64_decode(urldecode($params['location']));
     if (strpos($location, chr(13))) {
         $location = substr($location, 0, strpos($location, chr(13)));
     }
     if (strpos($location, '?') !== false) {
         $location .= '&_r=' . mt_rand(0, time());
     } else {
         $location .= '?_r=' . mt_rand(0, time());
     }
     //用户登录时间
     $time = $params['time'];
     //key的过期时间
     $keytime = $params['keytime'];
     //是否来自经纪人登陆
     $frombroker = $params['frombroker'];
     $errmsg = htmlspecialchars(urldecode($params['errmsg']));
     //错误代码
     $error = $params['error'];
     //来源
     $sid = @APF::get_instance()->get_request()->get_parameter("sid");
     //登陆成功
     if ($uid && Bll_Security_Member::check_key($key, $uid, $username, $member_key, $time, $keytime)) {
         $user = Model_Broker_Member::getAjkMembersByUserId($uid);
         if ($user->userType > 1) {
             $broker = Model_Broker_AjkBrokerExtend::getBrokerInfoByUserId($user->userId);
         }
         if ($user) {
             header("P3P: CP=CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR");
             $brokerid = 0;
             $cookietime = 86400 * 365;
             $ucity = APF::get_instance()->get_request()->getCityId();
             if ($user->userType == 2) {
                 // 自动创建三网支付中心账号
                 /*$bll_account = new BLL_Acenter_AccountUser();
                   $bll_account->create_three_account_must($uid);*/
                 if (intval($broker->checkState) == 2) {
                     // 被业务经理关闭的帐号
                     $errorMess = Const_Verify::CLOSE_ERROR;
                 }
                 if (intval($broker->accountType) == 10000) {
                     // 被业务经理冻结帐号
                     $errorMess = Const_Verify::FREEZE_ERROR;
                 }
                 if ($broker->isLogin == 0 && $broker->punish == 2) {
                     //黑名单经纪人不管是免费的还是续费的,立即关闭。
                     $errorMess = Const_Verify::BLACK_ERROR;
                 }
                 if ($errorMess) {
                     $backurl = strpos($location, '?') ? $location . '&errorMess=' . $errorMess : $location . '?errmsg=' . $errorMess;
                     Uri_Http::redirect_header($backurl, 302);
                     return;
                 }
                 $ucity = @$broker->cityId;
                 $brokerid = @$broker->brokerId;
                 $cookietime = 0;
                 $userTypeNew = Const_Verify::BROKER_USER;
             } else {
                 //查询是用户是否门店
                 $AgcyInfo = Model_Broker_AgcyAccount::getAgcyByUserId($user->userId);
                 if (is_array($AgcyInfo) && count($AgcyInfo)) {
                     $userTypeNew = Const_Verify::COMPANY_USER;
                 } else {
                     $userTypeNew = Const_Verify::COMMON_USER;
                 }
             }
             $userid = $user->userId;
             $username = $user->userName;
             $usertype = $user->userType;
             $fuid = $user->fuid;
             $emailpass = 1;
             if ($brokerid > 0) {
                 Model_Log_BrokerLogin::insertLoginLog(date('Ym'), $brokerid);
             }
             $anjuke_secques = APF::get_instance()->get_config("AnjukeSecques");
             $this->setLoginDataCookie($userid, $username, $usertype, $emailpass, $anjuke_secques, 0, $fuid, $ucity, $brokerid, $cookietime, $afutype = 0, $sid, $userTypeNew);
             $this->setLastLoinUserName($username, 86400 * 365);
         }
         //跳转用户原访问页面
         if (!$params['no_redirect']) {
             Uri_Http::redirect_header($location, 302);
         }
     } else {
         //登陆失败
         $backurl = strpos($location, '?') ? $location . '&errorMess=' . $errmsg . '&errorCode=' . $error : $location . '?errorMess=' . $errmsg . '&errorCode=' . $error;
         Uri_Http::redirect_header($backurl, 302);
         return;
     }
 }
Exemplo n.º 3
0
 public function handle_request_internal()
 {
     $request = APF::get_instance()->get_request();
     $params = $request->get_parameters();
     $channel = intval($params['channel']);
     if ($channel < 0 && $channel > 3) {
         $channel = 0;
     }
     $sid = $this->getSid($channel);
     if ($this->isBrokerLogin()) {
         $request->set_attribute("url", $params['url']);
         $request->set_attribute("sid", $sid);
         $request->set_attribute("loginok", "ok");
         return "Broker_Loginok";
     }
     if ($params["cityid"] && intval($params["cityid"]) > 10) {
         $defaultCityId = $params["cityid"];
     } else {
         $defaultCityId = 11;
     }
     if ($params["selectcityid"]) {
         $defaultCityId = $params["selectcityid"];
     }
     //得到可以选择主营业务的城市id列表
     $mainBusinessAvailableCity = APF::get_instance()->get_config("main_business_available", "multicity");
     if (isset($params['action'])) {
         $strAction = $params['action'];
     }
     if ($strAction == "register") {
         $preg = "/^(1|2)\\d{10}/";
         if (!preg_match($preg, $params['mobile'])) {
             $this->regError['mobile'] = Const_Register::REGISTER_MOBILE_FORMAT;
         }
         $mobile = Bll_Security_Member::dhtmlspecialchars(trim($params['mobile']));
         $checkMobileRes = Bll_Broker_Register::CheckMobile(array('mobile' => $mobile));
         if ($checkMobileRes) {
             $this->regError['mobile'] = Const_Register::REGISTER_MOBILE_CHECK;
         } else {
             $checkUserMobile = Bll_Broker_Register::checkUserMobile(array('mobile' => $mobile));
             if ($checkUserMobile) {
                 $this->regError['mobile'] = Const_Register::REGISTER_USER_MOBILE_CHECK;
             }
         }
         if (preg_match("/['\"&<>\\s]/i", $params['password'])) {
             $this->regError['password'] = Const_Register::PROFILE_PASSWORD_ILLEGAL;
         }
         if (preg_match("/['\"&<>\\s]/i", $params['truename']) || $params['truename'] == "") {
             $this->regError['truename'] = Const_Register::PROFILE_PASSWORD_ILLEGAL;
         }
         $checkPwd = Bll_Security_Member::dhtmlspecialchars(trim($params['checkpwd']));
         $password = Bll_Security_Member::dhtmlspecialchars(trim($params['password']));
         $passwordLength = strlen($password);
         if ($passwordLength < 6 || $passwordLength > 16) {
             $this->regError['password'] = Const_Register::PROFILE_PASSWORD_LENGTH;
         }
         if ($checkPwd != $password) {
             $this->regError['passwd_notmatch'] = Const_Register::PROFILE_PASSWORD_NOT_MATCH;
         }
         $selectcityid = intval($params['selectcityid']);
         $companyId = intval($params['companyid']);
         $selectareaid = intval($params['selectareaid']);
         $selectblockid = intval($params['selectblockid']);
         if ($selectcityid < 11) {
             $this->regError['city'] = Const_Register::REGISTER_CITY_CHECK;
         }
         $openRegisterCity = APF::get_instance()->get_config("open_register_city", "multicity");
         if (!empty($openRegisterCity) && empty($openRegisterCity[$selectcityid])) {
             $this->regError['city'] = Const_Register::REGISTER_CITY_CHECK_OPEN;
         }
         if ($companyId == 0) {
             $this->regError['company'] = Const_Register::REGISTER_COMPANY_CHECK;
         }
         if ($companyId < 1) {
             $companyId = 0;
         }
         if ($selectareaid <= 0 || $selectblockid <= 0) {
             $this->regError['city'] = Const_Register::REGISTER_BLOCK_CHECK;
         }
         if ($params['storeid'] == "") {
             $this->regError['store'] = Const_Register::REGISTER_STORE_CHECK;
         }
         if (empty($params['storeid'])) {
             $storeid = 0;
         } else {
             $storeid = $params['storeid'];
         }
         //验证主营业务数据是否合法
         $params['mainbusiness'] = (int) $params['mainbusiness'];
         if (!isset($params['mainbusiness'])) {
             $this->regError['main_business'] = Const_Register::MAIN_BUSSINESS_EMPTY;
         } elseif ($params['mainbusiness'] < 1 || $params['mainbusiness'] > 2) {
             $this->regError['main_business'] = Const_Register::MAIN_BUSSINESS_INVALID;
         } elseif ($params['mainbusiness'] == 2) {
             //检查该城市是否有权限选择主营业务
             $businessAccess = in_array($selectcityid, $mainBusinessAvailableCity);
             if ($businessAccess === false) {
                 $request->set_attribute("url", $params['url']);
                 $request->set_attribute("sid", $sid);
                 $request->set_attribute("error", Const_Register::MAIN_BUSSINESS_ACCESS);
                 $request->set_attribute("loginok", "ok");
                 return "Broker_Loginok";
             }
         }
         $truename = Bll_Security_Member::dhtmlspecialchars(trim($params['truename']));
         //验证cookie
         $regCookie = $request->get_cookie('anjukereg');
         $verifyCode = Util_AuthorCrypt::decrypt($regCookie, md5($_SERVER['HTTP_USER_AGENT']));
         if ($verifyCode != $params['code']) {
             $this->regError['seccodeverify'] = Const_Register::SUBMIT_SEC_CODE_INVALID;
         }
         if (count($this->regError) > 0) {
             $request->set_attribute("regerror", $this->regError);
         } else {
             $selectblockid = $selectblockid == 0 ? $selectareaid : $selectblockid;
             $getAreaInfo = Model_City_TypeCode::getAreaInfoByTypeId($selectblockid, $selectcityid);
             $areaCode = $getAreaInfo['typeCode'];
             if (!$areaCode) {
                 $request->set_attribute("url", $params['url']);
                 $request->set_attribute("sid", $sid);
                 $request->set_attribute("error", "发现不恰当行为,区域板块不存在。");
                 $request->set_attribute("loginok", "ok");
                 return "Broker_Loginok";
             }
             $clientIp = $request->get_client_ip();
             $brd = intval(trim($params['brd']));
             $ext = "";
             if ($brd) {
                 $ext = json_encode(array("brokerId" => $brd));
             }
             $ppcConfig = APF::get_instance()->get_config("ppc_city_config", "ppc");
             $postData = array("j_password" => $password, "trueName" => $truename, "cityId" => $selectcityid, "areaCode" => $areaCode, "companyId" => $companyId, "storeId" => $storeid, "userMobile" => $mobile, "channel" => $channel, "regip" => $clientIp, "ext" => $ext, 'clientPort' => intval($_SERVER['REMOTE_PORT']), "isPPC" => $ppcConfig[$selectcityid] ? "true" : "false", "mainBussiness" => $params['mainbusiness']);
             $registerRes = Bll_Broker_Register::register($postData);
             if ($registerRes && $registerRes['status'] == "ok") {
                 //记录经纪人的主营业务类型
                 $mainBusinessDate = array('broker_id' => $registerRes['broker']['brokerId'], 'member_id' => $registerRes['broker']['userId'], 'type' => $params['mainbusiness']);
                 $addMainBusiness = $this->store_main_business($mainBusinessDate);
                 //存储经纪人主营业务失败
                 if ($addMainBusiness['status'] === false) {
                     $request->set_attribute("url", $params['url']);
                     $request->set_attribute("sid", $sid);
                     $request->set_attribute("error", $addMainBusiness['mesg']);
                     $request->set_attribute("loginok", "ok");
                     return "Broker_Loginok";
                 }
                 $UserId = $registerRes['broker']['userId'];
                 $this->success($UserId);
             } else {
                 $request->set_attribute("url", $params['url']);
                 $request->set_attribute("sid", $sid);
                 $request->set_attribute("error", "服务器忙,请稍后再试。");
                 $request->set_attribute("loginok", "ok");
                 return "Broker_Loginok";
             }
         }
     }
     $cfsByPinYin = $this->getAllCityInfo();
     foreach ($cfsByPinYin as $key => $val) {
         foreach ($val as $k => $v) {
             if ($defaultCityId == $v['cityId']) {
                 $defaultCityName = $v['cityName'];
             }
         }
     }
     $request->set_attribute("defaultcityid", $defaultCityId);
     $request->set_attribute("channel", $channel);
     $request->set_attribute("defaultcityname", $defaultCityName);
     $hotCity = APF::get_instance()->get_config("hot_city", "multicity");
     $request->set_attribute("hotcity", $hotCity);
     $request->set_attribute("cfsbypinyin", $cfsByPinYin);
     //设置可以选择主营业务的城市id列表
     $request->set_attribute("mainbusinessavailablecity", json_encode($mainBusinessAvailableCity));
     //设置my domain
     $ajk_base_domain = APF::get_instance()->get_config('anjuke_base_domain');
     $ajk_domain = 'http://my.' . $ajk_base_domain;
     $request->set_attribute("ajkdomain", $ajk_domain);
     if (!empty($params["selectcityid"]) && !empty($params["selectareaid"])) {
         $daoinfo = Model_City_TypeCode::getAreaInfoByCityId(intval($params['selectcityid']));
         foreach ($daoinfo as $info) {
             if ($info["typeId"] == $params["selectareaid"]) {
                 $params["areaname"] = $info["typeName"];
                 break;
             }
         }
         if (!empty($params["selectblockid"])) {
             $daoinfo = Model_City_TypeCode::getArrayAreaInfoByParentId(intval($params['selectareaid']));
             foreach ($daoinfo as $info) {
                 if ($info["typeId"] == $params["selectblockid"]) {
                     $params["blockname"] = $info["typeName"];
                     break;
                 }
             }
         }
     }
     $request->set_attribute("params", $params);
     return "Broker_Register";
 }
Exemplo n.º 4
0
 public function is_url($url)
 {
     return Bll_Security_Member::is_url(base64_decode($url));
 }