|
|
|
@ -2,19 +2,103 @@
@@ -2,19 +2,103 @@
|
|
|
|
|
|
|
|
|
|
class AppControllerIndex |
|
|
|
|
{ |
|
|
|
|
private $_user; |
|
|
|
|
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 _initUser(string $address) |
|
|
|
|
{ |
|
|
|
|
$error = []; |
|
|
|
|
if (!$this->_validator->host($address, $error)) |
|
|
|
|
{ |
|
|
|
|
$this->_response( |
|
|
|
|
sprintf( |
|
|
|
|
_('Error - %s'), |
|
|
|
|
$this->_website->getName() |
|
|
|
|
), |
|
|
|
|
_('406'), |
|
|
|
|
$error, |
|
|
|
|
406 |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
$this->_database->beginTransaction(); |
|
|
|
|
|
|
|
|
|
$user = $this->_database->getUser( |
|
|
|
|
$this->_database->initUserId( |
|
|
|
|
$address, |
|
|
|
|
$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 |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function __construct() |
|
|
|
|
// Access denied |
|
|
|
|
if (!$user->status) |
|
|
|
|
{ |
|
|
|
|
require_once __DIR__ . '/user.php'; |
|
|
|
|
$this->_response( |
|
|
|
|
sprintf( |
|
|
|
|
_('Error - %s'), |
|
|
|
|
$this->_website->getName() |
|
|
|
|
), |
|
|
|
|
_('403'), |
|
|
|
|
_('Access denied'), |
|
|
|
|
403 |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$this->_user = new AppControllerUser( |
|
|
|
|
$_SERVER['REMOTE_ADDR'] |
|
|
|
|
// Require account type selection |
|
|
|
|
if (is_null($user->public)) |
|
|
|
|
{ |
|
|
|
|
header( |
|
|
|
|
sprintf( |
|
|
|
|
'Location: %s/welcome', |
|
|
|
|
trim($this->_website->getUrl(), '/') |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function render() |
|
|
|
|
{ |
|
|
|
|
$user = $this->_initUser( |
|
|
|
|
$this->_session->getAddress() |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$page = isset($_GET['page']) ? (int) $_GET['page'] : 1; |
|
|
|
|
|
|
|
|
|
$pages = []; |
|
|
|
@ -26,16 +110,16 @@ class AppControllerIndex
@@ -26,16 +110,16 @@ class AppControllerIndex
|
|
|
|
|
require_once __DIR__ . '/module/head.php'; |
|
|
|
|
|
|
|
|
|
$appControllerModuleHead = new AppControllerModuleHead( |
|
|
|
|
Environment::config('website')->url, |
|
|
|
|
$this->_website->getUrl(), |
|
|
|
|
$page > 1 ? |
|
|
|
|
sprintf( |
|
|
|
|
_('Page %s - BitTorrent Registry for Yggdrasil - %s'), |
|
|
|
|
$page, |
|
|
|
|
Environment::config('website')->name |
|
|
|
|
$this->_website->getName() |
|
|
|
|
) : |
|
|
|
|
sprintf( |
|
|
|
|
_('%s - BitTorrent Registry for Yggdrasil'), |
|
|
|
|
Environment::config('website')->name |
|
|
|
|
$this->_website->getName() |
|
|
|
|
), |
|
|
|
|
[ |
|
|
|
|
[ |
|
|
|
@ -60,7 +144,9 @@ class AppControllerIndex
@@ -60,7 +144,9 @@ class AppControllerIndex
|
|
|
|
|
require_once __DIR__ . '/module/profile.php'; |
|
|
|
|
|
|
|
|
|
$appControllerModuleProfile = new AppControllerModuleProfile( |
|
|
|
|
$this->_user |
|
|
|
|
$this->_database, |
|
|
|
|
$this->_website, |
|
|
|
|
$this->_session |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
require_once __DIR__ . '/module/header.php'; |
|
|
|
|