Browse Source

switch to yggdrasil-only model

main
ghost 1 year ago
parent
commit
cede3d0607
  1. 6
      src/config/app.php.example
  2. 47
      src/library/database.php
  3. 21
      src/public/action.php
  4. 12
      src/public/edit.php
  5. 71
      src/public/index.php
  6. 71
      src/public/magnet.php
  7. 68
      src/public/node.php

6
src/config/app.php.example

@ -103,8 +103,6 @@ define('MAGNET_STOP_WORDS_SIMILAR', @@ -103,8 +103,6 @@ define('MAGNET_STOP_WORDS_SIMILAR',
]
);
define('MAGNET_DOWNLOAD_YGGDRASIL_URL_ONLY', true);
// Comment
define('COMMENT_DEFAULT_APPROVED', false);
define('COMMENT_DEFAULT_PUBLIC', false);
@ -116,17 +114,17 @@ define('TRACKER_LINKS', (object) @@ -116,17 +114,17 @@ define('TRACKER_LINKS', (object)
[
'Tracker 1' => (object)
[
'url' => 'http://[201:23b4:991a:634d:8359:4521:5576:15b7]/yggtracker',
'announce' => 'http://[201:23b4:991a:634d:8359:4521:5576:15b7]/announce',
'stats' => 'http://[201:23b4:991a:634d:8359:4521:5576:15b7]/stats',
'scrape' => 'http://[201:23b4:991a:634d:8359:4521:5576:15b7]/scrape',
'rules' => 'yggdrasil only',
],
'Tracker 2' => (object)
[
'url' => false,
'announce' => 'http://[200:1e2f:e608:eb3a:2bf:1e62:87ba:e2f7]/announce',
'stats' => 'http://[200:1e2f:e608:eb3a:2bf:1e62:87ba:e2f7]/stats',
'scrape' => 'http://[200:1e2f:e608:eb3a:2bf:1e62:87ba:e2f7]/scrape',
'rules' => 'yggdrasil only',
],
// ...
]

47
src/library/database.php

@ -827,8 +827,40 @@ class Database { @@ -827,8 +827,40 @@ class Database {
return $this->addMagnetToAddressTracker($magnetId, $addressTrackerId);
}
/*
public function getMagnetToAddressTrackerSeedersSum() {
public function getMagnetToAddressTrackerSeedersSumByMagnetId(int $magnetId) : int {
$this->_debug->query->select->total++;
$query = $this->_db->prepare('SELECT SUM(`seeders`) AS `result` FROM `magnetToAddressTracker` WHERE `magnetId` = ?');
$query->execute([$magnetId]);
return (int) $query->fetch()->result;
}
public function getMagnetToAddressTrackerCompletedSumByMagnetId(int $magnetId) : int {
$this->_debug->query->select->total++;
$query = $this->_db->prepare('SELECT SUM(`completed`) AS `result` FROM `magnetToAddressTracker` WHERE `magnetId` = ?');
$query->execute([$magnetId]);
return (int) $query->fetch()->result;
}
public function getMagnetToAddressTrackerLeechersSumByMagnetId(int $magnetId) : int {
$this->_debug->query->select->total++;
$query = $this->_db->prepare('SELECT SUM(`leechers`) AS `result` FROM `magnetToAddressTracker` WHERE `magnetId` = ?');
$query->execute([$magnetId]);
return (int) $query->fetch()->result;
}
public function getMagnetToAddressTrackerSeedersSum() : int {
$this->_debug->query->select->total++;
@ -836,10 +868,10 @@ class Database { @@ -836,10 +868,10 @@ class Database {
$query->execute();
return $query->fetch()->result;
return (int) $query->fetch()->result;
}
public function getMagnetToAddressTrackerCompletedSum() {
public function getMagnetToAddressTrackerCompletedSum() : int {
$this->_debug->query->select->total++;
@ -847,10 +879,10 @@ class Database { @@ -847,10 +879,10 @@ class Database {
$query->execute();
return $query->fetch()->result;
return (int) $query->fetch()->result;
}
public function getMagnetToAddressTrackerLeechersSum() {
public function getMagnetToAddressTrackerLeechersSum() : int {
$this->_debug->query->select->total++;
@ -858,9 +890,8 @@ class Database { @@ -858,9 +890,8 @@ class Database {
$query->execute();
return $query->fetch()->result;
return (int) $query->fetch()->result;
}
*/
// Magnet to AcceptableSource
public function addMagnetToAcceptableSource(int $magnetId, int $acceptableSourceId) : int {

21
src/public/action.php

@ -463,8 +463,8 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false) @@ -463,8 +463,8 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
$host->value,
$uri->value)));
// Yggdrasil url only settings enabled
if (MAGNET_DOWNLOAD_YGGDRASIL_URL_ONLY && !preg_match(YGGDRASIL_URL_REGEX, $url))
// Yggdrasil url only
if (!preg_match(YGGDRASIL_URL_REGEX, $url))
{
continue;
}
@ -494,8 +494,8 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false) @@ -494,8 +494,8 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
$host->value,
$uri->value)));
// Yggdrasil url only settings enabled
if (MAGNET_DOWNLOAD_YGGDRASIL_URL_ONLY && !preg_match(YGGDRASIL_URL_REGEX, $url))
// Yggdrasil url only
if (!preg_match(YGGDRASIL_URL_REGEX, $url))
{
continue;
}
@ -520,8 +520,8 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false) @@ -520,8 +520,8 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
$host->value,
$uri->value)));
// Yggdrasil url only settings enabled
if (MAGNET_DOWNLOAD_YGGDRASIL_URL_ONLY && !preg_match(YGGDRASIL_URL_REGEX, $url))
// Yggdrasil url only
if (!preg_match(YGGDRASIL_URL_REGEX, $url))
{
continue;
}
@ -611,6 +611,8 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false) @@ -611,6 +611,8 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
foreach ($value as $tr)
{
if ($url = Yggverse\Parser\Url::parse($tr))
{
if (preg_match(YGGDRASIL_URL_REGEX, str_replace(['[',']'], false, $url->host->name)))
{
$db->initMagnetToAddressTrackerId(
$magnetId,
@ -623,6 +625,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false) @@ -623,6 +625,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
);
}
}
}
break;
case 'ws':
foreach ($value as $ws)
@ -634,6 +637,8 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false) @@ -634,6 +637,8 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
foreach ($value as $as)
{
if ($url = Yggverse\Parser\Url::parse($as))
{
if (preg_match(YGGDRASIL_URL_REGEX, str_replace(['[',']'], false, $url->host->name)))
{
$db->initMagnetToAcceptableSourceId(
$magnetId,
@ -646,11 +651,14 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false) @@ -646,11 +651,14 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
);
}
}
}
break;
case 'xs':
foreach ($value as $xs)
{
if ($url = Yggverse\Parser\Url::parse($xs))
{
if (preg_match(YGGDRASIL_URL_REGEX, str_replace(['[',']'], false, $url->host->name)))
{
$db->initMagnetToExactSourceId(
$magnetId,
@ -663,6 +671,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false) @@ -663,6 +671,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
);
}
}
}
break;
case 'mt':
foreach ($value as $mt)

