diff --git a/admin_backups.php b/admin_backups.php deleted file mode 100644 index d073cfd8..00000000 --- a/admin_backups.php +++ /dev/null @@ -1,183 +0,0 @@ - - * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 - */ - -const AREA = 'admin'; -require __DIR__ . '/lib/init.php'; - -use Froxlor\Api\Commands\Backups; -use Froxlor\Api\Commands\BackupStorages; -use Froxlor\FroxlorLogger; -use Froxlor\UI\Collection; -use Froxlor\UI\HTML; -use Froxlor\UI\Listing; -use Froxlor\UI\Panel\UI; -use Froxlor\UI\Request; -use Froxlor\UI\Response; - -$id = (int)Request::any('id'); - -if (($page == 'backups' || $page == 'overview')) { - if ($action == '') { - $log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "viewed admin_backups"); - - try { - $admin_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.backups.php'; - $collection = (new Collection(Backups::class, $userinfo)) - ->withPagination($admin_list_data['backups_list']['columns'], $admin_list_data['backups_list']['default_sorting']); - } catch (Exception $e) { - Response::dynamicError($e->getMessage()); - } - - UI::view('user/table.html.twig', [ - 'listing' => Listing::format($collection, $admin_list_data, 'backups_list'), - 'actions_links' => [ - [ - 'href' => $linker->getLink(['section' => 'backups', 'page' => $page, 'action' => 'restore']), - 'label' => lng('backup.backups_restore'), - 'icon' => 'fa-solid fa-file-import', - 'class' => 'btn-outline-secondary' - ], - [ - 'href' => $linker->getLink(['section' => 'backups', 'page' => 'storages']), - 'label' => lng('backup.backup_storages'), - 'icon' => 'fa-solid fa-hard-drive', - 'class' => 'btn-outline-secondary', - 'visible' => $userinfo['change_serversettings'] == '1' - ] - ] - ]); - } elseif ($action == 'delete' && $id != 0) { - - } elseif ($action == 'add') { - - } elseif ($action == 'edit' && $id != 0) { - - } elseif ($action == 'restore') { - - } -} else if ($page == 'storages' && $userinfo['change_serversettings'] == '1') { - if ($action == '') { - $log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "list backup storages"); - - try { - $backup_storage_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.backup_storages.php'; - $collection = (new Collection(BackupStorages::class, $userinfo)) - ->withPagination($backup_storage_list_data['backup_storages_list']['columns'], $backup_storage_list_data['backup_storages_list']['default_sorting']); - } catch (Exception $e) { - Response::dynamicError($e->getMessage()); - } - - UI::view('user/table.html.twig', [ - 'listing' => Listing::format($collection, $backup_storage_list_data, 'backup_storages_list'), - 'actions_links' => [ - [ - 'href' => $linker->getLink(['section' => 'backups', 'page' => 'backups']), - 'label' => lng('backup.backups'), - 'icon' => 'fa-solid fa-reply' - ], - [ - 'href' => $linker->getLink(['section' => 'backups', 'page' => $page, 'action' => 'add']), - 'label' => lng('backup.backup_storage.add') - ] - ] - ]); - } elseif ($action == 'delete' && $id != 0) { - try { - $json_result = BackupStorages::getLocal($userinfo, [ - 'id' => $id - ])->get(); - } catch (Exception $e) { - Response::dynamicError($e->getMessage()); - } - $result = json_decode($json_result, true)['data']; - - if ($result['id'] != '') { - if (isset($_POST['send']) && $_POST['send'] == 'send') { - BackupStorages::getLocal($userinfo, [ - 'id' => $id - ])->delete(); - Response::redirectTo($filename, [ - 'page' => $page - ]); - } else { - HTML::askYesNo('backup_backup_server_reallydelete', $filename, [ - 'id' => $id, - 'page' => $page, - 'action' => $action - ], $result['id']); - } - } - } elseif ($action == 'add') { - if (isset($_POST['send']) && $_POST['send'] == 'send') { - try { - BackupStorages::getLocal($userinfo, $_POST)->add(); - } catch (Exception $e) { - Response::dynamicError($e->getMessage()); - } - Response::redirectTo($filename, [ - 'page' => $page - ]); - } else { - $admin_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/backup_storages/formfield.backup_storage_add.php'; - - UI::view('user/form.html.twig', [ - 'formaction' => $linker->getLink(['section' => 'backups']), - 'formdata' => $admin_add_data['backup_storage_add'] - ]); - } - } elseif ($action == 'edit' && $id != 0) { - try { - $json_result = BackupStorages::getLocal($userinfo, [ - 'id' => $id - ])->get(); - } catch (Exception $e) { - Response::dynamicError($e->getMessage()); - } - $result = json_decode($json_result, true)['data']; - - if ($result['id'] != '') { - if (isset($_POST['send']) && $_POST['send'] == 'send') { - try { - BackupStorages::getLocal($userinfo, $_POST)->update(); - } catch (Exception $e) { - Response::dynamicError($e->getMessage()); - } - Response::redirectTo($filename, [ - 'page' => $page - ]); - } else { - $backup_storage_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/backup_storages/formfield.backup_storage_edit.php'; - - UI::view('user/form.html.twig', [ - 'formaction' => $linker->getLink(['section' => 'backups', 'id' => $id]), - 'formdata' => $backup_storage_edit_data['backup_storage_edit'], - 'editid' => $id - ]); - } - } - } -} else { - Response::dynamicError('403'); -} diff --git a/composer.json b/composer.json index 6d590322..713cb08c 100644 --- a/composer.json +++ b/composer.json @@ -57,9 +57,7 @@ "erusev/parsedown": "^1.7", "symfony/console": "^5.4", "pear/net_dns2": "^1.5", - "amnuts/opcache-gui": "^3.4", - "aws/aws-sdk-php": "^3.280", - "phpseclib/phpseclib": "~3.0" + "amnuts/opcache-gui": "^3.4" }, "require-dev": { "phpunit/phpunit": "^9", diff --git a/composer.lock b/composer.lock index 016aa532..3418278e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c64c2e8e5669531310620aa423ad2ecd", + "content-hash": "68bd39384604fb2afbfe7596496adc72", "packages": [ { "name": "amnuts/opcache-gui", @@ -68,155 +68,6 @@ ], "time": "2023-08-25T18:02:59+00:00" }, - { - "name": "aws/aws-crt-php", - "version": "v1.2.2", - "source": { - "type": "git", - "url": "https://github.com/awslabs/aws-crt-php.git", - "reference": "2f1dc7b7eda080498be96a4a6d683a41583030e9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/awslabs/aws-crt-php/zipball/2f1dc7b7eda080498be96a4a6d683a41583030e9", - "reference": "2f1dc7b7eda080498be96a4a6d683a41583030e9", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35||^5.6.3||^9.5", - "yoast/phpunit-polyfills": "^1.0" - }, - "suggest": { - "ext-awscrt": "Make sure you install awscrt native extension to use any of the functionality." - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "AWS SDK Common Runtime Team", - "email": "aws-sdk-common-runtime@amazon.com" - } - ], - "description": "AWS Common Runtime for PHP", - "homepage": "https://github.com/awslabs/aws-crt-php", - "keywords": [ - "amazon", - "aws", - "crt", - "sdk" - ], - "support": { - "issues": "https://github.com/awslabs/aws-crt-php/issues", - "source": "https://github.com/awslabs/aws-crt-php/tree/v1.2.2" - }, - "time": "2023-07-20T16:49:55+00:00" - }, - { - "name": "aws/aws-sdk-php", - "version": "3.280.2", - "source": { - "type": "git", - "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "d68b83b3bc39b70bf33e9b8b5166facbe3e4fe9b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/d68b83b3bc39b70bf33e9b8b5166facbe3e4fe9b", - "reference": "d68b83b3bc39b70bf33e9b8b5166facbe3e4fe9b", - "shasum": "" - }, - "require": { - "aws/aws-crt-php": "^1.0.4", - "ext-json": "*", - "ext-pcre": "*", - "ext-simplexml": "*", - "guzzlehttp/guzzle": "^6.5.8 || ^7.4.5", - "guzzlehttp/promises": "^1.4.0 || ^2.0", - "guzzlehttp/psr7": "^1.9.1 || ^2.4.5", - "mtdowling/jmespath.php": "^2.6", - "php": ">=7.2.5", - "psr/http-message": "^1.0 || ^2.0" - }, - "require-dev": { - "andrewsville/php-token-reflection": "^1.4", - "aws/aws-php-sns-message-validator": "~1.0", - "behat/behat": "~3.0", - "composer/composer": "^1.10.22", - "dms/phpunit-arraysubset-asserts": "^0.4.0", - "doctrine/cache": "~1.4", - "ext-dom": "*", - "ext-openssl": "*", - "ext-pcntl": "*", - "ext-sockets": "*", - "nette/neon": "^2.3", - "paragonie/random_compat": ">= 2", - "phpunit/phpunit": "^5.6.3 || ^8.5 || ^9.5", - "psr/cache": "^1.0", - "psr/simple-cache": "^1.0", - "sebastian/comparator": "^1.2.3 || ^4.0", - "yoast/phpunit-polyfills": "^1.0" - }, - "suggest": { - "aws/aws-php-sns-message-validator": "To validate incoming SNS notifications", - "doctrine/cache": "To use the DoctrineCacheAdapter", - "ext-curl": "To send requests using cURL", - "ext-openssl": "Allows working with CloudFront private distributions and verifying received SNS messages", - "ext-sockets": "To use client-side monitoring" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "files": [ - "src/functions.php" - ], - "psr-4": { - "Aws\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Amazon Web Services", - "homepage": "http://aws.amazon.com" - } - ], - "description": "AWS SDK for PHP - Use Amazon Web Services in your PHP project", - "homepage": "http://aws.amazon.com/sdkforphp", - "keywords": [ - "amazon", - "aws", - "cloud", - "dynamodb", - "ec2", - "glacier", - "s3", - "sdk" - ], - "support": { - "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", - "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.280.2" - }, - "time": "2023-09-01T18:06:10+00:00" - }, { "name": "erusev/parsedown", "version": "1.7.4", @@ -323,331 +174,6 @@ }, "time": "2019-12-31T12:16:30+00:00" }, - { - "name": "guzzlehttp/guzzle", - "version": "7.8.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "1110f66a6530a40fe7aea0378fe608ee2b2248f9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/1110f66a6530a40fe7aea0378fe608ee2b2248f9", - "reference": "1110f66a6530a40fe7aea0378fe608ee2b2248f9", - "shasum": "" - }, - "require": { - "ext-json": "*", - "guzzlehttp/promises": "^1.5.3 || ^2.0.1", - "guzzlehttp/psr7": "^1.9.1 || ^2.5.1", - "php": "^7.2.5 || ^8.0", - "psr/http-client": "^1.0", - "symfony/deprecation-contracts": "^2.2 || ^3.0" - }, - "provide": { - "psr/http-client-implementation": "1.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.1", - "ext-curl": "*", - "php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999", - "php-http/message-factory": "^1.1", - "phpunit/phpunit": "^8.5.29 || ^9.5.23", - "psr/log": "^1.1 || ^2.0 || ^3.0" - }, - "suggest": { - "ext-curl": "Required for CURL handler support", - "ext-intl": "Required for Internationalized Domain Name (IDN) support", - "psr/log": "Required for using the Log middleware" - }, - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": true, - "forward-command": false - } - }, - "autoload": { - "files": [ - "src/functions_include.php" - ], - "psr-4": { - "GuzzleHttp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Jeremy Lindblom", - "email": "jeremeamia@gmail.com", - "homepage": "https://github.com/jeremeamia" - }, - { - "name": "George Mponos", - "email": "gmponos@gmail.com", - "homepage": "https://github.com/gmponos" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/Nyholm" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://github.com/sagikazarmark" - }, - { - "name": "Tobias Schultze", - "email": "webmaster@tubo-world.de", - "homepage": "https://github.com/Tobion" - } - ], - "description": "Guzzle is a PHP HTTP client library", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "psr-18", - "psr-7", - "rest", - "web service" - ], - "support": { - "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.8.0" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://github.com/Nyholm", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", - "type": "tidelift" - } - ], - "time": "2023-08-27T10:20:53+00:00" - }, - { - "name": "guzzlehttp/promises", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/promises.git", - "reference": "111166291a0f8130081195ac4556a5587d7f1b5d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/111166291a0f8130081195ac4556a5587d7f1b5d", - "reference": "111166291a0f8130081195ac4556a5587d7f1b5d", - "shasum": "" - }, - "require": { - "php": "^7.2.5 || ^8.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.1", - "phpunit/phpunit": "^8.5.29 || ^9.5.23" - }, - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": true, - "forward-command": false - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/Nyholm" - }, - { - "name": "Tobias Schultze", - "email": "webmaster@tubo-world.de", - "homepage": "https://github.com/Tobion" - } - ], - "description": "Guzzle promises library", - "keywords": [ - "promise" - ], - "support": { - "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.0.1" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://github.com/Nyholm", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", - "type": "tidelift" - } - ], - "time": "2023-08-03T15:11:55+00:00" - }, - { - "name": "guzzlehttp/psr7", - "version": "2.6.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "be45764272e8873c72dbe3d2edcfdfcc3bc9f727" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/be45764272e8873c72dbe3d2edcfdfcc3bc9f727", - "reference": "be45764272e8873c72dbe3d2edcfdfcc3bc9f727", - "shasum": "" - }, - "require": { - "php": "^7.2.5 || ^8.0", - "psr/http-factory": "^1.0", - "psr/http-message": "^1.1 || ^2.0", - "ralouphie/getallheaders": "^3.0" - }, - "provide": { - "psr/http-factory-implementation": "1.0", - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.1", - "http-interop/http-factory-tests": "^0.9", - "phpunit/phpunit": "^8.5.29 || ^9.5.23" - }, - "suggest": { - "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" - }, - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": true, - "forward-command": false - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "George Mponos", - "email": "gmponos@gmail.com", - "homepage": "https://github.com/gmponos" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/Nyholm" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://github.com/sagikazarmark" - }, - { - "name": "Tobias Schultze", - "email": "webmaster@tubo-world.de", - "homepage": "https://github.com/Tobion" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://sagikazarmark.hu" - } - ], - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": [ - "http", - "message", - "psr-7", - "request", - "response", - "stream", - "uri", - "url" - ], - "support": { - "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.6.1" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://github.com/Nyholm", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", - "type": "tidelift" - } - ], - "time": "2023-08-27T10:13:57+00:00" - }, { "name": "monolog/monolog", "version": "1.27.1", @@ -734,189 +260,6 @@ ], "time": "2022-06-09T08:53:42+00:00" }, - { - "name": "mtdowling/jmespath.php", - "version": "2.7.0", - "source": { - "type": "git", - "url": "https://github.com/jmespath/jmespath.php.git", - "reference": "bbb69a935c2cbb0c03d7f481a238027430f6440b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/jmespath/jmespath.php/zipball/bbb69a935c2cbb0c03d7f481a238027430f6440b", - "reference": "bbb69a935c2cbb0c03d7f481a238027430f6440b", - "shasum": "" - }, - "require": { - "php": "^7.2.5 || ^8.0", - "symfony/polyfill-mbstring": "^1.17" - }, - "require-dev": { - "composer/xdebug-handler": "^3.0.3", - "phpunit/phpunit": "^8.5.33" - }, - "bin": [ - "bin/jp.php" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.7-dev" - } - }, - "autoload": { - "files": [ - "src/JmesPath.php" - ], - "psr-4": { - "JmesPath\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Declaratively specify how to extract elements from a JSON document", - "keywords": [ - "json", - "jsonpath" - ], - "support": { - "issues": "https://github.com/jmespath/jmespath.php/issues", - "source": "https://github.com/jmespath/jmespath.php/tree/2.7.0" - }, - "time": "2023-08-25T10:54:48+00:00" - }, - { - "name": "paragonie/constant_time_encoding", - "version": "v2.6.3", - "source": { - "type": "git", - "url": "https://github.com/paragonie/constant_time_encoding.git", - "reference": "58c3f47f650c94ec05a151692652a868995d2938" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/58c3f47f650c94ec05a151692652a868995d2938", - "reference": "58c3f47f650c94ec05a151692652a868995d2938", - "shasum": "" - }, - "require": { - "php": "^7|^8" - }, - "require-dev": { - "phpunit/phpunit": "^6|^7|^8|^9", - "vimeo/psalm": "^1|^2|^3|^4" - }, - "type": "library", - "autoload": { - "psr-4": { - "ParagonIE\\ConstantTime\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com", - "role": "Maintainer" - }, - { - "name": "Steve 'Sc00bz' Thomas", - "email": "steve@tobtu.com", - "homepage": "https://www.tobtu.com", - "role": "Original Developer" - } - ], - "description": "Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)", - "keywords": [ - "base16", - "base32", - "base32_decode", - "base32_encode", - "base64", - "base64_decode", - "base64_encode", - "bin2hex", - "encoding", - "hex", - "hex2bin", - "rfc4648" - ], - "support": { - "email": "info@paragonie.com", - "issues": "https://github.com/paragonie/constant_time_encoding/issues", - "source": "https://github.com/paragonie/constant_time_encoding" - }, - "time": "2022-06-14T06:56:20+00:00" - }, - { - "name": "paragonie/random_compat", - "version": "v9.99.100", - "source": { - "type": "git", - "url": "https://github.com/paragonie/random_compat.git", - "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a", - "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a", - "shasum": "" - }, - "require": { - "php": ">= 7" - }, - "require-dev": { - "phpunit/phpunit": "4.*|5.*", - "vimeo/psalm": "^1" - }, - "suggest": { - "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com" - } - ], - "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", - "keywords": [ - "csprng", - "polyfill", - "pseudorandom", - "random" - ], - "support": { - "email": "info@paragonie.com", - "issues": "https://github.com/paragonie/random_compat/issues", - "source": "https://github.com/paragonie/random_compat" - }, - "time": "2020-10-15T08:29:30+00:00" - }, { "name": "pear/net_dns2", "version": "v1.5.3", @@ -1048,116 +391,6 @@ ], "time": "2023-08-29T08:26:30+00:00" }, - { - "name": "phpseclib/phpseclib", - "version": "3.0.21", - "source": { - "type": "git", - "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "4580645d3fc05c189024eb3b834c6c1e4f0f30a1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/4580645d3fc05c189024eb3b834c6c1e4f0f30a1", - "reference": "4580645d3fc05c189024eb3b834c6c1e4f0f30a1", - "shasum": "" - }, - "require": { - "paragonie/constant_time_encoding": "^1|^2", - "paragonie/random_compat": "^1.4|^2.0|^9.99.99", - "php": ">=5.6.1" - }, - "require-dev": { - "phpunit/phpunit": "*" - }, - "suggest": { - "ext-dom": "Install the DOM extension to load XML formatted public keys.", - "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", - "ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.", - "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.", - "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations." - }, - "type": "library", - "autoload": { - "files": [ - "phpseclib/bootstrap.php" - ], - "psr-4": { - "phpseclib3\\": "phpseclib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jim Wigginton", - "email": "terrafrost@php.net", - "role": "Lead Developer" - }, - { - "name": "Patrick Monnerat", - "email": "pm@datasphere.ch", - "role": "Developer" - }, - { - "name": "Andreas Fischer", - "email": "bantu@phpbb.com", - "role": "Developer" - }, - { - "name": "Hans-Jürgen Petrich", - "email": "petrich@tronic-media.com", - "role": "Developer" - }, - { - "name": "Graham Campbell", - "email": "graham@alt-three.com", - "role": "Developer" - } - ], - "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.", - "homepage": "http://phpseclib.sourceforge.net", - "keywords": [ - "BigInteger", - "aes", - "asn.1", - "asn1", - "blowfish", - "crypto", - "cryptography", - "encryption", - "rsa", - "security", - "sftp", - "signature", - "signing", - "ssh", - "twofish", - "x.509", - "x509" - ], - "support": { - "issues": "https://github.com/phpseclib/phpseclib/issues", - "source": "https://github.com/phpseclib/phpseclib/tree/3.0.21" - }, - "funding": [ - { - "url": "https://github.com/terrafrost", - "type": "github" - }, - { - "url": "https://www.patreon.com/phpseclib", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib", - "type": "tidelift" - } - ], - "time": "2023-07-09T15:24:48+00:00" - }, { "name": "psr/container", "version": "1.1.2", @@ -1206,166 +439,6 @@ }, "time": "2021-11-05T16:50:12+00:00" }, - { - "name": "psr/http-client", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-client.git", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-client/zipball/0955afe48220520692d2d09f7ab7e0f93ffd6a31", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31", - "shasum": "" - }, - "require": { - "php": "^7.0 || ^8.0", - "psr/http-message": "^1.0 || ^2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Client\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP clients", - "homepage": "https://github.com/php-fig/http-client", - "keywords": [ - "http", - "http-client", - "psr", - "psr-18" - ], - "support": { - "source": "https://github.com/php-fig/http-client/tree/1.0.2" - }, - "time": "2023-04-10T20:12:12+00:00" - }, - { - "name": "psr/http-factory", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-factory.git", - "reference": "e616d01114759c4c489f93b099585439f795fe35" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35", - "reference": "e616d01114759c4c489f93b099585439f795fe35", - "shasum": "" - }, - "require": { - "php": ">=7.0.0", - "psr/http-message": "^1.0 || ^2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interfaces for PSR-7 HTTP message factories", - "keywords": [ - "factory", - "http", - "message", - "psr", - "psr-17", - "psr-7", - "request", - "response" - ], - "support": { - "source": "https://github.com/php-fig/http-factory/tree/1.0.2" - }, - "time": "2023-04-10T20:10:41+00:00" - }, - { - "name": "psr/http-message", - "version": "2.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", - "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ], - "support": { - "source": "https://github.com/php-fig/http-message/tree/2.0" - }, - "time": "2023-04-04T09:54:51+00:00" - }, { "name": "psr/log", "version": "1.1.4", @@ -1416,50 +489,6 @@ }, "time": "2021-05-03T11:20:27+00:00" }, - { - "name": "ralouphie/getallheaders", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/ralouphie/getallheaders.git", - "reference": "120b605dfeb996808c31b6477290a714d356e822" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", - "reference": "120b605dfeb996808c31b6477290a714d356e822", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "require-dev": { - "php-coveralls/php-coveralls": "^2.1", - "phpunit/phpunit": "^5 || ^6.5" - }, - "type": "library", - "autoload": { - "files": [ - "src/getallheaders.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ralph Khattar", - "email": "ralph.khattar@gmail.com" - } - ], - "description": "A polyfill for getallheaders.", - "support": { - "issues": "https://github.com/ralouphie/getallheaders/issues", - "source": "https://github.com/ralouphie/getallheaders/tree/develop" - }, - "time": "2019-03-08T08:55:37+00:00" - }, { "name": "robthree/twofactorauth", "version": "1.8.2", @@ -3554,16 +2583,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.32", + "version": "1.10.34", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "c47e47d3ab03137c0e121e77c4d2cb58672f6d44" + "reference": "7f806b6f1403e6914c778140e2ba07c293cb4901" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c47e47d3ab03137c0e121e77c4d2cb58672f6d44", - "reference": "c47e47d3ab03137c0e121e77c4d2cb58672f6d44", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/7f806b6f1403e6914c778140e2ba07c293cb4901", + "reference": "7f806b6f1403e6914c778140e2ba07c293cb4901", "shasum": "" }, "require": { @@ -3612,20 +2641,20 @@ "type": "tidelift" } ], - "time": "2023-08-24T21:54:50+00:00" + "time": "2023-09-13T09:49:47+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.27", + "version": "9.2.28", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1" + "reference": "7134a5ccaaf0f1c92a4f5501a6c9f98ac4dcc0ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/b0a88255cb70d52653d80c890bd7f38740ea50d1", - "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7134a5ccaaf0f1c92a4f5501a6c9f98ac4dcc0ef", + "reference": "7134a5ccaaf0f1c92a4f5501a6c9f98ac4dcc0ef", "shasum": "" }, "require": { @@ -3682,7 +2711,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.27" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.28" }, "funding": [ { @@ -3690,7 +2719,7 @@ "type": "github" } ], - "time": "2023-07-26T13:44:30+00:00" + "time": "2023-09-12T14:36:20+00:00" }, { "name": "phpunit/php-file-iterator", @@ -3935,16 +2964,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.11", + "version": "9.6.12", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "810500e92855eba8a7a5319ae913be2da6f957b0" + "reference": "a122c2ebd469b751d774aa0f613dc0d67697653f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/810500e92855eba8a7a5319ae913be2da6f957b0", - "reference": "810500e92855eba8a7a5319ae913be2da6f957b0", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a122c2ebd469b751d774aa0f613dc0d67697653f", + "reference": "a122c2ebd469b751d774aa0f613dc0d67697653f", "shasum": "" }, "require": { @@ -3959,7 +2988,7 @@ "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.13", + "phpunit/php-code-coverage": "^9.2.28", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", @@ -4018,7 +3047,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.11" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.12" }, "funding": [ { @@ -4034,7 +3063,7 @@ "type": "tidelift" } ], - "time": "2023-08-19T07:10:56+00:00" + "time": "2023-09-12T14:39:31+00:00" }, { "name": "sebastian/cli-parser", @@ -5503,7 +4532,8 @@ "ext-fileinfo": "*", "ext-gmp": "*", "ext-gd": "*", - "ext-ftp": "*" + "ext-ftp": "*", + "ext-gnupg": "*" }, "platform-dev": { "ext-pcntl": "*" diff --git a/install/froxlor.sql.php b/install/froxlor.sql.php index 29181ea5..e6383208 100644 --- a/install/froxlor.sql.php +++ b/install/froxlor.sql.php @@ -921,8 +921,7 @@ INSERT INTO `cronjobs_run` (`id`, `module`, `cronfile`, `cronclass`, `interval`, (3, 'froxlor/reports', 'usage_report', '\\Froxlor\\Cron\\Traffic\\ReportsCron', '1 DAY', '1', 'cron_usage_report'), (4, 'froxlor/core', 'mailboxsize', '\\Froxlor\\Cron\\System\\MailboxsizeCron', '6 HOUR', '1', 'cron_mailboxsize'), (5, 'froxlor/letsencrypt', 'letsencrypt', '\\Froxlor\\Cron\\Http\\LetsEncrypt\\AcmeSh', '5 MINUTE', '0', 'cron_letsencrypt'), - (6, 'froxlor/export', 'export', '\\Froxlor\\Cron\\System\\ExportCron', '1 HOUR', '0', 'cron_export'), - (7, 'froxlor/backup', 'backup', '\\Froxlor\\Cron\\Backup\\BackupCron', '1 DAY', '0', 'cron_backup'); + (6, 'froxlor/export', 'export', '\\Froxlor\\Cron\\System\\ExportCron', '1 HOUR', '0', 'cron_export'); DROP TABLE IF EXISTS `ftp_quotalimits`; @@ -1070,38 +1069,4 @@ CREATE TABLE `panel_loginlinks` ( `allowed_from` text NOT NULL, UNIQUE KEY `loginname` (`loginname`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; - - -DROP TABLE IF EXISTS `panel_backup_storages`; -CREATE TABLE `panel_backup_storages` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(255) NOT NULL, - `type` varchar(255) NOT NULL DEFAULT 'local', - `region` varchar(255) NULL, - `bucket` varchar(255) NULL, - `destination_path` varchar(255) NOT NULL, - `hostname` varchar(255) NULL, - `username` varchar(255) NULL, - `password` text, - `pgp_public_key` text, - `retention` int(3) NOT NULL DEFAULT 3, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; - -INSERT INTO `panel_backup_storages` (`id`, `description`, `destination_path`) VALUES - (1, 'Local backup storage', '/var/customers/backups'); - - -DROP TABLE IF EXISTS `panel_backups`; -CREATE TABLE `panel_backups` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `adminid` int(11) NOT NULL, - `customerid` int(11) NOT NULL, - `loginname` varchar(255) NOT NULL, - `size` bigint(20) NOT NULL, - `storage_id` int(11) NOT NULL, - `filename` varchar(255) NOT NULL, - `created_at` int(15) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; FROXLORSQL; diff --git a/install/updates/froxlor/update_2.1.inc.php b/install/updates/froxlor/update_2.1.inc.php index e6fff65d..eeed5e6b 100644 --- a/install/updates/froxlor/update_2.1.inc.php +++ b/install/updates/froxlor/update_2.1.inc.php @@ -62,54 +62,6 @@ if (Froxlor::isDatabaseVersion('202304260')) { Update::lastStepStatus(1, 'Customized setting, not changing'); } - Update::showUpdateStep("Creating new tables and fields for backups"); - Database::query("DROP TABLE IF EXISTS `" . TABLE_PANEL_BACKUP_STORAGES . "`;"); - $sql = "CREATE TABLE `" . TABLE_PANEL_BACKUP_STORAGES . "` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(255) NOT NULL, - `type` varchar(255) NOT NULL DEFAULT 'local', - `region` varchar(255) NULL, - `bucket` varchar(255) NULL, - `destination_path` varchar(255) NOT NULL, - `hostname` varchar(255) NULL, - `username` varchar(255) NULL, - `password` text, - `pgp_public_key` text, - `retention` int(3) NOT NULL DEFAULT 3, - PRIMARY KEY (`id`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; - Database::query($sql); - Database::query(" - INSERT INTO `panel_backup_storages` (`id`, `description`, `destination_path`) VALUES - (1, 'Local backup storage', '/var/customers/backups'); - "); - Database::query("DROP TABLE IF EXISTS `" . TABLE_PANEL_BACKUPS . "`;"); - $sql = "CREATE TABLE `" . TABLE_PANEL_BACKUPS . "` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `adminid` int(11) NOT NULL, - `customerid` int(11) NOT NULL, - `loginname` varchar(255) NOT NULL, - `size` bigint(20) NOT NULL, - `storage_id` int(11) NOT NULL, - `filename` varchar(255) NOT NULL, - `created_at` int(15) NOT NULL, - PRIMARY KEY (`id`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; - Database::query($sql); - // add customer backup-target-storage - Database::query("ALTER TABLE `" . TABLE_PANEL_CUSTOMERS . "` ADD `backup` int(11) NOT NULL default '1' AFTER `allowed_mysqlserver`;"); - Database::query("ALTER TABLE `" . TABLE_PANEL_CUSTOMERS . "` ADD `access_backups` tinyint(1) NOT NULL default '1' AFTER `backup`;"); - Update::lastStepStatus(0); - - Update::showUpdateStep("Adding new backup settings"); - Settings::AddNew('backup.enabled', 0); - Settings::AddNew('backup.default_storage', 1); - Settings::AddNew('backup.default_customer_access', 1); - Settings::AddNew('backup.default_pgp_public_key', ''); - Settings::AddNew('backup.default_retention', 3); - Settings::AddNew('backup.backup_tmp_dir', '/var/customers/backup/'); - Update::lastStepStatus(0); - Update::showUpdateStep("Adjusting cronjobs"); Database::query(" UPDATE `" . TABLE_PANEL_CRONRUNS . "` SET @@ -119,15 +71,6 @@ if (Froxlor::isDatabaseVersion('202304260')) { `interval` = '1 HOUR', `desc_lng_key` = 'cron_export' WHERE `module` = 'froxlor/backup' - "); - Database::query(" - INSERT INTO `" . TABLE_PANEL_CRONRUNS . "` SET - `module`= 'froxlor/backup', - `cronfile` = 'backup', - `cronclass` = '\\Froxlor\\Cron\\Backup\\BackupCron', - `interval` = '1 DAY', - `isactive` = '0', - `desc_lng_key` = 'cron_backup' "); Update::lastStepStatus(0); diff --git a/lib/Froxlor/Api/Commands/BackupStorages.php b/lib/Froxlor/Api/Commands/BackupStorages.php deleted file mode 100644 index 2f9a6e0b..00000000 --- a/lib/Froxlor/Api/Commands/BackupStorages.php +++ /dev/null @@ -1,542 +0,0 @@ - - * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 - */ - -namespace Froxlor\Api\Commands; - -use Exception; -use Froxlor\Api\ApiCommand; -use Froxlor\Api\ResourceEntity; -use Froxlor\Database\Database; -use Froxlor\FileDir; -use Froxlor\FroxlorLogger; -use Froxlor\Settings; -use Froxlor\UI\Response; -use Froxlor\Validate\Validate; -use PDO; -use phpseclib3\Crypt\Common\PublicKey; -use phpseclib3\Crypt\PublicKeyLoader; -use phpseclib3\Exception\NoKeyLoadedException; - -/** - * @since 2.1.0 - */ -class BackupStorages extends ApiCommand implements ResourceEntity -{ - const SUPPORTED_TYPES = [ - 'local', - 'ftp', - 'sftp', - 'rsync', - 's3', - ]; - - /** - * lists all backup storages entries - * - * @param array $sql_search - * optional array with index = fieldname, and value = array with 'op' => operator (one of <, > or =), - * LIKE is used if left empty and 'value' => searchvalue - * @param int $sql_limit - * optional specify number of results to be returned - * @param int $sql_offset - * optional specify offset for resultset - * @param array $sql_orderby - * optional array with index = fieldname and value = ASC|DESC to order the resultset by one or more - * fields - * - * @access admin - * @return string json-encoded array count|list - * @throws Exception - */ - public function listing() - { - if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) { - $this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "[API] list backup storages"); - $query_fields = []; - $result_stmt = Database::prepare(" - SELECT * FROM `" . TABLE_PANEL_BACKUP_STORAGES . "` " . $this->getSearchWhere($query_fields) . $this->getOrderBy() . $this->getLimit() - ); - Database::pexecute($result_stmt, $query_fields, true, true); - $result = []; - while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { - $result[] = $row; - } - return $this->response([ - 'count' => count($result), - 'list' => $result - ]); - } - throw new Exception("Not allowed to execute given command.", 403); - } - - /** - * returns the total number of backup storages - * - * @access admin - * @return string json-encoded response message - * @throws Exception - */ - public function listingCount() - { - if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) { - $result_stmt = Database::prepare(" - SELECT COUNT(*) as num_backup_storagess - FROM `" . TABLE_PANEL_BACKUP_STORAGES . "` - "); - $result = Database::pexecute_first($result_stmt, null, true, true); - if ($result) { - return $this->response($result['num_backup_storagess']); - } - $this->response(0); - } - throw new Exception("Not allowed to execute given command.", 403); - } - - /** - * create a backup storage - * - * @param string $type - * required, backup storage type - * @param string $destination_path - * required, destination path for backup storage - * @param string $description - * required, description for backup storage - * @param string $region - * optional, required if type=s3. Region for backup storage (used for S3) - * @param string $bucket - * optional, required if type=s3. Bucket for backup storage (used for S3) - * @param string $hostname - * optional, required if type != local. Hostname for backup storage - * @param string $username - * optional, required if type != local. Username for backup storage (also used as access key for S3) - * @param string $password - * optional, required if type != local. Password for backup storage (also used as secret key for S3) - * @param string $pgp_public_key - * optional, pgp public key for backup storage - * @param string $retention - * optional, retention for backup storage (default {backup.default_retention}) - * - * @access admin - * @return string json-encoded array - * @throws Exception - */ - public function add() - { - if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) { - // required parameters - $type = $this->getParam('type'); - $destination_path = $this->getParam('destination_path'); - $description = $this->getParam('description'); - - // type related requirements - $optional_flags = [ - 'region' => true, - 'bucket' => true, - 'hostname' => true, - 'username' => true, - 'password' => true, - ]; - - if (!in_array($type, self::SUPPORTED_TYPES)) { - throw new Exception("Unsupported storage type: '" . $type . "'", 406); - } - - if ($type != 'local') { - $optional_flags['hostname'] = false; - $optional_flags['username'] = false; - $optional_flags['password'] = false; - } - if ($type == 's3') { - $optional_flags['region'] = false; - $optional_flags['bucket'] = false; - } - - // parameters - $region = $this->getParam('region', $optional_flags['region']); - $bucket = $this->getParam('bucket', $optional_flags['bucket']); - $hostname = $this->getParam('hostname', $optional_flags['hostname']); - $username = $this->getParam('username', $optional_flags['username']); - $password = $this->getParam('password', $optional_flags['password']); - $pgp_public_key = $this->getParam('pgp_public_key', true, null); - $retention = $this->getParam('retention', true, Settings::Get('backup.default_retention')); - - // validation - $destination_path = FileDir::makeCorrectDir(Validate::validate($destination_path, 'destination_path', Validate::REGEX_DIR, '', [], true)); - if ($type != 'local') { - if (!Validate::validateUrl($hostname)) { - Response::standardError('invalidhostname', '', true); - } - // check whether password is an ssh public key - $pwd_is_ssh_key = false; - try { - $key = PublicKeyLoader::loadPublicKey($password); - if ($key instanceof PublicKey) { - $pwd_is_ssh_key = true; - } - } catch (NoKeyLoadedException $e) { - /* nothing to do */ - } - if (!$pwd_is_ssh_key) { - // normal password - $password = Validate::validate($password, 'password', '', '', [], true); - } - } - if ($type == 's3') { - $region = Validate::validate($region, 'region', '', '', [], true); - $bucket = Validate::validate($bucket, 'bucket', '/(?!(^xn--|.+-s3alias$))^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/', '', [], true); - } - if ($retention <= 0) { - $retention = Settings::Get('backup.default_retention'); - } - // TODO: add more validation - - // pgp public key validation - if (!empty($pgp_public_key)) { - // check if gnupg extension is loaded - if (!extension_loaded('gnupg')) { - Response::standardError('gnupgextensionnotavailable', '', true); - } - // check if the pgp public key is a valid key - putenv('GNUPGHOME=' . sys_get_temp_dir()); - if (gnupg_import(gnupg_init(), $pgp_public_key) === false) { - Response::standardError('invalidpgppublickey', '', true); - } - } - - // store - $stmt = Database::prepare(" - INSERT INTO `" . TABLE_PANEL_BACKUP_STORAGES . "` ( - `description`, - `type`, - `region`, - `bucket`, - `destination_path`, - `hostname`, - `username`, - `password`, - `pgp_public_key`, - `retention` - ) VALUES ( - :description, - :type, - :region, - :bucket, - :destination_path, - :hostname, - :username, - :password, - :pgp_public_key, - :retention - ) - "); - $params = [ - "description" => $description, - "type" => $type, - "region" => $region, - "bucket" => $bucket, - "destination_path" => $destination_path, - "hostname" => $hostname, - "username" => $username, - "password" => $password, - "pgp_public_key" => $pgp_public_key, - "retention" => $retention, - ]; - Database::pexecute($stmt, $params, true, true); - $id = Database::lastInsertId(); - - // return - $result = $this->apiCall('BackupStorages.get', [ - 'id' => $id - ]); - $this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] added backup storage '" . $result['description'] . "' (" . $result['type'] . ")"); - return $this->response($result); - } - throw new Exception("Not allowed to execute given command.", 403); - } - - /** - * return a backup storage entry by id - * - * @param int $id - * the backup-storage-id - * - * @access admin - * @return string json-encoded array - * @throws Exception - */ - public function get() - { - $id = $this->getParam('id'); - - if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) { - $result_stmt = Database::prepare(" - SELECT * FROM `" . TABLE_PANEL_BACKUP_STORAGES . "` - WHERE `id` = :id" - ); - $params = [ - 'id' => $id - ]; - $result = Database::pexecute_first($result_stmt, $params, true, true); - if ($result) { - $this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "[API] get backup storage '" . $result['description'] . "'"); - return $this->response($result); - } - throw new Exception("Backup storage with " . $id . " could not be found", 404); - } - throw new Exception("Not allowed to execute given command.", 403); - } - - /** - * update a backup storage by given id - * - * @param int $id - * required, the backup-storage-id - * @param string $type - * optional, backup storage type - * @param string $destination_path - * optional, destination path for backup storage - * @param string $description - * required, description for backup storage - * @param string $region - * optional, region for backup storage (used for S3) - * @param string $bucket - * optional, bucket for backup storage (used for S3) - * @param string $hostname - * optional, hostname for backup storage - * @param string $username - * optional, username for backup storage (also used as access key for S3) - * @param string $password - * optional, password for backup storage (also used as secret key for S3) - * @param string $pgp_public_key - * optional, pgp public key for backup storage - * @param string $retention - * optional, retention for backup storage (default {backup.default_retention}) - * - * @access admin - * @return string json-encoded array - * @throws Exception - */ - public function update() - { - $id = $this->getParam('id'); - - if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) { - // validation - $result = $this->apiCall('BackupStorages.get', [ - 'id' => $id - ]); - - // parameters - $description = $this->getParam('description', true, $result['description']); - $type = $this->getParam('type', true, $result['type']); - $region = $this->getParam('region', true, $result['region']); - $bucket = $this->getParam('bucket', true, $result['bucket']); - $destination_path = $this->getParam('destination_path', true, $result['destination_path']); - $hostname = $this->getParam('hostname', true, $result['hostname']); - $username = $this->getParam('username', true, $result['username']); - $password = $this->getParam('password', true, ''); - $pgp_public_key = $this->getParam('pgp_public_key', true, $result['pgp_public_key']); - $retention = $this->getParam('retention', true, $result['retention']); - - if (!in_array($type, self::SUPPORTED_TYPES)) { - throw new Exception("Unsupported storage type: '" . $type . "'", 406); - } - - if ($type != 'local') { - if (empty($hostname)) { - throw new Exception("Field 'hostname' cannot be empty", 406); - } - if (empty($username)) { - throw new Exception("Field 'username' cannot be empty", 406); - } - // password change - if (!empty($password)) { - // check whether password is an ssh public key - $pwd_is_ssh_key = false; - try { - $key = PublicKeyLoader::loadPublicKey($password); - if ($key instanceof PublicKey) { - $pwd_is_ssh_key = true; - } - } catch (NoKeyLoadedException $e) { - /* nothing to do */ - } - if (!$pwd_is_ssh_key) { - // normal password - $password = Validate::validate($password, 'password', '', '', [], true); - } - } - } - if ($type == 's3') { - if (empty($region)) { - throw new Exception("Field 'region' cannot be empty", 406); - } - if (empty($bucket)) { - throw new Exception("Field 'bucket' cannot be empty", 406); - } - } - - // validation - $destination_path = FileDir::makeCorrectDir(Validate::validate($destination_path, 'destination_path', Validate::REGEX_DIR, '', [], true)); - if ($type != 'local' && !Validate::validateUrl($hostname)) { - Response::standardError('invalidhostname', '', true); - } - if ($type == 's3') { - $region = Validate::validate($region, 'region', '', '', [], true); - $bucket = Validate::validate($bucket, 'bucket', '/(?!(^xn--|.+-s3alias$))^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/', '', [], true); - } - if ($retention <= 0) { - $retention = Settings::Get('backup.default_retention'); - } - // TODO: add more validation - - // pgp public key validation - if (!empty($pgp_public_key) && $pgp_public_key != $result['pgp_public_key']) { - // check if gnupg extension is loaded - if (!extension_loaded('gnupg')) { - Response::standardError('gnupgextensionnotavailable', '', true); - } - // check if the pgp public key is a valid key - putenv('GNUPGHOME=' . sys_get_temp_dir()); - if (gnupg_import(gnupg_init(), $pgp_public_key) === false) { - Response::standardError('invalidpgppublickey', '', true); - } - } - - if (!empty($password)) { - $stmt = Database::prepare("UPDATE `" . TABLE_PANEL_BACKUP_STORAGES . "` - SET `password` = :password - WHERE `id` = :id - "); - Database::pexecute($stmt, [ - "id" => $id, - "password" => $password - ], true, true); - $this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] updated password for backup-storage '" . $result['description'] . "'"); - } - - // update - $stmt = Database::prepare(" - UPDATE `" . TABLE_PANEL_BACKUP_STORAGES . "` - SET `description` = :description, - `type` = :type, - `region` = :region, - `bucket` = :bucket, - `destination_path` = :destination_path, - `hostname` = :hostname, - `username` = :username, - `pgp_public_key` = :pgp_public_key, - `retention` = :retention - WHERE `id` = :id - "); - $params = [ - "id" => $id, - "description" => $description, - "type" => $type, - "region" => $region, - "bucket" => $bucket, - "destination_path" => $destination_path, - "hostname" => $hostname, - "username" => $username, - "pgp_public_key" => $pgp_public_key, - "retention" => $retention, - ]; - Database::pexecute($stmt, $params, true, true); - $this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] edited backup storage '" . $result['description'] . "'"); - - // return - $result = $this->apiCall('BackupStorages.get', [ - 'id' => $id - ]); - return $this->response($result); - } - throw new Exception("Not allowed to execute given command.", 403); - } - - /** - * delete a backup-storage entry by id - * - * @param int $id - * required, the backup-storage-id - * - * @access admin - * @return string json-encoded array - * @throws Exception - */ - public function delete() - { - $id = $this->getParam('id'); - - if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) { - // validation - $result = $this->apiCall('BackupStorages.get', [ - 'id' => $id - ]); - - // validate no-one's using it - - // settings - if ($id == Settings::Get('backup.default_storage')) { - throw new Exception("Given backup storage is currently set as default storage and cannot be deleted.", 406); - } - // customers - $sel_stmt = Database::prepare(" - SELECT COUNT(*) as num_storage_users - FROM `" . TABLE_PANEL_CUSTOMERS . "` - WHERE `backup` = :id - "); - $storage_users_result = Database::pexecute_first($sel_stmt, ['id' => $id]); - if ($storage_users_result && $storage_users_result['num_storage_users'] > 0) { - throw new Exception("Given backup storage is currently assigned to " . $storage_users_result['num_storage_users'] . " customers and cannot be deleted.", 406); - } - // existing backups - $sel_stmt = Database::prepare(" - SELECT COUNT(*) as num_storage_backups - FROM `" . TABLE_PANEL_BACKUPS . "` - WHERE `storage_id` = :id - "); - $storage_backups_result = Database::pexecute_first($sel_stmt, ['id' => $id]); - if ($storage_backups_result && $storage_backups_result['num_storage_backups'] > 0) { - throw new Exception("Given backup storage has still " . $storage_backups_result['num_storage_backups'] . " backups on it and cannot be deleted.", 406); - } - - // delete - $stmt = Database::prepare(" - DELETE FROM `" . TABLE_PANEL_BACKUP_STORAGES . "` - WHERE `id` = :id - "); - $params = [ - "id" => $id - ]; - Database::pexecute($stmt, $params, true, true); - $this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] deleted backup storage '" . $result['description'] . "'"); - - // return - return $this->response(true); - } - - throw new Exception("Not allowed to execute given command.", 403); - } -} diff --git a/lib/Froxlor/Api/Commands/Backups.php b/lib/Froxlor/Api/Commands/Backups.php deleted file mode 100644 index b5f556e1..00000000 --- a/lib/Froxlor/Api/Commands/Backups.php +++ /dev/null @@ -1,211 +0,0 @@ - - * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 - */ - -namespace Froxlor\Api\Commands; - -use Exception; -use Froxlor\Api\ApiCommand; -use Froxlor\Api\ResourceEntity; -use Froxlor\Database\Database; -use Froxlor\FroxlorLogger; -use PDO; - -/** - * @since 2.1.0 - */ -class Backups extends ApiCommand implements ResourceEntity -{ - /** - * lists all admin entries - * - * @param array $sql_search - * optional array with index = fieldname, and value = array with 'op' => operator (one of <, > or =), - * LIKE is used if left empty and 'value' => searchvalue - * @param int $sql_limit - * optional specify number of results to be returned - * @param int $sql_offset - * optional specify offset for resultset - * @param array $sql_orderby - * optional array with index = fieldname and value = ASC|DESC to order the resultset by one or more - * fields - * - * @access admin - * @return string json-encoded array count|list - * @throws Exception - */ - public function listing() - { - if ($this->isAdmin()) { - // if we're an admin, list all backups of all the admins customers - // or optionally for one specific customer identified by id or loginname - $customerid = $this->getParam('customerid', true, 0); - $loginname = $this->getParam('loginname', true, ''); - - if (!empty($customerid) || !empty($loginname)) { - $result = $this->apiCall('Customers.get', [ - 'id' => $customerid, - 'loginname' => $loginname - ]); - $custom_list_result = [ - $result - ]; - } else { - $_custom_list_result = $this->apiCall('Customers.listing'); - $custom_list_result = $_custom_list_result['list']; - } - $customer_ids = []; - foreach ($custom_list_result as $customer) { - $customer_ids[] = $customer['customerid']; - } - if (empty($customer_ids)) { - throw new Exception("Required resource unsatisfied.", 405); - } - } else { - $customer_ids = [ - $this->getUserDetail('customerid') - ]; - } - - $this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "[API] list backups"); - $query_fields = []; - $result_stmt = Database::prepare(" - SELECT `b`.*, `a`.`loginname` as `adminname` - FROM `" . TABLE_PANEL_BACKUPS . "` `b` - LEFT JOIN `" . TABLE_PANEL_ADMINS . "` `a` USING(`adminid`) - WHERE `b`.`customerid` IN (" . implode(', ', $customer_ids) . ") - " . $this->getSearchWhere($query_fields, true) . $this->getOrderBy() . $this->getLimit() - ); - Database::pexecute($result_stmt, $query_fields, true, true); - $result = []; - while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { - $result[] = $row; - } - return $this->response([ - 'count' => count($result), - 'list' => $result - ]); - } - - /** - * returns the total number of backups for the given admin - * - * @access admin - * @return string json-encoded response message - * @throws Exception - */ - public function listingCount() - { - if ($this->isAdmin()) { - // if we're an admin, list all backups of all the admins customers - // or optionally for one specific customer identified by id or loginname - $customerid = $this->getParam('customerid', true, 0); - $loginname = $this->getParam('loginname', true, ''); - - if (!empty($customerid) || !empty($loginname)) { - $result = $this->apiCall('Customers.get', [ - 'id' => $customerid, - 'loginname' => $loginname - ]); - $custom_list_result = [ - $result - ]; - } else { - $_custom_list_result = $this->apiCall('Customers.listing'); - $custom_list_result = $_custom_list_result['list']; - } - $customer_ids = []; - foreach ($custom_list_result as $customer) { - $customer_ids[] = $customer['customerid']; - } - if (empty($customer_ids)) { - throw new Exception("Required resource unsatisfied.", 405); - } - } else { - $customer_ids = [ - $this->getUserDetail('customerid') - ]; - } - $result_stmt = Database::prepare(" - SELECT COUNT(*) as num_backups - FROM `" . TABLE_PANEL_BACKUPS . "` `b` - WHERE `b`.`customerid` IN (" . implode(', ', $customer_ids) . ") - "); - $result = Database::pexecute_first($result_stmt, null, true, true); - if ($result) { - return $this->response($result['num_backups']); - } - $this->response(0); - } - - /** - * You cannot add a backup entry - * - * @throws Exception - */ - public function add() - { - throw new Exception('You cannot add a backup entry', 303); - } - - /** - * return a backup entry by id - * - * @param int $id - * optional, the backup-entry-id - * - * @access admin, customers - * @return string json-encoded array - * @throws Exception - */ - public function get() - { - throw new Exception("@TODO", 303); - } - - /** - * You cannot update a backup entry - * - * @throws Exception - */ - public function update() - { - throw new Exception('You cannot update a backup entry', 303); - } - - /** - * delete a backup entry by id - * - * @param int $id - * required, the backup-entry-id - * - * @access admin, customer - * @return string json-encoded array - * @throws Exception - */ - public function delete() - { - throw new Exception("@TODO", 303); - } -} diff --git a/lib/Froxlor/Api/Commands/Customers.php b/lib/Froxlor/Api/Commands/Customers.php index 722d78c1..f9cd52a8 100644 --- a/lib/Froxlor/Api/Commands/Customers.php +++ b/lib/Froxlor/Api/Commands/Customers.php @@ -273,13 +273,6 @@ class Customers extends ApiCommand implements ResourceEntity * @param array $allowed_mysqlserver * optional, array of IDs of defined mysql-servers the customer is allowed to use, * default is to allow the default dbserver (id=0) - * @param int $backup - * optional, either 0 to disable backup for this customer or a backup-storage-id - * where backups are to be stored, requires change_serversettings permissions, - * default is system-setting backup.default_storage - * @param bool $access_backups - * optional, where the customer is allowed to view backups, default is system-setting - * default_customer_access * * @access admin * @return string json-encoded array @@ -366,24 +359,6 @@ class Customers extends ApiCommand implements ResourceEntity $p_allowed_mysqlserver = []; } - if ($this->getUserDetail('change_serversettings')) { - $backup = $this->getParam('backup', true, Settings::Get('backup.default_storage')); - if ($backup > 0) { - try { - $this->apiCall('BackupStorages.get', [ - 'id' => $backup - ]); - } catch (Exception $e) { - // not found or other issue, set default - $backup = Settings::Get('backup.default_storage'); - } - } - $access_backups = $this->getBoolParam('access_backups', true, Settings::Get('backup.default_customer_access')); - } else { - $backup = Settings::Get('backup.default_storage'); - $access_backups = Settings::Get('backup.default_customer_access'); - } - // validation $name = Validate::validate($name, 'name', Validate::REGEX_DESC_TEXT, '', [], true); $firstname = Validate::validate($firstname, 'first name', Validate::REGEX_DESC_TEXT, '', [], true); @@ -562,9 +537,7 @@ class Customers extends ApiCommand implements ResourceEntity 'theme' => $_theme, 'custom_notes' => $custom_notes, 'custom_notes_show' => $custom_notes_show, - 'allowed_mysqlserver' => empty($allowed_mysqlserver) ? "" : json_encode($allowed_mysqlserver), - 'backup' => $backup, - 'access_backups' => $access_backups + 'allowed_mysqlserver' => empty($allowed_mysqlserver) ? "" : json_encode($allowed_mysqlserver) ]; $ins_stmt = Database::prepare(" @@ -607,9 +580,7 @@ class Customers extends ApiCommand implements ResourceEntity `theme` = :theme, `custom_notes` = :custom_notes, `custom_notes_show` = :custom_notes_show, - `allowed_mysqlserver`= :allowed_mysqlserver, - `backup` = :backup, - `access_backups` = :access_backups + `allowed_mysqlserver`= :allowed_mysqlserver "); Database::pexecute($ins_stmt, $ins_data, true, true); @@ -1057,13 +1028,6 @@ class Customers extends ApiCommand implements ResourceEntity * @param array $allowed_mysqlserver * optional, array of IDs of defined mysql-servers the customer is allowed to use, * default is to allow the default dbserver (id=0) - * @param int $backup - * optional, either 0 to disable backup for this customer or a backup-storage-id - * where backups are to be stored, requires change_serversettings permissions, - * default is system-setting backup.default_storage - * @param bool $access_backups - * optional, where the customer is allowed to view backups, default is system-setting - * default_customer_access * * @access admin, customer * @return string json-encoded array @@ -1125,24 +1089,6 @@ class Customers extends ApiCommand implements ResourceEntity $deactivated = $this->getBoolParam('deactivated', true, $result['deactivated']); $theme = $this->getParam('theme', true, $result['theme']); $allowed_mysqlserver = $this->getParam('allowed_mysqlserver', true, json_decode($result['allowed_mysqlserver'], true)); - - if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) { - $backup = $this->getParam('backup', true, $result['backup']); - if ($backup > 0) { - try { - $this->apiCall('BackupStorages.get', [ - 'id' => $backup - ]); - } catch (Exception $e) { - // not found or other issue, dont update - $backup = $result['backup']; - } - } - $access_backups = $this->getBoolParam('access_backups', true, Settings::Get('backup.default_customer_access')); - } else { - $backup = $result['backup']; - $access_backups = $result['access_backups']; - } } else { // allowed parameters $def_language = $this->getParam('def_language', true, $result['def_language']); @@ -1451,9 +1397,7 @@ class Customers extends ApiCommand implements ResourceEntity 'custom_notes' => $custom_notes, 'custom_notes_show' => $custom_notes_show, 'api_allowed' => $api_allowed, - 'allowed_mysqlserver' => empty($allowed_mysqlserver) ? "" : json_encode($allowed_mysqlserver), - 'backup' => $backup, - 'access_backups' => $access_backups + 'allowed_mysqlserver' => empty($allowed_mysqlserver) ? "" : json_encode($allowed_mysqlserver) ]; $upd_data += $admin_upd_data; } @@ -1496,9 +1440,7 @@ class Customers extends ApiCommand implements ResourceEntity `custom_notes` = :custom_notes, `custom_notes_show` = :custom_notes_show, `api_allowed` = :api_allowed, - `allowed_mysqlserver` = :allowed_mysqlserver, - `backup`= :backup, - `access_backups` = :access_backups"; + `allowed_mysqlserver` = :allowed_mysqlserver"; $upd_query .= $admin_upd_query; } $upd_query .= " WHERE `customerid` = :customerid"; diff --git a/lib/Froxlor/Backup/Backup.php b/lib/Froxlor/Backup/Backup.php deleted file mode 100644 index 005df682..00000000 --- a/lib/Froxlor/Backup/Backup.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 - */ - -namespace Froxlor\Backup; - -use Froxlor\Database\Database; -use PDO; - -class Backup -{ - /** - * returns an array of existing backup-storages - * in our database for the settings-array - * - * @return array - */ - public static function getBackupStorages(): array - { - $storages_array = [ - 0 => lng('backup.storage_none') - ]; - // get all storages - $result_stmt = Database::query("SELECT id, type, description FROM `" . TABLE_PANEL_BACKUP_STORAGES . "` ORDER BY type, description"); - while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { - if (!isset($storages_array[$row['id']]) && !in_array($row['id'], $storages_array)) { - $storages_array[$row['id']] = "[" . $row['type'] . "] " . html_entity_decode($row['description']); - } - } - return $storages_array; - } -} diff --git a/lib/Froxlor/Backup/Storages/Ftp.php b/lib/Froxlor/Backup/Storages/Ftp.php deleted file mode 100644 index 1108ec46..00000000 --- a/lib/Froxlor/Backup/Storages/Ftp.php +++ /dev/null @@ -1,102 +0,0 @@ -sData['storage']['hostname'] ?? ''; - $username = $this->sData['storage']['username'] ?? ''; - $password = $this->sData['storage']['password'] ?? ''; - if (!empty($hostname) && !empty($username) && !empty($password)) { - $tmp = explode(":", $hostname); - $hostname = $tmp[0]; - $port = $tmp[1] ?? 21; - $this->ftp_conn = ftp_connect($hostname, $port); - if ($this->ftp_conn === false) { - throw new Exception('Unable to connect to ftp-server "' . $hostname . ':' . $port . '"'); - } - if (!ftp_login($this->ftp_conn, $username, $password)) { - throw new Exception('Unable to login to ftp-server "' . $hostname . ':' . $port . '"'); - } - return $this->changeToCorrectDirectory(); - } - throw new Exception('Empty hostname for FTP backup storage'); - } - - /** - * Move/Upload file from tmp-source-directory. The file should be moved or deleted afterward. - * Must return the (relative) path including filename to the backup. - * - * @param string $filename - * @param string $tmp_source_directory - * @return string - * @throws Exception - */ - protected function putFile(string $filename, string $tmp_source_directory): string - { - $source = FileDir::makeCorrectFile($tmp_source_directory . "/" . $filename); - if (file_exists($source) && ftp_size($this->ftp_conn, $filename) == -1) { - if (ftp_put($this->ftp_conn, $filename, $source, FTP_BINARY)) { - return FileDir::makeCorrectFile($this->getDestinationDirectory() . '/' . $filename); - } - } - return ""; - } - - /** - * @param string $filename - * @return bool - * @throws Exception - */ - protected function rmFile(string $filename): bool - { - $target = basename($filename); - if (ftp_size($this->ftp_conn, $target) >= 0) { - return ftp_delete($this->ftp_conn, $target); - } - return true; - } - - /** - * @return bool - */ - public function shutdown(): bool - { - return ftp_close($this->ftp_conn); - } - - /** - * @return bool - * @throws Exception - */ - private function changeToCorrectDirectory(): bool - { - $dirs = explode("/", $this->getDestinationDirectory()); - array_shift($dirs); - if (count($dirs) > 0 && !empty($dirs[0])) { - foreach ($dirs as $dir) { - if (empty($dir)) { - continue; - } - if (!@ftp_chdir($this->ftp_conn, $dir)) { - ftp_mkdir($this->ftp_conn, $dir); - ftp_chmod($this->ftp_conn, 0700, $dir); - ftp_chdir($this->ftp_conn, $dir); - } - } - return true; - } - return ftp_chdir($this->ftp_conn, "/"); - } -} diff --git a/lib/Froxlor/Backup/Storages/Local.php b/lib/Froxlor/Backup/Storages/Local.php deleted file mode 100644 index 7c5d0bfb..00000000 --- a/lib/Froxlor/Backup/Storages/Local.php +++ /dev/null @@ -1,64 +0,0 @@ -getDestinationDirectory())) { - return mkdir($this->getDestinationDirectory(), 0700, true); - } - return true; - } - - /** - * Move/Upload file from tmp-source-directory. The file should be moved or deleted afterward. - * Must return the (relative) path including filename to the backup. - * - * @param string $filename - * @param string $tmp_source_directory - * @return string - * @throws Exception - */ - protected function putFile(string $filename, string $tmp_source_directory): string - { - $source = FileDir::makeCorrectFile($tmp_source_directory . "/" . $filename); - $target = FileDir::makeCorrectFile($this->getDestinationDirectory() . "/" . $filename); - if (file_exists($source) && !file_exists($target)) { - rename($source, $target); - return $target; - } - return ""; - } - - /** - * @param string $filename - * @return bool - * @throws Exception - */ - protected function rmFile(string $filename): bool - { - $target = FileDir::makeCorrectFile($this->getDestinationDirectory() . "/" . $filename); - if (file_exists($target)) { - return @unlink($target); - } - return true; - } - - /** - * @return bool - */ - public function shutdown(): bool - { - return true; - } -} diff --git a/lib/Froxlor/Backup/Storages/Rsync.php b/lib/Froxlor/Backup/Storages/Rsync.php deleted file mode 100644 index 687a372a..00000000 --- a/lib/Froxlor/Backup/Storages/Rsync.php +++ /dev/null @@ -1,45 +0,0 @@ - [ - 'key' => $this->sData['storage']['username'] ?? '', - 'secret' => $this->sData['storage']['password'] ?? '' - ], - 'endpoint' => $this->sData['storage']['hostname'] ?? '', - 'region' => $this->sData['storage']['region'] ?? '', - 'version' => 'latest', - 'use_path_style_endpoint' => true - ]; - $this->s3_client = new S3Client($raw_credentials); - } - - /** - * Move/Upload file from tmp-source-directory. The file should be moved or deleted afterward. - * Must return the (relative) path including filename to the backup. - * - * @param string $filename - * @param string $tmp_source_directory - * @return string - * @throws \Exception - */ - protected function putFile(string $filename, string $tmp_source_directory): string - { - $source = FileDir::makeCorrectFile($tmp_source_directory . "/" . $filename); - $target = FileDir::makeCorrectFile($this->getDestinationDirectory() . "/" . $filename); - $this->s3_client->putObject([ - 'Bucket' => $this->sData['storage']['bucket'], - 'Key' => $target, - 'SourceFile' => $source, - ]); - } - - /** - * @param string $filename - * @return bool - */ - protected function rmFile(string $filename): bool - { - $result = $this->s3_client->deleteObject([ - 'Bucket' => $this->sData['storage']['bucket'], - 'Key' => $filename, - ]); - - if ($result['DeleteMarker']) { - return true; - } - return false; - } - - /** - * @return bool - */ - public function shutdown(): bool - { - return true; - } -} diff --git a/lib/Froxlor/Backup/Storages/Sftp.php b/lib/Froxlor/Backup/Storages/Sftp.php deleted file mode 100644 index 1e417d52..00000000 --- a/lib/Froxlor/Backup/Storages/Sftp.php +++ /dev/null @@ -1,73 +0,0 @@ -sData['storage']['hostname'] ?? ''; - $username = $this->sData['storage']['username'] ?? ''; - $password = $this->sData['storage']['password'] ?? ''; - if (!empty($hostname) && !empty($username) && !empty($password)) { - $tmp = explode(":", $hostname); - $hostname = $tmp[0]; - $port = $tmp[1] ?? 22; - $this->sftp_client = new secSFTP($hostname, $port); - if ($this->sftp_client->isConnected()) { - // @todo login by either user/passwd or user/ssh-key - return true; - } - return false; - } - throw new Exception('Empty hostname for FTP backup storage'); - } - - /** - * Move/Upload file from tmp-source-directory. The file should be moved or deleted afterward. - * Must return the (relative) path including filename to the backup. - * - * @param string $filename - * @param string $tmp_source_directory - * @return string - * @throws Exception - */ - protected function putFile(string $filename, string $tmp_source_directory): string - { - $source = FileDir::makeCorrectFile($tmp_source_directory . "/" . $filename); - $target = FileDir::makeCorrectFile($this->getDestinationDirectory() . "/" . $filename); - $this->sftp_client->put($target, $source, secSFTP::SOURCE_LOCAL_FILE); - } - - /** - * @param string $filename - * @return bool - * @throws Exception - */ - protected function rmFile(string $filename): bool - { - $target = FileDir::makeCorrectFile($this->getDestinationDirectory() . "/" . $filename); - if ($this->sftp_client->file_exists($target)) { - return $this->sftp_client->delete($target); - } - return false; - } - - /** - * @return bool - */ - public function shutdown(): bool - { - $this->sftp_client->disconnect(); - return true; - } -} diff --git a/lib/Froxlor/Backup/Storages/Storage.php b/lib/Froxlor/Backup/Storages/Storage.php deleted file mode 100644 index fe035d9a..00000000 --- a/lib/Froxlor/Backup/Storages/Storage.php +++ /dev/null @@ -1,283 +0,0 @@ -sData = $storage_data; - $tmpDirectory = Settings::Get('backup.backup_tmp_dir') ?: sys_get_temp_dir(); - $this->tmpDirectory = FileDir::makeCorrectDir($tmpDirectory . '/backup-' . $this->sData['loginname']); - } - - /** - * Validate sData, open connection to target storage, etc. - * - * @return bool - */ - abstract public function init(): bool; - - /** - * Disconnect / clean up connection if needed - * - * @return bool - */ - abstract public function shutdown(): bool; - - /** - * prepare files to back up (e.g. create archive or similar) and fill $filesToStore - * - * @return void - * @throws Exception - */ - public function prepareFiles(): void - { - $this->filesToStore = []; - - $tmpdir = FileDir::makeCorrectDir($this->tmpDirectory . '/.tmp/'); - FileDir::safe_exec('mkdir -p ' . escapeshellarg($tmpdir)); - - // create archive of web, mail and database data - $this->prepareWebData(); - $this->prepareDatabaseData(); - $this->prepareMailData(); - - // create json-info-file - } - - /** - * @throws Exception - */ - private function prepareWebData(): void - { - $tmpdir = FileDir::makeCorrectDir($this->tmpDirectory . '/.tmp/web'); - FileDir::safe_exec('mkdir -p ' . escapeshellarg($tmpdir)); - FileDir::safe_exec('tar cfz ' . escapeshellarg(FileDir::makeCorrectFile($tmpdir . '/' . $this->sData['loginname'] . '-web.tar.gz')) . ' -C ' . escapeshellarg($this->sData['documentroot']) . ' .'); - $this->filesToStore[] = FileDir::makeCorrectFile($tmpdir . '/' . $this->sData['loginname'] . '-web.tar.gz'); - } - - /** - * @throws Exception - */ - private function prepareDatabaseData(): void - { - $tmpdir = FileDir::makeCorrectDir($this->tmpDirectory . '/.tmp/mysql'); - FileDir::safe_exec('mkdir -p ' . escapeshellarg($tmpdir)); - - // get all customer database-names - $sel_stmt = Database::prepare(" - SELECT `databasename`, `dbserver` FROM `" . TABLE_PANEL_DATABASES . "` - WHERE `customerid` = :cid ORDER BY `dbserver` - "); - Database::pexecute($sel_stmt, [ - 'cid' => $this->sData['customerid'] - ]); - - $has_dbs = false; - $current_dbserver = -1; - while ($row = $sel_stmt->fetch()) { - // Get sql_root data for the specific database-server the database resides on - if ($current_dbserver != $row['dbserver']) { - Database::needRoot(true, $row['dbserver']); - Database::needSqlData(); - $sql_root = Database::getSqlData(); - Database::needRoot(false); - // create temporary mysql-defaults file for the connection-credentials/details - $mysqlcnf_file = tempnam("/tmp", "frx"); - $mysqlcnf = "[mysqldump]\npassword=" . $sql_root['passwd'] . "\nhost=" . $sql_root['host'] . "\n"; - if (!empty($sql_root['port'])) { - $mysqlcnf .= "port=" . $sql_root['port'] . "\n"; - } elseif (!empty($sql_root['socket'])) { - $mysqlcnf .= "socket=" . $sql_root['socket'] . "\n"; - } - file_put_contents($mysqlcnf_file, $mysqlcnf); - } - $bool_false = false; - FileDir::safe_exec('mysqldump --defaults-file=' . escapeshellarg($mysqlcnf_file) . ' -u ' . escapeshellarg($sql_root['user']) . ' ' . $row['databasename'] . ' > ' . FileDir::makeCorrectFile($tmpdir . '/' . $row['databasename'] . '_' . date('YmdHi', time()) . '.sql'), $bool_false, [ - '>' - ]); - $has_dbs = true; - $current_dbserver = $row['dbserver']; - } - - if ($has_dbs) { - $this->filesToStore[] = $tmpdir; - } - - if (@file_exists($mysqlcnf_file)) { - @unlink($mysqlcnf_file); - } - } - - private function prepareMailData(): void - { - $tmpdir = FileDir::makeCorrectDir($this->tmpDirectory . '/.tmp/mail'); - FileDir::safe_exec('mkdir -p ' . escapeshellarg($tmpdir)); - - // get all customer mail-accounts - $sel_stmt = Database::prepare(" - SELECT `homedir`, `maildir` FROM `" . TABLE_MAIL_USERS . "` - WHERE `customerid` = :cid - "); - Database::pexecute($sel_stmt, [ - 'cid' => $this->sData['customerid'] - ]); - - $tar_file_list = ""; - $mail_homedir = ""; - while ($row = $sel_stmt->fetch()) { - $tar_file_list .= escapeshellarg("./" . $row['maildir']) . " "; - if (empty($mail_homedir)) { - // this should be equal for all entries - $mail_homedir = $row['homedir']; - } - } - - if (!empty($tar_file_list)) { - FileDir::safe_exec('tar cfz ' . escapeshellarg(FileDir::makeCorrectFile($tmpdir . '/' . $this->sData['loginname'] . '-mail.tar.gz')) . ' -C ' . escapeshellarg($mail_homedir) . ' ' . trim($tar_file_list)); - $this->filesToStore[] = FileDir::makeCorrectFile($tmpdir . '/' . $this->sData['loginname'] . '-mail.tar.gz'); - } - } - - /** - * Move/Upload file from tmp-source-directory. The file should be moved or deleted afterward. - * Must return the (relative) path including filename to the backup. - * - * @param string $filename - * @param string $tmp_source_directory - * @return string - */ - abstract protected function putFile(string $filename, string $tmp_source_directory): string; - - /** - * @param string $filename - * @return bool - */ - abstract protected function rmFile(string $filename): bool; - - /** - * @return bool - * @throws Exception - */ - public function removeOld(): bool - { - // retention in days - $retention = $this->sData['storage']['retention'] ?? 3; - // keep date - $keepDate = new \DateTime(); - $keepDate->setTime(0, 0, 0, 1); - // subtract retention days - $keepDate->sub(new \DateInterval('P' . $retention . 'D')); - // select target backups to remove for this storage-id and customer - $sel_stmt = Database::prepare(" - SELECT * FROM `" . TABLE_PANEL_BACKUPS . "` - WHERE `created_at` < :keepdate - AND `storage_id` = :sid - AND `customerid` = :cid - "); - Database::pexecute($sel_stmt, [ - 'keepdate' => $keepDate->format('U'), - 'sid' => $this->sData['backup'], - 'cid' => $this->sData['customerid'] - ]); - while ($oldBackup = $sel_stmt->fetch(\PDO::FETCH_ASSOC)) { - $this->rmFile($oldBackup['filename']); - } - } - - /** - * Returns the storage configured destination path for all backups - * - * @return string - * @throws Exception - */ - public function getDestinationDirectory(): string - { - return FileDir::makeCorrectDir($this->sData['storage']['destination_path'] ?? "/"); - } - - /** - * Create backup-archive/file from $filesToStore and call putFile() - * - * @return bool - * @throws Exception - */ - public function createFromFiles(): bool - { - if (empty($this->filesToStore)) { - return false; - } - - $filename = FileDir::makeCorrectFile($this->tmpDirectory . "/backup-" . $this->sData['loginname'] . "-" . date('c') . ".tar.gz"); - $tmpdir = FileDir::makeCorrectDir($this->tmpDirectory . '/.tmp/'); - $create_export_tar_data = implode(" ", $this->filesToStore); - FileDir::safe_exec('chown -R ' . (int)$this->sData['guid'] . ':' . (int)$this->sData['guid'] . ' ' . escapeshellarg($tmpdir)); - - if (!empty($data['pgp_public_key'])) { - // pack all archives in tmp-dir to one archive and encrypt it with gpg - $recipient_file = FileDir::makeCorrectFile($this->tmpDirectory . '/' . $this->sData['loginname'] . '-recipients.gpg'); - file_put_contents($recipient_file, $data['pgp_public_key']); - $return_value = []; - FileDir::safe_exec('tar cfz - -C ' . escapeshellarg($tmpdir) . ' ' . trim($create_export_tar_data) . ' | gpg --encrypt --recipient-file ' . escapeshellarg($recipient_file) . ' --output ' . escapeshellarg($filename) . ' --trust-model always --batch --yes', $return_value, ['|']); - } else { - // pack all archives in tmp-dir to one archive - FileDir::safe_exec('tar cfz ' . escapeshellarg($filename) . ' -C ' . escapeshellarg($tmpdir) . ' ' . trim($create_export_tar_data)); - } - - // determine filesize (use stat locally here b/c files are possibly large and php's filesize() can't handle them) - $fileSizeOutput = FileDir::safe_exec('/usr/bin/stat -c "%s" ' . escapeshellarg($filename)); - $fileSize = (int)array_shift($fileSizeOutput); - - // add entry to database and upload/store file - - FileDir::safe_exec('rm -rf ' . escapeshellarg($tmpdir)); - $fileDest = $this->putFile(basename($filename), $this->tmpDirectory); - if (!empty($fileDest)) { - $this->addEntry($fileDest, $fileSize); - return true; - } - return false; - } - - /** - * @param string $filename - * @param int $fileSize - * @return void - * @throws Exception - */ - private function addEntry(string $filename, int $fileSize): void - { - $ins_stmt = Database::prepare(" - INSERT INTO `" . TABLE_PANEL_BACKUPS . "` SET - `adminid` = :adminid, - `customerid` = :customerid, - `loginname` = :loginname, - `size` = :size, - `storage_id` = :sid, - `filename` = :filename, - `created_at` = UNIX_TIMESTAMP() - "); - Database::pexecute($ins_stmt, [ - 'adminid' => $this->sData['adminid'], - 'customerid' => $this->sData['customerid'], - 'loginname' => $this->sData['loginname'], - 'size' => $fileSize, - 'sid' => $this->sData['backup'], - 'filename' => $filename - ]); - } -} diff --git a/lib/Froxlor/Backup/Storages/StorageFactory.php b/lib/Froxlor/Backup/Storages/StorageFactory.php deleted file mode 100644 index 73e28a90..00000000 --- a/lib/Froxlor/Backup/Storages/StorageFactory.php +++ /dev/null @@ -1,39 +0,0 @@ - $storage_id]); - if (empty($storage)) { - throw new Exception("Invalid/empty backup-storage. Unable to continue"); - } - return $storage; - } -} diff --git a/lib/Froxlor/Cli/BackupCommand.php b/lib/Froxlor/Cli/BackupCommand.php deleted file mode 100644 index 5d24cfda..00000000 --- a/lib/Froxlor/Cli/BackupCommand.php +++ /dev/null @@ -1,129 +0,0 @@ - - * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 - */ - -namespace Froxlor\Cli; - -use Exception; -use Froxlor\Backup\Storages\StorageFactory; -use Froxlor\Database\Database; -use Froxlor\Froxlor; -use Froxlor\Settings; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\OutputInterface; - -final class BackupCommand extends CliCommand -{ - - protected function configure() - { - $this->setName('froxlor:backup'); - $this->setDescription('Various backup actions'); - $this->addOption('list', 'L', InputOption::VALUE_OPTIONAL, 'List backups (optionally pass a customer loginname to list backups of a specific user)') - ->addOption('create', 'c', InputOption::VALUE_REQUIRED, 'Manually run a backup task for given customer (loginname)') - ->addOption('delete', 'd', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Remove given backup by id'); - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $result = $this->validateRequirements($input, $output); - - require Froxlor::getInstallDir() . '/lib/functions.php'; - - // set error-handler - @set_error_handler([ - '\\Froxlor\\Api\\Api', - 'phpErrHandler' - ]); - - if (!Settings::Get('backup.enabled')) { - $output->writeln('Backup feature not enabled.'); - $result = self::INVALID; - } - - if ($result == self::SUCCESS) { - - try { - $loginname = ""; - $userinfo = []; - if ($input->hasArgument('user')) { - $loginname = $input->getArgument('user'); - $userinfo = $this->getUserByName($loginname, false); - } - - $do_list = $input->getOption('list'); - $do_create = $input->getOption('create'); - $do_delete = $input->getOption('delete'); - - if ($do_list === false && $do_create === false && $do_delete === false) { - $output->writeln('No option given, nothing to do.'); - return self::INVALID; - } - - // list - if ($do_list !== false) { - if ($do_list === null) { - // all customers - } elseif ($do_list !== false) { - // specific customer - } - } elseif ($do_create !== false) { - $stmt = Database::prepare("SELECT - customerid, - loginname, - adminid, - backup, - guid, - documentroot - FROM `" . TABLE_PANEL_CUSTOMERS . "` - WHERE `backup` > 0 AND `loginname` = :loginname - "); - $customer = Database::pexecute_first($stmt, ['loginname' => $do_create]); - - if (empty($customer)) { - $output->writeln('Given customer not found or customer has backup=off'); - return self::INVALID; - } - - $backupStorage = StorageFactory::fromStorageId($customer['backup'], $customer); - $output->writeln("Initializing storage"); - $backupStorage->init(); - $output->writeln("Preparing files and folders"); - $backupStorage->prepareFiles(); - $output->writeln("Creating backup file"); - $backupStorage->createFromFiles(); - $output->writeln("Removing older backups by retention"); - $backupStorage->removeOld(); - $output->writeln('Backup created successfully'); - } - } catch (Exception $e) { - $output->writeln('' . $e->getMessage() . ''); - $result = self::FAILURE; - } - } - - return $result; - } -} diff --git a/lib/Froxlor/Cron/Backup/BackupCron.php b/lib/Froxlor/Cron/Backup/BackupCron.php deleted file mode 100644 index 5d375622..00000000 --- a/lib/Froxlor/Cron/Backup/BackupCron.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 - */ - -namespace Froxlor\Cron\Backup; - -use Exception; -use Froxlor\Backup\Storages\StorageFactory; -use Froxlor\Cron\Forkable; -use Froxlor\Cron\FroxlorCron; -use Froxlor\Database\Database; -use Froxlor\FroxlorLogger; -use Froxlor\Settings; -use PDO; - -class BackupCron extends FroxlorCron -{ - use Forkable; - - public static function run() - { - if (!Settings::Get('backup.enabled')) { - FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'BackupCron: disabled - exiting'); - return -1; - } - - $stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_BACKUP_STORAGES . "`"); - Database::pexecute($stmt); - - $storages = []; - while ($storage = $stmt->fetch(PDO::FETCH_ASSOC)) { - $storages[$storage['id']] = $storage; - } - - $stmt = Database::prepare("SELECT - customerid, - loginname, - adminid, - backup, - guid, - documentroot - FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `backup` > 0 - "); - Database::pexecute($stmt); - - $customers = []; - while ($customer = $stmt->fetch(PDO::FETCH_ASSOC)) { - $customer['storage'] = $storages[$customer['backup']]; - $customers[] = $customer; - } - - self::runFork([self::class, 'handle'], $customers); - } - - /** - * @throws Exception - */ - private static function handle(array $userdata) - { - echo "BackupCron: started - creating customer backup for user " . $userdata['loginname'] . "\n"; - - $backupStorage = StorageFactory::fromType($userdata['storage']['type'], $userdata); - // initialize storage - $backupStorage->init(); - // do what is required to obtain files/archives and move/upload - $backupStorage->prepareFiles(); - // upload/move to target - $backupStorage->createFromFiles(); - // remove by retention - $backupStorage->removeOld(); - - echo "BackupCron: finished - creating customer backup for user " . $userdata['loginname'] . "\n"; - } -} diff --git a/lib/Froxlor/UI/Callbacks/Backup.php b/lib/Froxlor/UI/Callbacks/Backup.php deleted file mode 100644 index e4b1b217..00000000 --- a/lib/Froxlor/UI/Callbacks/Backup.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 - */ - -namespace Froxlor\UI\Callbacks; - -use Froxlor\Database\Database; -use Froxlor\UI\Panel\UI; - -class Backup -{ - public static function backupStorageLink(array $attributes) - { - $sel_stmt = Database::prepare("SELECT `description` FROM `" . TABLE_PANEL_BACKUP_STORAGES . "` WHERE `id` = :id"); - $backupstorage = Database::pexecute_first($sel_stmt, ['id' => $attributes['data']]); - if ((int)UI::getCurrentUser()['adminsession'] == 1 && UI::getCurrentUser()['change_serversettings']) { - $linker = UI::getLinker(); - $result = '' . $backupstorage['description'] . ''; - } else { - $result = $backupstorage['description']; - } - return $result; - } -} diff --git a/lib/formfields/admin/backup_storages/formfield.backup_storage_add.php b/lib/formfields/admin/backup_storages/formfield.backup_storage_add.php deleted file mode 100644 index 983f90a4..00000000 --- a/lib/formfields/admin/backup_storages/formfield.backup_storage_add.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 - */ - -use Froxlor\Settings; - -return [ - 'backup_storage_add' => [ - 'title' => lng('backup.backup_storage.add'), - 'image' => 'fa-solid fa-file-archive', - 'self_overview' => ['section' => 'backups', 'page' => 'storages'], - 'sections' => [ - 'section_a' => [ - 'title' => lng('backup.backup_storage.create'), - 'fields' => [ - 'description' => [ - 'label' => lng('backup.backup_storage.description'), - 'type' => 'text', - 'maxlength' => 200, - 'mandatory' => true, - ], - 'type' => [ - 'label' => lng('backup.backup_storage.type'), - 'type' => 'select', - 'selected' => 'local', - 'select_var' => [ - 'local' => lng('backup.backup_storage.type_local'), - 'ftp' => lng('backup.backup_storage.type_ftp'), - 'sftp' => lng('backup.backup_storage.type_sftp'), - 'rsync' => lng('backup.backup_storage.type_rsync'), - 's3' => lng('backup.backup_storage.type_s3'), - ], - 'mandatory' => true, - ], - 'region' => [ - 'label' => lng('backup.backup_storage.region'), - 'type' => 'text' - ], - 'bucket' => [ - 'label' => lng('backup.backup_storage.bucket'), - 'type' => 'text' - ], - 'destination_path' => [ - 'label' => lng('backup.backup_storage.destination_path'), - 'type' => 'text', - 'mandatory' => true, - ], - 'hostname' => [ - 'label' => lng('backup.backup_storage.hostname'), - 'type' => 'text' - ], - 'username' => [ - 'label' => lng('backup.backup_storage.username'), - 'type' => 'text' - ], - 'password' => [ - 'label' => lng('backup.backup_storage.password'), - 'type' => 'textarea', - 'autocomplete' => 'off', - ], - 'pgp_public_key' => [ - 'label' => lng('backup.backup_storage.pgp_public_key'), - 'type' => 'textarea', - 'value' => Settings::Get('backup.default_pgp_public_key') - ], - 'retention' => [ - 'label' => lng('backup.backup_storage.retention'), - 'type' => 'number', - 'min' => 0, - 'value' => Settings::Get('backup.default_retention') - ] - ] - ] - ] - ], -]; diff --git a/lib/formfields/admin/backup_storages/formfield.backup_storage_edit.php b/lib/formfields/admin/backup_storages/formfield.backup_storage_edit.php deleted file mode 100644 index 8aaaa698..00000000 --- a/lib/formfields/admin/backup_storages/formfield.backup_storage_edit.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 - */ - -return [ - 'backup_storage_edit' => [ - 'title' => lng('backup.backup_storage.edit'), - 'image' => 'fa-solid fa-file-archive', - 'self_overview' => ['section' => 'backups', 'page' => 'storages'], - 'sections' => [ - 'section_a' => [ - 'title' => lng('backup.backup_storage.edit'), - 'fields' => [ - 'description' => [ - 'label' => lng('backup.backup_storage.description'), - 'type' => 'text', - 'value' => $result['description'], - 'mandatory' => true, - ], - 'type' => [ - 'label' => lng('backup.backup_storage.type'), - 'type' => 'select', - 'selected' => $result['type'], - 'select_var' => [ - 'local' => lng('backup.backup_storage.type_local'), - 'ftp' => lng('backup.backup_storage.type_ftp'), - 'sftp' => lng('backup.backup_storage.type_sftp'), - 'rsync' => lng('backup.backup_storage.type_rsync'), - 's3' => lng('backup.backup_storage.type_s3'), - ], - 'mandatory' => true, - ], - 'region' => [ - 'label' => lng('backup.backup_storage.region'), - 'type' => 'text', - 'value' => $result['region'] - ], - 'bucket' => [ - 'label' => lng('backup.backup_storage.bucket'), - 'type' => 'text', - 'value' => $result['bucket'] - ], - 'destination_path' => [ - 'label' => lng('backup.backup_storage.destination_path'), - 'type' => 'text', - 'value' => $result['destination_path'], - 'mandatory' => true, - ], - 'hostname' => [ - 'label' => lng('backup.backup_storage.hostname'), - 'type' => 'text', - 'value' => $result['hostname'] - ], - 'username' => [ - 'label' => lng('backup.backup_storage.username'), - 'type' => 'text', - 'value' => $result['username'] - ], - 'password' => [ - 'label' => lng('backup.backup_storage.password.title'), - 'desc' => lng('backup.backup_storage.password.description') . '
(' . lng('panel.emptyfornochanges') . ')', - 'type' => 'textarea', - 'autocomplete' => 'off' - ], - 'pgp_public_key' => [ - 'label' => lng('backup.backup_storage.pgp_public_key'), - 'type' => 'textarea', - 'value' => $result['pgp_public_key'] - ], - 'retention' => [ - 'label' => lng('backup.backup_storage.retention'), - 'type' => 'number', - 'min' => 0, - 'value' => $result['retention'] - ] - ] - ] - ] - ], -]; diff --git a/lib/formfields/admin/backup_storages/index.html b/lib/formfields/admin/backup_storages/index.html deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/formfields/admin/backups/formfield.backups_add.php b/lib/formfields/admin/backups/formfield.backups_add.php deleted file mode 100644 index 9aba2c5d..00000000 --- a/lib/formfields/admin/backups/formfield.backups_add.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 - */ - -return [ - 'backups_add' => [ - 'title' => lng('backups.backups_add'), - 'image' => 'fa-solid fa-file-archive', - 'self_overview' => ['section' => 'backups', 'page' => 'storages'], - 'sections' => [] - ], -]; diff --git a/lib/formfields/admin/backups/formfield.backups_edit.php b/lib/formfields/admin/backups/formfield.backups_edit.php deleted file mode 100644 index dea4d84f..00000000 --- a/lib/formfields/admin/backups/formfield.backups_edit.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 - */ - -return [ - 'backups_edit' => [ - 'title' => lng('backups.backups_edit'), - 'image' => 'fa-solid fa-file-archive', - 'self_overview' => ['section' => 'backups', 'page' => 'admins'], - 'sections' => [] - ], -]; diff --git a/lib/formfields/admin/backups/formfield.backups_restore.php b/lib/formfields/admin/backups/formfield.backups_restore.php deleted file mode 100644 index 36b13fcf..00000000 --- a/lib/formfields/admin/backups/formfield.backups_restore.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 - */ - -return [ - 'backups_restore' => [ - 'title' => lng('backups.backups_restore'), - 'image' => 'fa-solid fa-file-archive', - 'self_overview' => ['section' => 'backups', 'page' => 'storages'], - 'sections' => [] - ], -]; diff --git a/lib/formfields/admin/backups/index.html b/lib/formfields/admin/backups/index.html deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/formfields/admin/customer/formfield.customer_add.php b/lib/formfields/admin/customer/formfield.customer_add.php index 91579890..77831b7a 100644 --- a/lib/formfields/admin/customer/formfield.customer_add.php +++ b/lib/formfields/admin/customer/formfield.customer_add.php @@ -316,21 +316,6 @@ return [ 'value' => '1', 'checked' => true ], - 'backup' => [ - 'label' => lng('backup.backup_storage.title'), - 'desc' => lng('backup.backup_storage.description'), - 'type' => 'select', - 'select_var' => $backup_storages, - 'selected' => Settings::Get('backup.default_storage'), - 'visible' => Settings::Get('backup.enabled') == '1' && $userinfo['change_serversettings'] == '1' - ], - 'access_backups' => [ - 'label' => lng('backup.access_backups'), - 'type' => 'checkbox', - 'value' => '1', - 'checked' => Settings::Get('backup.enabled') == '1' && Settings::Get('backup.default_customer_access'), - 'visible' => Settings::Get('backup.enabled') == '1' && ($userinfo['change_serversettings'] == '1' || Settings::Get('backup.default_customer_access')) - ], ] ] ] diff --git a/lib/formfields/admin/customer/formfield.customer_edit.php b/lib/formfields/admin/customer/formfield.customer_edit.php index f873e731..a6ce7c57 100644 --- a/lib/formfields/admin/customer/formfield.customer_edit.php +++ b/lib/formfields/admin/customer/formfield.customer_edit.php @@ -324,21 +324,6 @@ return [ 'value' => '1', 'checked' => $result['logviewenabled'] ], - 'backup' => [ - 'label' => lng('backup.backup_storage.title'), - 'desc' => lng('backup.backup_storage.description'), - 'type' => 'select', - 'select_var' => $backup_storages, - 'selected' => $result['backup'], - 'visible' => Settings::Get('backup.enabled') == '1' && $userinfo['change_serversettings'] == '1' - ], - 'access_backups' => [ - 'label' => lng('backup.access_backups'), - 'type' => 'checkbox', - 'value' => '1', - 'checked' => $result['access_backups'], - 'visible' => Settings::Get('backup.enabled') == '1' && ($userinfo['change_serversettings'] == '1' || Settings::Get('backup.default_customer_access')) - ], ] ], 'section_d' => [ diff --git a/lib/navigation/00.froxlor.main.php b/lib/navigation/00.froxlor.main.php index 36b93357..aa2c8624 100644 --- a/lib/navigation/00.froxlor.main.php +++ b/lib/navigation/00.froxlor.main.php @@ -261,11 +261,6 @@ return [ 'label' => lng('admin.cron.cronsettings'), 'required_resources' => 'change_serversettings' ], - [ - 'url' => 'admin_backups.php?page=overview', - 'label' => lng('admin.backups.backups'), - 'show_element' => (Settings::Get('backup.enabled') == true) - ], [ 'url' => 'admin_logger.php?page=log', 'label' => lng('menue.logger.logger'), diff --git a/lib/tablelisting/admin/tablelisting.backup_storages.php b/lib/tablelisting/admin/tablelisting.backup_storages.php deleted file mode 100644 index 83b6506d..00000000 --- a/lib/tablelisting/admin/tablelisting.backup_storages.php +++ /dev/null @@ -1,123 +0,0 @@ - - * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 - */ - -use Froxlor\UI\Callbacks\Admin; -use Froxlor\UI\Callbacks\Customer; -use Froxlor\UI\Callbacks\Impersonate; -use Froxlor\UI\Callbacks\PHPConf; -use Froxlor\UI\Callbacks\ProgressBar; -use Froxlor\UI\Callbacks\Style; -use Froxlor\UI\Callbacks\Text; -use Froxlor\UI\Listing; - -return [ - 'backup_storages_list' => [ - 'title' => lng('backup.backup_storage.list'), - 'icon' => 'fa-solid fa-file-archive', - 'self_overview' => ['section' => 'backups', 'page' => 'storages'], - 'default_sorting' => ['description' => 'asc'], - 'columns' => [ - 'id' => [ - 'label' => 'ID', - 'field' => 'id', - 'sortable' => true, - ], - 'description' => [ - 'label' => lng('backup.backup_storage.description'), - 'field' => 'description', - 'sortable' => true, - ], - 'type' => [ - 'label' => lng('backup.backup_storage.type'), - 'field' => 'type', - 'sortable' => true, - ], - 'region' => [ - 'label' => lng('backup.backup_storage.region'), - 'field' => 'region', - 'sortable' => true, - ], - 'bucket' => [ - 'label' => lng('backup.backup_storage.bucket'), - 'field' => 'bucket', - 'sortable' => true, - ], - 'destination_path' => [ - 'label' => lng('backup.backup_storage.destination_path.title'), - 'field' => 'destination_path', - 'sortable' => true, - ], - 'hostname' => [ - 'label' => lng('backup.backup_storage.hostname'), - 'field' => 'hostname', - 'sortable' => true, - ], - 'username' => [ - 'label' => lng('backup.backup_storage.username'), - 'field' => 'username', - 'sortable' => true, - ], - 'retention' => [ - 'label' => lng('backup.backup_storage.retention'), - 'field' => 'retention', - 'sortable' => true, - ], - ], - 'visible_columns' => Listing::getVisibleColumnsForListing('backup_storages_list', [ - 'id', - 'description', - 'type', - 'retention', - ]), - 'actions' => [ - 'show' => [ - 'icon' => 'fa-solid fa-eye', - 'title' => lng('usersettings.custom_notes.title'), - ], - 'edit' => [ - 'icon' => 'fa-solid fa-edit', - 'title' => lng('panel.edit'), - 'href' => [ - 'section' => 'backups', - 'page' => 'storages', - 'action' => 'edit', - 'id' => ':id' - ], - ], - 'delete' => [ - 'icon' => 'fa-solid fa-trash', - 'title' => lng('panel.delete'), - 'class' => 'btn-danger', - 'href' => [ - 'section' => 'backups', - 'page' => 'storages', - 'action' => 'delete', - 'id' => ':id' - ], - 'visible' => [PHPConf::class, 'isNotDefault'] - ], - ], - ] -]; diff --git a/lib/tablelisting/admin/tablelisting.backups.php b/lib/tablelisting/admin/tablelisting.backups.php deleted file mode 100644 index 92341374..00000000 --- a/lib/tablelisting/admin/tablelisting.backups.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 - */ - -use Froxlor\UI\Callbacks\Admin; -use Froxlor\UI\Callbacks\Backup; -use Froxlor\UI\Callbacks\Customer; -use Froxlor\UI\Callbacks\Impersonate; -use Froxlor\UI\Callbacks\ProgressBar; -use Froxlor\UI\Callbacks\Style; -use Froxlor\UI\Callbacks\Text; -use Froxlor\UI\Listing; - -return [ - 'backups_list' => [ - 'title' => lng('admin.backups.backups'), - 'icon' => 'fa-solid fa-file-archive', - 'self_overview' => ['section' => 'admins', 'page' => 'admins'], - 'default_sorting' => ['loginname' => 'asc'], - 'columns' => [ - 'id' => [ - 'label' => 'ID', - 'field' => 'id', - 'sortable' => true, - ], - 'customerid' => [ - 'label' => lng('customerid'), - 'field' => 'customerid', - 'sortable' => true, - ], - 'loginname' => [ - 'label' => lng('login.username'), - 'field' => 'loginname', - 'callback' => [Impersonate::class, 'customer'], - 'sortable' => true, - ], - 'adminid' => [ - 'label' => lng('adminid'), - 'field' => 'adminid', - 'sortable' => true, - ], - 'adminname' => [ - 'label' => lng('admin.admin'), - 'field' => 'adminname', - 'callback' => [Impersonate::class, 'admin'], - ], - 'size' => [ - 'label' => lng('backup.size'), - 'field' => 'size', - 'sortable' => true, - 'callback' => [Text::class, 'size'], - ], - 'storage_id' => [ - 'label' => lng('backup.backup_storage.title'), - 'field' => 'storage_id', - 'class' => 'text-center', - 'callback' => [Backup::class, 'backupStorageLink'], - ], - 'filename' => [ - 'label' => lng('backup.size'), - 'field' => 'filename', - 'sortable' => true, - ], - 'created_at' => [ - 'label' => lng('backup.created_at'), - 'field' => 'created_at', - 'sortable' => true, - 'callback' => [Text::class, 'timestamp'], - ], - ], - 'visible_columns' => Listing::getVisibleColumnsForListing('backups_list', [ - 'id', - 'adminname', - 'loginname', - 'size', - 'created_at', - ]), - 'actions' => [ - 'delete' => [ - 'icon' => 'fa-solid fa-trash', - 'title' => lng('panel.delete'), - 'class' => 'btn-danger', - 'href' => [ - 'section' => 'backups', - 'page' => 'storages', - 'action' => 'delete', - 'id' => ':id' - ], - 'visible' => [Admin::class, 'canChangeServerSettings'], - ], - ] - ] -]; diff --git a/lib/tablelisting/admin/tablelisting.customers.php b/lib/tablelisting/admin/tablelisting.customers.php index 847b12f2..de3e8fb5 100644 --- a/lib/tablelisting/admin/tablelisting.customers.php +++ b/lib/tablelisting/admin/tablelisting.customers.php @@ -23,13 +23,11 @@ * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 */ -use Froxlor\Settings; -use Froxlor\UI\Callbacks\Backup; use Froxlor\UI\Callbacks\Customer; use Froxlor\UI\Callbacks\Impersonate; use Froxlor\UI\Callbacks\ProgressBar; -use Froxlor\UI\Callbacks\Text; use Froxlor\UI\Callbacks\Style; +use Froxlor\UI\Callbacks\Text; use Froxlor\UI\Listing; return [ @@ -151,20 +149,6 @@ return [ 'class' => 'text-center', 'callback' => [Text::class, 'boolean'], ], - 'c.backup' => [ - 'label' => lng('backup.backup_storage.title'), - 'field' => 'backup', - 'class' => 'text-center', - 'callback' => [Backup::class, 'backupStorageLink'], - 'visible' => (bool)Settings::Get('backup.enabled'), - ], - 'c.access_backups' => [ - 'label' => lng('backup.access_backups'), - 'field' => 'access_backups', - 'class' => 'text-center', - 'callback' => [Text::class, 'boolean'], - 'visible' => (bool)Settings::Get('backup.enabled'), - ], ], 'visible_columns' => Listing::getVisibleColumnsForListing('customer_list', [ 'c.name', diff --git a/lib/tables.inc.php b/lib/tables.inc.php index 2e8d1fa9..26214333 100644 --- a/lib/tables.inc.php +++ b/lib/tables.inc.php @@ -32,8 +32,6 @@ const TABLE_MAIL_USERS = 'mail_users'; const TABLE_MAIL_VIRTUAL = 'mail_virtual'; const TABLE_PANEL_ACTIVATION = 'panel_activation'; const TABLE_PANEL_ADMINS = 'panel_admins'; -const TABLE_PANEL_BACKUPS = 'panel_backups'; -const TABLE_PANEL_BACKUP_STORAGES = 'panel_backup_storages'; const TABLE_PANEL_CUSTOMERS = 'panel_customers'; const TABLE_PANEL_DATABASES = 'panel_databases'; const TABLE_PANEL_DOMAINS = 'panel_domains'; diff --git a/lng/de.lng.php b/lng/de.lng.php index 3abeec91..269837c1 100644 --- a/lng/de.lng.php +++ b/lng/de.lng.php @@ -2296,39 +2296,4 @@ Vielen Dank, Ihr Administrator', 'config_note' => 'Damit froxlor mit dem Backend vernünftig kommunizieren kann, musst du dieses noch konfigurieren.', 'config_now' => 'Jetzt konfigurieren' ], - 'backup' => [ - 'backup' => 'Backup', - 'backups' => 'Backups', - 'backups_restore' => 'Wiederherstellen', - 'backup_storages' => 'Speichermedien verwalten', - 'size' => 'Größe', - 'created_at' => 'Erstellt', - 'backup_storage' => [ - 'add' => 'Speichermedium hinzufügen', - 'create' => 'Neues Speichermedium erstellen', - 'edit' => 'Speichermedien bearbeiten', - 'list' => 'Speichermedien', - 'description' => 'Beschreibung', - 'type' => 'Typ', - 'type_local' => 'Lokales Dateisystem', - 'type_ftp' => 'FTP Server', - 'type_sftp' => 'SFTP auf entfernten Server', - 'type_rsync' => 'Rsync zu entfernten Server', - 'type_s3' => 'S3 Server', - 'region' => 'S3 Region', - 'bucket' => 'S3 Bucket', - 'destination_path' => [ - 'title' => 'Ziel-Pfad', - 'description' => 'Absoluter Pfad, wenn Speicher-Typ ist "lokal", sonst relativ zum Heimatverzeichnisses des Benutzers', - ], - 'hostname' => 'Ziel Hostname', - 'username' => 'Benutzername', - 'password' => [ - 'title' => 'Passwort oder SSH Public-key', - 'description' => 'Es kann entweder ein Passwort oder ein vollständiger SSH Public-Key angegeben werden' - ], - 'pgp_public_key' => 'PGP Public-key', - 'retention' => 'Backup-Aufbewahrung in Tagen', - ], - ], ]; diff --git a/lng/en.lng.php b/lng/en.lng.php index 15ef2d92..410b3c4c 100644 --- a/lng/en.lng.php +++ b/lng/en.lng.php @@ -2430,39 +2430,4 @@ Yours sincerely, your administrator', 'config_note' => 'In order for froxlor to be able to communicate properly with the backend, you have to configure it.', 'config_now' => 'Configure now' ], - 'backup' => [ - 'backup' => 'Backup', - 'backups' => 'Backups', - 'backups_restore' => 'Restore backups', - 'backup_storages' => 'Configure storages', - 'size' => 'Size', - 'created_at' => 'Created at', - 'backup_storage' => [ - 'add' => 'Add backup storage', - 'create' => 'Create new backup storage', - 'edit' => 'Edit backup storage', - 'list' => 'Backup storages', - 'description' => 'Storage description', - 'type' => 'Storage type', - 'type_local' => 'local filesystem', - 'type_ftp' => 'FTP server', - 'type_sftp' => 'SFTP to remote server', - 'type_rsync' => 'Rsync to remote server', - 'type_s3' => 'S3 server', - 'region' => 'S3 region', - 'bucket' => 'S3 bucket', - 'destination_path' => [ - 'title' => 'Destination path', - 'description' => 'Absolute path if storage type is "local", else relative to home-directory of given user', - ], - 'hostname' => 'Target hostname', - 'username' => 'Username', - 'password' => [ - 'title' => 'Password or ssh public-key', - 'description' => 'Can be either a password or a complete SSH public key' - ], - 'pgp_public_key' => 'PGP public key', - 'retention' => 'Backup retention in days', - ], - ], ];