[WIP] Some work on settings

Add hidden settings
New method: parse, to parse settings from array
Move base html to twig template
Remove vocation loading from .xml, instead use predefined voc names
This commit is contained in:
slawkens 2023-05-15 00:22:27 +02:00
parent 44d5d7ae64
commit 1fa6788310
10 changed files with 748 additions and 665 deletions

View File

@ -21,11 +21,11 @@ $plugin = $_GET['plugin'];
if($plugin != 'core') { if($plugin != 'core') {
$pluginSettings = Plugins::getPluginSettings($plugin); $pluginSettings = Plugins::getPluginSettings($plugin);
if (!$pluginSettings) { if (!$pluginSettings) {
error('This plugin does not exist or does not have options defined.'); error('This plugin does not exist or does not have settings defined.');
return; return;
} }
$settingsFilePath = PLUGINS . $plugin . '/settings.php'; $settingsFilePath = BASE . $pluginSettings;
} }
else { else {
$settingsFilePath = SYSTEM . 'settings.php'; $settingsFilePath = SYSTEM . 'settings.php';
@ -36,13 +36,7 @@ if (!file_exists($settingsFilePath)) {
return; return;
} }
if($plugin === 'core') { $settingsFile = require $settingsFilePath;
$settingsFile = require $settingsFilePath;
}
else {
$settingsFile = require $settingsFilePath;
}
if (!is_array($settingsFile)) { if (!is_array($settingsFile)) {
return; return;
} }
@ -61,182 +55,14 @@ if (isset($_POST['save'])) {
if ($cache->enabled()) { if ($cache->enabled()) {
$cache->delete('settings'); $cache->delete('settings');
} }
success('Saved at ' . date('H:i')); success('Saved at ' . date('H:i'));
} }
$title = ($plugin == 'core' ? 'Settings' : 'Plugin Settings - ' . $plugin); $title = ($plugin == 'core' ? 'Settings' : 'Plugin Settings - ' . $plugin);
$query = 'SELECT `key`, `value` FROM `' . TABLE_PREFIX . 'settings` WHERE `plugin_name` = ' . $db->quote($plugin) . ';'; $settings = Settings::parse($plugin, $settingsFile['settings']);
$query = $db->query($query);
$settingsDb = []; $twig->display('admin.settings.html.twig', [
if($query->rowCount() > 0) { 'settings' => $settings,
foreach($query->fetchAll(PDO::FETCH_ASSOC) as $value) { ]);
$settingsDb[$value['key']] = $value['value'];
}
}
?>
<form method="post">
<div class="row">
<div class="col-md-12">
<div class="box">
<div class="box-body">
<button name="save" type="submit" class="btn btn-primary">Save</button>
</div>
<br/>
<ul class="nav nav-tabs" id="myTab">
<?php
$i = 0;
foreach($settingsFile as $key => $setting) {
if ($setting['type'] === 'category') {
?>
<li class="nav-item">
<button class="nav-link<?= ($i === 0 ? ' active' : ''); ?>" id="home-tab-<?= $i++; ?>" data-toggle="tab" data-target="#tab-<?= str_replace(' ', '', $setting['title']); ?>" type="button"><?= $setting['title']; ?></button>
</li>
<?php
}
}
?>
</ul>
<div class="tab-content" id="tab-content">
<?php
$checkbox = function ($key, $type, $value) {
echo '<label><input type="radio" id="' . $key . '" name="settings[' . $key . ']" value="' . ($type ? 'true' : 'false') . '" ' . ($value === $type ? 'checked' : '') . '/>' . ($type ? 'Yes' : 'No') . '</label> ';
};
$i = 0;
$j = 0;
foreach($settingsFile as $key => $setting) {
if ($setting['type'] === 'category') {
if ($j++ !== 0) {
echo '</tbody></table></div>';
}
?>
<div class="tab-pane fade show<?= ($j === 1 ? ' active' : ''); ?>" id="tab-<?= str_replace(' ', '', $setting['title']); ?>">
<?php
continue;
}
if ($setting['type'] === 'section') {
if ($i++ !== 0) {
echo '</tbody></table>';
}
?>
<h2 style="text-align: center"><strong><?= $setting['title']; ?></strong></h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="width: 10%">Name</th>
<th style="width: 30%">Value</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<?php
continue;
}
?>
<tr>
<td><label for="<?= $key ?>" class="control-label"><?= $setting['name'] ?></label></td>
<td>
<?php
if ($setting['type'] === 'boolean') {
if(isset($settingsDb[$key])) {
if($settingsDb[$key] === 'true') {
$value = true;
}
else {
$value = false;
}
}
else {
$value = ($setting['default'] ?? false);
}
$checkbox($key, true, $value);
$checkbox($key, false, $value);
}
else if (in_array($setting['type'], ['text', 'number', 'email', 'password'])) {
echo '<input class="form-control" type="' . $setting['type'] . '" name="settings[' . $key . ']" value="' . ($settingsDb[$key] ?? ($setting['default'] ?? '')) . '" id="' . $key . '"/>';
}
else if($setting['type'] === 'textarea') {
echo '<textarea class="form-control" name="settings[' . $key . ']" id="' . $key . '">' . ($settingsDb[$key] ?? ($setting['default'] ?? '')) . '</textarea>';
}
if ($setting['type'] === 'options') {
if ($setting['options'] === '$templates') {
$templates = [];
foreach (get_templates() as $value) {
$templates[$value] = $value;
}
$setting['options'] = $templates;
}
else if($setting['options'] === '$clients') {
$clients = [];
foreach((array)config('clients') as $client) {
$client_version = (string)($client / 100);
if(strpos($client_version, '.') === false)
$client_version .= '.0';
$clients[$client] = $client_version;
}
$setting['options'] = $clients;
}
else {
if (is_string($setting['options'])) {
$setting['options'] = explode(',', $setting['options']);
foreach ($setting['options'] as &$option) {
$option = trim($option);
}
}
}
echo '<select class="form-control" name="settings[' . $key . ']" id="' . $key . '">';
foreach ($setting['options'] as $value => $option) {
$compareTo = (isset($settingsDb[$key]) ? $settingsDb[$key] : (isset($setting['default']) ? $setting['default'] : ''));
if($value === 'true') {
$selected = $compareTo === true;
}
else if($value === 'false') {
$selected = $compareTo === false;
}
else {
$selected = $compareTo == $value;
}
echo '<option value="' . $value . '" ' . ($selected ? 'selected' : '') . '>' . $option . '</option>';
}
echo '</select>';
}
?>
</td>
<td>
<div class="well">
<?= $setting['desc'] ?>
</div>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
<div class="box-footer">
<button name="save" type="submit" class="btn btn-primary">Save</button>
</div>
</div>
</div>
</div>
</form>

View File

@ -18,8 +18,30 @@ $deprecatedConfig = [
'views_counter', 'views_counter',
'outfit_images_url', 'outfit_images_url',
'item_images_url', 'item_images_url',
'account_country',
'team_display_outfit',
'team_display_status',
'team_display_world',
'team_display_lastlogin',
'multiworld',
]; ];
foreach ($deprecatedConfig as $value) { foreach ($deprecatedConfig as $value) {
$config[$value] = $settings['core.'.$value]['value']; config(
[
$value,
$settings['core.'.$value]['value']
]
);
//var_dump($settings['core.'.$value]['value']);
} }
$vocationsParsed = array_map(
function(string $value): string {
return trim($value);
},
explode(',', $settings['core.vocations']['value'])
);
config(['vocations', $vocationsParsed]);

