init MVC framework refactory #14

This commit is contained in:
ghost 2023-09-23 21:37:52 +03:00
parent c4f5409ffa
commit a600a08a28
28 changed files with 1235 additions and 925 deletions

View file

@ -0,0 +1,116 @@
<?php
class AppControllerIndex
{
private $_db;
private $_sphinx;
private $_memory;
public function __construct()
{
require_once __DIR__ . '/../../library/database.php';
require_once __DIR__ . '/../../library/sphinx.php';
require_once __DIR__ . '/../../library/scrapeer.php';
require_once __DIR__ . '/../../library/time.php';
require_once __DIR__ . '/../../library/curl.php';
require_once __DIR__ . '/../../library/valid.php';
require_once __DIR__ . '/../../library/filter.php';
require_once __DIR__ . '/../../../vendor/autoload.php';
try
{
$this->_db = new Database(
DB_HOST,
DB_PORT,
DB_NAME,
DB_USERNAME,
DB_PASSWORD
);
$this->_sphinx = new Sphinx(
SPHINX_HOST,
SPHINX_PORT
);
$this->_memory = new \Yggverse\Cache\Memory(
MEMCACHED_HOST,
MEMCACHED_PORT,
MEMCACHED_NAMESPACE,
MEMCACHED_TIMEOUT + time()
);
}
catch (Exception $error)
{
require_once __DIR__ . '/error/500.php';
$controller = new AppControllerError500(
print_r($error, true)
);
$controller->render();
exit;
}
}
public function render()
{
$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
$pages = [];
require_once __DIR__ . '/module/pagination.php';
$appControllerModulePagination = new appControllerModulePagination();
require_once __DIR__ . '/module/head.php';
$appControllerModuleHead = new AppControllerModuleHead(
WEBSITE_URL,
$page > 1 ?
sprintf(
_('Page %s - BitTorrent Registry for Yggdrasil - %s'),
$page,
WEBSITE_NAME
) :
sprintf(
_('%s - BitTorrent Registry for Yggdrasil'),
WEBSITE_NAME
),
[
[
'rel' => 'stylesheet',
'type' => 'text/css',
'href' => sprintf(
'assets/theme/default/css/common.css?%s',
WEBSITE_CSS_VERSION
),
],
[
'rel' => 'stylesheet',
'type' => 'text/css',
'href' => sprintf(
'assets/theme/default/css/framework.css?%s',
WEBSITE_CSS_VERSION
),
],
]
);
require_once __DIR__ . '/module/profile.php';
$appControllerModuleProfile = new AppControllerModuleProfile($user->userId);
require_once __DIR__ . '/module/header.php';
$appControllerModuleHeader = new AppControllerModuleHeader();
require_once __DIR__ . '/module/footer.php';
$appControllerModuleFooter = new AppControllerModuleFooter();
include __DIR__ . '/../view/theme/default/index.phtml';
}
}

View file

@ -0,0 +1,25 @@
<?php
class AppControllerModuleFooter
{
public function render()
{
$response['trackers'] = [];
if ($trackers = json_decode(file_get_contents(__DIR__ . '/../../../config/trackers.json')))
{
foreach ($trackers as $tracker)
{
if (!empty($tracker->announce) && !empty($tracker->stats))
{
$response['trackers'][] = [
'announce' => $tracker->announce,
'stats' => $tracker->stats,
];
}
}
}
include __DIR__ . '../../../view/theme/default/module/footer.phtml';
}
}

View file

@ -0,0 +1,54 @@
<?php
class AppControllerModuleHead
{
private $_title;
private $_base;
private $_links = [];
public function __construct(string $base, string $title, array $links = [])
{
$this->setBase($base);
$this->setTitle($title);
foreach ($links as $link)
{
$this->addLink(
$link['rel'],
$link['type'],
$link['href'],
);
}
}
public function setBase(string $base) : void
{
$this->_base = $base;
}
public function setTitle(string $title) : void
{
$this->_title = $title;
}
public function addLink(string $rel, string $type, string $href) : void
{
$this->_links[] = (object)
[
'rel' => $rel,
'type' => $type,
'href' => $href,
];
}
public function render()
{
$base = $this->_base;
$links = $this->_links;
$title = htmlentities($this->_title);
include __DIR__ . '../../../view/theme/default/module/head.phtml';
}
}

View file

@ -0,0 +1,19 @@
<?php
class AppControllerModuleHeader
{
public function render()
{
$name = str_replace(
'YGG',
'<span>YGG</span>',
WEBSITE_NAME
);
require_once __DIR__ . '/search.php';
$appControllerModuleSearch = new AppControllerModuleSearch();
include __DIR__ . '../../../view/theme/default/module/header.phtml';
}
}

View file

