mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-02 01:55:31 +00:00
update bootstrap
This commit is contained in:
parent
d949474737
commit
5a3ac70fd2
8 changed files with 356 additions and 60 deletions
|
|
@ -4,21 +4,9 @@ class AppControllerModuleFooter
|
|||
{
|
||||
public function render()
|
||||
{
|
||||
$response['trackers'] = [];
|
||||
$trackers = Environment::config('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,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
$api = Environment::config('website')->api->export;
|
||||
|
||||
include __DIR__ . '../../../view/theme/default/module/footer.phtml';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class AppControllerModuleHeader
|
|||
$name = str_replace(
|
||||
'YGG',
|
||||
'<span>YGG</span>',
|
||||
WEBSITE_NAME
|
||||
Environment::config('website')->name
|
||||
);
|
||||
|
||||
require_once __DIR__ . '/search.php';
|
||||
|
|
|
|||
209
src/app/controller/page.php
Normal file
209
src/app/controller/page.php
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
<?php
|
||||
|
||||
class AppControllerPage
|
||||
{
|
||||
private $_database;
|
||||
private $_validator;
|
||||
|
||||
private $_user;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
require_once __DIR__ . '/../model/database.php';
|
||||
|
||||
$this->_database = new AppModelDatabase(
|
||||
Environment::config('database')
|
||||
);
|
||||
|
||||
require_once __DIR__ . '/../model/validator.php';
|
||||
|
||||
$this->_validator = new AppModelValidator(
|
||||
Environment::config('validator')
|
||||
);
|
||||
|
||||
require_once __DIR__ . '/user.php';
|
||||
|
||||
$this->_user = new AppControllerUser(
|
||||
$_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 renderFormDescription()
|
||||
{
|
||||
// Init form
|
||||
$form = (object)
|
||||
[
|
||||
'title' => (object)
|
||||
[
|
||||
'error' => [],
|
||||
'attribute' => (object)
|
||||
[
|
||||
'value' => null,
|
||||
'required' => $this->_validator->getPageTitleRequired(),
|
||||
'minlength' => $this->_validator->getPageTitleLengthMin(),
|
||||
'maxlength' => $this->_validator->getPageTitleLengthMax(),
|
||||
'placeholder' => sprintf(
|
||||
_('Page subject (%s-%s chars)'),
|
||||
number_format($this->_validator->getPageTitleLengthMin()),
|
||||
number_format($this->_validator->getPageTitleLengthMax())
|
||||
),
|
||||
]
|
||||
],
|
||||
'description' => (object)
|
||||
[
|
||||
'error' => [],
|
||||
'attribute' => (object)
|
||||
[
|
||||
'value' => null,
|
||||
'required' => $this->_validator->getPageDescriptionRequired(),
|
||||
'minlength' => $this->_validator->getPageDescriptionLengthMin(),
|
||||
'maxlength' => $this->_validator->getPageDescriptionLengthMax(),
|
||||
'placeholder' => sprintf(
|
||||
_('Page description text (%s-%s chars)'),
|
||||
number_format($this->_validator->getPageDescriptionLengthMin()),
|
||||
number_format($this->_validator->getPageDescriptionLengthMax())
|
||||
),
|
||||
]
|
||||
],
|
||||
'keywords' => (object)
|
||||
[
|
||||
'error' => [],
|
||||
'attribute' => (object)
|
||||
[
|
||||
'value' => null,
|
||||
'required' => $this->_validator->getPageKeywordsRequired(),
|
||||
'placeholder' => sprintf(
|
||||
_('Page keywords (%s-%s total / %s-%s chars per item)'),
|
||||
number_format($this->_validator->getPageKeywordsQuantityMin()),
|
||||
number_format($this->_validator->getPageKeywordsQuantityMax()),
|
||||
number_format($this->_validator->getPageKeywordLengthMin()),
|
||||
number_format($this->_validator->getPageKeywordLengthMax())
|
||||
),
|
||||
]
|
||||
],
|
||||
'sensitive' => (object)
|
||||
[
|
||||
'error' => [],
|
||||
'attribute' => (object)
|
||||
[
|
||||
'value' => null,
|
||||
'placeholder' => _('Apply NSFW filters for this publication'),
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
// Submit request
|
||||
if (isset($_POST))
|
||||
{
|
||||
if (isset($_POST['title']))
|
||||
{
|
||||
$error = [];
|
||||
|
||||
if (!$this->_validator->pageTitle($_POST['title'], $error))
|
||||
{
|
||||
$form->title->error[] = $error;
|
||||
}
|
||||
|
||||
// @TODO check for page duplicates
|
||||
|
||||
$form->title->attribute->value = htmlentities($_POST['title']);
|
||||
}
|
||||
|
||||
if (isset($_POST['description']))
|
||||
{
|
||||
$error = [];
|
||||
|
||||
if (!$this->_validator->pageDescription($_POST['description'], $error))
|
||||
{
|
||||
$form->description->error[] = $error;
|
||||
}
|
||||
|
||||
$form->description->attribute->value = htmlentities($_POST['description']);
|
||||
}
|
||||
|
||||
if (isset($_POST['keywords']))
|
||||
{
|
||||
$error = [];
|
||||
|
||||
if (!$this->_validator->pageKeywords($_POST['keywords'], $error))
|
||||
{
|
||||
$form->keywords->error[] = $error;
|
||||
}
|
||||
|
||||
$form->keywords->attribute->value = htmlentities($_POST['keywords']);
|
||||
}
|
||||
|
||||
if (isset($_POST['sensitive']))
|
||||
{
|
||||
$form->sensitive->attribute->value = (bool) $_POST['sensitive'];
|
||||
}
|
||||
|
||||
// Request valid
|
||||
if (empty($error))
|
||||
{
|
||||
// @TODO redirect
|
||||
}
|
||||
}
|
||||
|
||||
// Render template
|
||||
require_once __DIR__ . '/module/head.php';
|
||||
|
||||
$appControllerModuleHead = new AppControllerModuleHead(
|
||||
Environment::config('website')->url,
|
||||
sprintf(
|
||||
_('Submit - %s'),
|
||||
Environment::config('website')->name
|
||||
),
|
||||
[
|
||||
[
|
||||
'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/profile.php';
|
||||
|
||||
$appControllerModuleProfile = new AppControllerModuleProfile(
|
||||
$this->_user
|
||||
);
|
||||
|
||||
require_once __DIR__ . '/module/header.php';
|
||||
|
||||
$appControllerModuleHeader = new AppControllerModuleHeader();
|
||||
|
||||
require_once __DIR__ . '/module/footer.php';
|
||||
|
||||
$appControllerModuleFooter = new AppControllerModuleFooter();
|
||||
|
||||
include __DIR__ . '../../view/theme/default/page/form/description.phtml';
|
||||
}
|
||||
}
|
||||
|
|
@ -3,48 +3,33 @@
|
|||
class AppControllerUser
|
||||
{
|
||||
private $_database;
|
||||
private $_validator;
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
$this->_database = new AppModelDatabase(
|
||||
Environment::config('database')
|
||||
);
|
||||
|
||||
catch (Exception $error)
|
||||
{
|
||||
$this->_response(
|
||||
sprintf(
|
||||
_('Error - %s'),
|
||||
WEBSITE_NAME
|
||||
),
|
||||
_('500'),
|
||||
print_r($error, true),
|
||||
500
|
||||
);
|
||||
}
|
||||
require_once __DIR__ . '/../model/validator.php';
|
||||
|
||||
// Validate user address
|
||||
require_once __DIR__ . '/../../library/valid.php';
|
||||
$this->_validator = new AppModelValidator(
|
||||
Environment::config('validator')
|
||||
);
|
||||
|
||||
// Validate address
|
||||
$error = [];
|
||||
if (!Valid::host($address, $error))
|
||||
|
||||
if (!$this->_validator->host($address, $error))
|
||||
{
|
||||
$this->_response(
|
||||
sprintf(
|
||||
_('Error - %s'),
|
||||
WEBSITE_NAME
|
||||
Environment::config('website')->name
|
||||
),
|
||||
_('406'),
|
||||
print_r($error, true),
|
||||
|
|
@ -60,7 +45,7 @@ class AppControllerUser
|
|||
$this->_user = $this->_database->getUser(
|
||||
$this->_database->initUserId(
|
||||
$address,
|
||||
USER_DEFAULT_APPROVED,
|
||||
Environment::config('website')->default->user->approved,
|
||||
time()
|
||||
)
|
||||
);
|
||||
|
|
@ -75,13 +60,24 @@ class AppControllerUser
|
|||
$this->_response(
|
||||
sprintf(
|
||||
_('Error - %s'),
|
||||
WEBSITE_NAME
|
||||
Environment::config('website')->name
|
||||
),
|
||||
_('500'),
|
||||
print_r($error, true),
|
||||
500
|
||||
);
|
||||
}
|
||||
|
||||
// Require account type selection
|
||||
if (is_null($this->getPublic()))
|
||||
{
|
||||
header(
|
||||
sprintf(
|
||||
'Location: %s/welcome',
|
||||
trim($this->_config->url, '/')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private function _response(string $title, string $h1, string $text, int $code = 200)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue