123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- class BackupController
- {
-
- private $returnJson = array('type' => '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);
- }
- }
|