@ -0,0 +1,9 @@
<?php
class AppControllerCommonPage
{
public function render(int $pageId)
{
include __DIR__ . '../../../view/theme/default/common/page.phtml';
}
}

View file

@ -0,0 +1,43 @@
<?php
class AppControllerModulePagination
{
public function render(string $url, int $total, int $limit)
{
if ($total > $limit)
{
parse_str($url, $query);
$pagination->page = isset($query['total']) ? (int) $query['total'] : 1;
$pagination->pages = ceil($total / $limit);
// Previous
if ($page > 1)
{
$query['page'] = $page - 1;
$pagination->back = sprintf('%s', WEBSITE_URL, http_build_query($query));
}
else
{
$pagination->back = false;
}
// Next
if ($page < ceil($total / $limit))
{
$query['page'] = $page + 1;
$pagination->next = sprintf('%s', WEBSITE_URL, http_build_query($query));
}
else
{
$pagination->next = false;
}
// Render
}
}
}

View file

@ -0,0 +1,11 @@
<?php
class AppControllerModuleSearch
{
public function render()
{
$query = empty($_GET['query']) ? false : urldecode($_GET['query']);
include __DIR__ . '../../../view/theme/default/module/search.phtml';
}
}

View file

@ -0,0 +1,65 @@
<?php
class AppControllerResponse
{
private $_title;
private $_h1;
private $_text;
private $_code;
public function __construct(string $title, string $h1, string $text, int $code = 200)
{
$this->_title = $title;
$this->_h1 = $h1;
$this->_text = $text;
$this->_code = $code;
}
public function render()
{
header(
sprintf(
'HTTP/1.0 %s Not Found',
$this->_code
)
);
$h1 = $this->_h1;
$text = $this->_text;
require_once __DIR__ . '/module/head.php';
$appControllerModuleHead = new AppControllerModuleHead(
WEBSITE_URL,
$this->_title,
[
[
'rel' => 'stylesheet',
'type' => 'text/css',
'href' => sprintf(
'assets/theme/default/css/common.css?%s',
WEBSITE_CSS_VERSION
),
],
[
'rel' => 'stylesheet',
'type' => 'text/css',
'href' => sprintf(
'assets/theme/default/css/framework.css?%s',
WEBSITE_CSS_VERSION
),
],
]
);
require_once __DIR__ . '/module/header.php';
$appControllerModuleHeader = new AppControllerModuleHeader();
require_once __DIR__ . '/module/footer.php';
$appControllerModuleFooter = new AppControllerModuleFooter();
include __DIR__ . '../../view/theme/default/response.phtml';
}
}

View file

@ -0,0 +1,96 @@
<?php
class AppControllerSubmit
{
private function _response(string $title, string $h1, string $text, int $code = 200)
{
require_once __DIR__ . '/response.php';
$appControllerResponse = new AppControllerResponse(
$title,
$h1,
$text,
$code
);
$appControllerResponse->render();
exit;
}
public function render()
{
require_once __DIR__ . '/user.php';
$appControllerUser = new AppControllerUser(
$_SERVER['REMOTE_ADDR']
);
// Get user info
if (!$user = $appControllerUser->getUser())
{
$this->_response(
sprintf(
_('Error - %s'),
WEBSITE_NAME
),
_('500'),
_('Could not init user'),
500
);
}
// Require account type selection
if (is_null($user->public))
{
header(
sprintf('Location: %s/welcome', trim(WEBSITE_URL, '/'))
);
}
// Render
require_once __DIR__ . '/module/head.php';
$appControllerModuleHead = new AppControllerModuleHead(
WEBSITE_URL,
sprintf(
_('Submit - %s'),
WEBSITE_NAME
),
[
[
'rel' => 'stylesheet',
'type' => 'text/css',
'href' => sprintf(
'assets/theme/default/css/common.css?%s',
WEBSITE_CSS_VERSION
),
],
[
'rel' => 'stylesheet',
'type' => 'text/css',
'href' => sprintf(
'assets/theme/default/css/framework.css?%s',
WEBSITE_CSS_VERSION
),
],
]
);
require_once __DIR__ . '/module/profile.php';
$appControllerModuleProfile = new AppControllerModuleProfile(
$appControllerUser
);
require_once __DIR__ . '/module/header.php';
$appControllerModuleHeader = new AppControllerModuleHeader();
require_once __DIR__ . '/module/footer.php';
$appControllerModuleFooter = new AppControllerModuleFooter();
include __DIR__ . '../../view/theme/default/submit.phtml';
}
}

152
src/app/controller/user.php Normal file
View file

