mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-01-10 23:17:53 +00:00
update action api
This commit is contained in:
parent
5b03f386fe
commit
a20ae75307
@ -271,360 +271,363 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'star':
|
case 'magnet':
|
||||||
|
|
||||||
// Yggdrasil connections only
|
switch (isset($_GET['toggle']) ? $_GET['toggle'] : false)
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
|
||||||
{
|
{
|
||||||
$response->success = false;
|
case 'star':
|
||||||
$response->message = _('Yggdrasil connection required for this action');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init session
|
// Yggdrasil connections only
|
||||||
else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROVED, time()))
|
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
||||||
{
|
|
||||||
$response->success = false;
|
|
||||||
$response->message = _('Could not init user session');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Magnet exists
|
|
||||||
else if (!$magnet = $db->getMagnet(isset($_GET['magnetId']) && $_GET['magnetId'] > 0 ? (int) $_GET['magnetId'] : 0))
|
|
||||||
{
|
|
||||||
$response->success = false;
|
|
||||||
$response->message = _('Requested magnet not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Access allowed
|
|
||||||
else if (!($_SERVER['REMOTE_ADDR'] == $db->getUser($magnet->userId)->address || in_array($_SERVER['REMOTE_ADDR'], MODERATOR_IP_LIST) || ($magnet->public && $magnet->approved))) {
|
|
||||||
|
|
||||||
$response->success = false;
|
|
||||||
$response->message = _('Magnet not available for this action');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate callback
|
|
||||||
else if (empty($_GET['callback']))
|
|
||||||
{
|
|
||||||
$response->success = false;
|
|
||||||
$response->message = _('Callback required');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate base64
|
|
||||||
else if (!$callback = (string) @base64_decode($_GET['callback']))
|
|
||||||
{
|
|
||||||
$response->success = false;
|
|
||||||
$response->message = _('Invalid callback encoding');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request valid
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Star exists, trigger delete
|
|
||||||
if ($db->findMagnetStarsTotalByUserId($magnet->magnetId, $userId))
|
|
||||||
{
|
|
||||||
$db->deleteMagnetStarByUserId($magnet->magnetId, $userId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Star not exists, trigger add
|
|
||||||
$db->addMagnetStar($magnet->magnetId, $userId, time());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Redirect to edit page
|
|
||||||
header(
|
|
||||||
sprintf('Location: %s', $callback)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'download':
|
|
||||||
|
|
||||||
// Yggdrasil connections only
|
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
|
||||||
{
|
|
||||||
$response->success = false;
|
|
||||||
$response->message = _('Yggdrasil connection required for this action');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init session
|
|
||||||
else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROVED, time()))
|
|
||||||
{
|
|
||||||
$response->success = false;
|
|
||||||
$response->message = _('Could not init user session');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Magnet exists
|
|
||||||
else if (!$magnet = $db->getMagnet(isset($_GET['magnetId']) && $_GET['magnetId'] > 0 ? (int) $_GET['magnetId'] : 0))
|
|
||||||
{
|
|
||||||
$response->success = false;
|
|
||||||
$response->message = _('Requested magnet not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Access allowed
|
|
||||||
else if (!($_SERVER['REMOTE_ADDR'] == $db->getUser($magnet->userId)->address || in_array($_SERVER['REMOTE_ADDR'], MODERATOR_IP_LIST) || ($magnet->public && $magnet->approved))) {
|
|
||||||
|
|
||||||
$response->success = false;
|
|
||||||
$response->message = _('Magnet not available for this action');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request valid
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Update download stats
|
|
||||||
$db->addMagnetDownload($magnet->magnetId, $userId, time());
|
|
||||||
|
|
||||||
// Build magnet link
|
|
||||||
$link = [];
|
|
||||||
|
|
||||||
/// Exact Topic
|
|
||||||
$link[] = sprintf('magnet:?xt=%s', $magnet->xt);
|
|
||||||
|
|
||||||
/// Display Name
|
|
||||||
$link[] = sprintf('dn=%s', urlencode($magnet->dn));
|
|
||||||
|
|
||||||
// Keyword Topic
|
|
||||||
$kt = [];
|
|
||||||
|
|
||||||
foreach ($db->findKeywordTopicByMagnetId($magnet->magnetId) as $result)
|
|
||||||
{
|
|
||||||
$kt[] = urlencode($db->getKeywordTopic($result->keywordTopicId)->value);
|
|
||||||
}
|
|
||||||
|
|
||||||
$link[] = sprintf('kt=%s', implode('+', $kt));
|
|
||||||
|
|
||||||
/// Address Tracker
|
|
||||||
foreach ($db->findAddressTrackerByMagnetId($magnet->magnetId) as $result)
|
|
||||||
{
|
|
||||||
$addressTracker = $db->getAddressTracker($result->addressTrackerId);
|
|
||||||
|
|
||||||
$scheme = $db->getScheme($addressTracker->schemeId);
|
|
||||||
$host = $db->getHost($addressTracker->hostId);
|
|
||||||
$port = $db->getPort($addressTracker->portId);
|
|
||||||
$uri = $db->getUri($addressTracker->uriId);
|
|
||||||
|
|
||||||
$link[] = 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)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Acceptable Source
|
|
||||||
foreach ($db->findAcceptableSourceByMagnetId($magnet->magnetId) as $result)
|
|
||||||
{
|
|
||||||
$acceptableSource = $db->getAcceptableSource($result->acceptableSourceId);
|
|
||||||
|
|
||||||
$scheme = $db->getScheme($acceptableSource->schemeId);
|
|
||||||
$host = $db->getHost($acceptableSource->hostId);
|
|
||||||
$port = $db->getPort($acceptableSource->portId);
|
|
||||||
$uri = $db->getUri($acceptableSource->uriId);
|
|
||||||
|
|
||||||
$link[] = 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)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Exact Source
|
|
||||||
foreach ($db->findExactSourceByMagnetId($magnet->magnetId) as $result)
|
|
||||||
{
|
|
||||||
$eXactSource = $db->getExactSource($result->eXactSourceId);
|
|
||||||
|
|
||||||
$scheme = $db->getScheme($eXactSource->schemeId);
|
|
||||||
$host = $db->getHost($eXactSource->hostId);
|
|
||||||
$port = $db->getPort($eXactSource->portId);
|
|
||||||
$uri = $db->getUri($eXactSource->uriId);
|
|
||||||
|
|
||||||
$link[] = 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 download link
|
|
||||||
header(
|
|
||||||
sprintf('Location: %s', implode('&', $link))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'new':
|
|
||||||
|
|
||||||
// Yggdrasil connections only
|
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
|
||||||
{
|
|
||||||
$response->success = false;
|
|
||||||
$response->message = _('Yggdrasil connection required for this action');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init session
|
|
||||||
else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROVED, time()))
|
|
||||||
{
|
|
||||||
$response->success = false;
|
|
||||||
$response->message = _('Could not init user session');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get user
|
|
||||||
else if (!$user = $db->getUser($userId))
|
|
||||||
{
|
|
||||||
$response->success = false;
|
|
||||||
$response->message = _('Could not init user info');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate link
|
|
||||||
if (empty($_GET['magnet']))
|
|
||||||
{
|
|
||||||
$response->success = false;
|
|
||||||
$response->message = _('Link required');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate base64
|
|
||||||
else if (!$link = (string) @base64_decode($_GET['magnet']))
|
|
||||||
{
|
|
||||||
$response->success = false;
|
|
||||||
$response->message = _('Invalid link encoding');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate magnet
|
|
||||||
else if (!$magnet = Yggverse\Parser\Magnet::parse($link))
|
|
||||||
{
|
|
||||||
$response->success = false;
|
|
||||||
$response->message = _('Invalid magnet link');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request valid
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Begin magnet registration
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$db->beginTransaction();
|
|
||||||
|
|
||||||
// Init magnet
|
|
||||||
if (Yggverse\Parser\Urn::parse($magnet->xt))
|
|
||||||
{
|
{
|
||||||
if ($magnetId = $db->initMagnetId($user->userId,
|
$response->success = false;
|
||||||
strip_tags($magnet->xt),
|
$response->message = _('Yggdrasil connection required for this action');
|
||||||
strip_tags($magnet->xl),
|
}
|
||||||
strip_tags($magnet->dn),
|
|
||||||
$link,
|
// Init session
|
||||||
MAGNET_DEFAULT_PUBLIC,
|
else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROVED, time()))
|
||||||
MAGNET_DEFAULT_COMMENTS,
|
{
|
||||||
MAGNET_DEFAULT_SENSITIVE,
|
$response->success = false;
|
||||||
$user->approved ? true : MAGNET_DEFAULT_APPROVED,
|
$response->message = _('Could not init user session');
|
||||||
time()))
|
}
|
||||||
|
|
||||||
|
// Magnet exists
|
||||||
|
else if (!$magnet = $db->getMagnet(isset($_GET['magnetId']) && $_GET['magnetId'] > 0 ? (int) $_GET['magnetId'] : 0))
|
||||||
|
{
|
||||||
|
$response->success = false;
|
||||||
|
$response->message = _('Requested magnet not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Access allowed
|
||||||
|
else if (!($_SERVER['REMOTE_ADDR'] == $db->getUser($magnet->userId)->address || in_array($_SERVER['REMOTE_ADDR'], MODERATOR_IP_LIST) || ($magnet->public && $magnet->approved))) {
|
||||||
|
|
||||||
|
$response->success = false;
|
||||||
|
$response->message = _('Magnet not available for this action');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate callback
|
||||||
|
else if (empty($_GET['callback']))
|
||||||
|
{
|
||||||
|
$response->success = false;
|
||||||
|
$response->message = _('Callback required');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate base64
|
||||||
|
else if (!$callback = (string) @base64_decode($_GET['callback']))
|
||||||
|
{
|
||||||
|
$response->success = false;
|
||||||
|
$response->message = _('Invalid callback encoding');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request valid
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Star exists, trigger delete
|
||||||
|
if ($db->findMagnetStarsTotalByUserId($magnet->magnetId, $userId))
|
||||||
{
|
{
|
||||||
foreach ($magnet as $key => $value)
|
$db->deleteMagnetStarByUserId($magnet->magnetId, $userId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Star not exists, trigger add
|
||||||
|
$db->addMagnetStar($magnet->magnetId, $userId, time());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirect to edit page
|
||||||
|
header(
|
||||||
|
sprintf('Location: %s', $callback)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'download':
|
||||||
|
|
||||||
|
// Yggdrasil connections only
|
||||||
|
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
||||||
|
{
|
||||||
|
$response->success = false;
|
||||||
|
$response->message = _('Yggdrasil connection required for this action');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init session
|
||||||
|
else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROVED, time()))
|
||||||
|
{
|
||||||
|
$response->success = false;
|
||||||
|
$response->message = _('Could not init user session');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Magnet exists
|
||||||
|
else if (!$magnet = $db->getMagnet(isset($_GET['magnetId']) && $_GET['magnetId'] > 0 ? (int) $_GET['magnetId'] : 0))
|
||||||
|
{
|
||||||
|
$response->success = false;
|
||||||
|
$response->message = _('Requested magnet not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Access allowed
|
||||||
|
else if (!($_SERVER['REMOTE_ADDR'] == $db->getUser($magnet->userId)->address || in_array($_SERVER['REMOTE_ADDR'], MODERATOR_IP_LIST) || ($magnet->public && $magnet->approved))) {
|
||||||
|
|
||||||
|
$response->success = false;
|
||||||
|
$response->message = _('Magnet not available for this action');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request valid
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Update download stats
|
||||||
|
$db->addMagnetDownload($magnet->magnetId, $userId, time());
|
||||||
|
|
||||||
|
// Build magnet link
|
||||||
|
$link = [];
|
||||||
|
|
||||||
|
/// Exact Topic
|
||||||
|
$link[] = sprintf('magnet:?xt=%s', $magnet->xt);
|
||||||
|
|
||||||
|
/// Display Name
|
||||||
|
$link[] = sprintf('dn=%s', urlencode($magnet->dn));
|
||||||
|
|
||||||
|
// Keyword Topic
|
||||||
|
$kt = [];
|
||||||
|
|
||||||
|
foreach ($db->findKeywordTopicByMagnetId($magnet->magnetId) as $result)
|
||||||
|
{
|
||||||
|
$kt[] = urlencode($db->getKeywordTopic($result->keywordTopicId)->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
$link[] = sprintf('kt=%s', implode('+', $kt));
|
||||||
|
|
||||||
|
/// Address Tracker
|
||||||
|
foreach ($db->findAddressTrackerByMagnetId($magnet->magnetId) as $result)
|
||||||
|
{
|
||||||
|
$addressTracker = $db->getAddressTracker($result->addressTrackerId);
|
||||||
|
|
||||||
|
$scheme = $db->getScheme($addressTracker->schemeId);
|
||||||
|
$host = $db->getHost($addressTracker->hostId);
|
||||||
|
$port = $db->getPort($addressTracker->portId);
|
||||||
|
$uri = $db->getUri($addressTracker->uriId);
|
||||||
|
|
||||||
|
$link[] = 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)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Acceptable Source
|
||||||
|
foreach ($db->findAcceptableSourceByMagnetId($magnet->magnetId) as $result)
|
||||||
|
{
|
||||||
|
$acceptableSource = $db->getAcceptableSource($result->acceptableSourceId);
|
||||||
|
|
||||||
|
$scheme = $db->getScheme($acceptableSource->schemeId);
|
||||||
|
$host = $db->getHost($acceptableSource->hostId);
|
||||||
|
$port = $db->getPort($acceptableSource->portId);
|
||||||
|
$uri = $db->getUri($acceptableSource->uriId);
|
||||||
|
|
||||||
|
$link[] = 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)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Exact Source
|
||||||
|
foreach ($db->findExactSourceByMagnetId($magnet->magnetId) as $result)
|
||||||
|
{
|
||||||
|
$eXactSource = $db->getExactSource($result->eXactSourceId);
|
||||||
|
|
||||||
|
$scheme = $db->getScheme($eXactSource->schemeId);
|
||||||
|
$host = $db->getHost($eXactSource->hostId);
|
||||||
|
$port = $db->getPort($eXactSource->portId);
|
||||||
|
$uri = $db->getUri($eXactSource->uriId);
|
||||||
|
|
||||||
|
$link[] = 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 download link
|
||||||
|
header(
|
||||||
|
sprintf('Location: %s', implode('&', $link))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'new':
|
||||||
|
|
||||||
|
// Yggdrasil connections only
|
||||||
|
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
||||||
|
{
|
||||||
|
$response->success = false;
|
||||||
|
$response->message = _('Yggdrasil connection required for this action');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init session
|
||||||
|
else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROVED, time()))
|
||||||
|
{
|
||||||
|
$response->success = false;
|
||||||
|
$response->message = _('Could not init user session');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get user
|
||||||
|
else if (!$user = $db->getUser($userId))
|
||||||
|
{
|
||||||
|
$response->success = false;
|
||||||
|
$response->message = _('Could not init user info');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate link
|
||||||
|
if (empty($_GET['magnet']))
|
||||||
|
{
|
||||||
|
$response->success = false;
|
||||||
|
$response->message = _('Link required');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate base64
|
||||||
|
else if (!$link = (string) @base64_decode($_GET['magnet']))
|
||||||
|
{
|
||||||
|
$response->success = false;
|
||||||
|
$response->message = _('Invalid link encoding');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate magnet
|
||||||
|
else if (!$magnet = Yggverse\Parser\Magnet::parse($link))
|
||||||
|
{
|
||||||
|
$response->success = false;
|
||||||
|
$response->message = _('Invalid magnet link');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request valid
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Begin magnet registration
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$db->beginTransaction();
|
||||||
|
|
||||||
|
// Init magnet
|
||||||
|
if (Yggverse\Parser\Urn::parse($magnet->xt))
|
||||||
{
|
{
|
||||||
switch ($key)
|
if ($magnetId = $db->initMagnetId($user->userId,
|
||||||
|
strip_tags($magnet->xt),
|
||||||
|
strip_tags($magnet->xl),
|
||||||
|
strip_tags($magnet->dn),
|
||||||
|
$link,
|
||||||
|
MAGNET_DEFAULT_PUBLIC,
|
||||||
|
MAGNET_DEFAULT_COMMENTS,
|
||||||
|
MAGNET_DEFAULT_SENSITIVE,
|
||||||
|
$user->approved ? true : MAGNET_DEFAULT_APPROVED,
|
||||||
|
time()))
|
||||||
{
|
{
|
||||||
case 'tr':
|
foreach ($magnet as $key => $value)
|
||||||
foreach ($value as $tr)
|
{
|
||||||
|
switch ($key)
|
||||||
{
|
{
|
||||||
if ($url = Yggverse\Parser\Url::parse($tr))
|
case 'tr':
|
||||||
{
|
foreach ($value as $tr)
|
||||||
$db->initMagnetToAddressTrackerId(
|
{
|
||||||
$magnetId,
|
if ($url = Yggverse\Parser\Url::parse($tr))
|
||||||
$db->initAddressTrackerId(
|
{
|
||||||
$db->initSchemeId($url->host->scheme),
|
$db->initMagnetToAddressTrackerId(
|
||||||
$db->initHostId($url->host->name),
|
$magnetId,
|
||||||
$db->initPortId($url->host->port),
|
$db->initAddressTrackerId(
|
||||||
$db->initUriId($url->page->uri)
|
$db->initSchemeId($url->host->scheme),
|
||||||
)
|
$db->initHostId($url->host->name),
|
||||||
);
|
$db->initPortId($url->host->port),
|
||||||
}
|
$db->initUriId($url->page->uri)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'ws':
|
||||||
|
foreach ($value as $ws)
|
||||||
|
{
|
||||||
|
// @TODO
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'as':
|
||||||
|
foreach ($value as $as)
|
||||||
|
{
|
||||||
|
if ($url = Yggverse\Parser\Url::parse($as))
|
||||||
|
{
|
||||||
|
$db->initMagnetToAcceptableSourceId(
|
||||||
|
$magnetId,
|
||||||
|
$db->initAcceptableSourceId(
|
||||||
|
$db->initSchemeId($url->host->scheme),
|
||||||
|
$db->initHostId($url->host->name),
|
||||||
|
$db->initPortId($url->host->port),
|
||||||
|
$db->initUriId($url->page->uri)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'xs':
|
||||||
|
foreach ($value as $xs)
|
||||||
|
{
|
||||||
|
if ($url = Yggverse\Parser\Url::parse($xs))
|
||||||
|
{
|
||||||
|
$db->initMagnetToExactSourceId(
|
||||||
|
$magnetId,
|
||||||
|
$db->initExactSourceId(
|
||||||
|
$db->initSchemeId($url->host->scheme),
|
||||||
|
$db->initHostId($url->host->name),
|
||||||
|
$db->initPortId($url->host->port),
|
||||||
|
$db->initUriId($url->page->uri)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'mt':
|
||||||
|
foreach ($value as $mt)
|
||||||
|
{
|
||||||
|
// @TODO
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'x.pe':
|
||||||
|
foreach ($value as $xPe)
|
||||||
|
{
|
||||||
|
// @TODO
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'kt':
|
||||||
|
foreach ($value as $kt)
|
||||||
|
{
|
||||||
|
$db->initMagnetToKeywordTopicId(
|
||||||
|
$magnetId,
|
||||||
|
$db->initKeywordTopicId(trim(mb_strtolower(strip_tags(html_entity_decode($kt)))))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case 'ws':
|
|
||||||
foreach ($value as $ws)
|
$db->commit();
|
||||||
{
|
|
||||||
// @TODO
|
// Redirect to edit page
|
||||||
}
|
header(sprintf('Location: %s/edit.php?magnetId=%s', trim(WEBSITE_URL, '/'), $magnetId));
|
||||||
break;
|
|
||||||
case 'as':
|
|
||||||
foreach ($value as $as)
|
|
||||||
{
|
|
||||||
if ($url = Yggverse\Parser\Url::parse($as))
|
|
||||||
{
|
|
||||||
$db->initMagnetToAcceptableSourceId(
|
|
||||||
$magnetId,
|
|
||||||
$db->initAcceptableSourceId(
|
|
||||||
$db->initSchemeId($url->host->scheme),
|
|
||||||
$db->initHostId($url->host->name),
|
|
||||||
$db->initPortId($url->host->port),
|
|
||||||
$db->initUriId($url->page->uri)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'xs':
|
|
||||||
foreach ($value as $xs)
|
|
||||||
{
|
|
||||||
if ($url = Yggverse\Parser\Url::parse($xs))
|
|
||||||
{
|
|
||||||
$db->initMagnetToExactSourceId(
|
|
||||||
$magnetId,
|
|
||||||
$db->initExactSourceId(
|
|
||||||
$db->initSchemeId($url->host->scheme),
|
|
||||||
$db->initHostId($url->host->name),
|
|
||||||
$db->initPortId($url->host->port),
|
|
||||||
$db->initUriId($url->page->uri)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'mt':
|
|
||||||
foreach ($value as $mt)
|
|
||||||
{
|
|
||||||
// @TODO
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'x.pe':
|
|
||||||
foreach ($value as $xPe)
|
|
||||||
{
|
|
||||||
// @TODO
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'kt':
|
|
||||||
foreach ($value as $kt)
|
|
||||||
{
|
|
||||||
$db->initMagnetToKeywordTopicId(
|
|
||||||
$magnetId,
|
|
||||||
$db->initKeywordTopicId(trim(mb_strtolower(strip_tags(html_entity_decode($kt)))))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->commit();
|
} catch (Exception $e) {
|
||||||
|
|
||||||
// Redirect to edit page
|
var_dump($e);
|
||||||
header(sprintf('Location: %s/edit.php?magnetId=%s', trim(WEBSITE_URL, '/'), $magnetId));
|
|
||||||
|
$db->rollBack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception $e) {
|
break;
|
||||||
|
|
||||||
var_dump($e);
|
|
||||||
|
|
||||||
$db->rollBack();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
header(
|
|
||||||
sprintf('Location: %s', WEBSITE_URL)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -78,7 +78,7 @@ else
|
|||||||
if ($magnet = Yggverse\Parser\Magnet::is($request->query))
|
if ($magnet = Yggverse\Parser\Magnet::is($request->query))
|
||||||
{
|
{
|
||||||
header(
|
header(
|
||||||
sprintf('Location: %s/action.php?target=new&magnet=%s', WEBSITE_URL, base64_encode($request->query))
|
sprintf('Location: %s/action.php?target=magnet&toggle=new&magnet=%s', WEBSITE_URL, base64_encode($request->query))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +297,7 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?>
|
|||||||
</a>
|
</a>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<!-- TODO
|
<!-- TODO
|
||||||
<a class="text-color-pink margin-l-12" href="<?php echo WEBSITE_URL ?>/action.php?target=report&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 _('Report') ?>">
|
<a class="text-color-pink margin-l-12" href="<?php echo WEBSITE_URL ?>/action.php?target=magnet&toggle=report&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 _('Report') ?>">
|
||||||
<svg class="text-color-pink" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-flag" viewBox="0 0 16 16">
|
<svg class="text-color-pink" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-flag" viewBox="0 0 16 16">
|
||||||
<path d="M14.778.085A.5.5 0 0 1 15 .5V8a.5.5 0 0 1-.314.464L14.5 8l.186.464-.003.001-.006.003-.023.009a12.435 12.435 0 0 1-.397.15c-.264.095-.631.223-1.047.35-.816.252-1.879.523-2.71.523-.847 0-1.548-.28-2.158-.525l-.028-.01C7.68 8.71 7.14 8.5 6.5 8.5c-.7 0-1.638.23-2.437.477A19.626 19.626 0 0 0 3 9.342V15.5a.5.5 0 0 1-1 0V.5a.5.5 0 0 1 1 0v.282c.226-.079.496-.17.79-.26C4.606.272 5.67 0 6.5 0c.84 0 1.524.277 2.121.519l.043.018C9.286.788 9.828 1 10.5 1c.7 0 1.638-.23 2.437-.477a19.587 19.587 0 0 0 1.349-.476l.019-.007.004-.002h.001M14 1.221c-.22.078-.48.167-.766.255-.81.252-1.872.523-2.734.523-.886 0-1.592-.286-2.203-.534l-.008-.003C7.662 1.21 7.139 1 6.5 1c-.669 0-1.606.229-2.415.478A21.294 21.294 0 0 0 3 1.845v6.433c.22-.078.48-.167.766-.255C4.576 7.77 5.638 7.5 6.5 7.5c.847 0 1.548.28 2.158.525l.028.01C9.32 8.29 9.86 8.5 10.5 8.5c.668 0 1.606-.229 2.415-.478A21.317 21.317 0 0 0 14 7.655V1.222z"/>
|
<path d="M14.778.085A.5.5 0 0 1 15 .5V8a.5.5 0 0 1-.314.464L14.5 8l.186.464-.003.001-.006.003-.023.009a12.435 12.435 0 0 1-.397.15c-.264.095-.631.223-1.047.35-.816.252-1.879.523-2.71.523-.847 0-1.548-.28-2.158-.525l-.028-.01C7.68 8.71 7.14 8.5 6.5 8.5c-.7 0-1.638.23-2.437.477A19.626 19.626 0 0 0 3 9.342V15.5a.5.5 0 0 1-1 0V.5a.5.5 0 0 1 1 0v.282c.226-.079.496-.17.79-.26C4.606.272 5.67 0 6.5 0c.84 0 1.524.277 2.121.519l.043.018C9.286.788 9.828 1 10.5 1c.7 0 1.638-.23 2.437-.477a19.587 19.587 0 0 0 1.349-.476l.019-.007.004-.002h.001M14 1.221c-.22.078-.48.167-.766.255-.81.252-1.872.523-2.734.523-.886 0-1.592-.286-2.203-.534l-.008-.003C7.662 1.21 7.139 1 6.5 1c-.669 0-1.606.229-2.415.478A21.294 21.294 0 0 0 3 1.845v6.433c.22-.078.48-.167.766-.255C4.576 7.77 5.638 7.5 6.5 7.5c.847 0 1.548.28 2.158.525l.028.01C9.32 8.29 9.86 8.5 10.5 8.5c.668 0 1.606-.229 2.415-.478A21.317 21.317 0 0 0 14 7.655V1.222z"/>
|
||||||
</svg>
|
</svg>
|
||||||
@ -353,7 +353,7 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?>
|
|||||||
<sup><?php echo $magnet->scrape->local->leechers ?> / <?php echo $magnet->scrape->total->leechers ?></sup>
|
<sup><?php echo $magnet->scrape->local->leechers ?> / <?php echo $magnet->scrape->total->leechers ?></sup>
|
||||||
</span>
|
</span>
|
||||||
<span class="float-right margin-l-12">
|
<span class="float-right margin-l-12">
|
||||||
<a href="<?php echo WEBSITE_URL ?>/action.php?target=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') ?>">
|
<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') ?>">
|
||||||
<?php if ($magnet->star->status) { ?>
|
<?php if ($magnet->star->status) { ?>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-star-fill" viewBox="0 0 16 16">
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-star-fill" viewBox="0 0 16 16">
|
||||||
<path d="M3.612 15.443c-.386.198-.824-.149-.746-.592l.83-4.73L.173 6.765c-.329-.314-.158-.888.283-.95l4.898-.696L7.538.792c.197-.39.73-.39.927 0l2.184 4.327 4.898.696c.441.062.612.636.282.95l-3.522 3.356.83 4.73c.078.443-.36.79-.746.592L8 13.187l-4.389 2.256z"/>
|
<path d="M3.612 15.443c-.386.198-.824-.149-.746-.592l.83-4.73L.173 6.765c-.329-.314-.158-.888.283-.95l4.898-.696L7.538.792c.197-.39.73-.39.927 0l2.184 4.327 4.898.696c.441.062.612.636.282.95l-3.522 3.356.83 4.73c.078.443-.36.79-.746.592L8 13.187l-4.389 2.256z"/>
|
||||||
@ -381,7 +381,7 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?>
|
|||||||
<sup><?php echo $magnet->comment->total ?></sup>
|
<sup><?php echo $magnet->comment->total ?></sup>
|
||||||
</span>
|
</span>
|
||||||
<span class="float-right margin-l-12">
|
<span class="float-right margin-l-12">
|
||||||
<a href="<?php echo WEBSITE_URL ?>/action.php?target=download&magnetId=<?php echo $magnet->magnetId ?>" title="<?php echo _('Download') ?>">
|
<a href="<?php echo WEBSITE_URL ?>/action.php?target=magnet&toggle=download&magnetId=<?php echo $magnet->magnetId ?>" title="<?php echo _('Download') ?>">
|
||||||
<?php if ($magnet->download->status) { ?>
|
<?php if ($magnet->download->status) { ?>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-down-circle-fill" viewBox="0 0 16 16">
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-down-circle-fill" viewBox="0 0 16 16">
|
||||||
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8.5 4.5a.5.5 0 0 0-1 0v5.793L5.354 8.146a.5.5 0 1 0-.708.708l3 3a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V4.5z"/>
|
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8.5 4.5a.5.5 0 0 0-1 0v5.793L5.354 8.146a.5.5 0 1 0-.708.708l3 3a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V4.5z"/>
|
||||||
|
@ -272,7 +272,7 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?>
|
|||||||
</a>
|
</a>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<!-- TODO
|
<!-- TODO
|
||||||
<a class="text-color-pink margin-l-12" href="<?php echo WEBSITE_URL ?>/action.php?target=report&magnetId=<?php echo $response->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 _('Report') ?>">
|
<a class="text-color-pink margin-l-12" href="<?php echo WEBSITE_URL ?>/action.php?target=magnet&toggle=report&magnetId=<?php echo $response->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 _('Report') ?>">
|
||||||
<svg class="text-color-pink" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-flag" viewBox="0 0 16 16">
|
<svg class="text-color-pink" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-flag" viewBox="0 0 16 16">
|
||||||
<path d="M14.778.085A.5.5 0 0 1 15 .5V8a.5.5 0 0 1-.314.464L14.5 8l.186.464-.003.001-.006.003-.023.009a12.435 12.435 0 0 1-.397.15c-.264.095-.631.223-1.047.35-.816.252-1.879.523-2.71.523-.847 0-1.548-.28-2.158-.525l-.028-.01C7.68 8.71 7.14 8.5 6.5 8.5c-.7 0-1.638.23-2.437.477A19.626 19.626 0 0 0 3 9.342V15.5a.5.5 0 0 1-1 0V.5a.5.5 0 0 1 1 0v.282c.226-.079.496-.17.79-.26C4.606.272 5.67 0 6.5 0c.84 0 1.524.277 2.121.519l.043.018C9.286.788 9.828 1 10.5 1c.7 0 1.638-.23 2.437-.477a19.587 19.587 0 0 0 1.349-.476l.019-.007.004-.002h.001M14 1.221c-.22.078-.48.167-.766.255-.81.252-1.872.523-2.734.523-.886 0-1.592-.286-2.203-.534l-.008-.003C7.662 1.21 7.139 1 6.5 1c-.669 0-1.606.229-2.415.478A21.294 21.294 0 0 0 3 1.845v6.433c.22-.078.48-.167.766-.255C4.576 7.77 5.638 7.5 6.5 7.5c.847 0 1.548.28 2.158.525l.028.01C9.32 8.29 9.86 8.5 10.5 8.5c.668 0 1.606-.229 2.415-.478A21.317 21.317 0 0 0 14 7.655V1.222z"/>
|
<path d="M14.778.085A.5.5 0 0 1 15 .5V8a.5.5 0 0 1-.314.464L14.5 8l.186.464-.003.001-.006.003-.023.009a12.435 12.435 0 0 1-.397.15c-.264.095-.631.223-1.047.35-.816.252-1.879.523-2.71.523-.847 0-1.548-.28-2.158-.525l-.028-.01C7.68 8.71 7.14 8.5 6.5 8.5c-.7 0-1.638.23-2.437.477A19.626 19.626 0 0 0 3 9.342V15.5a.5.5 0 0 1-1 0V.5a.5.5 0 0 1 1 0v.282c.226-.079.496-.17.79-.26C4.606.272 5.67 0 6.5 0c.84 0 1.524.277 2.121.519l.043.018C9.286.788 9.828 1 10.5 1c.7 0 1.638-.23 2.437-.477a19.587 19.587 0 0 0 1.349-.476l.019-.007.004-.002h.001M14 1.221c-.22.078-.48.167-.766.255-.81.252-1.872.523-2.734.523-.886 0-1.592-.286-2.203-.534l-.008-.003C7.662 1.21 7.139 1 6.5 1c-.669 0-1.606.229-2.415.478A21.294 21.294 0 0 0 3 1.845v6.433c.22-.078.48-.167.766-.255C4.576 7.77 5.638 7.5 6.5 7.5c.847 0 1.548.28 2.158.525l.028.01C9.32 8.29 9.86 8.5 10.5 8.5c.668 0 1.606-.229 2.415-.478A21.317 21.317 0 0 0 14 7.655V1.222z"/>
|
||||||
</svg>
|
</svg>
|
||||||
@ -328,7 +328,7 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?>
|
|||||||
<sup><?php echo $response->magnet->scrape->local->leechers ?> / <?php echo $response->magnet->scrape->total->leechers ?></sup>
|
<sup><?php echo $response->magnet->scrape->local->leechers ?> / <?php echo $response->magnet->scrape->total->leechers ?></sup>
|
||||||
</span>
|
</span>
|
||||||
<span class="float-right margin-l-12">
|
<span class="float-right margin-l-12">
|
||||||
<a href="<?php echo WEBSITE_URL ?>/action.php?target=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') ?>">
|
<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') ?>">
|
||||||
<?php if ($response->magnet->star->status) { ?>
|
<?php if ($response->magnet->star->status) { ?>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-star-fill" viewBox="0 0 16 16">
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-star-fill" viewBox="0 0 16 16">
|
||||||
<path d="M3.612 15.443c-.386.198-.824-.149-.746-.592l.83-4.73L.173 6.765c-.329-.314-.158-.888.283-.95l4.898-.696L7.538.792c.197-.39.73-.39.927 0l2.184 4.327 4.898.696c.441.062.612.636.282.95l-3.522 3.356.83 4.73c.078.443-.36.79-.746.592L8 13.187l-4.389 2.256z"/>
|
<path d="M3.612 15.443c-.386.198-.824-.149-.746-.592l.83-4.73L.173 6.765c-.329-.314-.158-.888.283-.95l4.898-.696L7.538.792c.197-.39.73-.39.927 0l2.184 4.327 4.898.696c.441.062.612.636.282.95l-3.522 3.356.83 4.73c.078.443-.36.79-.746.592L8 13.187l-4.389 2.256z"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user