public function userRegisterV1() { // 写log $txt = json_encode($_POST); $this->writeLog('userRegisterV1:' . $txt); // 参数判断 if (!empty($_POST['userName']) && !empty($_POST['password'])) { $userName = $_POST['userName']; $password = $_POST['password']; // 判断是否含有特殊字符 if (preg_match("/[\\'.,。,/:;*?~`!@#\$%^&+==)(<>{}]|\\]|\\[|\\/|\\\\|\"|\\|/", $userName)) { $this->errReturn(USERNAME_SPECIAL_CHARACTER, '用户名含有特殊字符'); } if (preg_match("/[\\'.,。,/:;*?~`!@#\$%^&+==)(<>{}]|\\]|\\[|\\/|\\\\|\"|\\|/", $password)) { $this->errReturn(PASSWORD_SPECIAL_CHARACTER, '密码含有特殊字符'); } // 判断长度 if (strlen($userName) < USERNAME_LENGTH) { $this->errReturn(USERNAME_LENGTH_NOT_ENOUGH, '用户名位数必须大于或等于' . USERNAME_LENGTH); } if (strlen($password) < PASSWORD_LENGTH) { $this->errReturn(PASSWORD_LENGTH_NOT_ENOUGH, '密码位数必须大于或等于' . PASSWORD_LENGTH); } // 查询用户名是否存在 if (!$this->userOpr->isExistByUserName($userName)) { // 生成盐 $salt = ToolUtil::randomkeys(6); // 封装数据 $data = array('account' => $userName, 'password' => md5($password . $salt), 'salt' => $salt, 'nickname' => "SwiftGG粉丝:" . $userName, 'the_third_type' => 'no', 'the_third_keyseri' => 'no', 'image_url' => '', 'score' => rand(0, 100), 'created_time' => time(), 'updated_time' => time()); $userId = $this->userOpr->addUser($data); // 返回参数 $responseData = array('userId' => $userId); return $this->sucReturn($responseData); } else { $this->errReturn(USERNAME_IS_EXIST, '账号已被注册,请重新输入'); } } else { $this->errReturn(ERR_PARAMETER, '请求参数有误'); } }