From a232e24d0c6066ac684429d3ac83d372055f2d5e Mon Sep 17 00:00:00 2001 From: ghost Date: Thu, 14 Sep 2023 01:34:54 +0300 Subject: [PATCH] add separated import/export settings --- example/environment/env.example.php | 25 +++++++++++++++++-------- src/crontab/export/feed.php | 26 +++++++++++++------------- src/public/action.php | 2 +- src/public/download.php | 2 +- src/public/edit.php | 2 +- src/public/faq.php | 2 +- src/public/index.php | 2 +- src/public/magnet.php | 2 +- src/public/node.php | 2 +- src/public/welcome.php | 2 +- 10 files changed, 38 insertions(+), 29 deletions(-) diff --git a/example/environment/env.example.php b/example/environment/env.example.php index 7a8548e..9afd58a 100644 --- a/example/environment/env.example.php +++ b/example/environment/env.example.php @@ -123,11 +123,20 @@ define('NODE_RULE_LANGUAGES', 'All'); // API define('API_VERSION', 1); -define('API_ENABLED', true); - -define('API_FEED_USERS_ENABLED', true); -define('API_FEED_MAGNETS_ENABLED', true); -define('API_FEED_DOWNLOADS_ENABLED', true); -define('API_FEED_COMMENTS_ENABLED', true); -define('API_FEED_STARS_ENABLED', true); -define('API_FEED_VIEWS_ENABLED', true); \ No newline at end of file +define('API_EXPORT_ENABLED', true); + +define('API_EXPORT_USERS_ENABLED', true); +define('API_EXPORT_MAGNETS_ENABLED', true); +define('API_EXPORT_DOWNLOADS_ENABLED', true); +define('API_EXPORT_COMMENTS_ENABLED', true); +define('API_EXPORT_STARS_ENABLED', true); +define('API_EXPORT_VIEWS_ENABLED', true); + +define('API_IMPORT_ENABLED', true); + +define('API_IMPORT_USERS_ENABLED', true); +define('API_IMPORT_MAGNETS_ENABLED', true); +define('API_IMPORT_DOWNLOADS_ENABLED', true); +define('API_IMPORT_COMMENTS_ENABLED', true); +define('API_IMPORT_STARS_ENABLED', true); +define('API_IMPORT_VIEWS_ENABLED', true); \ No newline at end of file diff --git a/src/crontab/export/feed.php b/src/crontab/export/feed.php index c8bac08..82ac5b9 100644 --- a/src/crontab/export/feed.php +++ b/src/crontab/export/feed.php @@ -45,7 +45,7 @@ try @unlink(__DIR__ . '/../public/api/stars.json'); @unlink(__DIR__ . '/../public/api/views.json'); - if (API_ENABLED) + if (API_EXPORT_ENABLED) { // Manifest $manifest = @@ -91,12 +91,12 @@ try 'MAGNET_STOP_WORDS_SIMILAR' => MAGNET_STOP_WORDS_SIMILAR, ], - 'users' => API_FEED_USERS_ENABLED ? sprintf('%s/api/users.json', WEBSITE_URL) : false, - 'magnets' => API_FEED_MAGNETS_ENABLED ? sprintf('%s/api/magnets.json', WEBSITE_URL) : false, - 'downloads' => API_FEED_DOWNLOADS_ENABLED ? sprintf('%s/api/downloads.json', WEBSITE_URL) : false, - 'comments' => API_FEED_COMMENTS_ENABLED ? sprintf('%s/api/comments.json', WEBSITE_URL) : false, - 'stars' => API_FEED_STARS_ENABLED ? sprintf('%s/api/stars.json', WEBSITE_URL) : false, - 'views' => API_FEED_VIEWS_ENABLED ? sprintf('%s/api/views.json', WEBSITE_URL) : false, + 'users' => API_EXPORT_USERS_ENABLED ? sprintf('%s/api/users.json', WEBSITE_URL) : false, + 'magnets' => API_EXPORT_MAGNETS_ENABLED ? sprintf('%s/api/magnets.json', WEBSITE_URL) : false, + 'downloads' => API_EXPORT_DOWNLOADS_ENABLED ? sprintf('%s/api/downloads.json', WEBSITE_URL) : false, + 'comments' => API_EXPORT_COMMENTS_ENABLED ? sprintf('%s/api/comments.json', WEBSITE_URL) : false, + 'stars' => API_EXPORT_STARS_ENABLED ? sprintf('%s/api/stars.json', WEBSITE_URL) : false, + 'views' => API_EXPORT_VIEWS_ENABLED ? sprintf('%s/api/views.json', WEBSITE_URL) : false, 'totals' => [ @@ -144,7 +144,7 @@ try } // Users - if (API_FEED_USERS_ENABLED) + if (API_EXPORT_USERS_ENABLED) { $users = []; @@ -181,7 +181,7 @@ try } // Magnets - if (API_FEED_MAGNETS_ENABLED) + if (API_EXPORT_MAGNETS_ENABLED) { $magnets = []; @@ -320,7 +320,7 @@ try } // Downloads - if (API_FEED_DOWNLOADS_ENABLED) + if (API_EXPORT_DOWNLOADS_ENABLED) { $downloads = []; @@ -349,7 +349,7 @@ try } // Comments - if (API_FEED_COMMENTS_ENABLED) + if (API_EXPORT_COMMENTS_ENABLED) { $comments = []; @@ -378,7 +378,7 @@ try } // Stars - if (API_FEED_STARS_ENABLED) + if (API_EXPORT_STARS_ENABLED) { $stars = []; @@ -407,7 +407,7 @@ try } } // Views - if (API_FEED_VIEWS_ENABLED) + if (API_EXPORT_VIEWS_ENABLED) { $views = []; diff --git a/src/public/action.php b/src/public/action.php index 6916605..ebfbda5 100644 --- a/src/public/action.php +++ b/src/public/action.php @@ -707,7 +707,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false) | - + | diff --git a/src/public/download.php b/src/public/download.php index a2ce8cf..1718172 100644 --- a/src/public/download.php +++ b/src/public/download.php @@ -309,7 +309,7 @@ else | - + | diff --git a/src/public/edit.php b/src/public/edit.php index b1a2a63..e07d3b3 100644 --- a/src/public/edit.php +++ b/src/public/edit.php @@ -862,7 +862,7 @@ else { | - + | diff --git a/src/public/faq.php b/src/public/faq.php index f3231f5..f9a0434 100644 --- a/src/public/faq.php +++ b/src/public/faq.php @@ -226,7 +226,7 @@ else if (is_null($user->public)) | - + | diff --git a/src/public/index.php b/src/public/index.php index cba8fba..a29a40c 100644 --- a/src/public/index.php +++ b/src/public/index.php @@ -424,7 +424,7 @@ echo '' . PHP_EOL ?> | - + | diff --git a/src/public/magnet.php b/src/public/magnet.php index 567133e..5e9adb6 100644 --- a/src/public/magnet.php +++ b/src/public/magnet.php @@ -499,7 +499,7 @@ echo '' . PHP_EOL ?> | - + | diff --git a/src/public/node.php b/src/public/node.php index 777f18c..ff61f68 100644 --- a/src/public/node.php +++ b/src/public/node.php @@ -470,7 +470,7 @@ else if (is_null($user->public)) | - + | diff --git a/src/public/welcome.php b/src/public/welcome.php index 3cbb3d9..33eb8a3 100644 --- a/src/public/welcome.php +++ b/src/public/welcome.php @@ -144,7 +144,7 @@ else if (isset($_POST['public'])) | - + |