View File

@ -1492,8 +1492,8 @@ function right($str, $length) {
} }
function getCreatureImgPath($creature){ function getCreatureImgPath($creature){
$creature_path = config('creatures_images_url'); $creature_path = config('monsters_images_url');
$creature_gfx_name = trim(strtolower($creature)) . config('creatures_images_extension'); $creature_gfx_name = trim(strtolower($creature)) . config('monsters_images_extension');
if (!file_exists($creature_path . $creature_gfx_name)) { if (!file_exists($creature_path . $creature_gfx_name)) {
$creature_gfx_name = str_replace(" ", "", $creature_gfx_name); $creature_gfx_name = str_replace(" ", "", $creature_gfx_name);
if (file_exists($creature_path . $creature_gfx_name)) { if (file_exists($creature_path . $creature_gfx_name)) {

View File

@ -148,35 +148,5 @@ define('USE_ACCOUNT_NAME', $db->hasColumn('accounts', 'name'));
define('USE_ACCOUNT_NUMBER', $db->hasColumn('accounts', 'number')); define('USE_ACCOUNT_NUMBER', $db->hasColumn('accounts', 'number'));
define('USE_ACCOUNT_SALT', $db->hasColumn('accounts', 'salt')); define('USE_ACCOUNT_SALT', $db->hasColumn('accounts', 'salt'));
// load vocation names
$tmp = '';
if($cache->enabled() && $cache->fetch('vocations', $tmp)) {
$config['vocations'] = unserialize($tmp);
}
else {
if(!class_exists('DOMDocument')) {
throw new RuntimeException('Please install PHP xml extension. MyAAC will not work without it.');
}
$vocations = new DOMDocument();
$file = $config['data_path'] . 'XML/vocations.xml';
if(!@file_exists($file))
$file = $config['data_path'] . 'vocations.xml';
if(!$vocations->load($file))
throw new RuntimeException('ERROR: Cannot load <i>vocations.xml</i> - the file is malformed. Check the file with xml syntax validator.');
$config['vocations'] = array();
foreach($vocations->getElementsByTagName('vocation') as $vocation) {
$id = $vocation->getAttribute('id');
$config['vocations'][$id] = $vocation->getAttribute('name');
}
if($cache->enabled()) {
$cache->set('vocations', serialize($config['vocations']), 120);
}
}
unset($tmp, $id, $vocation);
require LIBS . 'Towns.php'; require LIBS . 'Towns.php';
Towns::load(); Towns::load();

View File

@ -18,7 +18,7 @@ class Settings implements ArrayAccess
/** /**
* @return Settings * @return Settings
*/ */
public static function getInstance() public static function getInstance(): Settings
{ {
if (!self::$instance) { if (!self::$instance) {
self::$instance = new self(); self::$instance = new self();
@ -52,6 +52,210 @@ class Settings implements ArrayAccess
} }
} }
public static function parse($plugin, $settings): string
{
global $db;
$query = 'SELECT `key`, `value` FROM `' . TABLE_PREFIX . 'settings` WHERE `plugin_name` = ' . $db->quote($plugin) . ';';
$query = $db->query($query);
$settingsDb = [];
if($query->rowCount() > 0) {
foreach($query->fetchAll(PDO::FETCH_ASSOC) as $value) {
$settingsDb[$value['key']] = $value['value'];
}
}
ob_start();
?>
<ul class="nav nav-tabs" id="myTab">
<?php
$i = 0;
foreach($settings as $setting) {
if ($setting['type'] === 'category') {
?>
<li class="nav-item">
<a class="nav-link<?= ($i === 0 ? ' active' : ''); ?>" id="home-tab-<?= $i++; ?>" data-toggle="tab" href="#tab-<?= str_replace(' ', '', $setting['title']); ?>" type="button"><?= $setting['title']; ?></a>
</li>
<?php
}
}
?>
</ul>
<div class="tab-content" id="tab-content">
<?php
$checkbox = function ($key, $type, $value) {
echo '<label><input type="radio" id="' . $key . '" name="settings[' . $key . ']" value="' . ($type ? 'true' : 'false') . '" ' . ($value === $type ? 'checked' : '') . '/>' . ($type ? 'Yes' : 'No') . '</label> ';
};
$i = 0;
$j = 0;
foreach($settings as $key => $setting) {
if ($setting['type'] === 'category') {
if ($j++ !== 0) {
echo '</tbody></table></div>';
}
?>
<div class="tab-pane fade show<?= ($j === 1 ? ' active' : ''); ?>" id="tab-<?= str_replace(' ', '', $setting['title']); ?>">
<?php
continue;
}
if ($setting['type'] === 'section') {
if ($i++ !== 0) {
echo '</tbody></table>';
}
?>
<h2 style="text-align: center"><strong><?= $setting['title']; ?></strong></h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="width: 13%">Name</th>
<th style="width: 30%">Value</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<?php
continue;
}
if (!isset($setting['hidden']) || !$setting['hidden']) {
?>
<tr>
<td><label for="<?= $key ?>" class="control-label"><?= $setting['name'] ?></label></td>
<td>
<?php
}
if (isset($setting['hidden']) && $setting['hidden']) {
$value = '';
if ($setting['type'] === 'boolean') {
$value = ($setting['default'] ? 'true' : 'false');
}
else if (in_array($setting['type'], ['text', 'number', 'email', 'password', 'textarea'])) {
$value = $setting['default'];
}
else if ($setting['type'] === 'options') {
$value = $setting['options'][$setting['default']];
}
echo '<input type="hidden" name="settings[' . $key . ']" value="' . $value . '" id="' . $key . '"';
}
else if ($setting['type'] === 'boolean') {
if(isset($settingsDb[$key])) {
if($settingsDb[$key] === 'true') {
$value = true;
}
else {
$value = false;
}
}
else {
$value = ($setting['default'] ?? false);
}
$checkbox($key, true, $value);
$checkbox($key, false, $value);
}
else if (in_array($setting['type'], ['text', 'number', 'email', 'password'])) {
echo '<input class="form-control" type="' . $setting['type'] . '" name="settings[' . $key . ']" value="' . ($settingsDb[$key] ?? ($setting['default'] ?? '')) . '" id="' . $key . '"/>';
}
else if($setting['type'] === 'textarea') {
echo '<textarea class="form-control" name="settings[' . $key . ']" id="' . $key . '">' . ($settingsDb[$key] ?? ($setting['default'] ?? '')) . '</textarea>';
}
else if ($setting['type'] === 'options') {
if ($setting['options'] === '$templates') {
$templates = [];
foreach (get_templates() as $value) {
$templates[$value] = $value;
}
$setting['options'] = $templates;
}
else if($setting['options'] === '$clients') {
$clients = [];
foreach((array)config('clients') as $client) {
$client_version = (string)($client / 100);
if(strpos($client_version, '.') === false)
$client_version .= '.0';
$clients[$client] = $client_version;
}
$setting['options'] = $clients;
}
else {
if (is_string($setting['options'])) {
$setting['options'] = explode(',', $setting['options']);
foreach ($setting['options'] as &$option) {
$option = trim($option);
}
}
}
echo '<select class="form-control" name="settings[' . $key . ']" id="' . $key . '">';
foreach ($setting['options'] as $value => $option) {
$compareTo = (isset($settingsDb[$key]) ? $settingsDb[$key] : (isset($setting['default']) ? $setting['default'] : ''));
if($value === 'true') {
$selected = $compareTo === true;
}
else if($value === 'false') {
$selected = $compareTo === false;
}
else {
$selected = $compareTo == $value;
}
echo '<option value="' . $value . '" ' . ($selected ? 'selected' : '') . '>' . $option . '</option>';
}
echo '</select>';
}
if (!isset($setting['hidden']) || !$setting['hidden']) {
?>
</td>
<td>
<div class="well">
<?php
echo $setting['desc'];
echo '<br/>';
echo '<strong>Default:</strong> ';
if ($setting['type'] === 'boolean') {
echo ($setting['default'] ? 'Yes' : 'No');
}
else if (in_array($setting['type'], ['text', 'number', 'email', 'password', 'textarea'])) {
echo $setting['default'];
}
else if ($setting['type'] === 'options') {
echo $setting['options'][$setting['default']];
}
?>
</div>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div>
</div>
<div class="box-footer">
<button name="save" type="submit" class="btn btn-primary">Save</button>
</div>
<?php
return ob_get_clean();
}
#[\ReturnTypeWillChange] #[\ReturnTypeWillChange]
public function offsetSet($offset, $value) public function offsetSet($offset, $value)
{ {
@ -172,14 +376,21 @@ class Settings implements ArrayAccess
if ($pluginName === 'core') { if ($pluginName === 'core') {
$file = SYSTEM . 'settings.php'; $file = SYSTEM . 'settings.php';
} else { } else {
$file = PLUGINS . $pluginName . '/settings.php'; $pluginSettings = Plugins::getPluginSettings($pluginName);
if (!$pluginSettings) {
error('This plugin does not exist or does not have settings defined.');
return;
}
$settingsFilePath = BASE . $pluginSettings;
} }
if (!file_exists($file)) { if (!file_exists($file)) {
throw new \RuntimeException('Failed to load settings file for plugin: ' . $pluginName); throw new \RuntimeException('Failed to load settings file for plugin: ' . $pluginName);
} }
$this->plugins[$pluginName] = require $file; $tmp = require $file;
$this->plugins[$pluginName] = $tmp['settings'];
} }
} }
} }

View File

@ -244,7 +244,8 @@ class Plugins {
return $plugin_json; return $plugin_json;
} }
public static function install($file) { public static function install($file): bool
{
global $db; global $db;
if(!\class_exists('ZipArchive')) { if(!\class_exists('ZipArchive')) {

View File

@ -14,7 +14,7 @@ $title = 'Creatures';
if (empty($_REQUEST['name'])) { if (empty($_REQUEST['name'])) {
// display list of monsters // display list of monsters
$preview = config('creatures_images_preview'); $preview = config('monsters_images_preview');
$creatures = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 '.(empty($_REQUEST['boss']) ? '': 'AND `rewardboss` = 1').' ORDER BY name asc')->fetchAll(); $creatures = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 '.(empty($_REQUEST['boss']) ? '': 'AND `rewardboss` = 1').' ORDER BY name asc')->fetchAll();
if ($preview) { if ($preview) {
@ -62,7 +62,7 @@ if (isset($creature['name'])) {
$item['name'] = getItemNameById($item['id']); $item['name'] = getItemNameById($item['id']);
$item['rarity_chance'] = round($item['chance'] / 1000, 2); $item['rarity_chance'] = round($item['chance'] / 1000, 2);
$item['rarity'] = getItemRarity($item['chance']); $item['rarity'] = getItemRarity($item['chance']);
$item['tooltip'] = ucfirst($item['name']) . '<br/>Chance: ' . $item['rarity'] . (config('creatures_loot_percentage') ? ' ('. $item['rarity_chance'] .'%)' : '') . '<br/>Max count: ' . $item['count']; $item['tooltip'] = ucfirst($item['name']) . '<br/>Chance: ' . $item['rarity'] . (config('monsters_loot_percentage') ? ' ('. $item['rarity_chance'] .'%)' : '') . '<br/>Max count: ' . $item['count'];
} }
$creature['loot'] = isset($loot) ? $loot : null; $creature['loot'] = isset($loot) ? $loot : null;

View File

@ -1,449 +1,482 @@
<?php <?php
/**
* Possible types:
* - boolean - true/false
* - text - string
* - options - comma separated list of options
*/
return [ return [
'category_1' => [ 'name' => 'MyAAC',
'type' => 'category', 'settings' =>
'title' => 'General'
],
'section_1' => [
'type' => 'section',
'title' => 'Template'
],
'template' => [
'name' => 'Template Name',
'type' => 'options',
'options' => '$templates',
'desc' => 'Name of the template used by website',
'default' => 'kathrine',
],
'template_allow_change' => [
'name' => 'Template Allow Change',
'type' => 'boolean',
'desc' => 'Allow changing template of the website by showing a special select in the part of website',
'default' => true,
],
'section_2' => [
'type' => 'section',
'title' => 'Misc'
],
'vocations_amount' => [
'name' => 'Amount of Vocations',
'type' => 'number',
'desc' => 'how much basic vocations your server got (without promotion)',
'default' => 4,
],
'client' => [
'name' => 'Client Version',
'type' => 'options',
'options' => '$clients',
'desc' => 'what client version are you using on this OT?<br/>
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' => 'mod_rewrite is required for this, it makes links looks more elegant to eye, and also are SEO friendly (example: https://my-aac.org/guilds/Testing instead of https://my-aac.org/?subtopic=guilds&name=Testing).<br/><strong>Remember to rename .htaccess.dist to .htaccess</strong>',
'default' => false,
],
'backward_support' => [
'name' => 'Gesior Backward Support',
'type' => 'boolean',
'desc' => 'gesior backward support (templates & pages)<br/>
allows using gesior templates and pages with myaac<br/>
might bring some performance when disabled',
'default' => true,
],
'section_3' => [
'type' => 'section',
'title' => 'Meta Site Settings'
],
'charset' => [
'name' => 'Meta Charset',
'type' => 'text',
'desc' => 'Charset used in ' . escapeHtml('<meta>'),
'default' => 'utf-8',
],
'meta_description' => [
'name' => 'Meta Description',
'type' => 'textarea',
'desc' => 'description of the site in ' . escapeHtml('<meta>'),
'default' => 'Tibia is a free massive multiplayer online role playing game (MMORPG).',
],
'meta_keywords' => [
'name' => 'Meta Keywords',
'type' => 'textarea',
'desc' => 'keywords list separated by commas',
'default' => 'free online game, free multiplayer game, ots, open tibia server',
],
'footer' => [
'name' => 'Footer',
'type' => 'textarea',
'desc' => 'For example: "' . escapeHtml('<br/>') . 'Your Server &copy; 2020. All rights reserved."',
'default' => '',
],
/*'language' => [
'name' => 'Language',
'type' => 'options',
'options' => ['en' => 'English'],
'desc' => 'default language (currently only English available)',
'default' => 'en',
],*/
/*'language_allow_change' => [
'name' => 'Language Allow Change',
'type' => 'boolean',
'default' => false,
'desc' => 'default language (currently only English available)'
],*/
[ [
'type' => 'category', [
'title' => 'Counters', 'type' => 'category',
], 'title' => 'General'
[ ],
'type' => 'section', [
'title' => 'Visitors Counter & Views Counter' 'type' => 'section',
], 'title' => 'Template'
'visitors_counter' => [ ],
'name' => 'Visitors Counter', 'template' => [
'type' => 'boolean', 'name' => 'Template Name',
'desc' => 'Enable Visitors Counter? It will show list of online members on the website in Admin Panel', 'type' => 'options',
'default' => true, 'options' => '$templates',
], 'desc' => 'Name of the template used by website',
'visitors_counter_ttl' => [ 'default' => 'kathrine',
'name' => 'Visitors Counter TTL', ],
'type' => 'number', 'template_allow_change' => [
'desc' => 'Time To Live for Visitors Counter. In other words - how long user will be marked as online. In Minutes', 'name' => 'Template Allow Change',
'default' => 10 'type' => 'boolean',
], 'desc' => 'Allow changing template of the website by showing a special select in the part of website',
'views_counter' => [ 'default' => true,
'name' => 'Views Counter', ],
'type' => 'boolean', [
'desc' => 'Enable Views Counter? It will show how many times the website has been viewed by users', 'type' => 'section',
'default' => true, 'title' => escapeHtml('<meta>') . ' - Header'
], ],
[ 'charset' => [
'type' => 'category', 'name' => 'Meta Charset',
'title' => 'Account', 'type' => 'text',
], 'desc' => 'Charset used in ' . escapeHtml('<meta>'),
[ 'default' => 'utf-8',
'type' => 'section', ],
'title' => 'Account Settings' 'meta_description' => [
], 'name' => 'Meta Description',
'account_management' => [ 'type' => 'textarea',
'name' => 'Enable Account Management', 'desc' => 'description of the site in ' . escapeHtml('<meta>'),
'type' => 'boolean', 'default' => 'Tibia is a free massive multiplayer online role playing game (MMORPG).',
'desc' => "disable if you're using other method to manage users (fe. tfs account manager)", ],
'default' => true, 'meta_keywords' => [
], 'name' => 'Meta Keywords',
'account_login_by_email' => [ 'type' => 'textarea',
'name' => 'Account Login By E-Mail', 'desc' => 'keywords list separated by commas',
'type' => 'boolean', 'default' => 'free online game, free multiplayer game, ots, open tibia server',
'desc' => "use email instead of Account Name like in latest Tibia", ],
'default' => true, [
], 'type' => 'section',
'account_login_by_email_fallback' => [ 'title' => 'Footer'
'name' => 'Account Login By E-Mail Fallback', ],
'type' => 'boolean', 'footer' => [
'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", 'name' => 'Custom Text',
'default' => false, 'type' => 'textarea',
], 'desc' => 'Text displayed in the footer.<br/>For example: <i>' . escapeHtml('<br/>') . 'Your Server &copy; 2023. All rights reserved.</i>',
'account_create_auto_login' => [ 'default' => '',
'name' => 'Account Create Auto Login', ],
'type' => 'boolean', // do we really want this?
'desc' => 'Auto login after creating account?', /*
'default' => false, 'footer_powered_by' => [
], 'name' => 'Display Powered by MyAAC',
'account_create_character_create' => [ 'type' => 'boolean',
'name' => 'Account Create Character Create', 'desc' => 'Do you want to show powered by myaac slogan on the footer?',
'type' => 'boolean', 'default' => true,
'desc' => 'Allow to create character directly on create account page?', ],
'default' => true, */
], /*'language' => [
'account_mail_verify' => [ 'name' => 'Language',
'name' => 'Account Mail Verify', 'type' => 'options',
'type' => 'boolean', 'options' => ['en' => 'English'],
'desc' => 'Force users to confirm their email addresses when registering account', 'desc' => 'default language (currently only English available)',
'default' => false, 'default' => 'en',
], ],*/
'account_mail_unique' => [ /*'language_allow_change' => [
'name' => 'Account Mail Unique', 'name' => 'Language Allow Change',
'type' => 'boolean', 'type' => 'boolean',
'desc' => 'Email addresses cannot be duplicated? (one account = one email)', 'default' => false,
'default' => true, 'desc' => 'default language (currently only English available)'
], ],*/
'account_premium_days' => [ [
'name' => 'Default Account Premium Days', 'type' => 'section',
'type' => 'number', 'title' => 'Counters'
'desc' => 'Default premium days on new account', ],
'default' => 0, 'visitors_counter' => [
], 'name' => 'Visitors Counter',
'account_premium_points' => [ 'type' => 'boolean',
'name' => 'Default Account Premium Points', 'desc' => 'Enable Visitors Counter? It will show list of online members on the website in Admin Panel',
'type' => 'number', 'default' => true,
'desc' => 'Default premium points on new account', ],
'default' => 0, 'visitors_counter_ttl' => [
], 'name' => 'Visitors Counter TTL',
'account_welcome_mail' => [ 'type' => 'number',
'name' => 'Account Welcome Mail', 'desc' => 'Time To Live for Visitors Counter. In other words - how long user will be marked as online. In Minutes',
'type' => 'boolean', 'default' => 10
'desc' => 'Send welcome email when user registers', ],
'default' => true, 'views_counter' => [
], 'name' => 'Views Counter',
'account_mail_change' => [ 'type' => 'boolean',
'name' => 'Account Mail Change Days', 'desc' => 'Enable Views Counter? It will show how many times the website has been viewed by users',
'type' => 'number', 'default' => true,
'desc' => 'How many days user need to change email to account - block hackers', ],
'default' => 2, [
], 'type' => 'section',
'account_country' => [ 'title' => 'Misc'
'name' => 'Account Country', ],
'type' => 'boolean', 'vocations_amount' => [
'desc' => 'User will be able to set country of origin when registering account, this information will be viewable in others places as well', 'name' => 'Vocations Amount',
'default' => true, 'type' => 'number',
], 'desc' => 'How much basic vocations your server got (without promotion)',
'account_country_recognize' => [ 'default' => 4,
'name' => 'Auto Recognize Account Country', ],
'type' => 'boolean', 'vocations' => [
'desc' => 'should country of user be automatically recognized by his IP? This makes an external API call to http://ipinfo.io', 'name' => 'Vocation Names',
'default' => true, 'type' => 'textarea',
], 'desc' => 'Separated by comma ,',
[ 'default' => 'None, Sorcerer, Druid, Paladin, Knight, Master Sorcerer, Elder Druid,Royal Paladin, Elite Knight',
'type' => 'section', ],
'title' => 'Reward Users for confirming their E-Mails. Works only with Account Mail Verify enabled' 'client' => [
], 'name' => 'Client Version',
'account_mail_confirmed_reward_premium_days' => [ 'type' => 'options',
'name' => 'Reward Premium Points', 'options' => '$clients',
'type' => 'number', 'desc' => 'what client version are you using on this OT?<br/>used for the Downloads page and some templates aswell',
'desc' => '0 to disable', 'default' => 710
'default' => 0, ],
], 'session_prefix' => [
'account_mail_confirmed_reward_premium_points' => [ 'name' => 'Session Prefix',
'name' => 'Reward Premium Points', 'type' => 'text',
'type' => 'number', 'desc' => 'must be unique for every site on your server',
'desc' => '0 to disable', 'default' => 'myaac_',
'default' => 0, ],
], 'friendly_urls' => [
'account_mail_confirmed_reward_coins' => [ 'name' => 'Friendly URLs',
'name' => 'Reward Premium Points', 'type' => 'boolean',
'type' => 'number', 'desc' => 'It makes links looks more elegant to eye, and also are SEO friendly<br/><br/>
'desc' => '0 to disable. Works only with servers that supports coins', yes: http://example.net/guilds/Testing<br/>
'default' => 0, no: http://example.net/?subtopic=guilds&name=Testing<br/><br/>
], <strong>apache2:</strong> mod_rewrite is required for this + remember to rename .htaccess.dist to .htaccess<br/>
[ <strong>nginx:</strong> check included nginx-sample.conf',
'type' => 'category', 'default' => false,
'title' => 'Images', ],
], 'backward_support' => [
[ 'name' => 'Gesior Backward Support',
'type' => 'section', 'type' => 'boolean',
'title' => 'Item and Outfit Images' 'desc' => 'gesior backward support (templates & pages)<br/>
], allows using gesior templates and pages with myaac<br/>
'outfit_images_url' => [ might bring some performance when disabled',
'name' => 'Outfit Images URL', 'default' => true,
'type' => 'text', ],
'desc' => 'Set to animoutfit.php for animated outfit', [
'default' => 'http://outfit-images.ots.me/outfit.php', 'type' => 'category',
], 'title' => 'Accounts',
'outfit_images_wrong_looktypes' => [ ],
'name' => 'Outfit Images Wrong Looktypes', [
'type' => 'text', 'type' => 'section',
'desc' => 'This looktypes needs to have different margin-top and margin-left because they are wrong positioned', 'title' => 'Accounts Settings'
'default' => '75, 126, 127, 266, 302', ],
], 'account_management' => [
'item_images_url' => [ 'name' => 'Enable Account Management',
'name' => 'Item Images URL', 'type' => 'boolean',
'type' => 'text', 'desc' => "disable if you're using other method to manage users (fe. tfs account manager)",
'desc' => 'Set to images/items if you host your own items in images folder', 'default' => true,
'default' => 'http://item-images.ots.me/1092/', ],
], 'account_login_by_email' => [
'item_images_extension' => [ 'name' => 'Account Login By E-Mail',
'name' => 'Item Images File Extension', 'type' => 'boolean',
'type' => 'text', 'desc' => "use email instead of Account Name like in latest Tibia",
'desc' => '', 'default' => true,
'default' => '.gif', ],
], 'account_login_by_email_fallback' => [
[ 'name' => 'Account Login By E-Mail Fallback',
'type' => 'section', 'type' => 'boolean',
'title' => 'Monsters images' '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,
'creatures_images_url' => [ ],
'name' => 'Creatures images URL', 'account_create_auto_login' => [
'type' => 'text', 'name' => 'Account Create Auto Login',
'desc' => 'Set to images/monsters if you host your own creatures in images folder', 'type' => 'boolean',
'default' => 'images/monsters/', 'desc' => 'Auto login after creating account?',
], 'default' => false,
'creatures_images_extension' => [ ],
'name' => 'Creatures Images File Extension', 'account_create_character_create' => [
'type' => 'text', 'name' => 'Account Create Character Create',
'desc' => '', 'type' => 'boolean',
'default' => '.gif', 'desc' => 'Allow to create character directly on create account page?',
], 'default' => true,
'creatures_images_preview' => [ ],
'name' => 'Item Images URL', 'account_mail_verify' => [
'type' => 'boolean', 'name' => 'Account Mail Verify',
'desc' => 'Set to true to allow picture previews for creatures', 'type' => 'boolean',
'default' => false, 'desc' => 'Force users to confirm their email addresses when registering account',
], 'default' => false,
'creatures_items_url' => [ ],
'name' => 'Creatures Items URL', 'account_mail_unique' => [
'type' => 'text', 'name' => 'Account Mail Unique',
'desc' => 'Set to website which shows details about items', 'type' => 'boolean',
'default' => 'https://tibia.fandom.com/wiki/', 'desc' => 'Email addresses cannot be duplicated? (one account = one email)',
], 'default' => true,
'creatures_loot_percentage' => [ ],
'name' => 'Creatures Items URL', 'account_premium_days' => [
'type' => 'boolean', 'name' => 'Default Account Premium Days',
'desc' => 'Set to true to show the loot tooltip percent', 'type' => 'number',
'default' => true, 'desc' => 'Default premium days on new account',
], 'default' => 0,
[ ],
'type' => 'category', 'account_premium_points' => [
'title' => 'Guilds', 'name' => 'Default Account Premium Points',
], 'type' => 'number',
[ 'desc' => 'Default premium points on new account',
'type' => 'section', 'default' => 0,
'title' => 'Guilds' ],
], 'account_welcome_mail' => [
'guild_management' => [ 'name' => 'Account Welcome Mail',
'name' => 'Enable Guilds Management', 'type' => 'boolean',
'type' => 'boolean', 'desc' => 'Send welcome email when user registers',
'desc' => 'Enable guild management system on the site', 'default' => true,
'default' => true, ],
], 'account_mail_change' => [
'guild_need_level' => [ 'name' => 'Account Mail Change Days',
'name' => 'Guild Need Level', 'type' => 'number',
'type' => 'number', 'desc' => 'How many days user need to change email to account - block hackers',
'desc' => 'Min. level to form a guild', 'default' => 2,
'default' => 1, ],
], 'account_country' => [
'guild_need_premium' => [ 'name' => 'Account Country',
'name' => 'Guild Need Premium', 'type' => 'boolean',
'type' => 'boolean', 'desc' => 'User will be able to set country of origin when registering account, this information will be viewable in others places as well',
'desc' => 'Require premium account to form a guild?', 'default' => true,
'default' => true, ],
], 'account_country_recognize' => [
'guild_image_size_kb' => [ 'name' => 'Auto Recognize Account Country',
'name' => 'Guild Image Size', 'type' => 'boolean',
'type' => 'number', 'desc' => 'should country of user be automatically recognized by his IP? This makes an external API call to http://ipinfo.io',
'desc' => 'Maximum size of the guild logo image in KB (kilobytes)', 'default' => true,
'default' => 80, ],
], [
'guild_description_default' => [ 'type' => 'section',
'name' => 'Default Guild Description', 'title' => 'Reward Users for confirming their E-Mails. Works only with Account Mail Verify enabled'
'type' => 'text', ],
'desc' => 'Default description set on new guild', 'account_mail_confirmed_reward_premium_days' => [
'default' => 'New guild. Leader must edit this text :)', 'name' => 'Reward Premium Points',
], 'type' => 'number',
'guild_description_chars_limit' => [ 'desc' => '0 to disable',
'name' => 'Guild Description Characters Limit', 'default' => 0,
'type' => 'boolean', ],
'desc' => 'How many characters can be in guild description', 'account_mail_confirmed_reward_premium_points' => [
'default' => 1000, 'name' => 'Reward Premium Points',
], 'type' => 'number',
'guild_description_lines_limit' => [ 'desc' => '0 to disable',
'name' => 'Guild Description Lines Limit', 'default' => 0,
'type' => 'number', ],
'desc' => "Limit of lines, if description has more lines it will be showed as long text, without 'enters'", 'account_mail_confirmed_reward_coins' => [
'default' => 6, 'name' => 'Reward Premium Points',
], 'type' => 'number',
'guild_motd_chars_limit' => [ 'desc' => '0 to disable. Works only with servers that supports coins',
'name' => 'Guild MOTD Characters Limit', 'default' => 0,
'type' => 'boolean', ],
'desc' => 'Limit of MOTD (message of the day) that is shown later in the game on the guild channel', [
'default' => 150, 'type' => 'category',
], 'title' => 'Guilds',
[ ],
'type' => 'category', [
'title' => 'Pages', 'type' => 'section',
], 'title' => 'Guilds'
'section_10' => [ ],
'type' => 'section', 'guild_management' => [
'title' => 'Online Page' 'name' => 'Enable Guilds Management',
], 'type' => 'boolean',
'online_record' => [ 'desc' => 'Enable guild management system on the site',
'name' => 'Display Players Record', 'default' => true,
'type' => 'boolean', ],
'desc' => '', 'guild_need_level' => [
'default' => true, 'name' => 'Guild Need Level',
], 'type' => 'number',
'online_vocations' => [ 'desc' => 'Min. level to form a guild',
'name' => 'Display Vocation Statistics', 'default' => 1,
'type' => 'boolean', ],
'desc' => '', 'guild_need_premium' => [
'default' => false, 'name' => 'Guild Need Premium',
], 'type' => 'boolean',
'online_vocations_images' => [ 'desc' => 'Require premium account to form a guild?',
'name' => 'Display Vocation Images', 'default' => true,
'type' => 'boolean', ],
'desc' => 'Only if Display Vocation Statistics enabled', 'guild_image_size_kb' => [
'default' => true, 'name' => 'Guild Image Size',
], 'type' => 'number',
'online_skulls' => [ 'desc' => 'Maximum size of the guild logo image in KB (kilobytes)',
'name' => 'Display skull images', 'default' => 80,
'type' => 'boolean', ],
'desc' => '', 'guild_description_default' => [
'default' => true, 'name' => 'Default Guild Description',
], 'type' => 'text',
'online_outfit' => [ 'desc' => 'Default description set on new guild',
'name' => 'Display Player Outfit', 'default' => 'New guild. Leader must edit this text :)',
'type' => 'boolean', ],
'desc' => '', 'guild_description_chars_limit' => [
'default' => true, 'name' => 'Guild Description Characters Limit',
], 'type' => 'number',
'online_afk' => [ 'desc' => 'How many characters can be in guild description',
'name' => 'Display Players AFK', 'default' => 1000,
'type' => 'boolean', ],
'desc' => '', 'guild_description_lines_limit' => [
'default' => false, 'name' => 'Guild Description Lines Limit',
], 'type' => 'number',
[ 'desc' => "Limit of lines, if description has more lines it will be showed as long text, without 'enters'",
'type' => 'section', 'default' => 6,
'title' => 'Team Page' ],
], 'guild_motd_chars_limit' => [
'team_style' => [ 'name' => 'Guild MOTD Characters Limit',
'name' => 'Style', 'type' => 'number',
'type' => 'options', 'desc' => 'Limit of MOTD (message of the day) that is shown later in the game on the guild channel',
'desc' => '', 'default' => 150,
'options' => ['normal table', 'in boxes, grouped by group id'], ],
'default' => 2, [
], 'type' => 'category',
'team_display_status' => [ 'title' => 'Pages',
'name' => 'Display Online Status', ],
'type' => 'boolean', [
'desc' => '', 'type' => 'section',
'default' => true, 'title' => 'Online Page'
], ],
'team_display_lastlogin' => [ 'online_record' => [
'name' => 'Display Last Login', 'name' => 'Display Players Record',
'type' => 'boolean', 'type' => 'boolean',
'desc' => '', 'desc' => '',
'default' => true, 'default' => true,
], ],
'team_display_world' => [ 'online_vocations' => [
'name' => 'Display World', 'name' => 'Display Vocation Statistics',
'type' => 'boolean', 'type' => 'boolean',
'desc' => '', 'desc' => '',
'default' => false, 'default' => false,
], ],
'team_display_outfit' => [ 'online_vocations_images' => [
'name' => 'Display Outfit', 'name' => 'Display Vocation Images',
'type' => 'boolean', 'type' => 'boolean',
'desc' => '', 'desc' => 'Only if Display Vocation Statistics enabled',
'default' => true, 'default' => true,
], ],
[ 'online_skulls' => [
'type' => 'section', 'name' => 'Display Skull Images',
'title' => 'Bans Page' 'type' => 'boolean',
], 'desc' => '',
'bans_per_page' => [ 'default' => true,
'name' => 'Display Players Record', ],
'type' => 'boolean', 'online_outfit' => [
'desc' => '', 'name' => 'Display Player Outfit',
'default' => true, 'type' => 'boolean',
'desc' => '',
'default' => true,
],
'online_afk' => [
'name' => 'Display AFK Players',
'type' => 'boolean',
'desc' => '',
'default' => false,
],
[
'type' => 'section',
'title' => 'Team Page'
],
'team_style' => [
'name' => 'Style',
'type' => 'options',
'desc' => '',
'options' => ['normal table', 'in boxes, grouped by group id'],
'default' => 1,
],
'team_display_status' => [
'name' => 'Display Online Status',
'type' => 'boolean',
'desc' => '',
'default' => true,
],
'team_display_lastlogin' => [
'name' => 'Display Last Login',
'type' => 'boolean',
'desc' => '',
'default' => true,
],
'team_display_world' => [
'name' => 'Display World',
'type' => 'boolean',
'desc' => '',
'default' => false,
],
'team_display_outfit' => [
'name' => 'Display Outfit',
'type' => 'boolean',
'desc' => '',
'default' => true,
],
[
'type' => 'section',
'title' => 'Bans Page'
],
'bans_per_page' => [
'name' => 'Display Players Record',
'type' => 'boolean',
'desc' => '',
'default' => true,
],
[
'type' => 'category',
'title' => 'Images',
],
[
'type' => 'section',
'title' => 'Item and Outfit Images'
],
'outfit_images_url' => [
'name' => 'Outfit Images URL',
'type' => 'text',
'desc' => 'Set to animoutfit.php for animated outfit',
'default' => 'http://outfit-images.ots.me/outfit.php',
],
'outfit_images_wrong_looktypes' => [
'name' => 'Outfit Images Wrong Looktypes',
'type' => 'text',
'desc' => 'This looktypes needs to have different margin-top and margin-left because they are wrong positioned',
'default' => '75, 126, 127, 266, 302',
],
'item_images_url' => [
'name' => 'Item Images URL',
'type' => 'text',
'desc' => 'Set to <strong>images/items</strong> if you host your own items in images folder',
'default' => 'http://item-images.ots.me/1092/',
],
'item_images_extension' => [
'name' => 'Item Images File Extension',
'type' => 'text',
'desc' => '',
'default' => '.gif',
],
[
'type' => 'section',
'title' => 'Monsters Images'
],
'monsters_images_url' => [
'name' => 'Monsters Images URL',
'type' => 'text',
'desc' => 'Set to <i>images/monsters/</i> if you host your own creatures in images folder',
'default' => 'images/monsters/',
],
'monsters_images_extension' => [
'name' => 'Monsters Images File Extension',
'type' => 'text',
'desc' => '',
'default' => '.gif',
],
'monsters_images_preview' => [
'name' => 'Item Images URL',
'type' => 'boolean',
'desc' => 'Set to true to allow picture previews for creatures',
'default' => false,
],
'monsters_items_url' => [
'name' => 'Creatures Items URL',
'type' => 'text',
'desc' => 'Set to website which shows details about items',
'default' => 'https://tibia.fandom.com/wiki/',
],
'monsters_loot_percentage' => [
'name' => 'Creatures Items URL',
'type' => 'boolean',
'desc' => 'Set to true to show the loot tooltip percent',
'default' => true,
],
'multiworld' => [
'hidden' => true,
'type' => 'boolean',
'default' => false,
],
], ],
]; ];

View File

@ -0,0 +1,20 @@
<div class="card card-primary card-outline card-outline-tabs">
<div class="card-header">
<h5 class="m-0">Settings</h5>
</div>
<div class="card-body">
<form method="post">
<div class="row">
<div class="col-md-12">
<div class="box">
<div class="box-body">
<button name="save" type="submit" class="btn btn-primary">Save</button>
</div>
<br/>
{{ settings|raw }}
</div>
</div>
</div>
</form>
</div>
</div>

View File

@ -155,7 +155,7 @@
{% if (item.count > 1) %} {% if (item.count > 1) %}
<span class="loot_amount">{{ item.count }}</span> <span class="loot_amount">{{ item.count }}</span>
{% endif %} {% endif %}
<a href="{{ config.creatures_items_url }}{{ item.name|title }}"><img title="{{ item.tooltip }}" src="{{ config.item_images_url }}{{ item.id }}{{ config.item_images_extension }}" class="loot_image"/></a> <a href="{{ config.monsters_items_url }}{{ item.name|title }}"><img title="{{ item.tooltip }}" src="{{ config.item_images_url }}{{ item.id }}{{ config.item_images_extension }}" class="loot_image"/></a>
</span> </span>
{% endfor %} {% endfor %}
</td> </td>