diff --git a/.cliffignore b/.cliffignore
new file mode 100644
index 000000000..187668fd1
--- /dev/null
+++ b/.cliffignore
@@ -0,0 +1,7 @@
+9766c534bddad8e82e6d19f9bad5cf70b9887f9a
+92ce77ec0ec703c08a659419087a373f76e711f7
+2d53efc945c7747be1755d0b66557a86bdc12cbd
+602137b65129b817811b80975a369ebde3270c6d
+4eb26ae37e1f4c82a45961517ffeb54c20200408
+e59adce848a9e10ee5775254045cbbd915236b8b
+9e0a64108d62236ab07b3f8d10e8c78269b8e1d1
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000..ddde48ba4
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,19 @@
+# EditorConfig helps developers define and maintain consistent
+# coding styles between different editors and IDEs
+# editorconfig.org
+
+root = true
+
+[*]
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+indent_style = space
+indent_size = 2
+
+[*.{diff,md}]
+trim_trailing_whitespace = false
+
+[*.{php,tpl}]
+indent_size = 4
diff --git a/.env.example b/.env.example
new file mode 100644
index 000000000..c0776eda9
--- /dev/null
+++ b/.env.example
@@ -0,0 +1,13 @@
+# Common params
+TP_HOST=example.com
+TP_PORT=80
+APP_ENV=production
+APP_CRON_ENABLED=true
+APP_DEMO_MODE=false
+
+# Database credentials
+DB_HOST=localhost
+DB_PORT=3306
+DB_DATABASE=torrentpier
+DB_USERNAME=root
+DB_PASSWORD=secret
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 000000000..0baf955a6
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,4 @@
+# These are supported funding model platforms
+
+github: torrentpier
+open_collective: torrentpier
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
new file mode 100644
index 000000000..c3a7bf266
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -0,0 +1,62 @@
+name: Bug Report
+description: File a bug report
+title: "[Bug]"
+labels: [Bug]
+body:
+ - type: markdown
+ attributes:
+ value: |
+ Thanks for taking the time to fill out this bug report!
+ The more detailed this bug report is, the faster it can be reviewed and fixed.
+ - type: input
+ id: version-torrentpier
+ attributes:
+ label: TorrentPier Version
+ description: TorrentPier version your using?
+ placeholder: 2.4.0
+ validations:
+ required: true
+ - type: input
+ id: version-php-os
+ attributes:
+ label: PHP & Platform
+ description: Exact PHP and Platform (OS) versions your using.
+ placeholder: 8.2.2 - Ubuntu 22.04 x64
+ validations:
+ required: true
+ - type: checkboxes
+ id: requirements
+ attributes:
+ label: Have you done this?
+ options:
+ - label: I am willing to share my stack trace and logs
+ required: true
+ - label: I can suggest a fix as a Pull Request
+ required: false
+ - type: textarea
+ id: expectation
+ attributes:
+ label: Expectation
+ description: Write what you expect to (correctly) happen.
+ placeholder: When I do this, I expect to this to happen.
+ validations:
+ required: true
+ - type: textarea
+ id: description
+ attributes:
+ label: Description
+ description: Write what (incorrectly) happens instead.
+ placeholder: Instead, when I do this, I receive that.
+ validations:
+ required: true
+ - type: textarea
+ id: logs
+ attributes:
+ label: Stack trace & logs
+ description: |
+ If you have a stack trace, you can copy it here. You may hide sensitive information.
+ Including a stack trace when reporting an error 500 is required.
+ placeholder: This is automatically formatted into code, no need for backticks.
+ render: shell
+ validations:
+ required: false
diff --git a/.github/ISSUE_TEMPLATE/feature---enhancement-request.md b/.github/ISSUE_TEMPLATE/feature---enhancement-request.md
new file mode 100644
index 000000000..9f68fc3a6
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature---enhancement-request.md
@@ -0,0 +1,7 @@
+---
+name: Feature / Enhancement request
+about: Suggest an idea for TorrentPier
+title: "[Feature]"
+labels: [Feature, Enhancement]
+assignees: ''
+---
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 000000000..28f94a001
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,16 @@
+# To get started with Dependabot version updates, you'll need to specify which
+# package ecosystems to update and where the package manifests are located.
+# Please see the documentation for all configuration options:
+# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
+
+version: 2
+
+updates:
+ - package-ecosystem: "composer"
+ directory: "/"
+ versioning-strategy: increase-if-necessary
+ commit-message:
+ prefix: "Composer"
+ include: "scope"
+ schedule:
+ interval: "daily"
diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml
new file mode 100644
index 000000000..f257360c6
--- /dev/null
+++ b/.github/workflows/cd.yml
@@ -0,0 +1,80 @@
+name: Continuous Deployment
+
+on:
+ push:
+ tags:
+ - "v*.*.*"
+
+jobs:
+ generate-changelog:
+ name: Generate changelog
+ runs-on: ubuntu-22.04
+ outputs:
+ release_body: ${{ steps.git-cliff.outputs.content }}
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Generate a changelog
+ uses: orhun/git-cliff-action@v4
+ id: git-cliff
+ with:
+ config: cliff.toml
+ args: -vv --latest --no-exec --github-repo ${{ github.repository }}
+
+ - name: Print the changelog
+ run: cat "${{ steps.git-cliff.outputs.changelog }}"
+
+ release:
+ name: Create release
+ needs: [ generate-changelog ]
+ runs-on: ubuntu-22.04
+
+ steps:
+ - uses: actions/checkout@v4
+ - name: Set the release version
+ shell: bash
+ run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: '8.2'
+
+ - name: Install Composer dependencies
+ run: composer install --no-dev --no-progress --prefer-dist --optimize-autoloader
+
+ - name: Cleanup
+ run: php _cleanup.php && rm _cleanup.php
+
+ - name: Create archive
+ id: create-zip
+ run: |
+ ZIP_NAME="torrentpier-v${{ env.RELEASE_VERSION }}.zip"
+ zip -r "$ZIP_NAME" . -x ".git/*"
+ echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_OUTPUT
+
+ - name: Publish to GitHub
+ if: ${{ !contains(github.ref, '-') }}
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: ${{ steps.create-zip.outputs.ZIP_NAME }}
+ overwrite: true
+ tag: ${{ github.ref }}
+ release_name: "v${{ env.RELEASE_VERSION }}"
+ body: "${{ needs.generate-changelog.outputs.release_body }}"
+
+ - name: Publish to GitHub (pre-release)
+ if: ${{ contains(github.ref, '-') }}
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: ${{ steps.create-zip.outputs.ZIP_NAME }}
+ overwrite: true
+ tag: ${{ github.ref }}
+ release_name: "v${{ env.RELEASE_VERSION }}"
+ body: "${{ needs.generate-changelog.outputs.release_body }}"
+ prerelease: true
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 000000000..d4fd0b722
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,45 @@
+name: Continuous Integration
+
+on:
+ push:
+ branches:
+ - master
+
+jobs:
+ nightly:
+ name: Nightly builds 📦
+ runs-on: ubuntu-22.04
+
+ steps:
+ - name: Checkout code 🗳
+ uses: actions/checkout@v4
+
+ - name: Setup PHP 🔩
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: '8.2'
+
+ - name: Install Composer dependencies 🪚
+ run: composer install --no-dev --no-progress --prefer-dist --optimize-autoloader
+
+ - name: Get commit hash 🔗
+ id: get-commit-hash
+ run: |
+ COMMIT_HASH=$(git rev-parse --short HEAD)
+ echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_OUTPUT
+
+ - name: Cleanup
+ run: php _cleanup.php && rm _cleanup.php
+
+ - name: Create archive 🗞
+ id: create-zip
+ run: |
+ ZIP_NAME="torrentpier-${{ steps.get-commit-hash.outputs.COMMIT_HASH }}.zip"
+ zip -r "$ZIP_NAME" . -x ".git/*"
+ echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_OUTPUT
+
+ - name: Upload Archive 📤
+ uses: actions/upload-artifact@v4
+ with:
+ name: TorrentPier-master
+ path: ${{ steps.create-zip.outputs.ZIP_NAME }}
diff --git a/.github/workflows/phpmd.yml b/.github/workflows/phpmd.yml
new file mode 100644
index 000000000..3e06d7538
--- /dev/null
+++ b/.github/workflows/phpmd.yml
@@ -0,0 +1,57 @@
+# This workflow uses actions that are not certified by GitHub.
+# They are provided by a third-party and are governed by
+# separate terms of service, privacy policy, and support
+# documentation.
+# PHPMD is a spin-off project of PHP Depend and
+# aims to be a PHP equivalent of the well known Java tool PMD.
+# What PHPMD does is: It takes a given PHP source code base
+# and look for several potential problems within that source.
+# These problems can be things like:
+# Possible bugs
+# Suboptimal code
+# Overcomplicated expressions
+# Unused parameters, methods, properties
+# More details at https://phpmd.org/
+
+name: PHPMD
+
+on:
+ push:
+ branches: [ "master" ]
+ pull_request:
+ # The branches below must be a subset of the branches above
+ branches: [ "master" ]
+ schedule:
+ - cron: '40 0 * * 3'
+
+permissions:
+ contents: read
+
+jobs:
+ PHPMD:
+ name: Run PHPMD scanning
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read # for checkout to fetch code
+ security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
+ actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v3
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@aa1fe473f9c687b6fb896056d771232c0bc41161
+ with:
+ coverage: none
+ tools: phpmd
+
+ - name: Run PHPMD
+ run: phpmd . sarif codesize --reportfile phpmd-results.sarif
+ continue-on-error: true
+
+ - name: Upload analysis results to GitHub
+ uses: github/codeql-action/upload-sarif@v2
+ with:
+ sarif_file: phpmd-results.sarif
+ wait-for-processing: true
diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml
new file mode 100644
index 000000000..c1ad4f3c1
--- /dev/null
+++ b/.github/workflows/schedule.yml
@@ -0,0 +1,41 @@
+name: Changelog generation
+
+on:
+ schedule:
+ - cron: '0 0 * * *'
+ workflow_dispatch:
+
+jobs:
+ changelog:
+ name: Changelog generation
+ runs-on: ubuntu-22.04
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ ref: master
+ token: ${{ secrets.REPO_TOKEN }}
+
+ - name: Generate a changelog
+ uses: orhun/git-cliff-action@v4
+ id: git-cliff
+ with:
+ config: cliff.toml
+ args: v2.4.6-alpha.4.. --verbose
+ env:
+ OUTPUT: CHANGELOG.md
+ GITHUB_REPO: ${{ github.repository }}
+
+ - name: Print the changelog
+ run: cat "${{ steps.git-cliff.outputs.changelog }}"
+
+ - name: Commit changelog
+ run: |
+ git checkout master
+ git config --local user.name 'belomaxorka'
+ git config --local user.email 'roman25052006.kelesh@gmail.com'
+ set +e
+ git add CHANGELOG.md
+ git commit -m "changelog: Update CHANGELOG.md 📖"
+ git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git master
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..dd0e1f365
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,47 @@
+### IDE ###
+.idea
+.vscode
+
+### TorrentPier ###
+*.log
+install.php_*
+composer-setup.php
+.env
+.php_cs.cache
+data/avatars
+data/uploads
+internal_data/atom
+internal_data/cache
+internal_data/log
+internal_data/updater.json
+sitemap
+internal_data/triggers
+library/config.local.php
+vendor
+
+### Archives ###
+*.phar
+*.rar
+*.tar
+*.gz
+*.zip
+*.7z
+*.torrent
+*.pak
+
+### Windows ###
+Thumbs.db
+Desktop.ini
+$RECYCLE.BIN/
+*.lnk
+*.bat
+
+### OSX ###
+.DS_Store
+.AppleDouble
+.LSOverride
+._*
+.Spotlight-V100
+.Trashes
+*.orig
+*.rej
diff --git a/.htaccess b/.htaccess
new file mode 100644
index 000000000..a689fba84
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1,18 @@
+## set default server charset
+AddDefaultCharset UTF-8
+
+## folder listing access control
+Options All -Indexes
+
+## sitemap and atom rewrite
+RewriteEngine On
+RewriteRule ^sitemap.xml$ sitemap/sitemap.xml [L]
+RewriteRule ^/internal_data/atom/(.*) /atom$1 [L]
+
+## deny access to git folder
+RedirectMatch 404 /\\.git(/|$)
+
+## deny access to system files
+
+ Bull-powered BitTorrent tracker engine
+
+