Browse Source

update dependencies

main
ghost 1 year ago
parent
commit
8b8eb74835
  1. 64
      src/app/controller/index.php
  2. 2
      src/app/controller/response.php
  3. 21
      src/app/controller/welcome.php
  4. 2
      src/app/view/theme/default/welcome.phtml

64
src/app/controller/index.php

@ -2,57 +2,15 @@
class AppControllerIndex class AppControllerIndex
{ {
private $_db; private $_user;
private $_sphinx;
private $_memory;
public function __construct() public function __construct()
{ {
require_once __DIR__ . '/../../library/database.php'; require_once __DIR__ . '/user.php';
require_once __DIR__ . '/../../library/sphinx.php';
require_once __DIR__ . '/../../library/scrapeer.php'; $this->_user = new AppControllerUser(
require_once __DIR__ . '/../../library/time.php'; $_SERVER['REMOTE_ADDR']
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() public function render()
@ -68,16 +26,16 @@ class AppControllerIndex
require_once __DIR__ . '/module/head.php'; require_once __DIR__ . '/module/head.php';
$appControllerModuleHead = new AppControllerModuleHead( $appControllerModuleHead = new AppControllerModuleHead(
WEBSITE_URL, Environment::config('website')->url,
$page > 1 ? $page > 1 ?
sprintf( sprintf(
_('Page %s - BitTorrent Registry for Yggdrasil - %s'), _('Page %s - BitTorrent Registry for Yggdrasil - %s'),
$page, $page,
WEBSITE_NAME Environment::config('website')->name
) : ) :
sprintf( sprintf(
_('%s - BitTorrent Registry for Yggdrasil'), _('%s - BitTorrent Registry for Yggdrasil'),
WEBSITE_NAME Environment::config('website')->name
), ),
[ [
[ [
@ -101,7 +59,9 @@ class AppControllerIndex
require_once __DIR__ . '/module/profile.php'; require_once __DIR__ . '/module/profile.php';
$appControllerModuleProfile = new AppControllerModuleProfile($user->userId); $appControllerModuleProfile = new AppControllerModuleProfile(
$this->_user
);
require_once __DIR__ . '/module/header.php'; require_once __DIR__ . '/module/header.php';

2
src/app/controller/response.php

@ -30,7 +30,7 @@ class AppControllerResponse
require_once __DIR__ . '/module/head.php'; require_once __DIR__ . '/module/head.php';
$appControllerModuleHead = new AppControllerModuleHead( $appControllerModuleHead = new AppControllerModuleHead(
WEBSITE_URL, Environment::config('website')->url,
$this->_title, $this->_title,
[ [
[ [

21
src/app/controller/welcome.php

@ -6,13 +6,14 @@ class AppControllerWelcome
public function __construct() public function __construct()
{ {
require_once __DIR__ . '/../model/user.php'; require_once __DIR__ . '/user.php';
$this->_user = new AppModelUser( $this->_user = new AppControllerUser(
$_SERVER['REMOTE_ADDR'] $_SERVER['REMOTE_ADDR']
); );
} }
private function _response(string $title, string $h1, string $text, int $code = 200) private function _response(string $title, string $h1, string $text, int $code = 200)
{ {
require_once __DIR__ . '/response.php'; require_once __DIR__ . '/response.php';
@ -31,12 +32,12 @@ class AppControllerWelcome
public function render() public function render()
{ {
if (!$user = $this->_user->get()) if (!$address = $this->_user->getAddress())
{ {
$this->_response( $this->_response(
sprintf( sprintf(
_('Error - %s'), _('Error - %s'),
WEBSITE_NAME Environment::config('website')->name
), ),
_('500'), _('500'),
_('Could not init user'), _('Could not init user'),
@ -44,17 +45,17 @@ class AppControllerWelcome
); );
} }
if (!is_null($user->public)) if (!is_null($this->_user->getPublic()))
{ {
$this->_response( $this->_response(
sprintf( sprintf(
_('Welcome back - %s'), _('Welcome back - %s'),
WEBSITE_NAME Environment::config('website')->name
), ),
_('Welcome back!'), _('Welcome back!'),
sprintf( sprintf(
_('You already have selected account type to %s'), _('You already have selected account type to %s'),
$user->public ? _('Distributed') : _('Local') $this->_user->getPublic() ? _('Distributed') : _('Local')
), ),
405 405
); );
@ -67,7 +68,7 @@ class AppControllerWelcome
$this->_response( $this->_response(
sprintf( sprintf(
_('Success - %s'), _('Success - %s'),
WEBSITE_NAME Environment::config('website')->name
), ),
_('Success!'), _('Success!'),
sprintf( sprintf(
@ -81,10 +82,10 @@ class AppControllerWelcome
require_once __DIR__ . '/module/head.php'; require_once __DIR__ . '/module/head.php';
$appControllerModuleHead = new AppControllerModuleHead( $appControllerModuleHead = new AppControllerModuleHead(
WEBSITE_URL, Environment::config('website')->url,
sprintf( sprintf(
_('Welcome to %s'), _('Welcome to %s'),
WEBSITE_NAME Environment::config('website')->name
), ),
[ [
[ [

2
src/app/view/theme/default/welcome.phtml

@ -13,7 +13,7 @@
</div> </div>
<p class="margin-b-8"><?php echo _('YGGtracker uses 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 _('address below could be shared with independent nodes to allow you manage own content everywhere') ?></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> <h2 class="margin-b-16"><?php echo $address ?></h2>
<form name="public" action="welcome" method="post"> <form name="public" action="welcome" 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">

Loading…
Cancel
Save