mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-02 01:55:31 +00:00
redirect user to welcome / access level page on first visit #1
This commit is contained in:
parent
b3f26fd215
commit
9f2841220a
8 changed files with 292 additions and 168 deletions
|
|
@ -55,6 +55,14 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
$response->message = _('Could not init user info');
|
$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
|
// Render icon
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -105,6 +113,14 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
$response->message = _('Could not init user info');
|
$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
|
// Magnet comment exists
|
||||||
else if (!$magnetComment = $db->getMagnetComment(isset($_GET['magnetCommentId']) && $_GET['magnetCommentId'] > 0 ? (int) $_GET['magnetCommentId'] : 0))
|
else if (!$magnetComment = $db->getMagnetComment(isset($_GET['magnetCommentId']) && $_GET['magnetCommentId'] > 0 ? (int) $_GET['magnetCommentId'] : 0))
|
||||||
{
|
{
|
||||||
|
|
@ -186,6 +202,14 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
$response->message = _('Could not init user info');
|
$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
|
// Magnet comment exists
|
||||||
else if (!$magnetComment = $db->getMagnetComment(isset($_GET['magnetCommentId']) && $_GET['magnetCommentId'] > 0 ? (int) $_GET['magnetCommentId'] : 0))
|
else if (!$magnetComment = $db->getMagnetComment(isset($_GET['magnetCommentId']) && $_GET['magnetCommentId'] > 0 ? (int) $_GET['magnetCommentId'] : 0))
|
||||||
{
|
{
|
||||||
|
|
@ -256,6 +280,14 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
$response->message = _('Could not init user info');
|
$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
|
// Magnet exists
|
||||||
else if (!$magnet = $db->getMagnet(isset($_GET['magnetId']) && $_GET['magnetId'] > 0 ? (int) $_GET['magnetId'] : 0))
|
else if (!$magnet = $db->getMagnet(isset($_GET['magnetId']) && $_GET['magnetId'] > 0 ? (int) $_GET['magnetId'] : 0))
|
||||||
{
|
{
|
||||||
|
|
@ -342,6 +374,21 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
$response->message = _('Could not init user session');
|
$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
|
// Magnet exists
|
||||||
else if (!$magnet = $db->getMagnet(isset($_GET['magnetId']) && $_GET['magnetId'] > 0 ? (int) $_GET['magnetId'] : 0))
|
else if (!$magnet = $db->getMagnet(isset($_GET['magnetId']) && $_GET['magnetId'] > 0 ? (int) $_GET['magnetId'] : 0))
|
||||||
{
|
{
|
||||||
|
|
@ -415,6 +462,14 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
$response->message = _('Could not init user info');
|
$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
|
// Validate link
|
||||||
if (empty($_GET['magnet']))
|
if (empty($_GET['magnet']))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -30,37 +30,52 @@ $response = (object)
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
// Yggdrasil connections only
|
// Yggdrasil connections only
|
||||||
if (!preg_match(YGGDRASIL_HOST_REGEX, $_SERVER['REMOTE_ADDR']))
|
if (!preg_match(YGGDRASIL_HOST_REGEX, $_SERVER['REMOTE_ADDR']))
|
||||||
{
|
{
|
||||||
$response->success = false;
|
$response->success = false;
|
||||||
$response->message = _('Yggdrasil connection required for this action');
|
$response->message = _('Yggdrasil connection required for this action');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init session
|
// Init session
|
||||||
else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROVED, time()))
|
else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROVED, time()))
|
||||||
{
|
{
|
||||||
$response->success = false;
|
$response->success = false;
|
||||||
$response->message = _('Could not init user session');
|
$response->message = _('Could not init user session');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Magnet exists
|
// Magnet exists
|
||||||
else if (!$magnet = $db->getMagnet(isset($_GET['magnetId']) && $_GET['magnetId'] > 0 ? (int) $_GET['magnetId'] : 0))
|
else if (!$magnet = $db->getMagnet(isset($_GET['magnetId']) && $_GET['magnetId'] > 0 ? (int) $_GET['magnetId'] : 0))
|
||||||
{
|
{
|
||||||
$response->success = false;
|
$response->success = false;
|
||||||
$response->message = _('Requested magnet not found');
|
$response->message = _('Requested magnet not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Access allowed
|
// Access allowed
|
||||||
else if (!($_SERVER['REMOTE_ADDR'] == $db->getUser($magnet->userId)->address || in_array($_SERVER['REMOTE_ADDR'], MODERATOR_IP_LIST) || ($magnet->public && $magnet->approved))) {
|
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->success = false;
|
||||||
$response->message = _('Magnet not available for this action');
|
$response->message = _('Magnet not available for this action');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request valid
|
// Get user
|
||||||
else
|
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
|
||||||
|
{
|
||||||
// Update download stats
|
// Update download stats
|
||||||
$db->addMagnetDownload($magnet->magnetId, $userId, time());
|
$db->addMagnetDownload($magnet->magnetId, $userId, time());
|
||||||
|
|
||||||
|
|
@ -206,7 +221,7 @@ $response = (object)
|
||||||
// @TODO implement .bittorrent, separated v1/v2 magnet links
|
// @TODO implement .bittorrent, separated v1/v2 magnet links
|
||||||
$response->html->link->magnet = implode('&', array_unique($link->magnet));
|
$response->html->link->magnet = implode('&', array_unique($link->magnet));
|
||||||
$response->html->link->direct = $link->direct;
|
$response->html->link->direct = $link->direct;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,14 @@ else if (!($user->address == $db->getUser($magnet->userId)->address || in_array(
|
||||||
$response->message = _('You have no permissions to edit this magnet!');
|
$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
|
// Process form
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,21 @@ else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROV
|
||||||
$response->message = _('Could not init user session');
|
$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)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en-US">
|
<html lang="en-US">
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,14 @@ else if (!$user = $db->getUser($userId))
|
||||||
$response->message = _('Could not init user info');
|
$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
|
// Request valid
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,14 @@ else if (!$magnet = $db->getMagnet(isset($_GET['magnetId']) ? (int) $_GET['magne
|
||||||
$response->message = _('Magnet not found! Submit new magnet link by sending address to the search field.');
|
$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))
|
||||||
|
{
|
||||||
|
header(
|
||||||
|
sprintf('Location: %s/welcome.php', WEBSITE_URL)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Request valid
|
// Request valid
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,21 @@ else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROV
|
||||||
$response->message = _('Could not init user session');
|
$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)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en-US">
|
<html lang="en-US">
|
||||||
|
|
|
||||||
|
|
@ -102,14 +102,14 @@ else if (isset($_POST['public']))
|
||||||
<div class="margin-b-24 padding-b-16 border-bottom-default">
|
<div class="margin-b-24 padding-b-16 border-bottom-default">
|
||||||
<h1 class=""><?php echo _('Welcome, stranger!') ?></h1>
|
<h1 class=""><?php echo _('Welcome, stranger!') ?></h1>
|
||||||
</div>
|
</div>
|
||||||
<p class="margin-b-8"><?php echo _('YGGtracker use Yggdrasil address to identify users without registration') ?></p>
|
<p class="margin-b-8"><?php echo _('YGGtracker uses Yggdrasil address to identify users without registration') ?></p>
|
||||||
<p class="margin-b-16"><?php echo _('following address could be shared with independent nodes to allow you manage own content everywhere') ?></p>
|
<p class="margin-b-16"><?php echo _('following address could be shared with independent nodes to allow you manage own content everywhere') ?></p>
|
||||||
<h2 class="margin-b-16"><?php echo $user->address ?></h2>
|
<h2 class="margin-b-16"><?php echo $user->address ?></h2>
|
||||||
<form name="public" action="<?php echo sprintf('%s/welcome.php', WEBSITE_URL) ?>" method="post">
|
<form name="public" action="<?php echo sprintf('%s/welcome.php', WEBSITE_URL) ?>" method="post">
|
||||||
<div class="margin-b-16">
|
<div class="margin-b-16">
|
||||||
<label class="text-color-green margin-y-8 margin-x-4" for="public-1">
|
<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" />
|
<input type="radio" id="public-1" name="public" value="1" checked="checked" />
|
||||||
<?php echo _('Allow data distribution') ?>
|
<?php echo _('Allow address distribution') ?>
|
||||||
</label>
|
</label>
|
||||||
<label class="text-color-pink margin-y-8 margin-x-4" for="public-0">
|
<label class="text-color-pink margin-y-8 margin-x-4" for="public-0">
|
||||||
<input type="radio" id="public-0" name="public" value="0" />
|
<input type="radio" id="public-0" name="public" value="0" />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue