Use nextParameter instead of addParameter and manually counting where possible.
This commit is contained in:
parent
0f1a8886a6
commit
5e1d36abac
26 changed files with 490 additions and 554 deletions
|
@ -23,8 +23,8 @@ final class UpdateUserAgentStorage_20230721_121854 implements DbMigration {
|
||||||
while($selectLoginAttempts->next()) {
|
while($selectLoginAttempts->next()) {
|
||||||
$updateLoginAttempts->reset();
|
$updateLoginAttempts->reset();
|
||||||
$userAgent = $selectLoginAttempts->getString(0);
|
$userAgent = $selectLoginAttempts->getString(0);
|
||||||
$updateLoginAttempts->addParameter(1, json_encode(ClientInfo::parse($userAgent)));
|
$updateLoginAttempts->nextParameter(json_encode(ClientInfo::parse($userAgent)));
|
||||||
$updateLoginAttempts->addParameter(2, $userAgent);
|
$updateLoginAttempts->nextParameter($userAgent);
|
||||||
$updateLoginAttempts->execute();
|
$updateLoginAttempts->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ final class UpdateUserAgentStorage_20230721_121854 implements DbMigration {
|
||||||
while($selectSessions->next()) {
|
while($selectSessions->next()) {
|
||||||
$updateSessions->reset();
|
$updateSessions->reset();
|
||||||
$userAgent = $selectSessions->getString(0);
|
$userAgent = $selectSessions->getString(0);
|
||||||
$updateSessions->addParameter(1, json_encode(ClientInfo::parse($userAgent)));
|
$updateSessions->nextParameter(json_encode(ClientInfo::parse($userAgent)));
|
||||||
$updateSessions->addParameter(2, $userAgent);
|
$updateSessions->nextParameter($userAgent);
|
||||||
$updateSessions->execute();
|
$updateSessions->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,12 +77,13 @@ final class NewPermissionsSystem_20230830_213930 implements DbMigration {
|
||||||
|
|
||||||
$result = $conn->query('SELECT user_id, role_id, general_perms_allow, general_perms_deny, user_perms_allow, user_perms_deny, changelog_perms_allow, changelog_perms_deny, news_perms_allow, news_perms_deny, forum_perms_allow, forum_perms_deny, comments_perms_allow, comments_perms_deny FROM msz_permissions');
|
$result = $conn->query('SELECT user_id, role_id, general_perms_allow, general_perms_deny, user_perms_allow, user_perms_deny, changelog_perms_allow, changelog_perms_deny, news_perms_allow, news_perms_deny, forum_perms_allow, forum_perms_deny, comments_perms_allow, comments_perms_deny FROM msz_permissions');
|
||||||
while($result->next()) {
|
while($result->next()) {
|
||||||
$insert->addParameter(1, $result->isNull(0) ? null : $result->getString(0));
|
$insert->reset();
|
||||||
$insert->addParameter(2, $result->isNull(1) ? null : $result->getString(1));
|
$insert->nextParameter($result->isNull(0) ? null : $result->getString(0));
|
||||||
$insert->addParameter(3, null);
|
$insert->nextParameter($result->isNull(1) ? null : $result->getString(1));
|
||||||
$insert->addParameter(4, 'user');
|
$insert->nextParameter(null);
|
||||||
$insert->addParameter(5, $result->getInteger(4));
|
$insert->nextParameter('user');
|
||||||
$insert->addParameter(6, $result->getInteger(5));
|
$insert->nextParameter($result->getInteger(4));
|
||||||
|
$insert->nextParameter($result->getInteger(5));
|
||||||
$insert->execute();
|
$insert->execute();
|
||||||
|
|
||||||
$allow = $result->getInteger(2);
|
$allow = $result->getInteger(2);
|
||||||
|
@ -105,12 +106,13 @@ final class NewPermissionsSystem_20230830_213930 implements DbMigration {
|
||||||
|
|
||||||
$result = $conn->query('SELECT user_id, role_id, forum_id, forum_perms_allow, forum_perms_deny FROM msz_forum_permissions');
|
$result = $conn->query('SELECT user_id, role_id, forum_id, forum_perms_allow, forum_perms_deny FROM msz_forum_permissions');
|
||||||
while($result->next()) {
|
while($result->next()) {
|
||||||
$insert->addParameter(1, $result->isNull(0) ? null : $result->getString(0));
|
$insert->reset();
|
||||||
$insert->addParameter(2, $result->isNull(1) ? null : $result->getString(1));
|
$insert->nextParameter($result->isNull(0) ? null : $result->getString(0));
|
||||||
$insert->addParameter(3, $result->getString(2));
|
$insert->nextParameter($result->isNull(1) ? null : $result->getString(1));
|
||||||
$insert->addParameter(4, 'forum');
|
$insert->nextParameter($result->getString(2));
|
||||||
$insert->addParameter(5, $result->getInteger(3));
|
$insert->nextParameter('forum');
|
||||||
$insert->addParameter(6, $result->getInteger(4));
|
$insert->nextParameter($result->getInteger(3));
|
||||||
|
$insert->nextParameter($result->getInteger(4));
|
||||||
$insert->execute();
|
$insert->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ function db_to_zip(
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$stmt = $dbConn->prepare(sprintf('SELECT %s FROM msz_%s WHERE %s = ?', implode(', ', $fields), $baseName, $userIdField));
|
$stmt = $dbConn->prepare(sprintf('SELECT %s FROM msz_%s WHERE %s = ?', implode(', ', $fields), $baseName, $userIdField));
|
||||||
$stmt->addParameter(1, $userId);
|
$stmt->nextParameter($userId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
|
||||||
|
|
|
@ -36,11 +36,10 @@ class AuditLog {
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
if($hasRemoteAddr)
|
if($hasRemoteAddr)
|
||||||
$stmt->addParameter(++$args, $remoteAddr);
|
$stmt->nextParameter($remoteAddr);
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -81,14 +80,13 @@ class AuditLog {
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
if($hasRemoteAddr)
|
if($hasRemoteAddr)
|
||||||
$stmt->addParameter(++$args, $remoteAddr);
|
$stmt->nextParameter($remoteAddr);
|
||||||
if($hasPagination) {
|
if($hasPagination) {
|
||||||
$stmt->addParameter(++$args, $pagination->range);
|
$stmt->nextParameter($pagination->range);
|
||||||
$stmt->addParameter(++$args, $pagination->offset);
|
$stmt->nextParameter($pagination->offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@ -126,11 +124,11 @@ class AuditLog {
|
||||||
$params = json_encode($params);
|
$params = json_encode($params);
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_audit_log (user_id, log_action, log_params, log_ip, log_country) VALUES (?, ?, ?, INET6_ATON(?), UPPER(?))');
|
$stmt = $this->cache->get('INSERT INTO msz_audit_log (user_id, log_action, log_params, log_ip, log_country) VALUES (?, ?, ?, INET6_ATON(?), UPPER(?))');
|
||||||
$stmt->addParameter(1, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(2, $action);
|
$stmt->nextParameter($action);
|
||||||
$stmt->addParameter(3, $params);
|
$stmt->nextParameter($params);
|
||||||
$stmt->addParameter(4, $remoteAddr);
|
$stmt->nextParameter($remoteAddr);
|
||||||
$stmt->addParameter(5, $countryCode);
|
$stmt->nextParameter($countryCode);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,14 +43,13 @@ class LoginAttempts {
|
||||||
if($hasTimeRange)
|
if($hasTimeRange)
|
||||||
$query .= sprintf(' %s attempt_created > NOW() - INTERVAL ? SECOND', ++$args > 1 ? 'AND' : 'WHERE');
|
$query .= sprintf(' %s attempt_created > NOW() - INTERVAL ? SECOND', ++$args > 1 ? 'AND' : 'WHERE');
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
if($hasRemoteAddr)
|
if($hasRemoteAddr)
|
||||||
$stmt->addParameter(++$args, $remoteAddr);
|
$stmt->nextParameter($remoteAddr);
|
||||||
if($hasTimeRange)
|
if($hasTimeRange)
|
||||||
$stmt->addParameter(++$args, $timeRange);
|
$stmt->nextParameter($timeRange);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -103,17 +102,16 @@ class LoginAttempts {
|
||||||
if($hasPagination)
|
if($hasPagination)
|
||||||
$query .= ' LIMIT ? OFFSET ?';
|
$query .= ' LIMIT ? OFFSET ?';
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
if($hasRemoteAddr)
|
if($hasRemoteAddr)
|
||||||
$stmt->addParameter(++$args, $remoteAddr);
|
$stmt->nextParameter($remoteAddr);
|
||||||
if($hasTimeRange)
|
if($hasTimeRange)
|
||||||
$stmt->addParameter(++$args, $timeRange);
|
$stmt->nextParameter($timeRange);
|
||||||
if($hasPagination) {
|
if($hasPagination) {
|
||||||
$stmt->addParameter(++$args, $pagination->range);
|
$stmt->nextParameter($pagination->range);
|
||||||
$stmt->addParameter(++$args, $pagination->offset);
|
$stmt->nextParameter($pagination->offset);
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
|
@ -135,12 +133,12 @@ class LoginAttempts {
|
||||||
$clientInfo = json_encode($clientInfo ?? ClientInfo::parse($userAgentString));
|
$clientInfo = json_encode($clientInfo ?? ClientInfo::parse($userAgentString));
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_login_attempts (user_id, attempt_success, attempt_ip, attempt_country, attempt_user_agent, attempt_client_info) VALUES (?, ?, INET6_ATON(?), ?, ?, ?)');
|
$stmt = $this->cache->get('INSERT INTO msz_login_attempts (user_id, attempt_success, attempt_ip, attempt_country, attempt_user_agent, attempt_client_info) VALUES (?, ?, INET6_ATON(?), ?, ?, ?)');
|
||||||
$stmt->addParameter(1, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(2, $success ? 1 : 0);
|
$stmt->nextParameter($success ? 1 : 0);
|
||||||
$stmt->addParameter(3, $remoteAddr);
|
$stmt->nextParameter($remoteAddr);
|
||||||
$stmt->addParameter(4, $countryCode);
|
$stmt->nextParameter($countryCode);
|
||||||
$stmt->addParameter(5, $userAgentString);
|
$stmt->nextParameter($userAgentString);
|
||||||
$stmt->addParameter(6, $clientInfo);
|
$stmt->nextParameter($clientInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,14 +53,13 @@ class RecoveryTokens {
|
||||||
elseif($hasVerifyCode)
|
elseif($hasVerifyCode)
|
||||||
$query .= sprintf(' %s verification_code = ?', ++$args > 1 ? 'AND' : 'WHERE');
|
$query .= sprintf(' %s verification_code = ?', ++$args > 1 ? 'AND' : 'WHERE');
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
if($hasRemoteAddr)
|
if($hasRemoteAddr)
|
||||||
$stmt->addParameter(++$args, $remoteAddr);
|
$stmt->nextParameter($remoteAddr);
|
||||||
if($hasVerifyCode)
|
if($hasVerifyCode)
|
||||||
$stmt->addParameter(++$args, $verifyCode);
|
$stmt->nextParameter($verifyCode);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
|
||||||
|
@ -80,9 +79,9 @@ class RecoveryTokens {
|
||||||
$verifyCode = self::generateCode();
|
$verifyCode = self::generateCode();
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_users_password_resets (user_id, reset_ip, verification_code) VALUES (?, INET6_ATON(?), ?)');
|
$stmt = $this->cache->get('INSERT INTO msz_users_password_resets (user_id, reset_ip, verification_code) VALUES (?, INET6_ATON(?), ?)');
|
||||||
$stmt->addParameter(1, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(2, $remoteAddr);
|
$stmt->nextParameter($remoteAddr);
|
||||||
$stmt->addParameter(3, $verifyCode);
|
$stmt->nextParameter($verifyCode);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $this->getToken(verifyCode: $verifyCode);
|
return $this->getToken(verifyCode: $verifyCode);
|
||||||
|
@ -93,8 +92,8 @@ class RecoveryTokens {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_users_password_resets SET verification_code = NULL WHERE verification_code = ? AND user_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_users_password_resets SET verification_code = NULL WHERE verification_code = ? AND user_id = ?');
|
||||||
$stmt->addParameter(1, $tokenInfo->code);
|
$stmt->nextParameter($tokenInfo->code);
|
||||||
$stmt->addParameter(2, $tokenInfo->userId);
|
$stmt->nextParameter($tokenInfo->userId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,9 @@ class Sessions {
|
||||||
$query .= ' WHERE user_id = ?';
|
$query .= ' WHERE user_id = ?';
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -73,13 +72,12 @@ class Sessions {
|
||||||
if($hasPagination)
|
if($hasPagination)
|
||||||
$query .= ' LIMIT ? OFFSET ?';
|
$query .= ' LIMIT ? OFFSET ?';
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
if($hasPagination) {
|
if($hasPagination) {
|
||||||
$stmt->addParameter(++$args, $pagination->range);
|
$stmt->nextParameter($pagination->range);
|
||||||
$stmt->addParameter(++$args, $pagination->offset);
|
$stmt->nextParameter($pagination->offset);
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
|
@ -109,7 +107,7 @@ class Sessions {
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
$stmt->addParameter(1, $value);
|
$stmt->nextParameter($value);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -133,12 +131,12 @@ class Sessions {
|
||||||
$clientInfo = json_encode($clientInfo ?? ClientInfo::parse($userAgentString));
|
$clientInfo = json_encode($clientInfo ?? ClientInfo::parse($userAgentString));
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_sessions (user_id, session_key, session_ip, session_user_agent, session_client_info, session_country, session_expires) VALUES (?, ?, INET6_ATON(?), ?, ?, ?, NOW() + INTERVAL 1 MONTH)');
|
$stmt = $this->cache->get('INSERT INTO msz_sessions (user_id, session_key, session_ip, session_user_agent, session_client_info, session_country, session_expires) VALUES (?, ?, INET6_ATON(?), ?, ?, ?, NOW() + INTERVAL 1 MONTH)');
|
||||||
$stmt->addParameter(1, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(2, $sessionToken);
|
$stmt->nextParameter($sessionToken);
|
||||||
$stmt->addParameter(3, $remoteAddr);
|
$stmt->nextParameter($remoteAddr);
|
||||||
$stmt->addParameter(4, $userAgentString);
|
$stmt->nextParameter($userAgentString);
|
||||||
$stmt->addParameter(5, $clientInfo);
|
$stmt->nextParameter($clientInfo);
|
||||||
$stmt->addParameter(6, $countryCode);
|
$stmt->nextParameter($countryCode);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $this->getSession(sessionId: (string)$this->dbConn->getLastInsertId());
|
return $this->getSession(sessionId: (string)$this->dbConn->getLastInsertId());
|
||||||
|
@ -207,7 +205,6 @@ class Sessions {
|
||||||
if(!$hasSessionInfos && !$hasSessionTokens && !$hasUserInfos)
|
if(!$hasSessionInfos && !$hasSessionTokens && !$hasUserInfos)
|
||||||
throw new InvalidArgumentException('At least one argument must be specified.');
|
throw new InvalidArgumentException('At least one argument must be specified.');
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
|
|
||||||
if($hasSessionInfos)
|
if($hasSessionInfos)
|
||||||
|
@ -217,7 +214,7 @@ class Sessions {
|
||||||
elseif(!is_string($sessionInfo))
|
elseif(!is_string($sessionInfo))
|
||||||
throw new InvalidArgumentException('$sessionInfos must be strings or instances of SessionInfo.');
|
throw new InvalidArgumentException('$sessionInfos must be strings or instances of SessionInfo.');
|
||||||
|
|
||||||
$stmt->addParameter(++$args, $sessionInfo);
|
$stmt->nextParameter($sessionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($hasSessionTokens)
|
if($hasSessionTokens)
|
||||||
|
@ -225,7 +222,7 @@ class Sessions {
|
||||||
if(!is_string($sessionToken))
|
if(!is_string($sessionToken))
|
||||||
throw new InvalidArgumentException('$sessionTokens must be strings.');
|
throw new InvalidArgumentException('$sessionTokens must be strings.');
|
||||||
|
|
||||||
$stmt->addParameter(++$args, $sessionToken);
|
$stmt->nextParameter($sessionToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($hasUserInfos)
|
if($hasUserInfos)
|
||||||
|
@ -235,7 +232,7 @@ class Sessions {
|
||||||
elseif(!is_string($userInfo))
|
elseif(!is_string($userInfo))
|
||||||
throw new InvalidArgumentException('$userInfos must be strings or instances of UserInfo.');
|
throw new InvalidArgumentException('$userInfos must be strings or instances of UserInfo.');
|
||||||
|
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@ -267,8 +264,8 @@ class Sessions {
|
||||||
} else throw new RuntimeException('Failsafe to prevent all sessions from being updated at once somehow.');
|
} else throw new RuntimeException('Failsafe to prevent all sessions from being updated at once somehow.');
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
$stmt->addParameter(1, $remoteAddr);
|
$stmt->nextParameter($remoteAddr);
|
||||||
$stmt->addParameter(2, $value);
|
$stmt->nextParameter($value);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,8 @@ class TwoFactorAuthSessions {
|
||||||
$token = self::generateToken();
|
$token = self::generateToken();
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_auth_tfa (user_id, tfa_token) VALUES (?, ?)');
|
$stmt = $this->cache->get('INSERT INTO msz_auth_tfa (user_id, tfa_token) VALUES (?, ?)');
|
||||||
$stmt->addParameter(1, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(2, $token);
|
$stmt->nextParameter($token);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $token;
|
return $token;
|
||||||
|
@ -32,7 +32,7 @@ class TwoFactorAuthSessions {
|
||||||
|
|
||||||
public function getTokenUserId(string $token): string {
|
public function getTokenUserId(string $token): string {
|
||||||
$stmt = $this->cache->get('SELECT user_id FROM msz_auth_tfa WHERE tfa_token = ? AND tfa_created > NOW() - INTERVAL 15 MINUTE');
|
$stmt = $this->cache->get('SELECT user_id FROM msz_auth_tfa WHERE tfa_token = ? AND tfa_created > NOW() - INTERVAL 15 MINUTE');
|
||||||
$stmt->addParameter(1, $token);
|
$stmt->nextParameter($token);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class TwoFactorAuthSessions {
|
||||||
|
|
||||||
public function deleteToken(string $token): void {
|
public function deleteToken(string $token): void {
|
||||||
$stmt = $this->cache->get('DELETE FROM msz_auth_tfa WHERE tfa_token = ?');
|
$stmt = $this->cache->get('DELETE FROM msz_auth_tfa WHERE tfa_token = ?');
|
||||||
$stmt->addParameter(1, $token);
|
$stmt->nextParameter($token);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,14 +96,13 @@ class Changelog {
|
||||||
}
|
}
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
if($hasDateTime)
|
if($hasDateTime)
|
||||||
$stmt->addParameter(++$args, $dateTime);
|
$stmt->nextParameter($dateTime);
|
||||||
if($hasTags)
|
if($hasTags)
|
||||||
foreach($tags as $tag)
|
foreach($tags as $tag)
|
||||||
$stmt->addParameter(++$args, (string)$tag);
|
$stmt->nextParameter((string)$tag);
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -157,17 +156,16 @@ class Changelog {
|
||||||
$query .= ' LIMIT ? OFFSET ?';
|
$query .= ' LIMIT ? OFFSET ?';
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
if($hasDateTime)
|
if($hasDateTime)
|
||||||
$stmt->addParameter(++$args, $dateTime);
|
$stmt->nextParameter($dateTime);
|
||||||
if($hasTags)
|
if($hasTags)
|
||||||
foreach($tags as $tag)
|
foreach($tags as $tag)
|
||||||
$stmt->addParameter(++$args, (string)$tag);
|
$stmt->nextParameter((string)$tag);
|
||||||
if($hasPagination) {
|
if($hasPagination) {
|
||||||
$stmt->addParameter(++$args, $pagination->range);
|
$stmt->nextParameter($pagination->range);
|
||||||
$stmt->addParameter(++$args, $pagination->offset);
|
$stmt->nextParameter($pagination->offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@ -177,7 +175,7 @@ class Changelog {
|
||||||
|
|
||||||
public function getChange(string $changeId): ChangeInfo {
|
public function getChange(string $changeId): ChangeInfo {
|
||||||
$stmt = $this->cache->get('SELECT change_id, user_id, change_action, UNIX_TIMESTAMP(change_created), change_log, change_text FROM msz_changelog_changes WHERE change_id = ?');
|
$stmt = $this->cache->get('SELECT change_id, user_id, change_action, UNIX_TIMESTAMP(change_created), change_log, change_text FROM msz_changelog_changes WHERE change_id = ?');
|
||||||
$stmt->addParameter(1, $changeId);
|
$stmt->nextParameter($changeId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -210,11 +208,11 @@ class Changelog {
|
||||||
$body = null;
|
$body = null;
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_changelog_changes (user_id, change_action, change_created, change_log, change_text) VALUES (?, ?, FROM_UNIXTIME(?), ?, ?)');
|
$stmt = $this->cache->get('INSERT INTO msz_changelog_changes (user_id, change_action, change_created, change_log, change_text) VALUES (?, ?, FROM_UNIXTIME(?), ?, ?)');
|
||||||
$stmt->addParameter(1, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(2, $action);
|
$stmt->nextParameter($action);
|
||||||
$stmt->addParameter(3, $createdAt);
|
$stmt->nextParameter($createdAt);
|
||||||
$stmt->addParameter(4, $summary);
|
$stmt->nextParameter($summary);
|
||||||
$stmt->addParameter(5, $body);
|
$stmt->nextParameter($body);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $this->getChange((string)$this->dbConn->getLastInsertId());
|
return $this->getChange((string)$this->dbConn->getLastInsertId());
|
||||||
|
@ -225,7 +223,7 @@ class Changelog {
|
||||||
$infoOrId = $infoOrId->id;
|
$infoOrId = $infoOrId->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('DELETE FROM msz_changelog_changes WHERE change_id = ?');
|
$stmt = $this->cache->get('DELETE FROM msz_changelog_changes WHERE change_id = ?');
|
||||||
$stmt->addParameter(1, $infoOrId);
|
$stmt->nextParameter($infoOrId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,14 +260,14 @@ class Changelog {
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_changelog_changes SET change_action = COALESCE(?, change_action), change_log = COALESCE(?, change_log), change_text = IF(?, ?, change_text), user_id = IF(?, ?, user_id), change_created = COALESCE(FROM_UNIXTIME(?), change_created) WHERE change_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_changelog_changes SET change_action = COALESCE(?, change_action), change_log = COALESCE(?, change_log), change_text = IF(?, ?, change_text), user_id = IF(?, ?, user_id), change_created = COALESCE(FROM_UNIXTIME(?), change_created) WHERE change_id = ?');
|
||||||
$stmt->addParameter(1, $action);
|
$stmt->nextParameter($action);
|
||||||
$stmt->addParameter(2, $summary);
|
$stmt->nextParameter($summary);
|
||||||
$stmt->addParameter(3, $hasBody ? 1 : 0);
|
$stmt->nextParameter($hasBody ? 1 : 0);
|
||||||
$stmt->addParameter(4, $body);
|
$stmt->nextParameter($body);
|
||||||
$stmt->addParameter(5, $updateUserInfo ? 1 : 0);
|
$stmt->nextParameter($updateUserInfo ? 1 : 0);
|
||||||
$stmt->addParameter(6, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(7, $createdAt);
|
$stmt->nextParameter($createdAt);
|
||||||
$stmt->addParameter(8, $infoOrId);
|
$stmt->nextParameter($infoOrId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +286,7 @@ class Changelog {
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasChangeInfo)
|
if($hasChangeInfo)
|
||||||
$stmt->addParameter(1, $changeInfo);
|
$stmt->nextParameter($changeInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -307,7 +305,7 @@ class Changelog {
|
||||||
|
|
||||||
public function getTag(string $tagId): ChangeTagInfo {
|
public function getTag(string $tagId): ChangeTagInfo {
|
||||||
$stmt = $this->cache->get('SELECT tag_id, tag_name, tag_description, UNIX_TIMESTAMP(tag_created), UNIX_TIMESTAMP(tag_archived), 0 AS `tag_changes` FROM msz_changelog_tags WHERE tag_id = ?');
|
$stmt = $this->cache->get('SELECT tag_id, tag_name, tag_description, UNIX_TIMESTAMP(tag_created), UNIX_TIMESTAMP(tag_archived), 0 AS `tag_changes` FROM msz_changelog_tags WHERE tag_id = ?');
|
||||||
$stmt->addParameter(1, $tagId);
|
$stmt->nextParameter($tagId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -331,9 +329,9 @@ class Changelog {
|
||||||
$description = null;
|
$description = null;
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_changelog_tags (tag_name, tag_description, tag_archived) VALUES (?, ?, IF(?, NOW(), NULL))');
|
$stmt = $this->cache->get('INSERT INTO msz_changelog_tags (tag_name, tag_description, tag_archived) VALUES (?, ?, IF(?, NOW(), NULL))');
|
||||||
$stmt->addParameter(1, $name);
|
$stmt->nextParameter($name);
|
||||||
$stmt->addParameter(2, $description);
|
$stmt->nextParameter($description);
|
||||||
$stmt->addParameter(3, $archived ? 1 : 0);
|
$stmt->nextParameter($archived ? 1 : 0);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $this->getTag((string)$this->dbConn->getLastInsertId());
|
return $this->getTag((string)$this->dbConn->getLastInsertId());
|
||||||
|
@ -344,7 +342,7 @@ class Changelog {
|
||||||
$infoOrId = $infoOrId->id;
|
$infoOrId = $infoOrId->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('DELETE FROM msz_changelog_tags WHERE tag_id = ?');
|
$stmt = $this->cache->get('DELETE FROM msz_changelog_tags WHERE tag_id = ?');
|
||||||
$stmt->addParameter(1, $infoOrId);
|
$stmt->nextParameter($infoOrId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,12 +371,12 @@ class Changelog {
|
||||||
$hasArchived = $archived !== null;
|
$hasArchived = $archived !== null;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_changelog_tags SET tag_name = COALESCE(?, tag_name), tag_description = IF(?, ?, tag_description), tag_archived = IF(?, IF(?, NOW(), NULL), tag_archived) WHERE tag_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_changelog_tags SET tag_name = COALESCE(?, tag_name), tag_description = IF(?, ?, tag_description), tag_archived = IF(?, IF(?, NOW(), NULL), tag_archived) WHERE tag_id = ?');
|
||||||
$stmt->addParameter(1, $name);
|
$stmt->nextParameter($name);
|
||||||
$stmt->addParameter(2, $hasDescription ? 1 : 0);
|
$stmt->nextParameter($hasDescription ? 1 : 0);
|
||||||
$stmt->addParameter(3, $description);
|
$stmt->nextParameter($description);
|
||||||
$stmt->addParameter(4, $hasArchived ? 1 : 0);
|
$stmt->nextParameter($hasArchived ? 1 : 0);
|
||||||
$stmt->addParameter(5, $archived ? 1 : 0);
|
$stmt->nextParameter($archived ? 1 : 0);
|
||||||
$stmt->addParameter(6, $infoOrId);
|
$stmt->nextParameter($infoOrId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,8 +387,8 @@ class Changelog {
|
||||||
$tag = $tag->id;
|
$tag = $tag->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_changelog_change_tags (change_id, tag_id) VALUES (?, ?)');
|
$stmt = $this->cache->get('INSERT INTO msz_changelog_change_tags (change_id, tag_id) VALUES (?, ?)');
|
||||||
$stmt->addParameter(1, $change);
|
$stmt->nextParameter($change);
|
||||||
$stmt->addParameter(2, $tag);
|
$stmt->nextParameter($tag);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,8 +399,8 @@ class Changelog {
|
||||||
$tag = $tag->id;
|
$tag = $tag->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('DELETE FROM msz_changelog_change_tags WHERE change_id = ? AND tag_id = ?');
|
$stmt = $this->cache->get('DELETE FROM msz_changelog_change_tags WHERE change_id = ? AND tag_id = ?');
|
||||||
$stmt->addParameter(1, $change);
|
$stmt->nextParameter($change);
|
||||||
$stmt->addParameter(2, $tag);
|
$stmt->nextParameter($tag);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ class Comments {
|
||||||
$query .= ' WHERE owner_id = ?';
|
$query .= ' WHERE owner_id = ?';
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
$stmt->addParameter(1, $owner);
|
$stmt->nextParameter($owner);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
@ -61,12 +61,11 @@ class Comments {
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
if($hasOwner)
|
if($hasOwner)
|
||||||
$stmt->addParameter(++$args, $owner);
|
$stmt->nextParameter($owner);
|
||||||
if($hasPagination) {
|
if($hasPagination) {
|
||||||
$stmt->addParameter(++$args, $pagination->range);
|
$stmt->nextParameter($pagination->range);
|
||||||
$stmt->addParameter(++$args, $pagination->offset);
|
$stmt->nextParameter($pagination->offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@ -110,7 +109,7 @@ class Comments {
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
$stmt->addParameter(1, $value);
|
$stmt->nextParameter($value);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
|
||||||
|
@ -122,7 +121,7 @@ class Comments {
|
||||||
|
|
||||||
public function checkCategoryNameExists(string $name): bool {
|
public function checkCategoryNameExists(string $name): bool {
|
||||||
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_comments_categories WHERE category_name = ?');
|
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_comments_categories WHERE category_name = ?');
|
||||||
$stmt->addParameter(1, $name);
|
$stmt->nextParameter($name);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
@ -149,8 +148,8 @@ class Comments {
|
||||||
throw new InvalidArgumentException('$name may not be empty.');
|
throw new InvalidArgumentException('$name may not be empty.');
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_comments_categories (category_name, owner_id) VALUES (?, ?)');
|
$stmt = $this->cache->get('INSERT INTO msz_comments_categories (category_name, owner_id) VALUES (?, ?)');
|
||||||
$stmt->addParameter(1, $name);
|
$stmt->nextParameter($name);
|
||||||
$stmt->addParameter(2, $owner);
|
$stmt->nextParameter($owner);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $this->getCategory(categoryId: (string)$this->dbConn->getLastInsertId());
|
return $this->getCategory(categoryId: (string)$this->dbConn->getLastInsertId());
|
||||||
|
@ -161,7 +160,7 @@ class Comments {
|
||||||
$category = $category->id;
|
$category = $category->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('DELETE FROM msz_comments_categories WHERE category_id = ?');
|
$stmt = $this->cache->get('DELETE FROM msz_comments_categories WHERE category_id = ?');
|
||||||
$stmt->addParameter(1, $category);
|
$stmt->nextParameter($category);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,10 +182,10 @@ class Comments {
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_comments_categories SET category_name = COALESCE(?, category_name), owner_id = IF(?, ?, owner_id) WHERE category_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_comments_categories SET category_name = COALESCE(?, category_name), owner_id = IF(?, ?, owner_id) WHERE category_id = ?');
|
||||||
$stmt->addParameter(1, $name);
|
$stmt->nextParameter($name);
|
||||||
$stmt->addParameter(2, $updateOwner ? 1 : 0);
|
$stmt->nextParameter($updateOwner ? 1 : 0);
|
||||||
$stmt->addParameter(3, $owner ? 1 : 0);
|
$stmt->nextParameter($owner ? 1 : 0);
|
||||||
$stmt->addParameter(4, $category);
|
$stmt->nextParameter($category);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +194,7 @@ class Comments {
|
||||||
$category = $category->id;
|
$category = $category->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_comments_categories SET category_locked = COALESCE(category_locked, NOW()) WHERE category_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_comments_categories SET category_locked = COALESCE(category_locked, NOW()) WHERE category_id = ?');
|
||||||
$stmt->addParameter(1, $category);
|
$stmt->nextParameter($category);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +203,7 @@ class Comments {
|
||||||
$category = $category->id;
|
$category = $category->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_comments_categories SET category_locked = NULL WHERE category_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_comments_categories SET category_locked = NULL WHERE category_id = ?');
|
||||||
$stmt->addParameter(1, $category);
|
$stmt->nextParameter($category);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,14 +241,13 @@ class Comments {
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$query .= sprintf(' %s user_id = ?', ++$args > 1 ? 'AND' : 'WHERE');
|
$query .= sprintf(' %s user_id = ?', ++$args > 1 ? 'AND' : 'WHERE');
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasParentInfo)
|
if($hasParentInfo)
|
||||||
$stmt->addParameter(++$args, $parentInfo);
|
$stmt->nextParameter($parentInfo);
|
||||||
elseif($hasCategoryInfo)
|
elseif($hasCategoryInfo)
|
||||||
$stmt->addParameter(++$args, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo instanceof UserInfo ? $userInfo->id : $userInfo);
|
$stmt->nextParameter($userInfo instanceof UserInfo ? $userInfo->id : $userInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -314,14 +312,13 @@ class Comments {
|
||||||
else
|
else
|
||||||
$query .= ' ORDER BY comment_created DESC';
|
$query .= ' ORDER BY comment_created DESC';
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasParentInfo)
|
if($hasParentInfo)
|
||||||
$stmt->addParameter(++$args, $parentInfo);
|
$stmt->nextParameter($parentInfo);
|
||||||
elseif($hasCategoryInfo)
|
elseif($hasCategoryInfo)
|
||||||
$stmt->addParameter(++$args, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo instanceof UserInfo ? $userInfo->id : $userInfo);
|
$stmt->nextParameter($userInfo instanceof UserInfo ? $userInfo->id : $userInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $stmt->getResult()->getIterator(fn($result) => CommentsPostInfo::fromResult($result, $includeRepliesCount, $includeVotesCount));
|
return $stmt->getResult()->getIterator(fn($result) => CommentsPostInfo::fromResult($result, $includeRepliesCount, $includeVotesCount));
|
||||||
|
@ -343,7 +340,7 @@ class Comments {
|
||||||
$query .= ' FROM msz_comments_posts AS cpp WHERE comment_id = ?';
|
$query .= ' FROM msz_comments_posts AS cpp WHERE comment_id = ?';
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
$stmt->addParameter(1, $postId);
|
$stmt->nextParameter($postId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -377,11 +374,11 @@ class Comments {
|
||||||
throw new InvalidArgumentException('$body may not be empty.');
|
throw new InvalidArgumentException('$body may not be empty.');
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_comments_posts (category_id, user_id, comment_reply_to, comment_text, comment_pinned) VALUES (?, ?, ?, ?, IF(?, NOW(), NULL))');
|
$stmt = $this->cache->get('INSERT INTO msz_comments_posts (category_id, user_id, comment_reply_to, comment_text, comment_pinned) VALUES (?, ?, ?, ?, IF(?, NOW(), NULL))');
|
||||||
$stmt->addParameter(1, $category);
|
$stmt->nextParameter($category);
|
||||||
$stmt->addParameter(2, $user);
|
$stmt->nextParameter($user);
|
||||||
$stmt->addParameter(3, $parent);
|
$stmt->nextParameter($parent);
|
||||||
$stmt->addParameter(4, $body);
|
$stmt->nextParameter($body);
|
||||||
$stmt->addParameter(5, $pin ? 1 : 0);
|
$stmt->nextParameter($pin ? 1 : 0);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $this->getPost((string)$this->dbConn->getLastInsertId());
|
return $this->getPost((string)$this->dbConn->getLastInsertId());
|
||||||
|
@ -392,7 +389,7 @@ class Comments {
|
||||||
$infoOrId = $infoOrId->id;
|
$infoOrId = $infoOrId->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_comments_posts SET comment_deleted = COALESCE(comment_deleted, NOW()) WHERE comment_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_comments_posts SET comment_deleted = COALESCE(comment_deleted, NOW()) WHERE comment_id = ?');
|
||||||
$stmt->addParameter(1, $infoOrId);
|
$stmt->nextParameter($infoOrId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,7 +398,7 @@ class Comments {
|
||||||
$infoOrId = $infoOrId->id;
|
$infoOrId = $infoOrId->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('DELETE FROM msz_comments_posts WHERE comment_id = ?');
|
$stmt = $this->cache->get('DELETE FROM msz_comments_posts WHERE comment_id = ?');
|
||||||
$stmt->addParameter(1, $infoOrId);
|
$stmt->nextParameter($infoOrId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,7 +407,7 @@ class Comments {
|
||||||
$infoOrId = $infoOrId->id;
|
$infoOrId = $infoOrId->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_comments_posts SET comment_deleted = NULL WHERE comment_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_comments_posts SET comment_deleted = NULL WHERE comment_id = ?');
|
||||||
$stmt->addParameter(1, $infoOrId);
|
$stmt->nextParameter($infoOrId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,8 +419,8 @@ class Comments {
|
||||||
throw new InvalidArgumentException('$body may not be empty.');
|
throw new InvalidArgumentException('$body may not be empty.');
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_comments_posts SET comment_text = ?, comment_edited = NOW() WHERE comment_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_comments_posts SET comment_text = ?, comment_edited = NOW() WHERE comment_id = ?');
|
||||||
$stmt->addParameter(1, $body);
|
$stmt->nextParameter($body);
|
||||||
$stmt->addParameter(2, $infoOrId);
|
$stmt->nextParameter($infoOrId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,7 +429,7 @@ class Comments {
|
||||||
$infoOrId = $infoOrId->id;
|
$infoOrId = $infoOrId->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_comments_posts SET comment_pinned = COALESCE(comment_pinned, NOW()) WHERE comment_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_comments_posts SET comment_pinned = COALESCE(comment_pinned, NOW()) WHERE comment_id = ?');
|
||||||
$stmt->addParameter(1, $infoOrId);
|
$stmt->nextParameter($infoOrId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,7 +438,7 @@ class Comments {
|
||||||
$infoOrId = $infoOrId->id;
|
$infoOrId = $infoOrId->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_comments_posts SET comment_pinned = NULL WHERE comment_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_comments_posts SET comment_pinned = NULL WHERE comment_id = ?');
|
||||||
$stmt->addParameter(1, $infoOrId);
|
$stmt->nextParameter($infoOrId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,8 +453,8 @@ class Comments {
|
||||||
|
|
||||||
// SUM() here makes it so a result row is always returned, albeit with just NULLs
|
// SUM() here makes it so a result row is always returned, albeit with just NULLs
|
||||||
$stmt = $this->cache->get('SELECT comment_id, user_id, SUM(comment_vote) FROM msz_comments_votes WHERE comment_id = ? AND user_id = ?');
|
$stmt = $this->cache->get('SELECT comment_id, user_id, SUM(comment_vote) FROM msz_comments_votes WHERE comment_id = ? AND user_id = ?');
|
||||||
$stmt->addParameter(1, $post);
|
$stmt->nextParameter($post);
|
||||||
$stmt->addParameter(2, $user);
|
$stmt->nextParameter($user);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -480,9 +477,9 @@ class Comments {
|
||||||
$user = $user->id;
|
$user = $user->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('REPLACE INTO msz_comments_votes (comment_id, user_id, comment_vote) VALUES (?, ?, ?)');
|
$stmt = $this->cache->get('REPLACE INTO msz_comments_votes (comment_id, user_id, comment_vote) VALUES (?, ?, ?)');
|
||||||
$stmt->addParameter(1, $post);
|
$stmt->nextParameter($post);
|
||||||
$stmt->addParameter(2, $user);
|
$stmt->nextParameter($user);
|
||||||
$stmt->addParameter(3, $weight);
|
$stmt->nextParameter($weight);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -504,8 +501,8 @@ class Comments {
|
||||||
$user = $user->id;
|
$user = $user->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('DELETE FROM msz_comments_votes WHERE comment_id = ? AND user_id = ?');
|
$stmt = $this->cache->get('DELETE FROM msz_comments_votes WHERE comment_id = ? AND user_id = ?');
|
||||||
$stmt->addParameter(1, $post);
|
$stmt->nextParameter($post);
|
||||||
$stmt->addParameter(2, $user);
|
$stmt->nextParameter($user);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,11 +38,10 @@ class Counters {
|
||||||
if($hasPagination)
|
if($hasPagination)
|
||||||
$query .= ' LIMIT ? OFFSET ?';
|
$query .= ' LIMIT ? OFFSET ?';
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasPagination) {
|
if($hasPagination) {
|
||||||
$stmt->addParameter(++$args, $pagination->range);
|
$stmt->nextParameter($pagination->range);
|
||||||
$stmt->addParameter(++$args, $pagination->offset);
|
$stmt->nextParameter($pagination->offset);
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
|
@ -59,13 +58,12 @@ class Counters {
|
||||||
$names = [$names];
|
$names = [$names];
|
||||||
} else $returnFirst = false;
|
} else $returnFirst = false;
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get(sprintf(
|
$stmt = $this->cache->get(sprintf(
|
||||||
'SELECT counter_name, counter_value FROM msz_counters WHERE counter_name IN (%s)',
|
'SELECT counter_name, counter_value FROM msz_counters WHERE counter_name IN (%s)',
|
||||||
DbTools::prepareListString($names)
|
DbTools::prepareListString($names)
|
||||||
));
|
));
|
||||||
foreach($names as $name)
|
foreach($names as $name)
|
||||||
$stmt->addParameter(++$args, (string)$name);
|
$stmt->nextParameter((string)$name);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$values = [];
|
$values = [];
|
||||||
|
@ -89,15 +87,14 @@ class Counters {
|
||||||
} else $values = $nameOrValues;
|
} else $values = $nameOrValues;
|
||||||
|
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get(sprintf(
|
$stmt = $this->cache->get(sprintf(
|
||||||
'REPLACE INTO msz_counters (counter_name, counter_value) VALUES %s',
|
'REPLACE INTO msz_counters (counter_name, counter_value) VALUES %s',
|
||||||
DbTools::prepareListString($values, '(?, ?)')
|
DbTools::prepareListString($values, '(?, ?)')
|
||||||
));
|
));
|
||||||
|
|
||||||
foreach($values as $name => $value) {
|
foreach($values as $name => $value) {
|
||||||
$stmt->addParameter(++$args, (string)$name);
|
$stmt->nextParameter((string)$name);
|
||||||
$stmt->addParameter(++$args, (int)$value);
|
$stmt->nextParameter((int)$value);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@ -110,29 +107,28 @@ class Counters {
|
||||||
if(is_string($names))
|
if(is_string($names))
|
||||||
$names = [$names];
|
$names = [$names];
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get(sprintf(
|
$stmt = $this->cache->get(sprintf(
|
||||||
'DELETE FROM msz_counters WHERE counter_name IN (%s)',
|
'DELETE FROM msz_counters WHERE counter_name IN (%s)',
|
||||||
DbTools::prepareListString($names)
|
DbTools::prepareListString($names)
|
||||||
));
|
));
|
||||||
foreach($names as $name)
|
foreach($names as $name)
|
||||||
$stmt->addParameter(++$args, (string)$name);
|
$stmt->nextParameter((string)$name);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function increment(string $name, int $step = 1): void {
|
public function increment(string $name, int $step = 1): void {
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_counters (counter_name, counter_value) VALUES (?, ?) ON DUPLICATE KEY UPDATE counter_value = counter_value + ?');
|
$stmt = $this->cache->get('INSERT INTO msz_counters (counter_name, counter_value) VALUES (?, ?) ON DUPLICATE KEY UPDATE counter_value = counter_value + ?');
|
||||||
$stmt->addParameter(1, $name);
|
$stmt->nextParameter($name);
|
||||||
$stmt->addParameter(2, $step);
|
$stmt->nextParameter($step);
|
||||||
$stmt->addParameter(3, $step);
|
$stmt->nextParameter($step);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function decrement(string $name, int $step = 1): void {
|
public function decrement(string $name, int $step = 1): void {
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_counters (counter_name, counter_value) VALUES (?, ?) ON DUPLICATE KEY UPDATE counter_value = counter_value - ?');
|
$stmt = $this->cache->get('INSERT INTO msz_counters (counter_name, counter_value) VALUES (?, ?) ON DUPLICATE KEY UPDATE counter_value = counter_value - ?');
|
||||||
$stmt->addParameter(1, $name);
|
$stmt->nextParameter($name);
|
||||||
$stmt->addParameter(2, -$step);
|
$stmt->nextParameter(-$step);
|
||||||
$stmt->addParameter(3, $step);
|
$stmt->nextParameter($step);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Emotes {
|
||||||
|
|
||||||
public function getEmote(string $emoteId): EmoteInfo {
|
public function getEmote(string $emoteId): EmoteInfo {
|
||||||
$stmt = $this->cache->get('SELECT emote_id, emote_order, emote_hierarchy, emote_url FROM msz_emoticons WHERE emote_id = ?');
|
$stmt = $this->cache->get('SELECT emote_id, emote_order, emote_hierarchy, emote_url FROM msz_emoticons WHERE emote_id = ?');
|
||||||
$stmt->addParameter(1, $emoteId);
|
$stmt->nextParameter($emoteId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -65,7 +65,7 @@ class Emotes {
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasMinRank)
|
if($hasMinRank)
|
||||||
$stmt->addParameter(1, $minRank);
|
$stmt->nextParameter($minRank);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $stmt->getResult()->getIterator(EmoteInfo::fromResult(...));
|
return $stmt->getResult()->getIterator(EmoteInfo::fromResult(...));
|
||||||
|
@ -86,7 +86,7 @@ class Emotes {
|
||||||
return $check;
|
return $check;
|
||||||
|
|
||||||
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_emoticons WHERE emote_url = ?');
|
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_emoticons WHERE emote_url = ?');
|
||||||
$stmt->addParameter(1, $url);
|
$stmt->nextParameter($url);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
|
||||||
|
@ -102,9 +102,9 @@ class Emotes {
|
||||||
throw new InvalidArgumentException('$url is not correctly formatted: ' . $check);
|
throw new InvalidArgumentException('$url is not correctly formatted: ' . $check);
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_emoticons (emote_url, emote_hierarchy, emote_order) SELECT ?, ?, COALESCE(?, (SELECT FLOOR(MAX(emote_order) / 10) * 10 + 10 FROM msz_emoticons), 10)');
|
$stmt = $this->cache->get('INSERT INTO msz_emoticons (emote_url, emote_hierarchy, emote_order) SELECT ?, ?, COALESCE(?, (SELECT FLOOR(MAX(emote_order) / 10) * 10 + 10 FROM msz_emoticons), 10)');
|
||||||
$stmt->addParameter(1, $url);
|
$stmt->nextParameter($url);
|
||||||
$stmt->addParameter(2, $minRank);
|
$stmt->nextParameter($minRank);
|
||||||
$stmt->addParameter(3, $order);
|
$stmt->nextParameter($order);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $this->getEmote((string)$this->dbConn->getLastInsertId());
|
return $this->getEmote((string)$this->dbConn->getLastInsertId());
|
||||||
|
@ -115,7 +115,7 @@ class Emotes {
|
||||||
$infoOrId = $infoOrId->id;
|
$infoOrId = $infoOrId->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('DELETE FROM msz_emoticons WHERE emote_id = ?');
|
$stmt = $this->cache->get('DELETE FROM msz_emoticons WHERE emote_id = ?');
|
||||||
$stmt->addParameter(1, $infoOrId);
|
$stmt->nextParameter($infoOrId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,10 +135,10 @@ class Emotes {
|
||||||
$infoOrId = $infoOrId->id;
|
$infoOrId = $infoOrId->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_emoticons SET emote_order = COALESCE(?, emote_order), emote_hierarchy = COALESCE(?, emote_hierarchy), emote_url = COALESCE(?, emote_url) WHERE emote_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_emoticons SET emote_order = COALESCE(?, emote_order), emote_hierarchy = COALESCE(?, emote_hierarchy), emote_url = COALESCE(?, emote_url) WHERE emote_id = ?');
|
||||||
$stmt->addParameter(1, $order);
|
$stmt->nextParameter($order);
|
||||||
$stmt->addParameter(2, $minRank);
|
$stmt->nextParameter($minRank);
|
||||||
$stmt->addParameter(3, $url);
|
$stmt->nextParameter($url);
|
||||||
$stmt->addParameter(4, $infoOrId);
|
$stmt->nextParameter($infoOrId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,8 +148,8 @@ class Emotes {
|
||||||
$infoOrId = $infoOrId->id;
|
$infoOrId = $infoOrId->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_emoticons SET emote_order = emote_order + ? WHERE emote_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_emoticons SET emote_order = emote_order + ? WHERE emote_id = ?');
|
||||||
$stmt->addParameter(1, $offset);
|
$stmt->nextParameter($offset);
|
||||||
$stmt->addParameter(2, $infoOrId);
|
$stmt->nextParameter($infoOrId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ class Emotes {
|
||||||
$infoOrId = $infoOrId->id;
|
$infoOrId = $infoOrId->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('SELECT emote_id, emote_string_order, emote_string FROM msz_emoticons_strings WHERE emote_id = ? ORDER BY emote_string_order');
|
$stmt = $this->cache->get('SELECT emote_id, emote_string_order, emote_string FROM msz_emoticons_strings WHERE emote_id = ? ORDER BY emote_string_order');
|
||||||
$stmt->addParameter(1, $infoOrId);
|
$stmt->nextParameter($infoOrId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $stmt->getResult()->getIterator(EmoteStringInfo::fromResult(...));
|
return $stmt->getResult()->getIterator(EmoteStringInfo::fromResult(...));
|
||||||
|
@ -184,7 +184,7 @@ class Emotes {
|
||||||
return $check;
|
return $check;
|
||||||
|
|
||||||
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_emoticons_strings WHERE emote_string = ?');
|
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_emoticons_strings WHERE emote_string = ?');
|
||||||
$stmt->addParameter(1, $string);
|
$stmt->nextParameter($string);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
|
||||||
|
@ -203,9 +203,9 @@ class Emotes {
|
||||||
$infoOrId = $infoOrId->id;
|
$infoOrId = $infoOrId->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_emoticons_strings (emote_id, emote_string, emote_string_order) SELECT ? AS target_emote_id, ?, COALESCE(?, (SELECT MAX(emote_string_order) + 1 FROM msz_emoticons_strings WHERE emote_id = target_emote_id), 1)');
|
$stmt = $this->cache->get('INSERT INTO msz_emoticons_strings (emote_id, emote_string, emote_string_order) SELECT ? AS target_emote_id, ?, COALESCE(?, (SELECT MAX(emote_string_order) + 1 FROM msz_emoticons_strings WHERE emote_id = target_emote_id), 1)');
|
||||||
$stmt->addParameter(1, $infoOrId);
|
$stmt->nextParameter($infoOrId);
|
||||||
$stmt->addParameter(2, $string);
|
$stmt->nextParameter($string);
|
||||||
$stmt->addParameter(3, $order);
|
$stmt->nextParameter($order);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ class Emotes {
|
||||||
$infoOrString = $infoOrString->string;
|
$infoOrString = $infoOrString->string;
|
||||||
|
|
||||||
$stmt = $this->cache->get('DELETE FROM msz_emoticons_strings WHERE emote_string = ?');
|
$stmt = $this->cache->get('DELETE FROM msz_emoticons_strings WHERE emote_string = ?');
|
||||||
$stmt->addParameter(1, $infoOrString);
|
$stmt->nextParameter($infoOrString);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,12 +88,11 @@ class ForumCategories {
|
||||||
if($hasHidden)
|
if($hasHidden)
|
||||||
$query .= sprintf(' %s forum_hidden %s 0', ++$args > 1 ? 'AND' : 'WHERE', $hidden ? '<>' : '=');
|
$query .= sprintf(' %s forum_hidden %s 0', ++$args > 1 ? 'AND' : 'WHERE', $hidden ? '<>' : '=');
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasParentInfo && !$isRootParent)
|
if($hasParentInfo && !$isRootParent)
|
||||||
$stmt->addParameter(++$args, $parentInfo);
|
$stmt->nextParameter($parentInfo);
|
||||||
if($hasType)
|
if($hasType)
|
||||||
$stmt->addParameter(++$args, $type);
|
$stmt->nextParameter($type);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -143,19 +142,18 @@ class ForumCategories {
|
||||||
if($hasPagination)
|
if($hasPagination)
|
||||||
$query .= ' LIMIT ? OFFSET ?';
|
$query .= ' LIMIT ? OFFSET ?';
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasParentInfo && !$isRootParent) {
|
if($hasParentInfo && !$isRootParent) {
|
||||||
if($parentInfo instanceof ForumCategoryInfo)
|
if($parentInfo instanceof ForumCategoryInfo)
|
||||||
$stmt->addParameter(++$args, $parentInfo->id);
|
$stmt->nextParameter($parentInfo->id);
|
||||||
else
|
else
|
||||||
$stmt->addParameter(++$args, $parentInfo);
|
$stmt->nextParameter($parentInfo);
|
||||||
}
|
}
|
||||||
if($hasType)
|
if($hasType)
|
||||||
$stmt->addParameter(++$args, $type);
|
$stmt->nextParameter($type);
|
||||||
if($hasPagination) {
|
if($hasPagination) {
|
||||||
$stmt->addParameter(++$args, $pagination->range);
|
$stmt->nextParameter($pagination->range);
|
||||||
$stmt->addParameter(++$args, $pagination->offset);
|
$stmt->nextParameter($pagination->offset);
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
|
@ -209,7 +207,7 @@ class ForumCategories {
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
$stmt->addParameter(1, $value);
|
$stmt->nextParameter($value);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -237,7 +235,7 @@ class ForumCategories {
|
||||||
|
|
||||||
// previous implementation also WHERE'd for forum_type = link but i don't think there's any other way to get here anyhow
|
// previous implementation also WHERE'd for forum_type = link but i don't think there's any other way to get here anyhow
|
||||||
$stmt = $this->cache->get('UPDATE msz_forum_categories SET forum_link_clicks = forum_link_clicks + 1 WHERE forum_id = ? AND forum_link_clicks IS NOT NULL');
|
$stmt = $this->cache->get('UPDATE msz_forum_categories SET forum_link_clicks = forum_link_clicks + 1 WHERE forum_id = ? AND forum_link_clicks IS NOT NULL');
|
||||||
$stmt->addParameter(1, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +244,7 @@ class ForumCategories {
|
||||||
$categoryInfo = $categoryInfo->id;
|
$categoryInfo = $categoryInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_forum_categories SET forum_count_topics = forum_count_topics + 1 WHERE forum_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_forum_categories SET forum_count_topics = forum_count_topics + 1 WHERE forum_id = ?');
|
||||||
$stmt->addParameter(1, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +253,7 @@ class ForumCategories {
|
||||||
$categoryInfo = $categoryInfo->id;
|
$categoryInfo = $categoryInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_forum_categories SET forum_count_posts = forum_count_posts + 1 WHERE forum_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_forum_categories SET forum_count_posts = forum_count_posts + 1 WHERE forum_id = ?');
|
||||||
$stmt->addParameter(1, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +273,7 @@ class ForumCategories {
|
||||||
. ') SELECT * FROM msz_cte_ancestry';
|
. ') SELECT * FROM msz_cte_ancestry';
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
$stmt->addParameter(1, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $stmt->getResult()->getIterator(ForumCategoryInfo::fromResult(...));
|
return $stmt->getResult()->getIterator(ForumCategoryInfo::fromResult(...));
|
||||||
|
@ -335,17 +333,16 @@ class ForumCategories {
|
||||||
if($userInfo instanceof UserInfo)
|
if($userInfo instanceof UserInfo)
|
||||||
$userInfo = $userInfo->id;
|
$userInfo = $userInfo->id;
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get(sprintf(
|
$stmt = $this->cache->get(sprintf(
|
||||||
'SELECT COUNT(*) FROM msz_forum_topics AS ft LEFT JOIN msz_forum_topics_track AS ftt ON ftt.topic_id = ft.topic_id AND ftt.user_id = ? WHERE ft.forum_id IN (%s) AND ft.topic_deleted IS NULL AND ft.topic_bumped >= NOW() - INTERVAL 1 MONTH AND (ftt.track_last_read IS NULL OR ftt.track_last_read < ft.topic_bumped)',
|
'SELECT COUNT(*) FROM msz_forum_topics AS ft LEFT JOIN msz_forum_topics_track AS ftt ON ftt.topic_id = ft.topic_id AND ftt.user_id = ? WHERE ft.forum_id IN (%s) AND ft.topic_deleted IS NULL AND ft.topic_bumped >= NOW() - INTERVAL 1 MONTH AND (ftt.track_last_read IS NULL OR ftt.track_last_read < ft.topic_bumped)',
|
||||||
DbTools::prepareListString($categoryInfos)
|
DbTools::prepareListString($categoryInfos)
|
||||||
));
|
));
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
foreach($categoryInfos as $categoryInfo) {
|
foreach($categoryInfos as $categoryInfo) {
|
||||||
if($categoryInfo instanceof ForumCategoryInfo)
|
if($categoryInfo instanceof ForumCategoryInfo)
|
||||||
$stmt->addParameter(++$args, $categoryInfo->id);
|
$stmt->nextParameter($categoryInfo->id);
|
||||||
elseif(is_string($categoryInfo) || is_int($categoryInfo))
|
elseif(is_string($categoryInfo) || is_int($categoryInfo))
|
||||||
$stmt->addParameter(++$args, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
else
|
else
|
||||||
throw new InvalidArgumentException('Invalid item in $categoryInfos.');
|
throw new InvalidArgumentException('Invalid item in $categoryInfos.');
|
||||||
}
|
}
|
||||||
|
@ -368,8 +365,8 @@ class ForumCategories {
|
||||||
$categoryInfo = $categoryInfo->id;
|
$categoryInfo = $categoryInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('REPLACE INTO msz_forum_topics_track (user_id, topic_id, forum_id, track_last_read) SELECT ?, topic_id, forum_id, NOW() FROM msz_forum_topics WHERE forum_id = ? AND topic_bumped >= NOW() - INTERVAL 1 MONTH');
|
$stmt = $this->cache->get('REPLACE INTO msz_forum_topics_track (user_id, topic_id, forum_id, track_last_read) SELECT ?, topic_id, forum_id, NOW() FROM msz_forum_topics WHERE forum_id = ? AND topic_bumped >= NOW() - INTERVAL 1 MONTH');
|
||||||
$stmt->addParameter(1, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(2, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,7 +385,7 @@ class ForumCategories {
|
||||||
. ') SELECT forum_colour FROM msz_cte_colours WHERE forum_colour IS NOT NULL';
|
. ') SELECT forum_colour FROM msz_cte_colours WHERE forum_colour IS NOT NULL';
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
$stmt->addParameter(1, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -421,22 +418,21 @@ class ForumCategories {
|
||||||
$query .= sprintf(' AND topic_id NOT IN (%s)', DbTools::prepareListString($exceptTopicInfos));
|
$query .= sprintf(' AND topic_id NOT IN (%s)', DbTools::prepareListString($exceptTopicInfos));
|
||||||
$query .= ' GROUP BY forum_id ORDER BY post_count DESC LIMIT 1';
|
$query .= ' GROUP BY forum_id ORDER BY post_count DESC LIMIT 1';
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
foreach($exceptCategoryInfos as $categoryInfo) {
|
foreach($exceptCategoryInfos as $categoryInfo) {
|
||||||
if($categoryInfo instanceof ForumCategoryInfo)
|
if($categoryInfo instanceof ForumCategoryInfo)
|
||||||
$stmt->addParameter(++$args, $categoryInfo->id);
|
$stmt->nextParameter($categoryInfo->id);
|
||||||
elseif(is_string($categoryInfo) || is_int($categoryInfo))
|
elseif(is_string($categoryInfo) || is_int($categoryInfo))
|
||||||
$stmt->addParameter(++$args, (string)$categoryInfo);
|
$stmt->nextParameter((string)$categoryInfo);
|
||||||
else
|
else
|
||||||
throw new InvalidArgumentException('$exceptCategoryInfos may only contain string ids or instances of ForumCategoryInfo.');
|
throw new InvalidArgumentException('$exceptCategoryInfos may only contain string ids or instances of ForumCategoryInfo.');
|
||||||
}
|
}
|
||||||
foreach($exceptTopicInfos as $topicInfo) {
|
foreach($exceptTopicInfos as $topicInfo) {
|
||||||
if($topicInfo instanceof ForumTopicInfo)
|
if($topicInfo instanceof ForumTopicInfo)
|
||||||
$stmt->addParameter(++$args, $topicInfo->id);
|
$stmt->nextParameter($topicInfo->id);
|
||||||
elseif(is_string($topicInfo) || is_int($topicInfo))
|
elseif(is_string($topicInfo) || is_int($topicInfo))
|
||||||
$stmt->addParameter(++$args, (string)$topicInfo);
|
$stmt->nextParameter((string)$topicInfo);
|
||||||
else
|
else
|
||||||
throw new InvalidArgumentException('$exceptTopicInfos may only contain string ids or instances of ForumTopicInfo.');
|
throw new InvalidArgumentException('$exceptTopicInfos may only contain string ids or instances of ForumTopicInfo.');
|
||||||
}
|
}
|
||||||
|
@ -465,7 +461,7 @@ class ForumCategories {
|
||||||
$counters = new stdClass;
|
$counters = new stdClass;
|
||||||
|
|
||||||
$stmt = $this->cache->get('SELECT ? AS target_category_id, (SELECT COUNT(*) FROM msz_forum_topics WHERE forum_id = target_category_id AND topic_deleted IS NULL) AS count_topics, (SELECT COUNT(*) FROM msz_forum_posts WHERE forum_id = target_category_id AND post_deleted IS NULL) AS count_posts');
|
$stmt = $this->cache->get('SELECT ? AS target_category_id, (SELECT COUNT(*) FROM msz_forum_topics WHERE forum_id = target_category_id AND topic_deleted IS NULL) AS count_topics, (SELECT COUNT(*) FROM msz_forum_posts WHERE forum_id = target_category_id AND post_deleted IS NULL) AS count_posts');
|
||||||
$stmt->addParameter(1, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -476,7 +472,7 @@ class ForumCategories {
|
||||||
$counters->posts = $result->getInteger(2);
|
$counters->posts = $result->getInteger(2);
|
||||||
|
|
||||||
$stmt = $this->cache->get('SELECT forum_id FROM msz_forum_categories WHERE forum_parent = ?');
|
$stmt = $this->cache->get('SELECT forum_id FROM msz_forum_categories WHERE forum_parent = ?');
|
||||||
$stmt->addParameter(1, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$children = [];
|
$children = [];
|
||||||
|
@ -492,9 +488,9 @@ class ForumCategories {
|
||||||
|
|
||||||
if($updateCounters && $categoryInfo !== '0') {
|
if($updateCounters && $categoryInfo !== '0') {
|
||||||
$stmt = $this->cache->get('UPDATE msz_forum_categories SET forum_count_topics = ?, forum_count_posts = ? WHERE forum_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_forum_categories SET forum_count_topics = ?, forum_count_posts = ? WHERE forum_id = ?');
|
||||||
$stmt->addParameter(1, $counters->topics);
|
$stmt->nextParameter($counters->topics);
|
||||||
$stmt->addParameter(2, $counters->posts);
|
$stmt->nextParameter($counters->posts);
|
||||||
$stmt->addParameter(3, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,16 +55,15 @@ class ForumPosts {
|
||||||
if($hasDeleted)
|
if($hasDeleted)
|
||||||
$query .= sprintf(' %s post_deleted %s NULL', ++$args > 1 ? 'AND' : 'WHERE', $deleted ? 'IS NOT' : 'IS');
|
$query .= sprintf(' %s post_deleted %s NULL', ++$args > 1 ? 'AND' : 'WHERE', $deleted ? 'IS NOT' : 'IS');
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasCategoryInfo)
|
if($hasCategoryInfo)
|
||||||
$stmt->addParameter(++$args, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
if($hasTopicInfo)
|
if($hasTopicInfo)
|
||||||
$stmt->addParameter(++$args, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
if($hasUpToPostInfo)
|
if($hasUpToPostInfo)
|
||||||
$stmt->addParameter(++$args, $upToPostInfo);
|
$stmt->nextParameter($upToPostInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -164,30 +163,29 @@ class ForumPosts {
|
||||||
$query .= ' LIMIT ? OFFSET ?';
|
$query .= ' LIMIT ? OFFSET ?';
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasCategoryInfo) {
|
if($hasCategoryInfo) {
|
||||||
if(is_array($categoryInfo)) {
|
if(is_array($categoryInfo)) {
|
||||||
foreach($categoryInfo as $categoryInfoEntry)
|
foreach($categoryInfo as $categoryInfoEntry)
|
||||||
$stmt->addParameter(++$args, $categoryInfoEntry instanceof ForumCategoryInfo ? $categoryInfoEntry->id : (string)$categoryInfoEntry);
|
$stmt->nextParameter($categoryInfoEntry instanceof ForumCategoryInfo ? $categoryInfoEntry->id : (string)$categoryInfoEntry);
|
||||||
} else
|
} else
|
||||||
$stmt->addParameter(++$args, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
}
|
}
|
||||||
if($hasTopicInfo)
|
if($hasTopicInfo)
|
||||||
$stmt->addParameter(++$args, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
if($hasUpToPostInfo)
|
if($hasUpToPostInfo)
|
||||||
$stmt->addParameter(++$args, $upToPostInfo);
|
$stmt->nextParameter($upToPostInfo);
|
||||||
if($hasAfterPostInfo)
|
if($hasAfterPostInfo)
|
||||||
$stmt->addParameter(++$args, $afterPostInfo);
|
$stmt->nextParameter($afterPostInfo);
|
||||||
if($hasNewerThanDays)
|
if($hasNewerThanDays)
|
||||||
$stmt->addParameter(++$args, $newerThanDays);
|
$stmt->nextParameter($newerThanDays);
|
||||||
if($hasSearchQuery)
|
if($hasSearchQuery)
|
||||||
$stmt->addParameter(++$args, $searchQuery);
|
$stmt->nextParameter($searchQuery);
|
||||||
if($hasPagination) {
|
if($hasPagination) {
|
||||||
$stmt->addParameter(++$args, $pagination->range);
|
$stmt->nextParameter($pagination->range);
|
||||||
$stmt->addParameter(++$args, $pagination->offset);
|
$stmt->nextParameter($pagination->offset);
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
|
@ -254,10 +252,9 @@ class ForumPosts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
foreach($values as $value)
|
foreach($values as $value)
|
||||||
$stmt->addParameter(++$args, $value);
|
$stmt->nextParameter($value);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -289,13 +286,13 @@ class ForumPosts {
|
||||||
$userInfo = $userInfo->id;
|
$userInfo = $userInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_forum_posts (topic_id, forum_id, user_id, post_ip, post_text, post_parse, post_display_signature) VALUES (?, ?, ?, INET6_ATON(?), ?, ?, ?)');
|
$stmt = $this->cache->get('INSERT INTO msz_forum_posts (topic_id, forum_id, user_id, post_ip, post_text, post_parse, post_display_signature) VALUES (?, ?, ?, INET6_ATON(?), ?, ?, ?)');
|
||||||
$stmt->addParameter(1, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
$stmt->addParameter(2, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
$stmt->addParameter(3, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(4, $remoteAddr);
|
$stmt->nextParameter($remoteAddr);
|
||||||
$stmt->addParameter(5, $body);
|
$stmt->nextParameter($body);
|
||||||
$stmt->addParameter(6, $bodyParser);
|
$stmt->nextParameter($bodyParser);
|
||||||
$stmt->addParameter(7, $displaySignature ? 1 : 0);
|
$stmt->nextParameter($displaySignature ? 1 : 0);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $this->getPost(postId: (string)$this->dbConn->getLastInsertId());
|
return $this->getPost(postId: (string)$this->dbConn->getLastInsertId());
|
||||||
|
@ -341,11 +338,10 @@ class ForumPosts {
|
||||||
if($bumpEdited)
|
if($bumpEdited)
|
||||||
$fields[] = 'post_edited = NOW()';
|
$fields[] = 'post_edited = NOW()';
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get(sprintf('UPDATE msz_forum_posts SET %s WHERE post_id = ?', implode(', ', $fields)));
|
$stmt = $this->cache->get(sprintf('UPDATE msz_forum_posts SET %s WHERE post_id = ?', implode(', ', $fields)));
|
||||||
foreach($values as $value)
|
foreach($values as $value)
|
||||||
$stmt->addParameter(++$args, $value);
|
$stmt->nextParameter($value);
|
||||||
$stmt->addParameter(++$args, $postInfo);
|
$stmt->nextParameter($postInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +350,7 @@ class ForumPosts {
|
||||||
$postInfo = $postInfo->id;
|
$postInfo = $postInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_forum_posts SET post_deleted = COALESCE(post_deleted, NOW()) WHERE post_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_forum_posts SET post_deleted = COALESCE(post_deleted, NOW()) WHERE post_id = ?');
|
||||||
$stmt->addParameter(1, $postInfo);
|
$stmt->nextParameter($postInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,7 +359,7 @@ class ForumPosts {
|
||||||
$postInfo = $postInfo->id;
|
$postInfo = $postInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_forum_posts SET post_deleted = NULL WHERE post_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_forum_posts SET post_deleted = NULL WHERE post_id = ?');
|
||||||
$stmt->addParameter(1, $postInfo);
|
$stmt->nextParameter($postInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,7 +368,7 @@ class ForumPosts {
|
||||||
$postInfo = $postInfo->id;
|
$postInfo = $postInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('DELETE FROM msz_forum_posts WHERE post_id = ?');
|
$stmt = $this->cache->get('DELETE FROM msz_forum_posts WHERE post_id = ?');
|
||||||
$stmt->addParameter(1, $postInfo);
|
$stmt->nextParameter($postInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,7 +378,7 @@ class ForumPosts {
|
||||||
|
|
||||||
// intentionally including deleted posts
|
// intentionally including deleted posts
|
||||||
$stmt = $this->cache->get('SELECT UNIX_TIMESTAMP(MAX(post_created)) FROM msz_forum_posts WHERE user_id = ?');
|
$stmt = $this->cache->get('SELECT UNIX_TIMESTAMP(MAX(post_created)) FROM msz_forum_posts WHERE user_id = ?');
|
||||||
$stmt->addParameter(1, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -426,12 +422,11 @@ class ForumPosts {
|
||||||
$query .= sprintf(' AND topic_id NOT IN (%s)', DbTools::prepareListString($exceptTopicInfos));
|
$query .= sprintf(' AND topic_id NOT IN (%s)', DbTools::prepareListString($exceptTopicInfos));
|
||||||
$query .= ' GROUP BY user_id HAVING posts_count > 0 ORDER BY posts_count DESC';
|
$query .= ' GROUP BY user_id HAVING posts_count > 0 ORDER BY posts_count DESC';
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
foreach($exceptCategoryInfos as $exceptCategoryInfo)
|
foreach($exceptCategoryInfos as $exceptCategoryInfo)
|
||||||
$stmt->addParameter(++$args, $exceptCategoryInfo instanceof ForumCategoryInfo ? $exceptCategoryInfo->id : $exceptCategoryInfo);
|
$stmt->nextParameter($exceptCategoryInfo instanceof ForumCategoryInfo ? $exceptCategoryInfo->id : $exceptCategoryInfo);
|
||||||
foreach($exceptTopicInfos as $exceptTopicInfo)
|
foreach($exceptTopicInfos as $exceptTopicInfo)
|
||||||
$stmt->addParameter(++$args, $exceptTopicInfo instanceof ForumTopicInfo ? $exceptTopicInfo->id : $exceptTopicInfo);
|
$stmt->nextParameter($exceptTopicInfo instanceof ForumTopicInfo ? $exceptTopicInfo->id : $exceptTopicInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
|
|
@ -27,7 +27,7 @@ class ForumTopicRedirects {
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(1, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -51,13 +51,12 @@ class ForumTopicRedirects {
|
||||||
if($hasPagination)
|
if($hasPagination)
|
||||||
$query .= ' LIMIT ? OFFSET ?';
|
$query .= ' LIMIT ? OFFSET ?';
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
if($hasPagination) {
|
if($hasPagination) {
|
||||||
$stmt->addParameter(++$args, $pagination->range);
|
$stmt->nextParameter($pagination->range);
|
||||||
$stmt->addParameter(++$args, $pagination->offset);
|
$stmt->nextParameter($pagination->offset);
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
|
@ -69,7 +68,7 @@ class ForumTopicRedirects {
|
||||||
$topicInfo = $topicInfo->id;
|
$topicInfo = $topicInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_forum_topics_redirects WHERE topic_id = ?');
|
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_forum_topics_redirects WHERE topic_id = ?');
|
||||||
$stmt->addParameter(1, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -84,7 +83,7 @@ class ForumTopicRedirects {
|
||||||
$topicInfo = $topicInfo->id;
|
$topicInfo = $topicInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('SELECT topic_id, user_id, topic_redir_url, UNIX_TIMESTAMP(topic_redir_created) FROM msz_forum_topics_redirects WHERE topic_id = ?');
|
$stmt = $this->cache->get('SELECT topic_id, user_id, topic_redir_url, UNIX_TIMESTAMP(topic_redir_created) FROM msz_forum_topics_redirects WHERE topic_id = ?');
|
||||||
$stmt->addParameter(1, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -105,9 +104,9 @@ class ForumTopicRedirects {
|
||||||
$userInfo = $userInfo->id;
|
$userInfo = $userInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_forum_topics_redirects (topic_id, user_id, topic_redir_url) VALUES (?, ?, ?)');
|
$stmt = $this->cache->get('INSERT INTO msz_forum_topics_redirects (topic_id, user_id, topic_redir_url) VALUES (?, ?, ?)');
|
||||||
$stmt->addParameter(1, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
$stmt->addParameter(2, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(3, $linkTarget);
|
$stmt->nextParameter($linkTarget);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $this->getTopicRedirect($topicInfo);
|
return $this->getTopicRedirect($topicInfo);
|
||||||
|
@ -120,7 +119,7 @@ class ForumTopicRedirects {
|
||||||
$topicInfo = $topicInfo->id;
|
$topicInfo = $topicInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('DELETE FROM msz_forum_topics_redirects WHERE topic_id = ?');
|
$stmt = $this->cache->get('DELETE FROM msz_forum_topics_redirects WHERE topic_id = ?');
|
||||||
$stmt->addParameter(1, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,17 +66,16 @@ class ForumTopics {
|
||||||
if($hasDeleted)
|
if($hasDeleted)
|
||||||
$query .= sprintf(' %s topic_deleted %s NULL', ++$args > 1 ? 'AND' : 'WHERE', $deleted ? 'IS NOT' : 'IS');
|
$query .= sprintf(' %s topic_deleted %s NULL', ++$args > 1 ? 'AND' : 'WHERE', $deleted ? 'IS NOT' : 'IS');
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasCategoryInfo) {
|
if($hasCategoryInfo) {
|
||||||
if(is_array($categoryInfo)) {
|
if(is_array($categoryInfo)) {
|
||||||
foreach($categoryInfo as $categoryInfoEntry)
|
foreach($categoryInfo as $categoryInfoEntry)
|
||||||
$stmt->addParameter(++$args, $categoryInfoEntry instanceof ForumCategoryInfo ? $categoryInfoEntry->id : (string)$categoryInfoEntry);
|
$stmt->nextParameter($categoryInfoEntry instanceof ForumCategoryInfo ? $categoryInfoEntry->id : (string)$categoryInfoEntry);
|
||||||
} else
|
} else
|
||||||
$stmt->addParameter(++$args, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
}
|
}
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -177,24 +176,23 @@ class ForumTopics {
|
||||||
$query .= ' LIMIT ? OFFSET ?';
|
$query .= ' LIMIT ? OFFSET ?';
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasCategoryInfo) {
|
if($hasCategoryInfo) {
|
||||||
if(is_array($categoryInfo)) {
|
if(is_array($categoryInfo)) {
|
||||||
foreach($categoryInfo as $categoryInfoEntry)
|
foreach($categoryInfo as $categoryInfoEntry)
|
||||||
$stmt->addParameter(++$args, $categoryInfoEntry instanceof ForumCategoryInfo ? $categoryInfoEntry->id : (string)$categoryInfoEntry);
|
$stmt->nextParameter($categoryInfoEntry instanceof ForumCategoryInfo ? $categoryInfoEntry->id : (string)$categoryInfoEntry);
|
||||||
} else
|
} else
|
||||||
$stmt->addParameter(++$args, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
}
|
}
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
if($hasAfterTopicId)
|
if($hasAfterTopicId)
|
||||||
$stmt->addParameter(++$args, $afterTopicId);
|
$stmt->nextParameter($afterTopicId);
|
||||||
if($hasSearchQuery)
|
if($hasSearchQuery)
|
||||||
$stmt->addParameter(++$args, $searchQuery);
|
$stmt->nextParameter($searchQuery);
|
||||||
if($hasPagination) {
|
if($hasPagination) {
|
||||||
$stmt->addParameter(++$args, $pagination->range);
|
$stmt->nextParameter($pagination->range);
|
||||||
$stmt->addParameter(++$args, $pagination->offset);
|
$stmt->nextParameter($pagination->offset);
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
|
@ -234,7 +232,7 @@ class ForumTopics {
|
||||||
$query .= sprintf(' AND topic_deleted %s NULL', $deleted ? 'IS NOT' : 'IS');
|
$query .= sprintf(' AND topic_deleted %s NULL', $deleted ? 'IS NOT' : 'IS');
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
$stmt->addParameter(1, $value);
|
$stmt->nextParameter($value);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -261,10 +259,10 @@ class ForumTopics {
|
||||||
$userInfo = $userInfo->id;
|
$userInfo = $userInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_forum_topics (forum_id, user_id, topic_type, topic_title) VALUES (?, ?, ?, ?)');
|
$stmt = $this->cache->get('INSERT INTO msz_forum_topics (forum_id, user_id, topic_type, topic_title) VALUES (?, ?, ?, ?)');
|
||||||
$stmt->addParameter(1, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
$stmt->addParameter(2, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(3, $type);
|
$stmt->nextParameter($type);
|
||||||
$stmt->addParameter(4, $title);
|
$stmt->nextParameter($title);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $this->getTopic(topicId: (string)$this->dbConn->getLastInsertId());
|
return $this->getTopic(topicId: (string)$this->dbConn->getLastInsertId());
|
||||||
|
@ -301,11 +299,10 @@ class ForumTopics {
|
||||||
if(empty($fields))
|
if(empty($fields))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get(sprintf('UPDATE msz_forum_topics SET %s WHERE topic_id = ?', implode(', ', $fields)));
|
$stmt = $this->cache->get(sprintf('UPDATE msz_forum_topics SET %s WHERE topic_id = ?', implode(', ', $fields)));
|
||||||
foreach($values as $value)
|
foreach($values as $value)
|
||||||
$stmt->addParameter(++$args, $value);
|
$stmt->nextParameter($value);
|
||||||
$stmt->addParameter(++$args, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +311,7 @@ class ForumTopics {
|
||||||
$topicInfo = $topicInfo->id;
|
$topicInfo = $topicInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_forum_topics SET topic_count_views = topic_count_views + 1 WHERE topic_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_forum_topics SET topic_count_views = topic_count_views + 1 WHERE topic_id = ?');
|
||||||
$stmt->addParameter(1, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +320,7 @@ class ForumTopics {
|
||||||
$topicInfo = $topicInfo->id;
|
$topicInfo = $topicInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_forum_topics SET topic_bumped = NOW() WHERE topic_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_forum_topics SET topic_bumped = NOW() WHERE topic_id = ?');
|
||||||
$stmt->addParameter(1, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +329,7 @@ class ForumTopics {
|
||||||
$topicInfo = $topicInfo->id;
|
$topicInfo = $topicInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_forum_topics SET topic_locked = NOW() WHERE topic_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_forum_topics SET topic_locked = NOW() WHERE topic_id = ?');
|
||||||
$stmt->addParameter(1, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,7 +338,7 @@ class ForumTopics {
|
||||||
$topicInfo = $topicInfo->id;
|
$topicInfo = $topicInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_forum_topics SET topic_locked = NULL WHERE topic_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_forum_topics SET topic_locked = NULL WHERE topic_id = ?');
|
||||||
$stmt->addParameter(1, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,11 +347,11 @@ class ForumTopics {
|
||||||
$topicInfo = $topicInfo->id;
|
$topicInfo = $topicInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_forum_topics SET topic_deleted = COALESCE(topic_deleted, NOW()) WHERE topic_id = ? AND topic_deleted IS NULL');
|
$stmt = $this->cache->get('UPDATE msz_forum_topics SET topic_deleted = COALESCE(topic_deleted, NOW()) WHERE topic_id = ? AND topic_deleted IS NULL');
|
||||||
$stmt->addParameter(1, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_forum_posts AS fp SET post_deleted = (SELECT topic_deleted FROM msz_forum_topics WHERE topic_id = fp.topic_id) WHERE topic_id = ? AND post_deleted = NULL');
|
$stmt = $this->cache->get('UPDATE msz_forum_posts AS fp SET post_deleted = (SELECT topic_deleted FROM msz_forum_topics WHERE topic_id = fp.topic_id) WHERE topic_id = ? AND post_deleted = NULL');
|
||||||
$stmt->addParameter(1, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,11 +360,11 @@ class ForumTopics {
|
||||||
$topicInfo = $topicInfo->id;
|
$topicInfo = $topicInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_forum_posts AS fp SET post_deleted = NULL WHERE topic_id = ? AND post_deleted = (SELECT topic_deleted FROM msz_forum_topics WHERE topic_id = fp.topic_id)');
|
$stmt = $this->cache->get('UPDATE msz_forum_posts AS fp SET post_deleted = NULL WHERE topic_id = ? AND post_deleted = (SELECT topic_deleted FROM msz_forum_topics WHERE topic_id = fp.topic_id)');
|
||||||
$stmt->addParameter(1, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_forum_topics SET topic_deleted = NULL WHERE topic_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_forum_topics SET topic_deleted = NULL WHERE topic_id = ?');
|
||||||
$stmt->addParameter(1, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +373,7 @@ class ForumTopics {
|
||||||
$topicInfo = $topicInfo->id;
|
$topicInfo = $topicInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('DELETE FROM msz_forum_topics WHERE topic_id = ?');
|
$stmt = $this->cache->get('DELETE FROM msz_forum_topics WHERE topic_id = ?');
|
||||||
$stmt->addParameter(1, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,8 +389,8 @@ class ForumTopics {
|
||||||
$userInfo = $userInfo->id;
|
$userInfo = $userInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_forum_posts WHERE topic_id = ? AND user_id = ?');
|
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_forum_posts WHERE topic_id = ? AND user_id = ?');
|
||||||
$stmt->addParameter(1, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
$stmt->addParameter(2, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
|
||||||
|
@ -416,8 +413,8 @@ class ForumTopics {
|
||||||
$query .= ' AND track_last_read = (SELECT topic_bumped FROM msz_forum_topics WHERE topic_id = ftt.topic_id AND topic_bumped >= NOW() - INTERVAL 1 MONTH)';
|
$query .= ' AND track_last_read = (SELECT topic_bumped FROM msz_forum_topics WHERE topic_id = ftt.topic_id AND topic_bumped >= NOW() - INTERVAL 1 MONTH)';
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
$stmt->addParameter(1, $userInfo instanceof UserInfo ? $userInfo->id : $userInfo);
|
$stmt->nextParameter($userInfo instanceof UserInfo ? $userInfo->id : $userInfo);
|
||||||
$stmt->addParameter(2, $topicInfoIsInstance ? $topicInfo->id : $topicInfo);
|
$stmt->nextParameter($topicInfoIsInstance ? $topicInfo->id : $topicInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
|
||||||
|
@ -455,22 +452,21 @@ class ForumTopics {
|
||||||
$query .= sprintf(' AND topic_id NOT IN (%s)', DbTools::prepareListString($exceptTopicInfos));
|
$query .= sprintf(' AND topic_id NOT IN (%s)', DbTools::prepareListString($exceptTopicInfos));
|
||||||
$query .= ' GROUP BY topic_id ORDER BY post_count DESC LIMIT 1';
|
$query .= ' GROUP BY topic_id ORDER BY post_count DESC LIMIT 1';
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
foreach($exceptCategoryInfos as $categoryInfo) {
|
foreach($exceptCategoryInfos as $categoryInfo) {
|
||||||
if($categoryInfo instanceof ForumCategoryInfo)
|
if($categoryInfo instanceof ForumCategoryInfo)
|
||||||
$stmt->addParameter(++$args, $categoryInfo->id);
|
$stmt->nextParameter($categoryInfo->id);
|
||||||
elseif(is_string($categoryInfo) || is_int($categoryInfo))
|
elseif(is_string($categoryInfo) || is_int($categoryInfo))
|
||||||
$stmt->addParameter(++$args, (string)$categoryInfo);
|
$stmt->nextParameter((string)$categoryInfo);
|
||||||
else
|
else
|
||||||
throw new InvalidArgumentException('$exceptCategoryInfos may only contain string ids or instances of ForumCategoryInfo.');
|
throw new InvalidArgumentException('$exceptCategoryInfos may only contain string ids or instances of ForumCategoryInfo.');
|
||||||
}
|
}
|
||||||
foreach($exceptTopicInfos as $topicInfo) {
|
foreach($exceptTopicInfos as $topicInfo) {
|
||||||
if($topicInfo instanceof ForumTopicInfo)
|
if($topicInfo instanceof ForumTopicInfo)
|
||||||
$stmt->addParameter(++$args, $topicInfo->id);
|
$stmt->nextParameter($topicInfo->id);
|
||||||
elseif(is_string($topicInfo) || is_int($topicInfo))
|
elseif(is_string($topicInfo) || is_int($topicInfo))
|
||||||
$stmt->addParameter(++$args, (string)$topicInfo);
|
$stmt->nextParameter((string)$topicInfo);
|
||||||
else
|
else
|
||||||
throw new InvalidArgumentException('$exceptTopicInfos may only contain string ids or instances of ForumTopicInfo.');
|
throw new InvalidArgumentException('$exceptTopicInfos may only contain string ids or instances of ForumTopicInfo.');
|
||||||
}
|
}
|
||||||
|
@ -498,8 +494,8 @@ class ForumTopics {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_forum_topics_track WHERE topic_id = ? AND user_id = ?');
|
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_forum_topics_track WHERE topic_id = ? AND user_id = ?');
|
||||||
$stmt->addParameter(1, $topicInfo instanceof ForumTopicInfo ? $topicInfo->id : $topicInfo);
|
$stmt->nextParameter($topicInfo instanceof ForumTopicInfo ? $topicInfo->id : $topicInfo);
|
||||||
$stmt->addParameter(2, $userInfo instanceof UserInfo ? $userInfo->id : $userInfo);
|
$stmt->nextParameter($userInfo instanceof UserInfo ? $userInfo->id : $userInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
|
||||||
|
@ -528,9 +524,9 @@ class ForumTopics {
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = $this->cache->get('REPLACE INTO msz_forum_topics_track (user_id, topic_id, forum_id, track_last_read) VALUES (?, ?, ?, NOW())');
|
$stmt = $this->cache->get('REPLACE INTO msz_forum_topics_track (user_id, topic_id, forum_id, track_last_read) VALUES (?, ?, ?, NOW())');
|
||||||
$stmt->addParameter(1, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(2, $topicInfo);
|
$stmt->nextParameter($topicInfo);
|
||||||
$stmt->addParameter(3, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,6 @@ class HomeRoutes implements RouteHandler, UrlSource {
|
||||||
* }[]
|
* }[]
|
||||||
*/
|
*/
|
||||||
public function getPopularForumTopics(array $categoryIds): array {
|
public function getPopularForumTopics(array $categoryIds): array {
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->dbConn->prepare(
|
$stmt = $this->dbConn->prepare(
|
||||||
'SELECT t.topic_id, c.forum_id, t.topic_title, c.forum_icon, t.topic_count_views'
|
'SELECT t.topic_id, c.forum_id, t.topic_title, c.forum_icon, t.topic_count_views'
|
||||||
. ', (SELECT COUNT(*) FROM msz_forum_posts AS p WHERE p.topic_id = t.topic_id AND post_deleted IS NULL)'
|
. ', (SELECT COUNT(*) FROM msz_forum_posts AS p WHERE p.topic_id = t.topic_id AND post_deleted IS NULL)'
|
||||||
|
@ -133,7 +132,7 @@ class HomeRoutes implements RouteHandler, UrlSource {
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($categoryIds as $categoryId)
|
foreach($categoryIds as $categoryId)
|
||||||
$stmt->addParameter(++$args, (string)$categoryId);
|
$stmt->nextParameter((string)$categoryId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$topics = [];
|
$topics = [];
|
||||||
|
@ -165,7 +164,6 @@ class HomeRoutes implements RouteHandler, UrlSource {
|
||||||
* }[]
|
* }[]
|
||||||
*/
|
*/
|
||||||
public function getActiveForumTopics(array $categoryIds): array {
|
public function getActiveForumTopics(array $categoryIds): array {
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->dbConn->prepare(
|
$stmt = $this->dbConn->prepare(
|
||||||
'SELECT t.topic_id, c.forum_id, t.topic_title, c.forum_icon, t.topic_count_views'
|
'SELECT t.topic_id, c.forum_id, t.topic_title, c.forum_icon, t.topic_count_views'
|
||||||
. ', (SELECT COUNT(*) FROM msz_forum_posts AS p WHERE p.topic_id = t.topic_id AND post_deleted IS NULL)'
|
. ', (SELECT COUNT(*) FROM msz_forum_posts AS p WHERE p.topic_id = t.topic_id AND post_deleted IS NULL)'
|
||||||
|
@ -178,7 +176,7 @@ class HomeRoutes implements RouteHandler, UrlSource {
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($categoryIds as $categoryId)
|
foreach($categoryIds as $categoryId)
|
||||||
$stmt->addParameter(++$args, (string)$categoryId);
|
$stmt->nextParameter((string)$categoryId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$topics = [];
|
$topics = [];
|
||||||
|
|
|
@ -62,19 +62,18 @@ class MessagesDatabase {
|
||||||
$query .= sprintf(' %s msg_deleted %s NULL', ++$args > 1 ? 'AND' : 'WHERE', $deleted ? 'IS NOT' : 'IS');
|
$query .= sprintf(' %s msg_deleted %s NULL', ++$args > 1 ? 'AND' : 'WHERE', $deleted ? 'IS NOT' : 'IS');
|
||||||
$query .= ' ORDER BY msg_created DESC';
|
$query .= ' ORDER BY msg_created DESC';
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
|
|
||||||
if($hasOwnerInfo)
|
if($hasOwnerInfo)
|
||||||
$stmt->addParameter(++$args, $ownerInfo instanceof UserInfo ? $ownerInfo->id : $ownerInfo);
|
$stmt->nextParameter($ownerInfo instanceof UserInfo ? $ownerInfo->id : $ownerInfo);
|
||||||
if($hasAuthorInfo)
|
if($hasAuthorInfo)
|
||||||
$stmt->addParameter(++$args, $authorInfo instanceof UserInfo ? $authorInfo->id : $authorInfo);
|
$stmt->nextParameter($authorInfo instanceof UserInfo ? $authorInfo->id : $authorInfo);
|
||||||
if($hasRecipientInfo)
|
if($hasRecipientInfo)
|
||||||
$stmt->addParameter(++$args, $recipientInfo instanceof UserInfo ? $recipientInfo->id : $recipientInfo);
|
$stmt->nextParameter($recipientInfo instanceof UserInfo ? $recipientInfo->id : $recipientInfo);
|
||||||
if($hasRepliesFor)
|
if($hasRepliesFor)
|
||||||
$stmt->addParameter(++$args, $repliesFor instanceof MessageInfo ? $repliesFor->id : $repliesFor);
|
$stmt->nextParameter($repliesFor instanceof MessageInfo ? $repliesFor->id : $repliesFor);
|
||||||
if($hasReplyTo)
|
if($hasReplyTo)
|
||||||
$stmt->addParameter(++$args, $replyTo instanceof MessageInfo ? $replyTo->replyToId : $replyTo);
|
$stmt->nextParameter($replyTo instanceof MessageInfo ? $replyTo->replyToId : $replyTo);
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -138,18 +137,18 @@ class MessagesDatabase {
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
|
|
||||||
if($hasOwnerInfo)
|
if($hasOwnerInfo)
|
||||||
$stmt->addParameter(++$args, $ownerInfo instanceof UserInfo ? $ownerInfo->id : $ownerInfo);
|
$stmt->nextParameter($ownerInfo instanceof UserInfo ? $ownerInfo->id : $ownerInfo);
|
||||||
if($hasAuthorInfo)
|
if($hasAuthorInfo)
|
||||||
$stmt->addParameter(++$args, $authorInfo instanceof UserInfo ? $authorInfo->id : $authorInfo);
|
$stmt->nextParameter($authorInfo instanceof UserInfo ? $authorInfo->id : $authorInfo);
|
||||||
if($hasRecipientInfo)
|
if($hasRecipientInfo)
|
||||||
$stmt->addParameter(++$args, $recipientInfo instanceof UserInfo ? $recipientInfo->id : $recipientInfo);
|
$stmt->nextParameter($recipientInfo instanceof UserInfo ? $recipientInfo->id : $recipientInfo);
|
||||||
if($hasRepliesFor)
|
if($hasRepliesFor)
|
||||||
$stmt->addParameter(++$args, $repliesFor instanceof MessageInfo ? $repliesFor->id : $repliesFor);
|
$stmt->nextParameter($repliesFor instanceof MessageInfo ? $repliesFor->id : $repliesFor);
|
||||||
if($hasReplyTo)
|
if($hasReplyTo)
|
||||||
$stmt->addParameter(++$args, $replyTo instanceof MessageInfo ? $replyTo->replyToId : $replyTo);
|
$stmt->nextParameter($replyTo instanceof MessageInfo ? $replyTo->replyToId : $replyTo);
|
||||||
if($hasPagination) {
|
if($hasPagination) {
|
||||||
$stmt->addParameter(++$args, $pagination->range);
|
$stmt->nextParameter($pagination->range);
|
||||||
$stmt->addParameter(++$args, $pagination->offset);
|
$stmt->nextParameter($pagination->offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@ -168,10 +167,10 @@ class MessagesDatabase {
|
||||||
));
|
));
|
||||||
|
|
||||||
if($messageInfoOrId instanceof MessageInfo)
|
if($messageInfoOrId instanceof MessageInfo)
|
||||||
$stmt->addParameter(1, $useReplyTo ? $messageInfoOrId->replyToId : $messageInfoOrId->id);
|
$stmt->nextParameter($useReplyTo ? $messageInfoOrId->replyToId : $messageInfoOrId->id);
|
||||||
else
|
else
|
||||||
$stmt->addParameter(1, $messageInfoOrId);
|
$stmt->nextParameter($messageInfoOrId);
|
||||||
$stmt->addParameter(2, $ownerInfo instanceof UserInfo ? $ownerInfo->id : $ownerInfo);
|
$stmt->nextParameter($ownerInfo instanceof UserInfo ? $ownerInfo->id : $ownerInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -194,16 +193,16 @@ class MessagesDatabase {
|
||||||
DateTimeInterface|int|null $readAt = null
|
DateTimeInterface|int|null $readAt = null
|
||||||
): MessageInfo {
|
): MessageInfo {
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_messages (msg_id, msg_owner_id, msg_author_id, msg_recipient_id, msg_reply_to, msg_title, msg_body, msg_parser, msg_sent, msg_read) VALUES (?, ?, ?, ?, ?, TO_BASE64(?), TO_BASE64(?), ?, FROM_UNIXTIME(?), FROM_UNIXTIME(?))');
|
$stmt = $this->cache->get('INSERT INTO msz_messages (msg_id, msg_owner_id, msg_author_id, msg_recipient_id, msg_reply_to, msg_title, msg_body, msg_parser, msg_sent, msg_read) VALUES (?, ?, ?, ?, ?, TO_BASE64(?), TO_BASE64(?), ?, FROM_UNIXTIME(?), FROM_UNIXTIME(?))');
|
||||||
$stmt->addParameter(1, $messageId);
|
$stmt->nextParameter($messageId);
|
||||||
$stmt->addParameter(2, $ownerInfo instanceof UserInfo ? $ownerInfo->id : $ownerInfo);
|
$stmt->nextParameter($ownerInfo instanceof UserInfo ? $ownerInfo->id : $ownerInfo);
|
||||||
$stmt->addParameter(3, $authorInfo instanceof UserInfo ? $authorInfo->id : $authorInfo);
|
$stmt->nextParameter($authorInfo instanceof UserInfo ? $authorInfo->id : $authorInfo);
|
||||||
$stmt->addParameter(4, $recipientInfo instanceof UserInfo ? $recipientInfo->id : $recipientInfo);
|
$stmt->nextParameter($recipientInfo instanceof UserInfo ? $recipientInfo->id : $recipientInfo);
|
||||||
$stmt->addParameter(5, $replyTo instanceof MessageInfo ? $replyTo->id : $replyTo);
|
$stmt->nextParameter($replyTo instanceof MessageInfo ? $replyTo->id : $replyTo);
|
||||||
$stmt->addParameter(6, $title);
|
$stmt->nextParameter($title);
|
||||||
$stmt->addParameter(7, $body);
|
$stmt->nextParameter($body);
|
||||||
$stmt->addParameter(8, $parser);
|
$stmt->nextParameter($parser);
|
||||||
$stmt->addParameter(9, $sentAt instanceof DateTimeInterface ? (int)$sentAt->format('U') : $sentAt);
|
$stmt->nextParameter($sentAt instanceof DateTimeInterface ? (int)$sentAt->format('U') : $sentAt);
|
||||||
$stmt->addParameter(10, $readAt instanceof DateTimeInterface ? (int)$readAt->format('U') : $readAt);
|
$stmt->nextParameter($readAt instanceof DateTimeInterface ? (int)$readAt->format('U') : $readAt);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $this->getMessageInfo($ownerInfo, $messageId);
|
return $this->getMessageInfo($ownerInfo, $messageId);
|
||||||
|
@ -263,7 +262,6 @@ class MessagesDatabase {
|
||||||
if(empty($setQuery))
|
if(empty($setQuery))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get(sprintf(
|
$stmt = $this->cache->get(sprintf(
|
||||||
'UPDATE msz_messages SET %s WHERE %s',
|
'UPDATE msz_messages SET %s WHERE %s',
|
||||||
implode(', ', $setQuery),
|
implode(', ', $setQuery),
|
||||||
|
@ -271,9 +269,9 @@ class MessagesDatabase {
|
||||||
));
|
));
|
||||||
|
|
||||||
foreach($setValues as $value)
|
foreach($setValues as $value)
|
||||||
$stmt->addParameter(++$args, $value);
|
$stmt->nextParameter($value);
|
||||||
foreach($whereValues as $value)
|
foreach($whereValues as $value)
|
||||||
$stmt->addParameter(++$args, $value);
|
$stmt->nextParameter($value);
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
@ -299,17 +297,16 @@ class MessagesDatabase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
|
|
||||||
if($hasOwnerInfo)
|
if($hasOwnerInfo)
|
||||||
$stmt->addParameter(++$args, $ownerInfo instanceof UserInfo ? $ownerInfo->id : $ownerInfo);
|
$stmt->nextParameter($ownerInfo instanceof UserInfo ? $ownerInfo->id : $ownerInfo);
|
||||||
if($hasMessageInfos)
|
if($hasMessageInfos)
|
||||||
foreach($messageInfos as $messageInfo) {
|
foreach($messageInfos as $messageInfo) {
|
||||||
if(is_string($messageInfo))
|
if(is_string($messageInfo))
|
||||||
$stmt->addParameter(++$args, $messageInfo);
|
$stmt->nextParameter($messageInfo);
|
||||||
elseif($messageInfo instanceof MessageInfo)
|
elseif($messageInfo instanceof MessageInfo)
|
||||||
$stmt->addParameter(++$args, $messageInfo->id);
|
$stmt->nextParameter($messageInfo->id);
|
||||||
else
|
else
|
||||||
throw new InvalidArgumentException('$messageInfos must be an array of strings or MessageInfo instances.');
|
throw new InvalidArgumentException('$messageInfos must be an array of strings or MessageInfo instances.');
|
||||||
}
|
}
|
||||||
|
@ -338,17 +335,16 @@ class MessagesDatabase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
|
|
||||||
if($hasOwnerInfo)
|
if($hasOwnerInfo)
|
||||||
$stmt->addParameter(++$args, $ownerInfo instanceof UserInfo ? $ownerInfo->id : $ownerInfo);
|
$stmt->nextParameter($ownerInfo instanceof UserInfo ? $ownerInfo->id : $ownerInfo);
|
||||||
if($hasMessageInfos)
|
if($hasMessageInfos)
|
||||||
foreach($messageInfos as $messageInfo) {
|
foreach($messageInfos as $messageInfo) {
|
||||||
if(is_string($messageInfo))
|
if(is_string($messageInfo))
|
||||||
$stmt->addParameter(++$args, $messageInfo);
|
$stmt->nextParameter($messageInfo);
|
||||||
elseif($messageInfo instanceof MessageInfo)
|
elseif($messageInfo instanceof MessageInfo)
|
||||||
$stmt->addParameter(++$args, $messageInfo->id);
|
$stmt->nextParameter($messageInfo->id);
|
||||||
else
|
else
|
||||||
throw new InvalidArgumentException('$messageInfos must be an array of strings or MessageInfo instances.');
|
throw new InvalidArgumentException('$messageInfos must be an array of strings or MessageInfo instances.');
|
||||||
}
|
}
|
||||||
|
@ -377,17 +373,16 @@ class MessagesDatabase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
|
|
||||||
if($hasOwnerInfo)
|
if($hasOwnerInfo)
|
||||||
$stmt->addParameter(++$args, $ownerInfo instanceof UserInfo ? $ownerInfo->id : $ownerInfo);
|
$stmt->nextParameter($ownerInfo instanceof UserInfo ? $ownerInfo->id : $ownerInfo);
|
||||||
if($hasMessageInfos)
|
if($hasMessageInfos)
|
||||||
foreach($messageInfos as $messageInfo) {
|
foreach($messageInfos as $messageInfo) {
|
||||||
if(is_string($messageInfo))
|
if(is_string($messageInfo))
|
||||||
$stmt->addParameter(++$args, $messageInfo);
|
$stmt->nextParameter($messageInfo);
|
||||||
elseif($messageInfo instanceof MessageInfo)
|
elseif($messageInfo instanceof MessageInfo)
|
||||||
$stmt->addParameter(++$args, $messageInfo->id);
|
$stmt->nextParameter($messageInfo->id);
|
||||||
else
|
else
|
||||||
throw new InvalidArgumentException('$messageInfos must be an array of strings or MessageInfo instances.');
|
throw new InvalidArgumentException('$messageInfos must be an array of strings or MessageInfo instances.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,10 +52,9 @@ class News {
|
||||||
$query .= ' LIMIT ? OFFSET ?';
|
$query .= ' LIMIT ? OFFSET ?';
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
if($hasPagination) {
|
if($hasPagination) {
|
||||||
$stmt->addParameter(++$args, $pagination->range);
|
$stmt->nextParameter($pagination->range);
|
||||||
$stmt->addParameter(++$args, $pagination->offset);
|
$stmt->nextParameter($pagination->offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@ -93,7 +92,7 @@ class News {
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
$stmt->addParameter(1, $value);
|
$stmt->nextParameter($value);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -117,9 +116,9 @@ class News {
|
||||||
throw new InvalidArgumentException('$description may not be empty');
|
throw new InvalidArgumentException('$description may not be empty');
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_news_categories (category_name, category_description, category_is_hidden) VALUES (?, ?, ?)');
|
$stmt = $this->cache->get('INSERT INTO msz_news_categories (category_name, category_description, category_is_hidden) VALUES (?, ?, ?)');
|
||||||
$stmt->addParameter(1, $name);
|
$stmt->nextParameter($name);
|
||||||
$stmt->addParameter(2, $description);
|
$stmt->nextParameter($description);
|
||||||
$stmt->addParameter(3, $hidden ? 1 : 0);
|
$stmt->nextParameter($hidden ? 1 : 0);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $this->getCategory(categoryId: (string)$this->dbConn->getLastInsertId());
|
return $this->getCategory(categoryId: (string)$this->dbConn->getLastInsertId());
|
||||||
|
@ -130,7 +129,7 @@ class News {
|
||||||
$infoOrId = $infoOrId->id;
|
$infoOrId = $infoOrId->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('DELETE FROM msz_news_categories WHERE category_id = ?');
|
$stmt = $this->cache->get('DELETE FROM msz_news_categories WHERE category_id = ?');
|
||||||
$stmt->addParameter(1, $infoOrId);
|
$stmt->nextParameter($infoOrId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,11 +157,11 @@ class News {
|
||||||
$hasHidden = $hidden !== null;
|
$hasHidden = $hidden !== null;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_news_categories SET category_name = COALESCE(?, category_name), category_description = COALESCE(?, category_description), category_is_hidden = IF(?, ?, category_is_hidden) WHERE category_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_news_categories SET category_name = COALESCE(?, category_name), category_description = COALESCE(?, category_description), category_is_hidden = IF(?, ?, category_is_hidden) WHERE category_id = ?');
|
||||||
$stmt->addParameter(1, $name);
|
$stmt->nextParameter($name);
|
||||||
$stmt->addParameter(2, $description);
|
$stmt->nextParameter($description);
|
||||||
$stmt->addParameter(3, $hasHidden ? 1 : 0);
|
$stmt->nextParameter($hasHidden ? 1 : 0);
|
||||||
$stmt->addParameter(4, $hidden ? 1 : 0);
|
$stmt->nextParameter($hidden ? 1 : 0);
|
||||||
$stmt->addParameter(5, $infoOrId);
|
$stmt->nextParameter($infoOrId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +197,7 @@ class News {
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasCategoryInfo)
|
if($hasCategoryInfo)
|
||||||
$stmt->addParameter(1, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -253,14 +252,13 @@ class News {
|
||||||
$query .= ' LIMIT ? OFFSET ?';
|
$query .= ' LIMIT ? OFFSET ?';
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
if($hasCategoryInfo)
|
if($hasCategoryInfo)
|
||||||
$stmt->addParameter(++$args, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
if($hasSearchQuery)
|
if($hasSearchQuery)
|
||||||
$stmt->addParameter(++$args, $searchQuery);
|
$stmt->nextParameter($searchQuery);
|
||||||
if($hasPagination) {
|
if($hasPagination) {
|
||||||
$stmt->addParameter(++$args, $pagination->range);
|
$stmt->nextParameter($pagination->range);
|
||||||
$stmt->addParameter(++$args, $pagination->offset);
|
$stmt->nextParameter($pagination->offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@ -270,7 +268,7 @@ class News {
|
||||||
|
|
||||||
public function getPost(string $postId): NewsPostInfo {
|
public function getPost(string $postId): NewsPostInfo {
|
||||||
$stmt = $this->cache->get('SELECT post_id, category_id, user_id, comment_section_id, post_is_featured, post_title, post_text, UNIX_TIMESTAMP(post_scheduled), UNIX_TIMESTAMP(post_created), UNIX_TIMESTAMP(post_updated), UNIX_TIMESTAMP(post_deleted) FROM msz_news_posts WHERE post_id = ?');
|
$stmt = $this->cache->get('SELECT post_id, category_id, user_id, comment_section_id, post_is_featured, post_title, post_text, UNIX_TIMESTAMP(post_scheduled), UNIX_TIMESTAMP(post_created), UNIX_TIMESTAMP(post_updated), UNIX_TIMESTAMP(post_deleted) FROM msz_news_posts WHERE post_id = ?');
|
||||||
$stmt->addParameter(1, $postId);
|
$stmt->nextParameter($postId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -304,12 +302,12 @@ class News {
|
||||||
throw new InvalidArgumentException('$body may not be empty');
|
throw new InvalidArgumentException('$body may not be empty');
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_news_posts (category_id, user_id, post_is_featured, post_title, post_text, post_scheduled) VALUES (?, ?, ?, ?, ?, ?)');
|
$stmt = $this->cache->get('INSERT INTO msz_news_posts (category_id, user_id, post_is_featured, post_title, post_text, post_scheduled) VALUES (?, ?, ?, ?, ?, ?)');
|
||||||
$stmt->addParameter(1, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
$stmt->addParameter(2, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(3, $featured ? 1 : 0);
|
$stmt->nextParameter($featured ? 1 : 0);
|
||||||
$stmt->addParameter(4, $title);
|
$stmt->nextParameter($title);
|
||||||
$stmt->addParameter(5, $body);
|
$stmt->nextParameter($body);
|
||||||
$stmt->addParameter(6, $schedule);
|
$stmt->nextParameter($schedule);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $this->getPost((string)$this->dbConn->getLastInsertId());
|
return $this->getPost((string)$this->dbConn->getLastInsertId());
|
||||||
|
@ -320,7 +318,7 @@ class News {
|
||||||
$postInfo = $postInfo->id;
|
$postInfo = $postInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_news_posts SET post_deleted = COALESCE(post_deleted, NOW()) WHERE post_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_news_posts SET post_deleted = COALESCE(post_deleted, NOW()) WHERE post_id = ?');
|
||||||
$stmt->addParameter(1, $postInfo);
|
$stmt->nextParameter($postInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +327,7 @@ class News {
|
||||||
$postInfo = $postInfo->id;
|
$postInfo = $postInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_news_posts SET post_deleted = NULL WHERE post_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_news_posts SET post_deleted = NULL WHERE post_id = ?');
|
||||||
$stmt->addParameter(1, $postInfo);
|
$stmt->nextParameter($postInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +337,7 @@ class News {
|
||||||
|
|
||||||
// should this enforce a soft delete first? (AND post_deleted IS NOT NULL)
|
// should this enforce a soft delete first? (AND post_deleted IS NOT NULL)
|
||||||
$stmt = $this->cache->get('DELETE FROM msz_news_posts WHERE post_id = ?');
|
$stmt = $this->cache->get('DELETE FROM msz_news_posts WHERE post_id = ?');
|
||||||
$stmt->addParameter(1, $postInfo);
|
$stmt->nextParameter($postInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,15 +375,15 @@ class News {
|
||||||
$hasFeatured = $featured !== null;
|
$hasFeatured = $featured !== null;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_news_posts SET category_id = COALESCE(?, category_id), user_id = IF(?, ?, user_id), post_is_featured = IF(?, ?, post_is_featured), post_title = COALESCE(?, post_title), post_text = COALESCE(?, post_text), post_scheduled = COALESCE(?, post_scheduled) WHERE post_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_news_posts SET category_id = COALESCE(?, category_id), user_id = IF(?, ?, user_id), post_is_featured = IF(?, ?, post_is_featured), post_title = COALESCE(?, post_title), post_text = COALESCE(?, post_text), post_scheduled = COALESCE(?, post_scheduled) WHERE post_id = ?');
|
||||||
$stmt->addParameter(1, $categoryInfo);
|
$stmt->nextParameter($categoryInfo);
|
||||||
$stmt->addParameter(2, $updateUserInfo ? 1 : 0);
|
$stmt->nextParameter($updateUserInfo ? 1 : 0);
|
||||||
$stmt->addParameter(3, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(4, $hasFeatured ? 1 : 0);
|
$stmt->nextParameter($hasFeatured ? 1 : 0);
|
||||||
$stmt->addParameter(5, $featured ? 1 : 0);
|
$stmt->nextParameter($featured ? 1 : 0);
|
||||||
$stmt->addParameter(6, $title);
|
$stmt->nextParameter($title);
|
||||||
$stmt->addParameter(7, $body);
|
$stmt->nextParameter($body);
|
||||||
$stmt->addParameter(8, $schedule);
|
$stmt->nextParameter($schedule);
|
||||||
$stmt->addParameter(9, $postInfo);
|
$stmt->nextParameter($postInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,8 +397,8 @@ class News {
|
||||||
$commentsCategory = $commentsCategory->id;
|
$commentsCategory = $commentsCategory->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_news_posts SET comment_section_id = ? WHERE post_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_news_posts SET comment_section_id = ? WHERE post_id = ?');
|
||||||
$stmt->addParameter(1, $commentsCategory);
|
$stmt->nextParameter($commentsCategory);
|
||||||
$stmt->addParameter(2, $postInfo);
|
$stmt->nextParameter($postInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,20 +55,19 @@ class Permissions {
|
||||||
if($hasCategoryName)
|
if($hasCategoryName)
|
||||||
$query .= ' AND perms_category ' . ($categoryNamesIsArray ? sprintf('IN (%s)', DbTools::prepareListString($categoryNames)) : '= ?');
|
$query .= ' AND perms_category ' . ($categoryNamesIsArray ? sprintf('IN (%s)', DbTools::prepareListString($categoryNames)) : '= ?');
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo instanceof UserInfo ? $userInfo->id : $userInfo);
|
$stmt->nextParameter($userInfo instanceof UserInfo ? $userInfo->id : $userInfo);
|
||||||
if($hasRoleInfo)
|
if($hasRoleInfo)
|
||||||
$stmt->addParameter(++$args, $roleInfo instanceof RoleInfo ? $roleInfo->id : $roleInfo);
|
$stmt->nextParameter($roleInfo instanceof RoleInfo ? $roleInfo->id : $roleInfo);
|
||||||
if($hasForumCategoryInfo)
|
if($hasForumCategoryInfo)
|
||||||
$stmt->addParameter(++$args, $forumCategoryInfo instanceof ForumCategoryInfo ? $forumCategoryInfo->id : $forumCategoryInfo);
|
$stmt->nextParameter($forumCategoryInfo instanceof ForumCategoryInfo ? $forumCategoryInfo->id : $forumCategoryInfo);
|
||||||
if($hasCategoryName) {
|
if($hasCategoryName) {
|
||||||
if($categoryNamesIsArray) {
|
if($categoryNamesIsArray) {
|
||||||
foreach($categoryNames as $name)
|
foreach($categoryNames as $name)
|
||||||
$stmt->addParameter(++$args, $name);
|
$stmt->nextParameter($name);
|
||||||
} else
|
} else
|
||||||
$stmt->addParameter(++$args, $categoryNames);
|
$stmt->nextParameter($categoryNames);
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
|
@ -107,12 +106,12 @@ class Permissions {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_perms (user_id, role_id, forum_id, perms_category, perms_allow, perms_deny) VALUES (?, ?, ?, ?, ?, ?)');
|
$stmt = $this->cache->get('INSERT INTO msz_perms (user_id, role_id, forum_id, perms_category, perms_allow, perms_deny) VALUES (?, ?, ?, ?, ?, ?)');
|
||||||
$stmt->addParameter(1, $userInfo instanceof UserInfo ? $userInfo->id : $userInfo);
|
$stmt->nextParameter($userInfo instanceof UserInfo ? $userInfo->id : $userInfo);
|
||||||
$stmt->addParameter(2, $roleInfo instanceof RoleInfo ? $roleInfo->id : $roleInfo);
|
$stmt->nextParameter($roleInfo instanceof RoleInfo ? $roleInfo->id : $roleInfo);
|
||||||
$stmt->addParameter(3, $forumCategoryInfo instanceof ForumCategoryInfo ? $forumCategoryInfo->id : $forumCategoryInfo);
|
$stmt->nextParameter($forumCategoryInfo instanceof ForumCategoryInfo ? $forumCategoryInfo->id : $forumCategoryInfo);
|
||||||
$stmt->addParameter(4, $categoryName);
|
$stmt->nextParameter($categoryName);
|
||||||
$stmt->addParameter(5, $allow);
|
$stmt->nextParameter($allow);
|
||||||
$stmt->addParameter(6, $deny);
|
$stmt->nextParameter($deny);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,19 +135,18 @@ class Permissions {
|
||||||
if($hasCategoryNames)
|
if($hasCategoryNames)
|
||||||
$query .= ' AND perms_category ' . ($categoryNamesIsArray ? sprintf('IN (%s)', DbTools::prepareListString($categoryNames)) : '= ?');
|
$query .= ' AND perms_category ' . ($categoryNamesIsArray ? sprintf('IN (%s)', DbTools::prepareListString($categoryNames)) : '= ?');
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo instanceof UserInfo ? $userInfo->id : $userInfo);
|
$stmt->nextParameter($userInfo instanceof UserInfo ? $userInfo->id : $userInfo);
|
||||||
if($hasRoleInfo)
|
if($hasRoleInfo)
|
||||||
$stmt->addParameter(++$args, $roleInfo instanceof RoleInfo ? $roleInfo->id : $roleInfo);
|
$stmt->nextParameter($roleInfo instanceof RoleInfo ? $roleInfo->id : $roleInfo);
|
||||||
if($hasForumCategoryInfo)
|
if($hasForumCategoryInfo)
|
||||||
$stmt->addParameter(++$args, $forumCategoryInfo instanceof ForumCategoryInfo ? $forumCategoryInfo->id : $forumCategoryInfo);
|
$stmt->nextParameter($forumCategoryInfo instanceof ForumCategoryInfo ? $forumCategoryInfo->id : $forumCategoryInfo);
|
||||||
if($categoryNamesIsArray) {
|
if($categoryNamesIsArray) {
|
||||||
foreach($categoryNames as $name)
|
foreach($categoryNames as $name)
|
||||||
$stmt->addParameter(++$args, $name);
|
$stmt->nextParameter($name);
|
||||||
} else
|
} else
|
||||||
$stmt->addParameter(++$args, $categoryNames);
|
$stmt->nextParameter($categoryNames);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,14 +163,13 @@ class Permissions {
|
||||||
$query .= sprintf(' AND forum_id %s', $hasForumCategoryInfo ? '= ?' : 'IS NULL');
|
$query .= sprintf(' AND forum_id %s', $hasForumCategoryInfo ? '= ?' : 'IS NULL');
|
||||||
$query .= sprintf(' AND user_id %s', $hasUserInfo ? '= ?' : 'IS NULL');
|
$query .= sprintf(' AND user_id %s', $hasUserInfo ? '= ?' : 'IS NULL');
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
$stmt->addParameter(++$args, $perms);
|
$stmt->nextParameter($perms);
|
||||||
$stmt->addParameter(++$args, $categoryName);
|
$stmt->nextParameter($categoryName);
|
||||||
if($hasForumCategoryInfo)
|
if($hasForumCategoryInfo)
|
||||||
$stmt->addParameter(++$args, $forumCategoryInfo instanceof ForumCategoryInfo ? $forumCategoryInfo->id : $forumCategoryInfo);
|
$stmt->nextParameter($forumCategoryInfo instanceof ForumCategoryInfo ? $forumCategoryInfo->id : $forumCategoryInfo);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo instanceof UserInfo ? $userInfo->id : $userInfo);
|
$stmt->nextParameter($userInfo instanceof UserInfo ? $userInfo->id : $userInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -198,18 +195,17 @@ class Permissions {
|
||||||
$query .= sprintf(' AND user_id %s', $hasUserInfo ? '= ?' : 'IS NULL');
|
$query .= sprintf(' AND user_id %s', $hasUserInfo ? '= ?' : 'IS NULL');
|
||||||
$query .= ' GROUP BY perms_category';
|
$query .= ' GROUP BY perms_category';
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
|
|
||||||
if($categoryNamesIsArray) {
|
if($categoryNamesIsArray) {
|
||||||
foreach($categoryNames as $name)
|
foreach($categoryNames as $name)
|
||||||
$stmt->addParameter(++$args, $name);
|
$stmt->nextParameter($name);
|
||||||
} else
|
} else
|
||||||
$stmt->addParameter(++$args, $categoryNames);
|
$stmt->nextParameter($categoryNames);
|
||||||
if($hasForumCategoryInfo)
|
if($hasForumCategoryInfo)
|
||||||
$stmt->addParameter(++$args, $forumCategoryInfo instanceof ForumCategoryInfo ? $forumCategoryInfo->id : $forumCategoryInfo);
|
$stmt->nextParameter($forumCategoryInfo instanceof ForumCategoryInfo ? $forumCategoryInfo->id : $forumCategoryInfo);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo instanceof UserInfo ? $userInfo->id : $userInfo);
|
$stmt->nextParameter($userInfo instanceof UserInfo ? $userInfo->id : $userInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -321,13 +317,12 @@ class Permissions {
|
||||||
|
|
||||||
if($doGuest) {
|
if($doGuest) {
|
||||||
self::precalculatePermissionsLog('Calculating guest permission for forum category #%s...', $currentCatId);
|
self::precalculatePermissionsLog('Calculating guest permission for forum category #%s...', $currentCatId);
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get(sprintf(
|
$stmt = $this->cache->get(sprintf(
|
||||||
'SELECT perms_category, BIT_OR(perms_allow) & ~BIT_OR(perms_deny) FROM msz_perms WHERE forum_id IN (%s) AND user_id IS NULL AND role_id IS NULL GROUP BY perms_category',
|
'SELECT perms_category, BIT_OR(perms_allow) & ~BIT_OR(perms_deny) FROM msz_perms WHERE forum_id IN (%s) AND user_id IS NULL AND role_id IS NULL GROUP BY perms_category',
|
||||||
DbTools::prepareListString($catIds)
|
DbTools::prepareListString($catIds)
|
||||||
));
|
));
|
||||||
foreach($catIds as $catId)
|
foreach($catIds as $catId)
|
||||||
$stmt->addParameter(++$args, $catId);
|
$stmt->nextParameter($catId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$insert->reset();
|
$insert->reset();
|
||||||
|
|
|
@ -33,13 +33,12 @@ class ProfileFields {
|
||||||
$query .= ' ORDER BY field_order ASC';
|
$query .= ' ORDER BY field_order ASC';
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
$args = 0;
|
|
||||||
|
|
||||||
if($hasFieldValueInfos)
|
if($hasFieldValueInfos)
|
||||||
foreach($fieldValueInfos as $fieldValueInfo) {
|
foreach($fieldValueInfos as $fieldValueInfo) {
|
||||||
if(!($fieldValueInfo instanceof ProfileFieldValueInfo))
|
if(!($fieldValueInfo instanceof ProfileFieldValueInfo))
|
||||||
throw new InvalidArgumentException('All values in $fieldValueInfos must be of ProfileFieldValueInfo type.');
|
throw new InvalidArgumentException('All values in $fieldValueInfos must be of ProfileFieldValueInfo type.');
|
||||||
$stmt->addParameter(++$args, $fieldValueInfo->fieldId);
|
$stmt->nextParameter($fieldValueInfo->fieldId);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@ -49,7 +48,7 @@ class ProfileFields {
|
||||||
|
|
||||||
public function getField(string $fieldId): ProfileFieldInfo {
|
public function getField(string $fieldId): ProfileFieldInfo {
|
||||||
$stmt = $this->cache->get('SELECT field_id, field_order, field_key, field_title, field_regex FROM msz_profile_fields WHERE field_id = ?');
|
$stmt = $this->cache->get('SELECT field_id, field_order, field_key, field_title, field_regex FROM msz_profile_fields WHERE field_id = ?');
|
||||||
$stmt->addParameter(1, $fieldId);
|
$stmt->nextParameter($fieldId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -100,20 +99,19 @@ class ProfileFields {
|
||||||
);
|
);
|
||||||
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
$args = 0;
|
|
||||||
|
|
||||||
if($hasFieldInfos)
|
if($hasFieldInfos)
|
||||||
foreach($fieldInfos as $fieldInfo) {
|
foreach($fieldInfos as $fieldInfo) {
|
||||||
if(!($fieldInfo instanceof ProfileFieldInfo))
|
if(!($fieldInfo instanceof ProfileFieldInfo))
|
||||||
throw new InvalidArgumentException('All values in $fieldInfos must be of ProfileFieldInfo type.');
|
throw new InvalidArgumentException('All values in $fieldInfos must be of ProfileFieldInfo type.');
|
||||||
$stmt->addParameter(++$args, $fieldInfo->id);
|
$stmt->nextParameter($fieldInfo->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($hasFieldValueInfos)
|
if($hasFieldValueInfos)
|
||||||
foreach($fieldValueInfos as $fieldValueInfo) {
|
foreach($fieldValueInfos as $fieldValueInfo) {
|
||||||
if(!($fieldValueInfo instanceof ProfileFieldValueInfo))
|
if(!($fieldValueInfo instanceof ProfileFieldValueInfo))
|
||||||
throw new InvalidArgumentException('All values in $fieldValueInfos must be of ProfileFieldValueInfo type.');
|
throw new InvalidArgumentException('All values in $fieldValueInfos must be of ProfileFieldValueInfo type.');
|
||||||
$stmt->addParameter(++$args, $fieldValueInfo->formatId);
|
$stmt->nextParameter($fieldValueInfo->formatId);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@ -123,7 +121,7 @@ class ProfileFields {
|
||||||
|
|
||||||
public function getFieldFormat(string $formatId): ProfileFieldFormatInfo {
|
public function getFieldFormat(string $formatId): ProfileFieldFormatInfo {
|
||||||
$stmt = $this->cache->get('SELECT format_id, field_id, format_regex, format_link, format_display FROM msz_profile_fields_formats WHERE format_id = ?');
|
$stmt = $this->cache->get('SELECT format_id, field_id, format_regex, format_link, format_display FROM msz_profile_fields_formats WHERE format_id = ?');
|
||||||
$stmt->addParameter(1, $formatId);
|
$stmt->nextParameter($formatId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -141,8 +139,8 @@ class ProfileFields {
|
||||||
$fieldInfo = $fieldInfo->id;
|
$fieldInfo = $fieldInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('SELECT format_id, field_id, format_regex, format_link, format_display FROM msz_profile_fields_formats WHERE field_id = ? AND (format_regex IS NULL OR ? REGEXP format_regex) ORDER BY format_regex IS NULL ASC');
|
$stmt = $this->cache->get('SELECT format_id, field_id, format_regex, format_link, format_display FROM msz_profile_fields_formats WHERE field_id = ? AND (format_regex IS NULL OR ? REGEXP format_regex) ORDER BY format_regex IS NULL ASC');
|
||||||
$stmt->addParameter(1, $fieldInfo);
|
$stmt->nextParameter($fieldInfo);
|
||||||
$stmt->addParameter(2, $value);
|
$stmt->nextParameter($value);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -160,7 +158,7 @@ class ProfileFields {
|
||||||
// i don't really want to bother with the join for the ordering so i'll just do that somewhere in PHP for now
|
// i don't really want to bother with the join for the ordering so i'll just do that somewhere in PHP for now
|
||||||
// will probably add the ability for people to order them in whatever way they want, as well as visibility controls
|
// will probably add the ability for people to order them in whatever way they want, as well as visibility controls
|
||||||
$stmt = $this->cache->get('SELECT field_id, user_id, format_id, field_value FROM msz_profile_fields_values WHERE user_id = ?');
|
$stmt = $this->cache->get('SELECT field_id, user_id, format_id, field_value FROM msz_profile_fields_values WHERE user_id = ?');
|
||||||
$stmt->addParameter(1, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $stmt->getResult()->getIterator(ProfileFieldValueInfo::fromResult(...));
|
return $stmt->getResult()->getIterator(ProfileFieldValueInfo::fromResult(...));
|
||||||
|
@ -176,8 +174,8 @@ class ProfileFields {
|
||||||
$userInfo = $userInfo->id;
|
$userInfo = $userInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('SELECT field_id, user_id, format_id, field_value FROM msz_profile_fields_values WHERE field_id = ? AND user_id = ?');
|
$stmt = $this->cache->get('SELECT field_id, user_id, format_id, field_value FROM msz_profile_fields_values WHERE field_id = ? AND user_id = ?');
|
||||||
$stmt->addParameter(1, $fieldInfo);
|
$stmt->nextParameter($fieldInfo);
|
||||||
$stmt->addParameter(2, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -234,17 +232,16 @@ class ProfileFields {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get(
|
$stmt = $this->cache->get(
|
||||||
'REPLACE INTO msz_profile_fields_values (field_id, user_id, format_id, field_value) VALUES '
|
'REPLACE INTO msz_profile_fields_values (field_id, user_id, format_id, field_value) VALUES '
|
||||||
. DbTools::prepareListString($rows, '(?, ?, ?, ?)')
|
. DbTools::prepareListString($rows, '(?, ?, ?, ?)')
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($rows as $row) {
|
foreach($rows as $row) {
|
||||||
$stmt->addParameter(++$args, $row[0]);
|
$stmt->nextParameter($row[0]);
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(++$args, $row[1]);
|
$stmt->nextParameter($row[1]);
|
||||||
$stmt->addParameter(++$args, $row[2]);
|
$stmt->nextParameter($row[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@ -272,14 +269,13 @@ class ProfileFields {
|
||||||
throw new InvalidArgumentException('$fieldInfos array may only contain string IDs or instances of ProfileFieldInfo');
|
throw new InvalidArgumentException('$fieldInfos array may only contain string IDs or instances of ProfileFieldInfo');
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get(sprintf(
|
$stmt = $this->cache->get(sprintf(
|
||||||
'DELETE FROM msz_profile_fields_values WHERE user_id = ? AND field_id IN (%s)',
|
'DELETE FROM msz_profile_fields_values WHERE user_id = ? AND field_id IN (%s)',
|
||||||
DbTools::prepareListString($fieldInfos)
|
DbTools::prepareListString($fieldInfos)
|
||||||
));
|
));
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
foreach($fieldInfos as $value)
|
foreach($fieldInfos as $value)
|
||||||
$stmt->addParameter(++$args, $value);
|
$stmt->nextParameter($value);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,10 +42,9 @@ class Bans {
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$query .= sprintf(' %s user_id = ?', ++$args > 1 ? 'AND' : 'WHERE');
|
$query .= sprintf(' %s user_id = ?', ++$args > 1 ? 'AND' : 'WHERE');
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -90,13 +89,12 @@ class Bans {
|
||||||
if($hasPagination)
|
if($hasPagination)
|
||||||
$query .= ' LIMIT ? OFFSET ?';
|
$query .= ' LIMIT ? OFFSET ?';
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
if($hasPagination) {
|
if($hasPagination) {
|
||||||
$stmt->addParameter(++$args, $pagination->range);
|
$stmt->nextParameter($pagination->range);
|
||||||
$stmt->addParameter(++$args, $pagination->offset);
|
$stmt->nextParameter($pagination->offset);
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
|
@ -105,7 +103,7 @@ class Bans {
|
||||||
|
|
||||||
public function getBan(string $banId): BanInfo {
|
public function getBan(string $banId): BanInfo {
|
||||||
$stmt = $this->cache->get('SELECT ban_id, user_id, mod_id, ban_severity, ban_reason_public, ban_reason_private, UNIX_TIMESTAMP(ban_created), UNIX_TIMESTAMP(ban_expires) FROM msz_users_bans WHERE ban_id = ?');
|
$stmt = $this->cache->get('SELECT ban_id, user_id, mod_id, ban_severity, ban_reason_public, ban_reason_private, UNIX_TIMESTAMP(ban_created), UNIX_TIMESTAMP(ban_expires) FROM msz_users_bans WHERE ban_id = ?');
|
||||||
$stmt->addParameter(1, $banId);
|
$stmt->nextParameter($banId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -124,8 +122,8 @@ class Bans {
|
||||||
|
|
||||||
// orders by ban_expires descending with NULLs (permanent) first
|
// orders by ban_expires descending with NULLs (permanent) first
|
||||||
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_users_bans WHERE user_id = ? AND ban_severity >= ? AND (ban_expires IS NULL OR ban_expires > NOW()) ORDER BY ban_expires IS NULL DESC, ban_expires DESC');
|
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_users_bans WHERE user_id = ? AND ban_severity >= ? AND (ban_expires IS NULL OR ban_expires > NOW()) ORDER BY ban_expires IS NULL DESC, ban_expires DESC');
|
||||||
$stmt->addParameter(1, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(2, $minimumSeverity);
|
$stmt->nextParameter($minimumSeverity);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -141,8 +139,8 @@ class Bans {
|
||||||
|
|
||||||
// orders by ban_expires descending with NULLs (permanent) first
|
// orders by ban_expires descending with NULLs (permanent) first
|
||||||
$stmt = $this->cache->get('SELECT ban_id, user_id, mod_id, ban_severity, ban_reason_public, ban_reason_private, UNIX_TIMESTAMP(ban_created), UNIX_TIMESTAMP(ban_expires) FROM msz_users_bans WHERE user_id = ? AND ban_severity >= ? AND (ban_expires IS NULL OR ban_expires > NOW()) ORDER BY ban_expires IS NULL DESC, ban_expires DESC');
|
$stmt = $this->cache->get('SELECT ban_id, user_id, mod_id, ban_severity, ban_reason_public, ban_reason_private, UNIX_TIMESTAMP(ban_created), UNIX_TIMESTAMP(ban_expires) FROM msz_users_bans WHERE user_id = ? AND ban_severity >= ? AND (ban_expires IS NULL OR ban_expires > NOW()) ORDER BY ban_expires IS NULL DESC, ban_expires DESC');
|
||||||
$stmt->addParameter(1, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(2, $minimumSeverity);
|
$stmt->nextParameter($minimumSeverity);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -167,12 +165,12 @@ class Bans {
|
||||||
$expires = (int)$expires->format('U');
|
$expires = (int)$expires->format('U');
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_users_bans (user_id, mod_id, ban_severity, ban_reason_public, ban_reason_private, ban_expires) VALUES (?, ?, ?, ?, ?, FROM_UNIXTIME(?))');
|
$stmt = $this->cache->get('INSERT INTO msz_users_bans (user_id, mod_id, ban_severity, ban_reason_public, ban_reason_private, ban_expires) VALUES (?, ?, ?, ?, ?, FROM_UNIXTIME(?))');
|
||||||
$stmt->addParameter(1, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(2, $modInfo);
|
$stmt->nextParameter($modInfo);
|
||||||
$stmt->addParameter(3, $severity);
|
$stmt->nextParameter($severity);
|
||||||
$stmt->addParameter(4, $publicReason);
|
$stmt->nextParameter($publicReason);
|
||||||
$stmt->addParameter(5, $privateReason);
|
$stmt->nextParameter($privateReason);
|
||||||
$stmt->addParameter(6, $expires);
|
$stmt->nextParameter($expires);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $this->getBan((string)$this->dbConn->getLastInsertId());
|
return $this->getBan((string)$this->dbConn->getLastInsertId());
|
||||||
|
@ -190,14 +188,13 @@ class Bans {
|
||||||
DbTools::prepareListString($banInfos)
|
DbTools::prepareListString($banInfos)
|
||||||
));
|
));
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
foreach($banInfos as $banInfo) {
|
foreach($banInfos as $banInfo) {
|
||||||
if($banInfo instanceof BanInfo)
|
if($banInfo instanceof BanInfo)
|
||||||
$banInfo = $banInfo->id;
|
$banInfo = $banInfo->id;
|
||||||
elseif(!is_string($banInfo))
|
elseif(!is_string($banInfo))
|
||||||
throw new InvalidArgumentException('$banInfos must be strings of instances of BanInfo.');
|
throw new InvalidArgumentException('$banInfos must be strings of instances of BanInfo.');
|
||||||
|
|
||||||
$stmt->addParameter(++$args, $banInfo);
|
$stmt->nextParameter($banInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
|
@ -36,12 +36,11 @@ class ModNotes {
|
||||||
if($hasAuthorInfo)
|
if($hasAuthorInfo)
|
||||||
$query .= sprintf(' %s author_id = ?', ++$args > 1 ? 'AND' : 'WHERE');
|
$query .= sprintf(' %s author_id = ?', ++$args > 1 ? 'AND' : 'WHERE');
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
if($hasAuthorInfo)
|
if($hasAuthorInfo)
|
||||||
$stmt->addParameter(++$args, $authorInfo);
|
$stmt->nextParameter($authorInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -80,15 +79,14 @@ class ModNotes {
|
||||||
if($hasPagination)
|
if($hasPagination)
|
||||||
$query .= ' LIMIT ? OFFSET ?';
|
$query .= ' LIMIT ? OFFSET ?';
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
if($hasAuthorInfo)
|
if($hasAuthorInfo)
|
||||||
$stmt->addParameter(++$args, $authorInfo);
|
$stmt->nextParameter($authorInfo);
|
||||||
if($hasPagination) {
|
if($hasPagination) {
|
||||||
$stmt->addParameter(++$args, $pagination->range);
|
$stmt->nextParameter($pagination->range);
|
||||||
$stmt->addParameter(++$args, $pagination->offset);
|
$stmt->nextParameter($pagination->offset);
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
|
@ -97,7 +95,7 @@ class ModNotes {
|
||||||
|
|
||||||
public function getNote(string $noteId): ModNoteInfo {
|
public function getNote(string $noteId): ModNoteInfo {
|
||||||
$stmt = $this->cache->get('SELECT note_id, user_id, author_id, UNIX_TIMESTAMP(note_created), note_title, note_body FROM msz_users_modnotes WHERE note_id = ?');
|
$stmt = $this->cache->get('SELECT note_id, user_id, author_id, UNIX_TIMESTAMP(note_created), note_title, note_body FROM msz_users_modnotes WHERE note_id = ?');
|
||||||
$stmt->addParameter(1, $noteId);
|
$stmt->nextParameter($noteId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
|
||||||
|
@ -119,10 +117,10 @@ class ModNotes {
|
||||||
$authorInfo = $authorInfo->id;
|
$authorInfo = $authorInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_users_modnotes (user_id, author_id, note_title, note_body) VALUES (?, ?, ?, ?)');
|
$stmt = $this->cache->get('INSERT INTO msz_users_modnotes (user_id, author_id, note_title, note_body) VALUES (?, ?, ?, ?)');
|
||||||
$stmt->addParameter(1, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(2, $authorInfo);
|
$stmt->nextParameter($authorInfo);
|
||||||
$stmt->addParameter(3, $title);
|
$stmt->nextParameter($title);
|
||||||
$stmt->addParameter(4, $body);
|
$stmt->nextParameter($body);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $this->getNote((string)$this->dbConn->getLastInsertId());
|
return $this->getNote((string)$this->dbConn->getLastInsertId());
|
||||||
|
@ -140,14 +138,13 @@ class ModNotes {
|
||||||
DbTools::prepareListString($noteInfos)
|
DbTools::prepareListString($noteInfos)
|
||||||
));
|
));
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
foreach($noteInfos as $noteInfo) {
|
foreach($noteInfos as $noteInfo) {
|
||||||
if($noteInfo instanceof ModNoteInfo)
|
if($noteInfo instanceof ModNoteInfo)
|
||||||
$noteInfo = $noteInfo->id;
|
$noteInfo = $noteInfo->id;
|
||||||
elseif(!is_string($noteInfo))
|
elseif(!is_string($noteInfo))
|
||||||
throw new InvalidArgumentException('$noteInfos must be strings of instances of ModNoteInfo.');
|
throw new InvalidArgumentException('$noteInfos must be strings of instances of ModNoteInfo.');
|
||||||
|
|
||||||
$stmt->addParameter(++$args, $noteInfo);
|
$stmt->nextParameter($noteInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@ -162,9 +159,9 @@ class ModNotes {
|
||||||
$noteInfo = $noteInfo->id;
|
$noteInfo = $noteInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_users_modnotes SET note_title = COALESCE(?, note_title), note_body = COALESCE(?, note_body) WHERE note_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_users_modnotes SET note_title = COALESCE(?, note_title), note_body = COALESCE(?, note_body) WHERE note_id = ?');
|
||||||
$stmt->addParameter(1, $title);
|
$stmt->nextParameter($title);
|
||||||
$stmt->addParameter(2, $body);
|
$stmt->nextParameter($body);
|
||||||
$stmt->addParameter(3, $noteInfo);
|
$stmt->nextParameter($noteInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,9 @@ class Roles {
|
||||||
if($hasHidden)
|
if($hasHidden)
|
||||||
$query .= sprintf(' %s role_hidden %s 0', ++$args > 1 ? 'AND' : 'WHERE', $hidden ? '=' : '<>');
|
$query .= sprintf(' %s role_hidden %s 0', ++$args > 1 ? 'AND' : 'WHERE', $hidden ? '=' : '<>');
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
@ -96,7 +95,7 @@ class Roles {
|
||||||
|
|
||||||
public function getRole(string $roleId): RoleInfo {
|
public function getRole(string $roleId): RoleInfo {
|
||||||
$stmt = $this->cache->get('SELECT role_id, role_string, role_hierarchy, role_name, role_title, role_description, role_hidden, role_can_leave, role_colour, UNIX_TIMESTAMP(role_created) FROM msz_roles WHERE role_id = ?');
|
$stmt = $this->cache->get('SELECT role_id, role_string, role_hierarchy, role_name, role_title, role_description, role_hidden, role_can_leave, role_colour, UNIX_TIMESTAMP(role_created) FROM msz_roles WHERE role_id = ?');
|
||||||
$stmt->addParameter(1, $roleId);
|
$stmt->nextParameter($roleId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -151,14 +150,13 @@ class Roles {
|
||||||
DbTools::prepareListString($roleInfos)
|
DbTools::prepareListString($roleInfos)
|
||||||
));
|
));
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
foreach($roleInfos as $roleInfo) {
|
foreach($roleInfos as $roleInfo) {
|
||||||
if($roleInfo instanceof RoleInfo)
|
if($roleInfo instanceof RoleInfo)
|
||||||
$roleInfo = $roleInfo->id;
|
$roleInfo = $roleInfo->id;
|
||||||
elseif(!is_string($roleInfo))
|
elseif(!is_string($roleInfo))
|
||||||
throw new InvalidArgumentException('$roleInfos must be strings of instances of RoleInfo.');
|
throw new InvalidArgumentException('$roleInfos must be strings of instances of RoleInfo.');
|
||||||
|
|
||||||
$stmt->addParameter(++$args, $roleInfo);
|
$stmt->nextParameter($roleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@ -223,7 +221,7 @@ class Roles {
|
||||||
$roleInfo = $roleInfo->id;
|
$roleInfo = $roleInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_users_roles WHERE role_id = ?');
|
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_users_roles WHERE role_id = ?');
|
||||||
$stmt->addParameter(1, $roleInfo);
|
$stmt->nextParameter($roleInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
|
|
@ -73,16 +73,15 @@ class Users {
|
||||||
if($hasDeleted)
|
if($hasDeleted)
|
||||||
$query .= sprintf(' %s user_deleted %s NULL', ++$args > 1 ? 'AND' : 'WHERE', $deleted ? 'IS NOT' : 'IS');
|
$query .= sprintf(' %s user_deleted %s NULL', ++$args > 1 ? 'AND' : 'WHERE', $deleted ? 'IS NOT' : 'IS');
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasRoleInfo)
|
if($hasRoleInfo)
|
||||||
$stmt->addParameter(++$args, $roleInfo);
|
$stmt->nextParameter($roleInfo);
|
||||||
if($hasAfter)
|
if($hasAfter)
|
||||||
$stmt->addParameter(++$args, $after);
|
$stmt->nextParameter($after);
|
||||||
if($hasLastActiveInMinutes)
|
if($hasLastActiveInMinutes)
|
||||||
$stmt->addParameter(++$args, $lastActiveInMinutes);
|
$stmt->nextParameter($lastActiveInMinutes);
|
||||||
if($hasNewerThanDays)
|
if($hasNewerThanDays)
|
||||||
$stmt->addParameter(++$args, $newerThanDays);
|
$stmt->nextParameter($newerThanDays);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -192,23 +191,22 @@ class Users {
|
||||||
elseif($hasPagination)
|
elseif($hasPagination)
|
||||||
$query .= ' LIMIT ? OFFSET ?';
|
$query .= ' LIMIT ? OFFSET ?';
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasRoleInfo)
|
if($hasRoleInfo)
|
||||||
$stmt->addParameter(++$args, $roleInfo);
|
$stmt->nextParameter($roleInfo);
|
||||||
if($hasAfter)
|
if($hasAfter)
|
||||||
$stmt->addParameter(++$args, $after);
|
$stmt->nextParameter($after);
|
||||||
if($hasLastActiveInMinutes)
|
if($hasLastActiveInMinutes)
|
||||||
$stmt->addParameter(++$args, $lastActiveInMinutes);
|
$stmt->nextParameter($lastActiveInMinutes);
|
||||||
if($hasNewerThanDays)
|
if($hasNewerThanDays)
|
||||||
$stmt->addParameter(++$args, $newerThanDays);
|
$stmt->nextParameter($newerThanDays);
|
||||||
if($hasBirthdate)
|
if($hasBirthdate)
|
||||||
$stmt->addParameter(++$args, $birthdate->format('%-m-d'));
|
$stmt->nextParameter($birthdate->format('%-m-d'));
|
||||||
if($hasSearchQuery)
|
if($hasSearchQuery)
|
||||||
$stmt->addParameter(++$args, $searchQuery);
|
$stmt->nextParameter($searchQuery);
|
||||||
if($hasPagination) {
|
if($hasPagination) {
|
||||||
$stmt->addParameter(++$args, $pagination->range);
|
$stmt->nextParameter($pagination->range);
|
||||||
$stmt->addParameter(++$args, $pagination->offset);
|
$stmt->nextParameter($pagination->offset);
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
|
@ -264,14 +262,13 @@ class Users {
|
||||||
if($selectMail)
|
if($selectMail)
|
||||||
$query .= sprintf(' %s email = ?', ++$args > 1 ? 'OR' : 'WHERE');
|
$query .= sprintf(' %s email = ?', ++$args > 1 ? 'OR' : 'WHERE');
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($selectId)
|
if($selectId)
|
||||||
$stmt->addParameter(++$args, $value);
|
$stmt->nextParameter($value);
|
||||||
if($selectName)
|
if($selectName)
|
||||||
$stmt->addParameter(++$args, $value);
|
$stmt->nextParameter($value);
|
||||||
if($selectMail)
|
if($selectMail)
|
||||||
$stmt->addParameter(++$args, $value);
|
$stmt->nextParameter($value);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -302,13 +299,13 @@ class Users {
|
||||||
throw new InvalidArgumentException('$email is not a valid e-mail address.');
|
throw new InvalidArgumentException('$email is not a valid e-mail address.');
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_users (username, password, email, register_ip, last_ip, user_country, display_role) VALUES (?, ?, ?, INET6_ATON(?), INET6_ATON(?), ?, ?)');
|
$stmt = $this->cache->get('INSERT INTO msz_users (username, password, email, register_ip, last_ip, user_country, display_role) VALUES (?, ?, ?, INET6_ATON(?), INET6_ATON(?), ?, ?)');
|
||||||
$stmt->addParameter(1, $name);
|
$stmt->nextParameter($name);
|
||||||
$stmt->addParameter(2, $password);
|
$stmt->nextParameter($password);
|
||||||
$stmt->addParameter(3, $email);
|
$stmt->nextParameter($email);
|
||||||
$stmt->addParameter(4, $remoteAddr);
|
$stmt->nextParameter($remoteAddr);
|
||||||
$stmt->addParameter(5, $remoteAddr);
|
$stmt->nextParameter($remoteAddr);
|
||||||
$stmt->addParameter(6, $countryCode);
|
$stmt->nextParameter($countryCode);
|
||||||
$stmt->addParameter(7, $displayRoleInfo);
|
$stmt->nextParameter($displayRoleInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $this->getUser((string)$this->dbConn->getLastInsertId(), self::GET_USER_ID);
|
return $this->getUser((string)$this->dbConn->getLastInsertId(), self::GET_USER_ID);
|
||||||
|
@ -427,11 +424,10 @@ class Users {
|
||||||
if(empty($fields))
|
if(empty($fields))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get(sprintf('UPDATE msz_users SET %s WHERE user_id = ?', implode(', ', $fields)));
|
$stmt = $this->cache->get(sprintf('UPDATE msz_users SET %s WHERE user_id = ?', implode(', ', $fields)));
|
||||||
foreach($values as $value)
|
foreach($values as $value)
|
||||||
$stmt->addParameter(++$args, $value);
|
$stmt->nextParameter($value);
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,8 +439,8 @@ class Users {
|
||||||
$userInfo = $userInfo->id;
|
$userInfo = $userInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('UPDATE msz_users SET user_active = NOW(), last_ip = INET6_ATON(?) WHERE user_id = ?');
|
$stmt = $this->cache->get('UPDATE msz_users SET user_active = NOW(), last_ip = INET6_ATON(?) WHERE user_id = ?');
|
||||||
$stmt->addParameter(1, $remoteAddr);
|
$stmt->nextParameter($remoteAddr);
|
||||||
$stmt->addParameter(2, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,12 +471,11 @@ class Users {
|
||||||
elseif(empty($roleInfos))
|
elseif(empty($roleInfos))
|
||||||
return [];
|
return [];
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get(sprintf(
|
$stmt = $this->cache->get(sprintf(
|
||||||
'SELECT role_id FROM msz_users_roles WHERE user_id = ? AND role_id IN (%s)',
|
'SELECT role_id FROM msz_users_roles WHERE user_id = ? AND role_id IN (%s)',
|
||||||
DbTools::prepareListString($roleInfos)
|
DbTools::prepareListString($roleInfos)
|
||||||
));
|
));
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
|
|
||||||
foreach($roleInfos as $roleInfo) {
|
foreach($roleInfos as $roleInfo) {
|
||||||
if($roleInfo instanceof RoleInfo)
|
if($roleInfo instanceof RoleInfo)
|
||||||
|
@ -488,7 +483,7 @@ class Users {
|
||||||
elseif(!is_string($roleInfo))
|
elseif(!is_string($roleInfo))
|
||||||
throw new InvalidArgumentException('$roleInfos must be strings of instances of RoleInfo.');
|
throw new InvalidArgumentException('$roleInfos must be strings of instances of RoleInfo.');
|
||||||
|
|
||||||
$stmt->addParameter(++$args, $roleInfo);
|
$stmt->nextParameter($roleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@ -519,15 +514,14 @@ class Users {
|
||||||
DbTools::prepareListString($roleInfos, '(?, ?)')
|
DbTools::prepareListString($roleInfos, '(?, ?)')
|
||||||
));
|
));
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
foreach($roleInfos as $roleInfo) {
|
foreach($roleInfos as $roleInfo) {
|
||||||
if($roleInfo instanceof RoleInfo)
|
if($roleInfo instanceof RoleInfo)
|
||||||
$roleInfo = $roleInfo->id;
|
$roleInfo = $roleInfo->id;
|
||||||
elseif(!is_string($roleInfo))
|
elseif(!is_string($roleInfo))
|
||||||
throw new InvalidArgumentException('$roleInfos must be strings of instances of RoleInfo.');
|
throw new InvalidArgumentException('$roleInfos must be strings of instances of RoleInfo.');
|
||||||
|
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(++$args, $roleInfo);
|
$stmt->nextParameter($roleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@ -545,12 +539,11 @@ class Users {
|
||||||
elseif(empty($roleInfos))
|
elseif(empty($roleInfos))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get(sprintf(
|
$stmt = $this->cache->get(sprintf(
|
||||||
'DELETE FROM msz_users_roles WHERE user_id = ? AND role_id IN (%s)',
|
'DELETE FROM msz_users_roles WHERE user_id = ? AND role_id IN (%s)',
|
||||||
DbTools::prepareListString($roleInfos)
|
DbTools::prepareListString($roleInfos)
|
||||||
));
|
));
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
|
|
||||||
foreach($roleInfos as $roleInfo) {
|
foreach($roleInfos as $roleInfo) {
|
||||||
if($roleInfo instanceof RoleInfo)
|
if($roleInfo instanceof RoleInfo)
|
||||||
|
@ -558,7 +551,7 @@ class Users {
|
||||||
elseif(!is_string($roleInfo))
|
elseif(!is_string($roleInfo))
|
||||||
throw new InvalidArgumentException('$roleInfos must be strings of instances of RoleInfo.');
|
throw new InvalidArgumentException('$roleInfos must be strings of instances of RoleInfo.');
|
||||||
|
|
||||||
$stmt->addParameter(++$args, $roleInfo);
|
$stmt->nextParameter($roleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@ -580,7 +573,7 @@ class Users {
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = $this->cache->get(sprintf('SELECT role_colour FROM msz_roles WHERE role_id = %s', $query));
|
$stmt = $this->cache->get(sprintf('SELECT role_colour FROM msz_roles WHERE role_id = %s', $query));
|
||||||
$stmt->addParameter(1, $value);
|
$stmt->nextParameter($value);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -592,7 +585,7 @@ class Users {
|
||||||
$userInfo = $userInfo->id;
|
$userInfo = $userInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('SELECT MAX(role_hierarchy) FROM msz_roles WHERE role_id IN (SELECT role_id FROM msz_users_roles WHERE user_id = ?)');
|
$stmt = $this->cache->get('SELECT MAX(role_hierarchy) FROM msz_roles WHERE role_id IN (SELECT role_id FROM msz_users_roles WHERE user_id = ?)');
|
||||||
$stmt->addParameter(1, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -601,7 +594,7 @@ class Users {
|
||||||
|
|
||||||
public function checkNameInUse(string $name): bool {
|
public function checkNameInUse(string $name): bool {
|
||||||
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_users WHERE username = ?');
|
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_users WHERE username = ?');
|
||||||
$stmt->addParameter(1, $name);
|
$stmt->nextParameter($name);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
if(!$result->next())
|
if(!$result->next())
|
||||||
|
@ -646,7 +639,7 @@ class Users {
|
||||||
|
|
||||||
public function checkEMailAddressInUse(string $address): bool {
|
public function checkEMailAddressInUse(string $address): bool {
|
||||||
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_users WHERE email = ?');
|
$stmt = $this->cache->get('SELECT COUNT(*) FROM msz_users WHERE email = ?');
|
||||||
$stmt->addParameter(1, $address);
|
$stmt->nextParameter($address);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
if(!$result->next())
|
if(!$result->next())
|
||||||
|
|
|
@ -45,9 +45,9 @@ class Warnings {
|
||||||
$args = 0;
|
$args = 0;
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
if($hasBacklog)
|
if($hasBacklog)
|
||||||
$stmt->addParameter(++$args, $backlog);
|
$stmt->nextParameter($backlog);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -95,15 +95,14 @@ class Warnings {
|
||||||
if($hasPagination)
|
if($hasPagination)
|
||||||
$query .= ' LIMIT ? OFFSET ?';
|
$query .= ' LIMIT ? OFFSET ?';
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
$stmt = $this->cache->get($query);
|
$stmt = $this->cache->get($query);
|
||||||
if($hasUserInfo)
|
if($hasUserInfo)
|
||||||
$stmt->addParameter(++$args, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
if($hasBacklog)
|
if($hasBacklog)
|
||||||
$stmt->addParameter(++$args, $backlog);
|
$stmt->nextParameter($backlog);
|
||||||
if($hasPagination) {
|
if($hasPagination) {
|
||||||
$stmt->addParameter(++$args, $pagination->range);
|
$stmt->nextParameter($pagination->range);
|
||||||
$stmt->addParameter(++$args, $pagination->offset);
|
$stmt->nextParameter($pagination->offset);
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
|
@ -112,7 +111,7 @@ class Warnings {
|
||||||
|
|
||||||
public function getWarning(string $warnId): WarningInfo {
|
public function getWarning(string $warnId): WarningInfo {
|
||||||
$stmt = $this->cache->get('SELECT warn_id, user_id, mod_id, warn_body, UNIX_TIMESTAMP(warn_created) FROM msz_users_warnings WHERE warn_id = ?');
|
$stmt = $this->cache->get('SELECT warn_id, user_id, mod_id, warn_body, UNIX_TIMESTAMP(warn_created) FROM msz_users_warnings WHERE warn_id = ?');
|
||||||
$stmt->addParameter(1, $warnId);
|
$stmt->nextParameter($warnId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->getResult();
|
$result = $stmt->getResult();
|
||||||
|
@ -134,9 +133,9 @@ class Warnings {
|
||||||
$modInfo = $modInfo->id;
|
$modInfo = $modInfo->id;
|
||||||
|
|
||||||
$stmt = $this->cache->get('INSERT INTO msz_users_warnings (user_id, mod_id, warn_body) VALUES (?, ?, ?)');
|
$stmt = $this->cache->get('INSERT INTO msz_users_warnings (user_id, mod_id, warn_body) VALUES (?, ?, ?)');
|
||||||
$stmt->addParameter(1, $userInfo);
|
$stmt->nextParameter($userInfo);
|
||||||
$stmt->addParameter(2, $modInfo);
|
$stmt->nextParameter($modInfo);
|
||||||
$stmt->addParameter(3, $body);
|
$stmt->nextParameter($body);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return $this->getWarning((string)$this->dbConn->getLastInsertId());
|
return $this->getWarning((string)$this->dbConn->getLastInsertId());
|
||||||
|
@ -154,14 +153,13 @@ class Warnings {
|
||||||
DbTools::prepareListString($warnInfos)
|
DbTools::prepareListString($warnInfos)
|
||||||
));
|
));
|
||||||
|
|
||||||
$args = 0;
|
|
||||||
foreach($warnInfos as $warnInfo) {
|
foreach($warnInfos as $warnInfo) {
|
||||||
if($warnInfo instanceof WarningInfo)
|
if($warnInfo instanceof WarningInfo)
|
||||||
$warnInfo = $warnInfo->id;
|
$warnInfo = $warnInfo->id;
|
||||||
elseif(!is_string($warnInfo))
|
elseif(!is_string($warnInfo))
|
||||||
throw new InvalidArgumentException('$warnInfos must be strings of instances of WarningInfo.');
|
throw new InvalidArgumentException('$warnInfos must be strings of instances of WarningInfo.');
|
||||||
|
|
||||||
$stmt->addParameter(++$args, $warnInfo);
|
$stmt->nextParameter($warnInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
Reference in a new issue