diff --git a/library/ajax/avatar.php b/library/ajax/avatar.php
index 6649f98dc..8d729637e 100644
--- a/library/ajax/avatar.php
+++ b/library/ajax/avatar.php
@@ -38,6 +38,6 @@ switch ($mode) {
DB()->query("UPDATE " . BB_USERS . " SET avatar_ext_id = $new_ext_id WHERE user_id = $user_id");
-\TorrentPier\Legacy\Sessions::cache_rm_user_sessions($user_id);
+\TorrentPier\Sessions::cache_rm_user_sessions($user_id);
$this->response['avatar_html'] = $response;
diff --git a/library/ajax/change_tor_status.php b/library/ajax/change_tor_status.php
index 84aad69c5..2a9e9d3de 100644
--- a/library/ajax/change_tor_status.php
+++ b/library/ajax/change_tor_status.php
@@ -97,7 +97,7 @@ switch ($mode) {
}
send_pm($tor['poster_id'], $subject, $message, $userdata['user_id']);
- \TorrentPier\Legacy\Sessions::cache_rm_user_sessions($tor['poster_id']);
+ \TorrentPier\Sessions::cache_rm_user_sessions($tor['poster_id']);
}
}
break;
@@ -115,7 +115,7 @@ switch ($mode) {
}
send_pm($tor['checked_user_id'], $subject, $message, $userdata['user_id']);
- \TorrentPier\Legacy\Sessions::cache_rm_user_sessions($tor['checked_user_id']);
+ \TorrentPier\Sessions::cache_rm_user_sessions($tor['checked_user_id']);
break;
}
diff --git a/library/ajax/change_user_opt.php b/library/ajax/change_user_opt.php
index 0417f9ca6..76d0969bd 100644
--- a/library/ajax/change_user_opt.php
+++ b/library/ajax/change_user_opt.php
@@ -33,6 +33,6 @@ foreach ($bf['user_opt'] as $opt_name => $opt_bit) {
DB()->query("UPDATE " . BB_USERS . " SET user_opt = {$u_data['user_opt']} WHERE user_id = $user_id");
// Удаляем данные из кеша
-\TorrentPier\Legacy\Sessions::cache_rm_user_sessions($user_id);
+\TorrentPier\Sessions::cache_rm_user_sessions($user_id);
$this->response['resp_html'] = $lang['SAVED'];
diff --git a/library/ajax/change_user_rank.php b/library/ajax/change_user_rank.php
index 0397cfef7..5ed652c47 100644
--- a/library/ajax/change_user_rank.php
+++ b/library/ajax/change_user_rank.php
@@ -26,7 +26,7 @@ if ($rank_id != 0 && !isset($ranks[$rank_id])) {
DB()->query("UPDATE " . BB_USERS . " SET user_rank = $rank_id WHERE user_id = $user_id");
-\TorrentPier\Legacy\Sessions::cache_rm_user_sessions($user_id);
+\TorrentPier\Sessions::cache_rm_user_sessions($user_id);
$user_rank = ($rank_id) ? '' . $ranks[$rank_id]['rank_title'] . '' : '';
diff --git a/library/ajax/edit_user_profile.php b/library/ajax/edit_user_profile.php
index 8ac74c01c..b238abe93 100644
--- a/library/ajax/edit_user_profile.php
+++ b/library/ajax/edit_user_profile.php
@@ -153,6 +153,6 @@ switch ($field) {
$value_sql = DB()->escape($value, true);
DB()->query("UPDATE $table SET $field = $value_sql WHERE user_id = $user_id");
-\TorrentPier\Legacy\Sessions::cache_rm_user_sessions($user_id);
+\TorrentPier\Sessions::cache_rm_user_sessions($user_id);
$this->response['edit_id'] = $this->request['edit_id'];
diff --git a/library/ajax/index_data.php b/library/ajax/index_data.php
index 982f1f4d5..900d9cb35 100644
--- a/library/ajax/index_data.php
+++ b/library/ajax/index_data.php
@@ -90,7 +90,7 @@ switch ($mode) {
// Set current user timezone
DB()->query("UPDATE " . BB_USERS . " SET user_timezone = $tz WHERE user_id = " . $userdata['user_id']);
$bb_cfg['board_timezone'] = $tz;
- \TorrentPier\Legacy\Sessions::cache_rm_user_sessions($userdata['user_id']);
+ \TorrentPier\Sessions::cache_rm_user_sessions($userdata['user_id']);
}
break;
diff --git a/library/ajax/manage_user.php b/library/ajax/manage_user.php
index 8ca5890d4..9d58c832c 100644
--- a/library/ajax/manage_user.php
+++ b/library/ajax/manage_user.php
@@ -27,7 +27,7 @@ switch ($mode) {
}
if ($user_id != BOT_UID) {
- \TorrentPier\Legacy\Sessions::delete_user_sessions($user_id);
+ \TorrentPier\Sessions::delete_user_sessions($user_id);
\TorrentPier\Legacy\Admin\Common::user_delete($user_id);
$this->response['info'] = $lang['USER_DELETED'];
@@ -99,7 +99,7 @@ switch ($mode) {
}
DB()->query("UPDATE " . BB_USERS . " SET user_active = '0' WHERE user_id = " . $user_id);
- \TorrentPier\Legacy\Sessions::delete_user_sessions($user_id);
+ \TorrentPier\Sessions::delete_user_sessions($user_id);
$this->response['info'] = $lang['USER_ACTIVATE_OFF'];
diff --git a/library/ajax/post_mod_comment.php b/library/ajax/post_mod_comment.php
index 0a67acd8a..213d4c2cd 100644
--- a/library/ajax/post_mod_comment.php
+++ b/library/ajax/post_mod_comment.php
@@ -43,7 +43,7 @@ if ($mc_type && $post['poster_id'] != $userdata['user_id']) {
$message = sprintf($lang['MC_COMMENT_PM_MSG'], get_username($post['poster_id']), make_url(POST_URL . "$post_id#$post_id"), $lang['MC_COMMENT'][$mc_type]['type'], $mc_text);
send_pm($post['poster_id'], $subject, $message);
- \TorrentPier\Legacy\Sessions::cache_rm_user_sessions($post['poster_id']);
+ \TorrentPier\Sessions::cache_rm_user_sessions($post['poster_id']);
}
switch ($mc_type) {
diff --git a/library/includes/functions.php b/library/includes/functions.php
index d6642ce7c..c28cd732e 100644
--- a/library/includes/functions.php
+++ b/library/includes/functions.php
@@ -1368,7 +1368,7 @@ function bb_die($msg_text)
// If empty session
if (empty($userdata)) {
- $userdata = \TorrentPier\Legacy\Sessions::session_pagestart();
+ $userdata = \TorrentPier\Sessions::session_pagestart();
}
// If the header hasn't been output then do it
diff --git a/library/includes/page_header.php b/library/includes/page_header.php
index b3832f42d..d1f753462 100644
--- a/library/includes/page_header.php
+++ b/library/includes/page_header.php
@@ -70,7 +70,7 @@ if ($logged_in && empty($gen_simple_header) && !defined('IN_ADMIN')) {
if ($userdata['user_last_privmsg'] > $userdata['user_lastvisit'] && defined('IN_PM')) {
$userdata['user_last_privmsg'] = $userdata['user_lastvisit'];
- \TorrentPier\Legacy\Sessions::db_update_userdata($userdata, array(
+ \TorrentPier\Sessions::db_update_userdata($userdata, array(
'user_last_privmsg' => $userdata['user_lastvisit'],
));
@@ -93,7 +93,7 @@ if ($logged_in && empty($gen_simple_header) && !defined('IN_ADMIN')) {
if ($userdata['user_unread_privmsg'] != $real_unread_pm_count) {
$userdata['user_unread_privmsg'] = $real_unread_pm_count;
- \TorrentPier\Legacy\Sessions::db_update_userdata($userdata, array(
+ \TorrentPier\Sessions::db_update_userdata($userdata, array(
'user_unread_privmsg' => $real_unread_pm_count,
));
}
diff --git a/library/includes/ucp/bonus.php b/library/includes/ucp/bonus.php
index 12f679995..910ffa281 100644
--- a/library/includes/ucp/bonus.php
+++ b/library/includes/ucp/bonus.php
@@ -46,7 +46,7 @@ if (isset($_POST['bonus_id'])) {
AND u.user_id = bu.user_id
");
- \TorrentPier\Legacy\Sessions::cache_rm_user_sessions($user_id);
+ \TorrentPier\Sessions::cache_rm_user_sessions($user_id);
meta_refresh(BONUS_URL, 5);
$message = sprintf($lang['BONUS_SUCCES'], humn_size($upload_row[$id] * 1024 * 1024 * 1024));
diff --git a/library/includes/ucp/register.php b/library/includes/ucp/register.php
index f4fb25e1b..cd17aea31 100644
--- a/library/includes/ucp/register.php
+++ b/library/includes/ucp/register.php
@@ -628,7 +628,7 @@ if ($submit && !$errors) {
}
}
- \TorrentPier\Legacy\Sessions::cache_rm_user_sessions($pr_data['user_id']);
+ \TorrentPier\Sessions::cache_rm_user_sessions($pr_data['user_id']);
if ($adm_edit) {
bb_die($lang['PROFILE_USER'] . ' ' . profile_url($pr_data) . ' ' . $lang['GOOD_UPDATE']);
diff --git a/privmsg.php b/privmsg.php
index 2c9889011..74a024667 100644
--- a/privmsg.php
+++ b/privmsg.php
@@ -179,7 +179,7 @@ if ($mode == 'read') {
bb_die('Could not update private message read status for user');
}
if (DB()->affected_rows()) {
- \TorrentPier\Legacy\Sessions::cache_rm_userdata($userdata);
+ \TorrentPier\Sessions::cache_rm_userdata($userdata);
}
$sql = "UPDATE " . BB_PRIVMSGS . "
@@ -895,7 +895,7 @@ if ($mode == 'read') {
bb_die('Could not update private message new / read status for user');
}
- \TorrentPier\Legacy\Sessions::cache_rm_user_sessions($to_userdata['user_id']);
+ \TorrentPier\Sessions::cache_rm_user_sessions($to_userdata['user_id']);
if (bf($to_userdata['user_opt'], 'user_opt', 'user_notify_pm') && $to_userdata['user_active'] && $bb_cfg['pm_notify_enabled']) {
// Sending email
@@ -1146,7 +1146,7 @@ if ($mode == 'read') {
//
// Update unread status
//
- \TorrentPier\Legacy\Sessions::db_update_userdata($userdata, array(
+ \TorrentPier\Sessions::db_update_userdata($userdata, array(
'user_unread_privmsg' => 'user_unread_privmsg + user_new_privmsg',
'user_new_privmsg' => 0,
'user_last_privmsg' => $userdata['session_start'],
diff --git a/src/Legacy/Common/User.php b/src/Legacy/Common/User.php
index 612364400..036c89093 100644
--- a/src/Legacy/Common/User.php
+++ b/src/Legacy/Common/User.php
@@ -10,7 +10,7 @@
namespace TorrentPier\Legacy\Common;
use TorrentPier\Legacy\DateDelta;
-use TorrentPier\Legacy\Sessions;
+use TorrentPier\Sessions;
/**
* Class User
diff --git a/src/Legacy/Sessions.php b/src/Sessions.php
similarity index 80%
rename from src/Legacy/Sessions.php
rename to src/Sessions.php
index 9660bf27e..aa2196f2d 100644
--- a/src/Legacy/Sessions.php
+++ b/src/Sessions.php
@@ -7,11 +7,11 @@
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
*/
-namespace TorrentPier\Legacy;
+namespace TorrentPier;
/**
* Class Sessions
- * @package TorrentPier\Legacy
+ * @package TorrentPier
*/
class Sessions
{
@@ -20,19 +20,19 @@ class Sessions
*
* @return bool
*/
- private static function ignore_cached_userdata()
+ private static function ignore_cached_userdata(): bool
{
- return \defined('IN_PM') ? true : false;
+ return defined('IN_PM');
}
/**
* Get userdata from cache
*
- * @param int $id
+ * @param string $id
*
* @return bool|array
*/
- public static function cache_get_userdata($id)
+ public static function cache_get_userdata(string $id)
{
if (self::ignore_cached_userdata()) {
return false;
@@ -49,7 +49,7 @@ class Sessions
*
* @return bool
*/
- public static function cache_set_userdata($userdata, $force = false)
+ public static function cache_set_userdata(array $userdata, bool $force = false): bool
{
global $bb_cfg;
@@ -68,7 +68,7 @@ class Sessions
*
* @return bool
*/
- public static function cache_rm_userdata($userdata)
+ public static function cache_rm_userdata(array $userdata): bool
{
if (!$userdata) {
return false;
@@ -81,11 +81,11 @@ class Sessions
/**
* Delete user sessions from cache
*
- * @param array|string $user_id
+ * @param string|int $user_id
*/
public static function cache_rm_user_sessions($user_id)
{
- $user_id = get_id_csv($user_id);
+ $user_id = get_id_csv(explode(',', (string)$user_id));
$rowset = DB()->fetch_rowset("SELECT session_id FROM " . BB_SESSIONS . " WHERE session_user_id IN($user_id)");
@@ -101,7 +101,7 @@ class Sessions
*
* @return bool
*/
- public static function cache_update_userdata($userdata)
+ public static function cache_update_userdata(array $userdata): bool
{
return self::cache_set_userdata($userdata, true);
}
@@ -115,7 +115,7 @@ class Sessions
*
* @return bool
*/
- public static function db_update_userdata($userdata, $sql_ary, $data_already_escaped = true)
+ public static function db_update_userdata(array $userdata, array $sql_ary, bool $data_already_escaped = true): bool
{
if (!$userdata) {
return false;
@@ -134,13 +134,13 @@ class Sessions
/**
* Delete user sessions from cache and database
*
- * @param array|string $user_id
+ * @param string|int $user_id
*/
public static function delete_user_sessions($user_id)
{
self::cache_rm_user_sessions($user_id);
- $user_id = get_id_csv($user_id);
+ $user_id = get_id_csv(explode(',', (string)$user_id));
DB()->query("DELETE FROM " . BB_SESSIONS . " WHERE session_user_id IN($user_id)");
}
@@ -152,9 +152,8 @@ class Sessions
*
* @return array
* @deprecated
- *
*/
- public static function session_pagestart($user_ip = USER_IP, $page_id = 0, $req_login = false)
+ public static function session_pagestart($user_ip = USER_IP, $page_id = 0, bool $req_login = false): array
{
global $user;