true, 'message' => false, 'magnet' => [], 'comments' => [], ]; // Yggdrasil connections only if (!preg_match(YGGDRASIL_URL_REGEX, $_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.'); } // 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 viwed if ($accessRead) { $db->addMagnetView($magnet->magnetId, $userId, time()); } // Keywords $keywords = []; foreach ($db->findKeywordTopicByMagnetId($magnet->magnetId) as $keyword) { $keywords[] = $db->getKeywordTopic($keyword->keywordTopicId)->value; } // Scrapes $localScrape = (object) [ 'seeders' => 0, 'completed' => 0, 'leechers' => 0, ]; $totalScrape = (object) [ 'seeders' => 0, 'completed' => 0, 'leechers' => 0, ]; $trackers = []; foreach (TRACKER_LINKS as $tracker) { $trackers[] = $tracker->announce; } foreach ($db->findAddressTrackerByMagnetId($magnet->magnetId) as $magnetToAddressTracker) { if ($addressTracker = $db->getAddressTracker($magnetToAddressTracker->addressTrackerId)) { $scheme = $db->getScheme($addressTracker->schemeId); $host = $db->getHost($addressTracker->hostId); $port = $db->getPort($addressTracker->portId); $uri = $db->getUri($addressTracker->uriId); $url = $port->value ? sprintf('%s://%s:%s%s', $scheme->value, $host->value, $port->value, $uri->value) : sprintf('%s://%s%s', $scheme->value, $host->value, $uri->value); if (in_array($url, $trackers)) { $localScrape->seeders += (int) $magnetToAddressTracker->seeders; $localScrape->completed += (int) $magnetToAddressTracker->completed; $localScrape->leechers += (int) $magnetToAddressTracker->leechers; } $totalScrape->seeders += (int) $magnetToAddressTracker->seeders; $totalScrape->completed += (int) $magnetToAddressTracker->completed; $totalScrape->leechers += (int) $magnetToAddressTracker->leechers; } } $response->user = $user; $response->magnet = (object) [ 'magnetId' => $magnet->magnetId, 'metaTitle' => $magnet->metaTitle ? htmlentities($magnet->metaTitle) : ($magnet->dn ? htmlentities($magnet->dn): false), 'metaDescription' => $magnet->metaDescription ? nl2br( htmlentities( substr($magnet->metaDescription, 0, WEBSITE_MAGNET_SHORT_META_DESCRIPTION_LENGTH) ) ) : 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->getMagnetCommentsTotal($magnet->magnetId), 'status' => $db->findMagnetCommentsTotalByUserId($magnet->magnetId, $userId), ], 'download' => (object) [ 'total' => $db->getMagnetDownloadsTotalByUserId($magnet->magnetId), 'status' => $db->findMagnetDownloadsTotalByUserId($magnet->magnetId, $userId), ], 'star' => (object) [ 'total' => $db->getMagnetStarsTotal($magnet->magnetId), 'status' => $db->findMagnetStarsTotalByUserId($magnet->magnetId, $userId), ], 'access' => (object) [ 'read' => $accessRead, 'edit' => $accessEdit, ], 'scrape' => (object) [ 'local' => $localScrape, 'total' => $totalScrape ] ]; } if (isset($_GET['rss']) && $response->success) { ?>' . PHP_EOL ?> <?php echo sprintf(_('%s - Comments - %s'), htmlentities($response->magnet->metaTitle), WEBSITE_NAME) ?> magnet->magnetId) ?> getMagnetComments($response->magnet->magnetId) as $magnetComment) { ?> user->address == $db->getUser($magnetComment->userId)->address || in_array($response->user->address, MODERATOR_IP_LIST)) { ?> <?php echo sprintf('%s - comment #%s', htmlspecialchars($magnet->metaTitle, ENT_QUOTES, 'UTF-8'), $magnetComment->magnetCommentId) ?> value, ENT_QUOTES, 'UTF-8') ?> magnet->magnetId, $magnetComment->magnetCommentId) ?> magnet->magnetId, $magnetComment->magnetCommentId) ?> success) { ?> <?php echo sprintf(_('%s - %s'), htmlentities($response->magnet->metaTitle), WEBSITE_NAME) ?> <?php echo $response->message ?>
success) { ?> magnet->access->read) { ?>

magnet->metaTitle ?>

magnet->public) { ?> magnet->approved) { ?> magnet->access->edit) { ?>
magnet->metaDescription) { ?>
magnet->metaDescription ?>
magnet->keywords) { ?>
magnet->keywords as $keyword) { ?> #
magnet->timeUpdated ? _('Updated') : _('Added') ?> magnet->timeUpdated ? $response->magnet->timeUpdated : $response->magnet->timeAdded ?> magnet->scrape->local->seeders ?> / magnet->scrape->total->seeders ?> magnet->scrape->local->completed ?> / magnet->scrape->total->completed ?> magnet->scrape->local->leechers ?> / magnet->scrape->total->leechers ?> magnet->star->status) { ?> magnet->star->total ?> magnet->comment->status) { ?> magnet->comment->total ?> magnet->download->status) { ?> magnet->download->total ?>
searchMagnetsTotal($magnet->metaTitle ? $magnet->metaTitle : $magnet->dn, 'similar', MAGNET_STOP_WORDS_SIMILAR)) { ?> 1) { // skip current magnet ?>

searchMagnets( $magnet->metaTitle ? $magnet->metaTitle : $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) { ?>

getMagnetComments($response->magnet->magnetId) as $magnetComment) { ?>
user->address == $db->getUser($magnetComment->userId)->address || in_array($response->user->address, MODERATOR_IP_LIST)) { ?>
value)) ?>
timeAdded) ?> public) { ?> approved) { ?> public) { ?> user->address, MODERATOR_IP_LIST)) { ?> approved) { ?>
message ?>