diff --git a/.gitignore b/.gitignore index 5206d08b..6c1db9b7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ Thumbs.db .DS_Store .idea +# +/.htaccess + # composer composer.lock vendor diff --git a/common.php b/common.php index 7bea3ca4..c1a89bbd 100644 --- a/common.php +++ b/common.php @@ -143,7 +143,6 @@ if(!IS_CLI) { //define('CURRENT_URL', BASE_URL . $_SERVER['REQUEST_URI']); } -require SYSTEM . 'config.php'; if (file_exists(BASE . 'config.local.php')) { require BASE . 'config.local.php'; } diff --git a/system/compat/config.php b/system/compat/config.php index 07eaecd4..9748e07b 100644 --- a/system/compat/config.php +++ b/system/compat/config.php @@ -24,6 +24,12 @@ $deprecatedConfig = [ 'outfit_images_wrong_looktypes', 'item_images_url', 'account_country', + 'towns', + 'quests', + 'character_samples', + 'character_towns', + 'characters_per_account', + 'characters_search_limit', 'news_author', 'news_limit', 'news_ticker_limit', @@ -52,6 +58,8 @@ $deprecatedConfig = [ 'status_ip', 'status_port', 'mail_enabled', + 'account_login_by_email', + 'account_login_by_email_fallback', 'account_mail_verify', 'account_create_character_create', 'account_change_character_name', @@ -70,3 +78,26 @@ foreach ($deprecatedConfig as $key => $value) { //var_dump($settings['core.'.$value]['value']); } + +$deprecatedConfigCharacters = [ + 'level', + 'experience', + 'magic_level', + 'balance', + 'marriage_info' => 'marriage', + 'outfit', + 'creation_date', + 'quests', + 'skills', + 'equipment', + 'frags', + 'deleted', +]; + +$tmp = []; +foreach ($deprecatedConfigCharacters as $key => $value) { + $tmp[(is_string($key) ? $key : $value)] = setting('core.characters_'.$value); +} + +config(['characters', $tmp]); +unset($tmp); diff --git a/system/config.php b/system/config.php deleted file mode 100644 index 5fba18f4..00000000 --- a/system/config.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright 2019 MyAAC - * @link https://my-aac.org - */ - -// TODO: -// this file will be deleted, once all migrated to settings -$config = array( - 'account_mail_block_plus_sign' => true, // block email with '+' signs like test+box@gmail.com (help protect against spamming accounts) - 'characters_per_account' => 10, // max. number of characters per account - - // new character config - 'character_samples' => array( // vocations, format: ID_of_vocation => 'Name of Character to copy' - //0 => 'Rook Sample', - 1 => 'Sorcerer Sample', - 2 => 'Druid Sample', - 3 => 'Paladin Sample', - 4 => 'Knight Sample' - ), - - 'use_character_sample_skills' => false, - - // it must show limited number of players after using search in character page - 'characters_search_limit' => 15, - - // town list used when creating character - // won't be displayed if there is only one item (rookgaard for example) - 'character_towns' => array(1), - - // list of towns - // if you use TFS 1.3 with support for 'towns' table in database, then you can ignore this - it will be configured automatically (from MySQL database - Table - towns) - // otherwise it will try to load from your .OTBM map file - // if you don't see towns on website, then you need to fill this out - 'towns' => array( - 0 => 'No town', - 1 => 'Sample town' - ), - - // characters page - 'characters' => array( // what things to display on character view page (true/false in each option) - 'level' => true, - 'experience' => false, - 'magic_level' => false, - 'balance' => false, - 'marriage_info' => true, // only 0.3 - 'outfit' => true, - 'creation_date' => true, - 'quests' => true, - 'skills' => true, - 'equipment' => true, - 'frags' => false, - 'deleted' => false, // should deleted characters from same account be still listed on the list of characters? When enabled it will show that character is "[DELETED]" - ), - 'quests' => array( - //'Some Quest' => 123, - //'Some Quest Two' => 456, - ), // quests list (displayed in character view), name => storage -); diff --git a/system/libs/CreateCharacter.php b/system/libs/CreateCharacter.php index 24edfb5f..8ec6993a 100644 --- a/system/libs/CreateCharacter.php +++ b/system/libs/CreateCharacter.php @@ -149,7 +149,7 @@ class CreateCharacter $char_to_copy = new OTS_Player(); $char_to_copy->find($char_to_copy_name); if(!$char_to_copy->isLoaded()) - $errors[] = 'Wrong characters configuration. Try again or contact with admin. ADMIN: Edit file config.php and set valid characters to copy names. Character to copy: '.$char_to_copy_name.' doesn\'t exist.'; + $errors[] = 'Wrong characters configuration. Try again or contact with admin. ADMIN: Go to Admin Panel -> Settings -> Create Character and set valid characters to copy names. Character to copy: '.$char_to_copy_name.' doesn\'t exist.'; } if(!empty($errors)) { @@ -195,7 +195,7 @@ class CreateCharacter for($skill = POT::SKILL_FIRST; $skill <= POT::SKILL_LAST; $skill++) { $value = 10; - if (config('use_character_sample_skills')) { + if (setting('core.use_character_sample_skills')) { $value = $char_to_copy->getSkill($skill); } @@ -241,7 +241,7 @@ class CreateCharacter if($db->hasTable('player_skills')) { for($skill = POT::SKILL_FIRST; $skill <= POT::SKILL_LAST; $skill++) { $value = 10; - if (config('use_character_sample_skills')) { + if (setting('core.use_character_sample_skills')) { $value = $char_to_copy->getSkill($skill); } $skillExists = $db->query('SELECT `skillid` FROM `player_skills` WHERE `player_id` = ' . $player->getId() . ' AND `skillid` = ' . $skill); diff --git a/system/libs/Settings.php b/system/libs/Settings.php index 7bf61bc2..7e1d07f5 100644 --- a/system/libs/Settings.php +++ b/system/libs/Settings.php @@ -248,7 +248,13 @@ class Settings implements ArrayAccess } else if($setting['type'] === 'textarea') { - echo ''; + $value = ($settingsDb[$key] ?? ($setting['default'] ?? '')); + $valueWithSpaces = array_map('trim', preg_split('/\r\n|\r|\n/', trim($value))); + $rows = count($valueWithSpaces); + if ($rows < 2) { + $rows = 2; // always min 2 rows for textarea + } + echo ''; } else if ($setting['type'] === 'options') { @@ -314,8 +320,7 @@ class Settings implements ArrayAccess ?> -
- '; echo 'Default: '; @@ -331,8 +336,7 @@ class Settings implements ArrayAccess echo $setting['options'][$setting['default']]; } } - ?> -
+ ?> 'App Environment', 'type' => 'options', 'options' => ['prod' => 'Production', 'dev' => 'Development'], - 'desc' => 'if you use this script on your live server - set production
- * if you want to test and debug the script locally, or develop plugins, set to development
- * WARNING: on "development" cache is disabled, so site will be significantly slower !!!
- * WARNING2: on "development" all PHP errors/warnings are displayed
- * Recommended: "production" cause of speed (page load time is better)', + 'desc' => 'if you use this script on your live server - set production
' . + '* if you want to test and debug the script locally, or develop plugins, set to development
' . + '* WARNING: on "development" cache is disabled, so site will be significantly slower !!!
' . + '* WARNING2: on "development" all PHP errors/warnings are displayed
' . + '* Recommended: "production" cause of speed (page load time is better)', 'default' => 'prod', 'is_config' => true, ], @@ -41,28 +41,6 @@ return [ 'default' => '', 'is_config' => true, ], - 'gzip_output' => [ - 'name' => 'gzip Output', - 'type' => 'boolean', - 'desc' => 'gzip page content before sending it to the browser, uses less bandwidth but more cpu cycles', - 'default' => false, - 'is_config' => true, - ], - 'cache_engine' => [ - 'name' => 'Cache Engine', - 'type' => 'options', - 'options' => ['auto' => 'Auto', 'file' => 'Files', 'apc' => 'APC', 'apcu' => 'APCu', 'eaccelerator' => 'eAccelerator', 'disable' => 'Disable'], - 'desc' => 'Auto is most reasonable. It will detect the best cache engine', - 'default' => 'auto', - 'is_config' => true, - ], - 'cache_prefix' => [ - 'name' => 'Cache Prefix', - 'type' => 'text', - 'desc' => 'Have to be unique if running more MyAAC instances on the same server (except file system cache)', - 'default' => 'myaac_' . generateRandomString(8, true, false, true), - 'is_config' => true, - ], 'date_timezone' => [ 'name' => 'Date Timezone', 'type' => 'options', @@ -70,27 +48,22 @@ return [ 'desc' => 'Timezone of the server, more info at http://php.net/manual/en/timezones.php', 'default' => 'Europe/Warsaw', ], - 'genders' => [ - 'name' => 'Genders (aka sex)', - 'type' => 'textarea', - 'desc' => 'Separated with comma', - 'default' => 'Female, Male', - 'callbacks' => [ - 'get' => function ($value) { - return array_map('trim', explode(',', $value)); - }, - ], + 'friendly_urls' => [ + 'name' => 'Friendly URLs', + 'type' => 'boolean', + 'desc' => 'It makes links looks more elegant to eye, and also are SEO friendly

