PHP code example of marque / bloodhound

1. Go to this page and download the library: Download marque/bloodhound library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

marque / bloodhound example snippets


'routes' => [
    'announce_path' => 'announce',     // e.g. 'announce.php'
    'scrape_path'   => 'scrape',
    'key_source'    => 'path',         // 'path' | 'query'
    'key_parameter' => 'announce_key', // e.g. 'passkey'
    'key_pattern'   => '[0-9a-zA-Z]{32}',
],

use Marque\Bloodhound\Contracts\AnnounceLogServiceInterface;

public function __construct(
    private readonly AnnounceLogServiceInterface $log,
) {}

$recent = $this->log->forUser($user->id, now()->subDays(7));
$disputed = $this->log->forUserAndTorrent($user->id, $torrent->id);

use Marque\Bloodhound\Events\CheatDetected;

Event::listen(CheatDetected::class, function ($event) {
    // Ban user, notify admin, etc.
});
bash
php artisan vendor:publish --tag=bloodhound-config
php artisan migrate
env
BLOODHOUND_ANNOUNCE_PATH=announce.php
BLOODHOUND_SCRAPE_PATH=scrape.php
BLOODHOUND_KEY_SOURCE=query
BLOODHOUND_KEY_PARAMETER=passkey
bash
php artisan bloodhound:sync-swarm-counts
php artisan bloodhound:sync-swarm-counts --chunk=1000   # tune batch size
bash
php artisan bloodhound:prune-announce-log
bash
php artisan bloodhound:aggregate-ledger    # fold pending rows into totals (scheduled, every minute)
php artisan bloodhound:reconcile-ledger    # do the totals match the ledger? (scheduled, daily)
php artisan bloodhound:audit-ledger        # is the ledger itself coherent?
php artisan bloodhound:rebuild-totals      # recompute totals from the ledger