public function sendSms($phone = '', $type = 3)
 {
     self::smsApiUrl();
     $bool = checkPhoneRule($phone);
     // 接口 $reg = '/^(1[34578])[0-9]{9}$/';
     if ($bool) {
         $data['ticket'] = self::getToken();
         $data['registMobile'] = $phone;
         $data['type'] = $type;
         $result = self::curlHttpWeb('sendsms', $data);
         if ($result['returnCode'] == 0) {
             session('verify_phone.code', $result['returnData']['registCode']);
             session('verify_phone.expiretime', NOW_TIME + 33 * 60);
             session('verify_phone.mobile', $phone);
             return array('status' => TRUE, 'msg' => '', 'code' => 0, 'data' => $result['returnData']);
         } else {
             return array('status' => FALSE, 'msg' => $result['returnDesc'], 'code' => $result['returnCode']);
         }
     } else {
         return array('status' => FALSE, 'msg' => '输入合法的手机号');
     }
 }
 public function update_base()
 {
     $data = $this->CommonController->getRequestData();
     $data = $this->CommonController->arr2ToArr($data['user']);
     foreach ($data as $k => $v) {
         if ($k == 'id_number') {
             continue;
         }
         $v = trim($v);
         if (empty($v)) {
             $error[$k] = C('L_REQUIRED_INPUT');
         }
     }
     if ($data['contact_email']) {
         if (!checkMailRuleStudent($data['contact_email'])) {
             $error['contact_email'] = '邮箱格式不对';
         }
     }
     if ($data['id_number']) {
         //简单验证身份证正则表达式(18位)
         $isIDCard = "/^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}(\\d{1}|X{1})\$/i";
         $id_number_bool = preg_match($isIDCard, $data['id_number']);
         if (!$id_number_bool) {
             $error['id_number'] = '输入合法身份证号';
         }
         if (strlen($data['id_number']) != 18) {
             $error['id_number'] = '输入合法身份证号';
         }
     }
     if ($data['living_city']) {
         $data['living_city'] = cityNameToid($data['living_city']);
     }
     if ($data['mobile_type'] == 1) {
         if (!checkPhoneRule($data['contact_mobile'])) {
             $error['mobile'] = C('L_PHONE_RULE');
         }
     }
     if ($data['birth_date']) {
         if (strtotime($data['birth_date']) > strtotime(date('Y-m-d', NOW_TIME))) {
             $error['birth_date'] = C('L_BIRTH_RULE');
         }
     }
     if ($data['name']) {
         if (!strLength($data['name'], 12)) {
             $error['name'] = C('L_LIMIT_NAME');
         }
     }
     if ($data['graduate_school']) {
         if (!strLength($data['graduate_school'], 20)) {
             $error['graduate_school'] = C('L_LIMIT_SCHOOL');
         }
     }
     if ($data['detail_major']) {
         if (!strLength($data['detail_major'], 17)) {
             $error['detail_major'] = C('L_LIMIT_MAJOR');
         }
     }
     if (!empty($error)) {
         $error['status'] = FALSE;
         $error['code'] = 1;
         exit(json_encode($error));
     }
     $bool = $this->StudentModel->studentUpdata($data);
     if ($bool) {
         D('Account')->makeSession(session('account.account_id'));
         //编辑成功后写入SESSION
         exit(json_encode(array('code' => 2, 'status' => TRUE, 'msg' => C('L_UPDATE_SUCCESS'), 'data' => self::baseInfoTpl('', TRUE))));
     } else {
         exit(json_encode(array('code' => 3, 'status' => FALSE, 'msg' => C('L_UPDATE_FAIL'))));
     }
 }
Exemple #3
0
function checkPhoneRuleSpecial($phone)
{
    $bool = checkPhoneRule($phone);
    $tel2 = '/^(010|02\\d{1}|0[3-9]\\d{2})-*\\d{7,9}(-\\d+)?$/';
    //带区号座机
    $bool2 = preg_match($tel2, $phone);
    $tel3 = '/^\\d{7,9}$/';
    //不带区号座机
    $bool3 = preg_match($tel3, $phone);
    if ($bool || $bool2 || $bool3) {
        return true;
    } else {
        return false;
    }
}
 protected function chkphone($phone)
 {
     $bool = checkPhoneRule($phone);
     $rst = array('msg' => "", 'status' => TRUE);
     if (!$bool) {
         $rst = array('msg' => "请输入正确的大陆手机号码", 'status' => FALSE, 'code' => 101);
     }
     $bool = D('Student')->checkMobileOnly($phone);
     if ($bool) {
         $rst = array('msg' => "手机号已使用", 'status' => FALSE, 'code' => 102);
     }
     return $rst;
 }