Skip to content

Commit

Permalink
Merge pull request #4264 from HDInnovations/8.x.x
Browse files Browse the repository at this point in the history
(Release) v8.3.2
  • Loading branch information
HDVinnie authored Oct 21, 2024
2 parents 3514c68 + f35e2d7 commit 619c61c
Show file tree
Hide file tree
Showing 87 changed files with 3,061 additions and 945 deletions.
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ Common syntax | Shorter and more readable syntax
`->orderBy('age', 'desc')` | `->latest('age')`
`->orderBy('created_at', 'asc')` | `->oldest()`

### CSS

CSS should follow the [BEM methodology](https://getbem.com/) and the [7-1 SCSS Architecture](https://sass-guidelin.es/#the-7-1-pattern).

Any new pages should use the existing component styles unless a new block, element and/or modifier is being added. It is highly discouraged to add new components when an existing one will do.

## Other

Expand Down
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
<h1 align="center">UNIT3D Community Edition</h1>

<p align="center">
<a href="http://laravel.com"><img src="https://img.shields.io/badge/Laravel-11-f4645f.svg" /></a>
<a href="http://laravel.com"><img src="https://img.shields.io/badge/Laravel-11-f4645f.svg" /></a>
<a href="https://github.com/HDInnovations/UNIT3D/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-AGPL%20v3.0-yellow.svg" /></a>
<a href="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/lint.yml/badge.svg?branch=master"><img src="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/lint.yml/badge.svg?branch=master" /></a>
<a href="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/phpunit-test.yml/badge.svg?branch=master"><img src="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/phpunit-test.yml/badge.svg?branch=master" /></a>
<a href="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/compile-assets-test.yml/badge.svg?branch=master"><img src="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/compile-assets-test.yml/badge.svg?branch=master" /></a>
<a href="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/larastan.yml/badge.svg?branch=master"><img src="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/larastan.yml/badge.svg?branch=master" /></a>
<a href="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/prettier-blade.yml/badge.svg?branch=master"><img src="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/prettier-blade.yml/badge.svg?branch=master" /></a>
<a href="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/prettier-blade.yml/badge.svg?branch=master"><img src="https://github.com/HDInnovations/UNIT3D-Community-Edition/actions/workflows/prettier-blade.yml/badge.svg?branch=master" /></a>
<a href="https://polar.sh/HDInnovations"><img src="https://polar.sh/embed/seeks-funding-shield.svg?org=HDInnovations" /></a>
</p>

<p align="center">
🎉<b>A Big Thanks To All Our <a href="https://github.com/HDInnovations/UNIT3D-Community-Edition/graphs/contributors">Contributors</a> and <a href="https://polar.sh/HDInnovations/subscriptions">Sponsors</a></b>🎉
🎉 <b>A Big Thanks To All Our <a href="https://github.com/HDInnovations/UNIT3D-Community-Edition/graphs/contributors">Contributors</a> and <a href="https://polar.sh/HDInnovations">Subscribers</a></b> 🎉
</p>

## 📝 Table of Contents

1. [Introduction](#introduction)
2. [Installation](#installation)
3. [Updating](#updating)
4. [Demo Site](#demo)
5. [Support UNIT3D](#support)
6. [Funding Issues/Requests](#funding)
7. [Special Thanks](#thanks)
4. [Support UNIT3D](#support)
5. [Funding Issues/Requests](#funding)
6. [Special Thanks](#thanks)


## <a name="introduction"></a> 🧐 Introduction

We have been developing a Private Torrent Tracker Software called `UNIT3D`. This is a PHP software based on Laravel 10, Livewire and AlpineJS. It is MySQL Strict Mode Compliant, and PHP 8.2 Ready. The code is well-designed and follows the PSR-2 coding style. It uses an MVC Architecture to ensure clarity between logic and presentation. As a hashing algorithm of Bcrypt or Argon2 is used, to ensure a safe and proper way to store the passwords for the users. A lightweight Blade Templating Engine. Caching System Supporting: "apc,” "array,” "database,” "file," "memcached," and "redis" methods. Eloquent and much more!
We have been developing a Private Torrent Tracker Software called `UNIT3D`. This is a PHP software based on Laravel 11, Livewire and AlpineJS. It is MySQL Strict Mode Compliant, and PHP 8.3 Ready. The code is well-designed and follows the PSR-2 coding style. It uses an MVC Architecture to ensure clarity between logic and presentation. As a hashing algorithm of Bcrypt or Argon2 is used, to ensure a safe and proper way to store the passwords for the users. A lightweight Blade Templating Engine. Caching System Supporting: "apc,” "array,” "database,” "file," "memcached," and "redis" methods. Eloquent and much more!

## <a name="installation"></a> 🖥️ Installation

Expand All @@ -43,8 +42,6 @@ Use this command to generate demo users and torrents for testing purposes in a d
## <a name="updating"></a> 🖥️ Updating
`php artisan git:update`

## <a name="demo"></a> 🖥️ Demo Site
https://unit3d.dev

## <a name="support"></a> ✨ Support UNIT3D

Expand All @@ -61,8 +58,8 @@ Bitcoin (BTC) - 3HUVkv3Q8b5nbxa9DtXG1dm4RdTJaTFRfc
Bitcoin Cash (BCH) - qp3wgpnwzpj4v9sq90wflsca8p5s75glrvga9tweu2
Ether (ETH) - 0x5eFF42F65234aD9c6A0CA5B9495f3c6D205bBC27
ETC - 0xd644C7C7009eC3824f3305ff6C7E2Ee90497d56e
ETC - 0xd644C7C7009eC3824f3305ff6C7E2Ee90497d56e
Litecoin (LTC) - MDLKyHzupt1mchuo8mrjW9mihkKp1LD4nG
Expand Down
16 changes: 14 additions & 2 deletions app/Bots/NerdBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,25 @@ public function getBans(): string
$bans = cache()->remember(
'nerdbot-bans',
$this->expiresAt,
fn () => Ban::whereNull('unban_reason')
->whereNull('removed_at')
fn () => Ban::whereNotNull('ban_reason')
->where('created_at', '>', $this->current->subDay())->count()
);

return "In the last 24 hours, {$bans} users have been banned from {$this->site}";
}

public function getUnbans(): string
{
$unbans = cache()->remember(
'nerdbot-unbans',
$this->expiresAt,
fn () => Ban::whereNotNull('unban_reason')
->where('removed_at', '>', $this->current->subDay())->count()
);

return "In the last 24 hours, {$unbans} users have been unbanned from {$this->site}";
}

public function getWarnings(): string
{
$warnings = cache()->remember(
Expand Down Expand Up @@ -254,6 +265,7 @@ public function process(string $type, User $user, string $message = '', int $tar
$log = match($command[$x]) {
'banker' => $this->getBanker(),
'bans' => $this->getBans(),
'unbans' => $this->getUnbans(),
'doubleupload' => $this->getDoubleUpload(),
'freeleech' => $this->getFreeleech(),
'help' => $this->getHelp(),
Expand Down
4 changes: 3 additions & 1 deletion app/Console/Commands/AutoNerdStat.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ final public function handle(): void
'du',
'peers',
'bans',
'unbans',
'warnings',
'king',
])->random();
Expand All @@ -87,7 +88,8 @@ final public function handle(): void
'fl100' => 'There Are Currently [color=#93c47d][b]'.DB::table('torrents')->where('free', '=', 100)->count().'[/b][/color] 100% Freeleech Torrents On '.config('other.title').'!',
'du' => 'There Are Currently [color=#93c47d][b]'.DB::table('torrents')->where('doubleup', '=', 1)->count().'[/b][/color] Double Upload Torrents On '.config('other.title').'!',
'peers' => 'Currently There Are [color=#93c47d][b]'.DB::table('peers')->where('active', '=', 1)->count().'[/b][/color] Peers On '.config('other.title').'!',
'bans' => 'In The Last 24 Hours [color=#dd7e6b][b]'.DB::table('bans')->whereNull('unban_reason')->whereNull('removed_at')->where('created_at', '>', now()->subDay())->count().'[/b][/color] Users Have Been Banned From '.config('other.title').'!',
'bans' => 'In The Last 24 Hours [color=#dd7e6b][b]'.DB::table('bans')->whereNotNull('ban_reason')->where('created_at', '>', now()->subDay())->count().'[/b][/color] Users Have Been Banned From '.config('other.title').'!',
'unbans' => 'In The Last 24 Hours [color=#dd7e6b][b]'.DB::table('bans')->whereNotNull('unban_reason')->where('removed_at', '>', now()->subDay())->count().'[/b][/color] Users Have Been Unbanned From '.config('other.title').'!',
'warnings' => 'In The Last 24 Hours [color=#dd7e6b][b]'.DB::table('warnings')->where('created_at', '>', now()->subDay())->count().'[/b][/color] Hit and Run Warnings Have Been Issued On '.config('other.title').'!',
'king' => config('other.title').' Is King!',
default => 'Nerd Stat Error!',
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/AutoRefundDownload.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ final public function handle(): void
->whereColumn('torrents.user_id', '!=', 'history.user_id')
->when(!config('other.refundable'), fn ($query) => $query->where(
fn ($query) => $query
->where('groups.is_refundable', '=', 1)
->orWhere('torrents.refundable', '=', 1)
->where('groups.is_refundable', '=', true)
->orWhere('torrents.refundable', '=', true)
))
->update([
'history.refunded_download' => DB::raw('history.refunded_download + (@delta := LEAST(1, history.seedtime / '.(int) $FULL_REFUND_SEEDTIME.') * torrents.size - history.refunded_download)'),
Expand Down
4 changes: 4 additions & 0 deletions app/Console/Commands/AutoRemoveTimedTorrentBuffs.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ final public function handle(): void
Unit3dAnnounce::addTorrent($torrent);
}

Torrent::query()->whereNotNull('bumped_at')->where('bumped_at', '<', now()->subWeek())->update([
'bumped_at' => null,
]);

$this->comment('Automated Removal Of Expired Torrent Buffs Command Complete');
}
}
65 changes: 65 additions & 0 deletions app/Console/Commands/AutoSyncPeopleToMeilisearch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

declare(strict_types=1);

/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author HDVinnie <[email protected]>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/

namespace App\Console\Commands;

use App\Models\Person;
use Exception;
use Illuminate\Console\Command;
use Meilisearch\Client;

class AutoSyncPeopleToMeilisearch extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'auto:sync_people_to_meilisearch';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Syncs people to Meilisearch';

/**
* Execute the console command.
*
* @throws Exception
*/
public function handle(): void
{
$start = now();

$client = new Client(config('scout.meilisearch.host'), config('scout.meilisearch.key'));
$index = $client->index('people');

$people = Person::all(['id', 'name', 'birthday', 'still']);

$documents = $people->map(fn ($person) => [
'id' => $person->id,
'name' => $person->name,
'birthday' => $person->birthday,
'still' => $person->still,
])->toArray();

$index->addDocuments($documents);

$this->comment('Synced all people to Meilisearch in '.(now()->diffInMilliseconds($start) / 1000).' seconds.');
}
}
9 changes: 9 additions & 0 deletions app/Console/Commands/AutoSyncTorrentsToMeilisearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use App\Models\Torrent;
use Exception;
use Illuminate\Console\Command;
use Meilisearch\Client;

class AutoSyncTorrentsToMeilisearch extends Command
{
Expand All @@ -45,6 +46,14 @@ public function handle(): void
{
$start = now();

$client = new Client(config('scout.meilisearch.host'), config('scout.meilisearch.key'));

$index = $client->getIndex('torrents');

$index->updatePagination([
'maxTotalHits' => max(1, Torrent::query()->count()) + 1000,
]);

if ($this->option('wipe')) {
Torrent::removeAllFromSearch();
Torrent::query()->selectRaw(Torrent::SEARCHABLE)->searchable();
Expand Down
1 change: 1 addition & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ protected function schedule(Schedule $schedule): void
$schedule->command('auto:refund_download')->daily();
$schedule->command('auth:clear-resets')->daily();
$schedule->command('auto:sync_torrents_to_meilisearch')->everyFifteenMinutes();
$schedule->command('auto:sync_people_to_meilisearch')->daily();
$schedule->command('auto:remove_expired_donors')->daily();
//$schedule->command('auto:ban_disposable_users')->weekends();
$schedule->command('backup:clean')->daily();
Expand Down
14 changes: 11 additions & 3 deletions app/DTO/TorrentSearchFiltersDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ final public function toMeilisearchFilter(): array
}

if ($this->keywords !== []) {
$filters[] = 'keywords.name IN '.json_encode($this->keywords);
$filters[] = 'keywords IN '.json_encode($this->keywords);
}

if ($this->startYear !== null) {
Expand Down Expand Up @@ -330,6 +330,10 @@ final public function toMeilisearchFilter(): array
$filters[] = 'internal = true';
}

if ($this->trumpable) {
$filters[] = 'trumpable = true';
}

if ($this->personalRelease) {
$filters[] = 'personal_release = true';
}
Expand Down Expand Up @@ -368,11 +372,15 @@ final public function toMeilisearchFilter(): array
}

if ($this->userDownloaded === true) {
$filters[] = 'history_complete.user_id = '.$this->user->id;
$filters[] = [
'history_complete.user_id = '.$this->user->id,
'history_incomplete.user_id = '.$this->user->id,
];
}

if ($this->userDownloaded === false) {
$filters[] = 'history_incomplete.user_id = '.$this->user->id;
$filters[] = 'history_complete.user_id != '.$this->user->id;
$filters[] = 'history_incomplete.user_id != '.$this->user->id;
}

if ($this->userSeeder === false) {
Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/TrackerException.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class TrackerException extends Exception
138 => 'You have reached a rate limit. You can only seed/leech a single torrent from upto :limit locations.',

// Error message about User Account
140 => 'Passkey does not esist! Please Re-download the .torrent',
140 => 'Passkey does not exist! Please Re-download the .torrent',
141 => 'Your account is not enabled! ( Current `:status` )',
142 => 'Your downloading privileges have been disabled! (Read the rules)',

Expand Down
3 changes: 2 additions & 1 deletion app/Helpers/Bbcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ public function parse(?string $source, bool $replaceLineBreaks = true): string
{
// Replace all void elements since they don't have closing tags
$source = str_replace('[*]', '<li>', (string) $source);
$source = str_replace('[hr]', '<hr>', $source);
$source = preg_replace_callback(
'/\[url](.*?)\[\/url]/i',
fn ($matches) => '<a href="'.$this->sanitizeUrl($matches[1]).'">'.$this->sanitizeUrl($matches[1]).'</a>',
Expand Down Expand Up @@ -511,7 +512,7 @@ private function sanitizeUrl(string $url, ?bool $isImage = null): string
});

if (!$isWhitelisted) {
$url = 'https://wsrv.nl/?n=-1&url='.urlencode($url);
$url = 'https://wsrv.nl/?n=-1&ll&url='.urlencode($url);
}
}

Expand Down
Loading

0 comments on commit 619c61c

Please sign in to comment.