diff --git a/src/public/action.php b/src/public/action.php
deleted file mode 100644
index b4b1bdc..0000000
--- a/src/public/action.php
+++ /dev/null
@@ -1,670 +0,0 @@
- true,
- 'message' => _('Internal server error'),
- 'title' => sprintf(_('Oops - %s'), WEBSITE_NAME)
-];
-
-// Begin action request
-switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
-{
- case 'profile':
-
- switch (isset($_GET['toggle']) ? $_GET['toggle'] : false)
- {
- case 'jidenticon':
-
- // Yggdrasil connections only
- if (!Valid::host($_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');
- }
-
- // On first visit, redirect user to the welcome page with access level question
- else if (is_null($user->public))
- {
- header(
- sprintf('Location: %s/welcome.php', WEBSITE_URL)
- );
- }
-
- // Render icon
- else
- {
- header('Cache-Control: max-age=604800');
-
-
- $icon = new Jdenticon\Identicon();
-
- $icon->setValue($user->{USER_IDENTICON_FIELD});
- $icon->setSize(empty($_GET['size']) ? 100 : (int) $_GET['size']);
- $icon->setStyle(
- [
- 'backgroundColor' => 'rgba(255, 255, 255, 0)',
- ]
- );
- $icon->displayImage('webp');
- }
-
- break;
- }
-
- break;
-
- case 'comment':
-
- switch (isset($_GET['toggle']) ? $_GET['toggle'] : false)
- {
- case 'approved':
-
- // Yggdrasil connections only
- if (!Valid::host($_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');
- }
-
- // On first visit, redirect user to the welcome page with access level question
- else if (is_null($user->public))
- {
- header(
- sprintf('Location: %s/welcome.php', WEBSITE_URL)
- );
- }
-
- // Magnet comment exists
- else if (!$magnetComment = $db->getMagnetComment(isset($_GET['magnetCommentId']) && $_GET['magnetCommentId'] > 0 ? (int) $_GET['magnetCommentId'] : 0))
- {
- $response->success = false;
- $response->message = _('Requested magnet comment not found');
- }
-
- // Access allowed
- else if (!in_array($user->address, MODERATOR_IP_LIST)) {
-
- $response->success = false;
- $response->message = _('Access denied');
- }
-
- // 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
- {
- if ($magnetComment->approved)
- {
- $db->updateMagnetCommentApproved($magnetComment->magnetCommentId, false);
-
- if (USER_AUTO_APPROVE_ON_COMMENT_APPROVE)
- {
- $db->updateUserApproved($magnetComment->userId, false, time());
- }
- }
- else
- {
- $db->updateMagnetCommentApproved($magnetComment->magnetCommentId, true);
-
- if (USER_AUTO_APPROVE_ON_COMMENT_APPROVE)
- {
- $db->updateUserApproved($magnetComment->userId, true, time());
- }
- }
-
- // Redirect to edit page
- header(
- sprintf('Location: %s', $callback)
- );
- }
-
- break;
-
- case 'new':
-
- // Yggdrasil connections only
- if (!Valid::host($_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');
- }
-
- // On first visit, redirect user to the welcome page with access level question
- else if (is_null($user->public))
- {
- header(
- sprintf('Location: %s/welcome.php', WEBSITE_URL)
- );
- }
-
- // 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 (!($user->address == $db->getUser($magnet->userId)->address || in_array($user->address, 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');
- }
-
- // Validate comment value
- else if (empty($_POST['comment']) ||
- mb_strlen($_POST['comment']) < MAGNET_COMMENT_MIN_LENGTH ||
- mb_strlen($_POST['comment']) > MAGNET_COMMENT_MAX_LENGTH)
- {
- $response->success = false;
- $response->message = sprintf(_('Valid comment value required, %s-%s chars allowed'), MAGNET_COMMENT_MIN_LENGTH, MAGNET_COMMENT_MAX_LENGTH);
- }
-
- // Request valid
- else
- {
- if ($magnetCommentId = $db->addMagnetComment($magnet->magnetId,
- $user->userId,
- null, // @TODO implement threads
- trim($_POST['comment']),
- $user->approved || in_array($user->address, MODERATOR_IP_LIST) ? true : MAGNET_COMMENT_DEFAULT_APPROVED,
- MAGNET_COMMENT_DEFAULT_PUBLIC,
- time()))
- {
-
- // Push event to other nodes
- if (API_EXPORT_ENABLED &&
- API_EXPORT_PUSH_ENABLED &&
- API_EXPORT_USERS_ENABLED &&
- API_EXPORT_MAGNETS_ENABLED &&
- API_EXPORT_MAGNET_COMMENTS_ENABLED)
- {
- if (!$memoryApiExportPush = $memory->get('api.export.push'))
- {
- $memoryApiExportPush = [];
- }
-
- $memoryApiExportPush[] = (object)
- [
- 'time' => time(),
- 'userId' => $user->userId,
- 'magnetId' => $magnet->magnetId,
- 'magnetCommentId' => $magnetCommentId
- ];
-
- $memory->set('api.export.push', $memoryApiExportPush, 3600);
- }
-
- // Redirect to referrer page
- header(
- sprintf('Location: %s#comment-%s', $callback, $magnetCommentId)
- );
- }
- }
-
- break;
-
- default:
-
- header(
- sprintf('Location: %s', WEBSITE_URL)
- );
- }
-
- break;
-
- case 'magnet':
-
- switch (isset($_GET['toggle']) ? $_GET['toggle'] : false)
- {
- case 'star':
-
- // Yggdrasil connections only
- if (!Valid::host($_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');
- }
-
- // On first visit, redirect user to the welcome page with access level question
- else if (is_null($user->public))
- {
- header(
- sprintf('Location: %s/welcome.php', WEBSITE_URL)
- );
- }
-
- // 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
- {
- // Save star
- if ($magnetStarId = $db->addMagnetStar( $magnet->magnetId,
- $user->userId,
- !$db->findLastMagnetStarValue($magnet->magnetId, $user->userId),
- time()))
- {
- // Push event to other nodes
- if (API_EXPORT_ENABLED &&
- API_EXPORT_PUSH_ENABLED &&
- API_EXPORT_USERS_ENABLED &&
- API_EXPORT_MAGNETS_ENABLED &&
- API_EXPORT_MAGNET_STARS_ENABLED)
- {
- if (!$memoryApiExportPush = $memory->get('api.export.push'))
- {
- $memoryApiExportPush = [];
- }
-
- $memoryApiExportPush[] = (object)
- [
- 'time' => time(),
- 'userId' => $user->userId,
- 'magnetId' => $magnet->magnetId,
- 'magnetStarId' => $magnetStarId
- ];
-
- $memory->set('api.export.push', $memoryApiExportPush, 3600);
- }
-
- // Redirect to edit page
- header(
- sprintf('Location: %s', $callback)
- );
- }
- }
-
- break;
-
- case 'new':
-
- // Yggdrasil connections only
- if (!Valid::host($_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');
- }
-
- // On first visit, redirect user to the welcome page with access level question
- else if (is_null($user->public))
- {
- header(
- sprintf('Location: %s/welcome.php', WEBSITE_URL)
- );
- }
-
- // Validate link
- if (empty($_GET['magnet']))
- {
- $response->success = false;
- $response->message = _('Link required');
- }
-
- // Validate magnet
- else if (!$magnet = Yggverse\Parser\Magnet::parse($_GET['magnet']))
- {
- $response->success = false;
- $response->message = _('Invalid magnet link');
- }
-
- // Request valid
- else
- {
- // Begin magnet registration
- try
- {
- $db->beginTransaction();
-
- // Init magnet
- if ($magnetId = $db->addMagnet( $user->userId,
- $magnet->xl,
- $magnet->dn,
- '', // @TODO deprecated, remove
- MAGNET_DEFAULT_PUBLIC,
- MAGNET_DEFAULT_COMMENTS,
- MAGNET_DEFAULT_SENSITIVE,
- $user->approved ? true : MAGNET_DEFAULT_APPROVED,
- time()))
- {
- foreach ($magnet as $key => $value)
- {
- switch ($key)
- {
- case 'xt':
- foreach ($value as $xt)
- {
- if (Yggverse\Parser\Magnet::isXTv1($xt))
- {
- $db->addMagnetToInfoHash(
- $magnetId,
- $db->initInfoHashId(
- Yggverse\Parser\Magnet::filterInfoHash($xt), 1
- )
- );
- }
- if (Yggverse\Parser\Magnet::isXTv2($xt))
- {
- $db->addMagnetToInfoHash(
- $magnetId,
- $db->initInfoHashId(
- Yggverse\Parser\Magnet::filterInfoHash($xt), 2
- )
- );
- }
- }
- break;
- case 'tr':
- foreach ($value as $tr)
- {
- if (Valid::url($tr))
- {
- if ($url = Yggverse\Parser\Url::parse($tr))
- {
- $db->initMagnetToAddressTrackerId(
- $magnetId,
- $db->initAddressTrackerId(
- $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 (Valid::url($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 (Valid::url($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();
-
- // Redirect to edit page
- header(sprintf('Location: %s/edit.php?magnetId=%s', trim(WEBSITE_URL, '/'), $magnetId));
- }
-
- } catch (Exception $e) {
-
- var_dump($e);
-
- $db->rollBack();
- }
- }
-
- break;
- }
-
- break;
-}
-
-?>
-
-
-
-
-
-
-
- title ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $tracker) { ?>
- announce) && !empty($tracker->stats)) { ?>
-
- /
-
- |
-
-
-
- |
-
- |
-
-
- |
-
-
- |
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/public/download.php b/src/public/download.php
deleted file mode 100644
index ddadb96..0000000
--- a/src/public/download.php
+++ /dev/null
@@ -1,335 +0,0 @@
- true,
- 'message' => _('Internal server error'),
- 'html' => (object)
- [
- 'title' => sprintf(_('Oops - %s'), WEBSITE_NAME),
- 'h1' => false,
- 'link' => (object) [],
- ]
-];
-
-// Yggdrasil connections only
-if (!Valid::host($_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');
-}
-
-// Get user
-else if (!$user = $db->getUser($userId))
-{
- $response->success = false;
- $response->message = _('Could not init user info');
-}
-
-// On first visit, redirect user to the welcome page with access level question
-else if (is_null($user->public))
-{
- header(
- sprintf('Location: %s/welcome.php', WEBSITE_URL)
- );
-}
-
-// Request valid
-else
-{
- // Register magnet download
- if ($magnetDownloadId = $db->addMagnetDownload($magnet->magnetId, $user->userId, time()))
- {
- // Push event to other nodes
- if (API_EXPORT_ENABLED &&
- API_EXPORT_PUSH_ENABLED &&
- API_EXPORT_USERS_ENABLED &&
- API_EXPORT_MAGNETS_ENABLED &&
- API_EXPORT_MAGNET_DOWNLOADS_ENABLED)
- {
- if (!$memoryApiExportPush = $memory->get('api.export.push'))
- {
- $memoryApiExportPush = [];
- }
-
- $memoryApiExportPush[] = (object)
- [
- 'time' => time(),
- 'userId' => $user->userId,
- 'magnetId' => $magnet->magnetId,
- 'magnetDownloadId' => $magnetDownloadId
- ];
-
- $memory->set('api.export.push', $memoryApiExportPush, 3600);
- }
- }
-
- // Build magnet link
- $link = (object)
- [
- 'magnet' => [],
- 'direct' => [],
- ];
-
- /// Exact Topic
- $xt = [];
-
- foreach ($db->findMagnetToInfoHashByMagnetId($magnet->magnetId) as $result)
- {
- if ($infoHash = $db->getInfoHash($result->infoHashId))
- {
- switch ($infoHash->version)
- {
- case 1:
-
- $xt[] = sprintf('xt=urn:btih:%s', $infoHash->value);
-
- break;
-
- case 2:
-
- $xt[] = sprintf('xt=urn:btmh:1220%s', $infoHash->value);
-
- break;
- }
- }
- }
-
- $link->magnet[] = sprintf('magnet:?%s', implode('&', $xt));
-
- /// Display Name
- $link->magnet[] = sprintf('dn=%s', urlencode($magnet->dn));
-
- // Keyword Topic
- $kt = [];
-
- foreach ($db->findKeywordTopicByMagnetId($magnet->magnetId) as $result)
- {
- $kt[] = urlencode($db->getKeywordTopic($result->keywordTopicId)->value);
- }
-
- $link->magnet[] = 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);
-
- // Yggdrasil host only
- if (!Valid::host($host->value))
- {
- continue;
- }
-
- $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->magnet[] = sprintf('tr=%s', urlencode($tracker->announce));
- }
-
- /// 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);
-
- // Yggdrasil host only
- if (!Valid::host($host->value))
- {
- continue;
- }
-
- $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
- 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);
-
- // Yggdrasil host only
- if (!Valid::host($host->value))
- {
- continue;
- }
-
- $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
- $response->html->title = sprintf(
- _('%s - Download - %s'),
- htmlentities($magnet->title),
- WEBSITE_NAME
- );
-
- $response->html->h1 = htmlentities($magnet->title);
-
- // @TODO implement .bittorrent, separated v1/v2 magnet links
- $response->html->link->magnet = implode('&', array_unique($link->magnet));
- $response->html->link->direct = $link->direct;
-}
-
-?>
-
-
-
-
-
-
-
- html->title ?>
-
-
-
-
-
-
-
-
-
-
-
-
- success) { ?>
-
-
html->h1 ?>
-
-
-
-
-
-
-
-
- html->link->direct as $direct) { ?>
-
-
-
-
-
-
-
-
-
- message ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $tracker) { ?>
- announce) && !empty($tracker->stats)) { ?>
-
- /
-
- |
-
-
-
- |
-
- |
-
-
- |
-
-
- |
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/public/edit.php b/src/public/edit.php
deleted file mode 100644
index e8bf3e9..0000000
--- a/src/public/edit.php
+++ /dev/null
@@ -1,914 +0,0 @@
- true,
- 'message' => false,
- 'form' => (object)
- [
- 'title' => (object)
- [
- 'value' => false,
- 'valid' => (object)
- [
- 'success' => true,
- 'message' => false,
- ]
- ],
- 'preview' => (object)
- [
- 'value' => false,
- 'valid' => (object)
- [
- 'success' => true,
- 'message' => false,
- ]
- ],
- 'description' => (object)
- [
- 'value' => false,
- 'valid' => (object)
- [
- 'success' => true,
- 'message' => false,
- ]
- ],
- 'dn' => (object)
- [
- 'value' => false,
- 'valid' => (object)
- [
- 'success' => true,
- 'message' => false,
- ]
- ],
- 'xt' => (object)
- [
- 'value' => [],
- 'valid' => (object)
- [
- 'success' => true,
- 'message' => false,
- ]
- ],
- 'kt' => (object)
- [
- 'value' => [],
- 'valid' => (object)
- [
- 'success' => true,
- 'message' => false,
- ]
- ],
- 'tr' => (object)
- [
- 'value' => [],
- 'valid' => (object)
- [
- 'success' => true,
- 'message' => false,
- ]
- ],
- 'as' => (object)
- [
- 'value' => [],
- 'valid' => (object)
- [
- 'success' => true,
- 'message' => false,
- ]
- ],
- 'xs' => (object)
- [
- 'value' => [],
- 'valid' => (object)
- [
- 'success' => true,
- 'message' => false,
- ]
- ],
- 'public' => (object)
- [
- 'value' => false,
- 'valid' => (object)
- [
- 'success' => true,
- 'message' => false,
- ]
- ],
- 'comments' => (object)
- [
- 'value' => false,
- 'valid' => (object)
- [
- 'success' => true,
- 'message' => false,
- ]
- ],
- 'sensitive' => (object)
- [
- 'value' => false,
- 'valid' => (object)
- [
- 'success' => true,
- 'message' => false,
- ]
- ],
- 'approved' => (object)
- [
- 'value' => false,
- ],
- ]
-];
-
-// Yggdrasil connections only
-if (!Valid::host($_SERVER['REMOTE_ADDR']))
-{
- $response->success = false;
- $response->message = _('Yggdrasil connection required to enable resource features');
-}
-
-// 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');
-}
-
-// Init magnet
-else if (!$magnet = $db->getMagnet(isset($_GET['magnetId']) ? (int) $_GET['magnetId'] : 0)) {
-
- $response->success = false;
- $response->message = _('Magnet not found!');
-}
-
-// Validate access
-else if (!($user->address == $db->getUser($magnet->userId)->address || in_array($user->address, MODERATOR_IP_LIST))) {
-
- $response->success = false;
- $response->message = _('You have no permissions to edit this magnet!');
-}
-
-// On first visit, redirect user to the welcome page with access level question
-else if (is_null($user->public))
-{
- header(
- sprintf('Location: %s/welcome.php', WEBSITE_URL)
- );
-}
-
-// Process form
-else {
-
- // Validate magnet lock
- if ($lastMagnetLock = $db->findLastMagnetLock($magnet->magnetId))
- {
- if ($lastMagnetLock->userId != $user->userId &&
- $lastMagnetLock->timeAdded > time() - MAGNET_EDITOR_LOCK_TIMEOUT)
- {
- $response->success = false;
- $response->message = _('This form have opened by owner or moderator, to prevent overwriting, try attempt later!');
- }
- }
-
- // Lock form for moderators
- $db->addMagnetLock($magnet->magnetId, $user->userId, time());
-
- // Update form
- if (!empty($_POST)) {
-
- // Push event to other nodes
- if (API_EXPORT_ENABLED &&
- API_EXPORT_PUSH_ENABLED &&
- API_EXPORT_USERS_ENABLED &&
- API_EXPORT_MAGNETS_ENABLED)
- {
- if (!$memoryApiExportPush = $memory->get('api.export.push'))
- {
- $memoryApiExportPush = [];
- }
-
- $memoryApiExportPush[] = (object)
- [
- 'time' => time(),
- 'userId' => $user->userId,
- 'magnetId' => $magnet->magnetId,
- ];
-
- $memory->set('api.export.push', $memoryApiExportPush, 3600);
- }
-
- // Approve by moderation request
- if (in_array($user->address, MODERATOR_IP_LIST))
- {
- $db->updateMagnetApproved($magnet->magnetId, isset($_POST['approved']), time());
-
- // Auto-approve user on magnet approve
- if (USER_AUTO_APPROVE_ON_MAGNET_APPROVE)
- {
- $db->updateUserApproved($magnet->userId, isset($_POST['approved']), time());
- }
- }
-
- // Approve by user approved status
- else
- {
- $db->updateMagnetApproved($magnet->magnetId, (bool) $user->approved, time());
- }
-
- // Social
- $db->updateMagnetComments($magnet->magnetId, isset($_POST['comments']) ? true : false, time());
- $db->updateMagnetSensitive($magnet->magnetId, isset($_POST['sensitive']) ? true : false, time());
-
- if (isset($_POST['public'])) // could be enabled once only because of distributed database model #1
- {
- $db->updateMagnetPublic($magnet->magnetId, true, time());
- }
-
- // Title
- $response->form->title->valid->success = true;
- $response->form->title->valid->message = [];
-
- if (!Valid::magnetTitle($_POST['title'], $response->form->title->valid->message))
- {
- $response->form->title->valid->success = false;
- }
-
- else
- {
- $db->updateMagnetTitle(
- $magnet->magnetId,
- Filter::magnetTitle($_POST['title']),
- time()
- );
- }
-
- // Preview
- $response->form->preview->valid->success = true;
- $response->form->preview->valid->message = [];
-
- if (!Valid::magnetPreview($_POST['preview'], $response->form->preview->valid->message))
- {
- $response->form->preview->valid->success = false;
- }
-
- else
- {
- $db->updateMagnetPreview(
- $magnet->magnetId,
- Filter::magnetPreview($_POST['preview']),
- time()
- );
- }
-
- // Description
- $response->form->description->valid->success = true;
- $response->form->description->valid->message = [];
-
- if (!Valid::magnetDescription($_POST['description'], $response->form->description->valid->message))
- {
- $response->form->description->valid->success = false;
- }
-
- else
- {
- $db->updateMagnetDescription(
- $magnet->magnetId,
- Filter::magnetDescription($_POST['description']),
- time()
- );
- }
-
- // Display Name
- $response->form->dn->valid->success = true;
- $response->form->dn->valid->message = [];
-
- if (!Valid::magnetDn($_POST['dn'], $response->form->dn->valid->message))
- {
- $response->form->dn->valid->success = false;
- }
-
- else
- {
- $db->updateMagnetDn(
- $magnet->magnetId,
- Filter::magnetDn($_POST['dn']),
- time()
- );
- }
-
- // Exact Topic
- if (isset($_POST['xt']))
- {
- foreach ((array) $_POST['xt'] as $version => $value)
- {
- switch ($version)
- {
- case 1:
-
- if (!empty($value) && Yggverse\Parser\Magnet::isXTv1($value))
- {
- $exist = false;
-
- foreach ($db->findMagnetToInfoHashByMagnetId($magnet->magnetId) as $result)
- {
- if ($infoHash = $db->getInfoHash($result->infoHashId))
- {
- if ($infoHash->version == 1)
- {
- $exist = true;
- }
- }
- }
-
- if (!$exist)
- {
- $db->addMagnetToInfoHash(
- $magnet->magnetId,
- $db->initInfoHashId(
- Yggverse\Parser\Magnet::filterInfoHash($value), 1
- )
- );
- }
- }
-
- break;
-
- case 2:
-
- if (!empty($value) && Yggverse\Parser\Magnet::isXTv2($value))
- {
- $exist = false;
-
- foreach ($db->findMagnetToInfoHashByMagnetId($magnet->magnetId) as $result)
- {
- if ($infoHash = $db->getInfoHash($result->infoHashId))
- {
- if ($infoHash->version == 2)
- {
- $exist = true;
- }
- }
- }
-
- if (!$exist)
- {
- $db->addMagnetToInfoHash(
- $magnet->magnetId,
- $db->initInfoHashId(
- Yggverse\Parser\Magnet::filterInfoHash($value), 2
- )
- );
- }
- }
-
- break;
- }
- }
- }
-
- // Keyword Topic
- $db->deleteMagnetToKeywordTopicByMagnetId($magnet->magnetId);
-
- if (!empty($_POST['kt']))
- {
- foreach (explode(PHP_EOL, str_replace(['#', ',', ' '], PHP_EOL, $_POST['kt'])) as $kt)
- {
- $kt = trim($kt);
-
- if (!empty(trim($kt)))
- {
- $db->initMagnetToKeywordTopicId(
- $magnet->magnetId,
- $db->initKeywordTopicId(trim(mb_strtolower(strip_tags(html_entity_decode($kt)))))
- );
- }
- }
- }
-
- // Address Tracker
- $db->deleteMagnetToAddressTrackerByMagnetId($magnet->magnetId);
-
- if (!empty($_POST['tr']))
- {
- $response->form->tr->valid->success = false;
- $response->form->tr->valid->message = _('* please, provide at least one Yggdrasil address');
-
- foreach (explode(PHP_EOL, str_replace(['#', ',', ' '], PHP_EOL, $_POST['tr'])) as $tr)
- {
- $tr = trim($tr);
-
- if (Valid::url($tr))
- {
- if ($url = Yggverse\Parser\Url::parse($tr))
- {
- $db->initMagnetToAddressTrackerId(
- $magnet->magnetId,
- $db->initAddressTrackerId(
- $db->initSchemeId($url->host->scheme),
- $db->initHostId($url->host->name),
- $db->initPortId($url->host->port),
- $db->initUriId($url->page->uri)
- )
- );
-
- $response->form->tr->valid->success = true;
- $response->form->tr->valid->message = false;
- }
- }
- }
- }
-
- // Acceptable Source
- $db->deleteMagnetToAcceptableSourceByMagnetId($magnet->magnetId);
-
- if (!empty($_POST['as']))
- {
- $response->form->as->valid->success = false;
- $response->form->as->valid->message = _('* please, provide at least one Yggdrasil address');
-
- foreach (explode(PHP_EOL, str_replace(['#', ',', ' '], PHP_EOL, $_POST['as'])) as $as)
- {
- $xs = trim($as);
-
- if (Valid::url($as))
- {
- if ($url = Yggverse\Parser\Url::parse($as))
- {
- $db->initMagnetToAcceptableSourceId(
- $magnet->magnetId,
- $db->initAcceptableSourceId(
- $db->initSchemeId($url->host->scheme),
- $db->initHostId($url->host->name),
- $db->initPortId($url->host->port),
- $db->initUriId($url->page->uri)
- )
- );
-
- $response->form->as->valid->success = true;
- $response->form->as->valid->message = false;
- }
- }
- }
- }
-
- // Exact Source
- $db->deleteMagnetToExactSourceByMagnetId($magnet->magnetId);
-
- if (!empty($_POST['xs']))
- {
- $response->form->xs->valid->success = false;
- $response->form->xs->valid->message = _('* please, provide at least one Yggdrasil address');
-
- foreach (explode(PHP_EOL, str_replace(['#', ',', ' '], PHP_EOL, $_POST['xs'])) as $xs)
- {
- $xs = trim($xs);
-
- if (Valid::url($xs))
- {
- if ($url = Yggverse\Parser\Url::parse($xs))
- {
- $db->initMagnetToExactSourceId(
- $magnet->magnetId,
- $db->initExactSourceId(
- $db->initSchemeId($url->host->scheme),
- $db->initHostId($url->host->name),
- $db->initPortId($url->host->port),
- $db->initUriId($url->page->uri)
- )
- );
-
- $response->form->xs->valid->success = true;
- $response->form->xs->valid->message = false;
- }
- }
- }
- }
-
- // Is valid
- if ($response->success &&
- $response->form->title->valid->success &&
- $response->form->preview->valid->success &&
- $response->form->description->valid->success &&
- $response->form->dn->valid->success &&
- $response->form->tr->valid->success &&
- $response->form->as->valid->success &&
- $response->form->xs->valid->success)
- {
- // Unlock form
- $db->flushMagnetLock($magnet->magnetId);
-
- // Return redirect to the magnet page
- header(
- sprintf('Location: %s/magnet.php?magnetId=%s', WEBSITE_URL, $magnet->magnetId)
- );
- }
- else
- {
- // Refresh magnet data
- $magnet = $db->getMagnet($magnet->magnetId);
-
- // Replace fields by last POST data
- foreach ($_POST as $key => $value)
- {
- $magnet->{$key} = $value;
- }
- }
- }
-
- // Meta Title, auto-replace with Display Name on empty value
- $response->form->title->value = $magnet->title ? $magnet->title : $magnet->dn;
-
- // Meta Description
- $response->form->preview->value = $magnet->preview;
-
- // Description
- $response->form->description->value = $magnet->description;
-
- // Magnet settings
- $response->form->public->value = (bool) $magnet->public;
- $response->form->comments->value = (bool) $magnet->comments;
- $response->form->sensitive->value = (bool) $magnet->sensitive;
- $response->form->approved->value = (bool) $magnet->approved;
-
- // Display Name
- $response->form->dn->value = $magnet->dn;
-
- // Exact Topic
- foreach ($db->findMagnetToInfoHashByMagnetId($magnet->magnetId) as $result)
- {
- if ($infoHash = $db->getInfoHash($result->infoHashId))
- {
- $response->form->xt->value[$infoHash->version] = $infoHash->value;
- }
- }
-
- // Keyword Topic
- $kt = [];
- foreach ($db->findKeywordTopicByMagnetId($magnet->magnetId) as $result)
- {
- $kt[] = $db->getKeywordTopic($result->keywordTopicId)->value;
- }
-
- $response->form->kt->value = implode(', ', $kt);
-
- // Address Tracker
- $tr = [];
- 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);
-
- $tr[] = $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);
- }
-
- $response->form->tr->value = implode(PHP_EOL, $tr);
-
- // Acceptable Source
- $as = [];
- 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);
-
- $as[] = $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);
- }
-
- $response->form->as->value = implode(PHP_EOL, $as);
-
- // Exact Source
- $xs = [];
- 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);
-
- $xs[] = $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);
- }
-
- $response->form->xs->value = implode(PHP_EOL, $xs);
-}
-
-?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- success) { ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
- $tracker) { ?>
- announce) && !empty($tracker->stats)) { ?>
-
- /
-
- |
-
-
-
- |
-
- |
-
-
- |
-
-
- |
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/public/faq.php b/src/public/faq.php
deleted file mode 100644
index 06000d9..0000000
--- a/src/public/faq.php
+++ /dev/null
@@ -1,228 +0,0 @@
-
- true,
- 'message' => _('Internal server error'),
-];
-
-// Yggdrasil connections only
-if (!Valid::host($_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');
-}
-
-// On first visit, redirect user to the welcome page with access level question
-/* Allow to users read this page before accepting data access type in welcome form
-else if (is_null($user->public))
-{
- header(
- sprintf('Location: %s/welcome.php', WEBSITE_URL)
- );
-}
-*/
-
-?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- success) { ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
open source community-driven BitTorrent registry for Yggdrasil ecosystem.') ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Node page.'), WEBSITE_URL) ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
qBittorrent supports all required features, just check Preferences - Advanced - Optional IP address to bind and set to All addresses or Yggdrasil address only.') ?>
-
') ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Install section.') ?>
-
trackers.json registry to participate shared model testing.') ?>
-
-
-
-
-
message ?>
-
-
-
-
-
-
-
-
-
-
- $tracker) { ?>
- announce) && !empty($tracker->stats)) { ?>
-
- /
-
- |
-
-
-
- |
-
- |
-
-
- |
-
-
- |
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/public/magnet.php b/src/public/magnet.php
deleted file mode 100644
index 2c3f1e0..0000000
--- a/src/public/magnet.php
+++ /dev/null
@@ -1,508 +0,0 @@
- true,
- 'message' => false,
- 'magnet' => [],
- 'comments' => [],
-];
-
-// Yggdrasil connections only
-if (!Valid::host($_SERVER['REMOTE_ADDR']))
-{
- $response->success = false;
- $response->message = _('Yggdrasil connection required to enable resource features');
-}
-
-// 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');
-}
-
-// Init magnet
-else if (!$magnet = $db->getMagnet(isset($_GET['magnetId']) ? (int) $_GET['magnetId'] : 0))
-{
- $response->success = false;
- $response->message = _('Magnet not found! Submit new magnet link by sending address to the search field.');
-}
-
-// On first visit, redirect user to the welcome page with access level question
-else if (is_null($user->public) && !isset($_GET['rss']))
-{
- header(
- sprintf('Location: %s/welcome.php', WEBSITE_URL)
- );
-}
-
-// Request valid
-else
-{
- // Get access info
- $accessRead = ($user->address == $db->getUser($magnet->userId)->address || in_array($user->address, MODERATOR_IP_LIST) || ($magnet->public && $magnet->approved));
- $accessEdit = ($user->address == $db->getUser($magnet->userId)->address || in_array($user->address, MODERATOR_IP_LIST));
-
- // Update magnet viewed
- if ($accessRead)
- {
- if ($magnetViewId = $db->addMagnetView($magnet->magnetId, $userId, time()))
- {
- // Push event to other nodes
- if (API_EXPORT_ENABLED &&
- API_EXPORT_PUSH_ENABLED &&
- API_EXPORT_USERS_ENABLED &&
- API_EXPORT_MAGNETS_ENABLED &&
- API_EXPORT_MAGNET_VIEWS_ENABLED)
- {
- if (!$memoryApiExportPush = $memory->get('api.export.push'))
- {
- $memoryApiExportPush = [];
- }
-
- $memoryApiExportPush[] = (object)
- [
- 'time' => time(),
- 'userId' => $user->userId,
- 'magnetId' => $magnet->magnetId,
- 'magnetViewId' => $magnetViewId
- ];
-
- $memory->set('api.export.push', $memoryApiExportPush, 3600);
- }
- }
- }
-
- // Keywords
- $keywords = [];
-
- foreach ($db->findKeywordTopicByMagnetId($magnet->magnetId) as $keyword)
- {
- $keywords[] = $db->getKeywordTopic($keyword->keywordTopicId)->value;
- }
-
- $response->user = $user;
- $response->magnet = (object)
- [
- 'magnetId' => $magnet->magnetId,
- 'title' => $magnet->title ? htmlentities($magnet->title) : ($magnet->dn ? htmlentities($magnet->dn): false),
- 'preview' => $magnet->preview ? nl2br(
- htmlentities(
- $magnet->preview
- )
- ) : false,
- 'description' => $magnet->description ? nl2br(
- htmlentities(
- $magnet->description
- )
- ) : false,
- 'approved' => (bool) $magnet->approved,
- 'public' => (bool) $magnet->public,
- 'sensitive' => (bool) $magnet->sensitive,
- 'comments' => (bool) $magnet->comments,
- 'timeAdded' => $magnet->timeAdded ? Time::ago((int) $magnet->timeAdded) : false,
- 'timeUpdated' => $magnet->timeUpdated ? Time::ago((int) $magnet->timeUpdated) : false,
- 'keywords' => $keywords,
- 'comment' => (object)
- [
- 'total' => $db->findMagnetCommentsTotalByMagnetId($magnet->magnetId),
- 'status' => $db->findMagnetCommentsTotal($magnet->magnetId, $userId),
- ],
- 'download' => (object)
- [
- 'total' => $db->findMagnetDownloadsTotalByMagnetId($magnet->magnetId),
- 'status' => $db->findMagnetDownloadsTotal($magnet->magnetId, $userId),
- ],
- 'star' => (object)
- [
- 'total' => $db->findMagnetStarsTotalByMagnetId($magnet->magnetId, true),
- 'status' => $db->findLastMagnetStarValue($magnet->magnetId, $userId),
- ],
- 'access' => (object)
- [
- 'read' => $accessRead,
- 'edit' => $accessEdit,
- ],
- 'seeders' => $db->getMagnetToAddressTrackerSeedersSumByMagnetId($magnet->magnetId),
- 'completed' => $db->getMagnetToAddressTrackerCompletedSumByMagnetId($magnet->magnetId),
- 'leechers' => $db->getMagnetToAddressTrackerLeechersSumByMagnetId($magnet->magnetId),
- 'directs' => $db->getMagnetToAcceptableSourceTotalByMagnetId($magnet->magnetId),
- ];
-}
-
-if (isset($_GET['rss']) && isset($_GET['target']) && $_GET['target'] == 'comment' && $response->success) { ?>' . PHP_EOL ?>
-
-
-
- magnet->magnetId) ?>
- magnet->title), WEBSITE_NAME) ?>
-
- findMagnetComments($response->magnet->magnetId) as $magnetComment) { ?>
- user->address == $db->getUser($magnetComment->userId)->address || in_array($response->user->address, MODERATOR_IP_LIST)) { ?>
- -
-
title, ENT_QUOTES, 'UTF-8'), $magnetComment->magnetCommentId) ?>
- value, ENT_QUOTES, 'UTF-8') ?>
- magnet->magnetId, $magnetComment->magnetCommentId) ?>
- magnet->magnetId, $magnetComment->magnetCommentId) ?>
-
-
-
-
-
-
-
-
-
-
-
- success) { ?>
- magnet->title), WEBSITE_NAME) ?>
-
-
-
- message ?>
-
-
-
-
-
-
-
-
-
-
- success) { ?>
- magnet->access->read) { ?>
-
-
-
-
magnet->title ?>
- magnet->leechers && !$response->magnet->seeders) { ?>
-
-
-
-
-
- magnet->public) { ?>
-
-
-
-
-
-
-
- magnet->approved) { ?>
-
-
-
-
-
-
- magnet->access->edit) { ?>
-
-
-
-
-
-
-
-
-
-
- magnet->preview) { ?>
-
magnet->preview ?>
-
- magnet->description) { ?>
-
magnet->description ?>
-
- magnet->keywords) { ?>
-
- magnet->keywords as $keyword) { ?>
-
- #
-
-
-
-
-
-
-
-
- magnet->timeUpdated ? _('Updated') : _('Added') ?>
- magnet->timeUpdated ? $response->magnet->timeUpdated : $response->magnet->timeAdded ?>
-
-
-
-
-
-
- magnet->seeders ?>
-
-
-
-
-
- magnet->completed ?>
-
-
-
-
-
-
- magnet->leechers ?>
-
- magnet->directs) { ?>
-
-
-
-
- magnet->directs ?>
-
-
-
-
- magnet->star->status) { ?>
-
-
-
-
-
-
-
-
-
- magnet->star->total ?>
-
- magnet->comments) { ?>
-
-
- magnet->comment->status) { ?>
-
-
-
-
-
-
-
-
-
- magnet->comment->total ?>
-
-
-
-
- magnet->download->status) { ?>
-
-
-
-
-
-
-
-
-
- magnet->download->total ?>
-
-
-
- searchMagnetsTotal($magnet->title ? $magnet->title : $magnet->dn, 'similar', MAGNET_STOP_WORDS_SIMILAR)) { ?>
- 1) { // skip current magnet ?>
-
-
-
- searchMagnets(
- $magnet->title ? $magnet->title : $magnet->dn,
- 0,
- 10,
- $similarMagnetsTotal,
- 'similar',
- MAGNET_STOP_WORDS_SIMILAR
- ) as $result) { ?>
- getMagnet($result->magnetid)) { ?>
- magnetid != $response->magnet->magnetId && // skip current magnet
- ($response->user->address == $db->getUser($magnet->userId)->address ||
- in_array($response->user->address, MODERATOR_IP_LIST) || ($magnet->approved && $magnet->public))) { ?>
-
-
-
-
-
-
-
-
- magnet->comments) { ?>
-
-
- findMagnetComments($response->magnet->magnetId) as $magnetComment) { ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $tracker) { ?>
- announce) && !empty($tracker->stats)) { ?>
-
- /
-
- |
-
-
-
- |
-
- |
-
-
- |
-
-
- |
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/public/node.php b/src/public/node.php
deleted file mode 100644
index 08df253..0000000
--- a/src/public/node.php
+++ /dev/null
@@ -1,534 +0,0 @@
-
- true,
- 'message' => _('Internal server error'),
-];
-
-// Yggdrasil connections only
-if (!Valid::host($_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');
-}
-
-// On first visit, redirect user to the welcome page with access level question
-else if (is_null($user->public))
-{
- header(
- sprintf('Location: %s/welcome.php', WEBSITE_URL)
- );
-}
-
-?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- success) { ?>
-
-
-
-
-
-
-
-
-
-
-
- public ? _('Distributed') : _('Local') ?>
-
-
-
-
-
-
-
-
-
-
- address ?>
-
-
-
-
-
- timeUpdated) ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- getUsersTotal() ?>
- getUsersTotalByPublic(true)) { ?>
- /
-
-
-
-
- getUsersTotalByPublic(false)) { ?>
- /
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- getMagnetsTotal() ?>
- getMagnetsTotalByUsersPublic(true)) { ?>
- /
-
-
-
-
- getMagnetsTotalByUsersPublic(false)) { ?>
- /
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- getMagnetDownloadsTotal() ?>
- findMagnetDownloadsTotalByUsersPublic(true)) { ?>
- /
-
-
-
-
- findMagnetDownloadsTotalByUsersPublic(false)) { ?>
- /
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- getMagnetCommentsTotal() ?>
- findMagnetCommentsTotalByUsersPublic(true)) { ?>
- /
-
-
-
-
- findMagnetCommentsTotalByUsersPublic(false)) { ?>
- /
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- getMagnetStarsTotal() ?>
- findMagnetStarsTotalByUsersPublic(true)) { ?>
- /
-
-
-
-
- findMagnetStarsTotalByUsersPublic(false)) { ?>
- /
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- getMagnetViewsTotal() ?>
- findMagnetViewsTotalByUsersPublic(true)) { ?>
- /
-
-
-
-
- findMagnetViewsTotalByUsersPublic(false)) { ?>
- /
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- getMagnetToAddressTrackerSeedersSum() ?>
-
-
-
- getMagnetToAddressTrackerCompletedSum() ?>
-
-
-
- getMagnetToAddressTrackerLeechersSum() ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
-
- -
- /
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
- $tracker) { ?>
-
-
-
- $value) { ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $node) { ?>
-
-
-
- $value) { ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $peer) { ?>
-
-
-
- $value) { ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
message ?>
-
-
-
-
-
-
-
-
-
-
- $tracker) { ?>
- announce) && !empty($tracker->stats)) { ?>
-
- /
-
- |
-
-
-
- |
-
- |
-
-
- |
-
-
- |
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/public/search.php b/src/public/search.php
deleted file mode 100644
index ea1590c..0000000
--- a/src/public/search.php
+++ /dev/null
@@ -1,436 +0,0 @@
- false,
- 'page' => 1,
-];
-
-// Prepare request
-$request->query = isset($_GET['query']) ? urldecode((string) $_GET['query']) : '';
-$request->page = isset($_GET['page']) && $_GET['page'] > 0 ? (int) $_GET['page'] : 1;
-
-// Define response
-$response = (object)
-[
- 'success' => true,
- 'message' => false,
- 'magnets' => [],
-];
-
-// Yggdrasil connections only
-if (!Valid::host($_SERVER['REMOTE_ADDR']))
-{
- $response->success = false;
- $response->message = _('Yggdrasil connection required to enable resource features');
-}
-
-// 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');
-}
-
-// On first visit, redirect user to the welcome page with access level question
-else if (is_null($user->public) && !isset($_GET['rss']))
-{
- header(
- sprintf('Location: %s/welcome.php', WEBSITE_URL)
- );
-}
-
-// Request valid
-else
-{
- // Query is magnet link
- if ($magnet = Yggverse\Parser\Magnet::is($request->query))
- {
- header(
- sprintf('Location: %s/action.php?target=magnet&toggle=new&magnet=%s', WEBSITE_URL, urlencode($request->query))
- );
- }
-
- // Get index
- $response->total = $sphinx->searchMagnetsTotal($request->query);
- $results = $sphinx->searchMagnets(
- $request->query,
- $request->page * WEBSITE_PAGINATION_LIMIT - WEBSITE_PAGINATION_LIMIT,
- WEBSITE_PAGINATION_LIMIT,
- $response->total
- );
-
- foreach ($results as $result)
- {
- if ($magnet = $db->getMagnet($result->magnetid))
- {
- // Get access info
- $accessRead = ($user->address == $db->getUser($magnet->userId)->address || in_array($user->address, MODERATOR_IP_LIST) || ($magnet->public && $magnet->approved));
- $accessEdit = ($user->address == $db->getUser($magnet->userId)->address || in_array($user->address, MODERATOR_IP_LIST));
-
- // Keywords
- $keywords = [];
-
- foreach ($db->findKeywordTopicByMagnetId($magnet->magnetId) as $keyword)
- {
- $keywords[] = $db->getKeywordTopic($keyword->keywordTopicId)->value;
- }
-
- $response->magnets[] = (object)
- [
- 'magnetId' => $magnet->magnetId,
- 'title' => $magnet->title ? htmlentities($magnet->title) : ($magnet->dn ? htmlentities($magnet->dn): false),
- 'preview' => $magnet->preview ? nl2br(
- htmlentities(
- $magnet->preview
- )
- ) : false,
- 'approved' => (bool) $magnet->approved,
- 'public' => (bool) $magnet->public,
- 'sensitive' => (bool) $magnet->sensitive,
- 'comments' => (bool) $magnet->comments,
- 'timeAdded' => $magnet->timeAdded ? Time::ago((int) $magnet->timeAdded) : false,
- 'timeUpdated' => $magnet->timeUpdated ? Time::ago((int) $magnet->timeUpdated) : false,
- 'keywords' => $keywords,
- 'comment' => (object)
- [
- 'total' => $db->findMagnetCommentsTotalByMagnetId($magnet->magnetId),
- 'status' => $db->findMagnetCommentsTotal($magnet->magnetId, $userId),
- ],
- 'download' => (object)
- [
- 'total' => $db->findMagnetDownloadsTotalByMagnetId($magnet->magnetId),
- 'status' => $db->findMagnetDownloadsTotal($magnet->magnetId, $userId),
- ],
- 'star' => (object)
- [
- 'total' => $db->findMagnetStarsTotalByMagnetId($magnet->magnetId, true),
- 'status' => $db->findLastMagnetStarValue($magnet->magnetId, $userId),
- ],
- 'access' => (object)
- [
- 'read' => $accessRead,
- 'edit' => $accessEdit,
- ],
- 'seeders' => $db->getMagnetToAddressTrackerSeedersSumByMagnetId($magnet->magnetId),
- 'completed' => $db->getMagnetToAddressTrackerCompletedSumByMagnetId($magnet->magnetId),
- 'leechers' => $db->getMagnetToAddressTrackerLeechersSumByMagnetId($magnet->magnetId),
- 'directs' => $db->getMagnetToAcceptableSourceTotalByMagnetId($magnet->magnetId)
- ];
- }
- }
-}
-
-if (isset($_GET['rss']) && $response->success) { ?>' . PHP_EOL ?>
-
-
-
- query) ? sprintf(_('%s - Search - %s'), htmlspecialchars($request->query, ENT_QUOTES, 'UTF-8'), WEBSITE_NAME)
- : WEBSITE_NAME ?>
-
- query))) ?>
- magnets as $magnet) { ?>
- access->read) { ?>
- -
-
title, ENT_QUOTES, 'UTF-8') ?>
- preview), ENT_QUOTES, 'UTF-8') ?>
- magnetId) ?>
- magnetId) ?>
-
-
-
-
-
-
-
-
-
-
-
-
- query, ENT_QUOTES, 'UTF-8'),
- WEBSITE_NAME) ?>
-
-
-
-
-
-
-
-
-
-
-
-
- success) { ?>
- magnets) { ?>
- magnets as $magnet) { ?>
- access->read) { ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- total > WEBSITE_PAGINATION_LIMIT) { ?>
-
-
- page, ceil($response->total / WEBSITE_PAGINATION_LIMIT)) ?>
- page > 1) { ?>
-
-
-
-
- page < ceil($response->total / WEBSITE_PAGINATION_LIMIT)) { ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
- $tracker) { ?>
- announce) && !empty($tracker->stats)) { ?>
-
- /
-
- |
-
-
-
- |
-
- |
-
-
-
-
- |
-
-
- |
-
-
-
-
-
-
-
-
\ No newline at end of file