diff --git a/config.php b/config.php
index f6298198..c9abe001 100644
--- a/config.php
+++ b/config.php
@@ -169,15 +169,6 @@ $config = array(
// support/system
'bug_report' => true, // this configurable has no effect, its always enabled
- // forum
- 'forum' => 'site', // link to the server forum, set to "site" if you want to use build in forum system, otherwise leave empty if you aren't going to use any forum
- 'forum_level_required' => 0, // level required to post, 0 to disable
- 'forum_post_interval' => 30, // in seconds
- 'forum_posts_per_page' => 20,
- 'forum_threads_per_page' => 20,
- // uncomment to force use table for forum
- //'forum_table_prefix' => 'z_', // what forum mysql table to use, z_ (for gesior old forum) or myaac_ (for myaac)
-
// last kills
'last_kills_limit' => 50, // max. number of deaths shown on the last kills page
diff --git a/index.php b/index.php
index 34f42069..1e8b2b32 100644
--- a/index.php
+++ b/index.php
@@ -176,8 +176,9 @@ if(setting('core.backward_support')) {
$config['site']['serverinfo_page'] = true;
$config['site']['screenshot_page'] = true;
- if($config['forum'] != '')
- $config['forum_link'] = (strtolower($config['forum']) === 'site' ? getLink('forum') : $config['forum']);
+ $forumSetting = setting('core.forum');
+ if($forumSetting != '')
+ $config['forum_link'] = (strtolower($forumSetting) === 'site' ? getLink('forum') : $forumSetting);
foreach($status as $key => $value)
$config['status']['serverStatus_' . $key] = $value;
diff --git a/system/compat/config.php b/system/compat/config.php
index 8deca716..0f0d8457 100644
--- a/system/compat/config.php
+++ b/system/compat/config.php
@@ -32,6 +32,7 @@ $deprecatedConfig = [
'team_display_world' => 'team_world',
'team_display_lastlogin' => 'team_lastlogin',
'multiworld',
+ 'forum',
];
foreach ($deprecatedConfig as $key => $value) {
diff --git a/system/libs/forum.php b/system/libs/forum.php
index 4922a9c3..c7f303f7 100644
--- a/system/libs/forum.php
+++ b/system/libs/forum.php
@@ -10,7 +10,7 @@
*/
defined('MYAAC') or die('Direct access not allowed!');
-$configForumTablePrefix = config('forum_table_prefix');
+$configForumTablePrefix = setting('core.forum_table_prefix');
if(null !== $configForumTablePrefix && !empty(trim($configForumTablePrefix))) {
if(!in_array($configForumTablePrefix, array('myaac_', 'z_'))) {
throw new RuntimeException('Invalid value for forum_table_prefix in config.php. Can be only: "myaac_" or "z_".');
@@ -47,7 +47,7 @@ class Forum
return
$db->query(
'SELECT `id` FROM `players` WHERE `account_id` = ' . $db->quote($account->getId()) .
- ' AND `level` >= ' . $db->quote($config['forum_level_required']) .
+ ' AND `level` >= ' . $db->quote(setting('core.forum_level_required')) .
' LIMIT 1')->rowCount() > 0;
}
diff --git a/system/pages/forum.php b/system/pages/forum.php
index 5c9688a6..e5b68ed0 100644
--- a/system/pages/forum.php
+++ b/system/pages/forum.php
@@ -10,7 +10,11 @@
*/
defined('MYAAC') or exit;
-require __DIR__ . '/forum/base.php';
+$ret = require __DIR__ . '/forum/base.php';
+if ($ret === false) {
+ return;
+}
+
require __DIR__ . '/forum/admin.php';
$errors = [];
diff --git a/system/pages/forum/base.php b/system/pages/forum/base.php
index 57ae6d17..de449692 100644
--- a/system/pages/forum/base.php
+++ b/system/pages/forum/base.php
@@ -11,22 +11,24 @@
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Forum';
-if(strtolower($config['forum']) != 'site') {
- if($config['forum'] != '') {
- header('Location: ' . $config['forum']);
+require_once LIBS . 'forum.php';
+
+$forumSetting = setting('core.forum');
+if(strtolower($forumSetting) != 'site') {
+ if($forumSetting != '') {
+ header('Location: ' . $forumSetting);
exit;
}
echo 'Forum is disabled on this site.';
- return;
+ return false;
}
if(!$logged) {
echo 'You are not logged in. Log in to post on the forum.
';
+ return false;
}
-require_once LIBS . 'forum.php';
-
$sections = array();
foreach(getForumBoards() as $section) {
$sections[$section['id']] = array(
diff --git a/system/pages/forum/edit_post.php b/system/pages/forum/edit_post.php
index 2df443a0..539ca7e0 100644
--- a/system/pages/forum/edit_post.php
+++ b/system/pages/forum/edit_post.php
@@ -10,7 +10,10 @@
*/
defined('MYAAC') or die('Direct access not allowed!');
-require __DIR__ . '/base.php';
+$ret = require __DIR__ . '/base.php';
+if ($ret === false) {
+ return;
+}
if(Forum::canPost($account_logged))
{
@@ -75,7 +78,7 @@ if(Forum::canPost($account_logged))
$char_id = $thread['author_guid'];
$db->query("UPDATE `" . FORUM_TABLE_PREFIX . "forum` SET `author_guid` = ".(int) $char_id.", `post_text` = ".$db->quote($text).", `post_topic` = ".$db->quote($post_topic).", `post_smile` = ".$smile.", `post_html` = ".$html.", `last_edit_aid` = ".(int) $account_logged->getId().",`edit_date` = ".time()." WHERE `id` = ".(int) $thread['id']);
$post_page = $db->query("SELECT COUNT(`" . FORUM_TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . FORUM_TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . FORUM_TABLE_PREFIX . "forum`.`author_guid` AND `" . FORUM_TABLE_PREFIX . "forum`.`post_date` <= ".$thread['post_date']." AND `" . FORUM_TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['first_post'])->fetch();
- $_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
+ $_page = (int) ceil($post_page['posts_count'] / setting('core.forum_threads_per_page')) - 1;
header('Location: ' . getForumThreadLink($thread['first_post'], $_page));
echo '
Thank you for editing post.
GO BACK TO LAST THREAD';
}
@@ -117,6 +120,6 @@ if(Forum::canPost($account_logged))
}
}
else {
- $errors[] = "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.";
+ $errors[] = "Your account is banned, deleted or you don't have any player with level " . setting('core.forum_level_required') . " on your account. You can't post.";
displayErrorBoxWithBackButton($errors, getLink('forum'));
}
diff --git a/system/pages/forum/move_thread.php b/system/pages/forum/move_thread.php
index 3c01a13e..45d14683 100644
--- a/system/pages/forum/move_thread.php
+++ b/system/pages/forum/move_thread.php
@@ -10,7 +10,10 @@
*/
defined('MYAAC') or die('Direct access not allowed!');
-require __DIR__ . '/base.php';
+$ret = require __DIR__ . '/base.php';
+if ($ret === false) {
+ return;
+}
if(!Forum::isModerator()) {
echo 'You are not logged in or you are not moderator.';
diff --git a/system/pages/forum/new_post.php b/system/pages/forum/new_post.php
index d4b605c6..dd027984 100644
--- a/system/pages/forum/new_post.php
+++ b/system/pages/forum/new_post.php
@@ -10,7 +10,10 @@
*/
defined('MYAAC') or die('Direct access not allowed!');
-require __DIR__ . '/base.php';
+$ret = require __DIR__ . '/base.php';
+if ($ret === false) {
+ return;
+}
if(!$logged) {
$extra_url = '';
@@ -81,8 +84,8 @@ if(Forum::canPost($account_logged)) {
$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($last_post+setting('core.forum_post_interval')-time() > 0 && !Forum::isModerator())
+ $errors[] = 'You can post one time per ' . setting('core.forum_post_interval') . ' seconds. Next post after '.($last_post + setting('core.forum_post_interval')-time()).' second(s).';
}
if(count($errors) == 0) {
@@ -90,7 +93,7 @@ if(Forum::canPost($account_logged)) {
Forum::add_post($thread['id'], $thread['section'], $account_logged->getId(), $char_id, $text, $post_topic, $smile, $html);
$db->query("UPDATE `" . FORUM_TABLE_PREFIX . "forum` SET `replies`=`replies`+1, `last_post`=".time()." WHERE `id` = ".$thread_id);
$post_page = $db->query("SELECT COUNT(`" . FORUM_TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . FORUM_TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . FORUM_TABLE_PREFIX . "forum`.`author_guid` AND `" . FORUM_TABLE_PREFIX . "forum`.`post_date` <= ".time()." AND `" . FORUM_TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['id'])->fetch();
- $_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
+ $_page = (int) ceil($post_page['posts_count'] / setting('core.forum_threads_per_page')) - 1;
header('Location: ' . getForumThreadLink($thread_id, $_page));
echo '
Thank you for posting.
GO BACK TO LAST THREAD';
}
@@ -131,7 +134,7 @@ if(Forum::canPost($account_logged)) {
}
}
else {
- $errors[] = "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.";
+ $errors[] = "Your account is banned, deleted or you don't have any player with level " . setting('core.forum_level_required') . " on your account. You can't post.";
displayErrorBoxWithBackButton($errors, getLink('forum'));
}
diff --git a/system/pages/forum/new_thread.php b/system/pages/forum/new_thread.php
index b864c448..9dfe82a1 100644
--- a/system/pages/forum/new_thread.php
+++ b/system/pages/forum/new_thread.php
@@ -10,7 +10,10 @@
*/
defined('MYAAC') or die('Direct access not allowed!');
-require __DIR__ . '/base.php';
+$ret = require __DIR__ . '/base.php';
+if ($ret === false) {
+ return;
+}
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();
@@ -67,8 +70,8 @@ if(Forum::canPost($account_logged)) {
$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 ($last_post + setting('core.forum_post_interval') - time() > 0 && !Forum::isModerator())
+ $errors[] = 'You can post one time per ' . setting('core.forum_post_interval') . ' seconds. Next post after ' . ($last_post + setting('core.forum_post_interval') - time()) . ' second(s).';
}
if (count($errors) == 0) {
@@ -113,6 +116,6 @@ if(Forum::canPost($account_logged)) {
}
}
else {
- $errors[] = '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.';
+ $errors[] = 'Your account is banned, deleted or you don\'t have any player with level '.setting('core.forum_level_required').' on your account. You can\'t post.';
displayErrorBoxWithBackButton($errors, getLink('forum'));
}
diff --git a/system/pages/forum/remove_post.php b/system/pages/forum/remove_post.php
index a1e13338..c3f2d46f 100644
--- a/system/pages/forum/remove_post.php
+++ b/system/pages/forum/remove_post.php
@@ -10,7 +10,10 @@
*/
defined('MYAAC') or die('Direct access not allowed!');
-require __DIR__ . '/base.php';
+$ret = require __DIR__ . '/base.php';
+if ($ret === false) {
+ return;
+}
if(Forum::isModerator()) {
$id = (int) $_REQUEST['id'];
@@ -23,7 +26,7 @@ if(Forum::isModerator()) {
}
else {
$post_page = $db->query("SELECT COUNT(`" . FORUM_TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . FORUM_TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . FORUM_TABLE_PREFIX . "forum`.`author_guid` AND `" . FORUM_TABLE_PREFIX . "forum`.`id` < ".$id." AND `" . FORUM_TABLE_PREFIX . "forum`.`first_post` = ".(int) $post['first_post'])->fetch();
- $_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
+ $_page = (int) ceil($post_page['posts_count'] / setting('core.forum_threads_per_page')) - 1;
$db->query("DELETE FROM `" . FORUM_TABLE_PREFIX . "forum` WHERE `id` = ".$post['id']);
header('Location: ' . getForumThreadLink($post['first_post'], (int) $_page));
}
diff --git a/system/pages/forum/show_board.php b/system/pages/forum/show_board.php
index d3dcd0d5..4e37984c 100644
--- a/system/pages/forum/show_board.php
+++ b/system/pages/forum/show_board.php
@@ -10,7 +10,10 @@
*/
defined('MYAAC') or die('Direct access not allowed!');
-require __DIR__ . '/base.php';
+$ret = require __DIR__ . '/base.php';
+if ($ret === false) {
+ return;
+}
$links_to_pages = '';
$section_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : null;
@@ -29,7 +32,7 @@ if(!Forum::hasAccess($section_id)) {
$_page = (int) (isset($_REQUEST['page']) ? $_REQUEST['page'] : 0);
$threads_count = $db->query("SELECT COUNT(`" . FORUM_TABLE_PREFIX . "forum`.`id`) AS threads_count FROM `players`, `" . FORUM_TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . FORUM_TABLE_PREFIX . "forum`.`author_guid` AND `" . FORUM_TABLE_PREFIX . "forum`.`section` = ".(int) $section_id." AND `" . FORUM_TABLE_PREFIX . "forum`.`first_post` = `" . FORUM_TABLE_PREFIX . "forum`.`id`")->fetch();
-for($i = 0; $i < $threads_count['threads_count'] / $config['forum_threads_per_page']; $i++) {
+for($i = 0; $i < $threads_count['threads_count'] / setting('core.forum_threads_per_page'); $i++) {
if($i != $_page)
$links_to_pages .= ''.($i + 1).' ';
else
@@ -44,7 +47,7 @@ if(!$sections[$section_id]['closed'] || Forum::isModerator()) {
}
echo '
Page: '.$links_to_pages.'
';
-$last_threads = $db->query("SELECT `players`.`id` as `player_id`, `players`.`name`, `" . FORUM_TABLE_PREFIX . "forum`.`post_text`, `" . FORUM_TABLE_PREFIX . "forum`.`post_topic`, `" . FORUM_TABLE_PREFIX . "forum`.`id`, `" . FORUM_TABLE_PREFIX . "forum`.`last_post`, `" . FORUM_TABLE_PREFIX . "forum`.`replies`, `" . FORUM_TABLE_PREFIX . "forum`.`views`, `" . FORUM_TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . FORUM_TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . FORUM_TABLE_PREFIX . "forum`.`author_guid` AND `" . FORUM_TABLE_PREFIX . "forum`.`section` = ".$section_id." AND `" . FORUM_TABLE_PREFIX . "forum`.`first_post` = `" . FORUM_TABLE_PREFIX . "forum`.`id` ORDER BY `" . FORUM_TABLE_PREFIX . "forum`.`last_post` DESC LIMIT ".$config['forum_threads_per_page']." OFFSET ".($_page * $config['forum_threads_per_page']))->fetchAll();
+$last_threads = $db->query("SELECT `players`.`id` as `player_id`, `players`.`name`, `" . FORUM_TABLE_PREFIX . "forum`.`post_text`, `" . FORUM_TABLE_PREFIX . "forum`.`post_topic`, `" . FORUM_TABLE_PREFIX . "forum`.`id`, `" . FORUM_TABLE_PREFIX . "forum`.`last_post`, `" . FORUM_TABLE_PREFIX . "forum`.`replies`, `" . FORUM_TABLE_PREFIX . "forum`.`views`, `" . FORUM_TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . FORUM_TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . FORUM_TABLE_PREFIX . "forum`.`author_guid` AND `" . FORUM_TABLE_PREFIX . "forum`.`section` = ".$section_id." AND `" . FORUM_TABLE_PREFIX . "forum`.`first_post` = `" . FORUM_TABLE_PREFIX . "forum`.`id` ORDER BY `" . FORUM_TABLE_PREFIX . "forum`.`last_post` DESC LIMIT ".setting('core.forum_threads_per_page')." OFFSET ".($_page * setting('core.forum_threads_per_page')))->fetchAll();
if(isset($last_threads[0])) {
echo '