diff --git a/admin/pages/accounts.php b/admin/pages/accounts.php
index 7f47b3d0..66a60558 100644
--- a/admin/pages/accounts.php
+++ b/admin/pages/accounts.php
@@ -16,7 +16,7 @@ $title = 'Account editor';
$admin_base = ADMIN_URL . '?p=accounts';
$use_datatable = true;
-if ($config['account_country'])
+if (setting('core.account_country'))
require SYSTEM . 'countries.conf.php';
$nameOrNumberColumn = 'name';
@@ -30,7 +30,7 @@ $hasPointsColumn = $db->hasColumn('accounts', 'premium_points');
$hasTypeColumn = $db->hasColumn('accounts', 'type');
$hasGroupColumn = $db->hasColumn('accounts', 'group_id');
-if ($config['account_country']) {
+if (setting('core.account_country')) {
$countries = array();
foreach (array('pl', 'se', 'br', 'us', 'gb') as $c)
$countries[$c] = $config['countries'][$c];
diff --git a/admin/pages/mailer.php b/admin/pages/mailer.php
index 7d12f14b..732b7461 100644
--- a/admin/pages/mailer.php
+++ b/admin/pages/mailer.php
@@ -54,7 +54,7 @@ if (!empty($mail_content) && !empty($mail_subject) && empty($mail_to)) {
$failed = 0;
$add = '';
- if (config('account_mail_verify')) {
+ if (setting('core.account_mail_verify')) {
note('Note: Sending only to users with verified E-Mail.');
$add = ' AND `email_verified` = 1';
}
diff --git a/admin/pages/players.php b/admin/pages/players.php
index 48b0f1f5..b409c15e 100644
--- a/admin/pages/players.php
+++ b/admin/pages/players.php
@@ -569,7 +569,7 @@ else if (isset($_REQUEST['search'])) {
- getLookType() . ($hasLookAddons ? '&addons=' . $player->getLookAddons() : '') . '&head=' . $player->getLookHead() . '&body=' . $player->getLookBody() . '&legs=' . $player->getLookLegs() . '&feet=' . $player->getLookFeet(); ?>
+ getLookType() . ($hasLookAddons ? '&addons=' . $player->getLookAddons() : '') . '&head=' . $player->getLookHead() . '&body=' . $player->getLookBody() . '&legs=' . $player->getLookLegs() . '&feet=' . $player->getLookFeet(); ?>
@@ -858,7 +858,7 @@ else if (isset($_REQUEST['search'])) {
look_addons = '&addons=' + $('#look_addons').val();
- $("#player_outfit").attr("src", '= $config['outfit_images_url']; ?>?id=' + look_type + look_addons + '&head=' + look_head + '&body=' + look_body + '&legs=' + look_legs + '&feet=' + look_feet);
+ $("#player_outfit").attr("src", '= setting('core.outfit_images_url'); ?>?id=' + look_type + look_addons + '&head=' + look_head + '&body=' + look_body + '&legs=' + look_legs + '&feet=' + look_feet);
}
diff --git a/plugins/account-create-hint/hint.html.twig b/plugins/account-create-hint/hint.html.twig
index 5c31dfb1..ffc85434 100644
--- a/plugins/account-create-hint/hint.html.twig
+++ b/plugins/account-create-hint/hint.html.twig
@@ -1,3 +1,3 @@
To play on {{ config.lua.serverName }} you need an account.
-All you have to do to create your new account is to enter an account {% if constant('USE_ACCOUNT_NAME') %}name{% else %}number{% endif %}, password{% if config.account_country %}, country{% endif %} and your email address.
+All you have to do to create your new account is to enter an account {% if constant('USE_ACCOUNT_NAME') %}name{% else %}number{% endif %}, password{% if setting('core.account_country') %}, country{% endif %} and your email address.
Also you have to agree to the terms presented below. If you have done so, your account {% if constant('USE_ACCOUNT_NAME') %}name{% else %}number{% endif %} will be shown on the following page and your account password will be sent to your email address along with further instructions. If you do not receive the email with your password, please check your spam filter.
diff --git a/plugins/email-confirmed-reward/reward.php b/plugins/email-confirmed-reward/reward.php
index 107ab8d7..11af5b34 100644
--- a/plugins/email-confirmed-reward/reward.php
+++ b/plugins/email-confirmed-reward/reward.php
@@ -1,33 +1,37 @@
hasColumn('accounts', 'coins');
-if ($reward['coins'] > 0 && $hasCoinsColumn) {
- log_append('email_confirm_error.log', 'accounts.coins column does not exist.');
+$rewardCoins = setting('core.account_mail_confirmed_reward_coins');
+if ($rewardCoins > 0 && !$hasCoinsColumn) {
+ log_append('error.log', 'email_confirm: accounts.coins column does not exist.');
}
if (!isset($account) || !$account->isLoaded()) {
- log_append('email_confirm_error.log', 'Account not loaded.');
return;
}
-if ($reward['premium_points'] > 0) {
- $account->setCustomField('premium_points', (int)$account->getCustomField('premium_points') + $reward['premium_points']);
+$rewardMessage = 'You received %d %s for confirming your E-Mail address.';
- success(sprintf($reward['message'], $reward['premium_points'], 'premium points'));
+$rewardPremiumPoints = setting('core.account_mail_confirmed_reward_premium_points');
+if ($rewardPremiumPoints > 0) {
+ $account->setCustomField('premium_points', (int)$account->getCustomField('premium_points') + $rewardPremiumPoints);
+
+ success(sprintf($rewardMessage, $rewardPremiumPoints, 'premium points'));
}
-if ($reward['coins'] > 0 && $hasCoinsColumn) {
- $account->setCustomField('coins', (int)$account->getCustomField('coins') + $reward['coins']);
+if ($rewardCoins > 0 && $hasCoinsColumn) {
+ $account->setCustomField('coins', (int)$account->getCustomField('coins') + $rewardCoins);
- success(sprintf($reward['message'], $reward['coins'], 'coins'));
+ success(sprintf($rewardMessage, $rewardCoins, 'coins'));
}
-if ($reward['premium_days'] > 0) {
- $account->setPremDays($account->getPremDays() + $reward['premium_days']);
+$rewardPremiumDays = setting('core.account_mail_confirmed_reward_premium_days');
+if ($rewardPremiumDays > 0) {
+ $account->setPremDays($account->getPremDays() + $rewardPremiumDays);
$account->save();
- success(sprintf($reward['message'], $reward['premium_days'], 'premium days'));
+ success(sprintf($rewardMessage, $rewardPremiumDays, 'premium days'));
}
diff --git a/system/compat/config.php b/system/compat/config.php
index b6cf29f7..9d58f4d6 100644
--- a/system/compat/config.php
+++ b/system/compat/config.php
@@ -68,10 +68,12 @@ $deprecatedConfig = [
'status_ip',
'status_port',
'mail_enabled',
+ 'mail_address',
'account_login_by_email',
'account_login_by_email_fallback',
'account_mail_verify',
'account_mail_unique',
+ 'account_mail_change',
'account_premium_days',
'account_premium_points',
'account_create_character_create',
diff --git a/system/functions.php b/system/functions.php
index 70a67f32..5ea941cf 100644
--- a/system/functions.php
+++ b/system/functions.php
@@ -151,8 +151,7 @@ function getItemImage($id, $count = 1)
if($count > 1)
$file_name .= '-' . $count;
- global $config;
- return '
 . ')
';
+ return '
 . $file_name . setting('core.item_images_extension') . ')
';
}
function getItemRarity($chance) {
@@ -490,8 +489,8 @@ function template_place_holder($type): string
*/
function template_header($is_admin = false): string
{
- global $title_full, $config, $twig;
- $charset = $config['charset'] ?? 'utf-8';
+ global $title_full, $twig;
+ $charset = setting('core.charset') ?? 'utf-8';
return $twig->render('templates.header.html.twig',
[
@@ -1036,14 +1035,14 @@ function get_browser_real_ip() {
return '0';
}
function setSession($key, $data) {
- $_SESSION[config('session_prefix') . $key] = $data;
+ $_SESSION[setting('core.session_prefix') . $key] = $data;
}
function getSession($key) {
- $key = config('session_prefix') . $key;
+ $key = setting('core.session_prefix') . $key;
return isset($_SESSION[$key]) ? $_SESSION[$key] : false;
}
function unsetSession($key) {
- unset($_SESSION[config('session_prefix') . $key]);
+ unset($_SESSION[setting('core.session_prefix') . $key]);
}
function getTopPlayers($limit = 5) {
@@ -1270,7 +1269,7 @@ function getCustomPage($name, &$success): string
set_error_handler('error_handler');
global $config;
- if($config['backward_support']) {
+ if(setting('core.backward_support')) {
global $SQL, $main_content, $subtopic;
}
@@ -1527,8 +1526,8 @@ function right($str, $length) {
}
function getCreatureImgPath($creature){
- $creature_path = config('monsters_images_url');
- $creature_gfx_name = trim(strtolower($creature)) . config('monsters_images_extension');
+ $creature_path = setting('core.monsters_images_url');
+ $creature_gfx_name = trim(strtolower($creature)) . setting('core.monsters_images_extension');
if (!file_exists($creature_path . $creature_gfx_name)) {
$creature_gfx_name = str_replace(" ", "", $creature_gfx_name);
if (file_exists($creature_path . $creature_gfx_name)) {
diff --git a/system/init.php b/system/init.php
index bda1f85c..cf4b3f9b 100644
--- a/system/init.php
+++ b/system/init.php
@@ -137,7 +137,12 @@ require_once SYSTEM . 'compat/config.php';
date_default_timezone_set(setting('core.date_timezone'));
-$config['account_create_character_create'] = config('account_create_character_create') && (!setting('core.mail_enabled') || !config('account_mail_verify'));
+setting(
+ [
+ 'core.account_create_character_create',
+ setting('core.account_create_character_create') && (!setting('core.mail_enabled') || !setting('core.account_mail_verify'))
+ ]
+);
$settingsItemImagesURL = setting('core.item_images_url');
if($settingsItemImagesURL[strlen($settingsItemImagesURL) - 1] !== '/') {
diff --git a/system/libs/CreateCharacter.php b/system/libs/CreateCharacter.php
index a4a1f87a..994c4a61 100644
--- a/system/libs/CreateCharacter.php
+++ b/system/libs/CreateCharacter.php
@@ -140,8 +140,8 @@ class CreateCharacter
if(empty($errors))
{
$number_of_players_on_account = $account->getPlayersList(true)->count();
- if($number_of_players_on_account >= config('characters_per_account'))
- $errors[] = 'You have too many characters on your account
('.$number_of_players_on_account.'/'.config('characters_per_account').')!';
+ if($number_of_players_on_account >= setting('core.characters_per_account'))
+ $errors[] = 'You have too many characters on your account
('.$number_of_players_on_account . '/' . setting('core.characters_per_account') . ')!';
}
if(empty($errors))
diff --git a/system/libs/forum.php b/system/libs/forum.php
index c7f303f7..3f80c927 100644
--- a/system/libs/forum.php
+++ b/system/libs/forum.php
@@ -10,13 +10,13 @@
*/
defined('MYAAC') or die('Direct access not allowed!');
-$configForumTablePrefix = setting('core.forum_table_prefix');
-if(null !== $configForumTablePrefix && !empty(trim($configForumTablePrefix))) {
- if(!in_array($configForumTablePrefix, array('myaac_', 'z_'))) {
+$settingForumTablePrefix = setting('core.forum_table_prefix');
+if(null !== $settingForumTablePrefix && !empty(trim($settingForumTablePrefix))) {
+ if(!in_array($settingForumTablePrefix, array('myaac_', 'z_'))) {
throw new RuntimeException('Invalid value for forum_table_prefix in config.php. Can be only: "myaac_" or "z_".');
}
- define('FORUM_TABLE_PREFIX', $configForumTablePrefix);
+ define('FORUM_TABLE_PREFIX', $settingForumTablePrefix);
}
else {
if($db->hasTable('z_forum')) {
diff --git a/system/libs/usage_statistics.php b/system/libs/usage_statistics.php
index 0002c1c7..29afc51b 100644
--- a/system/libs/usage_statistics.php
+++ b/system/libs/usage_statistics.php
@@ -106,8 +106,8 @@ WHERE TABLE_SCHEMA = "' . $config['database_name'] . '";');
}
$ret['templates'] = get_templates();
- $ret['date_timezone'] = $config['date_timezone'];
- $ret['backward_support'] = $config['backward_support'];
+ $ret['date_timezone'] = setting('core.date_timezone');
+ $ret['backward_support'] = setting('core.backward_support');
$cache_engine = strtolower($config['cache_engine']);
if($cache_engine == 'auto') {
@@ -117,4 +117,4 @@ WHERE TABLE_SCHEMA = "' . $config['database_name'] . '";');
$ret['cache_engine'] = $cache_engine;
return $ret;
}
-}
\ No newline at end of file
+}
diff --git a/system/pages/account/change_email.php b/system/pages/account/change_email.php
index 3bc8edd7..95ce48fc 100644
--- a/system/pages/account/change_email.php
+++ b/system/pages/account/change_email.php
@@ -43,7 +43,7 @@ if($email_new_time < 10) {
}
if(empty($errors)) {
- $email_new_time = time() + $config['account_mail_change'] * 24 * 3600;
+ $email_new_time = time() + setting('account_mail_change') * 24 * 3600;
$account_logged->setCustomField("email_new", $email_new);
$account_logged->setCustomField("email_new_time", $email_new_time);
$twig->display('success.html.twig', array(
diff --git a/system/pages/account/change_info.php b/system/pages/account/change_info.php
index 8b61ea1c..2a8d4a07 100644
--- a/system/pages/account/change_info.php
+++ b/system/pages/account/change_info.php
@@ -20,7 +20,7 @@ if(!$logged) {
return;
}
-if($config['account_country'])
+if(setting('core.account_country'))
require SYSTEM . 'countries.conf.php';
$account = Account::find($account_logged->getId());
@@ -55,7 +55,7 @@ if(isset($_POST['changeinfosave']) && $_POST['changeinfosave'] == 1) {
if($show_form) {
$account_rlname = $account->rlname;
$account_location = $account->location;
- if ($config['account_country']) {
+ if (setting('core.account_country')) {
$account_country = $account->country;
$countries = array();
diff --git a/system/pages/account/create.php b/system/pages/account/create.php
index 2aa7c544..aff92145 100644
--- a/system/pages/account/create.php
+++ b/system/pages/account/create.php
@@ -11,7 +11,7 @@
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Create Account';
-if($config['account_country'])
+if (setting('core.account_country'))
require SYSTEM . 'countries.conf.php';
if($logged)
@@ -20,7 +20,7 @@ if($logged)
return;
}
-if(config('account_create_character_create')) {
+if(setting('core.account_create_character_create')) {
require_once LIBS . 'CreateCharacter.php';
$createCharacter = new CreateCharacter();
}
@@ -68,7 +68,7 @@ if($save)
// country
$country = '';
- if($config['account_country'])
+ if (setting('core.account_country'))
{
$country = $_POST['country'];
if(!isset($country))
@@ -93,7 +93,7 @@ if($save)
$errors['password'] = 'Password may not be the same as account name.';
}
- if($config['account_mail_unique'])
+ if(setting('core.account_mail_unique'))
{
$test_email_account = new OTS_Account();
$test_email_account->findByEMail($email);
@@ -115,7 +115,7 @@ if($save)
}
if($account_db->isLoaded()) {
- if (config('account_login_by_email') && !config('account_mail_unique')) {
+ if (config('account_login_by_email') && !setting('core.account_mail_unique')) {
$errors['account'] = 'Account with this email already exist.';
}
else if (!config('account_login_by_email')) {
@@ -150,7 +150,7 @@ if($save)
return;
}
- if(config('account_create_character_create')) {
+ if(setting('core.account_create_character_create')) {
$character_name = isset($_POST['name']) ? stripslashes(ucwords(strtolower($_POST['name']))) : null;
$character_sex = isset($_POST['sex']) ? (int)$_POST['sex'] : null;
$character_vocation = isset($_POST['vocation']) ? (int)$_POST['vocation'] : null;
@@ -191,27 +191,28 @@ if($save)
$new_account->setCustomField('created', time());
$new_account->logAction('Account created.');
- if($config['account_country']) {
+ if(setting('core.account_country')) {
$new_account->setCustomField('country', $country);
}
- if($config['account_premium_days'] && $config['account_premium_days'] > 0) {
+ $settingAccountPremiumDays = setting('core.account_premium_days');
+ if($settingAccountPremiumDays && $settingAccountPremiumDays > 0) {
if($db->hasColumn('accounts', 'premend')) { // othire
- $new_account->setCustomField('premend', time() + $config['account_premium_days'] * 86400);
+ $new_account->setCustomField('premend', time() + $settingAccountPremiumDays * 86400);
}
else { // rest
if ($db->hasColumn('accounts', 'premium_ends_at')) { // TFS 1.4+
- $new_account->setCustomField('premium_ends_at', time() + $config['account_premium_days'] * (60 * 60 * 24));
+ $new_account->setCustomField('premium_ends_at', time() + $settingAccountPremiumDays * (60 * 60 * 24));
}
else {
- $new_account->setCustomField('premdays', $config['account_premium_days']);
+ $new_account->setCustomField('premdays', $settingAccountPremiumDays);
$new_account->setCustomField('lastday', time());
}
}
}
- if($config['account_premium_points']) {
- $new_account->setCustomField('premium_points', $config['account_premium_points']);
+ if(setting('account_premium_points') && setting('account_premium_points') > 0) {
+ $new_account->setCustomField('premium_points', setting('account_premium_points'));
}
$tmp_account = $email;
@@ -219,7 +220,7 @@ if($save)
$tmp_account = (USE_ACCOUNT_NAME ? $account_name : $account_id);
}
- if(setting('core.mail_enabled') && $config['account_mail_verify'])
+ if(setting('core.mail_enabled') && setting('core.account_mail_verify'))
{
$hash = md5(generateRandomString(16, true, true) . $email);
$new_account->setCustomField('email_hash', $hash);
@@ -238,7 +239,7 @@ if($save)
'description' => 'Your account ' . $account_type . ' is
' . $tmp_account . 'You will need the account ' . $account_type . ' and your password to play on ' . configLua('serverName') . '.
Please keep your account ' . $account_type . ' and password in a safe place and
never give your account ' . $account_type . ' or password to anybody.',
- 'custom_buttons' => config('account_create_character_create') ? '' : null
+ 'custom_buttons' => setting('core.account_create_character_create') ? '' : null
));
}
else
@@ -249,7 +250,7 @@ if($save)
}
else
{
- if(config('account_create_character_create')) {
+ if(setting('core.account_create_character_create')) {
// character creation
$character_created = $createCharacter->doCreate($character_name, $character_sex, $character_vocation, $character_town, $new_account, $errors);
if (!$character_created) {
@@ -258,7 +259,7 @@ if($save)
}
}
- if(config('account_create_auto_login')) {
+ if(setting('core.account_create_auto_login')) {
if ($hasBeenCreatedByEMail) {
$_POST['account_login'] = $email;
}
@@ -273,7 +274,7 @@ if($save)
}
echo 'Your account';
- if(config('account_create_character_create')) {
+ if(setting('core.account_create_character_create')) {
echo ' and character have';
}
else {
@@ -281,7 +282,7 @@ if($save)
}
echo ' been created.';
- if(!config('account_create_character_create')) {
+ if(!setting('core.account_create_character_create')) {
echo ' Now you can login and create your first character.';
}
@@ -291,10 +292,10 @@ if($save)
'description' => 'Your account ' . $account_type . ' is
' . $tmp_account . 'You will need the account ' . $account_type . ' and your password to play on ' . configLua('serverName') . '.
Please keep your account ' . $account_type . ' and password in a safe place and
never give your account ' . $account_type . ' or password to anybody.',
- 'custom_buttons' => config('account_create_character_create') ? '' : null
+ 'custom_buttons' => setting('core.account_create_character_create') ? '' : null
));
- if(setting('core.mail_enabled') && $config['account_welcome_mail'])
+ if(setting('core.mail_enabled') && setting('account_welcome_mail'))
{
$mailBody = $twig->render('account.welcome_mail.html.twig', array(
'account' => $tmp_account
@@ -330,7 +331,7 @@ if(setting('core.account_country_recognize')) {
if(!empty($errors))
$twig->display('error_box.html.twig', array('errors' => $errors));
-if($config['account_country']) {
+if (setting('core.account_country')) {
$countries = array();
foreach (array('pl', 'se', 'br', 'us', 'gb') as $c)
$countries[$c] = $config['countries'][$c];
@@ -353,7 +354,7 @@ $params = array(
'save' => $save
);
-if($save && config('account_create_character_create')) {
+if($save && setting('core.account_create_character_create')) {
$params = array_merge($params, array(
'name' => $character_name,
'sex' => $character_sex,
diff --git a/system/pages/characters.php b/system/pages/characters.php
index 3411c043..2cb5e084 100644
--- a/system/pages/characters.php
+++ b/system/pages/characters.php
@@ -77,10 +77,10 @@ if($player->isLoaded() && !$player->isDeleted())
$rows = 0;
if($config['characters']['outfit'])
- $outfit = $config['outfit_images_url'] . '?id=' . $player->getLookType() . ($db->hasColumn('players', 'lookaddons') ? '&addons=' . $player->getLookAddons() : '') . '&head=' . $player->getLookHead() . '&body=' . $player->getLookBody() . '&legs=' . $player->getLookLegs() . '&feet=' . $player->getLookFeet();
+ $outfit = setting('core.outfit_images_url') . '?id=' . $player->getLookType() . ($db->hasColumn('players', 'lookaddons') ? '&addons=' . $player->getLookAddons() : '') . '&head=' . $player->getLookHead() . '&body=' . $player->getLookBody() . '&legs=' . $player->getLookLegs() . '&feet=' . $player->getLookFeet();
$flag = '';
- if($config['account_country']) {
+ if(setting('core.account_country')) {
$flag = getFlagImage($account->getCountry());
}
@@ -423,7 +423,7 @@ WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, kil
if($db->hasColumn('players', 'deletion'))
$deleted = 'deletion';
- $query = $db->query('SELECT `name`, `level`, `vocation`' . $promotion . ' FROM `players` WHERE `name` LIKE ' . $db->quote('%' . $name . '%') . ' AND ' . $deleted . ' != 1 LIMIT ' . (int)config('characters_search_limit') . ';');
+ $query = $db->query('SELECT `name`, `level`, `vocation`' . $promotion . ' FROM `players` WHERE `name` LIKE ' . $db->quote('%' . $name . '%') . ' AND ' . $deleted . ' != 1 LIMIT ' . (int)setting('core.characters_search_limit') . ';');
if($query->rowCount() > 0) {
echo 'Did you mean: