-
-
Notifications
You must be signed in to change notification settings - Fork 364
/
autoSeedbox.php
61 lines (51 loc) · 1.45 KB
/
autoSeedbox.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* NOTICE OF LICENSE
*
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D
* @license https://choosealicense.com/licenses/gpl-3.0/ GNU General Public License v3.0
* @author HDVinnie
*/
namespace App\Console\Commands;
use App\Torrent;
use App\Peer;
use App\Client;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class autoSeedbox extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'autoSeedbox';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Updates Torrents Highspeed Tag based on registered seedboxes.';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
DB::table('torrents')->update(['highspeed' => 0]);
$seedboxips = Client::select('ip')->get()->toArray();
if (is_array($seedboxips) && count($seedboxips) > 0) {
$torid = Peer::select('torrent_id')->whereIn('ip', $seedboxips)->get()->toArray();
foreach ($torid as $id) {
$torrent = Torrent::where('id', '=', $id)->first();
$torrent->highspeed = 1;
$torrent->save();
unset($torrent);
}
}
}
}