Vendor
1 year ago
.htaccess
1 year ago
Export.php
1 year ago
index.html
1 year ago
web.config
1 year ago
Export.php
42 lines
| 1 | <?php |
| 2 | |
| 3 | namespace JetBackup\Export; |
| 4 | |
| 5 | use JetBackup\Cron\Task\Task; |
| 6 | use JetBackup\Exception\IOException; |
| 7 | use JetBackup\Export\Vendor\CPanel; |
| 8 | use JetBackup\Export\Vendor\DirectAdmin; |
| 9 | use JetBackup\Export\Vendor\Vendor; |
| 10 | use JetBackup\Wordpress\Helper; |
| 11 | use JetBackup\Wordpress\Wordpress; |
| 12 | |
| 13 | if (!defined( '__JETBACKUP__')) die('Direct access is not allowed'); |
| 14 | |
| 15 | class Export { |
| 16 | |
| 17 | private Task $_task; |
| 18 | |
| 19 | public function __construct(Task $task) { |
| 20 | $this->_task = $task; |
| 21 | } |
| 22 | |
| 23 | public function build(int $type, string $homedir, array $database_tables, string $destination):string { |
| 24 | |
| 25 | if(!is_dir($destination)) throw new IOException("The provided destination not exists"); |
| 26 | |
| 27 | switch($type) { |
| 28 | default: throw new IOException("Invalid type provided"); |
| 29 | case Vendor::TYPE_CPANEL: $obj = new CPanel($this->_task); break; |
| 30 | case Vendor::TYPE_DIRECT_ADMIN: $obj = new DirectAdmin($this->_task); break; |
| 31 | } |
| 32 | |
| 33 | $obj->setPassword(DB_PASSWORD); |
| 34 | $obj->setDomain(Wordpress::getSiteDomain()); |
| 35 | $obj->setEmailAddress(Helper::getUserEmail()); |
| 36 | $obj->setDestination($destination); |
| 37 | $obj->setHomedir($homedir); |
| 38 | $obj->setDatabaseTables($database_tables); |
| 39 | |
| 40 | return $obj->build(); |
| 41 | } |
| 42 | } |