Use shorthand database operations everywhere.
This commit is contained in:
parent
af4ec2ac45
commit
0a8a4d3b99
24 changed files with 111 additions and 148 deletions
14
misuzu.php
14
misuzu.php
|
@ -34,10 +34,8 @@ if (PHP_SAPI === 'cli') {
|
||||||
if ($argv[0] === basename(__FILE__)) {
|
if ($argv[0] === basename(__FILE__)) {
|
||||||
switch ($argv[1] ?? null) {
|
switch ($argv[1] ?? null) {
|
||||||
case 'cron':
|
case 'cron':
|
||||||
$db = Database::connection();
|
|
||||||
|
|
||||||
// Ensure main role exists.
|
// Ensure main role exists.
|
||||||
$db->query("
|
Database::exec("
|
||||||
INSERT IGNORE INTO `msz_roles`
|
INSERT IGNORE INTO `msz_roles`
|
||||||
(`role_id`, `role_name`, `role_hierarchy`, `role_colour`, `role_description`, `created_at`)
|
(`role_id`, `role_name`, `role_hierarchy`, `role_colour`, `role_description`, `created_at`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -45,7 +43,7 @@ if (PHP_SAPI === 'cli') {
|
||||||
");
|
");
|
||||||
|
|
||||||
// Ensures all users are in the main role.
|
// Ensures all users are in the main role.
|
||||||
$db->query('
|
Database::exec('
|
||||||
INSERT INTO `msz_user_roles`
|
INSERT INTO `msz_user_roles`
|
||||||
(`user_id`, `role_id`)
|
(`user_id`, `role_id`)
|
||||||
SELECT `user_id`, 1 FROM `msz_users` as u
|
SELECT `user_id`, 1 FROM `msz_users` as u
|
||||||
|
@ -58,7 +56,7 @@ if (PHP_SAPI === 'cli') {
|
||||||
');
|
');
|
||||||
|
|
||||||
// Ensures all display_role values are correct with `msz_user_roles`
|
// Ensures all display_role values are correct with `msz_user_roles`
|
||||||
$db->query('
|
Database::exec('
|
||||||
UPDATE `msz_users` as u
|
UPDATE `msz_users` as u
|
||||||
SET `display_role` = (
|
SET `display_role` = (
|
||||||
SELECT ur.`role_id`
|
SELECT ur.`role_id`
|
||||||
|
@ -152,9 +150,7 @@ if (PHP_SAPI === 'cli') {
|
||||||
$app->startSession((int)$_COOKIE['msz_uid'], $_COOKIE['msz_sid']);
|
$app->startSession((int)$_COOKIE['msz_uid'], $_COOKIE['msz_sid']);
|
||||||
|
|
||||||
if ($app->hasActiveSession()) {
|
if ($app->hasActiveSession()) {
|
||||||
$db = Database::connection();
|
$bumpUserLast = Database::prepare('
|
||||||
|
|
||||||
$bumpUserLast = $db->prepare('
|
|
||||||
UPDATE `msz_users` SET
|
UPDATE `msz_users` SET
|
||||||
`last_seen` = NOW(),
|
`last_seen` = NOW(),
|
||||||
`last_ip` = INET6_ATON(:last_ip)
|
`last_ip` = INET6_ATON(:last_ip)
|
||||||
|
@ -164,7 +160,7 @@ if (PHP_SAPI === 'cli') {
|
||||||
$bumpUserLast->bindValue('user_id', $app->getUserId());
|
$bumpUserLast->bindValue('user_id', $app->getUserId());
|
||||||
$bumpUserLast->execute();
|
$bumpUserLast->execute();
|
||||||
|
|
||||||
$getUserDisplayInfo = $db->prepare('
|
$getUserDisplayInfo = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
u.`user_id`, u.`username`,
|
u.`user_id`, u.`username`,
|
||||||
COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `colour`
|
COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `colour`
|
||||||
|
|
|
@ -6,7 +6,6 @@ use Misuzu\Users\Session;
|
||||||
|
|
||||||
require_once __DIR__ . '/../misuzu.php';
|
require_once __DIR__ . '/../misuzu.php';
|
||||||
|
|
||||||
$db = Database::connection();
|
|
||||||
$config = $app->getConfig();
|
$config = $app->getConfig();
|
||||||
$templating = $app->getTemplating();
|
$templating = $app->getTemplating();
|
||||||
|
|
||||||
|
@ -76,7 +75,7 @@ switch ($authMode) {
|
||||||
$username = $_POST['username'] ?? '';
|
$username = $_POST['username'] ?? '';
|
||||||
$password = $_POST['password'] ?? '';
|
$password = $_POST['password'] ?? '';
|
||||||
|
|
||||||
$getUser = $db->prepare('
|
$getUser = Database::prepare('
|
||||||
SELECT `user_id`, `password`
|
SELECT `user_id`, `password`
|
||||||
FROM `msz_users`
|
FROM `msz_users`
|
||||||
WHERE LOWER(`email`) = LOWER(:email)
|
WHERE LOWER(`email`) = LOWER(:email)
|
||||||
|
|
|
@ -3,7 +3,6 @@ use Misuzu\Database;
|
||||||
|
|
||||||
require_once __DIR__ . '/../misuzu.php';
|
require_once __DIR__ . '/../misuzu.php';
|
||||||
|
|
||||||
$db = Database::connection();
|
|
||||||
$tpl = $app->getTemplating();
|
$tpl = $app->getTemplating();
|
||||||
|
|
||||||
$changelogOffset = max((int)($_GET['o'] ?? 0), 0);
|
$changelogOffset = max((int)($_GET['o'] ?? 0), 0);
|
||||||
|
@ -20,7 +19,7 @@ $tpl->vars([
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($changelogChange > 0) {
|
if ($changelogChange > 0) {
|
||||||
$getChange = $db->prepare('
|
$getChange = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
c.`change_id`, c.`change_created`, c.`change_log`, c.`change_text`,
|
c.`change_id`, c.`change_created`, c.`change_log`, c.`change_text`,
|
||||||
a.`action_name`, a.`action_colour`, a.`action_class`,
|
a.`action_name`, a.`action_colour`, a.`action_class`,
|
||||||
|
@ -43,7 +42,7 @@ if ($changelogChange > 0) {
|
||||||
if (!$change) {
|
if (!$change) {
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
} else {
|
} else {
|
||||||
$getTags = $db->prepare('
|
$getTags = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
t.`tag_id`, t.`tag_name`, t.`tag_description`
|
t.`tag_id`, t.`tag_name`, t.`tag_description`
|
||||||
FROM `msz_changelog_tags` as t
|
FROM `msz_changelog_tags` as t
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
use Misuzu\Database;
|
|
||||||
|
|
||||||
require_once __DIR__ . '/../../misuzu.php';
|
require_once __DIR__ . '/../../misuzu.php';
|
||||||
|
|
||||||
$forumId = max((int)($_GET['f'] ?? 0), 0);
|
$forumId = max((int)($_GET['f'] ?? 0), 0);
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
use Misuzu\Database;
|
|
||||||
|
|
||||||
require_once __DIR__ . '/../../misuzu.php';
|
require_once __DIR__ . '/../../misuzu.php';
|
||||||
|
|
||||||
$categories = forum_get_root_categories();
|
$categories = forum_get_root_categories();
|
||||||
|
|
|
@ -4,7 +4,6 @@ use Misuzu\Net\IPAddress;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../misuzu.php';
|
require_once __DIR__ . '/../../misuzu.php';
|
||||||
|
|
||||||
$db = Database::connection();
|
|
||||||
$templating = $app->getTemplating();
|
$templating = $app->getTemplating();
|
||||||
|
|
||||||
if (!$app->hasActiveSession()) {
|
if (!$app->hasActiveSession()) {
|
||||||
|
@ -29,7 +28,7 @@ if (empty($postId) && empty($topicId) && empty($forumId)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($postId)) {
|
if (!empty($postId)) {
|
||||||
$getPost = $db->prepare('
|
$getPost = Database::prepare('
|
||||||
SELECT `post_id`, `topic_id`
|
SELECT `post_id`, `topic_id`
|
||||||
FROM `msz_forum_posts`
|
FROM `msz_forum_posts`
|
||||||
WHERE `post_id` = :post_id
|
WHERE `post_id` = :post_id
|
||||||
|
@ -43,7 +42,7 @@ if (!empty($postId)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($topicId)) {
|
if (!empty($topicId)) {
|
||||||
$getTopic = $db->prepare('
|
$getTopic = Database::prepare('
|
||||||
SELECT `topic_id`, `forum_id`, `topic_title`, `topic_locked`
|
SELECT `topic_id`, `forum_id`, `topic_title`, `topic_locked`
|
||||||
FROM `msz_forum_topics`
|
FROM `msz_forum_topics`
|
||||||
WHERE `topic_id` = :topic_id
|
WHERE `topic_id` = :topic_id
|
||||||
|
@ -57,7 +56,7 @@ if (!empty($topicId)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($forumId)) {
|
if (!empty($forumId)) {
|
||||||
$getForum = $db->prepare('
|
$getForum = Database::prepare('
|
||||||
SELECT `forum_id`, `forum_name`, `forum_type`, `forum_archived`
|
SELECT `forum_id`, `forum_name`, `forum_type`, `forum_archived`
|
||||||
FROM `msz_forum_categories`
|
FROM `msz_forum_categories`
|
||||||
WHERE `forum_id` = :forum_id
|
WHERE `forum_id` = :forum_id
|
||||||
|
|
|
@ -3,7 +3,6 @@ use Misuzu\Database;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../misuzu.php';
|
require_once __DIR__ . '/../../misuzu.php';
|
||||||
|
|
||||||
$db = Database::connection();
|
|
||||||
$tpl = $app->getTemplating();
|
$tpl = $app->getTemplating();
|
||||||
|
|
||||||
$changelogPerms = perms_get_user(MSZ_PERMS_CHANGELOG, $app->getUserId());
|
$changelogPerms = perms_get_user(MSZ_PERMS_CHANGELOG, $app->getUserId());
|
||||||
|
@ -19,12 +18,12 @@ switch ($_GET['v'] ?? null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$changesTake = 20;
|
$changesTake = 20;
|
||||||
$changesCount = (int)$db->query('
|
$changesCount = (int)Database::query('
|
||||||
SELECT COUNT(`change_id`)
|
SELECT COUNT(`change_id`)
|
||||||
FROM `msz_changelog_changes`
|
FROM `msz_changelog_changes`
|
||||||
')->fetchColumn();
|
')->fetchColumn();
|
||||||
|
|
||||||
$getChanges = $db->prepare('
|
$getChanges = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
c.`change_id`, c.`change_log`, c.`change_created`,
|
c.`change_id`, c.`change_log`, c.`change_created`,
|
||||||
a.`action_name`, a.`action_colour`, a.`action_class`,
|
a.`action_name`, a.`action_colour`, a.`action_class`,
|
||||||
|
@ -44,7 +43,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
$getChanges->bindValue('offset', $queryOffset);
|
$getChanges->bindValue('offset', $queryOffset);
|
||||||
$changes = $getChanges->execute() ? $getChanges->fetchAll(PDO::FETCH_ASSOC) : [];
|
$changes = $getChanges->execute() ? $getChanges->fetchAll(PDO::FETCH_ASSOC) : [];
|
||||||
|
|
||||||
$getTags = $db->prepare('
|
$getTags = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
t.`tag_id`, t.`tag_name`, t.`tag_description`
|
t.`tag_id`, t.`tag_name`, t.`tag_description`
|
||||||
FROM `msz_changelog_change_tags` as ct
|
FROM `msz_changelog_change_tags` as ct
|
||||||
|
@ -78,7 +77,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && tmp_csrf_verify($_POST['csrf'] ?? '')) {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && tmp_csrf_verify($_POST['csrf'] ?? '')) {
|
||||||
if (!empty($_POST['change']) && is_array($_POST['change'])) {
|
if (!empty($_POST['change']) && is_array($_POST['change'])) {
|
||||||
if ($changeId > 0) {
|
if ($changeId > 0) {
|
||||||
$postChange = $db->prepare('
|
$postChange = Database::prepare('
|
||||||
UPDATE `msz_changelog_changes`
|
UPDATE `msz_changelog_changes`
|
||||||
SET `change_log` = :log,
|
SET `change_log` = :log,
|
||||||
`change_text` = :text,
|
`change_text` = :text,
|
||||||
|
@ -89,7 +88,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
');
|
');
|
||||||
$postChange->bindValue('change_id', $changeId);
|
$postChange->bindValue('change_id', $changeId);
|
||||||
} else {
|
} else {
|
||||||
$postChange = $db->prepare('
|
$postChange = Database::prepare('
|
||||||
INSERT INTO `msz_changelog_changes`
|
INSERT INTO `msz_changelog_changes`
|
||||||
(
|
(
|
||||||
`change_log`, `change_text`, `action_id`,
|
`change_log`, `change_text`, `action_id`,
|
||||||
|
@ -114,20 +113,20 @@ switch ($_GET['v'] ?? null) {
|
||||||
$postChange->execute();
|
$postChange->execute();
|
||||||
|
|
||||||
if ($changeId < 1) {
|
if ($changeId < 1) {
|
||||||
header('Location: ?v=change&c=' . $db->lastInsertId());
|
header('Location: ?v=change&c=' . Database::lastInsertId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_POST['add_tag']) && is_numeric($_POST['add_tag'])) {
|
if (!empty($_POST['add_tag']) && is_numeric($_POST['add_tag'])) {
|
||||||
$addTag = $db->prepare('REPLACE INTO `msz_changelog_change_tags` VALUES (:change_id, :tag_id)');
|
$addTag = Database::prepare('REPLACE INTO `msz_changelog_change_tags` VALUES (:change_id, :tag_id)');
|
||||||
$addTag->bindValue('change_id', $changeId);
|
$addTag->bindValue('change_id', $changeId);
|
||||||
$addTag->bindValue('tag_id', $_POST['add_tag']);
|
$addTag->bindValue('tag_id', $_POST['add_tag']);
|
||||||
$addTag->execute();
|
$addTag->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_POST['remove_tag']) && is_numeric($_POST['remove_tag'])) {
|
if (!empty($_POST['remove_tag']) && is_numeric($_POST['remove_tag'])) {
|
||||||
$removeTag = $db->prepare('
|
$removeTag = Database::prepare('
|
||||||
DELETE FROM `msz_changelog_change_tags`
|
DELETE FROM `msz_changelog_change_tags`
|
||||||
WHERE `change_id` = :change_id
|
WHERE `change_id` = :change_id
|
||||||
AND `tag_id` = :tag_id
|
AND `tag_id` = :tag_id
|
||||||
|
@ -138,14 +137,14 @@ switch ($_GET['v'] ?? null) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$actions = $db->query('
|
$actions = Database::query('
|
||||||
SELECT `action_id`, `action_name`
|
SELECT `action_id`, `action_name`
|
||||||
FROM `msz_changelog_actions`
|
FROM `msz_changelog_actions`
|
||||||
')->fetchAll(PDO::FETCH_ASSOC);
|
')->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$tpl->var('changelog_actions', $actions);
|
$tpl->var('changelog_actions', $actions);
|
||||||
|
|
||||||
if ($changeId > 0) {
|
if ($changeId > 0) {
|
||||||
$getChange = $db->prepare('
|
$getChange = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
`change_id`, `change_log`, `change_text`, `user_id`,
|
`change_id`, `change_log`, `change_text`, `user_id`,
|
||||||
`action_id`, `change_created`
|
`action_id`, `change_created`
|
||||||
|
@ -158,7 +157,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
if ($change) {
|
if ($change) {
|
||||||
$tpl->var('edit_change', $change);
|
$tpl->var('edit_change', $change);
|
||||||
|
|
||||||
$assignedTags = $db->prepare('
|
$assignedTags = Database::prepare('
|
||||||
SELECT `tag_id`, `tag_name`
|
SELECT `tag_id`, `tag_name`
|
||||||
FROM `msz_changelog_tags`
|
FROM `msz_changelog_tags`
|
||||||
WHERE `tag_id` IN (
|
WHERE `tag_id` IN (
|
||||||
|
@ -170,7 +169,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
$assignedTags->bindValue('change_id', $change['change_id']);
|
$assignedTags->bindValue('change_id', $change['change_id']);
|
||||||
$assignedTags = $assignedTags->execute() ? $assignedTags->fetchAll(PDO::FETCH_ASSOC) : [];
|
$assignedTags = $assignedTags->execute() ? $assignedTags->fetchAll(PDO::FETCH_ASSOC) : [];
|
||||||
|
|
||||||
$availableTags = $db->prepare('
|
$availableTags = Database::prepare('
|
||||||
SELECT `tag_id`, `tag_name`
|
SELECT `tag_id`, `tag_name`
|
||||||
FROM `msz_changelog_tags`
|
FROM `msz_changelog_tags`
|
||||||
WHERE `tag_archived` IS NULL
|
WHERE `tag_archived` IS NULL
|
||||||
|
@ -204,12 +203,12 @@ switch ($_GET['v'] ?? null) {
|
||||||
|
|
||||||
$tagsTake = 32;
|
$tagsTake = 32;
|
||||||
|
|
||||||
$tagsCount = (int)$db->query('
|
$tagsCount = (int)Database::query('
|
||||||
SELECT COUNT(`tag_id`)
|
SELECT COUNT(`tag_id`)
|
||||||
FROM `msz_changelog_tags`
|
FROM `msz_changelog_tags`
|
||||||
')->fetchColumn();
|
')->fetchColumn();
|
||||||
|
|
||||||
$getTags = $db->prepare('
|
$getTags = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
t.`tag_id`, t.`tag_name`, t.`tag_description`, t.`tag_created`,
|
t.`tag_id`, t.`tag_name`, t.`tag_description`, t.`tag_created`,
|
||||||
(
|
(
|
||||||
|
@ -244,7 +243,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && tmp_csrf_verify($_POST['csrf'] ?? '')) {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && tmp_csrf_verify($_POST['csrf'] ?? '')) {
|
||||||
if (!empty($_POST['tag']) && is_array($_POST['tag'])) {
|
if (!empty($_POST['tag']) && is_array($_POST['tag'])) {
|
||||||
if ($tagId > 0) {
|
if ($tagId > 0) {
|
||||||
$updateTag = $db->prepare('
|
$updateTag = Database::prepare('
|
||||||
UPDATE `msz_changelog_tags`
|
UPDATE `msz_changelog_tags`
|
||||||
SET `tag_name` = :name,
|
SET `tag_name` = :name,
|
||||||
`tag_description` = :description,
|
`tag_description` = :description,
|
||||||
|
@ -253,7 +252,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
');
|
');
|
||||||
$updateTag->bindValue('id', $tagId);
|
$updateTag->bindValue('id', $tagId);
|
||||||
} else {
|
} else {
|
||||||
$updateTag = $db->prepare('
|
$updateTag = Database::prepare('
|
||||||
INSERT INTO `msz_changelog_tags`
|
INSERT INTO `msz_changelog_tags`
|
||||||
(`tag_name`, `tag_description`, `tag_archived`)
|
(`tag_name`, `tag_description`, `tag_archived`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -268,14 +267,14 @@ switch ($_GET['v'] ?? null) {
|
||||||
$updateTag->execute();
|
$updateTag->execute();
|
||||||
|
|
||||||
if ($tagId < 1) {
|
if ($tagId < 1) {
|
||||||
header('Location: ?v=tag&t=' . $db->lastInsertId());
|
header('Location: ?v=tag&t=' . Database::lastInsertId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tagId > 0) {
|
if ($tagId > 0) {
|
||||||
$getTag = $db->prepare('
|
$getTag = Database::prepare('
|
||||||
SELECT `tag_id`, `tag_name`, `tag_description`, `tag_archived`, `tag_created`
|
SELECT `tag_id`, `tag_name`, `tag_description`, `tag_archived`, `tag_created`
|
||||||
FROM `msz_changelog_tags`
|
FROM `msz_changelog_tags`
|
||||||
WHERE `tag_id` = :tag_id
|
WHERE `tag_id` = :tag_id
|
||||||
|
@ -302,12 +301,12 @@ switch ($_GET['v'] ?? null) {
|
||||||
|
|
||||||
$actionTake = 32;
|
$actionTake = 32;
|
||||||
|
|
||||||
$actionCount = (int)$db->query('
|
$actionCount = (int)Database::query('
|
||||||
SELECT COUNT(`action_id`)
|
SELECT COUNT(`action_id`)
|
||||||
FROM `msz_changelog_actions`
|
FROM `msz_changelog_actions`
|
||||||
')->fetchColumn();
|
')->fetchColumn();
|
||||||
|
|
||||||
$getActions = $db->prepare('
|
$getActions = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
a.`action_id`, a.`action_name`, a.`action_colour`,
|
a.`action_id`, a.`action_name`, a.`action_colour`,
|
||||||
(
|
(
|
||||||
|
@ -342,7 +341,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && tmp_csrf_verify($_POST['csrf'] ?? '')) {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && tmp_csrf_verify($_POST['csrf'] ?? '')) {
|
||||||
if (!empty($_POST['action']) && is_array($_POST['action'])) {
|
if (!empty($_POST['action']) && is_array($_POST['action'])) {
|
||||||
if ($actionId > 0) {
|
if ($actionId > 0) {
|
||||||
$updateAction = $db->prepare('
|
$updateAction = Database::prepare('
|
||||||
UPDATE `msz_changelog_actions`
|
UPDATE `msz_changelog_actions`
|
||||||
SET `action_name` = :name,
|
SET `action_name` = :name,
|
||||||
`action_colour` = :colour,
|
`action_colour` = :colour,
|
||||||
|
@ -351,7 +350,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
');
|
');
|
||||||
$updateAction->bindValue('id', $actionId);
|
$updateAction->bindValue('id', $actionId);
|
||||||
} else {
|
} else {
|
||||||
$updateAction = $db->prepare('
|
$updateAction = Database::prepare('
|
||||||
INSERT INTO `msz_changelog_actions`
|
INSERT INTO `msz_changelog_actions`
|
||||||
(`action_name`, `action_colour`, `action_class`)
|
(`action_name`, `action_colour`, `action_class`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -375,14 +374,14 @@ switch ($_GET['v'] ?? null) {
|
||||||
$updateAction->execute();
|
$updateAction->execute();
|
||||||
|
|
||||||
if ($actionId < 1) {
|
if ($actionId < 1) {
|
||||||
header('Location: ?v=action&a=' . $db->lastInsertId());
|
header('Location: ?v=action&a=' . Database::lastInsertId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($actionId > 0) {
|
if ($actionId > 0) {
|
||||||
$getAction = $db->prepare('
|
$getAction = Database::prepare('
|
||||||
SELECT `action_id`, `action_name`, `action_colour`, `action_class`
|
SELECT `action_id`, `action_name`, `action_colour`, `action_class`
|
||||||
FROM `msz_changelog_actions`
|
FROM `msz_changelog_actions`
|
||||||
WHERE `action_id` = :action_id
|
WHERE `action_id` = :action_id
|
||||||
|
|
|
@ -3,7 +3,6 @@ use Misuzu\Database;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../misuzu.php';
|
require_once __DIR__ . '/../../misuzu.php';
|
||||||
|
|
||||||
$db = Database::connection();
|
|
||||||
$tpl = $app->getTemplating();
|
$tpl = $app->getTemplating();
|
||||||
|
|
||||||
$userPerms = perms_get_user(MSZ_PERMS_USER, $app->getUserId());
|
$userPerms = perms_get_user(MSZ_PERMS_USER, $app->getUserId());
|
||||||
|
@ -26,12 +25,12 @@ switch ($_GET['v'] ?? null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$usersTake = 32;
|
$usersTake = 32;
|
||||||
$manageUsersCount = $db->query('
|
$manageUsersCount = Database::query('
|
||||||
SELECT COUNT(`user_id`)
|
SELECT COUNT(`user_id`)
|
||||||
FROM `msz_users`
|
FROM `msz_users`
|
||||||
')->fetchColumn();
|
')->fetchColumn();
|
||||||
|
|
||||||
$getManageUsers = $db->prepare('
|
$getManageUsers = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
u.`user_id`, u.`username`,
|
u.`user_id`, u.`username`,
|
||||||
COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `colour`
|
COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `colour`
|
||||||
|
@ -66,7 +65,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
echo 'no';
|
echo 'no';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$getUser = $db->prepare('
|
$getUser = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
u.*,
|
u.*,
|
||||||
INET6_NTOA(u.`register_ip`) as `register_ip_decoded`,
|
INET6_NTOA(u.`register_ip`) as `register_ip_decoded`,
|
||||||
|
@ -87,7 +86,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$getHasRoles = $db->prepare('
|
$getHasRoles = Database::prepare('
|
||||||
SELECT `role_id`, `role_name`
|
SELECT `role_id`, `role_name`
|
||||||
FROM `msz_roles`
|
FROM `msz_roles`
|
||||||
WHERE `role_id` IN (
|
WHERE `role_id` IN (
|
||||||
|
@ -99,7 +98,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
$getHasRoles->bindValue('user_id', $manageUser['user_id']);
|
$getHasRoles->bindValue('user_id', $manageUser['user_id']);
|
||||||
$hasRoles = $getHasRoles->execute() ? $getHasRoles->fetchAll() : [];
|
$hasRoles = $getHasRoles->execute() ? $getHasRoles->fetchAll() : [];
|
||||||
|
|
||||||
$getAvailableRoles = $db->prepare('
|
$getAvailableRoles = Database::prepare('
|
||||||
SELECT `role_id`, `role_name`
|
SELECT `role_id`, `role_name`
|
||||||
FROM `msz_roles`
|
FROM `msz_roles`
|
||||||
WHERE `role_id` NOT IN (
|
WHERE `role_id` NOT IN (
|
||||||
|
@ -125,7 +124,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
&& user_validate_username($_POST['user']['username']) === ''
|
&& user_validate_username($_POST['user']['username']) === ''
|
||||||
&& user_validate_email($_POST['user']['email']) === ''
|
&& user_validate_email($_POST['user']['email']) === ''
|
||||||
&& strlen($_POST['user']['country']) === 2) {
|
&& strlen($_POST['user']['country']) === 2) {
|
||||||
$updateUserDetails = $db->prepare('
|
$updateUserDetails = Database::prepare('
|
||||||
UPDATE `msz_users`
|
UPDATE `msz_users`
|
||||||
SET `username` = :username,
|
SET `username` = :username,
|
||||||
`email` = LOWER(:email),
|
`email` = LOWER(:email),
|
||||||
|
@ -158,7 +157,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
&& !empty($_POST['password']['confirm'])
|
&& !empty($_POST['password']['confirm'])
|
||||||
&& user_validate_password($_POST['password']['new']) === ''
|
&& user_validate_password($_POST['password']['new']) === ''
|
||||||
&& $_POST['password']['new'] === $_POST['password']['confirm']) {
|
&& $_POST['password']['new'] === $_POST['password']['confirm']) {
|
||||||
$updatePassword = $db->prepare('
|
$updatePassword = Database::prepare('
|
||||||
UPDATE `msz_users`
|
UPDATE `msz_users`
|
||||||
SET `password` = :password
|
SET `password` = :password
|
||||||
WHERE `user_id` = :user_id
|
WHERE `user_id` = :user_id
|
||||||
|
@ -195,7 +194,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
|
|
||||||
if ($perms !== null) {
|
if ($perms !== null) {
|
||||||
$permKeys = array_keys($perms);
|
$permKeys = array_keys($perms);
|
||||||
$setPermissions = $db->prepare('
|
$setPermissions = Database::prepare('
|
||||||
REPLACE INTO `msz_permissions`
|
REPLACE INTO `msz_permissions`
|
||||||
(`role_id`, `user_id`, `' . implode('`, `', $permKeys) . '`)
|
(`role_id`, `user_id`, `' . implode('`, `', $permKeys) . '`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -209,7 +208,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
|
|
||||||
$setPermissions->execute();
|
$setPermissions->execute();
|
||||||
} else {
|
} else {
|
||||||
$deletePermissions = $db->prepare('
|
$deletePermissions = Database::prepare('
|
||||||
DELETE FROM `msz_permissions`
|
DELETE FROM `msz_permissions`
|
||||||
WHERE `role_id` IS NULL
|
WHERE `role_id` IS NULL
|
||||||
AND `user_id` = :user_id
|
AND `user_id` = :user_id
|
||||||
|
@ -239,12 +238,12 @@ switch ($_GET['v'] ?? null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$rolesTake = 10;
|
$rolesTake = 10;
|
||||||
$manageRolesCount = $db->query('
|
$manageRolesCount = Database::query('
|
||||||
SELECT COUNT(`role_id`)
|
SELECT COUNT(`role_id`)
|
||||||
FROM `msz_roles`
|
FROM `msz_roles`
|
||||||
')->fetchColumn();
|
')->fetchColumn();
|
||||||
|
|
||||||
$getManageRoles = $db->prepare('
|
$getManageRoles = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
`role_id`, `role_colour`, `role_name`,
|
`role_id`, `role_colour`, `role_name`,
|
||||||
(
|
(
|
||||||
|
@ -352,7 +351,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($roleId < 1) {
|
if ($roleId < 1) {
|
||||||
$updateRole = $db->prepare('
|
$updateRole = Database::prepare('
|
||||||
INSERT INTO `msz_roles`
|
INSERT INTO `msz_roles`
|
||||||
(
|
(
|
||||||
`role_name`, `role_hierarchy`, `role_secret`, `role_colour`,
|
`role_name`, `role_hierarchy`, `role_secret`, `role_colour`,
|
||||||
|
@ -365,7 +364,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
)
|
)
|
||||||
');
|
');
|
||||||
} else {
|
} else {
|
||||||
$updateRole = $db->prepare('
|
$updateRole = Database::prepare('
|
||||||
UPDATE `msz_roles`
|
UPDATE `msz_roles`
|
||||||
SET `role_name` = :role_name,
|
SET `role_name` = :role_name,
|
||||||
`role_hierarchy` = :role_hierarchy,
|
`role_hierarchy` = :role_hierarchy,
|
||||||
|
@ -387,7 +386,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
$updateRole->execute();
|
$updateRole->execute();
|
||||||
|
|
||||||
if ($roleId < 1) {
|
if ($roleId < 1) {
|
||||||
$roleId = (int)$db->lastInsertId();
|
$roleId = (int)Database::lastInsertId();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($permissions) && !empty($_POST['perms']) && is_array($_POST['perms'])) {
|
if (!empty($permissions) && !empty($_POST['perms']) && is_array($_POST['perms'])) {
|
||||||
|
@ -395,7 +394,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
|
|
||||||
if ($perms !== null) {
|
if ($perms !== null) {
|
||||||
$permKeys = array_keys($perms);
|
$permKeys = array_keys($perms);
|
||||||
$setPermissions = $db->prepare('
|
$setPermissions = Database::prepare('
|
||||||
REPLACE INTO `msz_permissions`
|
REPLACE INTO `msz_permissions`
|
||||||
(`role_id`, `user_id`, `' . implode('`, `', $permKeys) . '`)
|
(`role_id`, `user_id`, `' . implode('`, `', $permKeys) . '`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -409,7 +408,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
|
|
||||||
$setPermissions->execute();
|
$setPermissions->execute();
|
||||||
} else {
|
} else {
|
||||||
$deletePermissions = $db->prepare('
|
$deletePermissions = Database::prepare('
|
||||||
DELETE FROM `msz_permissions`
|
DELETE FROM `msz_permissions`
|
||||||
WHERE `role_id` = :role_id
|
WHERE `role_id` = :role_id
|
||||||
AND `user_id` IS NULL
|
AND `user_id` IS NULL
|
||||||
|
@ -429,7 +428,7 @@ switch ($_GET['v'] ?? null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$getEditRole = $db->prepare('
|
$getEditRole = Database::prepare('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `msz_roles`
|
FROM `msz_roles`
|
||||||
WHERE `role_id` = :role_id
|
WHERE `role_id` = :role_id
|
||||||
|
|
|
@ -58,10 +58,9 @@ if (empty($orderDir)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = Database::connection();
|
|
||||||
$tpl = $app->getTemplating();
|
$tpl = $app->getTemplating();
|
||||||
|
|
||||||
$getRole = $db->prepare('
|
$getRole = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
`role_id`, `role_name`, `role_colour`, `role_description`, `created_at`,
|
`role_id`, `role_name`, `role_colour`, `role_description`, `created_at`,
|
||||||
(
|
(
|
||||||
|
@ -73,22 +72,21 @@ $getRole = $db->prepare('
|
||||||
WHERE `role_id` = :role_id
|
WHERE `role_id` = :role_id
|
||||||
');
|
');
|
||||||
$getRole->bindValue('role_id', $roleId);
|
$getRole->bindValue('role_id', $roleId);
|
||||||
$role = $getRole->execute() ? $getRole->fetch() : [];
|
$role = $getRole->execute() ? $getRole->fetch(PDO::FETCH_ASSOC) : [];
|
||||||
|
|
||||||
if (!$role) {
|
if (!$role) {
|
||||||
echo render_error(404);
|
echo render_error(404);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$getRoles = $db->prepare('
|
$roles = Database::query('
|
||||||
SELECT `role_id`, `role_name`, `role_colour`
|
SELECT `role_id`, `role_name`, `role_colour`
|
||||||
FROM `msz_roles`
|
FROM `msz_roles`
|
||||||
WHERE `role_secret` = 0
|
WHERE `role_secret` = 0
|
||||||
ORDER BY `role_id`
|
ORDER BY `role_id`
|
||||||
');
|
')->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$roles = $getRoles->execute() ? $getRoles->fetchAll() : [];
|
|
||||||
|
|
||||||
$getUsers = $db->prepare("
|
$getUsers = Database::prepare("
|
||||||
SELECT
|
SELECT
|
||||||
u.`user_id`, u.`username`, u.`user_country`,
|
u.`user_id`, u.`username`, u.`user_country`,
|
||||||
u.`created_at` as `user_joined`, u.`last_seen` as `user_last_seen`,
|
u.`created_at` as `user_joined`, u.`last_seen` as `user_last_seen`,
|
||||||
|
@ -118,7 +116,7 @@ $getUsers = $db->prepare("
|
||||||
$getUsers->bindValue('role_id', $role['role_id']);
|
$getUsers->bindValue('role_id', $role['role_id']);
|
||||||
$getUsers->bindValue('offset', $usersOffset);
|
$getUsers->bindValue('offset', $usersOffset);
|
||||||
$getUsers->bindValue('take', $usersTake);
|
$getUsers->bindValue('take', $usersTake);
|
||||||
$users = $getUsers->execute() ? $getUsers->fetchAll() : [];
|
$users = $getUsers->execute() ? $getUsers->fetchAll(PDO::FETCH_ASSOC) : [];
|
||||||
|
|
||||||
echo $tpl->render('user.listing', [
|
echo $tpl->render('user.listing', [
|
||||||
'roles' => $roles,
|
'roles' => $roles,
|
||||||
|
|
|
@ -3,7 +3,6 @@ use Misuzu\Database;
|
||||||
|
|
||||||
require_once __DIR__ . '/../misuzu.php';
|
require_once __DIR__ . '/../misuzu.php';
|
||||||
|
|
||||||
$db = Database::connection();
|
|
||||||
$templating = $app->getTemplating();
|
$templating = $app->getTemplating();
|
||||||
|
|
||||||
$categoryId = isset($_GET['c']) ? (int)$_GET['c'] : null;
|
$categoryId = isset($_GET['c']) ? (int)$_GET['c'] : null;
|
||||||
|
@ -17,7 +16,7 @@ $templating->vars([
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($postId !== null) {
|
if ($postId !== null) {
|
||||||
$getPost = $db->prepare('
|
$getPost = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`,
|
p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`,
|
||||||
c.`category_id`, c.`category_name`,
|
c.`category_id`, c.`category_name`,
|
||||||
|
@ -45,7 +44,7 @@ if ($postId !== null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($categoryId !== null) {
|
if ($categoryId !== null) {
|
||||||
$getCategory = $db->prepare('
|
$getCategory = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
c.`category_id`, c.`category_name`, c.`category_description`,
|
c.`category_id`, c.`category_name`, c.`category_description`,
|
||||||
COUNT(p.`post_id`) AS `posts_count`
|
COUNT(p.`post_id`) AS `posts_count`
|
||||||
|
@ -63,7 +62,7 @@ if ($categoryId !== null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$getPosts = $db->prepare('
|
$getPosts = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`,
|
p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`,
|
||||||
c.`category_id`, c.`category_name`,
|
c.`category_id`, c.`category_name`,
|
||||||
|
@ -85,7 +84,7 @@ if ($categoryId !== null) {
|
||||||
$getPosts->bindValue('category_id', $category['category_id'], PDO::PARAM_INT);
|
$getPosts->bindValue('category_id', $category['category_id'], PDO::PARAM_INT);
|
||||||
$posts = $getPosts->execute() ? $getPosts->fetchAll() : false;
|
$posts = $getPosts->execute() ? $getPosts->fetchAll() : false;
|
||||||
|
|
||||||
$getFeatured = $db->prepare('
|
$getFeatured = Database::prepare('
|
||||||
SELECT `post_id`, `post_title`
|
SELECT `post_id`, `post_title`
|
||||||
FROM `msz_news_posts`
|
FROM `msz_news_posts`
|
||||||
WHERE `category_id` = :category_id
|
WHERE `category_id` = :category_id
|
||||||
|
@ -100,7 +99,7 @@ if ($categoryId !== null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$getCategories = $db->prepare('
|
$getCategories = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
c.`category_id`, c.`category_name`,
|
c.`category_id`, c.`category_name`,
|
||||||
COUNT(p.`post_id`) AS count
|
COUNT(p.`post_id`) AS count
|
||||||
|
@ -113,7 +112,7 @@ $getCategories = $db->prepare('
|
||||||
');
|
');
|
||||||
$categories = $getCategories->execute() ? $getCategories->fetchAll() : [];
|
$categories = $getCategories->execute() ? $getCategories->fetchAll() : [];
|
||||||
|
|
||||||
$postsCount = (int)$db->query('
|
$postsCount = (int)Database::query('
|
||||||
SELECT COUNT(p.`post_id`) as `posts_count`
|
SELECT COUNT(p.`post_id`) as `posts_count`
|
||||||
FROM `msz_news_posts` as p
|
FROM `msz_news_posts` as p
|
||||||
LEFT JOIN `msz_news_categories` as c
|
LEFT JOIN `msz_news_categories` as c
|
||||||
|
@ -129,7 +128,7 @@ if ($postsOffset < 0 || $postsOffset >= $postsCount) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$getPosts = $db->prepare('
|
$getPosts = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`,
|
p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`,
|
||||||
c.`category_id`, c.`category_name`,
|
c.`category_id`, c.`category_name`,
|
||||||
|
|
|
@ -42,7 +42,7 @@ switch ($mode) {
|
||||||
default:
|
default:
|
||||||
$templating = $app->getTemplating();
|
$templating = $app->getTemplating();
|
||||||
|
|
||||||
$getProfile = Database::connection()->prepare('
|
$getProfile = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
u.*,
|
u.*,
|
||||||
COALESCE(u.`user_title`, r.`role_title`) as `user_title`,
|
COALESCE(u.`user_title`, r.`role_title`) as `user_title`,
|
||||||
|
|
13
server.php
13
server.php
|
@ -1,13 +0,0 @@
|
||||||
<?php
|
|
||||||
// php -S localhost:8000 -t public/ server.php
|
|
||||||
|
|
||||||
// Decode and parse the request uri
|
|
||||||
$uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
|
|
||||||
|
|
||||||
// Check if the file exist in the public directory and if it does serve it.
|
|
||||||
if ($uri !== '/' && file_exists(__DIR__ . '/public' . $uri)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise include the router
|
|
||||||
require_once __DIR__ . '/public/index.php';
|
|
|
@ -94,6 +94,11 @@ final class Database
|
||||||
return self::connection($connection)->exec($statement);
|
return self::connection($connection)->exec($statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function lastInsertId(?string $name = null, ?string $connection = null): string
|
||||||
|
{
|
||||||
|
return self::connection($connection)->lastInsertId($name);
|
||||||
|
}
|
||||||
|
|
||||||
public static function queryCount(?string $connection = null): int
|
public static function queryCount(?string $connection = null): int
|
||||||
{
|
{
|
||||||
return (int)Database::query('SHOW SESSION STATUS LIKE "Questions"', $connection)->fetch()['Value'];
|
return (int)Database::query('SHOW SESSION STATUS LIKE "Questions"', $connection)->fetch()['Value'];
|
||||||
|
|
|
@ -41,7 +41,7 @@ function forum_may_have_topics(int $forumType): bool
|
||||||
|
|
||||||
function forum_fetch(int $forumId): array
|
function forum_fetch(int $forumId): array
|
||||||
{
|
{
|
||||||
$getForum = Database::connection()->prepare('
|
$getForum = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
`forum_id`, `forum_name`, `forum_type`, `forum_link`, `forum_link_clicks`, `forum_parent`,
|
`forum_id`, `forum_name`, `forum_type`, `forum_link`, `forum_link_clicks`, `forum_parent`,
|
||||||
(
|
(
|
||||||
|
@ -61,9 +61,7 @@ function forum_fetch(int $forumId): array
|
||||||
|
|
||||||
function forum_get_root_categories(): array
|
function forum_get_root_categories(): array
|
||||||
{
|
{
|
||||||
$dbc = Database::connection();
|
$categories = Database::query('
|
||||||
|
|
||||||
$categories = $dbc->query('
|
|
||||||
SELECT
|
SELECT
|
||||||
f.`forum_id`, f.`forum_name`, f.`forum_type`,
|
f.`forum_id`, f.`forum_name`, f.`forum_type`,
|
||||||
(
|
(
|
||||||
|
@ -80,7 +78,7 @@ function forum_get_root_categories(): array
|
||||||
|
|
||||||
$categories = array_merge([MSZ_FORUM_ROOT_DATA], $categories);
|
$categories = array_merge([MSZ_FORUM_ROOT_DATA], $categories);
|
||||||
|
|
||||||
$categories[0]['forum_children'] = (int)$dbc->query('
|
$categories[0]['forum_children'] = (int)Database::query('
|
||||||
SELECT COUNT(`forum_id`)
|
SELECT COUNT(`forum_id`)
|
||||||
FROM `msz_forum_categories`
|
FROM `msz_forum_categories`
|
||||||
WHERE `forum_parent` = ' . MSZ_FORUM_ROOT . '
|
WHERE `forum_parent` = ' . MSZ_FORUM_ROOT . '
|
||||||
|
@ -95,7 +93,7 @@ function forum_get_breadcrumbs(
|
||||||
array $indexLink = ['Forums' => '/forum/']
|
array $indexLink = ['Forums' => '/forum/']
|
||||||
): array {
|
): array {
|
||||||
$breadcrumbs = [];
|
$breadcrumbs = [];
|
||||||
$getBreadcrumb = Database::connection()->prepare('
|
$getBreadcrumb = Database::prepare('
|
||||||
SELECT `forum_id`, `forum_name`, `forum_parent`
|
SELECT `forum_id`, `forum_name`, `forum_parent`
|
||||||
FROM `msz_forum_categories`
|
FROM `msz_forum_categories`
|
||||||
WHERE `forum_id` = :forum_id
|
WHERE `forum_id` = :forum_id
|
||||||
|
@ -118,7 +116,7 @@ function forum_get_breadcrumbs(
|
||||||
|
|
||||||
function forum_increment_clicks(int $forumId): void
|
function forum_increment_clicks(int $forumId): void
|
||||||
{
|
{
|
||||||
$incrementLinkClicks = Database::connection()->prepare('
|
$incrementLinkClicks = Database::prepare('
|
||||||
UPDATE `msz_forum_categories`
|
UPDATE `msz_forum_categories`
|
||||||
SET `forum_link_clicks` = `forum_link_clicks` + 1
|
SET `forum_link_clicks` = `forum_link_clicks` + 1
|
||||||
WHERE `forum_id` = :forum_id
|
WHERE `forum_id` = :forum_id
|
||||||
|
@ -247,7 +245,7 @@ define('MSZ_FORUM_GET_CHILDREN_QUERY_STANDARD', '
|
||||||
|
|
||||||
function forum_get_children(int $parentId, int $userId, bool $small = false): array
|
function forum_get_children(int $parentId, int $userId, bool $small = false): array
|
||||||
{
|
{
|
||||||
$getListing = Database::connection()->prepare(
|
$getListing = Database::prepare(
|
||||||
$small
|
$small
|
||||||
? MSZ_FORUM_GET_CHILDREN_QUERY_SMALL
|
? MSZ_FORUM_GET_CHILDREN_QUERY_SMALL
|
||||||
: MSZ_FORUM_GET_CHILDREN_QUERY_STANDARD
|
: MSZ_FORUM_GET_CHILDREN_QUERY_STANDARD
|
||||||
|
|
|
@ -23,9 +23,7 @@ function forum_post_create(
|
||||||
string $text,
|
string $text,
|
||||||
int $parser = MSZ_FORUM_POST_PARSER_PLAIN
|
int $parser = MSZ_FORUM_POST_PARSER_PLAIN
|
||||||
): int {
|
): int {
|
||||||
$dbc = Database::connection();
|
$createPost = Database::prepare('
|
||||||
|
|
||||||
$createPost = $dbc->prepare('
|
|
||||||
INSERT INTO `msz_forum_posts`
|
INSERT INTO `msz_forum_posts`
|
||||||
(`topic_id`, `forum_id`, `user_id`, `post_ip`, `post_text`, `post_parse`)
|
(`topic_id`, `forum_id`, `user_id`, `post_ip`, `post_text`, `post_parse`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -38,12 +36,12 @@ function forum_post_create(
|
||||||
$createPost->bindValue('post_text', $text);
|
$createPost->bindValue('post_text', $text);
|
||||||
$createPost->bindValue('post_parse', $parser);
|
$createPost->bindValue('post_parse', $parser);
|
||||||
|
|
||||||
return $createPost->execute() ? $dbc->lastInsertId() : 0;
|
return $createPost->execute() ? Database::lastInsertId() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function forum_post_find(int $postId): array
|
function forum_post_find(int $postId): array
|
||||||
{
|
{
|
||||||
$getPostInfo = Database::connection()->prepare('
|
$getPostInfo = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
:post_id as `target_post_id`,
|
:post_id as `target_post_id`,
|
||||||
(
|
(
|
||||||
|
@ -86,7 +84,7 @@ define('MSZ_FORUM_POST_LISTING_QUERY_PAGINATED', MSZ_FORUM_POST_LISTING_QUERY_ST
|
||||||
function forum_post_listing(int $topicId, int $offset = 0, int $take = 0): array
|
function forum_post_listing(int $topicId, int $offset = 0, int $take = 0): array
|
||||||
{
|
{
|
||||||
$hasPagination = $offset >= 0 && $take > 0;
|
$hasPagination = $offset >= 0 && $take > 0;
|
||||||
$getPosts = Database::connection()->prepare(
|
$getPosts = Database::prepare(
|
||||||
$hasPagination
|
$hasPagination
|
||||||
? MSZ_FORUM_POST_LISTING_QUERY_PAGINATED
|
? MSZ_FORUM_POST_LISTING_QUERY_PAGINATED
|
||||||
: MSZ_FORUM_POST_LISTING_QUERY_STANDARD
|
: MSZ_FORUM_POST_LISTING_QUERY_STANDARD
|
||||||
|
|
|
@ -12,9 +12,7 @@ define('MSZ_TOPIC_TYPES', [
|
||||||
|
|
||||||
function forum_topic_create(int $forumId, int $userId, string $title): int
|
function forum_topic_create(int $forumId, int $userId, string $title): int
|
||||||
{
|
{
|
||||||
$dbc = Database::connection();
|
$createTopic = Database::prepare('
|
||||||
|
|
||||||
$createTopic = $dbc->prepare('
|
|
||||||
INSERT INTO `msz_forum_topics`
|
INSERT INTO `msz_forum_topics`
|
||||||
(`forum_id`, `user_id`, `topic_title`)
|
(`forum_id`, `user_id`, `topic_title`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -24,12 +22,12 @@ function forum_topic_create(int $forumId, int $userId, string $title): int
|
||||||
$createTopic->bindValue('user_id', $userId);
|
$createTopic->bindValue('user_id', $userId);
|
||||||
$createTopic->bindValue('topic_title', $title);
|
$createTopic->bindValue('topic_title', $title);
|
||||||
|
|
||||||
return $createTopic->execute() ? (int)$dbc->lastInsertId() : 0;
|
return $createTopic->execute() ? (int)Database::lastInsertId() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function forum_topic_fetch(int $topicId): array
|
function forum_topic_fetch(int $topicId): array
|
||||||
{
|
{
|
||||||
$getTopic = Database::connection()->prepare('
|
$getTopic = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
t.`topic_id`, t.`forum_id`, t.`topic_title`, t.`topic_type`, t.`topic_locked`,
|
t.`topic_id`, t.`forum_id`, t.`topic_title`, t.`topic_type`, t.`topic_locked`,
|
||||||
f.`forum_archived` as `topic_archived`,
|
f.`forum_archived` as `topic_archived`,
|
||||||
|
@ -58,7 +56,7 @@ function forum_topic_fetch(int $topicId): array
|
||||||
|
|
||||||
function forum_topic_bump(int $topicId): bool
|
function forum_topic_bump(int $topicId): bool
|
||||||
{
|
{
|
||||||
$bumpTopic = Database::connection()->prepare('
|
$bumpTopic = Database::prepare('
|
||||||
UPDATE `msz_forum_topics`
|
UPDATE `msz_forum_topics`
|
||||||
SET `topic_bumped` = NOW()
|
SET `topic_bumped` = NOW()
|
||||||
WHERE `topic_id` = :topic_id
|
WHERE `topic_id` = :topic_id
|
||||||
|
@ -73,7 +71,7 @@ function forum_topic_mark_read(int $userId, int $topicId, int $forumId): void
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$markAsRead = Database::connection()->prepare('
|
$markAsRead = Database::prepare('
|
||||||
REPLACE INTO `msz_forum_topics_track`
|
REPLACE INTO `msz_forum_topics_track`
|
||||||
(`user_id`, `topic_id`, `forum_id`, `track_last_read`)
|
(`user_id`, `topic_id`, `forum_id`, `track_last_read`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -147,7 +145,7 @@ define('MSZ_TOPIC_LISTING_QUERY_PAGINATED', MSZ_TOPIC_LISTING_QUERY_STANDARD . '
|
||||||
function forum_topic_listing(int $forumId, int $userId, int $offset = 0, int $take = 0): array
|
function forum_topic_listing(int $forumId, int $userId, int $offset = 0, int $take = 0): array
|
||||||
{
|
{
|
||||||
$hasPagination = $offset >= 0 && $take > 0;
|
$hasPagination = $offset >= 0 && $take > 0;
|
||||||
$getTopics = Database::connection()->prepare(
|
$getTopics = Database::prepare(
|
||||||
$hasPagination
|
$hasPagination
|
||||||
? MSZ_TOPIC_LISTING_QUERY_PAGINATED
|
? MSZ_TOPIC_LISTING_QUERY_PAGINATED
|
||||||
: MSZ_TOPIC_LISTING_QUERY_STANDARD
|
: MSZ_TOPIC_LISTING_QUERY_STANDARD
|
||||||
|
|
|
@ -3,7 +3,7 @@ use Misuzu\Database;
|
||||||
|
|
||||||
function user_login_attempt_record(bool $success, ?int $userId, string $ipAddress, string $userAgent): void
|
function user_login_attempt_record(bool $success, ?int $userId, string $ipAddress, string $userAgent): void
|
||||||
{
|
{
|
||||||
$storeAttempt = Database::connection()->prepare('
|
$storeAttempt = Database::prepare('
|
||||||
INSERT INTO `msz_login_attempts`
|
INSERT INTO `msz_login_attempts`
|
||||||
(`was_successful`, `attempt_ip`, `attempt_country`, `user_id`, `user_agent`, `created_at`)
|
(`was_successful`, `attempt_ip`, `attempt_country`, `user_id`, `user_agent`, `created_at`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -20,7 +20,7 @@ function user_login_attempt_record(bool $success, ?int $userId, string $ipAddres
|
||||||
|
|
||||||
function user_login_attempts_remaining(string $ipAddress): int
|
function user_login_attempts_remaining(string $ipAddress): int
|
||||||
{
|
{
|
||||||
$getRemaining = Database::connection()->prepare('
|
$getRemaining = Database::prepare('
|
||||||
SELECT 5 - COUNT(`attempt_id`)
|
SELECT 5 - COUNT(`attempt_id`)
|
||||||
FROM `msz_login_attempts`
|
FROM `msz_login_attempts`
|
||||||
WHERE `was_successful` = false
|
WHERE `was_successful` = false
|
||||||
|
|
|
@ -125,7 +125,7 @@ function user_profile_fields_set(int $userId, array $fields): array
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($values) > 0) {
|
if (count($values) > 0) {
|
||||||
$updateFields = Database::connection()->prepare('
|
$updateFields = Database::prepare('
|
||||||
UPDATE `msz_users`
|
UPDATE `msz_users`
|
||||||
SET ' . pdo_prepare_array_update($values, true) . '
|
SET ' . pdo_prepare_array_update($values, true) . '
|
||||||
WHERE `user_id` = :user_id
|
WHERE `user_id` = :user_id
|
||||||
|
|
|
@ -5,7 +5,7 @@ define('MSZ_ROLE_MAIN', 1);
|
||||||
|
|
||||||
function user_role_add(int $userId, int $roleId): bool
|
function user_role_add(int $userId, int $roleId): bool
|
||||||
{
|
{
|
||||||
$addRole = Database::connection()->prepare('
|
$addRole = Database::prepare('
|
||||||
INSERT INTO `msz_user_roles`
|
INSERT INTO `msz_user_roles`
|
||||||
(`user_id`, `role_id`)
|
(`user_id`, `role_id`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -18,7 +18,7 @@ function user_role_add(int $userId, int $roleId): bool
|
||||||
|
|
||||||
function user_role_remove(int $userId, int $roleId): bool
|
function user_role_remove(int $userId, int $roleId): bool
|
||||||
{
|
{
|
||||||
$removeRole = Database::connection()->prepare('
|
$removeRole = Database::prepare('
|
||||||
DELETE FROM `msz_user_roles`
|
DELETE FROM `msz_user_roles`
|
||||||
WHERE `user_id` = :user_id
|
WHERE `user_id` = :user_id
|
||||||
AND `role_id` = :role_id
|
AND `role_id` = :role_id
|
||||||
|
@ -30,7 +30,7 @@ function user_role_remove(int $userId, int $roleId): bool
|
||||||
|
|
||||||
function user_role_has(int $userId, int $roleId): bool
|
function user_role_has(int $userId, int $roleId): bool
|
||||||
{
|
{
|
||||||
$hasRole = Database::connection()->prepare('
|
$hasRole = Database::prepare('
|
||||||
SELECT COUNT(`role_id`) > 0
|
SELECT COUNT(`role_id`) > 0
|
||||||
FROM `msz_user_roles`
|
FROM `msz_user_roles`
|
||||||
WHERE `user_id` = :user_id
|
WHERE `user_id` = :user_id
|
||||||
|
@ -47,7 +47,7 @@ function user_role_set_display(int $userId, int $roleId): bool
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$setDisplay = Database::connection()->prepare('
|
$setDisplay = Database::prepare('
|
||||||
UPDATE `msz_users`
|
UPDATE `msz_users`
|
||||||
SET `display_role` = :role_id
|
SET `display_role` = :role_id
|
||||||
WHERE `user_id` = :user_id
|
WHERE `user_id` = :user_id
|
||||||
|
|
|
@ -10,7 +10,7 @@ function user_session_create(
|
||||||
): string {
|
): string {
|
||||||
$sessionKey = user_session_generate_key();
|
$sessionKey = user_session_generate_key();
|
||||||
|
|
||||||
$createSession = Database::connection()->prepare('
|
$createSession = Database::prepare('
|
||||||
INSERT INTO `msz_sessions`
|
INSERT INTO `msz_sessions`
|
||||||
(
|
(
|
||||||
`user_id`, `session_ip`, `session_country`,
|
`user_id`, `session_ip`, `session_country`,
|
||||||
|
@ -33,7 +33,7 @@ function user_session_create(
|
||||||
|
|
||||||
function user_session_delete(int $sessionId): bool
|
function user_session_delete(int $sessionId): bool
|
||||||
{
|
{
|
||||||
$deleteSession = Database::connection()->prepare('
|
$deleteSession = Database::prepare('
|
||||||
DELETE FROM `msz_sessions`
|
DELETE FROM `msz_sessions`
|
||||||
WHERE `session_id` = :session_id
|
WHERE `session_id` = :session_id
|
||||||
');
|
');
|
||||||
|
|
|
@ -21,8 +21,7 @@ function user_create(
|
||||||
string $email,
|
string $email,
|
||||||
string $ipAddress
|
string $ipAddress
|
||||||
): int {
|
): int {
|
||||||
$dbc = Database::connection();
|
$createUser = Database::prepare('
|
||||||
$createUser = $dbc->prepare('
|
|
||||||
INSERT INTO `msz_users`
|
INSERT INTO `msz_users`
|
||||||
(
|
(
|
||||||
`username`, `password`, `email`, `register_ip`,
|
`username`, `password`, `email`, `register_ip`,
|
||||||
|
@ -41,7 +40,7 @@ function user_create(
|
||||||
$createUser->bindValue('last_ip', $ipAddress);
|
$createUser->bindValue('last_ip', $ipAddress);
|
||||||
$createUser->bindValue('user_country', get_country_code($ipAddress));
|
$createUser->bindValue('user_country', get_country_code($ipAddress));
|
||||||
|
|
||||||
return $createUser->execute() ? (int)$dbc->lastInsertId() : 0;
|
return $createUser->execute() ? (int)Database::lastInsertId() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_password_hash(string $password): string
|
function user_password_hash(string $password): string
|
||||||
|
@ -55,7 +54,7 @@ function user_generate_chat_key(int $userId): string
|
||||||
{
|
{
|
||||||
$chatKey = bin2hex(random_bytes(16));
|
$chatKey = bin2hex(random_bytes(16));
|
||||||
|
|
||||||
$setChatKey = Database::connection()->prepare('
|
$setChatKey = Database::prepare('
|
||||||
UPDATE `msz_users`
|
UPDATE `msz_users`
|
||||||
SET `user_chat_key` = :user_chat_key
|
SET `user_chat_key` = :user_chat_key
|
||||||
WHERE `user_id` = :user_id
|
WHERE `user_id` = :user_id
|
||||||
|
|
|
@ -42,7 +42,7 @@ function user_validate_username(string $username, bool $checkInUse = false): str
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($checkInUse) {
|
if ($checkInUse) {
|
||||||
$getUser = Database::connection()->prepare('
|
$getUser = Database::prepare('
|
||||||
SELECT COUNT(`user_id`)
|
SELECT COUNT(`user_id`)
|
||||||
FROM `msz_users`
|
FROM `msz_users`
|
||||||
WHERE LOWER(`username`) = LOWER(:username)
|
WHERE LOWER(`username`) = LOWER(:username)
|
||||||
|
@ -69,7 +69,7 @@ function user_validate_email(string $email, bool $checkInUse = false): string
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($checkInUse) {
|
if ($checkInUse) {
|
||||||
$getUser = Database::connection()->prepare('
|
$getUser = Database::prepare('
|
||||||
SELECT COUNT(`user_id`)
|
SELECT COUNT(`user_id`)
|
||||||
FROM `msz_users`
|
FROM `msz_users`
|
||||||
WHERE LOWER(`email`) = LOWER(:email)
|
WHERE LOWER(`email`) = LOWER(:email)
|
||||||
|
|
|
@ -7,15 +7,13 @@ define('MSZ_CHANGELOG_PERM_MANAGE_ACTIONS', 1 << 2);
|
||||||
|
|
||||||
function changelog_action_add(string $name, ?int $colour = null, ?string $class = null): int
|
function changelog_action_add(string $name, ?int $colour = null, ?string $class = null): int
|
||||||
{
|
{
|
||||||
$dbc = Database::connection();
|
|
||||||
|
|
||||||
if ($colour === null) {
|
if ($colour === null) {
|
||||||
$colour = colour_none();
|
$colour = colour_none();
|
||||||
}
|
}
|
||||||
|
|
||||||
$class = preg_replace('#[^a-z]#', '', strtolower($class ?? $name));
|
$class = preg_replace('#[^a-z]#', '', strtolower($class ?? $name));
|
||||||
|
|
||||||
$addAction = $dbc->prepare('
|
$addAction = Database::prepare('
|
||||||
INSERT INTO `msz_changelog_actions`
|
INSERT INTO `msz_changelog_actions`
|
||||||
(`action_name`, `action_colour`, `action_class`)
|
(`action_name`, `action_colour`, `action_class`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -25,14 +23,12 @@ function changelog_action_add(string $name, ?int $colour = null, ?string $class
|
||||||
$addAction->bindValue('action_colour', $colour);
|
$addAction->bindValue('action_colour', $colour);
|
||||||
$addAction->bindValue('action_class', $class);
|
$addAction->bindValue('action_class', $class);
|
||||||
|
|
||||||
return $addAction->execute() ? (int)$dbc->lastInsertId() : 0;
|
return $addAction->execute() ? (int)Database::lastInsertId() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function changelog_entry_create(int $userId, int $actionId, string $log, string $text = null): int
|
function changelog_entry_create(int $userId, int $actionId, string $log, string $text = null): int
|
||||||
{
|
{
|
||||||
$dbc = Database::connection();
|
$createChange = Database::prepare('
|
||||||
|
|
||||||
$createChange = $dbc->prepare('
|
|
||||||
INSERT INTO `msz_changelog_changes`
|
INSERT INTO `msz_changelog_changes`
|
||||||
(`user_id`, `action_id`, `change_log`, `change_text`)
|
(`user_id`, `action_id`, `change_log`, `change_text`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -43,7 +39,7 @@ function changelog_entry_create(int $userId, int $actionId, string $log, string
|
||||||
$createChange->bindValue('change_log', $log);
|
$createChange->bindValue('change_log', $log);
|
||||||
$createChange->bindValue('change_text', $text);
|
$createChange->bindValue('change_text', $text);
|
||||||
|
|
||||||
return $createChange->execute() ? (int)$dbc->lastInsertId() : 0;
|
return $createChange->execute() ? (int)Database::lastInsertId() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
define('MSZ_CHANGELOG_GET_QUERY', '
|
define('MSZ_CHANGELOG_GET_QUERY', '
|
||||||
|
@ -80,8 +76,7 @@ function changelog_get_changes(string $date, int $user, int $offset, int $take):
|
||||||
!$hasDate ? 'LIMIT :offset, :take' : ''
|
!$hasDate ? 'LIMIT :offset, :take' : ''
|
||||||
);
|
);
|
||||||
|
|
||||||
$dbc = Database::connection();
|
$prep = Database::prepare($query);
|
||||||
$prep = $dbc->prepare($query);
|
|
||||||
|
|
||||||
if (!$hasDate) {
|
if (!$hasDate) {
|
||||||
$prep->bindValue('offset', $offset);
|
$prep->bindValue('offset', $offset);
|
||||||
|
@ -115,8 +110,7 @@ function changelog_count_changes(string $date, int $user): int
|
||||||
$hasUser ? '`user_id` = :user' : '1'
|
$hasUser ? '`user_id` = :user' : '1'
|
||||||
);
|
);
|
||||||
|
|
||||||
$dbc = Database::connection();
|
$prep = Database::prepare($query);
|
||||||
$prep = $dbc->prepare($query);
|
|
||||||
|
|
||||||
if ($hasDate) {
|
if ($hasDate) {
|
||||||
$prep->bindValue('date', $date);
|
$prep->bindValue('date', $date);
|
||||||
|
|
|
@ -89,7 +89,7 @@ function perms_get_user(string $prefix, int $user): int
|
||||||
$permsAllow = 0;
|
$permsAllow = 0;
|
||||||
$permsDeny = 0;
|
$permsDeny = 0;
|
||||||
|
|
||||||
$getPerms = Database::connection()->prepare("
|
$getPerms = Database::prepare("
|
||||||
SELECT `{$prefix}_perms_allow` as `allow`, `{$prefix}_perms_deny` as `deny`
|
SELECT `{$prefix}_perms_allow` as `allow`, `{$prefix}_perms_deny` as `deny`
|
||||||
FROM `msz_permissions`
|
FROM `msz_permissions`
|
||||||
WHERE (`user_id` = :user_id_1 AND `role_id` IS NULL)
|
WHERE (`user_id` = :user_id_1 AND `role_id` IS NULL)
|
||||||
|
@ -124,7 +124,7 @@ function perms_get_role(string $prefix, int $role): int
|
||||||
return perms_get_cache($prefix, 'role', $user);
|
return perms_get_cache($prefix, 'role', $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
$getPerms = Database::connection()->prepare("
|
$getPerms = Database::prepare("
|
||||||
SELECT `{$prefix}_perms_allow` &~ `{$prefix}_perms_deny`
|
SELECT `{$prefix}_perms_allow` &~ `{$prefix}_perms_deny`
|
||||||
FROM `msz_permissions`
|
FROM `msz_permissions`
|
||||||
WHERE `role_id` = :role_id
|
WHERE `role_id` = :role_id
|
||||||
|
@ -142,7 +142,7 @@ function perms_get_user_raw(int $user): array
|
||||||
return $emptyPerms;
|
return $emptyPerms;
|
||||||
}
|
}
|
||||||
|
|
||||||
$getPerms = Database::connection()->prepare('
|
$getPerms = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
`' . implode('`, `', perms_get_keys()) . '`
|
`' . implode('`, `', perms_get_keys()) . '`
|
||||||
FROM `msz_permissions`
|
FROM `msz_permissions`
|
||||||
|
@ -172,7 +172,7 @@ function perms_get_role_raw(int $role): array
|
||||||
return $emptyPerms;
|
return $emptyPerms;
|
||||||
}
|
}
|
||||||
|
|
||||||
$getPerms = Database::connection()->prepare('
|
$getPerms = Database::prepare('
|
||||||
SELECT
|
SELECT
|
||||||
`' . implode('`, `', perms_get_keys()) . '`
|
`' . implode('`, `', perms_get_keys()) . '`
|
||||||
FROM `msz_permissions`
|
FROM `msz_permissions`
|
||||||
|
|
Loading…
Add table
Reference in a new issue