ghost
1 year ago
6 changed files with 0 additions and 266 deletions
Binary file not shown.
@ -1,177 +0,0 @@
@@ -1,177 +0,0 @@
|
||||
<?php |
||||
|
||||
class AppControllerWelcome |
||||
{ |
||||
private $_database; |
||||
private $_validator; |
||||
private $_website; |
||||
private $_session; |
||||
|
||||
public function __construct( |
||||
AppModelDatabase $database, |
||||
AppModelValidator $validator, |
||||
AppModelWebsite $website, |
||||
AppModelSession $session, |
||||
) |
||||
{ |
||||
$this->_database = $database; |
||||
$this->_validator = $validator; |
||||
$this->_website = $website; |
||||
$this->_session = $session; |
||||
} |
||||
|
||||
private function _response(string $title, string $h1, mixed $data, int $code = 200) |
||||
{ |
||||
require_once __DIR__ . '/response.php'; |
||||
|
||||
if (is_array($data)) |
||||
{ |
||||
$data = implode('<br />', $data); |
||||
} |
||||
|
||||
$appControllerResponse = new AppControllerResponse( |
||||
$title, |
||||
$h1, |
||||
$data, |
||||
$code |
||||
); |
||||
|
||||
$appControllerResponse->render(); |
||||
|
||||
exit; |
||||
} |
||||
|
||||
public function render() |
||||
{ |
||||
$error = []; |
||||
if (!$this->_validator->host($this->_session->getAddress(), $error)) |
||||
{ |
||||
$this->_response( |
||||
sprintf( |
||||
_('Error - %s'), |
||||
$this->_website->getName() |
||||
), |
||||
_('406'), |
||||
$error, |
||||
406 |
||||
); |
||||
} |
||||
|
||||
try |
||||
{ |
||||
$this->_database->beginTransaction(); |
||||
|
||||
$user = $this->_database->getUser( |
||||
$this->_database->initUserId( |
||||
$this->_session->getAddress(), |
||||
$this->_website->getDefaultUserStatus(), |
||||
$this->_website->getDefaultUserApproved(), |
||||
time() |
||||
) |
||||
); |
||||
|
||||
$this->_database->commit(); |
||||
} |
||||
|
||||
catch (Exception $error) |
||||
{ |
||||
$this->_database->rollback(); |
||||
|
||||
$this->_response( |
||||
sprintf( |
||||
_('Error - %s'), |
||||
$this->_website->getName() |
||||
), |
||||
_('500'), |
||||
$error, |
||||
500 |
||||
); |
||||
} |
||||
|
||||
// Access denied |
||||
if (!$user->status) |
||||
{ |
||||
$this->_response( |
||||
sprintf( |
||||
_('Error - %s'), |
||||
$this->_website->getName() |
||||
), |
||||
_('403'), |
||||
_('Access denied'), |
||||
403 |
||||
); |
||||
} |
||||
|
||||
if (!is_null($user->public)) |
||||
{ |
||||
$this->_response( |
||||
sprintf( |
||||
_('Welcome back - %s'), |
||||
$this->_website->getName() |
||||
), |
||||
_('Welcome back!'), |
||||
sprintf( |
||||
_('You already have selected account type to %s'), |
||||
$user->public ? _('Distributed') : _('Local') |
||||
), |
||||
405 |
||||
); |
||||
} |
||||
|
||||
if (isset($_POST['public'])) |
||||
{ |
||||
if ($this->_database->updateUserPublic($user->userId, (bool) $_POST['public'], time())) |
||||
{ |
||||
$this->_response( |
||||
sprintf( |
||||
_('Success - %s'), |
||||
$this->_website->getName() |
||||
), |
||||
_('Success!'), |
||||
sprintf( |
||||
_('Account type successfully changed to %s'), |
||||
$_POST['public'] ? _('Distributed') : _('Local') |
||||
), |
||||
); |
||||
} |
||||
} |
||||
|
||||
require_once __DIR__ . '/module/head.php'; |
||||
|
||||
$appControllerModuleHead = new AppControllerModuleHead( |
||||
$this->_website->getUrl(), |
||||
sprintf( |
||||
_('Welcome to %s'), |
||||
$this->_website->getName() |
||||
), |
||||
[ |
||||
[ |
||||
'rel' => 'stylesheet', |
||||
'type' => 'text/css', |
||||
'href' => sprintf( |
||||
'assets/theme/default/css/common.css?%s', |
||||
CSS_VERSION |
||||
), |
||||
], |
||||
[ |
||||
'rel' => 'stylesheet', |
||||
'type' => 'text/css', |
||||
'href' => sprintf( |
||||
'assets/theme/default/css/framework.css?%s', |
||||
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'; |
||||
} |
||||
} |
@ -1,39 +0,0 @@
@@ -1,39 +0,0 @@
|
||||
<!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> |
Loading…
Reference in new issue