diff --git a/system/pages/accountmanagement.php b/system/pages/accountmanagement.php
index 928af2b8..46e966fb 100644
--- a/system/pages/accountmanagement.php
+++ b/system/pages/accountmanagement.php
@@ -124,7 +124,7 @@ $errors = array();
'players' => $account_players
));
}
- else if(file_exists(PAGES . 'account/' . $action)) {
+ else if(file_exists(PAGES . 'account/' . $action . '.php')) {
require(PAGES . 'account/' . $action . '.php');
}
?>
diff --git a/system/pages/forum.php b/system/pages/forum.php
index 0203fecb..591f3cfd 100644
--- a/system/pages/forum.php
+++ b/system/pages/forum.php
@@ -240,144 +240,10 @@ if(empty($action))
return;
}
-$links_to_pages = '';
-if($action == 'show_board')
+
+if($action == 'show_board' || $action == 'show_thread')
{
- $section_id = (int) $_REQUEST['id'];
- $_page = (int) (isset($_REQUEST['page']) ? $_REQUEST['page'] : 0);
- $threads_count = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS threads_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`section` = ".(int) $section_id." AND `" . TABLE_PREFIX . "forum`.`first_post` = `" . TABLE_PREFIX . "forum`.`id`")->fetch();
- for($i = 0; $i < $threads_count['threads_count'] / $config['forum_threads_per_page']; $i++)
- {
- if($i != $_page)
- $links_to_pages .= ''.($i + 1).' ';
- else
- $links_to_pages .= ''.($i + 1).' ';
- }
- echo 'Boards >> '.$sections[$section_id]['name'].' ';
- if(!$sections[$section_id]['closed'] || Forum::isModerator())
- {
- echo '
- ';
- }
-
- echo ' Page: '.$links_to_pages.' ';
- $last_threads = $db->query("SELECT `players`.`id` as `player_id`, `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`last_post`, `" . TABLE_PREFIX . "forum`.`replies`, `" . TABLE_PREFIX . "forum`.`views`, `" . TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`section` = ".(int) $section_id." AND `" . TABLE_PREFIX . "forum`.`first_post` = `" . TABLE_PREFIX . "forum`.`id` ORDER BY `" . TABLE_PREFIX . "forum`.`last_post` DESC LIMIT ".$config['forum_threads_per_page']." OFFSET ".($_page * $config['forum_threads_per_page']))->fetchAll();
- if(isset($last_threads[0]))
- {
- echo '
Thread Thread Starter Replies Views Last Post ';
-
- $player = new OTS_Player();
- foreach($last_threads as $thread)
- {
- echo '';
- if(Forum::isModerator())
- {
- echo '[MOVE] ';
- echo '[REMOVE] ';
- }
-
- $player->load($thread['player_id']);
- if(!$player->isLoaded()) {
- error('Forum error: Player not loaded.');
- die();
- }
-
- $player_account = $player->getAccount();
- $canEditForum = $player_account->hasFlag(FLAG_CONTENT_FORUM) || $player_account->isAdmin();
-
- echo ''.($canEditForum ? $thread['post_topic'] : htmlspecialchars($thread['post_topic'])) . ' '.($canEditForum ? substr(strip_tags($thread['post_text']), 0, 50) : htmlspecialchars(substr($thread['post_text'], 0, 50))).'... ' . getPlayerLink($thread['name']) . ' '.(int) $thread['replies'].' '.(int) $thread['views'].' ';
- if($thread['last_post'] > 0)
- {
- $last_post = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['id']." AND `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` ORDER BY `post_date` DESC LIMIT 1")->fetch();
- if(isset($last_post['name']))
- echo date('d.m.y H:i:s', $last_post['post_date']).' by ' . getPlayerLink($last_post['name']);
- else
- echo 'No posts.';
- }
- else
- echo date('d.m.y H:i:s', $thread['post_date']).' by ' . getPlayerLink($thread['name']);
- echo ' ';
- }
- echo '
';
- if(!$sections[$section_id]['closed'] || Forum::isModerator())
- echo ' ';
- }
- else
- echo 'No threads in this board. ';
- return;
-}
-if($action == 'show_thread')
-{
- $thread_id = (int) $_REQUEST['id'];
- $_page = (int) (isset($_REQUEST['page']) ? $_REQUEST['page'] : 0);
- $thread_name = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_topic` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." AND `" . TABLE_PREFIX . "forum`.`id` = `" . TABLE_PREFIX . "forum`.`first_post` AND `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` LIMIT 1")->fetch();
- if(!empty($thread_name['name']))
- {
- $posts_count = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id)->fetch();
- for($i = 0; $i < $posts_count['posts_count'] / $config['forum_threads_per_page']; $i++)
- {
- if($i != $_page)
- $links_to_pages .= ''.($i + 1).' ';
- else
- $links_to_pages .= ''.($i + 1).' ';
- }
- $threads = $db->query("SELECT `players`.`id` as `player_id`, `players`.`name`, `players`.`account_id`, `players`.`vocation`" . (fieldExist('promotion', 'players') ? ", `players`.`promotion`" : "") . ", `players`.`level`, `" . TABLE_PREFIX . "forum`.`id`,`" . TABLE_PREFIX . "forum`.`first_post`, `" . TABLE_PREFIX . "forum`.`section`,`" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_date`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`author_aid`, `" . TABLE_PREFIX . "forum`.`author_guid`, `" . TABLE_PREFIX . "forum`.`last_edit_aid`, `" . TABLE_PREFIX . "forum`.`edit_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." ORDER BY `" . TABLE_PREFIX . "forum`.`post_date` LIMIT ".$config['forum_posts_per_page']." OFFSET ".($_page * $config['forum_posts_per_page']))->fetchAll();
- if(isset($threads[0]['name']))
- $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `views`=`views`+1 WHERE `id` = ".(int) $thread_id);
- echo 'Boards >> '.$sections[$threads[0]['section']]['name'].' >> '.$thread_name['post_topic'].' ';
- echo ' Page: '.$links_to_pages.''.htmlspecialchars($thread_name['post_topic']).' by ' . getPlayerLink($thread_name['name']) . 'Author ';
- $player = $ots->createObject('Player');
- foreach($threads as $thread)
- {
- $player->load($thread['player_id']);
- if(!$player->isLoaded()) {
- error('Forum error: Player not loaded.');
- die();
- }
-
- echo '' . getPlayerLink($thread['name']) . 'Profession: '.$config['vocations'][$player->getVocation()].' Level: '.$thread['level'].' ';
-
- $rank = $player->getRank();
- if($rank->isLoaded())
- {
- $guild = $rank->getGuild();
- if($guild->isLoaded())
- echo $rank->getName().' of '.$guild->getName().' ';
- }
- $player_account = $player->getAccount();
- $canEditForum = $player_account->hasFlag(FLAG_CONTENT_FORUM) || $player_account->isAdmin();
-
- $posts = $db->query("SELECT COUNT(`id`) AS 'posts' FROM `" . TABLE_PREFIX . "forum` WHERE `author_aid`=".(int) $thread['account_id'])->fetch();
- echo ' Posts: '.(int) $posts['posts'].' '.showPost(($canEditForum ? $thread['post_topic'] : htmlspecialchars($thread['post_topic'])), ($canEditForum ? $thread['post_text'] : htmlspecialchars($thread['post_text'])), $thread['post_smile']).'
- '.date('d.m.y H:i:s', $thread['post_date']);
- if($thread['edit_date'] > 0)
- {
- if($thread['last_edit_aid'] != $thread['author_aid'])
- echo ' Edited by moderator';
- else
- echo ' Edited by '.$thread['name'];
- echo ' on '.date('d.m.y H:i:s', $thread['edit_date']);
- }
- echo ' ';
- if(Forum::isModerator())
- if($thread['first_post'] != $thread['id'])
- echo 'REMOVE POST ';
- else
- {
- echo '[MOVE] ';
- echo 'REMOVE THREAD ';
- }
- if($logged && ($thread['account_id'] == $account_logged->getId() || Forum::isModerator()))
- echo 'EDIT POST ';
- if($logged)
- echo 'Quote ';
- echo ' ';
- }
- echo '
';
- }
- else
- echo 'Thread with this ID does not exits.';
-
+ require(PAGES . 'forum/' . $action . '.php');
return;
}
@@ -387,387 +253,8 @@ if(!$logged)
return;
}
-if($action == 'remove_post')
-{
- if(Forum::isModerator())
- {
- $id = (int) $_REQUEST['id'];
- $post = $db->query("SELECT `id`, `first_post`, `section` FROM `" . TABLE_PREFIX . "forum` WHERE `id` = ".$id." LIMIT 1")->fetch();
- if($post['id'] == $id)
- {
- if($post['id'] == $post['first_post'])
- {
- $db->query("DELETE FROM `" . TABLE_PREFIX . "forum` WHERE `first_post` = ".$post['id']);
- header('Location: ' . getForumBoardLink($post['section']));
- }
- else
- {
- $post_page = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`id` < ".$id." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $post['first_post'])->fetch();
- $_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
- $db->query("DELETE FROM `" . TABLE_PREFIX . "forum` WHERE `id` = ".$post['id']);
- header('Location: ' . getForumThreadLink($post['first_post'], (int) $_page));
- }
- }
- else
- echo 'Post with ID ' . $id . ' does not exist.';
- }
- else
- echo 'You are not logged in or you are not moderator.';
-}
-if($action == 'new_post')
-{
- if(Forum::canPost($account_logged))
- {
- $players_from_account = $db->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll();
- $thread_id = (int) $_REQUEST['thread_id'];
- $thread = $db->query("SELECT `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`section` FROM `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`id` = ".(int) $thread_id." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." LIMIT 1")->fetch();
- echo 'Boards >> '.$sections[$thread['section']]['name'].' >> '.$thread['post_topic'].' >> Post new reply '.$thread['post_topic'].' ';
- if(isset($thread['id']))
- {
- $quote = isset($_REQUEST['quote']) ? (int) $_REQUEST['quote'] : NULL;
- $text = isset($_REQUEST['text']) ? stripslashes(trim($_REQUEST['text'])) : NULL;
- $char_id = (int) (isset($_REQUEST['char_id']) ? $_REQUEST['char_id'] : 0);
- $post_topic = isset($_REQUEST['topic']) ? stripslashes(trim($_REQUEST['topic'])) : '';
- $smile = (int) (isset($_REQUEST['smile']) ? $_REQUEST['smile'] : 0);
- $saved = false;
- if(isset($_REQUEST['quote']))
- {
- $quoted_post = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`id` = ".(int) $quote)->fetchAll();
- if(isset($quoted_post[0]['name']))
- $text = '[i]Originally posted by '.$quoted_post[0]['name'].' on '.date('d.m.y H:i:s', $quoted_post[0]['post_date']).':[/i][quote]'.$quoted_post[0]['post_text'].'[/quote]';
- }
- elseif(isset($_REQUEST['save']))
- {
- $lenght = 0;
- for($i = 0; $i < strlen($text); $i++)
- {
- if(ord($text[$i]) >= 33 && ord($text[$i]) <= 126)
- $lenght++;
- }
- if($lenght < 1 || strlen($text) > 15000)
- $errors[] = 'Too short or too long post (short: '.$lenght.' long: '.strlen($text).' letters). Minimum 1 letter, maximum 15000 letters.';
- if($char_id == 0)
- $errors[] = 'Please select a character.';
- $player_on_account = false;
- if(count($errors) == 0)
- {
- foreach($players_from_account as $player)
- if($char_id == $player['id'])
- $player_on_account = true;
- if(!$player_on_account)
- $errors[] = 'Player with selected ID '.$char_id.' doesn\'t exist or isn\'t on your account';
- }
- if(count($errors) == 0)
- {
- $last_post = 0;
- $query = $db->query('SELECT post_date FROM ' . TABLE_PREFIX . 'forum ORDER BY post_date DESC LIMIT 1');
- if($query->rowCount() > 0)
- {
- $query = $query->fetch();
- $last_post = $query['post_date'];
- }
- if($last_post+$config['forum_post_interval']-time() > 0 && !Forum::isModerator())
- $errors[] = 'You can post one time per '.$config['forum_post_interval'].' seconds. Next post after '.($last_post+$config['forum_post_interval']-time()).' second(s).';
- }
- if(count($errors) == 0)
- {
- $saved = true;
- $db->query("INSERT INTO `" . TABLE_PREFIX . "forum` (`id` ,`first_post` ,`last_post` ,`section` ,`replies` ,`views` ,`author_aid` ,`author_guid` ,`post_text` ,`post_topic` ,`post_smile` ,`post_date` ,`last_edit_aid` ,`edit_date`, `post_ip`) VALUES (NULL, '".$thread['id']."', '0', '".$thread['section']."', '0', '0', '".$account_logged->getId()."', '".(int) $char_id."', ".$db->quote($text).", ".$db->quote($post_topic).", '".(int) $smile."', '".time()."', '0', '0', '".$_SERVER['REMOTE_ADDR']."')");
- $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `replies`=`replies`+1, `last_post`=".time()." WHERE `id` = ".(int) $thread_id);
- $post_page = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`post_date` <= ".time()." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['id'])->fetch();
- $_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
- header('Location: ' . getForumThreadLink($thread_id, $_page));
- echo ' Thank you for posting.GO BACK TO LAST THREAD ';
- }
- }
- if(!$saved)
- {
- if(!empty($errors))
- echo $twig->render('error_box.html.twig', array('errors' => $errors));
-
- echo '';
- $threads = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_smile` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." ORDER BY `" . TABLE_PREFIX . "forum`.`post_date` DESC LIMIT 10")->fetchAll();
- echo 'Last 5 posts from thread: '.$thread['post_topic'].' ';
- foreach($threads as $thread)
- {
- echo ''.$thread['name'].' '.showPost($thread['post_topic'], $thread['post_text'], $thread['post_smile']).' ';
- }
- echo '
';
- }
- }
- else
- echo 'Thread with ID '.$thread_id.' doesn\'t exist.';
- }
- else
- echo "Your account is banned, deleted or you don't have any player with level " . $config['forum_level_required'] . " on your account. You can't post.";
-}
-
-if($action == 'edit_post')
-{
- if(Forum::canPost($account_logged))
- {
- $post_id = (int) $_REQUEST['id'];
- $thread = $db->query("SELECT `" . TABLE_PREFIX . "forum`.`author_guid`, `" . TABLE_PREFIX . "forum`.`author_aid`, `" . TABLE_PREFIX . "forum`.`first_post`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_date`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`section` FROM `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`id` = ".(int) $post_id." LIMIT 1")->fetch();
- if(isset($thread['id']))
- {
- $first_post = $db->query("SELECT `" . TABLE_PREFIX . "forum`.`author_guid`, `" . TABLE_PREFIX . "forum`.`author_aid`, `" . TABLE_PREFIX . "forum`.`first_post`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`section` FROM `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`id` = ".(int) $thread['first_post']." LIMIT 1")->fetch();
- echo 'Boards >> '.$sections[$thread['section']]['name'].' >> '.$first_post['post_topic'].' >> Edit post ';
- if($account_logged->getId() == $thread['author_aid'] || Forum::isModerator())
- {
- $players_from_account = $db->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll();
- $saved = false;
- if(isset($_REQUEST['save']))
- {
- $text = stripslashes(trim($_REQUEST['text']));
- $char_id = (int) $_REQUEST['char_id'];
- $post_topic = stripslashes(trim($_REQUEST['topic']));
- $smile = (int) $_REQUEST['smile'];
- $lenght = 0;
- for($i = 0; $i <= strlen($post_topic); $i++)
- {
- if(ord($post_topic[$i]) >= 33 && ord($post_topic[$i]) <= 126)
- $lenght++;
- }
- if(($lenght < 1 || strlen($post_topic) > 60) && $thread['id'] == $thread['first_post'])
- $errors[] = 'Too short or too long topic (short: '.$lenght.' long: '.strlen($post_topic).' letters). Minimum 1 letter, maximum 60 letters.';
- $lenght = 0;
- for($i = 0; $i <= strlen($text); $i++)
- {
- if(ord($text[$i]) >= 33 && ord($text[$i]) <= 126)
- $lenght++;
- }
- if($lenght < 1 || strlen($text) > 15000)
- $errors[] = 'Too short or too long post (short: '.$lenght.' long: '.strlen($text).' letters). Minimum 1 letter, maximum 15000 letters.';
- if($char_id == 0)
- $errors[] = 'Please select a character.';
- if(empty($post_topic) && $thread['id'] == $thread['first_post'])
- $errors[] = 'Thread topic can\'t be empty.';
- $player_on_account == false;
- if(count($errors) == 0)
- {
- foreach($players_from_account as $player)
- if($char_id == $player['id'])
- $player_on_account = true;
- if(!$player_on_account)
- $errors[] = 'Player with selected ID '.$char_id.' doesn\'t exist or isn\'t on your account';
- }
- if(count($errors) == 0)
- {
- $saved = true;
- if($account_logged->getId() != $thread['author_aid'])
- $char_id = $thread['author_guid'];
- $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `author_guid` = ".(int) $char_id.", `post_text` = ".$db->quote($text).", `post_topic` = ".$db->quote($post_topic).", `post_smile` = ".(int) $smile.", `last_edit_aid` = ".(int) $account_logged->getId().",`edit_date` = ".time()." WHERE `id` = ".(int) $thread['id']);
- $post_page = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`post_date` <= ".$thread['post_date']." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['first_post'])->fetch();
- $_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
- header('Location: ' . getForumThreadLink($thread['first_post'], $_page));
- echo ' Thank you for editing post.GO BACK TO LAST THREAD ';
- }
- }
- else
- {
- $text = $thread['post_text'];
- $char_id = (int) $thread['author_guid'];
- $post_topic = $thread['post_topic'];
- $smile = (int) $thread['post_smile'];
- }
- if(!$saved)
- {
- if(!empty($errors))
- echo $twig->render('error_box.html.twig', array('errors' => $errors));
-
- echo ' ';
- }
- }
- else
- echo ' You are not an author of this post.';
- }
- else
- echo ' Post with ID '.$post_id.' doesn\'t exist.';
- }
- else
- echo ' Your account is banned, deleted or you don\'t have any player with level '.$config['forum_level_required'].' on your account. You can\'t post.';
-}
-
-if($action == 'new_thread')
-{
- if(Forum::canPost($account_logged))
- {
- $players_from_account = $db->query('SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = '.(int) $account_logged->getId())->fetchAll();
- $section_id = isset($_REQUEST['section_id']) ? $_REQUEST['section_id'] : null;
- if($section_id !== null) {
- echo 'Boards >> ' . $sections[$section_id]['name'] . ' >> Post new thread ';
- if (isset($sections[$section_id]['name'])) {
- if ($sections[$section_id]['closed'] && !Forum::isModerator())
- $errors[] = 'You cannot create topic on this board.';
-
- $quote = (int)(isset($_REQUEST['quote']) ? $_REQUEST['quote'] : 0);
- $text = isset($_REQUEST['text']) ? stripslashes($_REQUEST['text']) : '';
- $char_id = (int)(isset($_REQUEST['char_id']) ? $_REQUEST['char_id'] : 0);
- $post_topic = isset($_REQUEST['topic']) ? stripslashes($_REQUEST['topic']) : '';
- $smile = (int)(isset($_REQUEST['smile']) ? $_REQUEST['smile'] : 0);
- $saved = false;
- if (isset($_REQUEST['save'])) {
- $errors = array();
-
- $lenght = 0;
- for ($i = 0; $i < strlen($post_topic); $i++) {
- if (ord($post_topic[$i]) >= 33 && ord($post_topic[$i]) <= 126)
- $lenght++;
- }
- if ($lenght < 1 || strlen($post_topic) > 60)
- $errors[] = 'Too short or too long topic (short: ' . $lenght . ' long: ' . strlen($post_topic) . ' letters). Minimum 1 letter, maximum 60 letters.';
- $lenght = 0;
- for ($i = 0; $i < strlen($text); $i++) {
- if (ord($text[$i]) >= 33 && ord($text[$i]) <= 126)
- $lenght++;
- }
- if ($lenght < 1 || strlen($text) > 15000)
- $errors[] = 'Too short or too long post (short: ' . $lenght . ' long: ' . strlen($text) . ' letters). Minimum 1 letter, maximum 15000 letters.';
-
- if ($char_id == 0)
- $errors[] = 'Please select a character.';
- $player_on_account = false;
-
- if (count($errors) == 0) {
- foreach ($players_from_account as $player)
- if ($char_id == $player['id'])
- $player_on_account = true;
- if (!$player_on_account)
- $errors[] = 'Player with selected ID ' . $char_id . ' doesn\'t exist or isn\'t on your account';
- }
-
- if (count($errors) == 0) {
- $last_post = 0;
- $query = $db->query('SELECT `post_date` FROM `' . TABLE_PREFIX . 'forum` ORDER BY `post_date` DESC LIMIT 1');
- if ($query->rowCount() > 0) {
- $query = $query->fetch();
- $last_post = $query['post_date'];
- }
- if ($last_post + $config['forum_post_interval'] - time() > 0 && !Forum::isModerator())
- $errors[] = 'You can post one time per ' . $config['forum_post_interval'] . ' seconds. Next post after ' . ($last_post + $config['forum_post_interval'] - time()) . ' second(s).';
- }
- if (count($errors) == 0) {
- $saved = true;
- $db->query("INSERT INTO `" . TABLE_PREFIX . "forum` (`first_post` ,`last_post` ,`section` ,`replies` ,`views` ,`author_aid` ,`author_guid` ,`post_text` ,`post_topic` ,`post_smile` ,`post_date` ,`last_edit_aid` ,`edit_date`, `post_ip`) VALUES ('0', '" . time() . "', '" . (int)$section_id . "', '0', '0', '" . $account_logged->getId() . "', '" . (int)$char_id . "', " . $db->quote($text) . ", " . $db->quote($post_topic) . ", '" . (int)$smile . "', '" . time() . "', '0', '0', '" . $_SERVER['REMOTE_ADDR'] . "')");
- $thread_id = $db->lastInsertId();
- $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `first_post`=" . (int)$thread_id . " WHERE `id` = " . (int)$thread_id);
- header('Location: ' . getForumThreadLink($thread_id));
- echo ' Thank you for posting.GO BACK TO LAST THREAD ';
- }
- }
- if (!$saved) {
- if (!empty($errors))
- echo $twig->render('error_box.html.twig', array('errors' => $errors));
-
- echo $twig->render('forum.new_thread.html.twig', array(
- 'section_id' => $section_id,
- 'players' => $players_from_account,
- 'post_player_id' => $char_id,
- 'post_thread' => $post_topic,
- 'text' => $text,
- 'smiles_enabled' => $smile > 0
- ));
- }
- }
- else
- echo 'Board with ID ' . $board_id . ' doesn\'t exist.';
- }
- else
- echo 'Please enter section_id.';
- }
- else
- echo 'Your account is banned, deleted or you don\'t have any player with level '.$config['forum_level_required'].' on your account. You can\'t post.';
-}
-
-//Board Change Function. Scripted by Cybermaster and Absolute Mango
-if($action == 'move_thread')
-{
- if(Forum::isModerator())
- {
- $id = (int) $_REQUEST['id'];
- $post = $db->query("SELECT `id`, `section`, `first_post`, `post_topic`, `author_guid` FROM `" . TABLE_PREFIX . "forum` WHERE `id` = ".$id." LIMIT 1")->fetch();
- $name= $db->query("SELECT `name` FROM `players` WHERE `id` = ".$post['author_guid']." ")->fetch();
- if($post['id'] == $id)
- {
- if($post['id'] == $post['first_post'])
- {
- echo $twig->render('forum.move_thread.html.twig', array(
- 'thread' => $post['post_topic'],
- 'author' => $name[0],
- 'board' => $sections[$post['section']]['name'],
- 'post_id' => $post['id'],
- 'sections' => $sections,
- 'section_link' => getForumBoardLink($post['section']),
- ));
- }
- }
- else
- echo 'Post with ID '.$id.' does not exist.';
- }
- else
- echo 'You are not logged in or you are not moderator.';
-}
-
-if($action == 'moved_thread')
-{
- if(Forum::isModerator())
- {
- $id = (int) $_REQUEST['id'];
- $board = (int) $_REQUEST['section'];
- $post = $db->query("SELECT `id`, `first_post`, `section` FROM `" . TABLE_PREFIX . "forum` WHERE `id` = ".$id." LIMIT 1")->fetch();
- if($post['id'] == $id)
- {
- if($post['id'] == $post['first_post'])
- {
- $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `section` = ".$board." WHERE `id` = ".$post['id']."") or die(mysql_error());
- $nPost = $db->query( 'SELECT `section` FROM `' . TABLE_PREFIX . 'forum` WHERE `id` = \''.$id.'\' LIMIT 1;' )->fetch();
- header('Location: ' . getForumBoardLink($nPost['section']));
- }
- }
- else
- echo 'Post with ID ' . $id . ' does not exist.';
- }
- else
- echo 'You are not logged in or you are not moderator.';
+if(file_exists(PAGES . 'forum/' . $action . '.php')) {
+ require(PAGES . 'forum/' . $action . '.php');
}
class Forum
diff --git a/system/pages/forum/edit_post.php b/system/pages/forum/edit_post.php
new file mode 100644
index 00000000..7edc2162
--- /dev/null
+++ b/system/pages/forum/edit_post.php
@@ -0,0 +1,110 @@
+
+ * @author Slawkens
+ * @copyright 2017 MyAAC
+ * @version 0.6.0
+ * @link http://my-aac.org
+ */
+defined('MYAAC') or die('Direct access not allowed!');
+
+if(Forum::canPost($account_logged))
+{
+ $post_id = (int) $_REQUEST['id'];
+ $thread = $db->query("SELECT `" . TABLE_PREFIX . "forum`.`author_guid`, `" . TABLE_PREFIX . "forum`.`author_aid`, `" . TABLE_PREFIX . "forum`.`first_post`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_date`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`section` FROM `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`id` = ".(int) $post_id." LIMIT 1")->fetch();
+ if(isset($thread['id']))
+ {
+ $first_post = $db->query("SELECT `" . TABLE_PREFIX . "forum`.`author_guid`, `" . TABLE_PREFIX . "forum`.`author_aid`, `" . TABLE_PREFIX . "forum`.`first_post`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`section` FROM `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`id` = ".(int) $thread['first_post']." LIMIT 1")->fetch();
+ echo 'Boards >> '.$sections[$thread['section']]['name'].' >> '.$first_post['post_topic'].' >> Edit post ';
+ if($account_logged->getId() == $thread['author_aid'] || Forum::isModerator())
+ {
+ $players_from_account = $db->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll();
+ $saved = false;
+ if(isset($_REQUEST['save']))
+ {
+ $text = stripslashes(trim($_REQUEST['text']));
+ $char_id = (int) $_REQUEST['char_id'];
+ $post_topic = stripslashes(trim($_REQUEST['topic']));
+ $smile = (int) $_REQUEST['smile'];
+ $lenght = 0;
+ for($i = 0; $i <= strlen($post_topic); $i++)
+ {
+ if(ord($post_topic[$i]) >= 33 && ord($post_topic[$i]) <= 126)
+ $lenght++;
+ }
+ if(($lenght < 1 || strlen($post_topic) > 60) && $thread['id'] == $thread['first_post'])
+ $errors[] = 'Too short or too long topic (short: '.$lenght.' long: '.strlen($post_topic).' letters). Minimum 1 letter, maximum 60 letters.';
+ $lenght = 0;
+ for($i = 0; $i <= strlen($text); $i++)
+ {
+ if(ord($text[$i]) >= 33 && ord($text[$i]) <= 126)
+ $lenght++;
+ }
+ if($lenght < 1 || strlen($text) > 15000)
+ $errors[] = 'Too short or too long post (short: '.$lenght.' long: '.strlen($text).' letters). Minimum 1 letter, maximum 15000 letters.';
+ if($char_id == 0)
+ $errors[] = 'Please select a character.';
+ if(empty($post_topic) && $thread['id'] == $thread['first_post'])
+ $errors[] = 'Thread topic can\'t be empty.';
+ $player_on_account == false;
+ if(count($errors) == 0)
+ {
+ foreach($players_from_account as $player)
+ if($char_id == $player['id'])
+ $player_on_account = true;
+ if(!$player_on_account)
+ $errors[] = 'Player with selected ID '.$char_id.' doesn\'t exist or isn\'t on your account';
+ }
+ if(count($errors) == 0)
+ {
+ $saved = true;
+ if($account_logged->getId() != $thread['author_aid'])
+ $char_id = $thread['author_guid'];
+ $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `author_guid` = ".(int) $char_id.", `post_text` = ".$db->quote($text).", `post_topic` = ".$db->quote($post_topic).", `post_smile` = ".(int) $smile.", `last_edit_aid` = ".(int) $account_logged->getId().",`edit_date` = ".time()." WHERE `id` = ".(int) $thread['id']);
+ $post_page = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`post_date` <= ".$thread['post_date']." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['first_post'])->fetch();
+ $_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
+ header('Location: ' . getForumThreadLink($thread['first_post'], $_page));
+ echo ' Thank you for editing post.GO BACK TO LAST THREAD ';
+ }
+ }
+ else
+ {
+ $text = $thread['post_text'];
+ $char_id = (int) $thread['author_guid'];
+ $post_topic = $thread['post_topic'];
+ $smile = (int) $thread['post_smile'];
+ }
+ if(!$saved)
+ {
+ if(!empty($errors))
+ echo $twig->render('error_box.html.twig', array('errors' => $errors));
+
+ echo ' ';
+ }
+ }
+ else
+ echo ' You are not an author of this post.';
+ }
+ else
+ echo ' Post with ID '.$post_id.' doesn\'t exist.';
+}
+else
+ echo ' Your account is banned, deleted or you don\'t have any player with level '.$config['forum_level_required'].' on your account. You can\'t post.';
+
+?>
\ No newline at end of file
diff --git a/system/pages/forum/move_thread.php b/system/pages/forum/move_thread.php
new file mode 100644
index 00000000..274e234c
--- /dev/null
+++ b/system/pages/forum/move_thread.php
@@ -0,0 +1,52 @@
+
+ * @author Slawkens
+ * @copyright 2017 MyAAC
+ * @version 0.6.0
+ * @link http://my-aac.org
+ */
+defined('MYAAC') or die('Direct access not allowed!');
+
+$save = isset($_REQUEST['save']) ? (int)$_REQUEST['save'] == 1 : false;
+if($save) {
+ if (Forum::isModerator()) {
+ $id = (int)$_REQUEST['id'];
+ $board = (int)$_REQUEST['section'];
+ $post = $db->query("SELECT `id`, `first_post`, `section` FROM `" . TABLE_PREFIX . "forum` WHERE `id` = " . $id . " LIMIT 1")->fetch();
+ if ($post['id'] == $id) {
+ if ($post['id'] == $post['first_post']) {
+ $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `section` = " . $board . " WHERE `id` = " . $post['id'] . "") or die(mysql_error());
+ $nPost = $db->query('SELECT `section` FROM `' . TABLE_PREFIX . 'forum` WHERE `id` = \'' . $id . '\' LIMIT 1;')->fetch();
+ header('Location: ' . getForumBoardLink($nPost['section']));
+ }
+ } else
+ echo 'Post with ID ' . $id . ' does not exist.';
+ } else
+ echo 'You are not logged in or you are not moderator.';
+}
+else {
+ if (Forum::isModerator()) {
+ $id = (int)$_REQUEST['id'];
+ $post = $db->query("SELECT `id`, `section`, `first_post`, `post_topic`, `author_guid` FROM `" . TABLE_PREFIX . "forum` WHERE `id` = " . $id . " LIMIT 1")->fetch();
+ $name = $db->query("SELECT `name` FROM `players` WHERE `id` = " . $post['author_guid'] . " ")->fetch();
+ if ($post['id'] == $id) {
+ if ($post['id'] == $post['first_post']) {
+ echo $twig->render('forum.move_thread.html.twig', array(
+ 'thread' => $post['post_topic'],
+ 'author' => $name[0],
+ 'board' => $sections[$post['section']]['name'],
+ 'post_id' => $post['id'],
+ 'sections' => $sections,
+ 'section_link' => getForumBoardLink($post['section']),
+ ));
+ }
+ } else
+ echo 'Post with ID ' . $id . ' does not exist.';
+ } else
+ echo 'You are not logged in or you are not moderator.';
+}
+?>
\ No newline at end of file
diff --git a/system/pages/forum/new_post.php b/system/pages/forum/new_post.php
new file mode 100644
index 00000000..f47bed5f
--- /dev/null
+++ b/system/pages/forum/new_post.php
@@ -0,0 +1,125 @@
+
+ * @author Slawkens
+ * @copyright 2017 MyAAC
+ * @version 0.6.0
+ * @link http://my-aac.org
+ */
+defined('MYAAC') or die('Direct access not allowed!');
+
+if(Forum::canPost($account_logged))
+{
+ $players_from_account = $db->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll();
+ $thread_id = (int) $_REQUEST['thread_id'];
+ $thread = $db->query("SELECT `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`section` FROM `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`id` = ".(int) $thread_id." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." LIMIT 1")->fetch();
+ echo 'Boards >> '.$sections[$thread['section']]['name'].' >> '.$thread['post_topic'].' >> Post new reply '.$thread['post_topic'].' ';
+ if(isset($thread['id']))
+ {
+ $quote = isset($_REQUEST['quote']) ? (int) $_REQUEST['quote'] : NULL;
+ $text = isset($_REQUEST['text']) ? stripslashes(trim($_REQUEST['text'])) : NULL;
+ $char_id = (int) (isset($_REQUEST['char_id']) ? $_REQUEST['char_id'] : 0);
+ $post_topic = isset($_REQUEST['topic']) ? stripslashes(trim($_REQUEST['topic'])) : '';
+ $smile = (int) (isset($_REQUEST['smile']) ? $_REQUEST['smile'] : 0);
+ $saved = false;
+ if(isset($_REQUEST['quote']))
+ {
+ $quoted_post = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`id` = ".(int) $quote)->fetchAll();
+ if(isset($quoted_post[0]['name']))
+ $text = '[i]Originally posted by '.$quoted_post[0]['name'].' on '.date('d.m.y H:i:s', $quoted_post[0]['post_date']).':[/i][quote]'.$quoted_post[0]['post_text'].'[/quote]';
+ }
+ elseif(isset($_REQUEST['save']))
+ {
+ $lenght = 0;
+ for($i = 0; $i < strlen($text); $i++)
+ {
+ if(ord($text[$i]) >= 33 && ord($text[$i]) <= 126)
+ $lenght++;
+ }
+ if($lenght < 1 || strlen($text) > 15000)
+ $errors[] = 'Too short or too long post (short: '.$lenght.' long: '.strlen($text).' letters). Minimum 1 letter, maximum 15000 letters.';
+ if($char_id == 0)
+ $errors[] = 'Please select a character.';
+ $player_on_account = false;
+ if(count($errors) == 0)
+ {
+ foreach($players_from_account as $player)
+ if($char_id == $player['id'])
+ $player_on_account = true;
+ if(!$player_on_account)
+ $errors[] = 'Player with selected ID '.$char_id.' doesn\'t exist or isn\'t on your account';
+ }
+ if(count($errors) == 0)
+ {
+ $last_post = 0;
+ $query = $db->query('SELECT post_date FROM ' . TABLE_PREFIX . 'forum ORDER BY post_date DESC LIMIT 1');
+ if($query->rowCount() > 0)
+ {
+ $query = $query->fetch();
+ $last_post = $query['post_date'];
+ }
+ if($last_post+$config['forum_post_interval']-time() > 0 && !Forum::isModerator())
+ $errors[] = 'You can post one time per '.$config['forum_post_interval'].' seconds. Next post after '.($last_post+$config['forum_post_interval']-time()).' second(s).';
+ }
+ if(count($errors) == 0)
+ {
+ $saved = true;
+ $db->query("INSERT INTO `" . TABLE_PREFIX . "forum` (`id` ,`first_post` ,`last_post` ,`section` ,`replies` ,`views` ,`author_aid` ,`author_guid` ,`post_text` ,`post_topic` ,`post_smile` ,`post_date` ,`last_edit_aid` ,`edit_date`, `post_ip`) VALUES (NULL, '".$thread['id']."', '0', '".$thread['section']."', '0', '0', '".$account_logged->getId()."', '".(int) $char_id."', ".$db->quote($text).", ".$db->quote($post_topic).", '".(int) $smile."', '".time()."', '0', '0', '".$_SERVER['REMOTE_ADDR']."')");
+ $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `replies`=`replies`+1, `last_post`=".time()." WHERE `id` = ".(int) $thread_id);
+ $post_page = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`post_date` <= ".time()." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['id'])->fetch();
+ $_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
+ header('Location: ' . getForumThreadLink($thread_id, $_page));
+ echo ' Thank you for posting.GO BACK TO LAST THREAD ';
+ }
+ }
+ if(!$saved)
+ {
+ if(!empty($errors))
+ echo $twig->render('error_box.html.twig', array('errors' => $errors));
+
+ echo '
+
+
+
+
+ ';
+ $threads = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_smile` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." ORDER BY `" . TABLE_PREFIX . "forum`.`post_date` DESC LIMIT 10")->fetchAll();
+ echo 'Last 5 posts from thread: '.$thread['post_topic'].' ';
+ foreach($threads as $thread)
+ {
+ echo ''.$thread['name'].' '.showPost($thread['post_topic'], $thread['post_text'], $thread['post_smile']).' ';
+ }
+ echo '
';
+ }
+ }
+ else
+ echo 'Thread with ID '.$thread_id.' doesn\'t exist.';
+}
+else
+ echo "Your account is banned, deleted or you don't have any player with level " . $config['forum_level_required'] . " on your account. You can't post.";
+
+?>
\ No newline at end of file
diff --git a/system/pages/forum/new_thread.php b/system/pages/forum/new_thread.php
new file mode 100644
index 00000000..4747de41
--- /dev/null
+++ b/system/pages/forum/new_thread.php
@@ -0,0 +1,102 @@
+
+ * @author Slawkens
+ * @copyright 2017 MyAAC
+ * @version 0.6.0
+ * @link http://my-aac.org
+ */
+defined('MYAAC') or die('Direct access not allowed!');
+
+if(Forum::canPost($account_logged))
+{
+ $players_from_account = $db->query('SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = '.(int) $account_logged->getId())->fetchAll();
+ $section_id = isset($_REQUEST['section_id']) ? $_REQUEST['section_id'] : null;
+ if($section_id !== null) {
+ echo 'Boards >> ' . $sections[$section_id]['name'] . ' >> Post new thread ';
+ if (isset($sections[$section_id]['name'])) {
+ if ($sections[$section_id]['closed'] && !Forum::isModerator())
+ $errors[] = 'You cannot create topic on this board.';
+
+ $quote = (int)(isset($_REQUEST['quote']) ? $_REQUEST['quote'] : 0);
+ $text = isset($_REQUEST['text']) ? stripslashes($_REQUEST['text']) : '';
+ $char_id = (int)(isset($_REQUEST['char_id']) ? $_REQUEST['char_id'] : 0);
+ $post_topic = isset($_REQUEST['topic']) ? stripslashes($_REQUEST['topic']) : '';
+ $smile = (int)(isset($_REQUEST['smile']) ? $_REQUEST['smile'] : 0);
+ $saved = false;
+ if (isset($_REQUEST['save'])) {
+ $errors = array();
+
+ $lenght = 0;
+ for ($i = 0; $i < strlen($post_topic); $i++) {
+ if (ord($post_topic[$i]) >= 33 && ord($post_topic[$i]) <= 126)
+ $lenght++;
+ }
+ if ($lenght < 1 || strlen($post_topic) > 60)
+ $errors[] = 'Too short or too long topic (short: ' . $lenght . ' long: ' . strlen($post_topic) . ' letters). Minimum 1 letter, maximum 60 letters.';
+ $lenght = 0;
+ for ($i = 0; $i < strlen($text); $i++) {
+ if (ord($text[$i]) >= 33 && ord($text[$i]) <= 126)
+ $lenght++;
+ }
+ if ($lenght < 1 || strlen($text) > 15000)
+ $errors[] = 'Too short or too long post (short: ' . $lenght . ' long: ' . strlen($text) . ' letters). Minimum 1 letter, maximum 15000 letters.';
+
+ if ($char_id == 0)
+ $errors[] = 'Please select a character.';
+ $player_on_account = false;
+
+ if (count($errors) == 0) {
+ foreach ($players_from_account as $player)
+ if ($char_id == $player['id'])
+ $player_on_account = true;
+ if (!$player_on_account)
+ $errors[] = 'Player with selected ID ' . $char_id . ' doesn\'t exist or isn\'t on your account';
+ }
+
+ if (count($errors) == 0) {
+ $last_post = 0;
+ $query = $db->query('SELECT `post_date` FROM `' . TABLE_PREFIX . 'forum` ORDER BY `post_date` DESC LIMIT 1');
+ if ($query->rowCount() > 0) {
+ $query = $query->fetch();
+ $last_post = $query['post_date'];
+ }
+ if ($last_post + $config['forum_post_interval'] - time() > 0 && !Forum::isModerator())
+ $errors[] = 'You can post one time per ' . $config['forum_post_interval'] . ' seconds. Next post after ' . ($last_post + $config['forum_post_interval'] - time()) . ' second(s).';
+ }
+ if (count($errors) == 0) {
+ $saved = true;
+ $db->query("INSERT INTO `" . TABLE_PREFIX . "forum` (`first_post` ,`last_post` ,`section` ,`replies` ,`views` ,`author_aid` ,`author_guid` ,`post_text` ,`post_topic` ,`post_smile` ,`post_date` ,`last_edit_aid` ,`edit_date`, `post_ip`) VALUES ('0', '" . time() . "', '" . (int)$section_id . "', '0', '0', '" . $account_logged->getId() . "', '" . (int)$char_id . "', " . $db->quote($text) . ", " . $db->quote($post_topic) . ", '" . (int)$smile . "', '" . time() . "', '0', '0', '" . $_SERVER['REMOTE_ADDR'] . "')");
+ $thread_id = $db->lastInsertId();
+ $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `first_post`=" . (int)$thread_id . " WHERE `id` = " . (int)$thread_id);
+ header('Location: ' . getForumThreadLink($thread_id));
+ echo ' Thank you for posting.GO BACK TO LAST THREAD ';
+ }
+ }
+ if (!$saved) {
+ if (!empty($errors))
+ echo $twig->render('error_box.html.twig', array('errors' => $errors));
+
+ echo $twig->render('forum.new_thread.html.twig', array(
+ 'section_id' => $section_id,
+ 'players' => $players_from_account,
+ 'post_player_id' => $char_id,
+ 'post_thread' => $post_topic,
+ 'text' => $text,
+ 'smiles_enabled' => $smile > 0
+ ));
+ }
+ }
+ else
+ echo 'Board with ID ' . $board_id . ' doesn\'t exist.';
+ }
+ else
+ echo 'Please enter section_id.';
+}
+else
+ echo 'Your account is banned, deleted or you don\'t have any player with level '.$config['forum_level_required'].' on your account. You can\'t post.';
+
+?>
\ No newline at end of file
diff --git a/system/pages/forum/remove_post.php b/system/pages/forum/remove_post.php
new file mode 100644
index 00000000..79fb7b19
--- /dev/null
+++ b/system/pages/forum/remove_post.php
@@ -0,0 +1,37 @@
+
+ * @author Slawkens
+ * @copyright 2017 MyAAC
+ * @version 0.6.0
+ * @link http://my-aac.org
+ */
+defined('MYAAC') or die('Direct access not allowed!');
+
+if(Forum::isModerator())
+{
+ $id = (int) $_REQUEST['id'];
+ $post = $db->query("SELECT `id`, `first_post`, `section` FROM `" . TABLE_PREFIX . "forum` WHERE `id` = ".$id." LIMIT 1")->fetch();
+ if($post['id'] == $id)
+ {
+ if($post['id'] == $post['first_post'])
+ {
+ $db->query("DELETE FROM `" . TABLE_PREFIX . "forum` WHERE `first_post` = ".$post['id']);
+ header('Location: ' . getForumBoardLink($post['section']));
+ }
+ else
+ {
+ $post_page = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`id` < ".$id." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $post['first_post'])->fetch();
+ $_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
+ $db->query("DELETE FROM `" . TABLE_PREFIX . "forum` WHERE `id` = ".$post['id']);
+ header('Location: ' . getForumThreadLink($post['first_post'], (int) $_page));
+ }
+ }
+ else
+ echo 'Post with ID ' . $id . ' does not exist.';
+}
+else
+ echo 'You are not logged in or you are not moderator.';
\ No newline at end of file
diff --git a/system/pages/forum/show_board.php b/system/pages/forum/show_board.php
new file mode 100644
index 00000000..fd7ffc6f
--- /dev/null
+++ b/system/pages/forum/show_board.php
@@ -0,0 +1,77 @@
+
+ * @author Slawkens
+ * @copyright 2017 MyAAC
+ * @version 0.6.0
+ * @link http://my-aac.org
+ */
+defined('MYAAC') or die('Direct access not allowed!');
+
+$links_to_pages = '';
+$section_id = (int) $_REQUEST['id'];
+$_page = (int) (isset($_REQUEST['page']) ? $_REQUEST['page'] : 0);
+$threads_count = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS threads_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`section` = ".(int) $section_id." AND `" . TABLE_PREFIX . "forum`.`first_post` = `" . TABLE_PREFIX . "forum`.`id`")->fetch();
+for($i = 0; $i < $threads_count['threads_count'] / $config['forum_threads_per_page']; $i++)
+{
+ if($i != $_page)
+ $links_to_pages .= ''.($i + 1).' ';
+ else
+ $links_to_pages .= ''.($i + 1).' ';
+}
+echo 'Boards >> '.$sections[$section_id]['name'].' ';
+if(!$sections[$section_id]['closed'] || Forum::isModerator())
+{
+ echo '
+ ';
+}
+
+echo ' Page: '.$links_to_pages.' ';
+$last_threads = $db->query("SELECT `players`.`id` as `player_id`, `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`last_post`, `" . TABLE_PREFIX . "forum`.`replies`, `" . TABLE_PREFIX . "forum`.`views`, `" . TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`section` = ".(int) $section_id." AND `" . TABLE_PREFIX . "forum`.`first_post` = `" . TABLE_PREFIX . "forum`.`id` ORDER BY `" . TABLE_PREFIX . "forum`.`last_post` DESC LIMIT ".$config['forum_threads_per_page']." OFFSET ".($_page * $config['forum_threads_per_page']))->fetchAll();
+if(isset($last_threads[0]))
+{
+ echo 'Thread Thread Starter Replies Views Last Post ';
+
+ $player = new OTS_Player();
+ foreach($last_threads as $thread)
+ {
+ echo '';
+ if(Forum::isModerator())
+ {
+ echo '[MOVE] ';
+ echo '[REMOVE] ';
+ }
+
+ $player->load($thread['player_id']);
+ if(!$player->isLoaded()) {
+ error('Forum error: Player not loaded.');
+ die();
+ }
+
+ $player_account = $player->getAccount();
+ $canEditForum = $player_account->hasFlag(FLAG_CONTENT_FORUM) || $player_account->isAdmin();
+
+ echo ''.($canEditForum ? $thread['post_topic'] : htmlspecialchars($thread['post_topic'])) . ' '.($canEditForum ? substr(strip_tags($thread['post_text']), 0, 50) : htmlspecialchars(substr($thread['post_text'], 0, 50))).'... ' . getPlayerLink($thread['name']) . ' '.(int) $thread['replies'].' '.(int) $thread['views'].' ';
+ if($thread['last_post'] > 0)
+ {
+ $last_post = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['id']." AND `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` ORDER BY `post_date` DESC LIMIT 1")->fetch();
+ if(isset($last_post['name']))
+ echo date('d.m.y H:i:s', $last_post['post_date']).' by ' . getPlayerLink($last_post['name']);
+ else
+ echo 'No posts.';
+ }
+ else
+ echo date('d.m.y H:i:s', $thread['post_date']).' by ' . getPlayerLink($thread['name']);
+ echo ' ';
+ }
+ echo '
';
+ if(!$sections[$section_id]['closed'] || Forum::isModerator())
+ echo ' ';
+}
+else
+ echo 'No threads in this board. ';
+
+?>
\ No newline at end of file
diff --git a/system/pages/forum/show_thread.php b/system/pages/forum/show_thread.php
new file mode 100644
index 00000000..3514761c
--- /dev/null
+++ b/system/pages/forum/show_thread.php
@@ -0,0 +1,85 @@
+
+ * @author Slawkens
+ * @copyright 2017 MyAAC
+ * @version 0.6.0
+ * @link http://my-aac.org
+ */
+defined('MYAAC') or die('Direct access not allowed!');
+
+$links_to_pages = '';
+$thread_id = (int) $_REQUEST['id'];
+$_page = (int) (isset($_REQUEST['page']) ? $_REQUEST['page'] : 0);
+$thread_name = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_topic` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." AND `" . TABLE_PREFIX . "forum`.`id` = `" . TABLE_PREFIX . "forum`.`first_post` AND `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` LIMIT 1")->fetch();
+if(!empty($thread_name['name']))
+{
+ $posts_count = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id)->fetch();
+ for($i = 0; $i < $posts_count['posts_count'] / $config['forum_threads_per_page']; $i++)
+ {
+ if($i != $_page)
+ $links_to_pages .= ''.($i + 1).' ';
+ else
+ $links_to_pages .= ''.($i + 1).' ';
+ }
+ $threads = $db->query("SELECT `players`.`id` as `player_id`, `players`.`name`, `players`.`account_id`, `players`.`vocation`" . (fieldExist('promotion', 'players') ? ", `players`.`promotion`" : "") . ", `players`.`level`, `" . TABLE_PREFIX . "forum`.`id`,`" . TABLE_PREFIX . "forum`.`first_post`, `" . TABLE_PREFIX . "forum`.`section`,`" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_date`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`author_aid`, `" . TABLE_PREFIX . "forum`.`author_guid`, `" . TABLE_PREFIX . "forum`.`last_edit_aid`, `" . TABLE_PREFIX . "forum`.`edit_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." ORDER BY `" . TABLE_PREFIX . "forum`.`post_date` LIMIT ".$config['forum_posts_per_page']." OFFSET ".($_page * $config['forum_posts_per_page']))->fetchAll();
+ if(isset($threads[0]['name']))
+ $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `views`=`views`+1 WHERE `id` = ".(int) $thread_id);
+ echo 'Boards >> '.$sections[$threads[0]['section']]['name'].' >> '.$thread_name['post_topic'].' ';
+ echo ' Page: '.$links_to_pages.''.htmlspecialchars($thread_name['post_topic']).' by ' . getPlayerLink($thread_name['name']) . 'Author ';
+ $player = $ots->createObject('Player');
+ foreach($threads as $thread)
+ {
+ $player->load($thread['player_id']);
+ if(!$player->isLoaded()) {
+ error('Forum error: Player not loaded.');
+ die();
+ }
+
+ echo '' . getPlayerLink($thread['name']) . 'Profession: '.$config['vocations'][$player->getVocation()].' Level: '.$thread['level'].' ';
+
+ $rank = $player->getRank();
+ if($rank->isLoaded())
+ {
+ $guild = $rank->getGuild();
+ if($guild->isLoaded())
+ echo $rank->getName().' of '.$guild->getName().' ';
+ }
+ $player_account = $player->getAccount();
+ $canEditForum = $player_account->hasFlag(FLAG_CONTENT_FORUM) || $player_account->isAdmin();
+
+ $posts = $db->query("SELECT COUNT(`id`) AS 'posts' FROM `" . TABLE_PREFIX . "forum` WHERE `author_aid`=".(int) $thread['account_id'])->fetch();
+ echo ' Posts: '.(int) $posts['posts'].' '.showPost(($canEditForum ? $thread['post_topic'] : htmlspecialchars($thread['post_topic'])), ($canEditForum ? $thread['post_text'] : htmlspecialchars($thread['post_text'])), $thread['post_smile']).'
+ '.date('d.m.y H:i:s', $thread['post_date']);
+ if($thread['edit_date'] > 0)
+ {
+ if($thread['last_edit_aid'] != $thread['author_aid'])
+ echo ' Edited by moderator';
+ else
+ echo ' Edited by '.$thread['name'];
+ echo ' on '.date('d.m.y H:i:s', $thread['edit_date']);
+ }
+ echo ' ';
+ if(Forum::isModerator())
+ if($thread['first_post'] != $thread['id'])
+ echo 'REMOVE POST ';
+ else
+ {
+ echo '[MOVE] ';
+ echo 'REMOVE THREAD ';
+ }
+ if($logged && ($thread['account_id'] == $account_logged->getId() || Forum::isModerator()))
+ echo 'EDIT POST ';
+ if($logged)
+ echo 'Quote ';
+ echo ' ';
+ }
+ echo '
';
+}
+else
+ echo 'Thread with this ID does not exits.';
+
+?>
\ No newline at end of file
diff --git a/system/templates/forum.move_thread.html.twig b/system/templates/forum.move_thread.html.twig
index 12ece24c..45951668 100644
--- a/system/templates/forum.move_thread.html.twig
+++ b/system/templates/forum.move_thread.html.twig
@@ -8,9 +8,9 @@
-
-
-
+
+
+
THREAD: {{ thread }}
AUTHOR: {{ author }}