12
src/public/edit.php

@ -286,6 +286,8 @@ else { @@ -286,6 +286,8 @@ else {
if (!empty($tr))
{
if ($url = Yggverse\Parser\Url::parse($tr))
{
if (preg_match(YGGDRASIL_URL_REGEX, str_replace(['[',']'], false, $url->host->name)))
{
$db->initMagnetToAddressTrackerId(
$magnet->magnetId,
@ -297,8 +299,6 @@ else { @@ -297,8 +299,6 @@ else {
)
);
if (preg_match(YGGDRASIL_URL_REGEX, str_replace(['[',']'], false, $url->host->name)))
{
$response->form->tr->valid->success = true;
$response->form->tr->valid->message = false;
}
@ -322,6 +322,8 @@ else { @@ -322,6 +322,8 @@ else {
if (!empty($as))
{
if ($url = Yggverse\Parser\Url::parse($as))
{
if (preg_match(YGGDRASIL_URL_REGEX, str_replace(['[',']'], false, $url->host->name)))
{
$db->initMagnetToAcceptableSourceId(
$magnet->magnetId,
@ -333,8 +335,6 @@ else { @@ -333,8 +335,6 @@ else {
)
);
if (preg_match(YGGDRASIL_URL_REGEX, str_replace(['[',']'], false, $url->host->name)))
{
$response->form->as->valid->success = true;
$response->form->as->valid->message = false;
}
@ -358,6 +358,8 @@ else { @@ -358,6 +358,8 @@ else {
if (!empty($xs))
{
if ($url = Yggverse\Parser\Url::parse($xs))
{
if (preg_match(YGGDRASIL_URL_REGEX, str_replace(['[',']'], false, $url->host->name)))
{
$db->initMagnetToExactSourceId(
$magnet->magnetId,
@ -369,8 +371,6 @@ else { @@ -369,8 +371,6 @@ else {
)
);
if (preg_match(YGGDRASIL_URL_REGEX, str_replace(['[',']'], false, $url->host->name)))
{
$response->form->xs->valid->success = true;
$response->form->xs->valid->message = false;
}

71
src/public/index.php

@ -113,57 +113,6 @@ else @@ -113,57 +113,6 @@ else
$keywords[] = $db->getKeywordTopic($keyword->keywordTopicId)->value;
}
// Scrapes
$localScrape = (object)
[
'seeders' => 0,
'completed' => 0,
'leechers' => 0,
];
$totalScrape = (object)
[
'seeders' => 0,
'completed' => 0,
'leechers' => 0,
];
$trackers = [];
foreach (TRACKER_LINKS as $tracker)
{
$trackers[] = $tracker->announce;
}
foreach ($db->findAddressTrackerByMagnetId($magnet->magnetId) as $magnetToAddressTracker)
{
if ($addressTracker = $db->getAddressTracker($magnetToAddressTracker->addressTrackerId))
{
$scheme = $db->getScheme($addressTracker->schemeId);
$host = $db->getHost($addressTracker->hostId);
$port = $db->getPort($addressTracker->portId);
$uri = $db->getUri($addressTracker->uriId);
$url = $port->value ? sprintf('%s://%s:%s%s', $scheme->value,
$host->value,
$port->value,
$uri->value) : sprintf('%s://%s%s', $scheme->value,
$host->value,
$uri->value);
if (in_array($url, $trackers))
{
$localScrape->seeders += (int) $magnetToAddressTracker->seeders;
$localScrape->completed += (int) $magnetToAddressTracker->completed;
$localScrape->leechers += (int) $magnetToAddressTracker->leechers;
}
$totalScrape->seeders += (int) $magnetToAddressTracker->seeders;
$totalScrape->completed += (int) $magnetToAddressTracker->completed;
$totalScrape->leechers += (int) $magnetToAddressTracker->leechers;
}
}
$response->magnets[] = (object)
[
'magnetId' => $magnet->magnetId,
@ -200,11 +149,9 @@ else @@ -200,11 +149,9 @@ else
'read' => $accessRead,
'edit' => $accessEdit,
],
'scrape' => (object)
[
'local' => $localScrape,
'total' => $totalScrape
]
'seeders' => $db->getMagnetToAddressTrackerSeedersSumByMagnetId($magnet->magnetId),
'completed' => $db->getMagnetToAddressTrackerCompletedSumByMagnetId($magnet->magnetId),
'leechers' => $db->getMagnetToAddressTrackerLeechersSumByMagnetId($magnet->magnetId)
];
}
}
@ -335,24 +282,24 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?> @@ -335,24 +282,24 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?>
<?php echo $magnet->timeUpdated ? $magnet->timeUpdated : $magnet->timeAdded ?>
</sup>
</span>
<span class="margin-t-8 margin-r-8 cursor-default opacity-0 parent-hover-opacity-09" title="<?php echo _('Seeders local / total') ?>">
<span class="margin-t-8 margin-r-8 cursor-default opacity-0 parent-hover-opacity-09" title="<?php echo _('Seeders') ?>">
<svg class="width-13px" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-up" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 15a.5.5 0 0 0 .5-.5V2.707l3.146 3.147a.5.5 0 0 0 .708-.708l-4-4a.5.5 0 0 0-.708 0l-4 4a.5.5 0 1 0 .708.708L7.5 2.707V14.5a.5.5 0 0 0 .5.5z"/>
</svg>
<sup><?php echo $magnet->scrape->local->seeders ?> / <?php echo $magnet->scrape->total->seeders ?></sup>
<sup><?php echo $magnet->seeders ?></sup>
</span>
<span class="margin-t-8 margin-r-8 cursor-default opacity-0 parent-hover-opacity-09" title="<?php echo _('Completed local / total') ?>">
<span class="margin-t-8 margin-r-8 cursor-default opacity-0 parent-hover-opacity-09" title="<?php echo _('Completed') ?>">
<svg class="width-13px" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-down" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 1a.5.5 0 0 1 .5.5v11.793l3.146-3.147a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 0 1 .708-.708L7.5 13.293V1.5A.5.5 0 0 1 8 1z"/>
</svg>
<sup><?php echo $magnet->scrape->local->completed ?> / <?php echo $magnet->scrape->total->completed ?></sup>
<sup><?php echo $magnet->completed ?></sup>
</span>
<span class="margin-t-8 margin-r-8 cursor-default opacity-0 parent-hover-opacity-09" title="<?php echo _('Leechers local / total') ?>">
<span class="margin-t-8 margin-r-8 cursor-default opacity-0 parent-hover-opacity-09" title="<?php echo _('Leechers') ?>">
<svg class="width-13px" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cup-hot" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M.5 6a.5.5 0 0 0-.488.608l1.652 7.434A2.5 2.5 0 0 0 4.104 16h5.792a2.5 2.5 0 0 0 2.44-1.958l.131-.59a3 3 0 0 0 1.3-5.854l.221-.99A.5.5 0 0 0 13.5 6H.5ZM13 12.5a2.01 2.01 0 0 1-.316-.025l.867-3.898A2.001 2.001 0 0 1 13 12.5ZM2.64 13.825 1.123 7h11.754l-1.517 6.825A1.5 1.5 0 0 1 9.896 15H4.104a1.5 1.5 0 0 1-1.464-1.175Z"/>
<path d="m4.4.8-.003.004-.014.019a4.167 4.167 0 0 0-.204.31 2.327 2.327 0 0 0-.141.267c-.026.06-.034.092-.037.103v.004a.593.593 0 0 0 .091.248c.075.133.178.272.308.445l.01.012c.118.158.26.347.37.543.112.2.22.455.22.745 0 .188-.065.368-.119.494a3.31 3.31 0 0 1-.202.388 5.444 5.444 0 0 1-.253.382l-.018.025-.005.008-.002.002A.5.5 0 0 1 3.6 4.2l.003-.004.014-.019a4.149 4.149 0 0 0 .204-.31 2.06 2.06 0 0 0 .141-.267c.026-.06.034-.092.037-.103a.593.593 0 0 0-.09-.252A4.334 4.334 0 0 0 3.6 2.8l-.01-.012a5.099 5.099 0 0 1-.37-.543A1.53 1.53 0 0 1 3 1.5c0-.188.065-.368.119-.494.059-.138.134-.274.202-.388a5.446 5.446 0 0 1 .253-.382l.025-.035A.5.5 0 0 1 4.4.8Zm3 0-.003.004-.014.019a4.167 4.167 0 0 0-.204.31 2.327 2.327 0 0 0-.141.267c-.026.06-.034.092-.037.103v.004a.593.593 0 0 0 .091.248c.075.133.178.272.308.445l.01.012c.118.158.26.347.37.543.112.2.22.455.22.745 0 .188-.065.368-.119.494a3.31 3.31 0 0 1-.202.388 5.444 5.444 0 0 1-.253.382l-.018.025-.005.008-.002.002A.5.5 0 0 1 6.6 4.2l.003-.004.014-.019a4.149 4.149 0 0 0 .204-.31 2.06 2.06 0 0 0 .141-.267c.026-.06.034-.092.037-.103a.593.593 0 0 0-.09-.252A4.334 4.334 0 0 0 6.6 2.8l-.01-.012a5.099 5.099 0 0 1-.37-.543A1.53 1.53 0 0 1 6 1.5c0-.188.065-.368.119-.494.059-.138.134-.274.202-.388a5.446 5.446 0 0 1 .253-.382l.025-.035A.5.5 0 0 1 7.4.8Zm3 0-.003.004-.014.019a4.077 4.077 0 0 0-.204.31 2.337 2.337 0 0 0-.141.267c-.026.06-.034.092-.037.103v.004a.593.593 0 0 0 .091.248c.075.133.178.272.308.445l.01.012c.118.158.26.347.37.543.112.2.22.455.22.745 0 .188-.065.368-.119.494a3.198 3.198 0 0 1-.202.388 5.385 5.385 0 0 1-.252.382l-.019.025-.005.008-.002.002A.5.5 0 0 1 9.6 4.2l.003-.004.014-.019a4.149 4.149 0 0 0 .204-.31 2.06 2.06 0 0 0 .141-.267c.026-.06.034-.092.037-.103a.593.593 0 0 0-.09-.252A4.334 4.334 0 0 0 9.6 2.8l-.01-.012a5.099 5.099 0 0 1-.37-.543A1.53 1.53 0 0 1 9 1.5c0-.188.065-.368.119-.494.059-.138.134-.274.202-.388a5.446 5.446 0 0 1 .253-.382l.025-.035A.5.5 0 0 1 10.4.8Z"/>
</svg>
<sup><?php echo $magnet->scrape->local->leechers ?> / <?php echo $magnet->scrape->total->leechers ?></sup>
<sup><?php echo $magnet->leechers ?></sup>
</span>
<span class="float-right margin-l-12">
<a href="<?php echo WEBSITE_URL ?>/action.php?target=magnet&toggle=star&magnetId=<?php echo $magnet->magnetId ?>&callback=<?php echo base64_encode(sprintf('%s/index.php?query=%s#magnet-%s', WEBSITE_URL, urlencode($request->query), $magnet->magnetId)) ?>" title="<?php echo _('Star') ?>">

71
src/public/magnet.php

@ -89,57 +89,6 @@ else @@ -89,57 +89,6 @@ else
$keywords[] = $db->getKeywordTopic($keyword->keywordTopicId)->value;
}
// Scrapes
$localScrape = (object)
[
'seeders' => 0,
'completed' => 0,
'leechers' => 0,
];
$totalScrape = (object)
[
'seeders' => 0,
'completed' => 0,
'leechers' => 0,
];
$trackers = [];
foreach (TRACKER_LINKS as $tracker)
{
$trackers[] = $tracker->announce;
}
foreach ($db->findAddressTrackerByMagnetId($magnet->magnetId) as $magnetToAddressTracker)
{
if ($addressTracker = $db->getAddressTracker($magnetToAddressTracker->addressTrackerId))
{
$scheme = $db->getScheme($addressTracker->schemeId);
$host = $db->getHost($addressTracker->hostId);
$port = $db->getPort($addressTracker->portId);
$uri = $db->getUri($addressTracker->uriId);
$url = $port->value ? sprintf('%s://%s:%s%s', $scheme->value,
$host->value,
$port->value,
$uri->value) : sprintf('%s://%s%s', $scheme->value,
$host->value,
$uri->value);
if (in_array($url, $trackers))
{
$localScrape->seeders += (int) $magnetToAddressTracker->seeders;
$localScrape->completed += (int) $magnetToAddressTracker->completed;
$localScrape->leechers += (int) $magnetToAddressTracker->leechers;
}
$totalScrape->seeders += (int) $magnetToAddressTracker->seeders;
$totalScrape->completed += (int) $magnetToAddressTracker->completed;
$totalScrape->leechers += (int) $magnetToAddressTracker->leechers;
}
}
$response->user = $user;
$response->magnet = (object)
[
@ -182,11 +131,9 @@ else @@ -182,11 +131,9 @@ else
'read' => $accessRead,
'edit' => $accessEdit,
],
'scrape' => (object)
[
'local' => $localScrape,
'total' => $totalScrape
]
'seeders' => $db->getMagnetToAddressTrackerSeedersSumByMagnetId($magnet->magnetId),
'completed' => $db->getMagnetToAddressTrackerCompletedSumByMagnetId($magnet->magnetId),
'leechers' => $db->getMagnetToAddressTrackerLeechersSumByMagnetId($magnet->magnetId)
];
}
@ -316,24 +263,24 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?> @@ -316,24 +263,24 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?>
<?php echo $response->magnet->timeUpdated ? $response->magnet->timeUpdated : $response->magnet->timeAdded ?>
</sup>
</span>
<span class="margin-t-8 margin-r-8 cursor-default opacity-0 parent-hover-opacity-09" title="<?php echo _('Seeders local / total') ?>">
<span class="margin-t-8 margin-r-8 cursor-default opacity-0 parent-hover-opacity-09" title="<?php echo _('Seeders') ?>">
<svg class="width-13px" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-up" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 15a.5.5 0 0 0 .5-.5V2.707l3.146 3.147a.5.5 0 0 0 .708-.708l-4-4a.5.5 0 0 0-.708 0l-4 4a.5.5 0 1 0 .708.708L7.5 2.707V14.5a.5.5 0 0 0 .5.5z"/>
</svg>
<sup><?php echo $response->magnet->scrape->local->seeders ?> / <?php echo $response->magnet->scrape->total->seeders ?></sup>
<sup><?php echo $response->magnet->seeders ?></sup>
</span>
<span class="margin-t-8 margin-r-8 cursor-default opacity-0 parent-hover-opacity-09" title="<?php echo _('Completed local / total') ?>">
<span class="margin-t-8 margin-r-8 cursor-default opacity-0 parent-hover-opacity-09" title="<?php echo _('Completed') ?>">
<svg class="width-13px" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-down" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 1a.5.5 0 0 1 .5.5v11.793l3.146-3.147a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 0 1 .708-.708L7.5 13.293V1.5A.5.5 0 0 1 8 1z"/>
</svg>
<sup><?php echo $response->magnet->scrape->local->completed ?> / <?php echo $response->magnet->scrape->total->completed ?></sup>
<sup><?php echo $response->magnet->completed ?></sup>
</span>
<span class="margin-t-8 margin-r-8 cursor-default opacity-0 parent-hover-opacity-09" title="<?php echo _('Leechers local / total') ?>">
<span class="margin-t-8 margin-r-8 cursor-default opacity-0 parent-hover-opacity-09" title="<?php echo _('Leechers') ?>">
<svg class="width-13px" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cup-hot" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M.5 6a.5.5 0 0 0-.488.608l1.652 7.434A2.5 2.5 0 0 0 4.104 16h5.792a2.5 2.5 0 0 0 2.44-1.958l.131-.59a3 3 0 0 0 1.3-5.854l.221-.99A.5.5 0 0 0 13.5 6H.5ZM13 12.5a2.01 2.01 0 0 1-.316-.025l.867-3.898A2.001 2.001 0 0 1 13 12.5ZM2.64 13.825 1.123 7h11.754l-1.517 6.825A1.5 1.5 0 0 1 9.896 15H4.104a1.5 1.5 0 0 1-1.464-1.175Z"/>
<path d="m4.4.8-.003.004-.014.019a4.167 4.167 0 0 0-.204.31 2.327 2.327 0 0 0-.141.267c-.026.06-.034.092-.037.103v.004a.593.593 0 0 0 .091.248c.075.133.178.272.308.445l.01.012c.118.158.26.347.37.543.112.2.22.455.22.745 0 .188-.065.368-.119.494a3.31 3.31 0 0 1-.202.388 5.444 5.444 0 0 1-.253.382l-.018.025-.005.008-.002.002A.5.5 0 0 1 3.6 4.2l.003-.004.014-.019a4.149 4.149 0 0 0 .204-.31 2.06 2.06 0 0 0 .141-.267c.026-.06.034-.092.037-.103a.593.593 0 0 0-.09-.252A4.334 4.334 0 0 0 3.6 2.8l-.01-.012a5.099 5.099 0 0 1-.37-.543A1.53 1.53 0 0 1 3 1.5c0-.188.065-.368.119-.494.059-.138.134-.274.202-.388a5.446 5.446 0 0 1 .253-.382l.025-.035A.5.5 0 0 1 4.4.8Zm3 0-.003.004-.014.019a4.167 4.167 0 0 0-.204.31 2.327 2.327 0 0 0-.141.267c-.026.06-.034.092-.037.103v.004a.593.593 0 0 0 .091.248c.075.133.178.272.308.445l.01.012c.118.158.26.347.37.543.112.2.22.455.22.745 0 .188-.065.368-.119.494a3.31 3.31 0 0 1-.202.388 5.444 5.444 0 0 1-.253.382l-.018.025-.005.008-.002.002A.5.5 0 0 1 6.6 4.2l.003-.004.014-.019a4.149 4.149 0 0 0 .204-.31 2.06 2.06 0 0 0 .141-.267c.026-.06.034-.092.037-.103a.593.593 0 0 0-.09-.252A4.334 4.334 0 0 0 6.6 2.8l-.01-.012a5.099 5.099 0 0 1-.37-.543A1.53 1.53 0 0 1 6 1.5c0-.188.065-.368.119-.494.059-.138.134-.274.202-.388a5.446 5.446 0 0 1 .253-.382l.025-.035A.5.5 0 0 1 7.4.8Zm3 0-.003.004-.014.019a4.077 4.077 0 0 0-.204.31 2.337 2.337 0 0 0-.141.267c-.026.06-.034.092-.037.103v.004a.593.593 0 0 0 .091.248c.075.133.178.272.308.445l.01.012c.118.158.26.347.37.543.112.2.22.455.22.745 0 .188-.065.368-.119.494a3.198 3.198 0 0 1-.202.388 5.385 5.385 0 0 1-.252.382l-.019.025-.005.008-.002.002A.5.5 0 0 1 9.6 4.2l.003-.004.014-.019a4.149 4.149 0 0 0 .204-.31 2.06 2.06 0 0 0 .141-.267c.026-.06.034-.092.037-.103a.593.593 0 0 0-.09-.252A4.334 4.334 0 0 0 9.6 2.8l-.01-.012a5.099 5.099 0 0 1-.37-.543A1.53 1.53 0 0 1 9 1.5c0-.188.065-.368.119-.494.059-.138.134-.274.202-.388a5.446 5.446 0 0 1 .253-.382l.025-.035A.5.5 0 0 1 10.4.8Z"/>
</svg>
<sup><?php echo $response->magnet->scrape->local->leechers ?> / <?php echo $response->magnet->scrape->total->leechers ?></sup>
<sup><?php echo $response->magnet->leechers ?></sup>
</span>
<span class="float-right margin-l-12">
<a href="<?php echo WEBSITE_URL ?>/action.php?target=magnet&toggle=star&magnetId=<?php echo $response->magnet->magnetId ?>&callback=<?php echo base64_encode(sprintf('%s/magnet.php?magnetId=%s', WEBSITE_URL, $response->magnet->magnetId)) ?>" title="<?php echo _('Star') ?>">

68
src/public/node.php

@ -39,64 +39,6 @@ else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROV @@ -39,64 +39,6 @@ else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROV
$response->message = _('Could not init user session');
}
else
{
// Scrapes
$localScrape = (object)
[
'seeders' => 0,
'completed' => 0,
'leechers' => 0,
];
$totalScrape = (object)
[
'seeders' => 0,
'completed' => 0,
'leechers' => 0,
];
$trackers = [];
foreach (TRACKER_LINKS as $tracker)
{
$trackers[] = $tracker->announce;
}
foreach ($db->getMagnets() as $magnet)
{
foreach ($db->findAddressTrackerByMagnetId($magnet->magnetId) as $magnetToAddressTracker)
{
if ($addressTracker = $db->getAddressTracker($magnetToAddressTracker->addressTrackerId))
{
$scheme = $db->getScheme($addressTracker->schemeId);
$host = $db->getHost($addressTracker->hostId);
$port = $db->getPort($addressTracker->portId);
$uri = $db->getUri($addressTracker->uriId);
$url = $port->value ? sprintf('%s://%s:%s%s', $scheme->value,
$host->value,
$port->value,
$uri->value) : sprintf('%s://%s%s', $scheme->value,
$host->value,
$uri->value);
if (in_array($url, $trackers))
{
$localScrape->seeders += (int) $magnetToAddressTracker->seeders;
$localScrape->completed += (int) $magnetToAddressTracker->completed;
$localScrape->leechers += (int) $magnetToAddressTracker->leechers;
}
$totalScrape->seeders += (int) $magnetToAddressTracker->seeders;
$totalScrape->completed += (int) $magnetToAddressTracker->completed;
$totalScrape->leechers += (int) $magnetToAddressTracker->leechers;
}
}
}
}
?>
<!DOCTYPE html>
<html lang="en-US">
@ -144,10 +86,6 @@ else @@ -144,10 +86,6 @@ else
<td><?php echo _('Languages') ?></td>
<td><?php echo _(RULE_LANGUAGES) ?></td>
</tr>
<tr>
<td><?php echo _('Yggdrasil only') ?></td>
<td><?php echo MAGNET_DOWNLOAD_YGGDRASIL_URL_ONLY ? _('yes') : _('no') ?></td>
</tr>
<tr>
<td class="padding-y-8 border-bottom-default text-right" colspan="2">
<?php echo _('Totals') ?>
@ -171,15 +109,15 @@ else @@ -171,15 +109,15 @@ else
</tr>
<tr>
<td><?php echo _('Seeders') ?></td>
<td><?php echo sprintf('%s / %s', $localScrape->seeders, $totalScrape->seeders) ?></td>
<td><?php echo $db->getMagnetToAddressTrackerSeedersSum() ?></td>
</tr>
<tr>
<td><?php echo _('Peers') ?></td>
<td><?php echo sprintf('%s / %s', $localScrape->completed, $totalScrape->completed) ?></td>
<td><?php echo $db->getMagnetToAddressTrackerCompletedSum() ?></td>
</tr>
<tr>
<td><?php echo _('Leechers') ?></td>
<td><?php echo sprintf('%s / %s', $localScrape->leechers, $totalScrape->leechers) ?></td>
<td><?php echo $db->getMagnetToAddressTrackerLeechersSum() ?></td>
</tr>
<tr>
<td class="padding-y-8 border-bottom-default text-right" colspan="2">

Loading…
Cancel
Save