'backup'); /** * 检查登录状态 */ public function __construct() { // 身份验证 $server = new GuestModule; if (!$server->checkLogin()) { $this->returnJson['statusCode'] = '120005'; exitOutput($this->returnJson); } } /** * 备份项目 */ public function backupProject() { $user_call = securelyInput('userCall'); $user_password = securelyInput('userPassword'); $project_id = securelyInput('projectID'); $verify_code = securelyInput('verifyCode'); if (empty($user_call)) { $this->returnJson['statusCode'] = '310001'; } elseif (!preg_match('/^[0-9a-zA-Z]{32}$/', $user_password)) { $this->returnJson['statusCode'] = '310002'; } elseif (!preg_match('/^[0-9]{1,11}$/', $project_id)) { $this->returnJson['statusCode'] = '310003'; } elseif (!preg_match('/^[0-9a-zA-Z]{32}$/', $verify_code)) { $this->returnJson['statusCode'] = '310004'; } else { $project_module = new ProjectModule(); $user_type = $project_module->getUserType($project_id); if ($user_type < 0 || $user_type > 1) { $this->returnJson['statusCode'] = '120007'; } else { $module = new BackupModule(); $result = $module->backupProject($user_call, $user_password, $project_id, $verify_code); if ($result === TRUE) { $this->returnJson['statusCode'] = '000000'; } else { switch ($result) { case -1: $this->returnJson['msg'] = '用户没有写权限'; $this->returnJson['statusCode'] = '310005'; break; case -2: $this->returnJson['msg'] = '发送登录请求失败'; $this->returnJson['statusCode'] = '310006'; break; case -3: $this->returnJson['msg'] = '登录账号非法'; $this->returnJson['statusCode'] = '310007'; break; case -4: $this->returnJson['msg'] = '账号不存在或密码错误'; $this->returnJson['statusCode'] = '310008'; break; case -5: $this->returnJson['msg'] = '未知登录错误'; $this->returnJson['statusCode'] = '310009'; break; case -6: $this->returnJson['msg'] = '备份项目失败'; $this->returnJson['statusCode'] = '310010'; break; default: $this->returnJson['statusCode'] = '310000'; $this->returnJson['statusCode'] = '备份项目失败'; } } } } exitOutput($this->returnJson); } }