private static function LoadThreadPosts($page = 1)
 {
     if (WoW_Account::IsLoggedIn()) {
         DB::WoW()->query("REPLACE INTO `DBPREFIX_forum_threads_reads` \n            SET `read_date` = NOW(), `thread_id` = %d, `bn_id` = %d, `page` = %d, `last_post_id` = (SELECT `post_id` FROM `DBPREFIX_forum_posts` WHERE `thread_id` = %d ORDER BY `post_date` DESC LIMIT 1)", self::GetThreadId(), WoW_Account::GetUserID(), self::$page, self::GetThreadId());
     }
     self::$total_thread_posts = DB::WoW()->selectCell("SELECT COUNT(*) FROM `DBPREFIX_forum_posts` WHERE `thread_id` = %d", self::GetThreadId());
     self::$thread_data = DB::WoW()->selectRow("SELECT * FROM `DBPREFIX_forum_threads` WHERE `thread_id` = %d", self::GetThreadId());
     DB::WoW()->query("SET @blizz=0, @tmp_row=0");
     self::$thread_posts = DB::WoW()->select("\n        SELECT DISTINCT\n          `a`.*,\n          DATE_FORMAT(`a`.`post_date`, '%%d/%%c/%%Y') AS `formated_date`,\n          DATE_FORMAT(`a`.`post_date`, '%%d.%%c.%%Y %%H:%%i:%%s') AS `fully_formated_date`,\n          DATE_FORMAT(`a`.`edit_date`, '%%d/%%c/%%Y %%H:%%i') AS `formated_edit_date`,\n          `b`.`title` AS `threadTitle`,\n          `c`.`title_%s` AS `categoryTitle`,\n          `d`.`name` AS `author`,\n          `d`.`class`,\n          `d`.`class_text`,\n          `d`.`class_key`,\n          `d`.`race`,\n          `d`.`race_text`,\n          `d`.`race_key`,\n          `d`.`gender`,\n          `d`.`level`,\n          `d`.`realmId`,\n          `d`.`realmName`,\n          `d`.`guildId`,\n          `d`.`guildName`,\n          `a`.`post_date`,\n          IF((SELECT `post_date` FROM `DBPREFIX_forum_posts` WHERE `thread_id` = `a`.`thread_id` AND `cat_id` = `a`.`cat_id` AND `post_date` > `a`.`post_date` AND `blizzpost` = 1 LIMIT 1) IS NOT NULL, NULL, 1) AS totaly_last_post, \n  \n          IF((SELECT `e`.`blizzpost` FROM `DBPREFIX_forum_posts` AS `e` WHERE `e`.`post_date` > `a`.`post_date` AND `e`.`thread_id` = `a`.`thread_id` AND `e`.`cat_id` = `a`.`cat_id` LIMIT 1) = 1, @tmp_row:=@blizz:=@tmp_row+1, @tmp_row:=@tmp_row+1) AS `ROW`,\n          IF(@blizz = @tmp_row, IF(`a`.`blizzpost` = 1, @blizz+1, NULL), IF(`a`.`blizzpost` = 1, @blizz:=@tmp_row+1+(SELECT COUNT(*) FROM `DBPREFIX_forum_posts` WHERE `thread_id` = `a`.`thread_id` AND `cat_id` = `a`.`cat_id` AND `post_date` BETWEEN `a`.`post_date` AND (SELECT `post_date` FROM `DBPREFIX_forum_posts` WHERE `thread_id` = `a`.`thread_id` AND `cat_id` = `a`.`cat_id` AND `post_date` > `a`.`post_date` AND `blizzpost` = 1 LIMIT 1) AND `blizzpost` = 0), NULL)) AS `nextBlizzPost`\n        \n        FROM `DBPREFIX_forum_posts` AS `a`\n        LEFT JOIN `DBPREFIX_forum_threads` AS `b` ON `b`.`thread_id` = `a`.`thread_id`\n        LEFT JOIN `DBPREFIX_forum_category` AS `c` ON `c`.`cat_id` = `a`.`cat_id`\n        LEFT JOIN `DBPREFIX_user_characters` AS `d` ON `d`.`bn_id` = `a`.`bn_id` AND `d`.`guid` = `a`.`character_guid`\n        WHERE `a`.`thread_id` = %d\n        ORDER BY `a`.`post_date` ASC\n        LIMIT %s%s", WoW_Locale::GetLocale(), self::GetThreadId(), $page > 0 ? ($page - 1) * 20 . ', ' : null, '20');
     self::HandleThreadPosts();
     self::UpdateThreadViews();
 }