@ -0,0 +1,152 @@
<?php
class AppControllerUser
{
private $_database;
private $_user;
public function __construct(string $address)
{
// Connect DB
require_once __DIR__ . '/../model/database.php';
try
{
$this->_database = new AppModelDatabase(
DB_HOST,
DB_PORT,
DB_NAME,
DB_USERNAME,
DB_PASSWORD
);
}
catch (Exception $error)
{
$this->_response(
sprintf(
_('Error - %s'),
WEBSITE_NAME
),
_('500'),
print_r($error, true),
500
);
}
// Validate user address
require_once __DIR__ . '/../../library/valid.php';
$error = [];
if (!Valid::host($address, $error))
{
$this->_response(
sprintf(
_('Error - %s'),
WEBSITE_NAME
),
_('406'),
print_r($error, true),
406
);
}
// Init user session
try
{
$this->_database->beginTransaction();
$this->_user = $this->_database->getUser(
$this->_database->initUserId(
$address,
USER_DEFAULT_APPROVED,
time()
)
);
$this->_database->commit();
}
catch (Exception $error)
{
$this->_database->rollback();
$this->_response(
sprintf(
_('Error - %s'),
WEBSITE_NAME
),
_('500'),
print_r($error, true),
500
);
}
}
private function _response(string $title, string $h1, string $text, int $code = 200)
{
require_once __DIR__ . '/response.php';
$appControllerResponse = new AppControllerResponse(
$title,
$h1,
$text,
$code
);
$appControllerResponse->render();
exit;
}
public function getUser()
{
return $this->_user;
}
public function findUserPageStarsDistinctTotalByValue(bool $value) : int
{
return $this->_database->findUserPageStarsDistinctTotal(
$this->_user->userId,
$value
);
}
public function findUserPageViewsDistinctTotal() : int
{
return $this->_database->findUserPageViewsDistinctTotal(
$this->_user->userId
);
}
public function findUserPageDownloadsDistinctTotal() : int
{
return $this->_database->findUserPageDownloadsDistinctTotal(
$this->_user->userId
);
}
public function findUserPageCommentsDistinctTotal() : int
{
return $this->_database->findUserPageCommentsDistinctTotal(
$this->_user->userId
);
}
public function findUserPageEditionsDistinctTotal() : int
{
return $this->_database->findUserPageEditionsDistinctTotal(
$this->_user->userId
);
}
public function updateUserPublic(bool $public, int $time) : int
{
return $this->_database->updateUserPublic(
$this->_user->userId,
$public,
$time
);
}
}

View file

@ -0,0 +1,119 @@
<?php
class AppControllerWelcome
{
private $_user;
public function __construct()
{
require_once __DIR__ . '/../model/user.php';
$this->_user = new AppModelUser(
$_SERVER['REMOTE_ADDR']
);
}
private function _response(string $title, string $h1, string $text, int $code = 200)
{
require_once __DIR__ . '/response.php';
$appControllerResponse = new AppControllerResponse(
$title,
$h1,
$text,
$code
);
$appControllerResponse->render();
exit;
}
public function render()
{
if (!$user = $this->_user->get())
{
$this->_response(
sprintf(
_('Error - %s'),
WEBSITE_NAME
),
_('500'),
_('Could not init user'),
500
);
}
if (!is_null($user->public))
{
$this->_response(
sprintf(
_('Welcome back - %s'),
WEBSITE_NAME
),
_('Welcome back!'),
sprintf(
_('You already have selected account type to %s'),
$user->public ? _('Distributed') : _('Local')
),
405
);
}
if (isset($_POST['public']))
{
if ($this->_user->updateUserPublic((bool) $_POST['public'], time()))
{
$this->_response(
sprintf(
_('Success - %s'),
WEBSITE_NAME
),
_('Success!'),
sprintf(
_('Account type successfully changed to %s'),
$_POST['public'] ? _('Distributed') : _('Local')
),
);
}
}
require_once __DIR__ . '/module/head.php';
$appControllerModuleHead = new AppControllerModuleHead(
WEBSITE_URL,
sprintf(
_('Welcome to %s'),
WEBSITE_NAME
),
[
[
'rel' => 'stylesheet',
'type' => 'text/css',
'href' => sprintf(
'assets/theme/default/css/common.css?%s',
WEBSITE_CSS_VERSION
),
],
[
'rel' => 'stylesheet',
'type' => 'text/css',
'href' => sprintf(
'assets/theme/default/css/framework.css?%s',
WEBSITE_CSS_VERSION
),
],
]
);
require_once __DIR__ . '/module/header.php';
$appControllerModuleHeader = new AppControllerModuleHeader();
require_once __DIR__ . '/module/footer.php';
$appControllerModuleFooter = new AppControllerModuleFooter();
include __DIR__ . '../../view/theme/default/welcome.phtml';
}
}

1767
src/app/model/database.php Normal file

File diff suppressed because it is too large Load diff

111
src/app/model/sphinx.php Normal file
View file

