BackupGuard
6 years ago
Dropbox
6 years ago
Request
6 years ago
SGArchive.php
6 years ago
SGArchiveToZip.php
6 years ago
SGAuthClient.php
6 years ago
SGCallback.php
6 years ago
SGCdrEntry.php
6 years ago
SGCharsetHandler.php
6 years ago
SGDBState.php
6 years ago
SGEntry.php
6 years ago
SGFileEntry.php
6 years ago
SGFileState.php
6 years ago
SGMigrateState.php
6 years ago
SGMysqldump.php
6 years ago
SGReloadHandler.php
6 years ago
SGReloader.php
6 years ago
SGReloaderState.php
6 years ago
SGReviewManager.php
6 years ago
SGState.php
6 years ago
SGUploadHandler.php
6 years ago
SGUploadState.php
6 years ago
test.txt
6 years ago
SGState.php
190 lines
| 1 | <?php |
| 2 | |
| 3 | require_once(SG_LIB_PATH.'SGFileState.php'); |
| 4 | require_once(SG_LIB_PATH.'SGDBState.php'); |
| 5 | require_once(SG_LIB_PATH.'SGUploadState.php'); |
| 6 | require_once(SG_LIB_PATH.'SGMigrateState.php'); |
| 7 | |
| 8 | class SGState |
| 9 | { |
| 10 | public $inprogress = false; |
| 11 | public $type = ''; |
| 12 | public $token = ''; |
| 13 | public $action = ''; |
| 14 | public $actionId = null; |
| 15 | public $actionStartTs = 0; |
| 16 | public $backupFileName = ''; |
| 17 | public $backupFilePath = ''; |
| 18 | public $progress = 0; |
| 19 | public $warningsFound = false; |
| 20 | public $pendingStorageUploads = array(); |
| 21 | public $restoreMode = ''; |
| 22 | public $restoreFiles = array(); |
| 23 | public $offset = 0; |
| 24 | |
| 25 | function __construct() |
| 26 | { |
| 27 | } |
| 28 | |
| 29 | public function setInprogress($inprogress) |
| 30 | { |
| 31 | $this->inprogress = $inprogress; |
| 32 | } |
| 33 | |
| 34 | public function setToken($token) |
| 35 | { |
| 36 | $this->token = $token; |
| 37 | } |
| 38 | |
| 39 | public function setAction($action) |
| 40 | { |
| 41 | $this->action = $action; |
| 42 | } |
| 43 | |
| 44 | public function setType($type) |
| 45 | { |
| 46 | $this->type = $type; |
| 47 | } |
| 48 | |
| 49 | public function setActionId($actionId) |
| 50 | { |
| 51 | $this->actionId = $actionId; |
| 52 | } |
| 53 | |
| 54 | public function setActionStartTs($actionStartTs) |
| 55 | { |
| 56 | $this->actionStartTs = $actionStartTs; |
| 57 | } |
| 58 | |
| 59 | public function setBackupFileName($name) |
| 60 | { |
| 61 | $this->backupFileName = $name; |
| 62 | } |
| 63 | |
| 64 | public function setBackupFilePath($backupFilePath) |
| 65 | { |
| 66 | $this->backupFilePath = $backupFilePath; |
| 67 | } |
| 68 | |
| 69 | public function setProgress($progress) |
| 70 | { |
| 71 | $this->progress = $progress; |
| 72 | } |
| 73 | |
| 74 | public function setWarningsFound($warningsFound) |
| 75 | { |
| 76 | $this->warningsFound = $warningsFound; |
| 77 | } |
| 78 | |
| 79 | public function setRestoreFiles($restoreFiles) |
| 80 | { |
| 81 | $this->restoreFiles = $restoreFiles; |
| 82 | } |
| 83 | |
| 84 | public function setPendingStorageUploads($pendingStorageUploads) |
| 85 | { |
| 86 | $this->pendingStorageUploads = $pendingStorageUploads; |
| 87 | } |
| 88 | |
| 89 | public function setRestoreMode($mode){ |
| 90 | $this->restoreMode = $mode; |
| 91 | } |
| 92 | |
| 93 | public function getRestoreMode(){ |
| 94 | return $this->restoreMode; |
| 95 | } |
| 96 | |
| 97 | public function getInprogress() |
| 98 | { |
| 99 | return $this->inprogress; |
| 100 | } |
| 101 | |
| 102 | public function getToken() |
| 103 | { |
| 104 | return $this->token; |
| 105 | } |
| 106 | |
| 107 | public function getAction() |
| 108 | { |
| 109 | return $this->action; |
| 110 | } |
| 111 | |
| 112 | public function getType() |
| 113 | { |
| 114 | return $this->type; |
| 115 | } |
| 116 | |
| 117 | public function getActionId() |
| 118 | { |
| 119 | return $this->actionId; |
| 120 | } |
| 121 | |
| 122 | public function getActionStartTs() |
| 123 | { |
| 124 | return $this->actionStartTs; |
| 125 | } |
| 126 | |
| 127 | public function getBackupFileName() |
| 128 | { |
| 129 | return $this->backupFileName; |
| 130 | } |
| 131 | |
| 132 | public function getBackupFilePath() |
| 133 | { |
| 134 | return $this->backupFilePath; |
| 135 | } |
| 136 | |
| 137 | public function getProgress() |
| 138 | { |
| 139 | return $this->progress; |
| 140 | } |
| 141 | |
| 142 | public function getWarningsFound() |
| 143 | { |
| 144 | return $this->warningsFound; |
| 145 | } |
| 146 | |
| 147 | public function getRestoreFiles() |
| 148 | { |
| 149 | return $this->restoreFiles; |
| 150 | } |
| 151 | |
| 152 | public function getPendingStorageUploads() |
| 153 | { |
| 154 | return $this->pendingStorageUploads; |
| 155 | } |
| 156 | |
| 157 | public function setOffset($offset) |
| 158 | { |
| 159 | $this->offset = $offset; |
| 160 | } |
| 161 | |
| 162 | public function getOffset() |
| 163 | { |
| 164 | return $this->offset; |
| 165 | } |
| 166 | |
| 167 | public function factory($stateJson) |
| 168 | { |
| 169 | $stateJson = json_decode($stateJson, true); |
| 170 | |
| 171 | $type = $stateJson['type']; |
| 172 | |
| 173 | if ($type == SG_STATE_TYPE_FILE) { |
| 174 | $sgState = new SGFileState(); |
| 175 | } |
| 176 | else if ($type == SG_STATE_TYPE_UPLOAD) { |
| 177 | $sgState = new SGUploadState(); |
| 178 | } |
| 179 | else if ($type == SG_STATE_TYPE_MIGRATE) { |
| 180 | $sgState = new SGMigrateState(); |
| 181 | } |
| 182 | else { |
| 183 | $sgState = new SGDBState(); |
| 184 | } |
| 185 | |
| 186 | $sgState = $sgState->init($stateJson); |
| 187 | return $sgState; |
| 188 | } |
| 189 | } |
| 190 |