Example #1
0
 public function handle_request_internal()
 {
     $params = APF::get_instance()->get_request()->get_parameters();
     if (empty($params)) {
         die;
     }
     $result = Bll_Broker_Register::checkMobile($params);
     //检测手机是否被用户注册
     if (!$result) {
         $userInfo = Bll_Broker_Register::checkUserMobile($params);
         if ($userInfo) {
             echo json_encode("userUsed");
             exit;
         }
     }
     echo json_encode(array($result));
     die;
 }
Example #2
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";
 }