@ -0,0 +1,111 @@
<?php
class AppModelSphinx {
private $_sphinx;
public function __construct(string $host, int $port)
{
$this->_sphinx = new PDO('mysql:host=' . $host . ';port=' . $port . ';charset=utf8', false, false, [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']);
$this->_sphinx->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->_sphinx->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
}
public function searchMagnetsTotal(string $keyword, string $mode = 'default', array $stopWords = []) : int
{
$query = $this->_sphinx->prepare('SELECT COUNT(*) AS `total` FROM `magnet` WHERE MATCH(?)');
$query->execute(
[
self::_match($keyword, $mode, $stopWords)
]
);
return $query->fetch()->total;
}
public function searchMagnets(string $keyword, int $start, int $limit, int $maxMatches, string $mode = 'default', array $stopWords = [])
{
$query = $this->_sphinx->prepare("SELECT *
FROM `magnet`
WHERE MATCH(?)
ORDER BY `magnetId` DESC, WEIGHT() DESC
LIMIT " . (int) ($start >= $maxMatches ? ($maxMatches > 0 ? $maxMatches - 1 : 0) : $start) . "," . (int) $limit . "
OPTION `max_matches`=" . (int) ($maxMatches >= 1 ? $maxMatches : 1));
$query->execute(
[
self::_match($keyword, $mode, $stopWords)
]
);
return $query->fetchAll();
}
private static function _match(string $keyword, string $mode = 'default', array $stopWords = []) : string
{
$keyword = trim($keyword);
if (empty($keyword))
{
return $keyword;
}
$keyword = str_replace(['"'], ' ', $keyword);
$keyword = preg_replace('/[\W]/ui', ' ', $keyword);
$keyword = preg_replace('/[\s]+/ui', ' ', $keyword);
$keyword = trim($keyword);
switch ($mode)
{
case 'similar':
$result = [];
$keyword = preg_replace('/[\d]/ui', ' ', $keyword);
$keyword = preg_replace('/[\s]+/ui', ' ', $keyword);
$keyword = trim($keyword);
foreach ((array) explode(' ', $keyword) as $value)
{
if (mb_strlen($value) > 5)
{
if (!in_array(mb_strtolower($value), array_map('strtolower', $stopWords)))
{
$result[] = sprintf('@title "%s" | @dn "%s"', $value, $value);
}
}
}
if (empty($result))
{
return '*';
}
else
{
return implode(' | ', $result);
}
break;
default:
$result = [];
foreach ((array) explode(' ', $keyword) as $value)
{
if (!in_array(mb_strtolower($value), $stopWords))
{
$result[] = sprintf('@"*%s*"', $value);
}
}
return implode(' | ', $result);
}
}
}

View file

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<?php $appControllerModuleHead->render() ?>
<body>
<?php $appControllerModuleHeader->render() ?>
<main>
<div class="container">
<div class="row">
<div class="column width-100">
<?php $appControllerModuleProfile->render() ?>
<?php if ($pages) { ?>
<?php foreach ($pages as $page) { ?>
<?php $appControllerModulePage->render($page->pageId) ?>
<?php } ?>
<?php $appControllerModulePagination->render() ?>
<?php } else { ?>
<div class="padding-16 margin-y-8 border-radius-3 background-color-night text-center">
<h1 class="margin-b-8">
<?php echo _('Nothing found') ?>
</h1>
<div class="text-color-night">
<?php echo _('* share your magnet links to change it') ?>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</main>
<?php $appControllerModuleFooter->render() ?>
</body>
</html>

View file

@ -0,0 +1,27 @@
<footer>
<div class="container">
<div class="row">
<div class="column width-100 text-center margin-y-8">
<?php foreach ($trackers as $i => $tracker) { ?>
<a href="<?php echo $tracker->announce ?>"><?php echo sprintf('Tracker %s', $i + 1) ?></a>
/
<a href="<?php echo $tracker->stats ?>"><?php echo _('Stats') ?></a>
|
<?php } ?>
<a href="faq"><?php echo _('F.A.Q') ?></a>
|
<a href="node"><?php echo _('Node') ?></a>
|
<a rel="nofollow" href="rss"><?php echo _('RSS') ?></a>
<?php if (API_EXPORT_ENABLED) { ?>
|
<a rel="nofollow" href="api/manifest.json"><?php echo _('API') ?></a>
<?php } ?>
|
<a href="https://github.com/YGGverse/YGGtracker"><?php echo _('GitHub') ?></a>
</div>
</div>
</div>
</footer>
</body>
</html>

View file

@ -0,0 +1,7 @@
<head>
<base href="<?php echo $base ?>" />
<title><?php echo $title ?></title>
<?php foreach ($links as $link) { ?>
<link rel="<?php echo $link->rel ?>" type="<?php echo $link->type ?>" href="<?php echo $link->href ?>" />
<?php } ?>
</head>

View file

@ -0,0 +1,10 @@
<header>
<div class="container">
<div class="row margin-t-8 text-center">
<a class="logo" href="">
<?php echo $name ?>
</a>
<?php $appControllerModuleSearch->render() ?>
</div>
</div>
</header>

View file

@ -0,0 +1,126 @@
<a name="magnet-<?php echo $pageId ?>"></a>
<div class="margin-y-8 border-radius-3 background-color-night <?php echo !$approved ? 'opacity-06 opacity-hover-1' : false ?>">
<div class="padding-16 <?php echo $sensitive ? 'blur-2 blur-hover-0' : false ?>">
<a href="<?php echo sprintf('%s/magnet.php?magnetId=%s', WEBSITE_URL, $pageId) ?>">
<h2 class="margin-b-8"><?php echo $title ?></h2>
<?php if ($leechers && !$seeders) { ?>
<span class="label label-green margin-x-4 font-size-10 position-relative top--2 cursor-default"
title="<?php echo _('Active leechers waiting for seeds') ?>">
<?php echo _('wanted') ?>
</span>
<?php } ?>
</a>
<div class="float-right opacity-0 parent-hover-opacity-09">
<?php if (!$approved) { ?>
<span class="margin-l-8" title="<?php echo _('Waiting for approve') ?>">
<svg class="width-13px" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-hourglass-split" viewBox="0 0 16 16">
<path d="M2.5 15a.5.5 0 1 1 0-1h1v-1a4.5 4.5 0 0 1 2.557-4.06c.29-.139.443-.377.443-.59v-.7c0-.213-.154-.451-.443-.59A4.5 4.5 0 0 1 3.5 3V2h-1a.5.5 0 0 1 0-1h11a.5.5 0 0 1 0 1h-1v1a4.5 4.5 0 0 1-2.557 4.06c-.29.139-.443.377-.443.59v.7c0 .213.154.451.443.59A4.5 4.5 0 0 1 12.5 13v1h1a.5.5 0 0 1 0 1h-11zm2-13v1c0 .537.12 1.045.337 1.5h6.326c.216-.455.337-.963.337-1.5V2h-7zm3 6.35c0 .701-.478 1.236-1.011 1.492A3.5 3.5 0 0 0 4.5 13s.866-1.299 3-1.48V8.35zm1 0v3.17c2.134.181 3 1.48 3 1.48a3.5 3.5 0 0 0-1.989-3.158C8.978 9.586 8.5 9.052 8.5 8.351z"/>
</svg>
</span>
<?php } ?>
<a class="text-color-green margin-l-12" href="<?php echo WEBSITE_URL ?>/edit.php?magnetId=<?php echo $magnet->magnetId ?>" title="<?php echo _('Edit') ?>">
<svg class="text-color-green" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil-square" viewBox="0 0 16 16">
<path d="M15.502 1.94a.5.5 0 0 1 0 .706L14.459 3.69l-2-2L13.502.646a.5.5 0 0 1 .707 0l1.293 1.293zm-1.75 2.456-2-2L4.939 9.21a.5.5 0 0 0-.121.196l-.805 2.414a.25.25 0 0 0 .316.316l2.414-.805a.5.5 0 0 0 .196-.12l6.813-6.814z"/>
<path fill-rule="evenodd" d="M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11z"/>
</svg>
</a>
</div>
<?php if ($magnet->preview) { ?>
<div class="margin-y-8"><?php echo $magnet->preview ?></div>
<?php } ?>
<?php if ($magnet->keywords) { ?>
<div class="margin-y-8">
<?php foreach ($magnet->keywords as $keyword) { ?>
<small>
<a href="<?php echo WEBSITE_URL ?>/search.php?query=<?php echo urlencode($keyword) ?>">#<?php echo htmlentities($keyword) ?></a>
</small>
<?php } ?>
</div>
<?php } ?>
<div class="width-100 padding-y-4"></div>
<span class="margin-t-8 margin-r-8 cursor-default">
<sup>
<?php echo $magnet->timeUpdated ? _('Updated') : _('Added') ?>
<?php echo $magnet->timeUpdated ? $magnet->timeUpdated : $magnet->timeAdded ?>
</sup>
</span>
<span class="margin-t-8 margin-r-8 cursor-default opacity-0 parent-hover-opacity-09" title="<?php echo _('Seeds') ?>">
<svg class="width-13px" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-up" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 15a.5.5 0 0 0 .5-.5V2.707l3.146 3.147a.5.5 0 0 0 .708-.708l-4-4a.5.5 0 0 0-.708 0l-4 4a.5.5 0 1 0 .708.708L7.5 2.707V14.5a.5.5 0 0 0 .5.5z"/>
</svg>
<sup><?php echo $magnet->seeders ?></sup>
</span>
<span class="margin-t-8 margin-r-8 cursor-default opacity-0 parent-hover-opacity-09" title="<?php echo _('Peers') ?>">
<svg class="width-13px" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-down" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 1a.5.5 0 0 1 .5.5v11.793l3.146-3.147a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 0 1 .708-.708L7.5 13.293V1.5A.5.5 0 0 1 8 1z"/>
</svg>
<sup><?php echo $magnet->completed ?></sup>
</span>
<span class="margin-t-8 margin-r-8 cursor-default opacity-0 parent-hover-opacity-09" title="<?php echo _('Leechers') ?>">
<svg class="width-13px" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cup-hot" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M.5 6a.5.5 0 0 0-.488.608l1.652 7.434A2.5 2.5 0 0 0 4.104 16h5.792a2.5 2.5 0 0 0 2.44-1.958l.131-.59a3 3 0 0 0 1.3-5.854l.221-.99A.5.5 0 0 0 13.5 6H.5ZM13 12.5a2.01 2.01 0 0 1-.316-.025l.867-3.898A2.001 2.001 0 0 1 13 12.5ZM2.64 13.825 1.123 7h11.754l-1.517 6.825A1.5 1.5 0 0 1 9.896 15H4.104a1.5 1.5 0 0 1-1.464-1.175Z"/>
<path d="m4.4.8-.003.004-.014.019a4.167 4.167 0 0 0-.204.31 2.327 2.327 0 0 0-.141.267c-.026.06-.034.092-.037.103v.004a.593.593 0 0 0 .091.248c.075.133.178.272.308.445l.01.012c.118.158.26.347.37.543.112.2.22.455.22.745 0 .188-.065.368-.119.494a3.31 3.31 0 0 1-.202.388 5.444 5.444 0 0 1-.253.382l-.018.025-.005.008-.002.002A.5.5 0 0 1 3.6 4.2l.003-.004.014-.019a4.149 4.149 0 0 0 .204-.31 2.06 2.06 0 0 0 .141-.267c.026-.06.034-.092.037-.103a.593.593 0 0 0-.09-.252A4.334 4.334 0 0 0 3.6 2.8l-.01-.012a5.099 5.099 0 0 1-.37-.543A1.53 1.53 0 0 1 3 1.5c0-.188.065-.368.119-.494.059-.138.134-.274.202-.388a5.446 5.446 0 0 1 .253-.382l.025-.035A.5.5 0 0 1 4.4.8Zm3 0-.003.004-.014.019a4.167 4.167 0 0 0-.204.31 2.327 2.327 0 0 0-.141.267c-.026.06-.034.092-.037.103v.004a.593.593 0 0 0 .091.248c.075.133.178.272.308.445l.01.012c.118.158.26.347.37.543.112.2.22.455.22.745 0 .188-.065.368-.119.494a3.31 3.31 0 0 1-.202.388 5.444 5.444 0 0 1-.253.382l-.018.025-.005.008-.002.002A.5.5 0 0 1 6.6 4.2l.003-.004.014-.019a4.149 4.149 0 0 0 .204-.31 2.06 2.06 0 0 0 .141-.267c.026-.06.034-.092.037-.103a.593.593 0 0 0-.09-.252A4.334 4.334 0 0 0 6.6 2.8l-.01-.012a5.099 5.099 0 0 1-.37-.543A1.53 1.53 0 0 1 6 1.5c0-.188.065-.368.119-.494.059-.138.134-.274.202-.388a5.446 5.446 0 0 1 .253-.382l.025-.035A.5.5 0 0 1 7.4.8Zm3 0-.003.004-.014.019a4.077 4.077 0 0 0-.204.31 2.337 2.337 0 0 0-.141.267c-.026.06-.034.092-.037.103v.004a.593.593 0 0 0 .091.248c.075.133.178.272.308.445l.01.012c.118.158.26.347.37.543.112.2.22.455.22.745 0 .188-.065.368-.119.494a3.198 3.198 0 0 1-.202.388 5.385 5.385 0 0 1-.252.382l-.019.025-.005.008-.002.002A.5.5 0 0 1 9.6 4.2l.003-.004.014-.019a4.149 4.149 0 0 0 .204-.31 2.06 2.06 0 0 0 .141-.267c.026-.06.034-.092.037-.103a.593.593 0 0 0-.09-.252A4.334 4.334 0 0 0 9.6 2.8l-.01-.012a5.099 5.099 0 0 1-.37-.543A1.53 1.53 0 0 1 9 1.5c0-.188.065-.368.119-.494.059-.138.134-.274.202-.388a5.446 5.446 0 0 1 .253-.382l.025-.035A.5.5 0 0 1 10.4.8Z"/>
</svg>
<sup><?php echo $magnet->leechers ?></sup>
</span>
<?php if ($magnet->directs) { ?>
<span class="margin-t-8 margin-r-8 cursor-default opacity-0 parent-hover-opacity-09" title="<?php echo _('Direct') ?>">
<svg class="width-13px" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-database" viewBox="0 0 16 16">
<path d="M4.318 2.687C5.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 4c0-.374.356-.875 1.318-1.313ZM13 5.698V7c0 .374-.356.875-1.318 1.313C10.766 8.729 9.464 9 8 9s-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-.777A4.92 4.92 0 0 0 13 5.698ZM14 4c0-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 16s3.022-.289 4.096-.777C13.125 14.755 14 14.007 14 13V4Zm-1 4.698V10c0 .374-.356.875-1.318 1.313C10.766 11.729 9.464 12 8 12s-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 10s3.022-.289 4.096-.777A4.92 4.92 0 0 0 13 8.698Zm0 3V13c0 .374-.356.875-1.318 1.313C10.766 14.729 9.464 15 8 15s-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 13s3.022-.289 4.096-.777c.324-.147.633-.323.904-.525Z"/>
</svg>
<sup><?php echo $magnet->directs ?></sup>
</span>
<?php } ?>
<span class="float-right margin-l-12">
<a rel="nofollow" href="<?php echo sprintf('%s/action.php?target=magnet&toggle=star&magnetId=%s&callback=%s',
WEBSITE_URL,
$magnet->magnetId,
base64_encode(sprintf('%s/search.php?%s#magnet-%s',
WEBSITE_URL,
($request->query ? sprintf('&query=%s', urlencode($request->query)) : false).
($request->page ? sprintf('&page=%s', urlencode($request->page)) : false),
$magnet->magnetId))) ?>" title="<?php echo _('Star') ?>">
<?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">
<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"/>
</svg>
<?php } else { ?>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-star" viewBox="0 0 16 16">
<path d="M2.866 14.85c-.078.444.36.791.746.593l4.39-2.256 4.389 2.256c.386.198.824-.149.746-.592l-.83-4.73 3.522-3.356c.33-.314.16-.888-.282-.95l-4.898-.696L8.465.792a.513.513 0 0 0-.927 0L5.354 5.12l-4.898.696c-.441.062-.612.636-.283.95l3.523 3.356-.83 4.73zm4.905-2.767-3.686 1.894.694-3.957a.565.565 0 0 0-.163-.505L1.71 6.745l4.052-.576a.525.525 0 0 0 .393-.288L8 2.223l1.847 3.658a.525.525 0 0 0 .393.288l4.052.575-2.906 2.77a.565.565 0 0 0-.163.506l.694 3.957-3.686-1.894a.503.503 0 0 0-.461 0z"/>
</svg>
<?php } ?>
</a>
<sup><?php echo $magnet->star->total ?></sup>
</span>
<?php if ($magnet->comments) { ?>
<span class="float-right margin-l-12">
<a rel="nofollow" href="<?php echo WEBSITE_URL ?>/magnet.php?magnetId=<?php echo $magnet->magnetId ?>#comment" title="<?php echo _('Comment') ?>">
<?php if ($magnet->comment->status) { ?>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chat-fill" viewBox="0 0 16 16">
<path d="M8 15c4.418 0 8-3.134 8-7s-3.582-7-8-7-8 3.134-8 7c0 1.76.743 3.37 1.97 4.6-.097 1.016-.417 2.13-.771 2.966-.079.186.074.394.273.362 2.256-.37 3.597-.938 4.18-1.234A9.06 9.06 0 0 0 8 15z"/>
</svg>
<?php } else { ?>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chat" viewBox="0 0 16 16">
<path d="M2.678 11.894a1 1 0 0 1 .287.801 10.97 10.97 0 0 1-.398 2c1.395-.323 2.247-.697 2.634-.893a1 1 0 0 1 .71-.074A8.06 8.06 0 0 0 8 14c3.996 0 7-2.807 7-6 0-3.192-3.004-6-7-6S1 4.808 1 8c0 1.468.617 2.83 1.678 3.894zm-.493 3.905a21.682 21.682 0 0 1-.713.129c-.2.032-.352-.176-.273-.362a9.68 9.68 0 0 0 .244-.637l.003-.01c.248-.72.45-1.548.524-2.319C.743 11.37 0 9.76 0 8c0-3.866 3.582-7 8-7s8 3.134 8 7-3.582 7-8 7a9.06 9.06 0 0 1-2.347-.306c-.52.263-1.639.742-3.468 1.105z"/>
</svg>
<?php } ?>
</a>
<sup><?php echo $magnet->comment->total ?></sup>
</span>
<?php } ?>
<span class="float-right margin-l-12">
<a rel="nofollow" href="<?php echo WEBSITE_URL ?>/download.php?magnetId=<?php echo $magnet->magnetId ?>" title="<?php echo _('Download') ?>">
<?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">
<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"/>
</svg>
<?php } else { ?>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-down-circle" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M1 8a7 7 0 1 0 14 0A7 7 0 0 0 1 8zm15 0A8 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"/>
</svg>
<?php } ?>
</a>
<sup><?php echo $magnet->download->total ?></sup>
</span>
</div>
</div>

View file

@ -0,0 +1,15 @@
<div class="row">
<div class="column width-100 text-right">
<?php echo sprintf(_('page %s / %s'), $pagination->page, $pagination->total) ?>
<?php if ($pagination->back) { ?>
<a class="button margin-l-8" rel="nofollow" href="<?php echo $pagination->back ?>">
<?php echo _('back') ?>
</a>
<?php } ?>
<?php if ($pagination->next) { ?>
<a class="button margin-l-4" rel="nofollow" href="<?php echo $pagination->next ?>">
<?php echo _('next') ?>
</a>
<?php } ?>
</div>
</div>

View file

@ -0,0 +1,4 @@
<form class="margin-t-8" name="search" method="get" action="search">
<input type="text" name="query" value="<?php echo $query ?>" placeholder="<?php echo _('search or submit magnet link') ?>" />
<input type="submit" value="<?php echo _('submit') ?>" />
</form>

View file

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<?php $appControllerModuleHead->render() ?>
<body>
<?php $appControllerModuleHeader->render() ?>
<main>
<div class="container">
<div class="row">
<div class="column width-100">
<div class="padding-16 margin-y-8 border-radius-3 background-color-night text-center">
<h1 class="margin-b-8">
<?php echo $h1 ?>
</h1>
<div>
<?php echo $text ?>
</div>
</div>
</div>
</div>
</div>
</main>
<?php $appControllerModuleFooter->render() ?>
</body>
</html>

View file

@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<?php $appControllerModuleHead->render() ?>
<body>
<?php $appControllerModuleHeader->render() ?>
<main>
<div class="container">
<div class="row">
<div class="column width-100">
<?php $appControllerModuleProfile->render() ?>
<div class="padding-16 margin-y-8 border-radius-3 background-color-night">
<div class="margin-b-24 padding-b-16 border-bottom-default">
<h2><?php echo _('Submit') ?></h2>
</div>
<form class="margin-t-8" name="search" method="post" action="submit">
<div class="margin-b-16">
<label class="margin-b-16 display-block" for="magnet"><?php echo _('Magnet URL') ?></label>
<textarea class="width-100" name="magnet" id="magnet" placeholder="<?php echo _('magnet: ...') ?>"></textarea>
</div>
<div class="margin-b-16">
<label class="margin-b-16 display-block" for="torrent"><?php echo _('Torrent file') ?></label>
<input class="width-100" type="file" name="torrent" id="torrent" value="" />
</div>
<div class="text-right">
<input type="submit" value="<?php echo _('submit') ?>" />
</div>
</form>
</div>
</div>
</div>
</div>
</main>
<?php $appControllerModuleFooter->render() ?>
</body>
</html>

View file

@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<?php $appControllerModuleHead->render() ?>
<body>
<?php $appControllerModuleHeader->render() ?>
<main>
<div class="container">
<div class="row">
<div class="column width-100">
<div class="padding-16 margin-y-8 border-radius-3 background-color-night text-center">
<div class="margin-b-24 padding-b-16 border-bottom-default">
<h1 class=""><?php echo _('Welcome, stranger!') ?></h1>
</div>
<p class="margin-b-8"><?php echo _('YGGtracker uses Yggdrasil address to identify users without registration') ?></p>
<p class="margin-b-16"><?php echo _('address below could be shared with independent nodes to allow you manage own content everywhere') ?></p>
<h2 class="margin-b-16"><?php echo $user->address ?></h2>
<form name="public" action="welcome" method="post">
<div class="margin-b-16">
<label class="text-color-green margin-y-8 margin-x-4" for="public-1">
<input type="radio" id="public-1" name="public" value="1" checked="checked" />
<?php echo _('Allow address distribution') ?>
</label>
<label class="text-color-pink margin-y-8 margin-x-4" for="public-0">
<input type="radio" id="public-0" name="public" value="0" />
<?php echo _('Keep activity local') ?>
</label>
</div>
<div class="text-center">
<input type="submit" value="<?php echo _('confirm') ?>" />
</div>
</form>
</div>
</div>
</div>
</div>
</main>
<?php $appControllerModuleFooter->render() ?>
</body>
</html>