' . + 'yes: http://example.net/guilds/Testing
' . + 'no: http://example.net/index.php/guilds/Testing

' . + 'apache2: mod_rewrite is required for this + remember to rename .htaccess.dist to .htaccess
' . + 'nginx: check included nginx-sample.conf', + 'default' => false, ], - 'account_types' => [ - 'name' => 'Account Types', - 'type' => 'textarea', - 'desc' => 'Separated with comma, you may need to adjust this for older tfs versions by removing Community Manager', - 'default' => 'None, Normal, Tutor, Senior Tutor, Gamemaster, Community Manager, God', - 'callbacks' => [ - 'get' => function ($value) { - return array_map('trim', explode(',', $value)); - }, - ], + 'gzip_output' => [ + 'name' => 'gzip Output', + 'type' => 'boolean', + 'desc' => 'gzip page content before sending it to the browser, uses less bandwidth but more cpu cycles', + 'default' => false, + 'is_config' => true, ], 'google_analytics_id' => [ 'name' => 'Google Analytics ID', @@ -204,6 +177,103 @@ return [ 'type' => 'section', 'title' => 'Misc' ], + 'cache_engine' => [ + 'name' => 'Cache Engine', + 'type' => 'options', + 'options' => ['auto' => 'Auto', 'file' => 'Files', 'apc' => 'APC', 'apcu' => 'APCu', 'eaccelerator' => 'eAccelerator', 'disable' => 'Disable'], + 'desc' => 'Auto is most reasonable. It will detect the best cache engine', + 'default' => 'auto', + 'is_config' => true, + ], + 'cache_prefix' => [ + 'name' => 'Cache Prefix', + 'type' => 'text', + 'desc' => 'Have to be unique if running more MyAAC instances on the same server (except file system cache)', + 'default' => 'myaac_' . generateRandomString(8, true, false, true), + 'is_config' => true, + ], + 'session_prefix' => [ + 'name' => 'Session Prefix', + 'type' => 'text', + 'desc' => 'must be unique for every site on your server', + 'default' => 'myaac_', + ], + 'backward_support' => [ + 'name' => 'Gesior Backward Support', + 'type' => 'boolean', + 'desc' => 'gesior backward support (templates & pages)
' . + 'allows using gesior templates and pages with myaac
' . + 'might bring some performance when disabled', + 'default' => true, + ], + 'anonymous_usage_statistics' => [ + 'name' => 'Anonymous Usage Statistics', + 'type' => 'boolean', + 'desc' => 'Allow MyAAC to report anonymous usage statistics to developers? The data is sent only once per 30 days and is fully confidential. It won\'t affect the performance of your website', + 'default' => true, + ], + [ + 'type' => 'category', + 'title' => 'Game', + ], + [ + 'type' => 'section', + 'title' => 'Game' + ], + 'client' => [ + 'name' => 'Client Version', + 'type' => 'options', + 'options' => '$clients', + 'desc' => 'what client version are you using on this OT?
used for the Downloads page and some templates aswell', + 'default' => 710 + ], + 'towns' => [ + 'name' => 'Towns', + 'type' => 'textarea', + 'desc' => "if you use TFS 1.3 with support for 'towns' table in database, then you can ignore this - it will be configured automatically (from MySQL database - Table - towns)
" . + "otherwise it will try to load from your .OTBM map file
" . + "if you don't see towns on website, then you need to fill this out", + 'default' => "0=No Town\n1=Sample Town", + 'callbacks' => [ + 'get' => function ($value) { + $ret = []; + $towns = array_map('trim', preg_split('/\r\n|\r|\n/', trim($value))); + + foreach ($towns as $town) { + if (empty($town)) { + continue; + } + + $explode = explode('=', $town); + $ret[$explode[0]] = $explode[1]; + } + + return $ret; + }, + ], + ], + 'genders' => [ + 'name' => 'Genders (aka sex)', + 'type' => 'textarea', + 'desc' => 'Separated with comma', + 'default' => 'Female, Male', + 'callbacks' => [ + 'get' => function ($value) { + return array_map('trim', explode(',', $value)); + }, + ], + ], + 'account_types' => [ + 'name' => 'Account Types', + 'type' => 'textarea', + 'desc' => 'Separated with comma, you may need to adjust this for older tfs versions by removing Community Manager', + 'default' => 'None, Normal, Tutor, Senior Tutor, Gamemaster, Community Manager, God', + 'callbacks' => [ + 'get' => function ($value) { + return array_map('trim', explode(',', $value)); + }, + ], + ], 'vocations_amount' => [ 'name' => 'Vocations Amount', 'type' => 'number', @@ -221,43 +291,6 @@ return [ }, ], ], - 'client' => [ - 'name' => 'Client Version', - 'type' => 'options', - 'options' => '$clients', - 'desc' => 'what client version are you using on this OT?
used for the Downloads page and some templates aswell', - 'default' => 710 - ], - 'session_prefix' => [ - 'name' => 'Session Prefix', - 'type' => 'text', - 'desc' => 'must be unique for every site on your server', - 'default' => 'myaac_', - ], - 'friendly_urls' => [ - 'name' => 'Friendly URLs', - 'type' => 'boolean', - 'desc' => 'It makes links looks more elegant to eye, and also are SEO friendly

- yes: http://example.net/guilds/Testing
- no: http://example.net/?subtopic=guilds&name=Testing

- apache2: mod_rewrite is required for this + remember to rename .htaccess.dist to .htaccess
- nginx: check included nginx-sample.conf', - 'default' => false, - ], - 'backward_support' => [ - 'name' => 'Gesior Backward Support', - 'type' => 'boolean', - 'desc' => 'gesior backward support (templates & pages)
- allows using gesior templates and pages with myaac
- might bring some performance when disabled', - 'default' => true, - ], - 'anonymous_usage_statistics' => [ - 'name' => 'Anonymous Usage Statistics', - 'type' => 'boolean', - 'desc' => 'Allow MyAAC to report anonymous usage statistics to developers? The data is sent only once per 30 days and is fully confidential. It won\'t affect the performance of your website', - 'default' => true, - ], [ 'type' => 'category', 'title' => 'Database', @@ -552,7 +585,7 @@ Sent by MyAAC,
], ], 'mail_lost_account_interval' => [ - 'name' => 'Default Account Premium Days', + 'name' => 'Mail Lost Interface Interval', 'type' => 'number', 'desc' => 'Time in seconds between e-mails to one account from lost account interface, block spam', 'default' => 60, @@ -585,6 +618,9 @@ Sent by MyAAC,
'type' => 'boolean', 'desc' => "allow also additionally login by Account Name/Number (for users that might forget their email). Works only if Account Login By E-Mail is also enabled", 'default' => false, + 'show_if' => [ + 'account_login_by_email', '=', 'true' + ], ], 'account_create_auto_login' => [ 'name' => 'Account Create Auto Login', @@ -622,6 +658,12 @@ Sent by MyAAC,
'desc' => 'How many days user need to change email to account - block hackers', 'default' => 2, ], + 'account_mail_block_plus_sign' => [ + 'name' => 'Account Mail Block Plus Sign (+)', + 'type' => 'boolean', + 'desc' => "Block E-Mails with '+' signs like test+box@gmail.com (help protect against spamming accounts)", + 'default' => true, + ], 'account_country' => [ 'name' => 'Account Country', 'type' => 'boolean', @@ -634,10 +676,52 @@ Sent by MyAAC,
'desc' => 'should country of user be automatically recognized by his IP? This makes an external API call to http://ipinfo.io', 'default' => true, ], + 'characters_per_account' => [ + 'name' => 'Characters per Account', + 'type' => 'number', + 'desc' => 'Max. number of characters per account', + 'default' => 10, + ], 'create_character' => [ 'type' => 'section', 'title' => 'Create Character', ], + 'character_samples' => [ + 'name' => 'Character Samples', + 'type' => 'textarea', + 'desc' => "Character Samples used when creating character.
" . + "Format: ID_of_vocation =Name of Character to copy
" . + "For Rook use - 0=Rook Sample", + 'default' => "1=Sorcerer Sample\n2=Druid Sample\n3=Paladin Sample\n4=Knight Sample", + 'callbacks' => [ + 'get' => function ($value) { + $ret = []; + $vocs = array_map('trim', preg_split('/\r\n|\r|\n/', trim($value))); + + foreach ($vocs as $voc) { + if (empty($voc)) { + continue; + } + + $explode = explode('=', $voc); + $ret[$explode[0]] = $explode[1]; + } + + return $ret; + }, + ], + ], + 'character_towns' => [ + 'name' => 'Towns List', + 'type' => 'text', + 'desc' => "Towns List used when creating character separated by comma (,). Won't be displayed if there is only one item (rookgaard for example)", + 'default' => '1,2', + 'callbacks' => [ + 'get' => function ($value) { + return array_map('trim', explode(',', $value)); + }, + ], + ], 'create_character_name_min_length' => [ 'name' => 'Name Min Length', 'type' => 'number', @@ -701,6 +785,12 @@ Sent by MyAAC,
'desc' => 'Should spells names and words be blocked when creating character?', 'default' => true, ], + 'use_character_sample_skills' => [ + 'name' => 'Use Character Sample Skills', + 'type' => 'boolean', + 'desc' => 'No = default skill = 10, yes - use sample skills', + 'default' => false, + ], 'account_mail_confirmed_reward' => [ 'type' => 'section', 'title' => 'Reward Users for confirming their E-Mails. Works only with Account Mail Verify enabled', @@ -709,7 +799,7 @@ Sent by MyAAC,
], ], 'account_mail_confirmed_reward_premium_days' => [ - 'name' => 'Reward Premium Points', + 'name' => 'Reward Premium Days', 'type' => 'number', 'desc' => '0 to disable', 'default' => 0, @@ -727,7 +817,7 @@ Sent by MyAAC,
], ], 'account_mail_confirmed_reward_coins' => [ - 'name' => 'Reward Premium Points', + 'name' => 'Reward Coins', 'type' => 'number', 'desc' => '0 to disable. Works only with servers that supports coins', 'default' => 0, @@ -980,6 +1070,114 @@ Sent by MyAAC,
}, ], ], + [ + 'type' => 'section', + 'title' => 'Characters Page', + ], + 'characters_search_limit' => [ + 'name' => 'Characters Search Limit', + 'type' => 'number', + 'desc' => "How many characters (players) to show when using search function", + 'default' => 15, + ], + 'characters_level' => [ + 'name' => 'Display Level', + 'type' => 'boolean', + 'desc' => 'Show characters level', + 'default' => true, + ], + 'characters_experience' => [ + 'name' => 'Display Experience', + 'type' => 'boolean', + 'desc' => 'Show characters experience points', + 'default' => false, + ], + 'characters_magic_level' => [ + 'name' => 'Display Magic Level', + 'type' => 'boolean', + 'desc' => 'Show characters magic level', + 'default' => false, + ], + 'characters_balance' => [ + 'name' => 'Display Balance', + 'type' => 'boolean', + 'desc' => 'Show characters bank balance', + 'default' => false, + ], + 'characters_marriage' => [ + 'name' => 'Display Marriage', + 'type' => 'boolean', + 'desc' => 'Show characters marriage info. Works only in TFS 0.3', + 'default' => true, + ], + 'characters_outfit' => [ + 'name' => 'Display Outfit', + 'type' => 'boolean', + 'desc' => 'Show characters outfit', + 'default' => true, + ], + 'characters_creation_date' => [ + 'name' => 'Display Creation Date', + 'type' => 'boolean', + 'desc' => 'Show characters date of creation', + 'default' => true, + ], + 'characters_quests' => [ + 'name' => 'Display Quests', + 'type' => 'boolean', + 'desc' => 'Show characters quests. Can be configured below', + 'default' => true, + ], + 'quests' => [ + 'name' => 'Quests List', + 'type' => 'textarea', + 'desc' => 'Character Quests List. Format: NameOfQuest=StorageValue', + 'default' => "Some Quest=123\nSome Quest Two=456", + 'show_if' => [ + 'characters_quests', '=', 'true' + ], + 'callbacks' => [ + 'get' => function ($value) { + $ret = []; + $quests = array_map('trim', preg_split('/\r\n|\r|\n/', trim($value))); + + foreach ($quests as $quest) { + if (empty($quest)) { + continue; + } + + $explode = explode('=', $quest); + $ret[$explode[0]] = $explode[1]; + } + + return $ret; + }, + ], + ], + 'characters_skills' => [ + 'name' => 'Display Skills', + 'type' => 'boolean', + 'desc' => 'Show characters skills', + 'default' => true, + ], + 'characters_equipment' => [ + 'name' => 'Display Equipment', + 'type' => 'boolean', + 'desc' => 'Show characters equipment', + 'default' => true, + ], + 'characters_frags' => [ + 'name' => 'Display Frags', + 'type' => 'boolean', + 'desc' => 'Show characters frags', + 'default' => false, + ], + 'characters_deleted' => [ + 'name' => 'Display Deleted', + 'type' => 'boolean', + 'desc' => 'Should deleted characters from same account be still listed on the list of characters? When enabled it will show that character is "[DELETED]', + 'default' => false, + ], [ 'type' => 'section', 'title' => 'Online Page' @@ -1192,7 +1390,7 @@ Sent by MyAAC,
'monsters_images_preview' => [ 'name' => 'Monsters Images Preview', 'type' => 'boolean', - 'desc' => 'Set to true to allow picture previews for creatures', + 'desc' => 'Set to yes to allow picture previews for creatures', 'default' => false, ], 'monsters_items_url' => [ @@ -1204,7 +1402,7 @@ Sent by MyAAC,
'monsters_loot_percentage' => [ 'name' => 'Monsters Items URL', 'type' => 'boolean', - 'desc' => 'Set to true to show the loot tooltip percent', + 'desc' => 'Set to yes to show the loot tooltip percent', 'default' => true, ], // this is hidden, because no implemented yet diff --git a/system/templates/admin.settings.html.twig b/system/templates/admin.settings.html.twig index d06eadc1..e5d3ef9b 100644 --- a/system/templates/admin.settings.html.twig +++ b/system/templates/admin.settings.html.twig @@ -18,6 +18,11 @@ +