diff --git a/CHANGELOG.md b/CHANGELOG.md index 28dc78b29..8a49462bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ **Merged pull requests:** - Release 2.4.5 🦕 ([belomaxorka](https://github.com/belomaxorka)) -- [CLI] TorrentPier installer ☕️ [\#1576](https://github.com/torrentpier/torrentpier/pull/1576) ([belomaxorka](https://github.com/belomaxorka)) +- [CLI] TorrentPier installer ☕️ [\#1576](https://github.com/torrentpier/torrentpier/pull/1576), [\#1582](https://github.com/torrentpier/torrentpier/pull/1582) ([belomaxorka](https://github.com/belomaxorka)) - Added some new HTML meta-tags [\#1562](https://github.com/torrentpier/torrentpier/pull/1562) ([belomaxorka](https://github.com/belomaxorka)) - Added showing releaser stats in profile [\#1568](https://github.com/torrentpier/torrentpier/pull/1568) ([belomaxorka](https://github.com/belomaxorka)) - Fixed `md5()` deprecated in PHP 8.4 [\#1561](https://github.com/torrentpier/torrentpier/pull/1561) ([belomaxorka](https://github.com/belomaxorka)) diff --git a/README.md b/README.md index 78336faea..429d4bc99 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ For installation, you need to follow a few simple steps. 1. Install [Composer](https://getcomposer.org/) 2. Run `composer create-project torrentpier/torrentpier` 3. After run `composer install` on the project directory -4. Create database and import dump located at **install/sql/mysql.sql** +4. Create database and import dump located at `install/sql/mysql.sql` 5. Edit database configuration settings in the environment (`.env.example`, after rename to `.env`) 6. Voila! ✨ @@ -81,13 +81,13 @@ For installation, you need to follow a few simple steps. 1. Edit domain name and domain port in the configuration file or a local copy (`$reserved_name` and `$reserved_port`) 2. Edit this files: - 1. **favicon.png** (change on your own) - 2. **robots.txt** (change the addresses in lines `Host` and `Sitemap` on your own) - 3. **opensearch_desc.xml** (change the description and address on your own) - 4. **opensearch_desc_bt.xml** (change the description and address on your own) + 1. `favicon.png` (change on your own) + 2. `robots.txt` (change the addresses in lines `Host` and `Sitemap` on your own) + 3. `opensearch_desc.xml` (change the description and address on your own) + 4. `opensearch_desc_bt.xml` (change the description and address on your own) 3. Log in to the forum with **admin/admin** login/password and finish setting up via admin panel -## 🔑 Access rights on folders and files +### 🔑 Access rights on folders and files (For manual installation only!) You must provide write permissions to the specified folders: * `data/avatars` @@ -108,8 +108,8 @@ If you discover a security vulnerability within TorrentPier, please follow our [ ## 📌 Our recommendations -* *The recommended way to run cron.php.* - For significant tracker speed increase may be required to replace built-in cron.php by operating system daemon. -* *Local configuration copy.* - You can override the settings using local configuration file **library/config.local.php**. +* *The recommended way to run `cron.php`.* - For significant tracker speed increase may be required to replace built-in cron.php by operating system daemon. +* *Local configuration copy.* - You can override the settings using local configuration file `library/config.local.php`. ## 💚 Contributing / Contributors diff --git a/install.php b/install.php index 3c212bda7..33ff6e7b6 100644 --- a/install.php +++ b/install.php @@ -40,7 +40,7 @@ function out(string $str, string $type = ''): void 'warning' => "\033[33m$str \033[0m\n", 'info' => "\033[36m$str \033[0m\n", 'debug' => "\033[90m$str \033[0m\n", - default => $str, + default => "$str\n", }; } @@ -90,8 +90,48 @@ function runProcess(string $cmd, string $input = null): void proc_close($process); } +/** + * Setting permissions recursively + * + * @param string $dir + * @param int $dirPermissions + * @param int $filePermissions + * @return void + */ +function chmod_r(string $dir, int $dirPermissions, int $filePermissions): void +{ + $dp = opendir($dir); + while ($file = readdir($dp)) { + if (($file == '.') || ($file == '..')) { + continue; + } + + $fullPath = realpath($dir . '/' . $file); + if (is_dir($fullPath)) { + out("- Directory: $fullPath"); + chmod($fullPath, $dirPermissions); + chmod_r($fullPath, $dirPermissions, $filePermissions); + } elseif (is_file($fullPath)) { + out("- File: $fullPath"); + chmod($fullPath, $filePermissions); + } else { + out("- Cannot find target path: $fullPath", 'error'); + return; + } + } + + closedir($dp); +} + // Welcoming message -out("- TorrentPier Installer\n", 'info'); +out("--- TorrentPier Installer ---\n", 'info'); + +// Setting permissions +out('- Setting permissions for folders...', 'info'); +chmod_r(ROOT . 'data', 0755, 0644); +chmod_r(ROOT . 'internal_data', 0755, 0644); +chmod_r(ROOT . 'sitemap', 0755, 0644); +out("- Permissions successfully applied!\n", 'success'); // Check composer installation if (!is_file(ROOT . 'vendor/autoload.php')) { @@ -145,7 +185,7 @@ $DB_USERNAME = ''; $DB_PASSWORD = ''; if (is_file(ROOT . '.env')) { - out("--- Configuring TorrentPier ---\n", 'info'); + out("--- Configuring TorrentPier ---", 'info'); $envContent = file_get_contents(ROOT . '.env'); if ($envContent === false) { @@ -166,8 +206,8 @@ if (is_file(ROOT . '.env')) { $$key = $value; } - out("Current value of $key: $value", 'debug'); - out("Enter a new value for $key (or leave empty to not change): "); + out("\nCurrent value of $key: $value", 'debug'); + echo "Enter a new value for $key (or leave empty to not change): "; $newValue = readline(); if (!empty($newValue)) {