Coding style
This commit is contained in:
parent
a228dc1792
commit
700435010a
94 changed files with 2250 additions and 933 deletions
|
@ -40,7 +40,12 @@ class Install
|
||||||
$this->c->user = $this->c->users->create(['id' => 2, 'group_id' => $this->c->GROUP_ADMIN]);
|
$this->c->user = $this->c->users->create(['id' => 2, 'group_id' => $this->c->GROUP_ADMIN]);
|
||||||
|
|
||||||
$r = $this->c->Router;
|
$r = $this->c->Router;
|
||||||
$r->add($r::DUO, '/install', 'Install:install', 'Install');
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/install',
|
||||||
|
'Install:install',
|
||||||
|
'Install'
|
||||||
|
);
|
||||||
|
|
||||||
$method = $_SERVER['REQUEST_METHOD'];
|
$method = $_SERVER['REQUEST_METHOD'];
|
||||||
|
|
||||||
|
|
|
@ -37,32 +37,88 @@ class Routing
|
||||||
// регистрация/вход/выход
|
// регистрация/вход/выход
|
||||||
if ($user->isGuest) {
|
if ($user->isGuest) {
|
||||||
// вход
|
// вход
|
||||||
$r->add($r::DUO, '/login', 'Auth:login', 'Login');
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/login',
|
||||||
|
'Auth:login',
|
||||||
|
'Login'
|
||||||
|
);
|
||||||
// забыли кодовую фразу
|
// забыли кодовую фразу
|
||||||
$r->add($r::DUO, '/login/forget', 'Auth:forget', 'Forget');
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/login/forget',
|
||||||
|
'Auth:forget',
|
||||||
|
'Forget'
|
||||||
|
);
|
||||||
// смена кодовой фразы
|
// смена кодовой фразы
|
||||||
$r->add($r::DUO, '/login/{id:\d+}/{key}/{hash}', 'Auth:changePass', 'ChangePassword');
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/login/{id:\d+}/{key}/{hash}',
|
||||||
|
'Auth:changePass',
|
||||||
|
'ChangePassword'
|
||||||
|
);
|
||||||
|
|
||||||
// регистрация
|
// регистрация
|
||||||
if ('1' == $config->o_regs_allow) {
|
if ('1' == $config->o_regs_allow) {
|
||||||
$r->add($r::GET, '/registration', 'Rules:confirmation', 'Register');
|
$r->add(
|
||||||
$r->add($r::PST, '/registration/agree', 'Register:reg', 'RegisterForm');
|
$r::GET,
|
||||||
$r->add($r::GET, '/registration/activate/{id:\d+}/{key}/{hash}', 'Register:activate', 'RegActivate');
|
'/registration',
|
||||||
|
'Rules:confirmation',
|
||||||
|
'Register'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::PST,
|
||||||
|
'/registration/agree',
|
||||||
|
'Register:reg',
|
||||||
|
'RegisterForm'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/registration/activate/{id:\d+}/{key}/{hash}',
|
||||||
|
'Register:activate',
|
||||||
|
'RegActivate'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// выход
|
// выход
|
||||||
$r->add($r::GET, '/logout/{token}', 'Auth:logout', 'Logout');
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/logout/{token}',
|
||||||
|
'Auth:logout',
|
||||||
|
'Logout'
|
||||||
|
);
|
||||||
|
|
||||||
// обработка "кривых" перенаправлений с логина и регистрации
|
// обработка "кривых" перенаправлений с логина и регистрации
|
||||||
$r->add($r::GET, '/login[/{tail:.*}]', 'Redirect:toIndex');
|
$r->add(
|
||||||
$r->add($r::GET, '/registration[/{tail:.*}]', 'Redirect:toIndex');
|
$r::GET,
|
||||||
|
'/login[/{tail:.*}]',
|
||||||
|
'Redirect:toIndex'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/registration[/{tail:.*}]',
|
||||||
|
'Redirect:toIndex'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// просмотр разрешен
|
// просмотр разрешен
|
||||||
if ('1' == $user->g_read_board) {
|
if ('1' == $user->g_read_board) {
|
||||||
// главная
|
// главная
|
||||||
$r->add($r::GET, '/', 'Index:view', 'Index');
|
$r->add(
|
||||||
$r->add($r::GET, '/index.php', 'Redirect:toIndex');
|
$r::GET,
|
||||||
$r->add($r::GET, '/index.html', 'Redirect:toIndex');
|
'/',
|
||||||
|
'Index:view',
|
||||||
|
'Index'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/index.php',
|
||||||
|
'Redirect:toIndex'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/index.html',
|
||||||
|
'Redirect:toIndex'
|
||||||
|
);
|
||||||
// правила
|
// правила
|
||||||
if (
|
if (
|
||||||
'1' == $config->o_rules
|
'1' == $config->o_rules
|
||||||
|
@ -71,96 +127,327 @@ class Routing
|
||||||
|| '1' == $config->o_regs_allow
|
|| '1' == $config->o_regs_allow
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
$r->add($r::GET, '/rules', 'Rules:view', 'Rules');
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/rules',
|
||||||
|
'Rules:view',
|
||||||
|
'Rules'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// поиск
|
// поиск
|
||||||
if ('1' == $user->g_search) {
|
if ('1' == $user->g_search) {
|
||||||
$r->add($r::GET, '/search[/simple/{keywords}[/{page:[1-9]\d*}]]', 'Search:view', 'Search');
|
$r->add(
|
||||||
$r->add($r::PST, '/search', 'Search:view');
|
$r::GET,
|
||||||
|
'/search[/simple/{keywords}[/{page:[1-9]\d*}]]',
|
||||||
|
'Search:view',
|
||||||
|
'Search'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::PST,
|
||||||
|
'/search',
|
||||||
|
'Search:view'
|
||||||
|
);
|
||||||
|
|
||||||
$r->add($r::GET, '/search/advanced[/{keywords}/{author}/{forums}/{serch_in:\d}/{sort_by:\d}/{sort_dir:\d}/{show_as:\d}[/{page:[1-9]\d*}]]', 'Search:viewAdvanced', 'SearchAdvanced');
|
$r->add(
|
||||||
$r->add($r::PST, '/search/advanced', 'Search:viewAdvanced');
|
$r::GET,
|
||||||
|
'/search/advanced[/{keywords}/{author}/{forums}/{serch_in:\d}/{sort_by:\d}/{sort_dir:\d}/{show_as:\d}[/{page:[1-9]\d*}]]',
|
||||||
|
'Search:viewAdvanced',
|
||||||
|
'SearchAdvanced'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::PST,
|
||||||
|
'/search/advanced',
|
||||||
|
'Search:viewAdvanced'
|
||||||
|
);
|
||||||
|
|
||||||
$r->add($r::GET, '/search[/user/{uid:[2-9]|[1-9]\d+}]/{action:(?!search)[a-z_]+}[/in_forum/{forum:[1-9]\d*}][/{page:[1-9]\d*}]', 'Search:action', 'SearchAction');
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/search[/user/{uid:[2-9]|[1-9]\d+}]/{action:(?!search)[a-z_]+}[/in_forum/{forum:[1-9]\d*}][/{page:[1-9]\d*}]',
|
||||||
|
'Search:action',
|
||||||
|
'SearchAction'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// юзеры
|
// юзеры
|
||||||
if ($user->viewUsers) {
|
if ($user->viewUsers) {
|
||||||
// список пользователей
|
// список пользователей
|
||||||
$r->add($r::GET, '/userlist[/{group:all|[1-9]\d*}/{sort:username|registered|num_posts}/{dir:ASC|DESC}/{name}][/{page:[1-9]\d*}]', 'Userlist:view', 'Userlist');
|
$r->add(
|
||||||
$r->add($r::PST, '/userlist', 'Userlist:view');
|
$r::GET,
|
||||||
|
'/userlist[/{group:all|[1-9]\d*}/{sort:username|registered|num_posts}/{dir:ASC|DESC}/{name}][/{page:[1-9]\d*}]',
|
||||||
|
'Userlist:view',
|
||||||
|
'Userlist'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::PST,
|
||||||
|
'/userlist',
|
||||||
|
'Userlist:view'
|
||||||
|
);
|
||||||
// юзеры
|
// юзеры
|
||||||
$r->add($r::GET, '/user/{id:[2-9]|[1-9]\d+}/{name}', 'ProfileView:view', 'User');
|
$r->add(
|
||||||
$r->add($r::DUO, '/user/{id:[2-9]|[1-9]\d+}/edit/profile', 'ProfileEdit:edit', 'EditUserProfile');
|
$r::GET,
|
||||||
$r->add($r::DUO, '/user/{id:[2-9]|[1-9]\d+}/edit/config', 'ProfileConfig:config', 'EditUserBoardConfig');
|
'/user/{id:[2-9]|[1-9]\d+}/{name}',
|
||||||
$r->add($r::DUO, '/user/{id:[2-9]|[1-9]\d+}/edit/email', 'ProfileEmail:email', 'EditUserEmail');
|
'ProfileView:view',
|
||||||
$r->add($r::DUO, '/user/{id:[2-9]|[1-9]\d+}/edit/passphrase', 'ProfilePass:pass', 'EditUserPass');
|
'User'
|
||||||
$r->add($r::DUO, '/user/{id:[2-9]|[1-9]\d+}/edit/moderation', 'ProfileMod:moderation', 'EditUserModeration');
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/user/{id:[2-9]|[1-9]\d+}/edit/profile',
|
||||||
|
'ProfileEdit:edit',
|
||||||
|
'EditUserProfile'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/user/{id:[2-9]|[1-9]\d+}/edit/config',
|
||||||
|
'ProfileConfig:config',
|
||||||
|
'EditUserBoardConfig'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/user/{id:[2-9]|[1-9]\d+}/edit/email',
|
||||||
|
'ProfileEmail:email',
|
||||||
|
'EditUserEmail'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/user/{id:[2-9]|[1-9]\d+}/edit/passphrase',
|
||||||
|
'ProfilePass:pass',
|
||||||
|
'EditUserPass'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/user/{id:[2-9]|[1-9]\d+}/edit/moderation',
|
||||||
|
'ProfileMod:moderation',
|
||||||
|
'EditUserModeration'
|
||||||
|
);
|
||||||
} elseif (! $user->isGuest) {
|
} elseif (! $user->isGuest) {
|
||||||
// только свой профиль
|
// только свой профиль
|
||||||
$r->add($r::GET, '/user/{id:' . $user->id . '}/{name}', 'ProfileView:view', 'User');
|
$r->add(
|
||||||
$r->add($r::DUO, '/user/{id:' . $user->id . '}/edit/profile', 'ProfileEdit:edit', 'EditUserProfile');
|
$r::GET,
|
||||||
$r->add($r::DUO, '/user/{id:' . $user->id . '}/edit/config', 'ProfileConfig:config', 'EditUserBoardConfig');
|
'/user/{id:' . $user->id . '}/{name}',
|
||||||
$r->add($r::DUO, '/user/{id:' . $user->id . '}/edit/email', 'ProfileEmail:email', 'EditUserEmail');
|
'ProfileView:view',
|
||||||
$r->add($r::DUO, '/user/{id:' . $user->id . '}/edit/passphrase', 'ProfilePass:pass', 'EditUserPass');
|
'User'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/user/{id:' . $user->id . '}/edit/profile',
|
||||||
|
'ProfileEdit:edit',
|
||||||
|
'EditUserProfile'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/user/{id:' . $user->id . '}/edit/config',
|
||||||
|
'ProfileConfig:config',
|
||||||
|
'EditUserBoardConfig'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/user/{id:' . $user->id . '}/edit/email',
|
||||||
|
'ProfileEmail:email',
|
||||||
|
'EditUserEmail'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/user/{id:' . $user->id . '}/edit/passphrase',
|
||||||
|
'ProfilePass:pass',
|
||||||
|
'EditUserPass'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// смена своего email
|
// смена своего email
|
||||||
if (! $user->isGuest) {
|
if (! $user->isGuest) {
|
||||||
$r->add($r::GET, '/user/{id:' . $user->id . '}/{email}/{key}/{hash}', 'ProfileEmail:setEmail', 'SetNewEmail');
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/user/{id:' . $user->id . '}/{email}/{key}/{hash}',
|
||||||
|
'ProfileEmail:setEmail',
|
||||||
|
'SetNewEmail'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// пометка разделов прочитанными
|
// пометка разделов прочитанными
|
||||||
if (! $user->isGuest) {
|
if (! $user->isGuest) {
|
||||||
$r->add($r::GET, '/forum/{id:\d+}/markread/{token}', 'Misc:markread', 'MarkRead');
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/forum/{id:\d+}/markread/{token}',
|
||||||
|
'Misc:markread',
|
||||||
|
'MarkRead'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// разделы
|
// разделы
|
||||||
$r->add($r::GET, '/forum/{id:[1-9]\d*}/{name}[/{page:[1-9]\d*}]', 'Forum:view', 'Forum' );
|
$r->add(
|
||||||
$r->add($r::DUO, '/forum/{id:[1-9]\d*}/new/topic', 'Post:newTopic', 'NewTopic');
|
$r::GET,
|
||||||
|
'/forum/{id:[1-9]\d*}/{name}[/{page:[1-9]\d*}]',
|
||||||
|
'Forum:view',
|
||||||
|
'Forum'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/forum/{id:[1-9]\d*}/new/topic',
|
||||||
|
'Post:newTopic',
|
||||||
|
'NewTopic'
|
||||||
|
);
|
||||||
// темы
|
// темы
|
||||||
$r->add($r::GET, '/topic/{id:[1-9]\d*}/{name}[/{page:[1-9]\d*}]', 'Topic:viewTopic', 'Topic' );
|
$r->add(
|
||||||
$r->add($r::GET, '/topic/{id:[1-9]\d*}/view/new', 'Topic:viewNew', 'TopicViewNew' );
|
$r::GET,
|
||||||
$r->add($r::GET, '/topic/{id:[1-9]\d*}/view/unread', 'Topic:viewUnread', 'TopicViewUnread');
|
'/topic/{id:[1-9]\d*}/{name}[/{page:[1-9]\d*}]',
|
||||||
$r->add($r::GET, '/topic/{id:[1-9]\d*}/view/last', 'Topic:viewLast', 'TopicViewLast' );
|
'Topic:viewTopic',
|
||||||
$r->add($r::GET, '/topic/{id:[1-9]\d*}/new/reply[/{quote:[1-9]\d*}]', 'Post:newReply', 'NewReply' );
|
'Topic'
|
||||||
$r->add($r::PST, '/topic/{id:[1-9]\d*}/new/reply', 'Post:newReply' );
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/topic/{id:[1-9]\d*}/view/new',
|
||||||
|
'Topic:viewNew',
|
||||||
|
'TopicViewNew'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/topic/{id:[1-9]\d*}/view/unread',
|
||||||
|
'Topic:viewUnread',
|
||||||
|
'TopicViewUnread'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/topic/{id:[1-9]\d*}/view/last',
|
||||||
|
'Topic:viewLast',
|
||||||
|
'TopicViewLast'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/topic/{id:[1-9]\d*}/new/reply[/{quote:[1-9]\d*}]',
|
||||||
|
'Post:newReply',
|
||||||
|
'NewReply'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::PST,
|
||||||
|
'/topic/{id:[1-9]\d*}/new/reply',
|
||||||
|
'Post:newReply'
|
||||||
|
);
|
||||||
// сообщения
|
// сообщения
|
||||||
$r->add($r::GET, '/post/{id:[1-9]\d*}#p{id}', 'Topic:viewPost', 'ViewPost' );
|
$r->add(
|
||||||
$r->add($r::DUO, '/post/{id:[1-9]\d*}/edit', 'Edit:edit', 'EditPost' );
|
$r::GET,
|
||||||
$r->add($r::DUO, '/post/{id:[1-9]\d*}/delete', 'Delete:delete', 'DeletePost');
|
'/post/{id:[1-9]\d*}#p{id}',
|
||||||
|
'Topic:viewPost',
|
||||||
|
'ViewPost'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/post/{id:[1-9]\d*}/edit',
|
||||||
|
'Edit:edit',
|
||||||
|
'EditPost'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/post/{id:[1-9]\d*}/delete',
|
||||||
|
'Delete:delete',
|
||||||
|
'DeletePost'
|
||||||
|
);
|
||||||
// сигналы (репорты)
|
// сигналы (репорты)
|
||||||
if (
|
if (
|
||||||
! $user->isAdmin
|
! $user->isAdmin
|
||||||
&& ! $user->isGuest
|
&& ! $user->isGuest
|
||||||
) { // ????
|
) { // ????
|
||||||
$r->add($r::DUO, '/post/{id:[1-9]\d*}/report', 'Report:report', 'ReportPost');
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/post/{id:[1-9]\d*}/report',
|
||||||
|
'Report:report',
|
||||||
|
'ReportPost'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// админ и модератор
|
// админ и модератор
|
||||||
if ($user->isAdmMod) {
|
if ($user->isAdmMod) {
|
||||||
$r->add($r::GET, '/admin/', 'AdminIndex:index', 'Admin');
|
$r->add(
|
||||||
$r->add($r::GET, '/admin/statistics', 'AdminStatistics:statistics', 'AdminStatistics');
|
$r::GET,
|
||||||
|
'/admin/',
|
||||||
|
'AdminIndex:index',
|
||||||
|
'Admin'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/admin/statistics',
|
||||||
|
'AdminStatistics:statistics',
|
||||||
|
'AdminStatistics'
|
||||||
|
);
|
||||||
|
|
||||||
if ($this->c->userRules->viewIP) {
|
if ($this->c->userRules->viewIP) {
|
||||||
$r->add($r::GET, '/admin/get/host/{ip:[0-9a-fA-F:.]+}', 'AdminHost:view', 'AdminHost');
|
$r->add(
|
||||||
$r->add($r::GET, '/admin/users/user/{id:[2-9]|[1-9]\d+}[/{page:[1-9]\d*}]', 'AdminUsersStat:view', 'AdminUserStat');
|
$r::GET,
|
||||||
|
'/admin/get/host/{ip:[0-9a-fA-F:.]+}',
|
||||||
|
'AdminHost:view',
|
||||||
|
'AdminHost'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/admin/users/user/{id:[2-9]|[1-9]\d+}[/{page:[1-9]\d*}]',
|
||||||
|
'AdminUsersStat:view',
|
||||||
|
'AdminUserStat'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$r->add($r::DUO, '/admin/users', 'AdminUsers:view', 'AdminUsers');
|
$r->add(
|
||||||
$r->add($r::DUO, '/admin/users/result/{data}[/{page:[1-9]\d*}]', 'AdminUsersResult:view', 'AdminUsersResult');
|
$r::DUO,
|
||||||
$r->add($r::DUO, '/admin/users/{action:\w+}/{ids:\d+(?:-\d+)*}[/{token}]', 'AdminUsersAction:view', 'AdminUsersAction');
|
'/admin/users',
|
||||||
|
'AdminUsers:view',
|
||||||
|
'AdminUsers'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/admin/users/result/{data}[/{page:[1-9]\d*}]',
|
||||||
|
'AdminUsersResult:view',
|
||||||
|
'AdminUsersResult'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/admin/users/{action:\w+}/{ids:\d+(?:-\d+)*}[/{token}]',
|
||||||
|
'AdminUsersAction:view',
|
||||||
|
'AdminUsersAction'
|
||||||
|
);
|
||||||
|
|
||||||
$r->add($r::GET, '/admin/users/promote/{uid:[2-9]|[1-9]\d+}/{pid:[1-9]\d*}/{token}', 'AdminUsersPromote:promote', 'AdminUserPromote');
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/admin/users/promote/{uid:[2-9]|[1-9]\d+}/{pid:[1-9]\d*}/{token}',
|
||||||
|
'AdminUsersPromote:promote',
|
||||||
|
'AdminUserPromote'
|
||||||
|
);
|
||||||
|
|
||||||
if ($user->isAdmin) {
|
if ($user->isAdmin) {
|
||||||
$r->add($r::DUO, '/admin/users/new', 'AdminUsersNew:view', 'AdminUsersNew');
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/admin/users/new',
|
||||||
|
'AdminUsersNew:view',
|
||||||
|
'AdminUsersNew'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->c->userRules->banUsers) {
|
if ($this->c->userRules->banUsers) {
|
||||||
$r->add($r::DUO, '/admin/bans', 'AdminBans:view', 'AdminBans');
|
$r->add(
|
||||||
$r->add($r::DUO, '/admin/bans/new[/{ids:\d+(?:-\d+)*}[/{uid:[2-9]|[1-9]\d+}]]', 'AdminBans:add', 'AdminBansNew');
|
$r::DUO,
|
||||||
$r->add($r::DUO, '/admin/bans/edit/{id:[1-9]\d*}', 'AdminBans:edit', 'AdminBansEdit');
|
'/admin/bans',
|
||||||
$r->add($r::GET, '/admin/bans/result/{data}[/{page:[1-9]\d*}]', 'AdminBans:result', 'AdminBansResult');
|
'AdminBans:view',
|
||||||
$r->add($r::GET, '/admin/bans/delete/{id:[1-9]\d*}/{token}[/{uid:[2-9]|[1-9]\d+}]', 'AdminBans:delete', 'AdminBansDelete');
|
'AdminBans'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/admin/bans/new[/{ids:\d+(?:-\d+)*}[/{uid:[2-9]|[1-9]\d+}]]',
|
||||||
|
'AdminBans:add',
|
||||||
|
'AdminBansNew'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/admin/bans/edit/{id:[1-9]\d*}',
|
||||||
|
'AdminBans:edit',
|
||||||
|
'AdminBansEdit'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/admin/bans/result/{data}[/{page:[1-9]\d*}]',
|
||||||
|
'AdminBans:result',
|
||||||
|
'AdminBansResult'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/admin/bans/delete/{id:[1-9]\d*}/{token}[/{uid:[2-9]|[1-9]\d+}]',
|
||||||
|
'AdminBans:delete',
|
||||||
|
'AdminBansDelete'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -168,33 +455,138 @@ class Routing
|
||||||
|| '0' == $config->o_report_method
|
|| '0' == $config->o_report_method
|
||||||
|| '2' == $config->o_report_method
|
|| '2' == $config->o_report_method
|
||||||
) {
|
) {
|
||||||
$r->add($r::GET, '/admin/reports', 'AdminReports:view', 'AdminReports');
|
$r->add(
|
||||||
$r->add($r::GET, '/admin/reports/zap/{id:[1-9]\d*}/{token}', 'AdminReports:zap', 'AdminReportsZap');
|
$r::GET,
|
||||||
|
'/admin/reports',
|
||||||
|
'AdminReports:view',
|
||||||
|
'AdminReports'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/admin/reports/zap/{id:[1-9]\d*}/{token}',
|
||||||
|
'AdminReports:zap',
|
||||||
|
'AdminReportsZap'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$r->add($r::PST, '/moderate', 'Moderate:action', 'Moderate');
|
$r->add(
|
||||||
|
$r::PST,
|
||||||
|
'/moderate',
|
||||||
|
'Moderate:action',
|
||||||
|
'Moderate'
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
// только админ
|
// только админ
|
||||||
if ($user->isAdmin) {
|
if ($user->isAdmin) {
|
||||||
$r->add($r::GET, '/admin/statistics/info', 'AdminStatistics:info', 'AdminInfo' );
|
$r->add(
|
||||||
$r->add($r::DUO, '/admin/options', 'AdminOptions:edit', 'AdminOptions' );
|
$r::GET,
|
||||||
$r->add($r::DUO, '/admin/permissions', 'AdminPermissions:edit', 'AdminPermissions' );
|
'/admin/statistics/info',
|
||||||
$r->add($r::DUO, '/admin/categories', 'AdminCategories:view', 'AdminCategories' );
|
'AdminStatistics:info',
|
||||||
$r->add($r::DUO, '/admin/categories/{id:[1-9]\d*}/delete', 'AdminCategories:delete', 'AdminCategoriesDelete');
|
'AdminInfo'
|
||||||
$r->add($r::DUO, '/admin/forums', 'AdminForums:view', 'AdminForums' );
|
);
|
||||||
$r->add($r::DUO, '/admin/forums/new', 'AdminForums:edit', 'AdminForumsNew' );
|
$r->add(
|
||||||
$r->add($r::DUO, '/admin/forums/{id:[1-9]\d*}/edit', 'AdminForums:edit', 'AdminForumsEdit' );
|
$r::DUO,
|
||||||
$r->add($r::DUO, '/admin/forums/{id:[1-9]\d*}/delete', 'AdminForums:delete', 'AdminForumsDelete' );
|
'/admin/options',
|
||||||
$r->add($r::GET, '/admin/groups', 'AdminGroups:view', 'AdminGroups' );
|
'AdminOptions:edit',
|
||||||
$r->add($r::PST, '/admin/groups/default', 'AdminGroups:defaultSet', 'AdminGroupsDefault');
|
'AdminOptions'
|
||||||
$r->add($r::PST, '/admin/groups/new[/{base:[1-9]\d*}]', 'AdminGroups:edit', 'AdminGroupsNew' );
|
);
|
||||||
$r->add($r::DUO, '/admin/groups/{id:[1-9]\d*}/edit', 'AdminGroups:edit', 'AdminGroupsEdit' );
|
$r->add(
|
||||||
$r->add($r::DUO, '/admin/groups/{id:[1-9]\d*}/delete', 'AdminGroups:delete', 'AdminGroupsDelete' );
|
$r::DUO,
|
||||||
$r->add($r::DUO, '/admin/censoring', 'AdminCensoring:edit', 'AdminCensoring' );
|
'/admin/permissions',
|
||||||
$r->add($r::DUO, '/admin/maintenance', 'AdminMaintenance:view', 'AdminMaintenance' );
|
'AdminPermissions:edit',
|
||||||
$r->add($r::PST, '/admin/maintenance/rebuild', 'AdminMaintenance:rebuild', 'AdminMaintenanceRebuild');
|
'AdminPermissions'
|
||||||
$r->add($r::GET, '/admin/maintenance/rebuild/{token}/{clear:[01]}/{limit:[1-9]\d*}/{start:[1-9]\d*}', 'AdminMaintenance:rebuild', 'AdminRebuildIndex' );
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/admin/categories',
|
||||||
|
'AdminCategories:view',
|
||||||
|
'AdminCategories'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/admin/categories/{id:[1-9]\d*}/delete',
|
||||||
|
'AdminCategories:delete',
|
||||||
|
'AdminCategoriesDelete'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/admin/forums',
|
||||||
|
'AdminForums:view',
|
||||||
|
'AdminForums'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/admin/forums/new',
|
||||||
|
'AdminForums:edit',
|
||||||
|
'AdminForumsNew'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/admin/forums/{id:[1-9]\d*}/edit',
|
||||||
|
'AdminForums:edit',
|
||||||
|
'AdminForumsEdit'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/admin/forums/{id:[1-9]\d*}/delete',
|
||||||
|
'AdminForums:delete',
|
||||||
|
'AdminForumsDelete'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/admin/groups',
|
||||||
|
'AdminGroups:view',
|
||||||
|
'AdminGroups'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::PST,
|
||||||
|
'/admin/groups/default',
|
||||||
|
'AdminGroups:defaultSet',
|
||||||
|
'AdminGroupsDefault'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::PST,
|
||||||
|
'/admin/groups/new[/{base:[1-9]\d*}]',
|
||||||
|
'AdminGroups:edit',
|
||||||
|
'AdminGroupsNew'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/admin/groups/{id:[1-9]\d*}/edit',
|
||||||
|
'AdminGroups:edit',
|
||||||
|
'AdminGroupsEdit'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/admin/groups/{id:[1-9]\d*}/delete',
|
||||||
|
'AdminGroups:delete',
|
||||||
|
'AdminGroupsDelete'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/admin/censoring',
|
||||||
|
'AdminCensoring:edit',
|
||||||
|
'AdminCensoring'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::DUO,
|
||||||
|
'/admin/maintenance',
|
||||||
|
'AdminMaintenance:view',
|
||||||
|
'AdminMaintenance'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::PST,
|
||||||
|
'/admin/maintenance/rebuild',
|
||||||
|
'AdminMaintenance:rebuild',
|
||||||
|
'AdminMaintenanceRebuild'
|
||||||
|
);
|
||||||
|
$r->add(
|
||||||
|
$r::GET,
|
||||||
|
'/admin/maintenance/rebuild/{token}/{clear:[01]}/{limit:[1-9]\d*}/{start:[1-9]\d*}',
|
||||||
|
'AdminMaintenance:rebuild',
|
||||||
|
'AdminRebuildIndex'
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,14 @@ class Mysql
|
||||||
{
|
{
|
||||||
$table = ($noPrefix ? '' : $this->dbPrefix) . $table;
|
$table = ($noPrefix ? '' : $this->dbPrefix) . $table;
|
||||||
try {
|
try {
|
||||||
$stmt = $this->db->query('SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?s:table', [':table' => $table]);
|
$vars = [
|
||||||
|
':table' => $table,
|
||||||
|
];
|
||||||
|
$query = 'SELECT 1
|
||||||
|
FROM INFORMATION_SCHEMA.TABLES
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?s:table';
|
||||||
|
|
||||||
|
$stmt = $this->db->query($query, $vars);
|
||||||
$result = $stmt->fetch();
|
$result = $stmt->fetch();
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
|
@ -179,7 +186,15 @@ class Mysql
|
||||||
{
|
{
|
||||||
$table = ($noPrefix ? '' : $this->dbPrefix) . $table;
|
$table = ($noPrefix ? '' : $this->dbPrefix) . $table;
|
||||||
try {
|
try {
|
||||||
$stmt = $this->db->query('SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?s:table AND COLUMN_NAME = ?s:field', [':table' => $table, ':field' => $field]);
|
$vars = [
|
||||||
|
':table' => $table,
|
||||||
|
':field' => $field,
|
||||||
|
];
|
||||||
|
$query = 'SELECT 1
|
||||||
|
FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?s:table AND COLUMN_NAME = ?s:field';
|
||||||
|
|
||||||
|
$stmt = $this->db->query($query, $vars);
|
||||||
$result = $stmt->fetch();
|
$result = $stmt->fetch();
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
|
@ -202,7 +217,15 @@ class Mysql
|
||||||
$table = ($noPrefix ? '' : $this->dbPrefix) . $table;
|
$table = ($noPrefix ? '' : $this->dbPrefix) . $table;
|
||||||
$index = 'PRIMARY' == $index ? $index : $table . '_' . $index;
|
$index = 'PRIMARY' == $index ? $index : $table . '_' . $index;
|
||||||
try {
|
try {
|
||||||
$stmt = $this->db->query('SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?s:table AND INDEX_NAME = ?s:index', [':table' => $table, ':index' => $index]);
|
$vars = [
|
||||||
|
':table' => $table,
|
||||||
|
':index' => $index,
|
||||||
|
];
|
||||||
|
$query = 'SELECT 1
|
||||||
|
FROM INFORMATION_SCHEMA.STATISTICS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?s:table AND INDEX_NAME = ?s:index';
|
||||||
|
|
||||||
|
$stmt = $this->db->query($query, $vars);
|
||||||
$result = $stmt->fetch();
|
$result = $stmt->fetch();
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
|
@ -546,7 +569,14 @@ class Mysql
|
||||||
*/
|
*/
|
||||||
public function getMap(): array
|
public function getMap(): array
|
||||||
{
|
{
|
||||||
$stmt = $this->db->query('SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME LIKE ?s', ["{$this->dbPrefix}%"]);
|
$vars = [
|
||||||
|
"{$this->dbPrefix}%",
|
||||||
|
];
|
||||||
|
$query = 'SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE
|
||||||
|
FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME LIKE ?s';
|
||||||
|
|
||||||
|
$stmt = $this->db->query($query, $vars);
|
||||||
$result = [];
|
$result = [];
|
||||||
$table = null;
|
$table = null;
|
||||||
while ($row = $stmt->fetch()) {
|
while ($row = $stmt->fetch()) {
|
||||||
|
|
|
@ -120,7 +120,10 @@ class File
|
||||||
protected function filterName(string $name): string
|
protected function filterName(string $name): string
|
||||||
{
|
{
|
||||||
if (\function_exists('\\transliterator_transliterate')) {
|
if (\function_exists('\\transliterator_transliterate')) {
|
||||||
$name = \transliterator_transliterate("Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();", $name);
|
$name = \transliterator_transliterate(
|
||||||
|
"Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();",
|
||||||
|
$name
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$name = \trim(\preg_replace('%[^\w.-]+%', '-', $name), '-');
|
$name = \trim(\preg_replace('%[^\w.-]+%', '-', $name), '-');
|
||||||
|
|
|
@ -138,7 +138,17 @@ class Func
|
||||||
$pages[] = [__($info, $cur, $all), 'info', null];
|
$pages[] = [__($info, $cur, $all), 'info', null];
|
||||||
$cur = \min(\max(1, $cur), $all);
|
$cur = \min(\max(1, $cur), $all);
|
||||||
if ($cur > 1) {
|
if ($cur > 1) {
|
||||||
$pages[] = [$this->c->Router->link($marker, ['page' => $cur - 1] + $args), 'prev', null];
|
$pages[] = [
|
||||||
|
$this->c->Router->link(
|
||||||
|
$marker,
|
||||||
|
[
|
||||||
|
'page' => $cur - 1,
|
||||||
|
]
|
||||||
|
+ $args
|
||||||
|
),
|
||||||
|
'prev',
|
||||||
|
null,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
$tpl = [1 => 1];
|
$tpl = [1 => 1];
|
||||||
$start = $cur < 6 ? 2 : $cur - 2;
|
$start = $cur < 6 ? 2 : $cur - 2;
|
||||||
|
@ -160,7 +170,17 @@ class Func
|
||||||
if ($i === $cur) {
|
if ($i === $cur) {
|
||||||
$pages[] = [null, $i, true];
|
$pages[] = [null, $i, true];
|
||||||
} else {
|
} else {
|
||||||
$pages[] = [$this->c->Router->link($marker, ['page' => $i] + $args), $i, null];
|
$pages[] = [
|
||||||
|
$this->c->Router->link(
|
||||||
|
$marker,
|
||||||
|
[
|
||||||
|
'page' => $i,
|
||||||
|
]
|
||||||
|
+ $args
|
||||||
|
),
|
||||||
|
$i,
|
||||||
|
null,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
$k = $i;
|
$k = $i;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +188,17 @@ class Func
|
||||||
$cur > 0
|
$cur > 0
|
||||||
&& $cur < $all
|
&& $cur < $all
|
||||||
) {
|
) {
|
||||||
$pages[] = [$this->c->Router->link($marker, ['page' => $cur + 1] + $args), 'next', null];
|
$pages[] = [
|
||||||
|
$this->c->Router->link(
|
||||||
|
$marker,
|
||||||
|
[
|
||||||
|
'page' => $cur + 1,
|
||||||
|
]
|
||||||
|
+ $args
|
||||||
|
),
|
||||||
|
'next',
|
||||||
|
null,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $pages;
|
return $pages;
|
||||||
|
|
|
@ -101,7 +101,11 @@ class Mail
|
||||||
if (
|
if (
|
||||||
! \is_string($email)
|
! \is_string($email)
|
||||||
|| \mb_strlen($email, 'UTF-8') > 80 //???? for DB
|
|| \mb_strlen($email, 'UTF-8') > 80 //???? for DB
|
||||||
|| ! \preg_match('%^(?!\.)((?:(?:^|\.)(?>"(?!\s)(?:\x5C[^\x00-\x1F]|[^\x00-\x1F\x5C"])++(?<!\s)"|[a-zA-Z0-9!#$\%&\'*+/=?^_`{|}~-]+))+)@([^\x00-\x1F\s@]++)$%Du', $email, $matches)
|
|| ! \preg_match(
|
||||||
|
'%^(?!\.)((?:(?:^|\.)(?>"(?!\s)(?:\x5C[^\x00-\x1F]|[^\x00-\x1F\x5C"])++(?<!\s)"|[a-zA-Z0-9!#$\%&\'*+/=?^_`{|}~-]+))+)@([^\x00-\x1F\s@]++)$%Du',
|
||||||
|
$email,
|
||||||
|
$matches
|
||||||
|
)
|
||||||
|| \mb_strlen($matches[1], 'UTF-8') > 64
|
|| \mb_strlen($matches[1], 'UTF-8') > 64
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -159,7 +159,11 @@ class Router
|
||||||
// значение не обязательно
|
// значение не обязательно
|
||||||
} else {
|
} else {
|
||||||
// $link = preg_replace('%\[[^\[\]{}]*{' . preg_quote($name, '%') . '}[^\[\]{}]*\]%', '', $link);
|
// $link = preg_replace('%\[[^\[\]{}]*{' . preg_quote($name, '%') . '}[^\[\]{}]*\]%', '', $link);
|
||||||
$link = \preg_replace('%\[[^\[\]]*?{' . \preg_quote($name, '%') . '}[^\[\]]*+(\[((?>[^\[\]]*+)|(?1))+\])*?\]%', '', $link);
|
$link = \preg_replace(
|
||||||
|
'%\[[^\[\]]*?{' . \preg_quote($name, '%') . '}[^\[\]]*+(\[((?>[^\[\]]*+)|(?1))+\])*?\]%',
|
||||||
|
'',
|
||||||
|
$link
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$link = \str_replace(['[', ']'], '', $link);
|
$link = \str_replace(['[', ']'], '', $link);
|
||||||
|
@ -238,7 +242,9 @@ class Router
|
||||||
$args = [];
|
$args = [];
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
if (isset($matches[$key])) { // ???? может isset($matches[$key][0]) тут поставить?
|
if (isset($matches[$key])) { // ???? может isset($matches[$key][0]) тут поставить?
|
||||||
$args[$key] = isset($matches[$key][0]) ? \str_replace($this->subRepl, $this->subSearch, $matches[$key]) : null;
|
$args[$key] = isset($matches[$key][0])
|
||||||
|
? \str_replace($this->subRepl, $this->subSearch, $matches[$key])
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return [self::OK, $handler, $args, $marker];
|
return [self::OK, $handler, $args, $marker];
|
||||||
|
|
|
@ -21,9 +21,11 @@ class Delete extends Method
|
||||||
$vars = [
|
$vars = [
|
||||||
':ids' => $ids,
|
':ids' => $ids,
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::bans WHERE id IN (?ai:ids)';
|
$query = 'DELETE
|
||||||
|
FROM ::bans
|
||||||
|
WHERE id IN (?ai:ids)';
|
||||||
|
|
||||||
$this->c->DB->exec($sql, $vars);
|
$this->c->DB->exec($query, $vars);
|
||||||
$this->model->load();
|
$this->model->load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,18 +98,18 @@ class Filter extends Method
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($where)) {
|
if (empty($where)) {
|
||||||
$sql = "SELECT b.id
|
$query = "SELECT b.id
|
||||||
FROM ::bans AS b
|
FROM ::bans AS b
|
||||||
ORDER BY {$orderBy}";
|
ORDER BY {$orderBy}";
|
||||||
} else {
|
} else {
|
||||||
$where = \implode(' AND ', $where);
|
$where = \implode(' AND ', $where);
|
||||||
$sql = "SELECT b.id
|
$query = "SELECT b.id
|
||||||
FROM ::bans AS b
|
FROM ::bans AS b
|
||||||
WHERE {$where}
|
WHERE {$where}
|
||||||
ORDER BY {$orderBy}";
|
ORDER BY {$orderBy}";
|
||||||
}
|
}
|
||||||
|
|
||||||
$ids = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
$ids = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
return $ids;
|
return $ids;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,13 +18,12 @@ class GetList extends Method
|
||||||
$vars = [
|
$vars = [
|
||||||
':ids' => $ids,
|
':ids' => $ids,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT b.id, b.username, b.ip, b.email, b.message, b.expire, u.id AS id_creator, u.username AS name_creator
|
$query = 'SELECT b.id, b.username, b.ip, b.email, b.message, b.expire, u.id AS id_creator, u.username AS name_creator
|
||||||
FROM ::bans AS b
|
FROM ::bans AS b
|
||||||
LEFT JOIN ::users AS u ON u.id=b.ban_creator
|
LEFT JOIN ::users AS u ON u.id=b.ban_creator
|
||||||
WHERE b.id IN (?ai:ids)';
|
WHERE b.id IN (?ai:ids)';
|
||||||
|
|
||||||
$stmt = $this->c->DB->query($sql, $vars);
|
$stmt = $this->c->DB->query($query, $vars);
|
||||||
|
|
||||||
$list = \array_fill_keys($ids, false);
|
$list = \array_fill_keys($ids, false);
|
||||||
|
|
||||||
while ($row = $stmt->fetch()) {
|
while ($row = $stmt->fetch()) {
|
||||||
|
|
|
@ -34,9 +34,10 @@ class Insert extends Method
|
||||||
|
|
||||||
$ban['creator'] = $this->c->user->id;
|
$ban['creator'] = $this->c->user->id;
|
||||||
|
|
||||||
$sql = 'INSERT INTO ::bans (username, ip, email, message, expire, ban_creator)
|
$query = 'INSERT INTO ::bans (username, ip, email, message, expire, ban_creator)
|
||||||
VALUES (?s:username, ?s:ip, ?s:email, ?s:message, ?i:expire, ?i:creator)';
|
VALUES (?s:username, ?s:ip, ?s:email, ?s:message, ?i:expire, ?i:creator)';
|
||||||
$this->c->DB->exec($sql, $ban);
|
|
||||||
|
$this->c->DB->exec($query, $ban);
|
||||||
|
|
||||||
return $this->model;
|
return $this->model;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,11 @@ class Update extends Method
|
||||||
throw new InvalidArgumentException('Empty ban');
|
throw new InvalidArgumentException('Empty ban');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'UPDATE ::bans
|
$query = 'UPDATE ::bans
|
||||||
SET username=?s:username, ip=?s:ip, email=?s:email, message=?s:message, expire=?i:expire
|
SET username=?s:username, ip=?s:ip, email=?s:email, message=?s:message, expire=?i:expire
|
||||||
WHERE id=?i:id';
|
WHERE id=?i:id';
|
||||||
$this->c->DB->exec($sql, $ban);
|
|
||||||
|
$this->c->DB->exec($query, $ban);
|
||||||
|
|
||||||
return $this->model;
|
return $this->model;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,12 @@ class Manager extends ManagerModel
|
||||||
*/
|
*/
|
||||||
public function init(): self
|
public function init(): self
|
||||||
{
|
{
|
||||||
$sql = 'SELECT c.id, c.cat_name, c.disp_position
|
$query = 'SELECT c.id, c.cat_name, c.disp_position
|
||||||
FROM ::categories AS c
|
FROM ::categories AS c
|
||||||
ORDER BY c.disp_position';
|
ORDER BY c.disp_position';
|
||||||
$this->repository = $this->c->DB->query($sql)->fetchAll(PDO::FETCH_UNIQUE);
|
|
||||||
|
$this->repository = $this->c->DB->query($query)->fetchAll(PDO::FETCH_UNIQUE);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,10 +66,11 @@ class Manager extends ManagerModel
|
||||||
':position' => $cat['disp_position'],
|
':position' => $cat['disp_position'],
|
||||||
':cid' => $key,
|
':cid' => $key,
|
||||||
];
|
];
|
||||||
$sql = 'UPDATE ::categories
|
$query = 'UPDATE ::categories
|
||||||
SET cat_name=?s:name, disp_position=?i:position
|
SET cat_name=?s:name, disp_position=?i:position
|
||||||
WHERE id=?i:cid';
|
WHERE id=?i:cid';
|
||||||
$this->c->DB->query($sql, $vars); //????
|
|
||||||
|
$this->c->DB->query($query, $vars); //????
|
||||||
}
|
}
|
||||||
$this->modified = [];
|
$this->modified = [];
|
||||||
|
|
||||||
|
@ -88,9 +91,9 @@ class Manager extends ManagerModel
|
||||||
':name' => $name,
|
':name' => $name,
|
||||||
':position' => $pos,
|
':position' => $pos,
|
||||||
];
|
];
|
||||||
$sql = 'INSERT INTO ::categories (cat_name, disp_position)
|
$query = 'INSERT INTO ::categories (cat_name, disp_position)
|
||||||
VALUES (?s:name, ?i:position)';
|
VALUES (?s:name, ?i:position)';
|
||||||
$this->c->DB->query($sql, $vars);
|
$this->c->DB->query($query, $vars);
|
||||||
|
|
||||||
$cid = $this->c->DB->lastInsertId();
|
$cid = $this->c->DB->lastInsertId();
|
||||||
|
|
||||||
|
@ -117,9 +120,11 @@ class Manager extends ManagerModel
|
||||||
$vars = [
|
$vars = [
|
||||||
':cid' => $cid,
|
':cid' => $cid,
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::categories
|
$query = 'DELETE
|
||||||
|
FROM ::categories
|
||||||
WHERE id=?i:cid';
|
WHERE id=?i:cid';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,10 @@ class Load extends Method
|
||||||
*/
|
*/
|
||||||
public function load(): array
|
public function load(): array
|
||||||
{
|
{
|
||||||
$sql = 'SELECT ce.id, ce.search_for, ce.replace_with
|
$query = 'SELECT ce.id, ce.search_for, ce.replace_with
|
||||||
FROM ::censoring AS ce
|
FROM ::censoring AS ce
|
||||||
ORDER BY REPLACE(ce.search_for, \'*\', \'\')';
|
ORDER BY REPLACE(ce.search_for, \'*\', \'\')';
|
||||||
return $this->c->DB->query($sql)->fetchAll(PDO::FETCH_UNIQUE);
|
|
||||||
|
return $this->c->DB->query($query)->fetchAll(PDO::FETCH_UNIQUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,9 @@ class Refresh extends Method
|
||||||
$search = [];
|
$search = [];
|
||||||
$replace = [];
|
$replace = [];
|
||||||
while ($row = $stmt->fetch()) {
|
while ($row = $stmt->fetch()) {
|
||||||
$search[$row['id']] = '%(?<![\p{L}\p{N}])(' . \str_replace('\*', '[\p{L}\p{N}]*?', \preg_quote($row['search_for'], '%')).')(?![\p{L}\p{N}])%iu';
|
$search[$row['id']] = '%(?<![\p{L}\p{N}])('
|
||||||
|
. \str_replace('\*', '[\p{L}\p{N}]*?', \preg_quote($row['search_for'], '%'))
|
||||||
|
. ')(?![\p{L}\p{N}])%iu';
|
||||||
$replace[$row['id']] = $row['replace_with'];
|
$replace[$row['id']] = $row['replace_with'];
|
||||||
}
|
}
|
||||||
$this->model->searchList = $search;
|
$this->model->searchList = $search;
|
||||||
|
|
|
@ -37,27 +37,32 @@ class Save extends Method
|
||||||
':search' => $list[$id]['search_for'],
|
':search' => $list[$id]['search_for'],
|
||||||
':replace' => $list[$id]['replace_with'],
|
':replace' => $list[$id]['replace_with'],
|
||||||
];
|
];
|
||||||
$sql = 'UPDATE ::censoring
|
$query = 'UPDATE ::censoring
|
||||||
SET search_for=?s:search, replace_with=?s:replace
|
SET search_for=?s:search, replace_with=?s:replace
|
||||||
WHERE id=?i:id';
|
WHERE id=?i:id';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
} elseif (0 === $id) {
|
} elseif (0 === $id) {
|
||||||
$vars = [
|
$vars = [
|
||||||
':search' => $list[$id]['search_for'],
|
':search' => $list[$id]['search_for'],
|
||||||
':replace' => $list[$id]['replace_with'],
|
':replace' => $list[$id]['replace_with'],
|
||||||
];
|
];
|
||||||
$sql = 'INSERT INTO ::censoring (search_for, replace_with)
|
$query = 'INSERT INTO ::censoring (search_for, replace_with)
|
||||||
VALUES (?s:search, ?s:replace)';
|
VALUES (?s:search, ?s:replace)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($forDel) {
|
if ($forDel) {
|
||||||
$vars = [
|
$vars = [
|
||||||
':del' => $forDel
|
':del' => $forDel
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::censoring WHERE id IN (?ai:del)';
|
$query = 'DELETE
|
||||||
$this->c->DB->exec($sql, $vars);
|
FROM ::censoring
|
||||||
|
WHERE id IN (?ai:del)';
|
||||||
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->c->Cache->delete('censorship');
|
$this->c->Cache->delete('censorship');
|
||||||
|
|
|
@ -28,13 +28,27 @@ class Save extends Method
|
||||||
];
|
];
|
||||||
//????
|
//????
|
||||||
//????
|
//????
|
||||||
$count = $this->c->DB->exec('UPDATE ::config SET conf_value=?s:value WHERE conf_name=?s:name', $vars);
|
$query = 'UPDATE ::config
|
||||||
|
SET conf_value=?s:value
|
||||||
|
WHERE conf_name=?s:name';
|
||||||
|
|
||||||
|
$count = $this->c->DB->exec($query, $vars);
|
||||||
//????
|
//????
|
||||||
//????
|
//????
|
||||||
if (0 === $count) {
|
if (0 === $count) {
|
||||||
//????
|
//????
|
||||||
//????
|
//????
|
||||||
$this->c->DB->exec('INSERT INTO ::config (conf_name, conf_value) SELECT ?s:name, ?s:value FROM ::groups WHERE NOT EXISTS (SELECT 1 FROM ::config WHERE conf_name=?s:name) LIMIT 1', $vars);
|
$query = 'INSERT INTO ::config (conf_name, conf_value)
|
||||||
|
SELECT ?s:name, ?s:value
|
||||||
|
FROM ::groups
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM ::config
|
||||||
|
WHERE conf_name=?s:name
|
||||||
|
)
|
||||||
|
LIMIT 1';
|
||||||
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->c->Cache->delete('config');
|
$this->c->Cache->delete('config');
|
||||||
|
|
|
@ -81,7 +81,9 @@ class Model extends ParentModel
|
||||||
public function get(string $name, $default = null)
|
public function get(string $name, $default = null)
|
||||||
{
|
{
|
||||||
$name = $this->prefix . $name;
|
$name = $this->prefix . $name;
|
||||||
return isset($_COOKIE[$name]) ? $this->c->Secury->replInvalidChars($_COOKIE[$name]) : $default;
|
return isset($_COOKIE[$name])
|
||||||
|
? $this->c->Secury->replInvalidChars($_COOKIE[$name])
|
||||||
|
: $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -182,7 +184,11 @@ class Model extends ParentModel
|
||||||
$passHash = $this->c->Secury->hmac($user->password . $expTime, $this->key2);
|
$passHash = $this->c->Secury->hmac($user->password . $expTime, $this->key2);
|
||||||
$ckHash = $this->c->Secury->hmac($pfx . $user->id . $expTime . $passHash, $this->key1);
|
$ckHash = $this->c->Secury->hmac($pfx . $user->id . $expTime . $passHash, $this->key1);
|
||||||
|
|
||||||
return $this->set(self::NAME, $pfx . $user->id . '_' . $expTime . '_' . $passHash . '_' . $ckHash, $expire);
|
return $this->set(
|
||||||
|
self::NAME,
|
||||||
|
$pfx . $user->id . '_' . $expTime . '_' . $passHash . '_' . $ckHash,
|
||||||
|
$expire
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,28 +22,28 @@ class CalcStat extends Method
|
||||||
}
|
}
|
||||||
|
|
||||||
$vars = [':fid' => $this->model->id];
|
$vars = [':fid' => $this->model->id];
|
||||||
$sql = 'SELECT COUNT(t.id)
|
$query = 'SELECT COUNT(t.id)
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
WHERE t.forum_id=?i:fid AND t.moved_to!=0';
|
WHERE t.forum_id=?i:fid AND t.moved_to!=0';
|
||||||
|
|
||||||
$moved = $this->c->DB->query($sql, $vars)->fetchColumn();
|
$moved = $this->c->DB->query($query, $vars)->fetchColumn();
|
||||||
|
|
||||||
$sql = 'SELECT COUNT(t.id) as num_topics, SUM(t.num_replies) as num_replies
|
$query = 'SELECT COUNT(t.id) as num_topics, SUM(t.num_replies) as num_replies
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
WHERE t.forum_id=?i:fid AND t.moved_to=0';
|
WHERE t.forum_id=?i:fid AND t.moved_to=0';
|
||||||
|
|
||||||
$result = $this->c->DB->query($sql, $vars)->fetch();
|
$result = $this->c->DB->query($query, $vars)->fetch();
|
||||||
|
|
||||||
$this->model->num_topics = $result['num_topics'] + $moved;
|
$this->model->num_topics = $result['num_topics'] + $moved;
|
||||||
$this->model->num_posts = $result['num_topics'] + $result['num_replies'];
|
$this->model->num_posts = $result['num_topics'] + $result['num_replies'];
|
||||||
|
|
||||||
$sql = 'SELECT t.last_post, t.last_post_id, t.last_poster, t.subject as last_topic
|
$query = 'SELECT t.last_post, t.last_post_id, t.last_poster, t.subject as last_topic
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
WHERE t.forum_id=?i:fid AND t.moved_to=0
|
WHERE t.forum_id=?i:fid AND t.moved_to=0
|
||||||
ORDER BY t.last_post DESC
|
ORDER BY t.last_post DESC
|
||||||
LIMIT 1';
|
LIMIT 1';
|
||||||
|
|
||||||
$result = $this->c->DB->query($sql, $vars)->fetch();
|
$result = $this->c->DB->query($query, $vars)->fetch();
|
||||||
|
|
||||||
if (empty($result)) {
|
if (empty($result)) {
|
||||||
$this->model->last_post = 0;
|
$this->model->last_post = 0;
|
||||||
|
|
|
@ -69,9 +69,11 @@ class Delete extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':users' => $users,
|
':users' => $users,
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::mark_of_forum
|
$query = 'DELETE
|
||||||
|
FROM ::mark_of_forum
|
||||||
WHERE uid IN (?ai:users)';
|
WHERE uid IN (?ai:users)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
|
|
||||||
//???? удаление модераторов из разделов
|
//???? удаление модераторов из разделов
|
||||||
}
|
}
|
||||||
|
@ -83,13 +85,17 @@ class Delete extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':forums' => \array_keys($forums),
|
':forums' => \array_keys($forums),
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::mark_of_forum
|
$query = 'DELETE
|
||||||
|
FROM ::mark_of_forum
|
||||||
WHERE fid IN (?ai:forums)';
|
WHERE fid IN (?ai:forums)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
|
||||||
$sql = 'DELETE FROM ::forums
|
$this->c->DB->exec($query, $vars);
|
||||||
|
|
||||||
|
$query = 'DELETE
|
||||||
|
FROM ::forums
|
||||||
WHERE id IN (?ai:forums)';
|
WHERE id IN (?ai:forums)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,12 +57,12 @@ class LoadTree extends Action
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($this->c->user->isGuest) {
|
if ($this->c->user->isGuest) {
|
||||||
$sql = 'SELECT f.id, f.forum_desc, f.num_topics, f.sort_by, f.num_posts,
|
$query = 'SELECT f.id, f.forum_desc, f.num_topics, f.sort_by, f.num_posts,
|
||||||
f.last_post, f.last_post_id, f.last_poster, f.last_topic
|
f.last_post, f.last_post_id, f.last_poster, f.last_topic
|
||||||
FROM ::forums AS f
|
FROM ::forums AS f
|
||||||
WHERE id IN (?ai:forums)';
|
WHERE id IN (?ai:forums)';
|
||||||
} elseif ('1' == $this->c->config->o_forum_subscriptions) {
|
} elseif ('1' == $this->c->config->o_forum_subscriptions) {
|
||||||
$sql = 'SELECT f.id, f.forum_desc, f.num_topics, f.sort_by, f.num_posts,
|
$query = 'SELECT f.id, f.forum_desc, f.num_topics, f.sort_by, f.num_posts,
|
||||||
f.last_post, f.last_post_id, f.last_poster, f.last_topic,
|
f.last_post, f.last_post_id, f.last_poster, f.last_topic,
|
||||||
mof.mf_mark_all_read, s.user_id AS is_subscribed
|
mof.mf_mark_all_read, s.user_id AS is_subscribed
|
||||||
FROM ::forums AS f
|
FROM ::forums AS f
|
||||||
|
@ -70,7 +70,7 @@ class LoadTree extends Action
|
||||||
LEFT JOIN ::mark_of_forum AS mof ON (mof.uid=?i:uid AND mof.fid=f.id)
|
LEFT JOIN ::mark_of_forum AS mof ON (mof.uid=?i:uid AND mof.fid=f.id)
|
||||||
WHERE f.id IN (?ai:forums)';
|
WHERE f.id IN (?ai:forums)';
|
||||||
} else {
|
} else {
|
||||||
$sql = 'SELECT f.id, f.forum_desc, f.num_topics, f.sort_by, f.num_posts,
|
$query = 'SELECT f.id, f.forum_desc, f.num_topics, f.sort_by, f.num_posts,
|
||||||
f.last_post, f.last_post_id, f.last_poster, f.last_topic,
|
f.last_post, f.last_post_id, f.last_poster, f.last_topic,
|
||||||
mof.mf_mark_all_read
|
mof.mf_mark_all_read
|
||||||
FROM ::forums AS f
|
FROM ::forums AS f
|
||||||
|
@ -78,7 +78,7 @@ class LoadTree extends Action
|
||||||
WHERE f.id IN (?ai:forums)';
|
WHERE f.id IN (?ai:forums)';
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = $this->c->DB->query($sql, $vars);
|
$stmt = $this->c->DB->query($query, $vars);
|
||||||
while ($cur = $stmt->fetch()) {
|
while ($cur = $stmt->fetch()) {
|
||||||
$list[$cur['id']]->replAttrs($cur)->__ready = true;
|
$list[$cur['id']]->replAttrs($cur)->__ready = true;
|
||||||
}
|
}
|
||||||
|
@ -118,14 +118,15 @@ class LoadTree extends Action
|
||||||
':forums' => \array_keys($time),
|
':forums' => \array_keys($time),
|
||||||
':max' => $max,
|
':max' => $max,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT t.forum_id, t.last_post
|
$query = 'SELECT t.forum_id, t.last_post
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
LEFT JOIN ::mark_of_topic AS mot ON (mot.uid=?i:uid AND mot.tid=t.id)
|
LEFT JOIN ::mark_of_topic AS mot ON (mot.uid=?i:uid AND mot.tid=t.id)
|
||||||
WHERE t.forum_id IN(?ai:forums)
|
WHERE t.forum_id IN(?ai:forums)
|
||||||
AND t.last_post>?i:max
|
AND t.last_post>?i:max
|
||||||
AND t.moved_to=0
|
AND t.moved_to=0
|
||||||
AND (mot.mt_last_visit IS NULL OR t.last_post>mot.mt_last_visit)';
|
AND (mot.mt_last_visit IS NULL OR t.last_post>mot.mt_last_visit)';
|
||||||
$stmt = $this->c->DB->query($sql, $vars);
|
|
||||||
|
$stmt = $this->c->DB->query($query, $vars);
|
||||||
while ($cur = $stmt->fetch()) {
|
while ($cur = $stmt->fetch()) {
|
||||||
if ($cur['last_post'] > $time[$cur['forum_id']]) {
|
if ($cur['last_post'] > $time[$cur['forum_id']]) {
|
||||||
$list[$cur['forum_id']]->__newMessages = true; //????
|
$list[$cur['forum_id']]->__newMessages = true; //????
|
||||||
|
|
|
@ -32,34 +32,43 @@ class Markread extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':uid' => $user->id,
|
':uid' => $user->id,
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::mark_of_topic WHERE uid=?i:uid';
|
$query = 'DELETE
|
||||||
$this->c->DB->exec($sql, $vars);
|
FROM ::mark_of_topic
|
||||||
|
WHERE uid=?i:uid';
|
||||||
|
|
||||||
$sql = 'DELETE FROM ::mark_of_forum WHERE uid=?i:uid';
|
$this->c->DB->exec($query, $vars);
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$query = 'DELETE
|
||||||
|
FROM ::mark_of_forum
|
||||||
|
WHERE uid=?i:uid';
|
||||||
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
} elseif ($forum->id > 0) {
|
} elseif ($forum->id > 0) {
|
||||||
$vars = [
|
$vars = [
|
||||||
':uid' => $user->id,
|
':uid' => $user->id,
|
||||||
':fid' => $forum->id,
|
':fid' => $forum->id,
|
||||||
':mark' => \time(),
|
':mark' => \time(),
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::mark_of_topic
|
$query = 'DELETE
|
||||||
|
FROM ::mark_of_topic
|
||||||
WHERE uid=?i:uid AND tid IN (
|
WHERE uid=?i:uid AND tid IN (
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM ::topics
|
FROM ::topics
|
||||||
WHERE forum_id=?i:fid
|
WHERE forum_id=?i:fid
|
||||||
)';
|
)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
|
|
||||||
if ($user->mf_mark_all_read) { // ????
|
if ($user->mf_mark_all_read) { // ????
|
||||||
$sql = 'UPDATE ::mark_of_forum
|
$query = 'UPDATE ::mark_of_forum
|
||||||
SET mf_mark_all_read=?i:mark
|
SET mf_mark_all_read=?i:mark
|
||||||
WHERE uid=?i:uid AND fid=?i:fid';
|
WHERE uid=?i:uid AND fid=?i:fid';
|
||||||
} else { // ????
|
} else { // ????
|
||||||
$sql = 'INSERT INTO ::mark_of_forum (uid, fid, mf_mark_all_read)
|
$query = 'INSERT INTO ::mark_of_forum (uid, fid, mf_mark_all_read)
|
||||||
VALUES (?i:uid, ?i:fid, ?i:mark)';
|
VALUES (?i:uid, ?i:fid, ?i:mark)';
|
||||||
}
|
}
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException('The model does not have ID');
|
throw new RuntimeException('The model does not have ID');
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,13 @@ class Model extends DataModel
|
||||||
if (0 === $this->id) {
|
if (0 === $this->id) {
|
||||||
return $this->c->Router->link('Index');
|
return $this->c->Router->link('Index');
|
||||||
} else {
|
} else {
|
||||||
return $this->c->Router->link('Forum', ['id' => $this->id, 'name' => $this->forum_name]);
|
return $this->c->Router->link(
|
||||||
|
'Forum',
|
||||||
|
[
|
||||||
|
'id' => $this->id,
|
||||||
|
'name' => $this->forum_name,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,9 +123,20 @@ class Model extends DataModel
|
||||||
protected function getlinkNew(): string
|
protected function getlinkNew(): string
|
||||||
{
|
{
|
||||||
if (0 === $this->id) {
|
if (0 === $this->id) {
|
||||||
return $this->c->Router->link('SearchAction', ['action' => 'new']);
|
return $this->c->Router->link(
|
||||||
|
'SearchAction',
|
||||||
|
[
|
||||||
|
'action' => 'new',
|
||||||
|
]
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return $this->c->Router->link('SearchAction', ['action' => 'new', 'forum' => $this->id]);
|
return $this->c->Router->link(
|
||||||
|
'SearchAction',
|
||||||
|
[
|
||||||
|
'action' => 'new',
|
||||||
|
'forum' => $this->id,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +150,12 @@ class Model extends DataModel
|
||||||
if ($this->last_post_id < 1) {
|
if ($this->last_post_id < 1) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return $this->c->Router->link('ViewPost', ['id' => $this->last_post_id]);
|
return $this->c->Router->link(
|
||||||
|
'ViewPost',
|
||||||
|
[
|
||||||
|
'id' => $this->last_post_id,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +166,12 @@ class Model extends DataModel
|
||||||
*/
|
*/
|
||||||
protected function getlinkCreateTopic(): string
|
protected function getlinkCreateTopic(): string
|
||||||
{
|
{
|
||||||
return $this->c->Router->link('NewTopic', ['id' => $this->id]);
|
return $this->c->Router->link(
|
||||||
|
'NewTopic',
|
||||||
|
[
|
||||||
|
'id' => $this->id,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -154,10 +181,17 @@ class Model extends DataModel
|
||||||
*/
|
*/
|
||||||
protected function getlinkMarkRead(): string
|
protected function getlinkMarkRead(): string
|
||||||
{
|
{
|
||||||
return $this->c->Router->link('MarkRead', [
|
return $this->c->Router->link(
|
||||||
|
'MarkRead', [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'token' => $this->c->Csrf->create('MarkRead', ['id' => $this->id]),
|
'token' => $this->c->Csrf->create(
|
||||||
]);
|
'MarkRead',
|
||||||
|
[
|
||||||
|
'id' => $this->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -311,7 +345,12 @@ class Model extends DataModel
|
||||||
*/
|
*/
|
||||||
protected function getpagination(): array
|
protected function getpagination(): array
|
||||||
{
|
{
|
||||||
return $this->c->Func->paginate($this->numPages, $this->page, 'Forum', ['id' => $this->id, 'name' => $this->forum_name]);
|
return $this->c->Func->paginate(
|
||||||
|
$this->numPages,
|
||||||
|
$this->page,
|
||||||
|
'Forum',
|
||||||
|
['id' => $this->id, 'name' => $this->forum_name]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -358,13 +397,13 @@ class Model extends DataModel
|
||||||
':offset' => ($this->page - 1) * $this->c->user->disp_topics,
|
':offset' => ($this->page - 1) * $this->c->user->disp_topics,
|
||||||
':rows' => $this->c->user->disp_topics,
|
':rows' => $this->c->user->disp_topics,
|
||||||
];
|
];
|
||||||
$sql = "SELECT t.id
|
$query = "SELECT t.id
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
WHERE t.forum_id=?i:fid
|
WHERE t.forum_id=?i:fid
|
||||||
ORDER BY t.sticky DESC, {$sortBy}, t.id DESC
|
ORDER BY t.sticky DESC, {$sortBy}, t.id DESC
|
||||||
LIMIT ?i:offset, ?i:rows";
|
LIMIT ?i:offset, ?i:rows";
|
||||||
|
|
||||||
$this->idsList = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
$this->idsList = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
return empty($this->idsList) ? [] : $this->c->topics->view($this);
|
return empty($this->idsList) ? [] : $this->c->topics->view($this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class Refresh extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':gid' => $gid,
|
':gid' => $gid,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT f.cat_id, c.cat_name, f.id, f.forum_name, f.redirect_url, f.parent_forum_id,
|
$query = 'SELECT f.cat_id, c.cat_name, f.id, f.forum_name, f.redirect_url, f.parent_forum_id,
|
||||||
f.moderators, f.no_sum_mess, f.disp_position, fp.post_topics, fp.post_replies
|
f.moderators, f.no_sum_mess, f.disp_position, fp.post_topics, fp.post_replies
|
||||||
FROM ::categories AS c
|
FROM ::categories AS c
|
||||||
INNER JOIN ::forums AS f ON c.id=f.cat_id
|
INNER JOIN ::forums AS f ON c.id=f.cat_id
|
||||||
|
@ -43,7 +43,7 @@ class Refresh extends Action
|
||||||
WHERE fp.read_forum IS NULL OR fp.read_forum=1
|
WHERE fp.read_forum IS NULL OR fp.read_forum=1
|
||||||
ORDER BY c.disp_position, c.id, f.disp_position';
|
ORDER BY c.disp_position, c.id, f.disp_position';
|
||||||
|
|
||||||
$stmt = $this->c->DB->query($sql, $vars);
|
$stmt = $this->c->DB->query($query, $vars);
|
||||||
while ($row = $stmt->fetch()) {
|
while ($row = $stmt->fetch()) {
|
||||||
$row['moderators'] = $this->formatModers($row['moderators']);
|
$row['moderators'] = $this->formatModers($row['moderators']);
|
||||||
$list[$row['id']] = $row;
|
$list[$row['id']] = $row;
|
||||||
|
|
|
@ -40,8 +40,10 @@ class Save extends Action
|
||||||
return $forum;
|
return $forum;
|
||||||
}
|
}
|
||||||
$vars[] = $forum->id;
|
$vars[] = $forum->id;
|
||||||
|
$query = 'UPDATE ::forums
|
||||||
|
SET ' . \implode(', ', $set) . ' WHERE id=?i';
|
||||||
|
|
||||||
$this->c->DB->exec('UPDATE ::forums SET ' . \implode(', ', $set) . ' WHERE id=?i', $vars);
|
$this->c->DB->exec($query, $vars);
|
||||||
|
|
||||||
// модификация категории у потомков при ее изменении
|
// модификация категории у потомков при ее изменении
|
||||||
if (
|
if (
|
||||||
|
@ -55,9 +57,11 @@ class Save extends Action
|
||||||
':ids' => \array_keys($forum->descendants),
|
':ids' => \array_keys($forum->descendants),
|
||||||
':category' => $values['cat_id'],
|
':category' => $values['cat_id'],
|
||||||
];
|
];
|
||||||
$sql = 'UPDATE ::forums SET cat_id=?i:category WHERE id IN (?ai:ids)';
|
$query = 'UPDATE ::forums
|
||||||
|
SET cat_id=?i:category
|
||||||
|
WHERE id IN (?ai:ids)';
|
||||||
|
|
||||||
$this->c->DB->exec($sql, $vars);
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
$forum->resModified();
|
$forum->resModified();
|
||||||
|
@ -93,7 +97,11 @@ class Save extends Action
|
||||||
if (empty($set)) {
|
if (empty($set)) {
|
||||||
throw new RuntimeException('The model is empty');
|
throw new RuntimeException('The model is empty');
|
||||||
}
|
}
|
||||||
$this->c->DB->query('INSERT INTO ::forums (' . \implode(', ', $set) . ') VALUES (' . \implode(', ', $set2) . ')', $vars);
|
|
||||||
|
$query = 'INSERT INTO ::forums (' . \implode(', ', $set) . ')
|
||||||
|
VALUES (' . \implode(', ', $set2) . ')';
|
||||||
|
|
||||||
|
$this->c->DB->query($query, $vars);
|
||||||
$forum->id = $this->c->DB->lastInsertId();
|
$forum->id = $this->c->DB->lastInsertId();
|
||||||
$forum->resModified();
|
$forum->resModified();
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,10 @@ class Delete extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':gid' => $group->g_id,
|
':gid' => $group->g_id,
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::groups
|
$query = 'DELETE
|
||||||
|
FROM ::groups
|
||||||
WHERE g_id=?i:gid';
|
WHERE g_id=?i:gid';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,12 @@ class Model extends DataModel
|
||||||
{
|
{
|
||||||
protected function getlinkEdit(): string
|
protected function getlinkEdit(): string
|
||||||
{
|
{
|
||||||
return $this->c->Router->link('AdminGroupsEdit', ['id' => $this->g_id]);
|
return $this->c->Router->link(
|
||||||
|
'AdminGroupsEdit',
|
||||||
|
[
|
||||||
|
'id' => $this->g_id,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getcanDelete(): bool
|
protected function getcanDelete(): bool
|
||||||
|
@ -24,7 +29,14 @@ class Model extends DataModel
|
||||||
|
|
||||||
protected function getlinkDelete(): ?string
|
protected function getlinkDelete(): ?string
|
||||||
{
|
{
|
||||||
return $this->canDelete ? $this->c->Router->link('AdminGroupsDelete', ['id' => $this->g_id]) : null;
|
return $this->canDelete
|
||||||
|
? $this->c->Router->link(
|
||||||
|
'AdminGroupsDelete',
|
||||||
|
[
|
||||||
|
'id' => $this->g_id,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getgroupGuest(): bool
|
protected function getgroupGuest(): bool
|
||||||
|
|
|
@ -30,12 +30,13 @@ class Perm extends Action
|
||||||
':fid' => $forum->id > 0 ? $forum->id : 0,
|
':fid' => $forum->id > 0 ? $forum->id : 0,
|
||||||
':adm' => $this->c->GROUP_ADMIN,
|
':adm' => $this->c->GROUP_ADMIN,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT g.g_id, fp.read_forum, fp.post_replies, fp.post_topics
|
$query = 'SELECT g.g_id, fp.read_forum, fp.post_replies, fp.post_topics
|
||||||
FROM ::groups AS g
|
FROM ::groups AS g
|
||||||
LEFT JOIN ::forum_perms AS fp ON (g.g_id=fp.group_id AND fp.forum_id=?i:fid)
|
LEFT JOIN ::forum_perms AS fp ON (g.g_id=fp.group_id AND fp.forum_id=?i:fid)
|
||||||
WHERE g.g_id!=?i:adm
|
WHERE g.g_id!=?i:adm
|
||||||
ORDER BY g.g_id';
|
ORDER BY g.g_id';
|
||||||
$perms = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_UNIQUE);
|
|
||||||
|
$perms = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_UNIQUE);
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($perms as $gid => $perm) {
|
foreach ($perms as $gid => $perm) {
|
||||||
|
@ -99,9 +100,11 @@ class Perm extends Action
|
||||||
':gid' => $id,
|
':gid' => $id,
|
||||||
':fid' => $forum->id,
|
':fid' => $forum->id,
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::forum_perms
|
$query = 'DELETE
|
||||||
|
FROM ::forum_perms
|
||||||
WHERE group_id=?i:gid AND forum_id=?i:fid';
|
WHERE group_id=?i:gid AND forum_id=?i:fid';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($modDef) {
|
if ($modDef) {
|
||||||
|
@ -112,8 +115,10 @@ class Perm extends Action
|
||||||
$list[] = 'group_id';
|
$list[] = 'group_id';
|
||||||
$list[] = 'forum_id';
|
$list[] = 'forum_id';
|
||||||
$list2 = \array_fill(0, \count($list), '?i');
|
$list2 = \array_fill(0, \count($list), '?i');
|
||||||
$sql = 'INSERT INTO ::forum_perms (' . \implode(', ', $list) . ') VALUES (' . \implode(', ', $list2) . ')';
|
$query = 'INSERT INTO ::forum_perms (' . \implode(', ', $list) . ')
|
||||||
$this->c->DB->exec($sql, $vars);
|
VALUES (' . \implode(', ', $list2) . ')';
|
||||||
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,9 +139,11 @@ class Perm extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':fid' => $forum->id,
|
':fid' => $forum->id,
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::forum_perms
|
$query = 'DELETE
|
||||||
|
FROM ::forum_perms
|
||||||
WHERE forum_id=?i:fid';
|
WHERE forum_id=?i:fid';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,9 +162,11 @@ class Perm extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':gid' => $group->g_id,
|
':gid' => $group->g_id,
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::forum_perms
|
$query = 'DELETE
|
||||||
|
FROM ::forum_perms
|
||||||
WHERE group_id=?i:gid';
|
WHERE group_id=?i:gid';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -183,11 +192,11 @@ class Perm extends Action
|
||||||
':old' => $from->g_id,
|
':old' => $from->g_id,
|
||||||
':new' => $to->g_id,
|
':new' => $to->g_id,
|
||||||
];
|
];
|
||||||
$sql = 'INSERT INTO ::forum_perms (group_id, forum_id, read_forum, post_replies, post_topics)
|
$query = 'INSERT INTO ::forum_perms (group_id, forum_id, read_forum, post_replies, post_topics)
|
||||||
SELECT ?i:new, forum_id, read_forum, post_replies, post_topics
|
SELECT ?i:new, forum_id, read_forum, post_replies, post_topics
|
||||||
FROM ::forum_perms
|
FROM ::forum_perms
|
||||||
WHERE group_id=?i:old';
|
WHERE group_id=?i:old';
|
||||||
|
|
||||||
$this->c->DB->exec($sql, $vars);
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,13 @@ class Info extends Method
|
||||||
if ('1' == $this->c->user->g_view_users) {
|
if ('1' == $this->c->user->g_view_users) {
|
||||||
foreach ($this->model->users as $id => $name) {
|
foreach ($this->model->users as $id => $name) {
|
||||||
$info[] = [
|
$info[] = [
|
||||||
$this->c->Router->link('User', [
|
$this->c->Router->link(
|
||||||
|
'User',
|
||||||
|
[
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
]),
|
]
|
||||||
|
),
|
||||||
$name,
|
$name,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,11 +56,19 @@ class Model extends ParentModel
|
||||||
$needClean = false;
|
$needClean = false;
|
||||||
|
|
||||||
if ($detail) {
|
if ($detail) {
|
||||||
$sql = 'SELECT o.user_id, o.ident, o.logged, o.o_position, o.o_name FROM ::online AS o ORDER BY o.logged';
|
$query = 'SELECT o.user_id, o.ident, o.logged, o.o_position, o.o_name
|
||||||
|
FROM ::online AS o
|
||||||
|
ORDER BY o.logged';
|
||||||
} else {
|
} else {
|
||||||
$sql = 'SELECT o.user_id, o.ident, o.logged FROM ::online AS o ORDER BY o.logged';
|
$query = 'SELECT o.user_id, o.ident, o.logged
|
||||||
|
FROM ::online AS o
|
||||||
|
ORDER BY o.logged';
|
||||||
}
|
}
|
||||||
$stmt = $this->c->DB->query($sql);
|
$stmt = $this->c->DB->query($query);
|
||||||
|
|
||||||
|
$query = 'UPDATE ::users
|
||||||
|
SET last_visit=?i:last
|
||||||
|
WHERE id=?i:id';
|
||||||
|
|
||||||
while ($cur = $stmt->fetch()) {
|
while ($cur = $stmt->fetch()) {
|
||||||
$this->visits[$cur['user_id']] = $cur['logged'];
|
$this->visits[$cur['user_id']] = $cur['logged'];
|
||||||
|
@ -71,7 +79,12 @@ class Model extends ParentModel
|
||||||
$needClean = true;
|
$needClean = true;
|
||||||
|
|
||||||
if ($cur['user_id'] > 1) {
|
if ($cur['user_id'] > 1) {
|
||||||
$this->c->DB->exec('UPDATE ::users SET last_visit=?i:last WHERE id=?i:id', [':last' => $cur['logged'], ':id' => $cur['user_id']]); //????
|
$vars = [
|
||||||
|
':last' => $cur['logged'],
|
||||||
|
':id' => $cur['user_id'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->c->DB->exec($query, $vars); //????
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -107,7 +120,13 @@ class Model extends ParentModel
|
||||||
|
|
||||||
// удаление просроченных посетителей
|
// удаление просроченных посетителей
|
||||||
if ($needClean) {
|
if ($needClean) {
|
||||||
$this->c->DB->exec('DELETE FROM ::online WHERE logged<?i:visit', [':visit' => $tVisit]);
|
$vars = [
|
||||||
|
':visit' => $tVisit,
|
||||||
|
];
|
||||||
|
$query = 'DELETE FROM ::online
|
||||||
|
WHERE logged<?i:visit';
|
||||||
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
// обновление максимального значение посетителей онлайн
|
// обновление максимального значение посетителей онлайн
|
||||||
|
@ -146,11 +165,24 @@ class Model extends ParentModel
|
||||||
':name' => (string) $this->c->user->isBot,
|
':name' => (string) $this->c->user->isBot,
|
||||||
':ip' => $this->c->user->ip
|
':ip' => $this->c->user->ip
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($this->c->user->logged > 0) {
|
if ($this->c->user->logged > 0) {
|
||||||
$this->c->DB->exec('UPDATE ::online SET logged=?i:logged, o_position=?s:pos, o_name=?s:name WHERE user_id=1 AND ident=?s:ip', $vars);
|
$query = 'UPDATE ::online
|
||||||
|
SET logged=?i:logged, o_position=?s:pos, o_name=?s:name
|
||||||
|
WHERE user_id=1 AND ident=?s:ip';
|
||||||
} else {
|
} else {
|
||||||
$this->c->DB->exec('INSERT INTO ::online (user_id, ident, logged, o_position, o_name) SELECT 1, ?s:ip, ?i:logged, ?s:pos, ?s:name FROM ::groups WHERE NOT EXISTS (SELECT 1 FROM ::online WHERE user_id=1 AND ident=?s:ip) LIMIT 1', $vars);
|
$query = 'INSERT INTO ::online (user_id, ident, logged, o_position, o_name)
|
||||||
|
SELECT 1, ?s:ip, ?i:logged, ?s:pos, ?s:name
|
||||||
|
FROM ::groups
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM ::online
|
||||||
|
WHERE user_id=1 AND ident=?s:ip
|
||||||
|
)
|
||||||
|
LIMIT 1';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
} else {
|
} else {
|
||||||
// пользователь
|
// пользователь
|
||||||
$vars = [
|
$vars = [
|
||||||
|
@ -159,11 +191,24 @@ class Model extends ParentModel
|
||||||
':id' => $this->c->user->id,
|
':id' => $this->c->user->id,
|
||||||
':name' => $this->c->user->username,
|
':name' => $this->c->user->username,
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($this->c->user->logged > 0) {
|
if ($this->c->user->logged > 0) {
|
||||||
$this->c->DB->exec('UPDATE ::online SET logged=?i:logged, o_position=?s:pos WHERE user_id=?i:id', $vars);
|
$query = 'UPDATE ::online
|
||||||
|
SET logged=?i:logged, o_position=?s:pos
|
||||||
|
WHERE user_id=?i:id';
|
||||||
} else {
|
} else {
|
||||||
$this->c->DB->exec('INSERT INTO ::online (user_id, ident, logged, o_position) SELECT ?i:id, ?s:name, ?i:logged, ?s:pos FROM ::groups WHERE NOT EXISTS (SELECT 1 FROM ::online WHERE user_id=?i:id) LIMIT 1', $vars);
|
$query = 'INSERT INTO ::online (user_id, ident, logged, o_position)
|
||||||
|
SELECT ?i:id, ?s:name, ?i:logged, ?s:pos
|
||||||
|
FROM ::groups
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM ::online
|
||||||
|
WHERE user_id=?i:id
|
||||||
|
)
|
||||||
|
LIMIT 1';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,9 +220,21 @@ class Model extends ParentModel
|
||||||
public function delete(User $user): void
|
public function delete(User $user): void
|
||||||
{
|
{
|
||||||
if ($user->isGuest) {
|
if ($user->isGuest) {
|
||||||
$this->c->DB->exec('DELETE FROM ::online WHERE user_id=1 AND ident=?s:ip', [':ip' => $user->ip]);
|
$vars = [
|
||||||
|
':ip' => $user->ip,
|
||||||
|
];
|
||||||
|
$query = 'DELETE
|
||||||
|
FROM ::online
|
||||||
|
WHERE user_id=1 AND ident=?s:ip';
|
||||||
} else {
|
} else {
|
||||||
$this->c->DB->exec('DELETE FROM ::online WHERE user_id=?i:id', [':id' => $user->id]);
|
$vars = [
|
||||||
}
|
':id' => $user->id,
|
||||||
|
];
|
||||||
|
$query = 'DELETE
|
||||||
|
FROM ::online
|
||||||
|
WHERE user_id=?i:id';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,19 +87,34 @@ abstract class Page extends Model
|
||||||
) {
|
) {
|
||||||
$sub = [];
|
$sub = [];
|
||||||
$sub['latest'] = [
|
$sub['latest'] = [
|
||||||
$r->link('SearchAction', ['action' => 'latest_active_topics']),
|
$r->link(
|
||||||
|
'SearchAction',
|
||||||
|
[
|
||||||
|
'action' => 'latest_active_topics',
|
||||||
|
]
|
||||||
|
),
|
||||||
'Latest active topics',
|
'Latest active topics',
|
||||||
'Find latest active topics',
|
'Find latest active topics',
|
||||||
];
|
];
|
||||||
if (! $this->user->isGuest) {
|
if (! $this->user->isGuest) {
|
||||||
$sub['with-your-posts'] = [
|
$sub['with-your-posts'] = [
|
||||||
$r->link('SearchAction', ['action' => 'topics_with_your_posts']),
|
$r->link(
|
||||||
|
'SearchAction',
|
||||||
|
[
|
||||||
|
'action' => 'topics_with_your_posts',
|
||||||
|
]
|
||||||
|
),
|
||||||
'Topics with your posts',
|
'Topics with your posts',
|
||||||
'Find topics with your posts',
|
'Find topics with your posts',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$sub['unanswered'] = [
|
$sub['unanswered'] = [
|
||||||
$r->link('SearchAction', ['action' => 'unanswered_topics']),
|
$r->link(
|
||||||
|
'SearchAction',
|
||||||
|
[
|
||||||
|
'action' => 'unanswered_topics',
|
||||||
|
]
|
||||||
|
),
|
||||||
'Unanswered topics',
|
'Unanswered topics',
|
||||||
'Find unanswered topics',
|
'Find unanswered topics',
|
||||||
];
|
];
|
||||||
|
@ -128,7 +143,15 @@ abstract class Page extends Model
|
||||||
$nav['admin'] = [$r->link('Admin'), 'Admin'];
|
$nav['admin'] = [$r->link('Admin'), 'Admin'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$nav['logout'] = [$r->link('Logout', ['token' => $this->c->Csrf->create('Logout')]), 'Logout'];
|
$nav['logout'] = [
|
||||||
|
$r->link(
|
||||||
|
'Logout',
|
||||||
|
[
|
||||||
|
'token' => $this->c->Csrf->create('Logout'),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
'Logout',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -254,9 +254,15 @@ class Bans extends Admin
|
||||||
protected function formBan(array $data = [], array $args = []): array
|
protected function formBan(array $data = [], array $args = []): array
|
||||||
{
|
{
|
||||||
$form = [
|
$form = [
|
||||||
'action' => $this->c->Router->link($this->formBanPage, $args),
|
'action' => $this->c->Router->link(
|
||||||
|
$this->formBanPage,
|
||||||
|
$args
|
||||||
|
),
|
||||||
'hidden' => [
|
'hidden' => [
|
||||||
'token' => $this->c->Csrf->create($this->formBanPage, $args),
|
'token' => $this->c->Csrf->create(
|
||||||
|
$this->formBanPage,
|
||||||
|
$args
|
||||||
|
),
|
||||||
],
|
],
|
||||||
'sets' => [],
|
'sets' => [],
|
||||||
'btns' => [
|
'btns' => [
|
||||||
|
@ -411,7 +417,15 @@ class Bans extends Admin
|
||||||
|
|
||||||
$this->nameTpl = 'admin/bans_result';
|
$this->nameTpl = 'admin/bans_result';
|
||||||
$this->mainSuffix = '-one-column';
|
$this->mainSuffix = '-one-column';
|
||||||
$this->aCrumbs[] = [$this->c->Router->link('AdminBansResult', ['data' => $args['data']]), __('Results head')];
|
$this->aCrumbs[] = [
|
||||||
|
$this->c->Router->link(
|
||||||
|
'AdminBansResult',
|
||||||
|
[
|
||||||
|
'data' => $args['data'],
|
||||||
|
]
|
||||||
|
),
|
||||||
|
__('Results head'),
|
||||||
|
];
|
||||||
$this->formResult = $this->form($banList, $startNum, $args);
|
$this->formResult = $this->form($banList, $startNum, $args);
|
||||||
$this->pagination = $this->c->Func->paginate($pages, $page, 'AdminBansResult', ['data' => $args['data']]);
|
$this->pagination = $this->c->Func->paginate($pages, $page, 'AdminBansResult', ['data' => $args['data']]);
|
||||||
|
|
||||||
|
@ -496,7 +510,13 @@ class Bans extends Admin
|
||||||
'type' => '1' == $this->c->user->g_view_users && $ban['id_creator'] > 1 ? 'link' : 'str',
|
'type' => '1' == $this->c->user->g_view_users && $ban['id_creator'] > 1 ? 'link' : 'str',
|
||||||
'caption' => __('Results banned by head'),
|
'caption' => __('Results banned by head'),
|
||||||
'value' => $ban['name_creator'],
|
'value' => $ban['name_creator'],
|
||||||
'href' => $this->c->Router->link('User', ['id' => $ban['id_creator'], 'name' => $ban['name_creator'],]), // ????
|
'href' => $this->c->Router->link(
|
||||||
|
'User',
|
||||||
|
[
|
||||||
|
'id' => $ban['id_creator'],
|
||||||
|
'name' => $ban['name_creator'],
|
||||||
|
]
|
||||||
|
), // ????
|
||||||
];
|
];
|
||||||
$fields[] = [
|
$fields[] = [
|
||||||
'type' => 'endwrap',
|
'type' => 'endwrap',
|
||||||
|
@ -515,7 +535,10 @@ class Bans extends Admin
|
||||||
'value' => '✎',
|
'value' => '✎',
|
||||||
'caption' => __('Results actions head'),
|
'caption' => __('Results actions head'),
|
||||||
'title' => __('Edit'),
|
'title' => __('Edit'),
|
||||||
'link' => $this->c->Router->link('AdminBansEdit', $arr),
|
'link' => $this->c->Router->link(
|
||||||
|
'AdminBansEdit',
|
||||||
|
$arr
|
||||||
|
),
|
||||||
];
|
];
|
||||||
$fields["delete-btn{$number}"] = [
|
$fields["delete-btn{$number}"] = [
|
||||||
'class' => ['result', 'btn-delete'],
|
'class' => ['result', 'btn-delete'],
|
||||||
|
@ -523,10 +546,16 @@ class Bans extends Admin
|
||||||
'value' => '❌',
|
'value' => '❌',
|
||||||
'caption' => __('Results actions head'),
|
'caption' => __('Results actions head'),
|
||||||
'title' => __('Delete'),
|
'title' => __('Delete'),
|
||||||
'link' => $this->c->Router->link('AdminBansDelete', [
|
'link' => $this->c->Router->link(
|
||||||
|
'AdminBansDelete',
|
||||||
|
[
|
||||||
'id' => $ban['id'],
|
'id' => $ban['id'],
|
||||||
'token' => $this->c->Csrf->create('AdminBansDelete', $arr),
|
'token' => $this->c->Csrf->create(
|
||||||
]),
|
'AdminBansDelete',
|
||||||
|
$arr
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
];
|
];
|
||||||
$fields[] = [
|
$fields[] = [
|
||||||
'type' => 'endwrap',
|
'type' => 'endwrap',
|
||||||
|
@ -746,7 +775,13 @@ class Bans extends Admin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->aCrumbs[] = [$this->c->Router->link($this->formBanPage, $args), $this->formBanSubHead];
|
$this->aCrumbs[] = [
|
||||||
|
$this->c->Router->link(
|
||||||
|
$this->formBanPage,
|
||||||
|
$args
|
||||||
|
),
|
||||||
|
$this->formBanSubHead,
|
||||||
|
];
|
||||||
$this->formBan = $this->formBan($data, $args);
|
$this->formBan = $this->formBan($data, $args);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -106,7 +106,12 @@ class Categories extends Admin
|
||||||
'type' => 'btn',
|
'type' => 'btn',
|
||||||
'value' => '❌',
|
'value' => '❌',
|
||||||
'caption' => __('Delete'),
|
'caption' => __('Delete'),
|
||||||
'link' => $this->c->Router->link('AdminCategoriesDelete', ['id' => $key]),
|
'link' => $this->c->Router->link(
|
||||||
|
'AdminCategoriesDelete',
|
||||||
|
[
|
||||||
|
'id' => $key,
|
||||||
|
]
|
||||||
|
),
|
||||||
];
|
];
|
||||||
$form['sets']["category{$key}"] = [
|
$form['sets']["category{$key}"] = [
|
||||||
'class' => 'category',
|
'class' => 'category',
|
||||||
|
@ -175,7 +180,15 @@ class Categories extends Admin
|
||||||
|
|
||||||
$this->nameTpl = 'admin/form';
|
$this->nameTpl = 'admin/form';
|
||||||
$this->aIndex = 'categories';
|
$this->aIndex = 'categories';
|
||||||
$this->aCrumbs[] = [$this->c->Router->link('AdminCategoriesDelete', ['id' => $args['id']]), __('Delete category head')];
|
$this->aCrumbs[] = [
|
||||||
|
$this->c->Router->link(
|
||||||
|
'AdminCategoriesDelete',
|
||||||
|
[
|
||||||
|
'id' => $args['id'],
|
||||||
|
]
|
||||||
|
),
|
||||||
|
__('Delete category head'),
|
||||||
|
];
|
||||||
$this->aCrumbs[] = __('"%s"', $category['cat_name']);
|
$this->aCrumbs[] = __('"%s"', $category['cat_name']);
|
||||||
$this->form = $this->formDelete($args, $category);
|
$this->form = $this->formDelete($args, $category);
|
||||||
$this->classForm = 'deletecategory';
|
$this->classForm = 'deletecategory';
|
||||||
|
@ -195,9 +208,15 @@ class Categories extends Admin
|
||||||
protected function formDelete(array $args, array $category): array
|
protected function formDelete(array $args, array $category): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'action' => $this->c->Router->link('AdminCategoriesDelete', $args),
|
'action' => $this->c->Router->link(
|
||||||
|
'AdminCategoriesDelete',
|
||||||
|
$args
|
||||||
|
),
|
||||||
'hidden' => [
|
'hidden' => [
|
||||||
'token' => $this->c->Csrf->create('AdminCategoriesDelete', $args),
|
'token' => $this->c->Csrf->create(
|
||||||
|
'AdminCategoriesDelete',
|
||||||
|
$args
|
||||||
|
),
|
||||||
],
|
],
|
||||||
'sets' => [
|
'sets' => [
|
||||||
'del' => [
|
'del' => [
|
||||||
|
|
|
@ -182,7 +182,12 @@ class Forums extends Admin
|
||||||
'type' => 'btn',
|
'type' => 'btn',
|
||||||
'value' => $forum->forum_name,
|
'value' => $forum->forum_name,
|
||||||
'caption' => __('Forum label'),
|
'caption' => __('Forum label'),
|
||||||
'link' => $this->c->Router->link('AdminForumsEdit', ['id' => $forum->id]),
|
'link' => $this->c->Router->link(
|
||||||
|
'AdminForumsEdit',
|
||||||
|
[
|
||||||
|
'id' => $forum->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
];
|
];
|
||||||
$fields["form[{$forum->id}][disp_position]"] = [
|
$fields["form[{$forum->id}][disp_position]"] = [
|
||||||
'class' => ['position', 'forum'],
|
'class' => ['position', 'forum'],
|
||||||
|
@ -198,7 +203,14 @@ class Forums extends Admin
|
||||||
'type' => 'btn',
|
'type' => 'btn',
|
||||||
'value' => '❌',
|
'value' => '❌',
|
||||||
'caption' => __('Delete'),
|
'caption' => __('Delete'),
|
||||||
'link' => $disabled ? '#' : $this->c->Router->link('AdminForumsDelete', ['id' => $forum->id]),
|
'link' => $disabled
|
||||||
|
? '#'
|
||||||
|
: $this->c->Router->link(
|
||||||
|
'AdminForumsDelete',
|
||||||
|
[
|
||||||
|
'id' => $forum->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
'disabled' => $disabled,
|
'disabled' => $disabled,
|
||||||
];
|
];
|
||||||
$form['sets']["forum{$forum->id}"] = [
|
$form['sets']["forum{$forum->id}"] = [
|
||||||
|
@ -259,7 +271,15 @@ class Forums extends Admin
|
||||||
|
|
||||||
$this->nameTpl = 'admin/form';
|
$this->nameTpl = 'admin/form';
|
||||||
$this->aIndex = 'forums';
|
$this->aIndex = 'forums';
|
||||||
$this->aCrumbs[] = [$this->c->Router->link('AdminForumsDelete', ['id' => $forum->id]), __('Delete forum head')];
|
$this->aCrumbs[] = [
|
||||||
|
$this->c->Router->link(
|
||||||
|
'AdminForumsDelete',
|
||||||
|
[
|
||||||
|
'id' => $forum->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
__('Delete forum head'),
|
||||||
|
];
|
||||||
$this->aCrumbs[] = __('"%s"', $forum->forum_name);
|
$this->aCrumbs[] = __('"%s"', $forum->forum_name);
|
||||||
$this->form = $this->formDelete($args, $forum);
|
$this->form = $this->formDelete($args, $forum);
|
||||||
$this->classForm = 'deleteforum';
|
$this->classForm = 'deleteforum';
|
||||||
|
@ -279,9 +299,15 @@ class Forums extends Admin
|
||||||
protected function formDelete(array $args, Forum $forum): array
|
protected function formDelete(array $args, Forum $forum): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'action' => $this->c->Router->link('AdminForumsDelete', $args),
|
'action' => $this->c->Router->link(
|
||||||
|
'AdminForumsDelete',
|
||||||
|
$args
|
||||||
|
),
|
||||||
'hidden' => [
|
'hidden' => [
|
||||||
'token' => $this->c->Csrf->create('AdminForumsDelete', $args),
|
'token' => $this->c->Csrf->create(
|
||||||
|
'AdminForumsDelete',
|
||||||
|
$args
|
||||||
|
),
|
||||||
],
|
],
|
||||||
'sets' => [
|
'sets' => [
|
||||||
'confirm' => [
|
'confirm' => [
|
||||||
|
@ -337,13 +363,19 @@ class Forums extends Admin
|
||||||
if (empty($args['id'])) {
|
if (empty($args['id'])) {
|
||||||
$forum = $this->c->forums->create();
|
$forum = $this->c->forums->create();
|
||||||
$marker = 'AdminForumsNew';
|
$marker = 'AdminForumsNew';
|
||||||
$this->aCrumbs[] = [$this->c->Router->link($marker), __('Add forum head')];
|
$this->aCrumbs[] = [
|
||||||
|
$this->c->Router->link($marker),
|
||||||
|
__('Add forum head'),
|
||||||
|
];
|
||||||
$this->titleForm = __('Add forum head');
|
$this->titleForm = __('Add forum head');
|
||||||
$this->classForm = 'createforum';
|
$this->classForm = 'createforum';
|
||||||
} else {
|
} else {
|
||||||
$forum = $this->c->forums->loadTree((int) $args['id']); //?????
|
$forum = $this->c->forums->loadTree((int) $args['id']); //?????
|
||||||
$marker = 'AdminForumsEdit';
|
$marker = 'AdminForumsEdit';
|
||||||
$this->aCrumbs[] = [$this->c->Router->link($marker, $args), __('Edit forum head')];
|
$this->aCrumbs[] = [
|
||||||
|
$this->c->Router->link($marker, $args),
|
||||||
|
__('Edit forum head'),
|
||||||
|
];
|
||||||
$this->aCrumbs[] = __('"%s"', $forum->forum_name);
|
$this->aCrumbs[] = __('"%s"', $forum->forum_name);
|
||||||
$this->titleForm = __('Edit forum head');
|
$this->titleForm = __('Edit forum head');
|
||||||
$this->classForm = 'editforum';
|
$this->classForm = 'editforum';
|
||||||
|
@ -433,9 +465,15 @@ class Forums extends Admin
|
||||||
protected function formEdit(array $args, Forum $forum, string $marker): array
|
protected function formEdit(array $args, Forum $forum, string $marker): array
|
||||||
{
|
{
|
||||||
$form = [
|
$form = [
|
||||||
'action' => $this->c->Router->link($marker, $args),
|
'action' => $this->c->Router->link(
|
||||||
|
$marker,
|
||||||
|
$args
|
||||||
|
),
|
||||||
'hidden' => [
|
'hidden' => [
|
||||||
'token' => $this->c->Csrf->create($marker, $args),
|
'token' => $this->c->Csrf->create(
|
||||||
|
$marker,
|
||||||
|
$args
|
||||||
|
),
|
||||||
],
|
],
|
||||||
'sets' => [],
|
'sets' => [],
|
||||||
'btns' => [],
|
'btns' => [],
|
||||||
|
|
|
@ -210,7 +210,13 @@ class Groups extends Admin
|
||||||
$marker = 'AdminGroupsEdit';
|
$marker = 'AdminGroupsEdit';
|
||||||
$vars = ['id' => $group->g_id];
|
$vars = ['id' => $group->g_id];
|
||||||
$notNext .= ',' . $group->g_id;
|
$notNext .= ',' . $group->g_id;
|
||||||
$this->aCrumbs[] = [$this->c->Router->link($marker, $vars), __('Edit group')];
|
$this->aCrumbs[] = [
|
||||||
|
$this->c->Router->link(
|
||||||
|
$marker,
|
||||||
|
$vars
|
||||||
|
),
|
||||||
|
__('Edit group'),
|
||||||
|
];
|
||||||
$this->aCrumbs[] = __('"%s"', $group->g_title);
|
$this->aCrumbs[] = __('"%s"', $group->g_title);
|
||||||
$this->titleForm = __('Edit group');
|
$this->titleForm = __('Edit group');
|
||||||
$this->classForm = 'editgroup';
|
$this->classForm = 'editgroup';
|
||||||
|
@ -366,9 +372,15 @@ class Groups extends Admin
|
||||||
protected function formEdit(array $args, Group $group, string $marker): array
|
protected function formEdit(array $args, Group $group, string $marker): array
|
||||||
{
|
{
|
||||||
$form = [
|
$form = [
|
||||||
'action' => $this->c->Router->link($marker, $args),
|
'action' => $this->c->Router->link(
|
||||||
|
$marker,
|
||||||
|
$args
|
||||||
|
),
|
||||||
'hidden' => [
|
'hidden' => [
|
||||||
'token' => $this->c->Csrf->create($marker, $args),
|
'token' => $this->c->Csrf->create(
|
||||||
|
$marker,
|
||||||
|
$args
|
||||||
|
),
|
||||||
],
|
],
|
||||||
'sets' => [],
|
'sets' => [],
|
||||||
'btns' => [
|
'btns' => [
|
||||||
|
@ -717,7 +729,13 @@ class Groups extends Admin
|
||||||
|
|
||||||
|
|
||||||
$this->nameTpl = 'admin/form';
|
$this->nameTpl = 'admin/form';
|
||||||
$this->aCrumbs[] = [$this->c->Router->link('AdminGroupsDelete', $args), __('Group delete')];
|
$this->aCrumbs[] = [
|
||||||
|
$this->c->Router->link(
|
||||||
|
'AdminGroupsDelete',
|
||||||
|
$args
|
||||||
|
),
|
||||||
|
__('Group delete'),
|
||||||
|
];
|
||||||
$this->aCrumbs[] = __('"%s"', $group->g_title);
|
$this->aCrumbs[] = __('"%s"', $group->g_title);
|
||||||
$this->form = $this->formDelete($args, $group, $count, $groups);
|
$this->form = $this->formDelete($args, $group, $count, $groups);
|
||||||
$this->titleForm = __('Group delete');
|
$this->titleForm = __('Group delete');
|
||||||
|
@ -739,9 +757,15 @@ class Groups extends Admin
|
||||||
protected function formDelete(array $args, Group $group, int $count, array $groups): array
|
protected function formDelete(array $args, Group $group, int $count, array $groups): array
|
||||||
{
|
{
|
||||||
$form = [
|
$form = [
|
||||||
'action' => $this->c->Router->link('AdminGroupsDelete', $args),
|
'action' => $this->c->Router->link(
|
||||||
|
'AdminGroupsDelete',
|
||||||
|
$args
|
||||||
|
),
|
||||||
'hidden' => [
|
'hidden' => [
|
||||||
'token' => $this->c->Csrf->create('AdminGroupsDelete', $args),
|
'token' => $this->c->Csrf->create(
|
||||||
|
'AdminGroupsDelete',
|
||||||
|
$args
|
||||||
|
),
|
||||||
],
|
],
|
||||||
'sets' => [],
|
'sets' => [],
|
||||||
'btns' => [
|
'btns' => [
|
||||||
|
|
|
@ -33,7 +33,12 @@ class Host extends Admin
|
||||||
$this->back = true;
|
$this->back = true;
|
||||||
$this->fIswev = [
|
$this->fIswev = [
|
||||||
'i',
|
'i',
|
||||||
__('Host info', $ip, $host, $this->c->Router->link('AdminUsersResult', ['data' => "ip:{$ip}"])),
|
__('Host info', $ip, $host, $this->c->Router->link(
|
||||||
|
'AdminUsersResult',
|
||||||
|
[
|
||||||
|
'data' => "ip:{$ip}",
|
||||||
|
]
|
||||||
|
)),
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -150,7 +150,13 @@ class Action extends Users
|
||||||
$this->nameTpl = 'admin/form';
|
$this->nameTpl = 'admin/form';
|
||||||
$this->classForm = 'delete-users';
|
$this->classForm = 'delete-users';
|
||||||
$this->titleForm = __('Deleting users');
|
$this->titleForm = __('Deleting users');
|
||||||
$this->aCrumbs[] = [$this->c->Router->link('AdminUsersAction', $args), __('Deleting users')];
|
$this->aCrumbs[] = [
|
||||||
|
$this->c->Router->link(
|
||||||
|
'AdminUsersAction',
|
||||||
|
$args
|
||||||
|
),
|
||||||
|
__('Deleting users'),
|
||||||
|
];
|
||||||
$this->form = $this->formDelete($args);
|
$this->form = $this->formDelete($args);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -168,9 +174,15 @@ class Action extends Users
|
||||||
$yn = [1 => __('Yes'), 0 => __('No')];
|
$yn = [1 => __('Yes'), 0 => __('No')];
|
||||||
$names = \implode(', ', $this->nameList($this->userList));
|
$names = \implode(', ', $this->nameList($this->userList));
|
||||||
$form = [
|
$form = [
|
||||||
'action' => $this->c->Router->link('AdminUsersAction', $args),
|
'action' => $this->c->Router->link(
|
||||||
|
'AdminUsersAction',
|
||||||
|
$args
|
||||||
|
),
|
||||||
'hidden' => [
|
'hidden' => [
|
||||||
'token' => $this->c->Csrf->create('AdminUsersAction', $args),
|
'token' => $this->c->Csrf->create(
|
||||||
|
'AdminUsersAction',
|
||||||
|
$args
|
||||||
|
),
|
||||||
],
|
],
|
||||||
'sets' => [
|
'sets' => [
|
||||||
'options' => [
|
'options' => [
|
||||||
|
@ -254,7 +266,12 @@ class Action extends Users
|
||||||
|
|
||||||
if ($profile) {
|
if ($profile) {
|
||||||
$user = $this->c->users->load((int) $args['ids']);
|
$user = $this->c->users->load((int) $args['ids']);
|
||||||
$link = $this->c->Router->link('EditUserProfile', ['id' => $user->id]);
|
$link = $this->c->Router->link(
|
||||||
|
'EditUserProfile',
|
||||||
|
[
|
||||||
|
'id' => $user->id,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
$user->isAdmin
|
$user->isAdmin
|
||||||
|
@ -311,7 +328,13 @@ class Action extends Users
|
||||||
$this->nameTpl = 'admin/form';
|
$this->nameTpl = 'admin/form';
|
||||||
$this->classForm = 'change-group';
|
$this->classForm = 'change-group';
|
||||||
$this->titleForm = __('Change user group');
|
$this->titleForm = __('Change user group');
|
||||||
$this->aCrumbs[] = [$this->c->Router->link('AdminUsersAction', $args), __('Change user group')];
|
$this->aCrumbs[] = [
|
||||||
|
$this->c->Router->link(
|
||||||
|
'AdminUsersAction',
|
||||||
|
$args
|
||||||
|
),
|
||||||
|
__('Change user group'),
|
||||||
|
];
|
||||||
$this->form = $this->formChange($args, $profile, $link, 'absent' !== $rulePass);
|
$this->form = $this->formChange($args, $profile, $link, 'absent' !== $rulePass);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -349,9 +372,15 @@ class Action extends Users
|
||||||
$yn = [1 => __('Yes'), 0 => __('No')];
|
$yn = [1 => __('Yes'), 0 => __('No')];
|
||||||
$names = \implode(', ', $this->nameList($this->userList));
|
$names = \implode(', ', $this->nameList($this->userList));
|
||||||
$form = [
|
$form = [
|
||||||
'action' => $this->c->Router->link('AdminUsersAction', $args),
|
'action' => $this->c->Router->link(
|
||||||
|
'AdminUsersAction',
|
||||||
|
$args
|
||||||
|
),
|
||||||
'hidden' => [
|
'hidden' => [
|
||||||
'token' => $this->c->Csrf->create('AdminUsersAction', $args),
|
'token' => $this->c->Csrf->create(
|
||||||
|
'AdminUsersAction',
|
||||||
|
$args
|
||||||
|
),
|
||||||
],
|
],
|
||||||
'sets' => [
|
'sets' => [
|
||||||
'options' => [
|
'options' => [
|
||||||
|
|
|
@ -133,7 +133,15 @@ class Result extends Users
|
||||||
|
|
||||||
$this->nameTpl = 'admin/users_result';
|
$this->nameTpl = 'admin/users_result';
|
||||||
$this->mainSuffix = '-one-column';
|
$this->mainSuffix = '-one-column';
|
||||||
$this->aCrumbs[] = [$this->c->Router->link('AdminUsersResult', ['data' => $args['data']]), $crName];
|
$this->aCrumbs[] = [
|
||||||
|
$this->c->Router->link(
|
||||||
|
'AdminUsersResult',
|
||||||
|
[
|
||||||
|
'data' => $args['data'],
|
||||||
|
]
|
||||||
|
),
|
||||||
|
$crName,
|
||||||
|
];
|
||||||
$this->formResult = $this->form($userList, $startNum, $args);
|
$this->formResult = $this->form($userList, $startNum, $args);
|
||||||
$this->pagination = $this->c->Func->paginate($pages, $page, 'AdminUsersResult', ['data' => $args['data']]);
|
$this->pagination = $this->c->Func->paginate($pages, $page, 'AdminUsersResult', ['data' => $args['data']]);
|
||||||
|
|
||||||
|
@ -226,9 +234,15 @@ class Result extends Users
|
||||||
protected function form(array $users, int $number, array $args): array
|
protected function form(array $users, int $number, array $args): array
|
||||||
{
|
{
|
||||||
$form = [
|
$form = [
|
||||||
'action' => $this->c->Router->link('AdminUsersResult', $args),
|
'action' => $this->c->Router->link(
|
||||||
|
'AdminUsersResult',
|
||||||
|
$args
|
||||||
|
),
|
||||||
'hidden' => [
|
'hidden' => [
|
||||||
'token' => $this->c->Csrf->create('AdminUsersResult', $args),
|
'token' => $this->c->Csrf->create(
|
||||||
|
'AdminUsersResult',
|
||||||
|
$args
|
||||||
|
),
|
||||||
],
|
],
|
||||||
'sets' => [],
|
'sets' => [],
|
||||||
'btns' => [],
|
'btns' => [],
|
||||||
|
@ -300,7 +314,13 @@ class Result extends Users
|
||||||
'type' => $user->num_posts ? 'link' : 'str',
|
'type' => $user->num_posts ? 'link' : 'str',
|
||||||
'caption' => __('Results posts head'),
|
'caption' => __('Results posts head'),
|
||||||
'value' => $user->num_posts ? \ForkBB\num($user->num_posts) : null,
|
'value' => $user->num_posts ? \ForkBB\num($user->num_posts) : null,
|
||||||
'href' => $this->c->Router->link('SearchAction', ['action' => 'posts', 'uid' => $user->id]),
|
'href' => $this->c->Router->link(
|
||||||
|
'SearchAction',
|
||||||
|
[
|
||||||
|
'action' => 'posts',
|
||||||
|
'uid' => $user->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
'title' => __('Results show posts link'),
|
'title' => __('Results show posts link'),
|
||||||
];
|
];
|
||||||
$fields["l{$number}-note"] = [
|
$fields["l{$number}-note"] = [
|
||||||
|
@ -316,7 +336,12 @@ class Result extends Users
|
||||||
'type' => $user->isGuest || ! $user->num_posts ? 'str' : 'link',
|
'type' => $user->isGuest || ! $user->num_posts ? 'str' : 'link',
|
||||||
'caption' => __('Results action head'),
|
'caption' => __('Results action head'),
|
||||||
'value' => $user->isGuest ? null : __('Results view IP link'),
|
'value' => $user->isGuest ? null : __('Results view IP link'),
|
||||||
'href' => $this->c->Router->link('AdminUserStat', ['id' => $user->id]),
|
'href' => $this->c->Router->link(
|
||||||
|
'AdminUserStat',
|
||||||
|
[
|
||||||
|
'id' => $user->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,15 @@ class Stat extends Users
|
||||||
|
|
||||||
$this->nameTpl = 'admin/users_result';
|
$this->nameTpl = 'admin/users_result';
|
||||||
$this->mainSuffix = '-one-column';
|
$this->mainSuffix = '-one-column';
|
||||||
$this->aCrumbs[] = [$this->c->Router->link('AdminUserStat', ['id' => $args['id']]), $user->username];
|
$this->aCrumbs[] = [
|
||||||
|
$this->c->Router->link(
|
||||||
|
'AdminUserStat',
|
||||||
|
[
|
||||||
|
'id' => $args['id'],
|
||||||
|
]
|
||||||
|
),
|
||||||
|
$user->username,
|
||||||
|
];
|
||||||
$this->formResult = $this->form($stat, $startNum);
|
$this->formResult = $this->form($stat, $startNum);
|
||||||
$this->pagination = $this->c->Func->paginate($pages, $page, 'AdminUserStat', ['id' => $args['id']]);
|
$this->pagination = $this->c->Func->paginate($pages, $page, 'AdminUserStat', ['id' => $args['id']]);
|
||||||
|
|
||||||
|
@ -75,7 +83,14 @@ class Stat extends Users
|
||||||
'type' => $flag ? 'link' : 'str',
|
'type' => $flag ? 'link' : 'str',
|
||||||
'caption' => __('Results IP address head'),
|
'caption' => __('Results IP address head'),
|
||||||
'value' => $flag ? $ip : null,
|
'value' => $flag ? $ip : null,
|
||||||
'href' => $flag ? $this->c->Router->link('AdminHost', ['ip' => $ip]) : null,
|
'href' => $flag
|
||||||
|
? $this->c->Router->link(
|
||||||
|
'AdminHost',
|
||||||
|
[
|
||||||
|
'ip' => $ip,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
: null,
|
||||||
];
|
];
|
||||||
$fields["l{$number}-last-used"] = [
|
$fields["l{$number}-last-used"] = [
|
||||||
'class' => ['result', 'last-used'],
|
'class' => ['result', 'last-used'],
|
||||||
|
@ -94,7 +109,14 @@ class Stat extends Users
|
||||||
'type' => $flag ? 'link' : 'str',
|
'type' => $flag ? 'link' : 'str',
|
||||||
'caption' => __('Results action head'),
|
'caption' => __('Results action head'),
|
||||||
'value' => $flag ? __('Results find more link') : null,
|
'value' => $flag ? __('Results find more link') : null,
|
||||||
'href' => $flag ? $this->c->Router->link('AdminUsersResult', ['data' => $this->encodeData($ip)]) : null,
|
'href' => $flag
|
||||||
|
? $this->c->Router->link(
|
||||||
|
'AdminUsersResult',
|
||||||
|
[
|
||||||
|
'data' => $this->encodeData($ip),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
: null,
|
||||||
];
|
];
|
||||||
|
|
||||||
$form['sets']["l{$number}"] = [
|
$form['sets']["l{$number}"] = [
|
||||||
|
|
|
@ -215,7 +215,14 @@ class Auth extends Page
|
||||||
if ($v->validation($_POST)) {
|
if ($v->validation($_POST)) {
|
||||||
$key = $this->c->Secury->randomPass(32);
|
$key = $this->c->Secury->randomPass(32);
|
||||||
$hash = $this->c->Secury->hash($tmpUser->id . $key);
|
$hash = $this->c->Secury->hash($tmpUser->id . $key);
|
||||||
$link = $this->c->Router->link('ChangePassword', ['id' => $tmpUser->id, 'key' => $key, 'hash' => $hash]);
|
$link = $this->c->Router->link(
|
||||||
|
'ChangePassword',
|
||||||
|
[
|
||||||
|
'id' => $tmpUser->id,
|
||||||
|
'key' => $key,
|
||||||
|
'hash' => $hash,
|
||||||
|
]
|
||||||
|
);
|
||||||
$tplData = [
|
$tplData = [
|
||||||
'fRootLink' => $this->c->Router->link('Index'),
|
'fRootLink' => $this->c->Router->link('Index'),
|
||||||
'fMailer' => __('Mailer', $this->c->config->o_board_title),
|
'fMailer' => __('Mailer', $this->c->config->o_board_title),
|
||||||
|
@ -385,9 +392,15 @@ class Auth extends Page
|
||||||
protected function formChange(array $args): array
|
protected function formChange(array $args): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'action' => $this->c->Router->link('ChangePassword', $args),
|
'action' => $this->c->Router->link(
|
||||||
|
'ChangePassword',
|
||||||
|
$args
|
||||||
|
),
|
||||||
'hidden' => [
|
'hidden' => [
|
||||||
'token' => $this->c->Csrf->create('ChangePassword', $args),
|
'token' => $this->c->Csrf->create(
|
||||||
|
'ChangePassword',
|
||||||
|
$args
|
||||||
|
),
|
||||||
],
|
],
|
||||||
'sets' => [
|
'sets' => [
|
||||||
'forget' => [
|
'forget' => [
|
||||||
|
|
|
@ -86,9 +86,19 @@ class Delete extends Page
|
||||||
protected function formDelete(array $args, Post $post, bool $deleteTopic): array
|
protected function formDelete(array $args, Post $post, bool $deleteTopic): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'action' => $this->c->Router->link('DeletePost', ['id' => $post->id]),
|
'action' => $this->c->Router->link(
|
||||||
|
'DeletePost',
|
||||||
|
[
|
||||||
|
'id' => $post->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
'hidden' => [
|
'hidden' => [
|
||||||
'token' => $this->c->Csrf->create('DeletePost', ['id' => $post->id]),
|
'token' => $this->c->Csrf->create(
|
||||||
|
'DeletePost',
|
||||||
|
[
|
||||||
|
'id' => $post->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
],
|
],
|
||||||
'sets' => [
|
'sets' => [
|
||||||
'info' => [
|
'info' => [
|
||||||
|
@ -124,7 +134,10 @@ class Delete extends Page
|
||||||
'cancel' => [
|
'cancel' => [
|
||||||
'type' => 'btn',
|
'type' => 'btn',
|
||||||
'value' => __('Cancel'),
|
'value' => __('Cancel'),
|
||||||
'link' => $this->c->Router->link('ViewPost', $args),
|
'link' => $this->c->Router->link(
|
||||||
|
'ViewPost',
|
||||||
|
$args
|
||||||
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
|
@ -38,7 +38,14 @@ class Forum extends Page
|
||||||
$this->fIndex = 'index';
|
$this->fIndex = 'index';
|
||||||
$this->nameTpl = 'forum';
|
$this->nameTpl = 'forum';
|
||||||
$this->onlinePos = 'forum-' . $args['id'];
|
$this->onlinePos = 'forum-' . $args['id'];
|
||||||
$this->canonical = $this->c->Router->link('Forum', ['id' => $args['id'], 'name' => $forum->forum_name, 'page' => $forum->page]);
|
$this->canonical = $this->c->Router->link(
|
||||||
|
'Forum',
|
||||||
|
[
|
||||||
|
'id' => $args['id'],
|
||||||
|
'name' => $forum->forum_name,
|
||||||
|
'page' => $forum->page,
|
||||||
|
]
|
||||||
|
);
|
||||||
$this->model = $forum;
|
$this->model = $forum;
|
||||||
$this->topics = $forum->pageData();
|
$this->topics = $forum->pageData();
|
||||||
$this->crumbs = $this->crumbs($forum);
|
$this->crumbs = $this->crumbs($forum);
|
||||||
|
|
|
@ -19,10 +19,13 @@ class Index extends Page
|
||||||
|
|
||||||
// крайний пользователь // ???? может в stats переместить?
|
// крайний пользователь // ???? может в stats переместить?
|
||||||
$this->c->stats->userLast = $this->user->viewUsers
|
$this->c->stats->userLast = $this->user->viewUsers
|
||||||
? [ $this->c->Router->link('User', [
|
? [
|
||||||
|
$this->c->Router->link(
|
||||||
|
'User', [
|
||||||
'id' => $this->c->stats->userLast['id'],
|
'id' => $this->c->stats->userLast['id'],
|
||||||
'name' => $this->c->stats->userLast['username'],
|
'name' => $this->c->stats->userLast['username'],
|
||||||
]),
|
]
|
||||||
|
),
|
||||||
$this->c->stats->userLast['username'],
|
$this->c->stats->userLast['username'],
|
||||||
]
|
]
|
||||||
: $this->c->stats->userLast['username'];
|
: $this->c->stats->userLast['username'];
|
||||||
|
@ -49,10 +52,18 @@ class Index extends Page
|
||||||
$this->categoryes = $ctgs;
|
$this->categoryes = $ctgs;
|
||||||
|
|
||||||
if (! $this->user->isGuest) {
|
if (! $this->user->isGuest) {
|
||||||
$this->linkMarkRead = $this->c->Router->link('MarkRead', [
|
$this->linkMarkRead = $this->c->Router->link(
|
||||||
|
'MarkRead',
|
||||||
|
[
|
||||||
'id' => 0,
|
'id' => 0,
|
||||||
'token' => $this->c->Csrf->create('MarkRead', ['id' => 0]),
|
'token' => $this->c->Csrf->create(
|
||||||
]);
|
'MarkRead',
|
||||||
|
[
|
||||||
|
'id' => 0,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -247,11 +247,14 @@ class Moderate extends Page
|
||||||
$this->processAsPosts = true;
|
$this->processAsPosts = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->backLink = $this->c->Router->link('Topic', [
|
$this->backLink = $this->c->Router->link(
|
||||||
|
'Topic',
|
||||||
|
[
|
||||||
'id' => $this->curTopic->id,
|
'id' => $this->curTopic->id,
|
||||||
'name' => $this->curTopic->subject,
|
'name' => $this->curTopic->subject,
|
||||||
'page' => $page
|
'page' => $page,
|
||||||
]);
|
]
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$objects = $this->c->topics->loadByIds($v->ids, false);
|
$objects = $this->c->topics->loadByIds($v->ids, false);
|
||||||
foreach ($objects as $topic) {
|
foreach ($objects as $topic) {
|
||||||
|
@ -263,11 +266,14 @@ class Moderate extends Page
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->backLink = $this->c->Router->link('Forum', [
|
$this->backLink = $this->c->Router->link(
|
||||||
|
'Forum',
|
||||||
|
[
|
||||||
'id' => $this->curForum->id,
|
'id' => $this->curForum->id,
|
||||||
'name' => $this->curForum->forum_name,
|
'name' => $this->curForum->forum_name,
|
||||||
'page' => $page
|
'page' => $page,
|
||||||
]);
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->{'action' . \ucfirst($v->action)}($objects, $v);
|
return $this->{'action' . \ucfirst($v->action)}($objects, $v);
|
||||||
|
|
|
@ -58,7 +58,12 @@ class Post extends Page
|
||||||
|
|
||||||
$this->nameTpl = 'post';
|
$this->nameTpl = 'post';
|
||||||
$this->onlinePos = 'forum-' . $forum->id;
|
$this->onlinePos = 'forum-' . $forum->id;
|
||||||
$this->canonical = $this->c->Router->link('NewTopic', ['id' => $forum->id]);
|
$this->canonical = $this->c->Router->link(
|
||||||
|
'NewTopic',
|
||||||
|
[
|
||||||
|
'id' => $forum->id,
|
||||||
|
]
|
||||||
|
);
|
||||||
$this->robots = 'noindex';
|
$this->robots = 'noindex';
|
||||||
$this->crumbs = $this->crumbs(__('Post new topic'), $forum);
|
$this->crumbs = $this->crumbs(__('Post new topic'), $forum);
|
||||||
$this->formTitle = __('Post new topic');
|
$this->formTitle = __('Post new topic');
|
||||||
|
@ -123,7 +128,12 @@ class Post extends Page
|
||||||
|
|
||||||
$this->nameTpl = 'post';
|
$this->nameTpl = 'post';
|
||||||
$this->onlinePos = 'topic-' . $topic->id;
|
$this->onlinePos = 'topic-' . $topic->id;
|
||||||
$this->canonical = $this->c->Router->link('NewReply', ['id' => $topic->id]);
|
$this->canonical = $this->c->Router->link(
|
||||||
|
'NewReply',
|
||||||
|
[
|
||||||
|
'id' => $topic->id,
|
||||||
|
]
|
||||||
|
);
|
||||||
$this->robots = 'noindex';
|
$this->robots = 'noindex';
|
||||||
$this->crumbs = $this->crumbs(__('Post a reply'), $topic);
|
$this->crumbs = $this->crumbs(__('Post a reply'), $topic);
|
||||||
$this->formTitle = __('Post a reply');
|
$this->formTitle = __('Post a reply');
|
||||||
|
|
|
@ -26,9 +26,15 @@ trait PostFormTrait
|
||||||
|
|
||||||
$autofocus = $quickReply ? null : true;
|
$autofocus = $quickReply ? null : true;
|
||||||
$form = [
|
$form = [
|
||||||
'action' => $this->c->Router->link($marker, $args),
|
'action' => $this->c->Router->link(
|
||||||
|
$marker,
|
||||||
|
$args
|
||||||
|
),
|
||||||
'hidden' => [
|
'hidden' => [
|
||||||
'token' => $this->c->Csrf->create($marker, $args),
|
'token' => $this->c->Csrf->create(
|
||||||
|
$marker,
|
||||||
|
$args
|
||||||
|
),
|
||||||
],
|
],
|
||||||
'sets' => [],
|
'sets' => [],
|
||||||
'btns' => [
|
'btns' => [
|
||||||
|
|
|
@ -99,29 +99,44 @@ abstract class Profile extends Page
|
||||||
if (isset($this->c->bans->userList[\mb_strtolower($this->curUser->username)])) { //????
|
if (isset($this->c->bans->userList[\mb_strtolower($this->curUser->username)])) { //????
|
||||||
$id = $this->c->bans->userList[\mb_strtolower($this->curUser->username)];
|
$id = $this->c->bans->userList[\mb_strtolower($this->curUser->username)];
|
||||||
$btns['unban-user'] = [
|
$btns['unban-user'] = [
|
||||||
$this->c->Router->link('AdminBansDelete', [
|
$this->c->Router->link(
|
||||||
|
'AdminBansDelete',
|
||||||
|
[
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'uid' => $this->curUser->id,
|
'uid' => $this->curUser->id,
|
||||||
'token' => $this->c->Csrf->create('AdminBansDelete', [
|
'token' => $this->c->Csrf->create(
|
||||||
|
'AdminBansDelete',
|
||||||
|
[
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'uid' => $this->curUser->id,
|
'uid' => $this->curUser->id,
|
||||||
]),
|
]
|
||||||
]),
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
__('Unban user'),
|
__('Unban user'),
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$btns['ban-user'] = [
|
$btns['ban-user'] = [
|
||||||
$this->c->Router->link('AdminBansNew', [
|
$this->c->Router->link(
|
||||||
|
'AdminBansNew',
|
||||||
|
[
|
||||||
'ids' => $this->curUser->id,
|
'ids' => $this->curUser->id,
|
||||||
'uid' => $this->curUser->id,
|
'uid' => $this->curUser->id,
|
||||||
]),
|
]
|
||||||
|
),
|
||||||
__('Ban user'),
|
__('Ban user'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($this->rules->deleteUser) {
|
if ($this->rules->deleteUser) {
|
||||||
$btns['delete-user'] = [
|
$btns['delete-user'] = [
|
||||||
$this->c->Router->link('AdminUsersAction', ['action' => 'delete', 'ids' => $this->curUser->id]), // ????
|
$this->c->Router->link(
|
||||||
|
'AdminUsersAction',
|
||||||
|
[
|
||||||
|
'action' => 'delete',
|
||||||
|
'ids' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
), // ????
|
||||||
__('Delete user'),
|
__('Delete user'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -130,7 +145,12 @@ abstract class Profile extends Page
|
||||||
&& $this->rules->editProfile
|
&& $this->rules->editProfile
|
||||||
) {
|
) {
|
||||||
$btns['edit-profile'] = [
|
$btns['edit-profile'] = [
|
||||||
$this->c->Router->link('EditUserProfile', ['id' => $this->curUser->id]),
|
$this->c->Router->link(
|
||||||
|
'EditUserProfile',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
__('Edit '),
|
__('Edit '),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -145,7 +165,12 @@ abstract class Profile extends Page
|
||||||
&& $this->rules->editConfig
|
&& $this->rules->editConfig
|
||||||
) {
|
) {
|
||||||
$btns['edit-settings'] = [
|
$btns['edit-settings'] = [
|
||||||
$this->c->Router->link('EditUserBoardConfig', ['id' => $this->curUser->id]),
|
$this->c->Router->link(
|
||||||
|
'EditUserBoardConfig',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
__('Configure '),
|
__('Configure '),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -159,13 +184,19 @@ abstract class Profile extends Page
|
||||||
*/
|
*/
|
||||||
protected function linkChangeGroup(): string
|
protected function linkChangeGroup(): string
|
||||||
{
|
{
|
||||||
return $this->c->Router->link('AdminUsersAction', [
|
return $this->c->Router->link(
|
||||||
|
'AdminUsersAction',
|
||||||
|
[
|
||||||
'action' => 'change_group',
|
'action' => 'change_group',
|
||||||
'ids' => $this->curUser->id,
|
'ids' => $this->curUser->id,
|
||||||
'token' => $this->c->Csrf->create('AdminUsersAction', [
|
'token' => $this->c->Csrf->create(
|
||||||
|
'AdminUsersAction',
|
||||||
|
[
|
||||||
'action' => 'change_group',
|
'action' => 'change_group',
|
||||||
'ids' => $this->curUser->id,
|
'ids' => $this->curUser->id,
|
||||||
]),
|
]
|
||||||
]);
|
),
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,17 @@ class Config extends Profile
|
||||||
$this->fIswev = $v->getErrors();
|
$this->fIswev = $v->getErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->crumbs = $this->crumbs([$this->c->Router->link('EditUserBoardConfig', ['id' => $this->curUser->id]), __('Board configuration')]);
|
$this->crumbs = $this->crumbs(
|
||||||
|
[
|
||||||
|
$this->c->Router->link(
|
||||||
|
'EditUserBoardConfig',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
__('Board configuration'),
|
||||||
|
]
|
||||||
|
);
|
||||||
$this->form = $this->form();
|
$this->form = $this->form();
|
||||||
$this->actionBtns = $this->btns('config');
|
$this->actionBtns = $this->btns('config');
|
||||||
|
|
||||||
|
@ -108,9 +118,19 @@ class Config extends Profile
|
||||||
protected function form(): array
|
protected function form(): array
|
||||||
{
|
{
|
||||||
$form = [
|
$form = [
|
||||||
'action' => $this->c->Router->link('EditUserBoardConfig', ['id' => $this->curUser->id]),
|
'action' => $this->c->Router->link(
|
||||||
|
'EditUserBoardConfig',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
'hidden' => [
|
'hidden' => [
|
||||||
'token' => $this->c->Csrf->create('EditUserBoardConfig', ['id' => $this->curUser->id]),
|
'token' => $this->c->Csrf->create(
|
||||||
|
'EditUserBoardConfig',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id
|
||||||
|
]
|
||||||
|
),
|
||||||
],
|
],
|
||||||
'sets' => [],
|
'sets' => [],
|
||||||
'btns' => [
|
'btns' => [
|
||||||
|
|
|
@ -136,7 +136,17 @@ class Edit extends Profile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->crumbs = $this->crumbs([$this->c->Router->link('EditUserProfile', ['id' => $this->curUser->id]), __('Editing profile')]);
|
$this->crumbs = $this->crumbs(
|
||||||
|
[
|
||||||
|
$this->c->Router->link(
|
||||||
|
'EditUserProfile',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
__('Editing profile'),
|
||||||
|
]
|
||||||
|
);
|
||||||
$this->form = $this->form();
|
$this->form = $this->form();
|
||||||
$this->actionBtns = $this->btns('edit');
|
$this->actionBtns = $this->btns('edit');
|
||||||
|
|
||||||
|
@ -189,9 +199,19 @@ class Edit extends Profile
|
||||||
protected function form(): array
|
protected function form(): array
|
||||||
{
|
{
|
||||||
$form = [
|
$form = [
|
||||||
'action' => $this->c->Router->link('EditUserProfile', ['id' => $this->curUser->id]),
|
'action' => $this->c->Router->link(
|
||||||
|
'EditUserProfile',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
'hidden' => [
|
'hidden' => [
|
||||||
'token' => $this->c->Csrf->create('EditUserProfile', ['id' => $this->curUser->id]),
|
'token' => $this->c->Csrf->create(
|
||||||
|
'EditUserProfile',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
],
|
],
|
||||||
'sets' => [],
|
'sets' => [],
|
||||||
'btns' => [
|
'btns' => [
|
||||||
|
@ -243,7 +263,12 @@ class Edit extends Profile
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'value' => __('Configure moderator rights'),
|
'value' => __('Configure moderator rights'),
|
||||||
'title' => __('Configure moderator rights'),
|
'title' => __('Configure moderator rights'),
|
||||||
'href' => $this->c->Router->link('EditUserModeration', ['id' => $this->curUser->id]),
|
'href' => $this->c->Router->link(
|
||||||
|
'EditUserModeration',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
if ($this->rules->setTitle) {
|
if ($this->rules->setTitle) {
|
||||||
|
@ -266,7 +291,12 @@ class Edit extends Profile
|
||||||
$fields['change_pass'] = [
|
$fields['change_pass'] = [
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'value' => __('Change passphrase'),
|
'value' => __('Change passphrase'),
|
||||||
'href' => $this->c->Router->link('EditUserPass', ['id' => $this->curUser->id]),
|
'href' => $this->c->Router->link(
|
||||||
|
'EditUserPass',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
if ($this->rules->useAvatar) {
|
if ($this->rules->useAvatar) {
|
||||||
|
@ -376,7 +406,12 @@ class Edit extends Profile
|
||||||
$fields['change_email'] = [
|
$fields['change_email'] = [
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'value' => __('To change email'),
|
'value' => __('To change email'),
|
||||||
'href' => $this->c->Router->link('EditUserEmail', ['id' => $this->curUser->id]),
|
'href' => $this->c->Router->link(
|
||||||
|
'EditUserEmail',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$fields['email_setting'] = [
|
$fields['email_setting'] = [
|
||||||
|
|
|
@ -93,7 +93,15 @@ class Email extends Profile
|
||||||
} else {
|
} else {
|
||||||
$key = $this->c->Secury->randomPass(33);
|
$key = $this->c->Secury->randomPass(33);
|
||||||
$hash = $this->c->Secury->hash($this->curUser->id . $v->new_email . $key);
|
$hash = $this->c->Secury->hash($this->curUser->id . $v->new_email . $key);
|
||||||
$link = $this->c->Router->link('SetNewEmail', ['id' => $this->curUser->id, 'email' => $v->new_email, 'key' => $key, 'hash' => $hash]);
|
$link = $this->c->Router->link(
|
||||||
|
'SetNewEmail',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
'email' => $v->new_email,
|
||||||
|
'key' => $key,
|
||||||
|
'hash' => $hash,
|
||||||
|
]
|
||||||
|
);
|
||||||
$tplData = [
|
$tplData = [
|
||||||
'fRootLink' => $this->c->Router->link('Index'),
|
'fRootLink' => $this->c->Router->link('Index'),
|
||||||
'fMailer' => __('Mailer', $this->c->config->o_board_title),
|
'fMailer' => __('Mailer', $this->c->config->o_board_title),
|
||||||
|
@ -134,8 +142,24 @@ class Email extends Profile
|
||||||
|
|
||||||
|
|
||||||
$this->crumbs = $this->crumbs(
|
$this->crumbs = $this->crumbs(
|
||||||
[$this->c->Router->link('EditUserEmail', ['id' => $this->curUser->id]), __('Change email')],
|
[
|
||||||
[$this->c->Router->link('EditUserProfile', ['id' => $this->curUser->id]), __('Editing profile')]
|
$this->c->Router->link(
|
||||||
|
'EditUserEmail',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
__('Change email'),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
$this->c->Router->link(
|
||||||
|
'EditUserProfile',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
__('Editing profile'),
|
||||||
|
]
|
||||||
);
|
);
|
||||||
$this->form = $this->form();
|
$this->form = $this->form();
|
||||||
$this->actionBtns = $this->btns('edit');
|
$this->actionBtns = $this->btns('edit');
|
||||||
|
@ -151,9 +175,19 @@ class Email extends Profile
|
||||||
protected function form(): array
|
protected function form(): array
|
||||||
{
|
{
|
||||||
$form = [
|
$form = [
|
||||||
'action' => $this->c->Router->link('EditUserEmail', ['id' => $this->curUser->id]),
|
'action' => $this->c->Router->link(
|
||||||
|
'EditUserEmail',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
'hidden' => [
|
'hidden' => [
|
||||||
'token' => $this->c->Csrf->create('EditUserEmail', ['id' => $this->curUser->id]),
|
'token' => $this->c->Csrf->create(
|
||||||
|
'EditUserEmail',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
],
|
],
|
||||||
'sets' => [
|
'sets' => [
|
||||||
'new-email' => [
|
'new-email' => [
|
||||||
|
|
|
@ -64,8 +64,24 @@ class Mod extends Profile
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->crumbs = $this->crumbs(
|
$this->crumbs = $this->crumbs(
|
||||||
[$this->c->Router->link('EditUserModeration', ['id' => $this->curUser->id]), __('Moderator rights')],
|
[
|
||||||
[$this->c->Router->link('EditUserProfile', ['id' => $this->curUser->id]), __('Editing profile')]
|
$this->c->Router->link(
|
||||||
|
'EditUserModeration',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
__('Moderator rights'),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
$this->c->Router->link(
|
||||||
|
'EditUserProfile',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
__('Editing profile'),
|
||||||
|
]
|
||||||
);
|
);
|
||||||
$this->form = $this->form();
|
$this->form = $this->form();
|
||||||
$this->actionBtns = $this->btns('edit');
|
$this->actionBtns = $this->btns('edit');
|
||||||
|
@ -95,9 +111,19 @@ class Mod extends Profile
|
||||||
protected function form(): array
|
protected function form(): array
|
||||||
{
|
{
|
||||||
$form = [
|
$form = [
|
||||||
'action' => $this->c->Router->link('EditUserModeration', ['id' => $this->curUser->id]),
|
'action' => $this->c->Router->link(
|
||||||
|
'EditUserModeration',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
'hidden' => [
|
'hidden' => [
|
||||||
'token' => $this->c->Csrf->create('EditUserModeration', ['id' => $this->curUser->id]),
|
'token' => $this->c->Csrf->create(
|
||||||
|
'EditUserModeration',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
],
|
],
|
||||||
'sets' => [],
|
'sets' => [],
|
||||||
'btns' => [
|
'btns' => [
|
||||||
|
|
|
@ -67,8 +67,24 @@ class Pass extends Profile
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->crumbs = $this->crumbs(
|
$this->crumbs = $this->crumbs(
|
||||||
[$this->c->Router->link('EditUserPass', ['id' => $this->curUser->id]), __('Change pass')],
|
[
|
||||||
[$this->c->Router->link('EditUserProfile', ['id' => $this->curUser->id]), __('Editing profile')]
|
$this->c->Router->link(
|
||||||
|
'EditUserPass',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
__('Change pass'),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
$this->c->Router->link(
|
||||||
|
'EditUserProfile',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
__('Editing profile'),
|
||||||
|
]
|
||||||
);
|
);
|
||||||
$this->form = $this->form();
|
$this->form = $this->form();
|
||||||
$this->actionBtns = $this->btns('edit');
|
$this->actionBtns = $this->btns('edit');
|
||||||
|
@ -84,9 +100,19 @@ class Pass extends Profile
|
||||||
protected function form(): array
|
protected function form(): array
|
||||||
{
|
{
|
||||||
$form = [
|
$form = [
|
||||||
'action' => $this->c->Router->link('EditUserPass', ['id' => $this->curUser->id]),
|
'action' => $this->c->Router->link(
|
||||||
|
'EditUserPass',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
'hidden' => [
|
'hidden' => [
|
||||||
'token' => $this->c->Csrf->create('EditUserPass', ['id' => $this->curUser->id]),
|
'token' => $this->c->Csrf->create(
|
||||||
|
'EditUserPass',
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
],
|
],
|
||||||
'sets' => [
|
'sets' => [
|
||||||
'new-pass' => [
|
'new-pass' => [
|
||||||
|
|
|
@ -169,7 +169,12 @@ class View extends Profile
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'caption' => __('Email info'),
|
'caption' => __('Email info'),
|
||||||
'value' => __('Send email'),
|
'value' => __('Send email'),
|
||||||
'href' => $this->c->Router->link('', ['id' => $this->curUser->id]), // ????
|
'href' => $this->c->Router->link(
|
||||||
|
'', // ????
|
||||||
|
[
|
||||||
|
'id' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,7 +250,13 @@ class View extends Profile
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'caption' => __('Posts info'),
|
'caption' => __('Posts info'),
|
||||||
'value' => $this->user->showPostCount ? \ForkBB\num($this->curUser->num_posts) : __('Show posts'),
|
'value' => $this->user->showPostCount ? \ForkBB\num($this->curUser->num_posts) : __('Show posts'),
|
||||||
'href' => $this->c->Router->link('SearchAction', ['action' => 'posts', 'uid' => $this->curUser->id]),
|
'href' => $this->c->Router->link(
|
||||||
|
'SearchAction',
|
||||||
|
[
|
||||||
|
'action' => 'posts',
|
||||||
|
'uid' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
'title' => __('Show posts'),
|
'title' => __('Show posts'),
|
||||||
];
|
];
|
||||||
$fields['topics'] = [
|
$fields['topics'] = [
|
||||||
|
@ -253,7 +264,13 @@ class View extends Profile
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'caption' => __('Topics info'),
|
'caption' => __('Topics info'),
|
||||||
'value' => $this->user->showPostCount ? \ForkBB\num($this->curUser->num_topics) : __('Show topics'),
|
'value' => $this->user->showPostCount ? \ForkBB\num($this->curUser->num_topics) : __('Show topics'),
|
||||||
'href' => $this->c->Router->link('SearchAction', ['action' => 'topics', 'uid' => $this->curUser->id]),
|
'href' => $this->c->Router->link(
|
||||||
|
'SearchAction',
|
||||||
|
[
|
||||||
|
'action' => 'topics',
|
||||||
|
'uid' => $this->curUser->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
'title' => __('Show topics'),
|
'title' => __('Show topics'),
|
||||||
];
|
];
|
||||||
} elseif ($this->user->showPostCount) {
|
} elseif ($this->user->showPostCount) {
|
||||||
|
@ -280,7 +297,12 @@ class View extends Profile
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'caption' => __('IP'),
|
'caption' => __('IP'),
|
||||||
'value' => $this->curUser->registration_ip,
|
'value' => $this->curUser->registration_ip,
|
||||||
'href' => $this->c->Router->link('AdminHost', ['ip' => $this->curUser->registration_ip]),
|
'href' => $this->c->Router->link(
|
||||||
|
'AdminHost',
|
||||||
|
[
|
||||||
|
'ip' => $this->curUser->registration_ip,
|
||||||
|
]
|
||||||
|
),
|
||||||
'title' => __('IP title'),
|
'title' => __('IP title'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,10 @@ class Redirect extends Page
|
||||||
*/
|
*/
|
||||||
public function page(string $marker, array $args = []): Page
|
public function page(string $marker, array $args = []): Page
|
||||||
{
|
{
|
||||||
$this->link = $this->c->Router->link($marker, $args);
|
$this->link = $this->c->Router->link(
|
||||||
|
$marker,
|
||||||
|
$args
|
||||||
|
);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,13 @@ class Register extends Page
|
||||||
'fRootLink' => $this->c->Router->link('Index'),
|
'fRootLink' => $this->c->Router->link('Index'),
|
||||||
'fMailer' => __('Mailer', $this->c->config->o_board_title),
|
'fMailer' => __('Mailer', $this->c->config->o_board_title),
|
||||||
'username' => $v->username,
|
'username' => $v->username,
|
||||||
'userLink' => $this->c->Router->link('User', ['id' => $newUserId, 'name' => $v->username]),
|
'userLink' => $this->c->Router->link(
|
||||||
|
'User',
|
||||||
|
[
|
||||||
|
'id' => $newUserId,
|
||||||
|
'name' => $v->username,
|
||||||
|
]
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -194,7 +200,14 @@ class Register extends Page
|
||||||
// отправка письма активации аккаунта
|
// отправка письма активации аккаунта
|
||||||
if ('1' == $this->c->config->o_regs_verify) {
|
if ('1' == $this->c->config->o_regs_verify) {
|
||||||
$hash = $this->c->Secury->hash($newUserId . $key);
|
$hash = $this->c->Secury->hash($newUserId . $key);
|
||||||
$link = $this->c->Router->link('RegActivate', ['id' => $newUserId, 'key' => $key, 'hash' => $hash]);
|
$link = $this->c->Router->link(
|
||||||
|
'RegActivate',
|
||||||
|
[
|
||||||
|
'id' => $newUserId,
|
||||||
|
'key' => $key,
|
||||||
|
'hash' => $hash,
|
||||||
|
]
|
||||||
|
);
|
||||||
$tplData = [
|
$tplData = [
|
||||||
'fTitle' => $this->c->config->o_board_title,
|
'fTitle' => $this->c->config->o_board_title,
|
||||||
'fRootLink' => $this->c->Router->link('Index'),
|
'fRootLink' => $this->c->Router->link('Index'),
|
||||||
|
|
|
@ -112,9 +112,15 @@ class Report extends Page
|
||||||
protected function formReport(array $args, array $data): array
|
protected function formReport(array $args, array $data): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'action' => $this->c->Router->link('ReportPost', $args),
|
'action' => $this->c->Router->link(
|
||||||
|
'ReportPost',
|
||||||
|
$args
|
||||||
|
),
|
||||||
'hidden' => [
|
'hidden' => [
|
||||||
'token' => $this->c->Csrf->create('ReportPost', $args),
|
'token' => $this->c->Csrf->create(
|
||||||
|
'ReportPost',
|
||||||
|
$args
|
||||||
|
),
|
||||||
],
|
],
|
||||||
'sets' => [
|
'sets' => [
|
||||||
'report' => [
|
'report' => [
|
||||||
|
@ -158,7 +164,12 @@ class Report extends Page
|
||||||
$tplData = [
|
$tplData = [
|
||||||
'fMailer' => __('Mailer', $this->c->config->o_board_title),
|
'fMailer' => __('Mailer', $this->c->config->o_board_title),
|
||||||
'username' => $report->author->username,
|
'username' => $report->author->username,
|
||||||
'postLink' => $this->c->Router->link('ViewPost', ['id' => $report->post->id]),
|
'postLink' => $this->c->Router->link(
|
||||||
|
'ViewPost',
|
||||||
|
[
|
||||||
|
'id' => $report->post->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
'reason' => $report->message,
|
'reason' => $report->message,
|
||||||
'forumId' => $report->post->parent->parent->id,
|
'forumId' => $report->post->parent->parent->id,
|
||||||
'topicSubject' => $report->post->parent->subject,
|
'topicSubject' => $report->post->parent->subject,
|
||||||
|
|
|
@ -148,7 +148,14 @@ class Topic extends Page
|
||||||
$this->nameTpl = 'topic';
|
$this->nameTpl = 'topic';
|
||||||
$this->onlinePos = 'topic-' . $topic->id;
|
$this->onlinePos = 'topic-' . $topic->id;
|
||||||
$this->onlineDetail = true;
|
$this->onlineDetail = true;
|
||||||
$this->canonical = $this->c->Router->link('Topic', ['id' => $topic->id, 'name' => \ForkBB\cens($topic->subject), 'page' => $topic->page]);
|
$this->canonical = $this->c->Router->link(
|
||||||
|
'Topic',
|
||||||
|
[
|
||||||
|
'id' => $topic->id,
|
||||||
|
'name' => \ForkBB\cens($topic->subject),
|
||||||
|
'page' => $topic->page
|
||||||
|
]
|
||||||
|
);
|
||||||
$this->model = $topic;
|
$this->model = $topic;
|
||||||
$this->posts = $posts;
|
$this->posts = $posts;
|
||||||
$this->crumbs = $this->crumbs($topic);
|
$this->crumbs = $this->crumbs($topic);
|
||||||
|
|
|
@ -116,7 +116,10 @@ class Userlist extends Page
|
||||||
|
|
||||||
foreach (['ASC', 'DESC'] as $j => $dir) {
|
foreach (['ASC', 'DESC'] as $j => $dir) {
|
||||||
$vars['dir'] = $dir;
|
$vars['dir'] = $dir;
|
||||||
$links[$i * 2 + $j] = $this->c->Router->link('Userlist', $vars);
|
$links[$i * 2 + $j] = $this->c->Router->link(
|
||||||
|
'Userlist',
|
||||||
|
$vars
|
||||||
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
$v->sort === $sort
|
$v->sort === $sort
|
||||||
|
@ -138,7 +141,10 @@ class Userlist extends Page
|
||||||
$this->fIndex = 'userlist';
|
$this->fIndex = 'userlist';
|
||||||
$this->nameTpl = 'userlist';
|
$this->nameTpl = 'userlist';
|
||||||
$this->onlinePos = 'userlist';
|
$this->onlinePos = 'userlist';
|
||||||
$this->canonical = $this->c->Router->link('Userlist', $args);
|
$this->canonical = $this->c->Router->link(
|
||||||
|
'Userlist',
|
||||||
|
$args
|
||||||
|
);
|
||||||
$this->robots = 'noindex';
|
$this->robots = 'noindex';
|
||||||
$this->crumbs = $this->crumbs([$this->c->Router->link('Userlist'), __('User list')]);
|
$this->crumbs = $this->crumbs([$this->c->Router->link('Userlist'), __('User list')]);
|
||||||
$this->pagination = $this->c->Func->paginate($pages, $page, 'Userlist', $args);
|
$this->pagination = $this->c->Func->paginate($pages, $page, 'Userlist', $args);
|
||||||
|
|
|
@ -91,32 +91,37 @@ class Delete extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':users' => $usersToGuest,
|
':users' => $usersToGuest,
|
||||||
];
|
];
|
||||||
$sql = 'UPDATE ::posts
|
$query = 'UPDATE ::posts
|
||||||
SET poster_id=1
|
SET poster_id=1
|
||||||
WHERE poster_id IN (?ai:users)';
|
WHERE poster_id IN (?ai:users)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
if ($usersDel) {
|
if ($usersDel) {
|
||||||
$vars = [
|
$vars = [
|
||||||
':users' => $usersDel,
|
':users' => $usersDel,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT p.topic_id
|
$query = 'SELECT p.topic_id
|
||||||
FROM ::posts as p
|
FROM ::posts as p
|
||||||
WHERE p.poster_id IN (?ai:users)
|
WHERE p.poster_id IN (?ai:users)
|
||||||
GROUP BY p.topic_id';
|
GROUP BY p.topic_id';
|
||||||
$parents = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
|
||||||
|
|
||||||
$sql = 'SELECT t.id
|
$parents = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
|
$query = 'SELECT t.id
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
INNER JOIN ::posts AS p ON t.first_post_id=p.id
|
INNER JOIN ::posts AS p ON t.first_post_id=p.id
|
||||||
WHERE p.poster_id IN (?ai:users)';
|
WHERE p.poster_id IN (?ai:users)';
|
||||||
$notUse = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
|
||||||
|
$notUse = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
$parents = \array_diff($parents, $notUse); //????
|
$parents = \array_diff($parents, $notUse); //????
|
||||||
|
|
||||||
$sql = 'DELETE FROM ::posts
|
$query = 'DELETE
|
||||||
|
FROM ::posts
|
||||||
WHERE poster_id IN (?ai:users)';
|
WHERE poster_id IN (?ai:users)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
|
|
||||||
foreach ($parents as &$parent) {
|
foreach ($parents as &$parent) {
|
||||||
$parent = $this->c->topics->load($parent); //???? ааааАААААААААААААА О_о
|
$parent = $this->c->topics->load($parent); //???? ааааАААААААААААААА О_о
|
||||||
|
@ -127,42 +132,49 @@ class Delete extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':forums' => \array_keys($forums),
|
':forums' => \array_keys($forums),
|
||||||
];
|
];
|
||||||
$sql = 'SELECT p.poster_id
|
$query = 'SELECT p.poster_id
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
INNER JOIN ::topics AS t ON t.id=p.topic_id
|
INNER JOIN ::topics AS t ON t.id=p.topic_id
|
||||||
WHERE t.forum_id IN (?ai:forums)
|
WHERE t.forum_id IN (?ai:forums)
|
||||||
GROUP BY p.poster_id';
|
GROUP BY p.poster_id';
|
||||||
$users = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
|
||||||
|
|
||||||
$sql = 'DELETE FROM ::posts
|
$users = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
|
$query = 'DELETE
|
||||||
|
FROM ::posts
|
||||||
WHERE topic_id IN (
|
WHERE topic_id IN (
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM ::topics
|
FROM ::topics
|
||||||
WHERE forum_id IN (?ai:forums)
|
WHERE forum_id IN (?ai:forums)
|
||||||
)';
|
)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
if ($topics) {
|
if ($topics) {
|
||||||
$vars = [
|
$vars = [
|
||||||
':topics' => \array_keys($topics),
|
':topics' => \array_keys($topics),
|
||||||
];
|
];
|
||||||
$sql = 'SELECT p.poster_id
|
$query = 'SELECT p.poster_id
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
WHERE p.topic_id IN (?ai:topics)
|
WHERE p.topic_id IN (?ai:topics)
|
||||||
GROUP BY p.poster_id';
|
GROUP BY p.poster_id';
|
||||||
$users = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
|
||||||
|
|
||||||
$sql = 'DELETE FROM ::posts
|
$users = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
|
$query = 'DELETE
|
||||||
|
FROM ::posts
|
||||||
WHERE topic_id IN (?ai:topics)';
|
WHERE topic_id IN (?ai:topics)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
if ($posts) {
|
if ($posts) {
|
||||||
$vars = [
|
$vars = [
|
||||||
':posts' => $posts,
|
':posts' => $posts,
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::posts
|
$query = 'DELETE
|
||||||
|
FROM ::posts
|
||||||
WHERE id IN (?ai:posts)';
|
WHERE id IN (?ai:posts)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
if ($parents) {
|
if ($parents) {
|
||||||
$topics = $parents;
|
$topics = $parents;
|
||||||
|
|
|
@ -15,10 +15,11 @@ class Load extends Action
|
||||||
*/
|
*/
|
||||||
protected function getSql(string $where): string
|
protected function getSql(string $where): string
|
||||||
{
|
{
|
||||||
$sql = 'SELECT p.*
|
$query = 'SELECT p.*
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
WHERE ' . $where;
|
WHERE ' . $where;
|
||||||
return $sql;
|
|
||||||
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,8 +51,9 @@ class Load extends Action
|
||||||
':pid' => $id,
|
':pid' => $id,
|
||||||
':tid' => $tid,
|
':tid' => $tid,
|
||||||
];
|
];
|
||||||
$sql = $this->getSql(null !== $tid ? 'p.id=?i:pid AND p.topic_id=?i:tid' : 'p.id=?i:pid');
|
$query = $this->getSql(null !== $tid ? 'p.id=?i:pid AND p.topic_id=?i:tid' : 'p.id=?i:pid');
|
||||||
$data = $this->c->DB->query($sql, $vars)->fetch();
|
|
||||||
|
$data = $this->c->DB->query($query, $vars)->fetch();
|
||||||
|
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -93,8 +95,9 @@ class Load extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':ids' => $ids,
|
':ids' => $ids,
|
||||||
];
|
];
|
||||||
$sql = $this->getSql('p.id IN (?ai:ids)');
|
$query = $this->getSql('p.id IN (?ai:ids)');
|
||||||
$stmt = $this->c->DB->query($sql, $vars);
|
|
||||||
|
$stmt = $this->c->DB->query($query, $vars);
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
$topicIds = [];
|
$topicIds = [];
|
||||||
|
|
|
@ -43,7 +43,12 @@ class Model extends DataModel
|
||||||
*/
|
*/
|
||||||
protected function getlink(): string
|
protected function getlink(): string
|
||||||
{
|
{
|
||||||
return $this->c->Router->link('ViewPost', ['id' => $this->id]);
|
return $this->c->Router->link(
|
||||||
|
'ViewPost',
|
||||||
|
[
|
||||||
|
'id' => $this->id,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +83,12 @@ class Model extends DataModel
|
||||||
|
|
||||||
protected function getlinkReport(): string
|
protected function getlinkReport(): string
|
||||||
{
|
{
|
||||||
return $this->c->Router->link('ReportPost', ['id' => $this->id]);
|
return $this->c->Router->link(
|
||||||
|
'ReportPost',
|
||||||
|
[
|
||||||
|
'id' => $this->id,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getcanDelete(): bool
|
protected function getcanDelete(): bool
|
||||||
|
@ -117,7 +127,12 @@ class Model extends DataModel
|
||||||
|
|
||||||
protected function getlinkDelete(): string
|
protected function getlinkDelete(): string
|
||||||
{
|
{
|
||||||
return $this->c->Router->link('DeletePost', ['id' => $this->id]);
|
return $this->c->Router->link(
|
||||||
|
'DeletePost',
|
||||||
|
[
|
||||||
|
'id' => $this->id,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getcanEdit(): bool
|
protected function getcanEdit(): bool
|
||||||
|
@ -147,7 +162,12 @@ class Model extends DataModel
|
||||||
|
|
||||||
protected function getlinkEdit(): string
|
protected function getlinkEdit(): string
|
||||||
{
|
{
|
||||||
return $this->c->Router->link('EditPost', ['id' => $this->id]);
|
return $this->c->Router->link(
|
||||||
|
'EditPost',
|
||||||
|
[
|
||||||
|
'id' => $this->id,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getcanQuote(): bool
|
protected function getcanQuote(): bool
|
||||||
|
@ -157,7 +177,13 @@ class Model extends DataModel
|
||||||
|
|
||||||
protected function getlinkQuote(): string
|
protected function getlinkQuote(): string
|
||||||
{
|
{
|
||||||
return $this->c->Router->link('NewReply', ['id' => $this->parent->id, 'quote' => $this->id]);
|
return $this->c->Router->link(
|
||||||
|
'NewReply',
|
||||||
|
[
|
||||||
|
'id' => $this->parent->id,
|
||||||
|
'quote' => $this->id,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,12 +20,13 @@ class PreviousPost extends Action
|
||||||
':pid' => $post->id,
|
':pid' => $post->id,
|
||||||
':tid' => $post->topic_id,
|
':tid' => $post->topic_id,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT p.id
|
$query = 'SELECT p.id
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
WHERE p.id < ?i:pid AND p.topic_id=?i:tid
|
WHERE p.id < ?i:pid AND p.topic_id=?i:tid
|
||||||
ORDER BY p.id DESC
|
ORDER BY p.id DESC
|
||||||
LIMIT 1';
|
LIMIT 1';
|
||||||
$id = $this->c->DB->query($sql, $vars)->fetchColumn();
|
|
||||||
|
$id = $this->c->DB->query($query, $vars)->fetchColumn();
|
||||||
|
|
||||||
return empty($id) ? null : $id;
|
return empty($id) ? null : $id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,15 +22,14 @@ class RebuildIndex extends Action
|
||||||
':start' => $start,
|
':start' => $start,
|
||||||
':limit' => $limit,
|
':limit' => $limit,
|
||||||
];
|
];
|
||||||
|
$query = 'SELECT p.id, p.message, t.id as topic_id, t.subject, t.first_post_id
|
||||||
$sql = 'SELECT p.id, p.message, t.id as topic_id, t.subject, t.first_post_id
|
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
INNER JOIN ::topics AS t ON t.id=p.topic_id
|
INNER JOIN ::topics AS t ON t.id=p.topic_id
|
||||||
WHERE p.id>=?i:start
|
WHERE p.id>=?i:start
|
||||||
ORDER BY p.id ASC
|
ORDER BY p.id ASC
|
||||||
LIMIT ?i:limit';
|
LIMIT ?i:limit';
|
||||||
|
|
||||||
$stmt = $this->c->DB->query($sql, $vars);
|
$stmt = $this->c->DB->query($query, $vars);
|
||||||
$number = 0;
|
$number = 0;
|
||||||
|
|
||||||
while ($row = $stmt->fetch()) {
|
while ($row = $stmt->fetch()) {
|
||||||
|
|
|
@ -19,13 +19,13 @@ class UserInfoFromIP extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':ip' => $ip,
|
':ip' => $ip,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT p.poster_id, p.poster
|
$query = 'SELECT p.poster_id, p.poster
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
WHERE p.poster_ip=?s:ip
|
WHERE p.poster_ip=?s:ip
|
||||||
GROUP BY p.poster_id, p.poster
|
GROUP BY p.poster_id, p.poster
|
||||||
ORDER BY p.poster';
|
ORDER BY p.poster';
|
||||||
|
|
||||||
$stmt = $this->c->DB->query($sql, $vars);
|
$stmt = $this->c->DB->query($query, $vars);
|
||||||
$result = [];
|
$result = [];
|
||||||
$ids = [];
|
$ids = [];
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,12 @@ class UserStat extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':id' => $id,
|
':id' => $id,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT p.poster_ip, MAX(p.posted) AS last_used, COUNT(p.id) AS used_times
|
$query = 'SELECT p.poster_ip, MAX(p.posted) AS last_used, COUNT(p.id) AS used_times
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
WHERE p.poster_id=?i:id
|
WHERE p.poster_id=?i:id
|
||||||
GROUP BY p.poster_ip
|
GROUP BY p.poster_ip
|
||||||
ORDER BY last_used DESC';
|
ORDER BY last_used DESC';
|
||||||
|
|
||||||
return $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_UNIQUE);
|
return $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_UNIQUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,10 +43,11 @@ class View extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':ids' => $arg->idsList,
|
':ids' => $arg->idsList,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT w.id, w.message, w.poster, w.posted
|
$query = 'SELECT w.id, w.message, w.poster, w.posted
|
||||||
FROM ::warnings AS w
|
FROM ::warnings AS w
|
||||||
WHERE w.id IN (?ai:ids)';
|
WHERE w.id IN (?ai:ids)';
|
||||||
$warnings = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_GROUP);
|
|
||||||
|
$warnings = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_GROUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
$userIds = [];
|
$userIds = [];
|
||||||
|
|
|
@ -26,10 +26,11 @@ class Load extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':id' => $id,
|
':id' => $id,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT r.*
|
$query = 'SELECT r.*
|
||||||
FROM ::reports AS r
|
FROM ::reports AS r
|
||||||
WHERE r.id=?i:id';
|
WHERE r.id=?i:id';
|
||||||
$data = $this->c->DB->query($sql, $vars)->fetch();
|
|
||||||
|
$data = $this->c->DB->query($query, $vars)->fetch();
|
||||||
|
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -53,18 +54,18 @@ class Load extends Action
|
||||||
$vars = [];
|
$vars = [];
|
||||||
|
|
||||||
if ($noZapped) {
|
if ($noZapped) {
|
||||||
$sql = 'SELECT r.*
|
$query = 'SELECT r.*
|
||||||
FROM ::reports AS r
|
FROM ::reports AS r
|
||||||
WHERE r.zapped=0
|
WHERE r.zapped=0
|
||||||
ORDER BY r.id DESC';
|
ORDER BY r.id DESC';
|
||||||
} else {
|
} else {
|
||||||
$sql = 'SELECT r.*
|
$query = 'SELECT r.*
|
||||||
FROM ::reports AS r
|
FROM ::reports AS r
|
||||||
WHERE r.zapped!=0
|
WHERE r.zapped!=0
|
||||||
ORDER BY r.zapped DESC'; // LIMIT 10 не нужен, если при обработке сигнала будут удалены старые
|
ORDER BY r.zapped DESC'; // LIMIT 10 не нужен, если при обработке сигнала будут удалены старые
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->c->DB->query($sql, $vars)->fetchAll();
|
$data = $this->c->DB->query($query, $vars)->fetchAll();
|
||||||
|
|
||||||
foreach ($data as $row) {
|
foreach ($data as $row) {
|
||||||
$result[] = $this->manager->create($row);
|
$result[] = $this->manager->create($row);
|
||||||
|
|
|
@ -96,7 +96,12 @@ class Manager extends ManagerModel
|
||||||
if ($this->c->Cache->has('report')) {
|
if ($this->c->Cache->has('report')) {
|
||||||
$last = $this->list = $this->c->Cache->get('report');
|
$last = $this->list = $this->c->Cache->get('report');
|
||||||
} else {
|
} else {
|
||||||
$last = (int) $this->c->DB->query('SELECT r.id FROM ::reports AS r ORDER BY r.id DESC LIMIT 1')->fetchColumn();
|
$query = 'SELECT r.id
|
||||||
|
FROM ::reports AS r
|
||||||
|
ORDER BY r.id DESC
|
||||||
|
LIMIT 1';
|
||||||
|
|
||||||
|
$last = (int) $this->c->DB->query($query)->fetchColumn();
|
||||||
|
|
||||||
$this->c->Cache->set('report', $last);
|
$this->c->Cache->set('report', $last);
|
||||||
}
|
}
|
||||||
|
@ -109,20 +114,23 @@ class Manager extends ManagerModel
|
||||||
*/
|
*/
|
||||||
public function clear(): void
|
public function clear(): void
|
||||||
{
|
{
|
||||||
$sql = 'SELECT r.zapped
|
$query = 'SELECT r.zapped
|
||||||
FROM ::reports as r
|
FROM ::reports as r
|
||||||
WHERE r.zapped!=0
|
WHERE r.zapped!=0
|
||||||
ORDER BY r.zapped DESC
|
ORDER BY r.zapped DESC
|
||||||
LIMIT 10,1';
|
LIMIT 10,1';
|
||||||
$time = (int) $this->c->DB->query($sql)->fetchColumn();
|
|
||||||
|
$time = (int) $this->c->DB->query($query)->fetchColumn();
|
||||||
|
|
||||||
if ($time > 0) {
|
if ($time > 0) {
|
||||||
$vars = [
|
$vars = [
|
||||||
':time' => $time,
|
':time' => $time,
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::reports
|
$query = 'DELETE
|
||||||
|
FROM ::reports
|
||||||
WHERE zapped<=?i:time';
|
WHERE zapped<=?i:time';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,10 +138,18 @@ class Model extends DataModel
|
||||||
public function getlinkZap(): string
|
public function getlinkZap(): string
|
||||||
{
|
{
|
||||||
if (empty($this->zapped)) {
|
if (empty($this->zapped)) {
|
||||||
return $this->c->Router->link('AdminReportsZap', [
|
return $this->c->Router->link(
|
||||||
|
'AdminReportsZap',
|
||||||
|
[
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'token' => $this->c->Csrf->create('AdminReportsZap', ['id' => $this->id]),
|
'token' => $this->c->Csrf->create(
|
||||||
]);
|
'AdminReportsZap',
|
||||||
|
[
|
||||||
|
'id' => $this->id,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,41 +30,29 @@ class ActionP extends Method
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = null;
|
$query = null;
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'search':
|
case 'search':
|
||||||
$list = $this->model->queryIds;
|
$list = $this->model->queryIds;
|
||||||
break;
|
break;
|
||||||
case 'posts':
|
case 'posts':
|
||||||
$sql = 'SELECT p.id
|
$query = 'SELECT p.id
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
INNER JOIN ::topics AS t ON t.id=p.topic_id
|
INNER JOIN ::topics AS t ON t.id=p.topic_id
|
||||||
WHERE t.forum_id IN (?ai:forums) AND t.moved_to=0 AND p.poster_id=?i:uid
|
WHERE t.forum_id IN (?ai:forums) AND t.moved_to=0 AND p.poster_id=?i:uid
|
||||||
ORDER BY p.posted DESC';
|
ORDER BY p.posted DESC';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
# case 'last':
|
|
||||||
# $sql = 'SELECT t.id
|
|
||||||
# FROM ::topics AS t
|
|
||||||
# WHERE t.forum_id IN (?ai:forums) AND t.moved_to=0
|
|
||||||
# ORDER BY t.last_post DESC';
|
|
||||||
# break;
|
|
||||||
# case 'unanswered':
|
|
||||||
# $sql = 'SELECT t.id
|
|
||||||
# FROM ::topics AS t
|
|
||||||
# WHERE t.forum_id IN (?ai:forums) AND t.moved_to=0 AND t.num_replies=0
|
|
||||||
# ORDER BY t.last_post DESC';
|
|
||||||
# break;
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidArgumentException('Unknown action: ' . $action);
|
throw new InvalidArgumentException('Unknown action: ' . $action);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $sql) {
|
if (null !== $query) {
|
||||||
$vars = [
|
$vars = [
|
||||||
':forums' => $forums,
|
':forums' => $forums,
|
||||||
':uid' => $uid,
|
':uid' => $uid,
|
||||||
];
|
];
|
||||||
$list = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
|
||||||
|
$list = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->model->numPages = (int) \ceil((\count($list) ?: 1) / $this->c->user->disp_posts);
|
$this->model->numPages = (int) \ceil((\count($list) ?: 1) / $this->c->user->disp_posts);
|
||||||
|
|
|
@ -30,25 +30,25 @@ class ActionT extends Method
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = null;
|
$query = null;
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'search':
|
case 'search':
|
||||||
$list = $this->model->queryIds;
|
$list = $this->model->queryIds;
|
||||||
break;
|
break;
|
||||||
case 'latest_active_topics':
|
case 'latest_active_topics':
|
||||||
$sql = 'SELECT t.id
|
$query = 'SELECT t.id
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
WHERE t.forum_id IN (?ai:forums) AND t.moved_to=0
|
WHERE t.forum_id IN (?ai:forums) AND t.moved_to=0
|
||||||
ORDER BY t.last_post DESC';
|
ORDER BY t.last_post DESC';
|
||||||
break;
|
break;
|
||||||
case 'unanswered_topics':
|
case 'unanswered_topics':
|
||||||
$sql = 'SELECT t.id
|
$query = 'SELECT t.id
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
WHERE t.forum_id IN (?ai:forums) AND t.moved_to=0 AND t.num_replies=0
|
WHERE t.forum_id IN (?ai:forums) AND t.moved_to=0 AND t.num_replies=0
|
||||||
ORDER BY t.last_post DESC';
|
ORDER BY t.last_post DESC';
|
||||||
break;
|
break;
|
||||||
case 'topics_with_your_posts':
|
case 'topics_with_your_posts':
|
||||||
$sql = 'SELECT t.id
|
$query = 'SELECT t.id
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
INNER JOIN ::posts AS p ON t.id=p.topic_id
|
INNER JOIN ::posts AS p ON t.id=p.topic_id
|
||||||
WHERE t.forum_id IN (?ai:forums) AND t.moved_to=0 AND p.poster_id=?i:uid
|
WHERE t.forum_id IN (?ai:forums) AND t.moved_to=0 AND p.poster_id=?i:uid
|
||||||
|
@ -56,14 +56,14 @@ class ActionT extends Method
|
||||||
ORDER BY t.last_post DESC';
|
ORDER BY t.last_post DESC';
|
||||||
break;
|
break;
|
||||||
case 'topics':
|
case 'topics':
|
||||||
$sql = 'SELECT t.id
|
$query = 'SELECT t.id
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
INNER JOIN ::posts AS p ON t.first_post_id=p.id
|
INNER JOIN ::posts AS p ON t.first_post_id=p.id
|
||||||
WHERE t.forum_id IN (?ai:forums) AND t.moved_to=0 AND p.poster_id=?i:uid
|
WHERE t.forum_id IN (?ai:forums) AND t.moved_to=0 AND p.poster_id=?i:uid
|
||||||
ORDER BY t.last_post DESC';
|
ORDER BY t.last_post DESC';
|
||||||
break;
|
break;
|
||||||
case 'new':
|
case 'new':
|
||||||
$sql = 'SELECT t.id
|
$query = 'SELECT t.id
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
LEFT JOIN ::mark_of_topic AS mot ON (mot.uid=?i:uid AND mot.tid=t.id)
|
LEFT JOIN ::mark_of_topic AS mot ON (mot.uid=?i:uid AND mot.tid=t.id)
|
||||||
LEFT JOIN ::mark_of_forum AS mof ON (mof.uid=?i:uid AND mof.fid=t.forum_id)
|
LEFT JOIN ::mark_of_forum AS mof ON (mof.uid=?i:uid AND mof.fid=t.forum_id)
|
||||||
|
@ -78,13 +78,14 @@ class ActionT extends Method
|
||||||
throw new InvalidArgumentException('Unknown action: ' . $action);
|
throw new InvalidArgumentException('Unknown action: ' . $action);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $sql) {
|
if (null !== $query) {
|
||||||
$vars = [
|
$vars = [
|
||||||
':forums' => $forums,
|
':forums' => $forums,
|
||||||
':uid' => $uid,
|
':uid' => $uid,
|
||||||
':max' => \max((int) $this->c->user->last_visit, (int) $this->c->user->u_mark_all_read),
|
':max' => \max((int) $this->c->user->last_visit, (int) $this->c->user->u_mark_all_read),
|
||||||
];
|
];
|
||||||
$list = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
|
||||||
|
$list = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->model->numPages = (int) \ceil((\count($list) ?: 1) / $this->c->user->disp_topics);
|
$this->model->numPages = (int) \ceil((\count($list) ?: 1) / $this->c->user->disp_topics);
|
||||||
|
|
|
@ -76,13 +76,14 @@ class Delete extends Method
|
||||||
throw new InvalidArgumentException('Expected only User(s), Forum(s), Topic(s) or Post(s)');
|
throw new InvalidArgumentException('Expected only User(s), Forum(s), Topic(s) or Post(s)');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = null;
|
$query = null;
|
||||||
|
|
||||||
if ($users) {
|
if ($users) {
|
||||||
$vars = [
|
$vars = [
|
||||||
':users' => $users,
|
':users' => $users,
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::search_matches
|
$query = 'DELETE
|
||||||
|
FROM ::search_matches
|
||||||
WHERE post_id IN (
|
WHERE post_id IN (
|
||||||
SELECT p.id
|
SELECT p.id
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
|
@ -93,7 +94,8 @@ class Delete extends Method
|
||||||
$vars = [
|
$vars = [
|
||||||
':forums' => \array_keys($forums),
|
':forums' => \array_keys($forums),
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::search_matches
|
$query = 'DELETE
|
||||||
|
FROM ::search_matches
|
||||||
WHERE post_id IN (
|
WHERE post_id IN (
|
||||||
SELECT p.id
|
SELECT p.id
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
|
@ -105,7 +107,8 @@ class Delete extends Method
|
||||||
$vars = [
|
$vars = [
|
||||||
':topics' => \array_keys($topics),
|
':topics' => \array_keys($topics),
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::search_matches
|
$query = 'DELETE
|
||||||
|
FROM ::search_matches
|
||||||
WHERE post_id IN (
|
WHERE post_id IN (
|
||||||
SELECT p.id
|
SELECT p.id
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
|
@ -116,11 +119,12 @@ class Delete extends Method
|
||||||
$vars = [
|
$vars = [
|
||||||
':posts' => \array_keys($posts),
|
':posts' => \array_keys($posts),
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::search_matches
|
$query = 'DELETE
|
||||||
|
FROM ::search_matches
|
||||||
WHERE post_id IN (?ai:posts)';
|
WHERE post_id IN (?ai:posts)';
|
||||||
}
|
}
|
||||||
if ($sql) {
|
if ($query) {
|
||||||
$this->c->DB->exec($sql, $vars);
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,12 +57,13 @@ class Execute extends Method
|
||||||
$vars = [
|
$vars = [
|
||||||
':key' => $key,
|
':key' => $key,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT sc.search_time, sc.search_data
|
$query = 'SELECT sc.search_time, sc.search_data
|
||||||
FROM ::search_cache AS sc
|
FROM ::search_cache AS sc
|
||||||
WHERE sc.search_key=?s:key
|
WHERE sc.search_key=?s:key
|
||||||
ORDER BY sc.search_time DESC
|
ORDER BY sc.search_time DESC
|
||||||
LIMIT 1';
|
LIMIT 1';
|
||||||
$row = $this->c->DB->query($sql, $vars)->fetch();
|
|
||||||
|
$row = $this->c->DB->query($query, $vars)->fetch();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
! empty($row['search_time'])
|
! empty($row['search_time'])
|
||||||
|
@ -77,13 +78,11 @@ class Execute extends Method
|
||||||
}
|
}
|
||||||
|
|
||||||
$ids = $this->exec($this->model->queryWords, $queryVars);
|
$ids = $this->exec($this->model->queryWords, $queryVars);
|
||||||
|
|
||||||
if (1 === $v->sort_dir) {
|
if (1 === $v->sort_dir) {
|
||||||
\asort($ids, $this->sortType);
|
\asort($ids, $this->sortType);
|
||||||
} else {
|
} else {
|
||||||
\arsort($ids, $this->sortType);
|
\arsort($ids, $this->sortType);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ids = \array_keys($ids);
|
$ids = \array_keys($ids);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
|
@ -94,9 +93,10 @@ class Execute extends Method
|
||||||
':key' => $key,
|
':key' => $key,
|
||||||
':time' => \time(),
|
':time' => \time(),
|
||||||
];
|
];
|
||||||
$sql = 'INSERT INTO ::search_cache (search_key, search_time, search_data)
|
$query = 'INSERT INTO ::search_cache (search_key, search_time, search_data)
|
||||||
VALUES (?s:key, ?i:time, ?s:data)';
|
VALUES (?s:key, ?i:time, ?s:data)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
|
|
||||||
$this->model->queryIds = $ids;
|
$this->model->queryIds = $ids;
|
||||||
$this->model->queryNoCache = true;
|
$this->model->queryNoCache = true;
|
||||||
|
|
|
@ -26,11 +26,12 @@ class Index extends Method
|
||||||
$vars = [
|
$vars = [
|
||||||
':pid' => $post->id,
|
':pid' => $post->id,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT sw.id, sw.word, sm.subject_match
|
$query = 'SELECT sw.id, sw.word, sm.subject_match
|
||||||
FROM ::search_words AS sw
|
FROM ::search_words AS sw
|
||||||
INNER JOIN ::search_matches AS sm ON sw.id=sm.word_id
|
INNER JOIN ::search_matches AS sm ON sw.id=sm.word_id
|
||||||
WHERE sm.post_id=?i:pid';
|
WHERE sm.post_id=?i:pid';
|
||||||
$stmt = $this->c->DB->query($sql, $vars);
|
|
||||||
|
$stmt = $this->c->DB->query($query, $vars);
|
||||||
|
|
||||||
$mesCurWords = [];
|
$mesCurWords = [];
|
||||||
$subCurWords = [];
|
$subCurWords = [];
|
||||||
|
@ -70,18 +71,19 @@ class Index extends Method
|
||||||
$vars = [
|
$vars = [
|
||||||
':words' => $allWords,
|
':words' => $allWords,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT sw.word
|
$query = 'SELECT sw.word
|
||||||
FROM ::search_words AS sw
|
FROM ::search_words AS sw
|
||||||
WHERE sw.word IN(?as:words)';
|
WHERE sw.word IN(?as:words)';
|
||||||
$oldWords = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
|
||||||
|
$oldWords = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
$newWords = \array_diff($allWords, $oldWords);
|
$newWords = \array_diff($allWords, $oldWords);
|
||||||
|
|
||||||
if (! empty($newWords)) {
|
if (! empty($newWords)) {
|
||||||
$sql = 'INSERT INTO ::search_words (word) VALUES(?s:word)';
|
$query = 'INSERT INTO ::search_words (word) VALUES(?s:word)';
|
||||||
$stmt = null;
|
$stmt = null;
|
||||||
foreach ($newWords as $word) {
|
foreach ($newWords as $word) {
|
||||||
if (null === $stmt) {
|
if (null === $stmt) {
|
||||||
$stmt = $this->c->DB->prepare($sql, [':word' => $word]);
|
$stmt = $this->c->DB->prepare($query, [':word' => $word]);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
} else {
|
} else {
|
||||||
$stmt->execute([':word' => $word]);
|
$stmt->execute([':word' => $word]);
|
||||||
|
@ -100,9 +102,11 @@ class Index extends Method
|
||||||
':subj' => 's' === $key ? 1 : 0,
|
':subj' => 's' === $key ? 1 : 0,
|
||||||
':ids' => $list,
|
':ids' => $list,
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::search_matches
|
$query = 'DELETE
|
||||||
|
FROM ::search_matches
|
||||||
WHERE word_id IN(?ai:ids) AND post_id=?i:pid AND subject_match=?i:subj';
|
WHERE word_id IN(?ai:ids) AND post_id=?i:pid AND subject_match=?i:subj';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($words['add'] as $key => $list)
|
foreach ($words['add'] as $key => $list)
|
||||||
|
@ -116,11 +120,12 @@ class Index extends Method
|
||||||
':subj' => 's' === $key ? 1 : 0,
|
':subj' => 's' === $key ? 1 : 0,
|
||||||
':words' => $list,
|
':words' => $list,
|
||||||
];
|
];
|
||||||
$sql = 'INSERT INTO ::search_matches (post_id, word_id, subject_match)
|
$query = 'INSERT INTO ::search_matches (post_id, word_id, subject_match)
|
||||||
SELECT ?i:pid, id, ?i:subj
|
SELECT ?i:pid, id, ?i:subj
|
||||||
FROM ::search_words
|
FROM ::search_words
|
||||||
WHERE word IN(?as:words)';
|
WHERE word IN(?as:words)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,10 @@ class Model extends ParentModel
|
||||||
*/
|
*/
|
||||||
protected function getlink(): string
|
protected function getlink(): string
|
||||||
{
|
{
|
||||||
return $this->c->Router->link($this->linkMarker, $this->linkArgs);
|
return $this->c->Router->link(
|
||||||
|
$this->linkMarker,
|
||||||
|
$this->linkArgs
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -26,8 +26,11 @@ class Access extends Action
|
||||||
':ids' => $ids,
|
':ids' => $ids,
|
||||||
':closed' => $open ? 0 : 1,
|
':closed' => $open ? 0 : 1,
|
||||||
];
|
];
|
||||||
$sql = 'UPDATE ::topics SET closed=?i:closed WHERE id IN (?ai:ids)';
|
$query = 'UPDATE ::topics
|
||||||
$this->c->DB->exec($sql, $vars);
|
SET closed=?i:closed
|
||||||
|
WHERE id IN (?ai:ids)';
|
||||||
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,32 +27,32 @@ class CalcStat extends Method
|
||||||
$vars = [
|
$vars = [
|
||||||
':tid' => $this->model->id
|
':tid' => $this->model->id
|
||||||
];
|
];
|
||||||
$sql = 'SELECT COUNT(p.id) - 1
|
$query = 'SELECT COUNT(p.id) - 1
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
WHERE p.topic_id=?i:tid';
|
WHERE p.topic_id=?i:tid';
|
||||||
|
|
||||||
$numReplies = $this->c->DB->query($sql, $vars)->fetchColumn();
|
$numReplies = $this->c->DB->query($query, $vars)->fetchColumn();
|
||||||
|
|
||||||
$sql = 'SELECT p.id, p.poster, p.poster_id, p.posted
|
$query = 'SELECT p.id, p.poster, p.poster_id, p.posted
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
WHERE p.topic_id=?i:tid
|
WHERE p.topic_id=?i:tid
|
||||||
ORDER BY p.id
|
ORDER BY p.id
|
||||||
LIMIT 1';
|
LIMIT 1';
|
||||||
|
|
||||||
$result = $this->c->DB->query($sql, $vars)->fetch();
|
$result = $this->c->DB->query($query, $vars)->fetch();
|
||||||
|
|
||||||
$this->model->poster = $result['poster'];
|
$this->model->poster = $result['poster'];
|
||||||
$this->model->poster_id = $result['poster_id'];
|
$this->model->poster_id = $result['poster_id'];
|
||||||
$this->model->posted = $result['posted'];
|
$this->model->posted = $result['posted'];
|
||||||
$this->model->first_post_id = $result['id'];
|
$this->model->first_post_id = $result['id'];
|
||||||
|
|
||||||
$sql = 'SELECT p.id, p.poster, p.poster_id, p.posted, p.edited
|
$query = 'SELECT p.id, p.poster, p.poster_id, p.posted, p.edited
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
WHERE p.topic_id=?i:tid
|
WHERE p.topic_id=?i:tid
|
||||||
ORDER BY p.id DESC
|
ORDER BY p.id DESC
|
||||||
LIMIT 1';
|
LIMIT 1';
|
||||||
|
|
||||||
$result = $this->c->DB->query($sql, $vars)->fetch();
|
$result = $this->c->DB->query($query, $vars)->fetch();
|
||||||
|
|
||||||
$this->model->last_post_id = $result['id'];
|
$this->model->last_post_id = $result['id'];
|
||||||
$this->model->last_poster = $result['poster'];
|
$this->model->last_poster = $result['poster'];
|
||||||
|
|
|
@ -76,33 +76,36 @@ class Delete extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':forums' => \array_keys($forums),
|
':forums' => \array_keys($forums),
|
||||||
];
|
];
|
||||||
$sql = 'SELECT p.poster_id
|
$query = 'SELECT p.poster_id
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
INNER JOIN ::posts AS p ON t.first_post_id=p.id
|
INNER JOIN ::posts AS p ON t.first_post_id=p.id
|
||||||
WHERE t.forum_id IN (?ai:forums) AND t.moved_to=0
|
WHERE t.forum_id IN (?ai:forums) AND t.moved_to=0
|
||||||
GROUP BY p.poster_id';
|
GROUP BY p.poster_id';
|
||||||
$usersUpd = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
|
||||||
|
$usersUpd = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
}
|
}
|
||||||
if ($topics) {
|
if ($topics) {
|
||||||
$vars = [
|
$vars = [
|
||||||
':topics' => \array_keys($topics),
|
':topics' => \array_keys($topics),
|
||||||
];
|
];
|
||||||
$sql = 'SELECT p.poster_id
|
$query = 'SELECT p.poster_id
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
INNER JOIN ::posts AS p ON t.first_post_id=p.id
|
INNER JOIN ::posts AS p ON t.first_post_id=p.id
|
||||||
WHERE t.id IN (?ai:topics) AND t.moved_to=0
|
WHERE t.id IN (?ai:topics) AND t.moved_to=0
|
||||||
GROUP BY p.poster_id';
|
GROUP BY p.poster_id';
|
||||||
$usersUpd = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
|
||||||
|
$usersUpd = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
}
|
}
|
||||||
if ($usersDel) {
|
if ($usersDel) {
|
||||||
$vars = [
|
$vars = [
|
||||||
':users' => $usersDel,
|
':users' => $usersDel,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT t.id, t.forum_id
|
$query = 'SELECT t.id, t.forum_id
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
INNER JOIN ::posts AS p ON t.first_post_id=p.id
|
INNER JOIN ::posts AS p ON t.first_post_id=p.id
|
||||||
WHERE p.poster_id IN (?ai:users)';
|
WHERE p.poster_id IN (?ai:users)';
|
||||||
$topics = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_KEY_PAIR); //????
|
|
||||||
|
$topics = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_KEY_PAIR); //????
|
||||||
|
|
||||||
if ($topics) {
|
if ($topics) {
|
||||||
foreach ($topics as $value) { // ????
|
foreach ($topics as $value) { // ????
|
||||||
|
@ -124,51 +127,63 @@ class Delete extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':users' => $users,
|
':users' => $users,
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::mark_of_topic
|
$query = 'DELETE
|
||||||
|
FROM ::mark_of_topic
|
||||||
WHERE uid IN (?ai:users)';
|
WHERE uid IN (?ai:users)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
if ($usersToGuest) {
|
if ($usersToGuest) {
|
||||||
$vars = [
|
$vars = [
|
||||||
':users' => $usersToGuest,
|
':users' => $usersToGuest,
|
||||||
];
|
];
|
||||||
$sql = 'UPDATE ::topics
|
$query = 'UPDATE ::topics
|
||||||
SET poster_id=1
|
SET poster_id=1
|
||||||
WHERE poster_id IN (?ai:users)';
|
WHERE poster_id IN (?ai:users)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
|
||||||
$sql = 'UPDATE ::topics
|
$this->c->DB->exec($query, $vars);
|
||||||
|
|
||||||
|
$query = 'UPDATE ::topics
|
||||||
SET last_poster_id=1
|
SET last_poster_id=1
|
||||||
WHERE last_poster_id IN (?ai:users)';
|
WHERE last_poster_id IN (?ai:users)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
if ($forums) {
|
if ($forums) {
|
||||||
$vars = [
|
$vars = [
|
||||||
':forums' => \array_keys($forums),
|
':forums' => \array_keys($forums),
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::mark_of_topic
|
$query = 'DELETE
|
||||||
|
FROM ::mark_of_topic
|
||||||
WHERE tid IN (
|
WHERE tid IN (
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM ::topics
|
FROM ::topics
|
||||||
WHERE forum_id IN (?ai:forums)
|
WHERE forum_id IN (?ai:forums)
|
||||||
)';
|
)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
|
||||||
$sql = 'DELETE FROM ::topics
|
$this->c->DB->exec($query, $vars);
|
||||||
|
|
||||||
|
$query = 'DELETE
|
||||||
|
FROM ::topics
|
||||||
WHERE forum_id IN (?ai:forums)';
|
WHERE forum_id IN (?ai:forums)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
if ($topics) {
|
if ($topics) {
|
||||||
$vars = [
|
$vars = [
|
||||||
':topics' => \array_keys($topics),
|
':topics' => \array_keys($topics),
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::mark_of_topic
|
$query = 'DELETE
|
||||||
|
FROM ::mark_of_topic
|
||||||
WHERE tid IN (?ai:topics)';
|
WHERE tid IN (?ai:topics)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
|
||||||
$sql = 'DELETE FROM ::topics
|
$this->c->DB->exec($query, $vars);
|
||||||
|
|
||||||
|
$query = 'DELETE
|
||||||
|
FROM ::topics
|
||||||
WHERE id IN (?ai:topics)';
|
WHERE id IN (?ai:topics)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
|
|
||||||
foreach ($parents as $forum) {
|
foreach ($parents as $forum) {
|
||||||
$this->c->forums->update($forum->calcStat());
|
$this->c->forums->update($forum->calcStat());
|
||||||
|
|
|
@ -15,23 +15,24 @@ class Load extends Action
|
||||||
protected function getSql(string $where, bool $full): string
|
protected function getSql(string $where, bool $full): string
|
||||||
{
|
{
|
||||||
if ($this->c->user->isGuest) {
|
if ($this->c->user->isGuest) {
|
||||||
$sql = 'SELECT t.*
|
$query = 'SELECT t.*
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
WHERE ' . $where;
|
WHERE ' . $where;
|
||||||
} elseif ($full) {
|
} elseif ($full) {
|
||||||
$sql = 'SELECT t.*, s.user_id AS is_subscribed, mof.mf_mark_all_read, mot.mt_last_visit, mot.mt_last_read
|
$query = 'SELECT t.*, s.user_id AS is_subscribed, mof.mf_mark_all_read, mot.mt_last_visit, mot.mt_last_read
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
LEFT JOIN ::topic_subscriptions AS s ON (t.id=s.topic_id AND s.user_id=?i:uid)
|
LEFT JOIN ::topic_subscriptions AS s ON (t.id=s.topic_id AND s.user_id=?i:uid)
|
||||||
LEFT JOIN ::mark_of_forum AS mof ON (mof.uid=?i:uid AND t.forum_id=mof.fid)
|
LEFT JOIN ::mark_of_forum AS mof ON (mof.uid=?i:uid AND t.forum_id=mof.fid)
|
||||||
LEFT JOIN ::mark_of_topic AS mot ON (mot.uid=?i:uid AND t.id=mot.tid)
|
LEFT JOIN ::mark_of_topic AS mot ON (mot.uid=?i:uid AND t.id=mot.tid)
|
||||||
WHERE ' . $where;
|
WHERE ' . $where;
|
||||||
} else {
|
} else {
|
||||||
$sql = 'SELECT t.*, mot.mt_last_visit, mot.mt_last_read
|
$query = 'SELECT t.*, mot.mt_last_visit, mot.mt_last_read
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
LEFT JOIN ::mark_of_topic AS mot ON (mot.uid=?i:uid AND t.id=mot.tid)
|
LEFT JOIN ::mark_of_topic AS mot ON (mot.uid=?i:uid AND t.id=mot.tid)
|
||||||
WHERE ' . $where;
|
WHERE ' . $where;
|
||||||
}
|
}
|
||||||
return $sql;
|
|
||||||
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,8 +54,9 @@ class Load extends Action
|
||||||
':tid' => $id,
|
':tid' => $id,
|
||||||
':uid' => $this->c->user->id,
|
':uid' => $this->c->user->id,
|
||||||
];
|
];
|
||||||
$sql = $this->getSql('t.id=?i:tid', true);
|
$query = $this->getSql('t.id=?i:tid', true);
|
||||||
$data = $this->c->DB->query($sql, $vars)->fetch();
|
|
||||||
|
$data = $this->c->DB->query($query, $vars)->fetch();
|
||||||
|
|
||||||
// тема отсутствует или недоступна
|
// тема отсутствует или недоступна
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
|
@ -94,8 +96,9 @@ class Load extends Action
|
||||||
':ids' => $ids,
|
':ids' => $ids,
|
||||||
':uid' => $this->c->user->id,
|
':uid' => $this->c->user->id,
|
||||||
];
|
];
|
||||||
$sql = $this->getSql('t.id IN (?ai:ids)', $full);
|
$query = $this->getSql('t.id IN (?ai:ids)', $full);
|
||||||
$stmt = $this->c->DB->query($sql, $vars);
|
|
||||||
|
$stmt = $this->c->DB->query($query, $vars);
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
while ($row = $stmt->fetch()) {
|
while ($row = $stmt->fetch()) {
|
||||||
|
|
|
@ -57,19 +57,21 @@ class Merge extends Action
|
||||||
'end' => "[/from]\n",
|
'end' => "[/from]\n",
|
||||||
'topics' => $ids,
|
'topics' => $ids,
|
||||||
];
|
];
|
||||||
$sql = 'UPDATE ::posts AS p, ::topics as t
|
$query = 'UPDATE ::posts AS p, ::topics as t
|
||||||
SET p.message=CONCAT(?s:start, t.subject, ?s:end, p.message)
|
SET p.message=CONCAT(?s:start, t.subject, ?s:end, p.message)
|
||||||
WHERE p.topic_id IN (?ai:topics) AND t.id=p.topic_id';
|
WHERE p.topic_id IN (?ai:topics) AND t.id=p.topic_id';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
|
|
||||||
$vars = [
|
$vars = [
|
||||||
'id' => $firstTopic->id,
|
'id' => $firstTopic->id,
|
||||||
'topics' => $ids,
|
'topics' => $ids,
|
||||||
];
|
];
|
||||||
$sql = 'UPDATE ::posts AS p
|
$query = 'UPDATE ::posts AS p
|
||||||
SET p.topic_id=?i:id
|
SET p.topic_id=?i:id
|
||||||
WHERE p.topic_id IN (?ai:topics)';
|
WHERE p.topic_id IN (?ai:topics)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
|
|
||||||
// добавить перенос подписок на первую тему?
|
// добавить перенос подписок на первую тему?
|
||||||
|
|
||||||
|
@ -82,10 +84,11 @@ class Merge extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
'topics' => $ids,
|
'topics' => $ids,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT t.id
|
$query = 'SELECT t.id
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
WHERE t.moved_to IN (?ai:topics)';
|
WHERE t.moved_to IN (?ai:topics)';
|
||||||
$linkTopics = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
|
||||||
|
$linkTopics = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
foreach ($linkTopics as $topic) {
|
foreach ($linkTopics as $topic) {
|
||||||
$topic->moved_to = $firstTopic->id;
|
$topic->moved_to = $firstTopic->id;
|
||||||
|
|
|
@ -69,7 +69,13 @@ class Model extends DataModel
|
||||||
*/
|
*/
|
||||||
protected function getlink(): string
|
protected function getlink(): string
|
||||||
{
|
{
|
||||||
return $this->c->Router->link('Topic', ['id' => $this->moved_to ?: $this->id, 'name' => \ForkBB\cens($this->subject)]);
|
return $this->c->Router->link(
|
||||||
|
'Topic',
|
||||||
|
[
|
||||||
|
'id' => $this->moved_to ?: $this->id,
|
||||||
|
'name' => \ForkBB\cens($this->subject),
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,7 +85,12 @@ class Model extends DataModel
|
||||||
*/
|
*/
|
||||||
protected function getlinkReply(): string
|
protected function getlinkReply(): string
|
||||||
{
|
{
|
||||||
return $this->c->Router->link('NewReply', ['id' => $this->id]);
|
return $this->c->Router->link(
|
||||||
|
'NewReply',
|
||||||
|
[
|
||||||
|
'id' => $this->id,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,7 +103,12 @@ class Model extends DataModel
|
||||||
if ($this->moved_to) {
|
if ($this->moved_to) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return $this->c->Router->link('ViewPost', ['id' => $this->last_post_id]);
|
return $this->c->Router->link(
|
||||||
|
'ViewPost',
|
||||||
|
[
|
||||||
|
'id' => $this->last_post_id,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +119,12 @@ class Model extends DataModel
|
||||||
*/
|
*/
|
||||||
protected function getlinkNew(): string
|
protected function getlinkNew(): string
|
||||||
{
|
{
|
||||||
return $this->c->Router->link('TopicViewNew', ['id' => $this->id]);
|
return $this->c->Router->link(
|
||||||
|
'TopicViewNew',
|
||||||
|
[
|
||||||
|
'id' => $this->id,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,7 +132,12 @@ class Model extends DataModel
|
||||||
*/
|
*/
|
||||||
protected function getlinkUnread(): string
|
protected function getlinkUnread(): string
|
||||||
{
|
{
|
||||||
return $this->c->Router->link('TopicViewUnread', ['id' => $this->id]);
|
return $this->c->Router->link(
|
||||||
|
'TopicViewUnread',
|
||||||
|
[
|
||||||
|
'id' => $this->id,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -176,9 +202,11 @@ class Model extends DataModel
|
||||||
':tid' => $this->id,
|
':tid' => $this->id,
|
||||||
':visit' => $this->hasNew,
|
':visit' => $this->hasNew,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT MIN(p.id) FROM ::posts AS p WHERE p.topic_id=?i:tid AND p.posted>?i:visit';
|
$query = 'SELECT MIN(p.id)
|
||||||
|
FROM ::posts AS p
|
||||||
|
WHERE p.topic_id=?i:tid AND p.posted>?i:visit';
|
||||||
|
|
||||||
$pid = $this->c->DB->query($sql, $vars)->fetchColumn();
|
$pid = $this->c->DB->query($query, $vars)->fetchColumn();
|
||||||
|
|
||||||
return $pid ?: 0;
|
return $pid ?: 0;
|
||||||
}
|
}
|
||||||
|
@ -198,9 +226,11 @@ class Model extends DataModel
|
||||||
':tid' => $this->id,
|
':tid' => $this->id,
|
||||||
':visit' => $this->hasUnread,
|
':visit' => $this->hasUnread,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT MIN(p.id) FROM ::posts AS p WHERE p.topic_id=?i:tid AND p.posted>?i:visit';
|
$query = 'SELECT MIN(p.id)
|
||||||
|
FROM ::posts AS p
|
||||||
|
WHERE p.topic_id=?i:tid AND p.posted>?i:visit';
|
||||||
|
|
||||||
$pid = $this->c->DB->query($sql, $vars)->fetchColumn();
|
$pid = $this->c->DB->query($query, $vars)->fetchColumn();
|
||||||
|
|
||||||
return $pid ?: 0;
|
return $pid ?: 0;
|
||||||
}
|
}
|
||||||
|
@ -269,12 +299,13 @@ class Model extends DataModel
|
||||||
':offset' => ($this->page - 1) * $this->c->user->disp_posts,
|
':offset' => ($this->page - 1) * $this->c->user->disp_posts,
|
||||||
':rows' => $this->c->user->disp_posts,
|
':rows' => $this->c->user->disp_posts,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT p.id
|
$query = 'SELECT p.id
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
WHERE p.topic_id=?i:tid
|
WHERE p.topic_id=?i:tid
|
||||||
ORDER BY p.id
|
ORDER BY p.id
|
||||||
LIMIT ?i:offset, ?i:rows';
|
LIMIT ?i:offset, ?i:rows';
|
||||||
$list = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
|
||||||
|
$list = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
! empty($list)
|
! empty($list)
|
||||||
|
@ -309,12 +340,13 @@ class Model extends DataModel
|
||||||
':tid' => $this->id,
|
':tid' => $this->id,
|
||||||
':rows' => $this->c->config->o_topic_review,
|
':rows' => $this->c->config->o_topic_review,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT p.id
|
$query = 'SELECT p.id
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
WHERE p.topic_id=?i:tid
|
WHERE p.topic_id=?i:tid
|
||||||
ORDER BY p.id DESC
|
ORDER BY p.id DESC
|
||||||
LIMIT 0, ?i:rows';
|
LIMIT 0, ?i:rows';
|
||||||
$this->idsList = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
|
||||||
|
$this->idsList = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
return empty($this->idsList) ? [] : $this->c->posts->view($this, true);
|
return empty($this->idsList) ? [] : $this->c->posts->view($this, true);
|
||||||
}
|
}
|
||||||
|
@ -330,12 +362,12 @@ class Model extends DataModel
|
||||||
':tid' => $this->id,
|
':tid' => $this->id,
|
||||||
':pid' => $pid,
|
':pid' => $pid,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT COUNT(p.id) AS num
|
$query = 'SELECT COUNT(p.id) AS num
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
INNER JOIN ::posts AS j ON (j.topic_id=?i:tid AND j.id=?i:pid)
|
INNER JOIN ::posts AS j ON (j.topic_id=?i:tid AND j.id=?i:pid)
|
||||||
WHERE p.topic_id=?i:tid AND p.id<?i:pid'; //???? может на два запроса разбить?
|
WHERE p.topic_id=?i:tid AND p.id<?i:pid'; //???? может на два запроса разбить?
|
||||||
|
|
||||||
$result = $this->c->DB->query($sql, $vars)->fetch();
|
$result = $this->c->DB->query($query, $vars)->fetch();
|
||||||
|
|
||||||
$this->page = empty($result) ? null : (int) \ceil(($result['num'] + 1) / $this->c->user->disp_posts);
|
$this->page = empty($result) ? null : (int) \ceil(($result['num'] + 1) / $this->c->user->disp_posts);
|
||||||
}
|
}
|
||||||
|
@ -358,9 +390,11 @@ class Model extends DataModel
|
||||||
$vars = [
|
$vars = [
|
||||||
':tid' => $this->id,
|
':tid' => $this->id,
|
||||||
];
|
];
|
||||||
$sql = 'UPDATE ::topics SET num_views=num_views+1 WHERE id=?i:tid';
|
$query = 'UPDATE ::topics
|
||||||
|
SET num_views=num_views+1
|
||||||
|
WHERE id=?i:tid';
|
||||||
|
|
||||||
$this->c->DB->query($sql, $vars);
|
$this->c->DB->query($query, $vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -398,19 +432,22 @@ class Model extends DataModel
|
||||||
empty($this->mt_last_read)
|
empty($this->mt_last_read)
|
||||||
&& empty($this->mt_last_visit)
|
&& empty($this->mt_last_visit)
|
||||||
) {
|
) {
|
||||||
$sql = 'INSERT INTO ::mark_of_topic (uid, tid, mt_last_visit, mt_last_read)
|
$query = 'INSERT INTO ::mark_of_topic (uid, tid, mt_last_visit, mt_last_read)
|
||||||
SELECT ?i:uid, ?i:tid, ?i:visit, ?i:read
|
SELECT ?i:uid, ?i:tid, ?i:visit, ?i:read
|
||||||
FROM ::groups
|
FROM ::groups
|
||||||
WHERE NOT EXISTS (SELECT 1
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
FROM ::mark_of_topic
|
FROM ::mark_of_topic
|
||||||
WHERE uid=?i:uid AND tid=?i:tid)
|
WHERE uid=?i:uid AND tid=?i:tid
|
||||||
|
)
|
||||||
LIMIT 1';
|
LIMIT 1';
|
||||||
} else {
|
} else {
|
||||||
$sql = 'UPDATE ::mark_of_topic
|
$query = 'UPDATE ::mark_of_topic
|
||||||
SET mt_last_visit=?i:visit, mt_last_read=?i:read
|
SET mt_last_visit=?i:visit, mt_last_read=?i:read
|
||||||
WHERE uid=?i:uid AND tid=?i:tid';
|
WHERE uid=?i:uid AND tid=?i:tid';
|
||||||
}
|
}
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,11 +49,12 @@ class View extends Action
|
||||||
':uid' => $this->c->user->id,
|
':uid' => $this->c->user->id,
|
||||||
':ids' => $arg->idsList,
|
':ids' => $arg->idsList,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT p.topic_id
|
$query = 'SELECT p.topic_id
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
WHERE p.poster_id=?i:uid AND p.topic_id IN (?ai:ids)
|
WHERE p.poster_id=?i:uid AND p.topic_id IN (?ai:ids)
|
||||||
GROUP BY p.topic_id';
|
GROUP BY p.topic_id';
|
||||||
$dots = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
|
||||||
|
$dots = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
foreach ($dots as $id) {
|
foreach ($dots as $id) {
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -17,8 +17,10 @@ class AdminsIds extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':gid' => $this->c->GROUP_ADMIN,
|
':gid' => $this->c->GROUP_ADMIN,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT u.id FROM ::users AS u WHERE u.group_id=?i:gid';
|
$query = 'SELECT u.id
|
||||||
|
FROM ::users AS u
|
||||||
|
WHERE u.group_id=?i:gid';
|
||||||
|
|
||||||
return $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
return $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,10 +69,11 @@ class ChangeGroup extends Action
|
||||||
':new' => $newGroupId,
|
':new' => $newGroupId,
|
||||||
':ids' => $ids,
|
':ids' => $ids,
|
||||||
];
|
];
|
||||||
$sql = 'UPDATE ::users AS u
|
$query = 'UPDATE ::users AS u
|
||||||
SET u.group_id = ?i:new
|
SET u.group_id = ?i:new
|
||||||
WHERE u.id IN (?ai:ids)';
|
WHERE u.id IN (?ai:ids)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
|
|
||||||
if ($adminPresent) {
|
if ($adminPresent) {
|
||||||
$this->c->admins->reset();
|
$this->c->admins->reset();
|
||||||
|
|
|
@ -67,9 +67,11 @@ class Delete extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':users' => $ids,
|
':users' => $ids,
|
||||||
];
|
];
|
||||||
$sql = 'DELETE FROM ::users
|
$query = 'DELETE
|
||||||
|
FROM ::users
|
||||||
WHERE id IN (?ai:users)';
|
WHERE id IN (?ai:users)';
|
||||||
$this->c->DB->exec($sql, $vars);
|
|
||||||
|
$this->c->DB->exec($query, $vars);
|
||||||
|
|
||||||
if ($adminPresent) {
|
if ($adminPresent) {
|
||||||
$this->c->admins->reset();
|
$this->c->admins->reset();
|
||||||
|
|
|
@ -98,13 +98,12 @@ class Filter extends Action
|
||||||
}
|
}
|
||||||
|
|
||||||
$where = \implode(' AND ', $where);
|
$where = \implode(' AND ', $where);
|
||||||
|
$query = "SELECT u.id
|
||||||
$sql = "SELECT u.id
|
|
||||||
FROM ::users AS u
|
FROM ::users AS u
|
||||||
WHERE {$where}
|
WHERE {$where}
|
||||||
ORDER BY {$orderBy}";
|
ORDER BY {$orderBy}";
|
||||||
|
|
||||||
$ids = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
$ids = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
return $ids;
|
return $ids;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,12 @@ class Load extends Action
|
||||||
*/
|
*/
|
||||||
protected function getSql(string $where): string
|
protected function getSql(string $where): string
|
||||||
{
|
{
|
||||||
$sql = 'SELECT u.*, g.*
|
$query = 'SELECT u.*, g.*
|
||||||
FROM ::users AS u
|
FROM ::users AS u
|
||||||
LEFT JOIN ::groups AS g ON u.group_id=g.g_id
|
LEFT JOIN ::groups AS g ON u.group_id=g.g_id
|
||||||
WHERE ' . $where;
|
WHERE ' . $where;
|
||||||
return $sql;
|
|
||||||
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,8 +34,9 @@ class Load extends Action
|
||||||
}
|
}
|
||||||
|
|
||||||
$vars = [':id' => $id];
|
$vars = [':id' => $id];
|
||||||
$sql = $this->getSql('u.id=?i:id');
|
$query = $this->getSql('u.id=?i:id');
|
||||||
$data = $this->c->DB->query($sql, $vars)->fetch();
|
|
||||||
|
$data = $this->c->DB->query($query, $vars)->fetch();
|
||||||
|
|
||||||
return empty($data['id']) ? null : $this->manager->create($data);
|
return empty($data['id']) ? null : $this->manager->create($data);
|
||||||
}
|
}
|
||||||
|
@ -56,8 +58,9 @@ class Load extends Action
|
||||||
}
|
}
|
||||||
|
|
||||||
$vars = [':ids' => $ids];
|
$vars = [':ids' => $ids];
|
||||||
$sql = $this->getSql('u.id IN (?ai:ids)');
|
$query = $this->getSql('u.id IN (?ai:ids)');
|
||||||
$data = $this->c->DB->query($sql, $vars)->fetchAll();
|
|
||||||
|
$data = $this->c->DB->query($query, $vars)->fetchAll();
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($data as $row) {
|
foreach ($data as $row) {
|
||||||
|
@ -71,9 +74,9 @@ class Load extends Action
|
||||||
*
|
*
|
||||||
* @throws ForkException
|
* @throws ForkException
|
||||||
*/
|
*/
|
||||||
protected function returnUser(string $sql, array $vars): ?User
|
protected function returnUser(string $query, array $vars): ?User
|
||||||
{
|
{
|
||||||
$data = $this->c->DB->query($sql, $vars)->fetchAll();
|
$data = $this->c->DB->query($query, $vars)->fetchAll();
|
||||||
|
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -91,9 +94,9 @@ class Load extends Action
|
||||||
{
|
{
|
||||||
$where = $caseInsencytive ? 'LOWER(u.username)=LOWER(?s:name)' : 'u.username=?s:name';
|
$where = $caseInsencytive ? 'LOWER(u.username)=LOWER(?s:name)' : 'u.username=?s:name';
|
||||||
$vars = [':name' => $name];
|
$vars = [':name' => $name];
|
||||||
$sql = $this->getSql($where);
|
$query = $this->getSql($where);
|
||||||
|
|
||||||
return $this->returnUser($sql, $vars);
|
return $this->returnUser($query, $vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,8 +105,8 @@ class Load extends Action
|
||||||
public function loadByEmail(string $email): ?User
|
public function loadByEmail(string $email): ?User
|
||||||
{
|
{
|
||||||
$vars = [':email' => $this->c->NormEmail->normalize($email)];
|
$vars = [':email' => $this->c->NormEmail->normalize($email)];
|
||||||
$sql = $this->getSql('u.email_normal=?s:email');
|
$query = $this->getSql('u.email_normal=?s:email');
|
||||||
|
|
||||||
return $this->returnUser($sql, $vars);
|
return $this->returnUser($query, $vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,13 @@ class Model extends DataModel
|
||||||
if ($this->isGuest) {
|
if ($this->isGuest) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return $this->c->Router->link('User', ['id' => $this->id, 'name' => $this->username]);
|
return $this->c->Router->link(
|
||||||
|
'User',
|
||||||
|
[
|
||||||
|
'id' => $this->id,
|
||||||
|
'name' => $this->username,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,14 +371,20 @@ class Model extends DataModel
|
||||||
&& $this->id !== $post->user->id //????
|
&& $this->id !== $post->user->id //????
|
||||||
&& 0 < $post->user->g_promote_min_posts * $post->user->g_promote_next_group
|
&& 0 < $post->user->g_promote_min_posts * $post->user->g_promote_next_group
|
||||||
) {
|
) {
|
||||||
return $this->c->Router->link('AdminUserPromote', [
|
return $this->c->Router->link(
|
||||||
|
'AdminUserPromote',
|
||||||
|
[
|
||||||
'uid' => $post->user->id,
|
'uid' => $post->user->id,
|
||||||
'pid' => $post->id,
|
'pid' => $post->id,
|
||||||
'token' => $this->c->Csrf->create('AdminUserPromote', [
|
'token' => $this->c->Csrf->create(
|
||||||
|
'AdminUserPromote',
|
||||||
|
[
|
||||||
'uid' => $post->user->id,
|
'uid' => $post->user->id,
|
||||||
'pid' => $post->id,
|
'pid' => $post->id,
|
||||||
]),
|
]
|
||||||
]);
|
),
|
||||||
|
]
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,11 @@ class Promote extends Action
|
||||||
':old' => $args[0]->g_id,
|
':old' => $args[0]->g_id,
|
||||||
':new' => $args[1]->g_id,
|
':new' => $args[1]->g_id,
|
||||||
];
|
];
|
||||||
$sql = 'UPDATE ::users
|
$query = 'UPDATE ::users
|
||||||
SET group_id=?i:new
|
SET group_id=?i:new
|
||||||
WHERE group_id=?i:old';
|
WHERE group_id=?i:old';
|
||||||
return $this->c->DB->exec($sql, $vars);
|
|
||||||
|
return $this->c->DB->exec($query, $vars);
|
||||||
// продвижение всех пользователей в группе 0
|
// продвижение всех пользователей в группе 0
|
||||||
} elseif (1 == $count) {
|
} elseif (1 == $count) {
|
||||||
$vars = [
|
$vars = [
|
||||||
|
@ -38,10 +39,11 @@ class Promote extends Action
|
||||||
':new' => $args[0]->g_promote_next_group,
|
':new' => $args[0]->g_promote_next_group,
|
||||||
':count' => $args[0]->g_promote_min_posts,
|
':count' => $args[0]->g_promote_min_posts,
|
||||||
];
|
];
|
||||||
$sql = 'UPDATE ::users
|
$query = 'UPDATE ::users
|
||||||
SET group_id=?i:new
|
SET group_id=?i:new
|
||||||
WHERE group_id=?i:old AND num_posts>=?i:count';
|
WHERE group_id=?i:old AND num_posts>=?i:count';
|
||||||
return $this->c->DB->exec($sql, $vars);
|
|
||||||
|
return $this->c->DB->exec($query, $vars);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Illegal number of parameters ({$count})");
|
throw new RuntimeException("Illegal number of parameters ({$count})");
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ class UpdateCountPosts extends Action
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'UPDATE ::users AS u
|
$query = 'UPDATE ::users AS u
|
||||||
SET u.num_posts = (
|
SET u.num_posts = (
|
||||||
SELECT COUNT(p.id)
|
SELECT COUNT(p.id)
|
||||||
FROM ::posts AS p
|
FROM ::posts AS p
|
||||||
|
@ -54,6 +54,6 @@ class UpdateCountPosts extends Action
|
||||||
)
|
)
|
||||||
WHERE ' . $where;
|
WHERE ' . $where;
|
||||||
|
|
||||||
$this->c->DB->exec($sql, $vars);
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ class UpdateCountTopics extends Action
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'UPDATE ::users AS u
|
$query = 'UPDATE ::users AS u
|
||||||
SET u.num_topics = (
|
SET u.num_topics = (
|
||||||
SELECT COUNT(t.id)
|
SELECT COUNT(t.id)
|
||||||
FROM ::topics AS t
|
FROM ::topics AS t
|
||||||
|
@ -53,6 +53,6 @@ class UpdateCountTopics extends Action
|
||||||
)
|
)
|
||||||
WHERE ' . $where;
|
WHERE ' . $where;
|
||||||
|
|
||||||
$this->c->DB->exec($sql, $vars);
|
$this->c->DB->exec($query, $vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,10 @@ class UsersNumber extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':gid' => $group->g_id,
|
':gid' => $group->g_id,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT COUNT(u.id) FROM ::users AS u WHERE u.group_id=?i:gid';
|
$query = 'SELECT COUNT(u.id)
|
||||||
|
FROM ::users AS u
|
||||||
|
WHERE u.group_id=?i:gid';
|
||||||
|
|
||||||
return $this->c->DB->query($sql, $vars)->fetchColumn();
|
return $this->c->DB->query($query, $vars)->fetchColumn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue