|
|
|
@ -65,7 +65,11 @@ $response = (object)
@@ -65,7 +65,11 @@ $response = (object)
|
|
|
|
|
$db->addMagnetDownload($magnet->magnetId, $userId, time()); |
|
|
|
|
|
|
|
|
|
// Build magnet link |
|
|
|
|
$link = []; |
|
|
|
|
$link = (object) |
|
|
|
|
[ |
|
|
|
|
'magnet' => [], |
|
|
|
|
'direct' => [], |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
/// Exact Topic |
|
|
|
|
$xt = []; |
|
|
|
@ -91,10 +95,10 @@ $response = (object)
@@ -91,10 +95,10 @@ $response = (object)
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$link[] = sprintf('magnet:?%s', implode('&', $xt)); |
|
|
|
|
$link->magnet[] = sprintf('magnet:?%s', implode('&', $xt)); |
|
|
|
|
|
|
|
|
|
/// Display Name |
|
|
|
|
$link[] = sprintf('dn=%s', urlencode($magnet->dn)); |
|
|
|
|
$link->magnet[] = sprintf('dn=%s', urlencode($magnet->dn)); |
|
|
|
|
|
|
|
|
|
// Keyword Topic |
|
|
|
|
$kt = []; |
|
|
|
@ -104,7 +108,7 @@ $response = (object)
@@ -104,7 +108,7 @@ $response = (object)
|
|
|
|
|
$kt[] = urlencode($db->getKeywordTopic($result->keywordTopicId)->value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$link[] = sprintf('kt=%s', implode('+', $kt)); |
|
|
|
|
$link->magnet[] = sprintf('kt=%s', implode('+', $kt)); |
|
|
|
|
|
|
|
|
|
/// Address Tracker |
|
|
|
|
foreach ($db->findAddressTrackerByMagnetId($magnet->magnetId) as $result) |
|
|
|
@ -116,26 +120,24 @@ $response = (object)
@@ -116,26 +120,24 @@ $response = (object)
|
|
|
|
|
$port = $db->getPort($addressTracker->portId); |
|
|
|
|
$uri = $db->getUri($addressTracker->uriId); |
|
|
|
|
|
|
|
|
|
$url = sprintf('tr=%s', urlencode($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))); |
|
|
|
|
|
|
|
|
|
// Yggdrasil host only |
|
|
|
|
if (!preg_match(YGGDRASIL_HOST_REGEX, str_replace(['[',']'], false, $host->value))) |
|
|
|
|
{ |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$link[] = $url; |
|
|
|
|
$link->magnet[] = sprintf('tr=%s', urlencode($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))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Append trackers.json |
|
|
|
|
foreach (json_decode(file_get_contents(__DIR__ . '/../config/trackers.json')) as $tracker) |
|
|
|
|
{ |
|
|
|
|
$link[] = sprintf('tr=%s', urlencode($tracker->announce)); |
|
|
|
|
$link->magnet[] = sprintf('tr=%s', urlencode($tracker->announce)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Acceptable Source |
|
|
|
@ -148,19 +150,24 @@ $response = (object)
@@ -148,19 +150,24 @@ $response = (object)
|
|
|
|
|
$port = $db->getPort($acceptableSource->portId); |
|
|
|
|
$uri = $db->getUri($acceptableSource->uriId); |
|
|
|
|
|
|
|
|
|
$url = sprintf('as=%s', urlencode($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))); |
|
|
|
|
// Yggdrasil host only |
|
|
|
|
if (!preg_match(YGGDRASIL_HOST_REGEX, str_replace(['[',']'], false, $host->value))) |
|
|
|
|
{ |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$link[] = $url; |
|
|
|
|
$link->magnet[] = sprintf('as=%s', urlencode($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))); |
|
|
|
|
$link->direct[] = $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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Exact Source |
|
|
|
@ -173,20 +180,18 @@ $response = (object)
@@ -173,20 +180,18 @@ $response = (object)
|
|
|
|
|
$port = $db->getPort($eXactSource->portId); |
|
|
|
|
$uri = $db->getUri($eXactSource->uriId); |
|
|
|
|
|
|
|
|
|
$url = sprintf('xs=%s', urlencode($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))); |
|
|
|
|
|
|
|
|
|
// Yggdrasil host only |
|
|
|
|
if (!preg_match(YGGDRASIL_HOST_REGEX, str_replace(['[',']'], false, $host->value))) |
|
|
|
|
{ |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$link[] = $url; |
|
|
|
|
$link->magnet[] = sprintf('xs=%s', urlencode($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))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Return html |
|
|
|
@ -197,7 +202,10 @@ $response = (object)
@@ -197,7 +202,10 @@ $response = (object)
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$response->html->h1 = htmlentities($magnet->metaTitle); |
|
|
|
|
$response->html->link->magnet = implode('&', array_unique($link)); // @TODO implement .bittorrent and separated v1/v2 magnet links |
|
|
|
|
|
|
|
|
|
// @TODO implement .bittorrent, separated v1/v2 magnet links |
|
|
|
|
$response->html->link->magnet = implode('&', array_unique($link->magnet)); |
|
|
|
|
$response->html->link->direct = $link->direct; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
?> |
|
|
|
@ -208,7 +216,7 @@ $response = (object)
@@ -208,7 +216,7 @@ $response = (object)
|
|
|
|
|
<link rel="stylesheet" type="text/css" href="<?php echo WEBSITE_URL ?>/assets/theme/default/css/common.css?<?php echo WEBSITE_CSS_VERSION ?>" /> |
|
|
|
|
<link rel="stylesheet" type="text/css" href="<?php echo WEBSITE_URL ?>/assets/theme/default/css/framework.css?<?php echo WEBSITE_CSS_VERSION ?>" /> |
|
|
|
|
<title> |
|
|
|
|
<?php echo $response->data->title ?> |
|
|
|
|
<?php echo $response->html->title ?> |
|
|
|
|
</title> |
|
|
|
|
<meta name="robots" content="noindex,nofollow"/> |
|
|
|
|
<meta name="author" content="YGGtracker" /> |
|
|
|
@ -237,11 +245,19 @@ $response = (object)
@@ -237,11 +245,19 @@ $response = (object)
|
|
|
|
|
<div class="margin-b-16 text-color-night"> |
|
|
|
|
<?php echo _('* make sure BitTorrent client listen Yggdrasil interface!') ?> |
|
|
|
|
</div> |
|
|
|
|
<a href="<?php echo $response->html->link->magnet ?>"> |
|
|
|
|
<a class="padding-x-4" href="<?php echo $response->html->link->magnet ?>" title="<?php echo _('Magnet download') ?>"> |
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-magnet" viewBox="0 0 16 16"> |
|
|
|
|
<path d="M8 1a7 7 0 0 0-7 7v3h4V8a3 3 0 0 1 6 0v3h4V8a7 7 0 0 0-7-7Zm7 11h-4v3h4v-3ZM5 12H1v3h4v-3ZM0 8a8 8 0 1 1 16 0v8h-6V8a2 2 0 1 0-4 0v8H0V8Z"/> |
|
|
|
|
</svg> |
|
|
|
|
</a> |
|
|
|
|
<?php foreach ($response->html->link->direct as $direct) { ?> |
|
|
|
|
<a class="padding-x-4" href="<?php echo $direct ?>" title="<?php echo _('Direct download') ?>"> |
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-database-down" viewBox="0 0 16 16"> |
|
|
|
|
<path d="M12.5 9a3.5 3.5 0 1 1 0 7 3.5 3.5 0 0 1 0-7Zm.354 5.854 1.5-1.5a.5.5 0 0 0-.708-.708l-.646.647V10.5a.5.5 0 0 0-1 0v2.793l-.646-.647a.5.5 0 0 0-.708.708l1.5 1.5a.5.5 0 0 0 .708 0Z"/> |
|
|
|
|
<path d="M12.096 6.223A4.92 4.92 0 0 0 13 5.698V7c0 .289-.213.654-.753 1.007a4.493 4.493 0 0 1 1.753.25V4c0-1.007-.875-1.755-1.904-2.223C11.022 1.289 9.573 1 8 1s-3.022.289-4.096.777C2.875 2.245 2 2.993 2 4v9c0 1.007.875 1.755 1.904 2.223C4.978 15.71 6.427 16 8 16c.536 0 1.058-.034 1.555-.097a4.525 4.525 0 0 1-.813-.927C8.5 14.992 8.252 15 8 15c-1.464 0-2.766-.27-3.682-.687C3.356 13.875 3 13.373 3 13v-1.302c.271.202.58.378.904.525C4.978 12.71 6.427 13 8 13h.027a4.552 4.552 0 0 1 0-1H8c-1.464 0-2.766-.27-3.682-.687C3.356 10.875 3 10.373 3 10V8.698c.271.202.58.378.904.525C4.978 9.71 6.427 10 8 10c.262 0 .52-.008.774-.024a4.525 4.525 0 0 1 1.102-1.132C9.298 8.944 8.666 9 8 9c-1.464 0-2.766-.27-3.682-.687C3.356 7.875 3 7.373 3 7V5.698c.271.202.58.378.904.525C4.978 6.711 6.427 7 8 7s3.022-.289 4.096-.777ZM3 4c0-.374.356-.875 1.318-1.313C5.234 2.271 6.536 2 8 2s2.766.27 3.682.687C12.644 3.125 13 3.627 13 4c0 .374-.356.875-1.318 1.313C10.766 5.729 9.464 6 8 6s-2.766-.27-3.682-.687C3.356 4.875 3 4.373 3 4Z"/> |
|
|
|
|
</svg> |
|
|
|
|
</a> |
|
|
|
|
<?php } ?> |
|
|
|
|
</div> |
|
|
|
|
<?php } else { ?> |
|
|
|
|
<div class="text-center"> |
|
|
|
|