mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-14 01:34:55 +02:00
Feature: settings (#216)
* New admin panel Pages: Options + Config [WIP] * Forgot the plugin example of options * Rename to settings.php * Add Settings Class * New myaac_settings table * Add $limit parameter to $db->select method * Add $member var annotation * Remove useless title_separator from config * Move $menus to menus.php Also fix active link when menu item has subpage * Settings [WIP] New Settings class New Plugins::load() method Move config.php to settings.php MyAAC Settings will have plugin_name = 'core' Add compat_config.php * Change options.php to settings.php * Change name to settings * Add Settings menu * Add Sections + Add setting($key) function Reorganisation * Add email + password fields as type * Update 33.php * add settings migration * php 8 compatibility * add missing hook * Add categories in tabs, move more settings, revert back getPluginSettings Categories and sections are now not numbered Remove example settings plugin * fix typo * Update .gitignore * Add 36th migration for settings table * Execute migrations just after db connect * Update plugins.php * [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 * Rename * Fix path * [WIP] More work on settings Move more config to settings (mainly mail_* + some other) Remove mail_admin, wasnt used anywhere Add return type to some functions Add Twig settings(key) function Possibility to save setting to db * Add min, max, step to number field option * Re-enable plugin if disabled and already installed * Add Settings menu, including all plugins with settings One change included in previous commit, due to missclick * Nothing important * Better boolean detection * More detailed error message in settings * Lets call it settings.name instead * Add new function: only_if, to hide fields when they are not enabled [WIP] Not fully finished yet * guild_management: show_if * Hide section title on show_if * Fix: check on page load if radio button is checked * Add: show_if - account_mail_verify * nothing important * Rename team_* variables + add to deprecated * Change variable name * Extract Settings:save function * Add settings.callbacks.get * Move forum config to settings * Move status config to settings * Remove whitespaces * More config to settings: account_types, genders, highscores, admin * Move signature config to settings * Move news config to settings * Rename variable * Save config.php in Settings Egg and hen problem solved :) * Test database connection on save settings -> prevents from making website unusable if connection is wrong * Test server_path -> same There is no config.php anymore, just config.local.php, which can be edited manually and also from admin panel * Remove configs from previous commit * Fix create account, if account_create_character_create is enabled * Add more deprecated configs * Add more info into comment * Update 5-database.php * Fix menu highlighting & opening * Update template.php * Enable script option * Reword email settings + move two new settings * add last_kills_limit + move shop * google_analytics_id * add mail_lost_account_interval * Create character blocked words (by @gpedro), just moved to settings * Fix google_analytics * create character name config moved to settings * Fix for install warning - min/max length * New create character checks configurable: block monsters & spells names * fixes * Improve character npc name check * New setting: donate_column + move donate config to settings * Add super fancy No Refresh saving with a toast * Add new possibility: to deny saving setting if condition is not met * Move database settings to separate category * Fix default value displaying * Add database_hash setting * add last_kills_limit to compat config * Move create character blocked names down * Every setting needs to have default * Move rest of config to settings Remove config.php completely Add new settings category: Game Fix account_login_by_email Min textarea size = 2 + adjusted automatically
This commit is contained in:
103
system/compat/config.php
Normal file
103
system/compat/config.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
$deprecatedConfig = [
|
||||
'date_timezone',
|
||||
'genders',
|
||||
'template',
|
||||
'template_allow_change',
|
||||
'vocations_amount',
|
||||
'vocations',
|
||||
'client',
|
||||
'session_prefix',
|
||||
'friendly_urls',
|
||||
'backward_support',
|
||||
'charset',
|
||||
'meta_description',
|
||||
'meta_keywords',
|
||||
'footer',
|
||||
'database_encryption' => 'database_hash',
|
||||
//'language',
|
||||
'visitors_counter',
|
||||
'visitors_counter_ttl',
|
||||
'views_counter',
|
||||
'outfit_images_url',
|
||||
'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',
|
||||
'news_date_format',
|
||||
'highscores_groups_hidden',
|
||||
'highscores_ids_hidden',
|
||||
'online_record',
|
||||
'online_vocations',
|
||||
'online_vocations_images',
|
||||
'online_skulls',
|
||||
'online_outfit',
|
||||
'online_afk',
|
||||
'team_display_outfit' => 'team_outfit',
|
||||
'team_display_status' => 'team_status',
|
||||
'team_display_world' => 'team_world',
|
||||
'team_display_lastlogin' => 'team_lastlogin',
|
||||
'last_kills_limit',
|
||||
'multiworld',
|
||||
'forum',
|
||||
'signature_enabled',
|
||||
'signature_type',
|
||||
'signature_cache_time',
|
||||
'signature_browser_cache',
|
||||
'gifts_system',
|
||||
'status_enabled',
|
||||
'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',
|
||||
'account_change_character_name_points' => 'account_change_character_name_price',
|
||||
'account_change_character_sex',
|
||||
'account_change_character_sex_points' => 'account_change_character_name_price',
|
||||
];
|
||||
|
||||
foreach ($deprecatedConfig as $key => $value) {
|
||||
config(
|
||||
[
|
||||
(is_string($key) ? $key : $value),
|
||||
setting('core.'.$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);
|
@@ -9,7 +9,11 @@
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if(!isset($config['database_user'][0], $config['database_password'][0], $config['database_name'][0]))
|
||||
if (!isset($config['database_overwrite'])) {
|
||||
$config['database_overwrite'] = false;
|
||||
}
|
||||
|
||||
if(!$config['database_overwrite'] && !isset($config['database_user'][0], $config['database_password'][0], $config['database_name'][0]))
|
||||
{
|
||||
if(isset($config['lua']['sqlType'])) {// tfs 0.3
|
||||
if(isset($config['lua']['mysqlHost'])) {// tfs 0.2
|
||||
@@ -116,4 +120,4 @@ catch(PDOException $error) {
|
||||
'<li>MySQL is not configured propertly in <i>config.lua</i>.</li>' .
|
||||
'<li>MySQL server is not running.</li>' .
|
||||
'</ul>' . $error->getMessage());
|
||||
}
|
||||
}
|
||||
|
@@ -32,55 +32,49 @@ function message($message, $type, $return)
|
||||
return true;
|
||||
}
|
||||
function success($message, $return = false) {
|
||||
return message($message, 'success', $return);
|
||||
return message($message, 'success', $return);
|
||||
}
|
||||
function warning($message, $return = false) {
|
||||
return message($message, 'warning', $return);
|
||||
return message($message, 'warning', $return);
|
||||
}
|
||||
function note($message, $return = false) {
|
||||
return message($message, 'note', $return);
|
||||
return message($message, 'note', $return);
|
||||
}
|
||||
function error($message, $return = false) {
|
||||
return message($message, ((defined('MYAAC_INSTALL') || defined('MYAAC_ADMIN')) ? 'danger' : 'error'), $return);
|
||||
return message($message, ((defined('MYAAC_INSTALL') || defined('MYAAC_ADMIN')) ? 'danger' : 'error'), $return);
|
||||
}
|
||||
|
||||
function longToIp($ip)
|
||||
function longToIp($ip): string
|
||||
{
|
||||
$exp = explode(".", long2ip($ip));
|
||||
return $exp[3].".".$exp[2].".".$exp[1].".".$exp[0];
|
||||
}
|
||||
|
||||
function generateLink($url, $name, $blank = false) {
|
||||
function generateLink($url, $name, $blank = false): string {
|
||||
return '<a href="' . $url . '"' . ($blank ? ' target="_blank"' : '') . '>' . $name . '</a>';
|
||||
}
|
||||
|
||||
function getFullLink($page, $name, $blank = false) {
|
||||
function getFullLink($page, $name, $blank = false): string {
|
||||
return generateLink(getLink($page), $name, $blank);
|
||||
}
|
||||
|
||||
function getLink($page, $action = null)
|
||||
{
|
||||
global $config;
|
||||
return BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . $page . ($action ? '/' . $action : '');
|
||||
function getLink($page, $action = null): string {
|
||||
return BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . $page . ($action ? '/' . $action : '');
|
||||
}
|
||||
function internalLayoutLink($page, $action = null) {return getLink($page, $action);}
|
||||
|
||||
function getForumThreadLink($thread_id, $page = NULL)
|
||||
{
|
||||
global $config;
|
||||
return BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . 'forum/thread/' . (int)$thread_id . (isset($page) ? '/' . $page : '');
|
||||
function internalLayoutLink($page, $action = null): string {
|
||||
return getLink($page, $action);
|
||||
}
|
||||
|
||||
function getForumBoardLink($board_id, $page = NULL)
|
||||
{
|
||||
global $config;
|
||||
return BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . 'forum/board/' . (int)$board_id . (isset($page) ? '/' . $page : '');
|
||||
function getForumThreadLink($thread_id, $page = NULL): string {
|
||||
return BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'forum/thread/' . (int)$thread_id . (isset($page) ? '/' . $page : '');
|
||||
}
|
||||
|
||||
function getPlayerLink($name, $generate = true)
|
||||
{
|
||||
global $config;
|
||||
function getForumBoardLink($board_id, $page = NULL): string {
|
||||
return BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'forum/board/' . (int)$board_id . (isset($page) ? '/' . $page : '');
|
||||
}
|
||||
|
||||
function getPlayerLink($name, $generate = true): string
|
||||
{
|
||||
if(is_numeric($name))
|
||||
{
|
||||
$player = new OTS_Player();
|
||||
@@ -89,25 +83,23 @@ function getPlayerLink($name, $generate = true)
|
||||
$name = $player->getName();
|
||||
}
|
||||
|
||||
$url = BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . 'characters/' . urlencode($name);
|
||||
$url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'characters/' . urlencode($name);
|
||||
|
||||
if(!$generate) return $url;
|
||||
return generateLink($url, $name);
|
||||
}
|
||||
|
||||
function getMonsterLink($name, $generate = true)
|
||||
function getMonsterLink($name, $generate = true): string
|
||||
{
|
||||
global $config;
|
||||
|
||||
$url = BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . 'creatures/' . urlencode($name);
|
||||
$url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'creatures/' . urlencode($name);
|
||||
|
||||
if(!$generate) return $url;
|
||||
return generateLink($url, $name);
|
||||
}
|
||||
|
||||
function getHouseLink($name, $generate = true)
|
||||
function getHouseLink($name, $generate = true): string
|
||||
{
|
||||
global $db, $config;
|
||||
global $db;
|
||||
|
||||
if(is_numeric($name))
|
||||
{
|
||||
@@ -117,16 +109,14 @@ function getHouseLink($name, $generate = true)
|
||||
$name = $house->fetchColumn();
|
||||
}
|
||||
|
||||
$url = BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . 'houses/' . urlencode($name);
|
||||
$url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'houses/' . urlencode($name);
|
||||
|
||||
if(!$generate) return $url;
|
||||
return generateLink($url, $name);
|
||||
}
|
||||
|
||||
function getGuildLink($name, $generate = true)
|
||||
function getGuildLink($name, $generate = true): string
|
||||
{
|
||||
global $config;
|
||||
|
||||
if(is_numeric($name)) {
|
||||
$name = getGuildNameById($name);
|
||||
if ($name === false) {
|
||||
@@ -134,7 +124,7 @@ function getGuildLink($name, $generate = true)
|
||||
}
|
||||
}
|
||||
|
||||
$url = BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . 'guilds/' . urlencode($name);
|
||||
$url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'guilds/' . urlencode($name);
|
||||
|
||||
if(!$generate) return $url;
|
||||
return generateLink($url, $name);
|
||||
@@ -180,7 +170,7 @@ function getItemRarity($chance) {
|
||||
return '';
|
||||
}
|
||||
|
||||
function getFlagImage($country)
|
||||
function getFlagImage($country): string
|
||||
{
|
||||
if(!isset($country[0]))
|
||||
return '';
|
||||
@@ -202,7 +192,7 @@ function getFlagImage($country)
|
||||
* @param mixed $v Variable to check.
|
||||
* @return bool Value boolean status.
|
||||
*/
|
||||
function getBoolean($v)
|
||||
function getBoolean($v): bool
|
||||
{
|
||||
if(is_bool($v)) {
|
||||
return $v;
|
||||
@@ -225,7 +215,7 @@ function getBoolean($v)
|
||||
* @param bool $special Should special characters by used?
|
||||
* @return string Generated string.
|
||||
*/
|
||||
function generateRandomString($length, $lowCase = true, $upCase = false, $numeric = false, $special = false)
|
||||
function generateRandomString($length, $lowCase = true, $upCase = false, $numeric = false, $special = false): string
|
||||
{
|
||||
$characters = '';
|
||||
if($lowCase)
|
||||
@@ -465,7 +455,7 @@ function tickers()
|
||||
* Types: head_start, head_end, body_start, body_end, center_top
|
||||
*
|
||||
*/
|
||||
function template_place_holder($type)
|
||||
function template_place_holder($type): string
|
||||
{
|
||||
global $twig, $template_place_holders;
|
||||
$ret = '';
|
||||
@@ -489,7 +479,7 @@ function template_place_holder($type)
|
||||
/**
|
||||
* Returns <head> content to be used by templates.
|
||||
*/
|
||||
function template_header($is_admin = false)
|
||||
function template_header($is_admin = false): string
|
||||
{
|
||||
global $title_full, $config, $twig;
|
||||
$charset = isset($config['charset']) ? $config['charset'] : 'utf-8';
|
||||
@@ -506,29 +496,32 @@ function template_header($is_admin = false)
|
||||
/**
|
||||
* Returns footer content to be used by templates.
|
||||
*/
|
||||
function template_footer()
|
||||
function template_footer(): string
|
||||
{
|
||||
global $config, $views_counter;
|
||||
global $views_counter;
|
||||
$ret = '';
|
||||
if(admin())
|
||||
if(admin()) {
|
||||
$ret .= generateLink(ADMIN_URL, 'Admin Panel', true);
|
||||
}
|
||||
|
||||
if($config['visitors_counter'])
|
||||
{
|
||||
if(setting('core.visitors_counter')) {
|
||||
global $visitors;
|
||||
$amount = $visitors->getAmountVisitors();
|
||||
$ret .= '<br/>Currently there ' . ($amount > 1 ? 'are' : 'is') . ' ' . $amount . ' visitor' . ($amount > 1 ? 's' : '') . '.';
|
||||
}
|
||||
|
||||
if($config['views_counter'])
|
||||
if(setting('core.views_counter')) {
|
||||
$ret .= '<br/>Page has been viewed ' . $views_counter . ' times.';
|
||||
}
|
||||
|
||||
if(config('footer_show_load_time')) {
|
||||
if(setting('core.footer_load_time')) {
|
||||
$ret .= '<br/>Load time: ' . round(microtime(true) - START_TIME, 4) . ' seconds.';
|
||||
}
|
||||
|
||||
if(isset($config['footer'][0]))
|
||||
$ret .= '<br/>' . $config['footer'];
|
||||
$settingFooter = setting('core.footer');
|
||||
if(isset($settingFooter[0])) {
|
||||
$ret .= '<br/>' . $settingFooter;
|
||||
}
|
||||
|
||||
// please respect my work and help spreading the word, thanks!
|
||||
return $ret . '<br/>' . base64_decode('UG93ZXJlZCBieSA8YSBocmVmPSJodHRwOi8vbXktYWFjLm9yZyIgdGFyZ2V0PSJfYmxhbmsiPk15QUFDLjwvYT4=');
|
||||
@@ -536,8 +529,8 @@ function template_footer()
|
||||
|
||||
function template_ga_code()
|
||||
{
|
||||
global $config, $twig;
|
||||
if(!isset($config['google_analytics_id'][0]))
|
||||
global $twig;
|
||||
if(!isset(setting('core.google_analytics_id')[0]))
|
||||
return '';
|
||||
|
||||
return $twig->render('google_analytics.html.twig');
|
||||
@@ -822,7 +815,7 @@ function getWorldName($id)
|
||||
|
||||
/**
|
||||
* Mailing users.
|
||||
* $config['mail_enabled'] have to be enabled.
|
||||
* Mailing has to be enabled in settings (in Admin Panel).
|
||||
*
|
||||
* @param string $to Recipient email address.
|
||||
* @param string $subject Subject of the message.
|
||||
@@ -834,8 +827,9 @@ function _mail($to, $subject, $body, $altBody = '', $add_html_tags = true)
|
||||
{
|
||||
global $mailer, $config;
|
||||
|
||||
if (!config('mail_enabled')) {
|
||||
log_append('mailer-error.log', '_mail() function has been used, but config.mail_enabled is disabled.');
|
||||
if (!setting('core.mail_enabled')) {
|
||||
log_append('mailer-error.log', '_mail() function has been used, but Mail Support is disabled.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$mailer)
|
||||
@@ -847,47 +841,60 @@ function _mail($to, $subject, $body, $altBody = '', $add_html_tags = true)
|
||||
$mailer->clearAllRecipients();
|
||||
}
|
||||
|
||||
$signature_html = '';
|
||||
if(isset($config['mail_signature']['html']))
|
||||
$signature_html = $config['mail_signature']['html'];
|
||||
|
||||
$signature_html = setting('core.mail_signature_html');
|
||||
if($add_html_tags && isset($body[0]))
|
||||
$tmp_body = '<html><head></head><body>' . $body . '<br/><br/>' . $signature_html . '</body></html>';
|
||||
else
|
||||
$tmp_body = $body . '<br/><br/>' . $signature_html;
|
||||
|
||||
if($config['smtp_enabled'])
|
||||
define('MAIL_MAIL', 0);
|
||||
define('MAIL_SMTP', 1);
|
||||
|
||||
$mailOption = setting('core.mail_option');
|
||||
if($mailOption == MAIL_SMTP)
|
||||
{
|
||||
$mailer->isSMTP();
|
||||
$mailer->Host = $config['smtp_host'];
|
||||
$mailer->Port = (int)$config['smtp_port'];
|
||||
$mailer->SMTPAuth = $config['smtp_auth'];
|
||||
$mailer->Username = $config['smtp_user'];
|
||||
$mailer->Password = $config['smtp_pass'];
|
||||
$mailer->SMTPSecure = isset($config['smtp_secure']) ? $config['smtp_secure'] : '';
|
||||
$mailer->Host = setting('core.smtp_host');
|
||||
$mailer->Port = setting('core.smtp_port');
|
||||
$mailer->SMTPAuth = setting('core.smtp_auth');
|
||||
$mailer->Username = setting('core.smtp_user');
|
||||
$mailer->Password = setting('core.smtp_pass');
|
||||
|
||||
define('SMTP_SECURITY_NONE', 0);
|
||||
define('SMTP_SECURITY_SSL', 1);
|
||||
define('SMTP_SECURITY_TLS', 2);
|
||||
|
||||
$security = setting('core.smtp_security');
|
||||
|
||||
$tmp = '';
|
||||
if ($security === SMTP_SECURITY_SSL) {
|
||||
$tmp = 'ssl';
|
||||
}
|
||||
else if ($security == SMTP_SECURITY_TLS) {
|
||||
$tmp = 'tls';
|
||||
}
|
||||
|
||||
$mailer->SMTPSecure = $tmp;
|
||||
}
|
||||
else {
|
||||
$mailer->isMail();
|
||||
}
|
||||
|
||||
$mailer->isHTML(isset($body[0]) > 0);
|
||||
$mailer->From = $config['mail_address'];
|
||||
$mailer->Sender = $config['mail_address'];
|
||||
$mailer->From = setting('core.mail_address');
|
||||
$mailer->Sender = setting('core.mail_address');
|
||||
$mailer->CharSet = 'utf-8';
|
||||
$mailer->FromName = $config['lua']['serverName'];
|
||||
$mailer->Subject = $subject;
|
||||
$mailer->addAddress($to);
|
||||
$mailer->Body = $tmp_body;
|
||||
|
||||
if(config('smtp_debug')) {
|
||||
if(setting('core.smtp_debug')) {
|
||||
$mailer->SMTPDebug = 2;
|
||||
$mailer->Debugoutput = 'echo';
|
||||
}
|
||||
|
||||
$signature_plain = '';
|
||||
if(isset($config['mail_signature']['plain']))
|
||||
$signature_plain = $config['mail_signature']['plain'];
|
||||
|
||||
$signature_plain = setting('core.mail_signature_plain');
|
||||
if(isset($altBody[0])) {
|
||||
$mailer->AltBody = $altBody . $signature_plain;
|
||||
}
|
||||
@@ -1047,7 +1054,7 @@ function getTopPlayers($limit = 5) {
|
||||
$deleted = 'deletion';
|
||||
|
||||
$is_tfs10 = $db->hasTable('players_online');
|
||||
$players = $db->query('SELECT `id`, `name`, `level`, `vocation`, `experience`, `looktype`' . ($db->hasColumn('players', 'lookaddons') ? ', `lookaddons`' : '') . ', `lookhead`, `lookbody`, `looklegs`, `lookfeet`' . ($is_tfs10 ? '' : ', `online`') . ' FROM `players` WHERE `group_id` < ' . config('highscores_groups_hidden') . ' AND `id` NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ') AND `' . $deleted . '` = 0 AND `account_id` != 1 ORDER BY `experience` DESC LIMIT ' . (int)$limit)->fetchAll();
|
||||
$players = $db->query('SELECT `id`, `name`, `level`, `vocation`, `experience`, `looktype`' . ($db->hasColumn('players', 'lookaddons') ? ', `lookaddons`' : '') . ', `lookhead`, `lookbody`, `looklegs`, `lookfeet`' . ($is_tfs10 ? '' : ', `online`') . ' FROM `players` WHERE `group_id` < ' . setting('core.highscores_groups_hidden') . ' AND `id` NOT IN (' . implode(', ', setting('core.highscores_ids_hidden')) . ') AND `' . $deleted . '` = 0 AND `account_id` != 1 ORDER BY `experience` DESC LIMIT ' . (int)$limit)->fetchAll();
|
||||
|
||||
if($is_tfs10) {
|
||||
foreach($players as &$player) {
|
||||
@@ -1100,6 +1107,9 @@ function deleteDirectory($dir, $ignore = array(), $contentOnly = false) {
|
||||
function config($key) {
|
||||
global $config;
|
||||
if (is_array($key)) {
|
||||
if (is_null($key[1])) {
|
||||
unset($config[$key[0]]);
|
||||
}
|
||||
return $config[$key[0]] = $key[1];
|
||||
}
|
||||
|
||||
@@ -1115,6 +1125,21 @@ function configLua($key) {
|
||||
return @$config['lua'][$key];
|
||||
}
|
||||
|
||||
function setting($key)
|
||||
{
|
||||
$settings = Settings::getInstance();
|
||||
|
||||
if (is_array($key)) {
|
||||
if (is_null($key[1])) {
|
||||
unset($settings[$key[0]]);
|
||||
}
|
||||
|
||||
return $settings[$key[0]] = $key[1];
|
||||
}
|
||||
|
||||
return $settings[$key]['value'];
|
||||
}
|
||||
|
||||
function clearCache()
|
||||
{
|
||||
require_once LIBS . 'news.php';
|
||||
@@ -1483,8 +1508,8 @@ function right($str, $length) {
|
||||
}
|
||||
|
||||
function getCreatureImgPath($creature){
|
||||
$creature_path = config('creatures_images_url');
|
||||
$creature_gfx_name = trim(strtolower($creature)) . config('creatures_images_extension');
|
||||
$creature_path = config('monsters_images_url');
|
||||
$creature_gfx_name = trim(strtolower($creature)) . config('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)) {
|
||||
|
@@ -9,11 +9,6 @@
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
// load configuration
|
||||
require_once BASE . 'config.php';
|
||||
if(file_exists(BASE . 'config.local.php')) // user customizations
|
||||
require BASE . 'config.local.php';
|
||||
|
||||
if(!isset($config['installed']) || !$config['installed']) {
|
||||
throw new RuntimeException('MyAAC has not been installed yet or there was error during installation. Please install again.');
|
||||
}
|
||||
@@ -22,13 +17,16 @@ if(config('env') === 'dev') {
|
||||
require SYSTEM . 'exception.php';
|
||||
}
|
||||
|
||||
date_default_timezone_set($config['date_timezone']);
|
||||
if(empty($config['server_path'])) {
|
||||
throw new RuntimeException('Server Path has been not set. Go to config.php and set it.');
|
||||
}
|
||||
|
||||
// take care of trailing slash at the end
|
||||
if($config['server_path'][strlen($config['server_path']) - 1] !== '/')
|
||||
$config['server_path'] .= '/';
|
||||
|
||||
// enable gzip compression if supported by the browser
|
||||
if($config['gzip_output'] && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('ob_gzhandler'))
|
||||
if(isset($config['gzip_output']) && $config['gzip_output'] && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('ob_gzhandler'))
|
||||
ob_start('ob_gzhandler');
|
||||
|
||||
// cache
|
||||
@@ -96,9 +94,6 @@ if(isset($config['lua']['servername']))
|
||||
if(isset($config['lua']['houserentperiod']))
|
||||
$config['lua']['houseRentPeriod'] = $config['lua']['houserentperiod'];
|
||||
|
||||
if($config['item_images_url'][strlen($config['item_images_url']) - 1] !== '/')
|
||||
$config['item_images_url'] .= '/';
|
||||
|
||||
// localize data/ directory based on data directory set in config.lua
|
||||
foreach(array('dataDirectory', 'data_directory', 'datadir') as $key) {
|
||||
if(!isset($config['lua'][$key][0])) {
|
||||
@@ -122,51 +117,34 @@ if(!isset($foundValue)) {
|
||||
$config['data_path'] = $foundValue;
|
||||
unset($foundValue);
|
||||
|
||||
// new config values for compatibility
|
||||
if(!isset($config['highscores_ids_hidden']) || count($config['highscores_ids_hidden']) == 0) {
|
||||
$config['highscores_ids_hidden'] = array(0);
|
||||
}
|
||||
|
||||
$config['account_create_character_create'] = config('account_create_character_create') && (!config('mail_enabled') || !config('account_mail_verify'));
|
||||
|
||||
// POT
|
||||
require_once SYSTEM . 'libs/pot/OTS.php';
|
||||
$ots = POT::getInstance();
|
||||
require_once SYSTEM . 'database.php';
|
||||
|
||||
// execute migrations
|
||||
require SYSTEM . 'migrate.php';
|
||||
|
||||
// settings
|
||||
require_once LIBS . 'Settings.php';
|
||||
$settings = Settings::getInstance();
|
||||
$settings->load();
|
||||
|
||||
// deprecated config values
|
||||
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'));
|
||||
|
||||
$settingsItemImagesURL = setting('core.item_images_url');
|
||||
if($settingsItemImagesURL[strlen($settingsItemImagesURL) - 1] !== '/') {
|
||||
setting(['core.item_images_url', $settingsItemImagesURL . '/']);
|
||||
}
|
||||
|
||||
define('USE_ACCOUNT_NAME', $db->hasColumn('accounts', 'name'));
|
||||
define('USE_ACCOUNT_NUMBER', $db->hasColumn('accounts', 'number'));
|
||||
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';
|
||||
Towns::load();
|
||||
|
@@ -18,8 +18,8 @@ class CreateCharacter
|
||||
*/
|
||||
public function checkName($name, &$errors)
|
||||
{
|
||||
$minLength = config('character_name_min_length');
|
||||
$maxLength = config('character_name_max_length');
|
||||
$minLength = setting('core.create_character_name_min_length');
|
||||
$maxLength = setting('core.create_character_name_max_length');
|
||||
|
||||
if(empty($name)) {
|
||||
$errors['name'] = 'Please enter a name for your character!';
|
||||
@@ -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: <b>'.$char_to_copy_name.'</b> 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: <b>'.$char_to_copy_name.'</b> 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);
|
||||
}
|
||||
|
||||
@@ -239,14 +239,14 @@ class CreateCharacter
|
||||
}
|
||||
|
||||
if($db->hasTable('player_skills')) {
|
||||
for($i=0; $i<7; $i++) {
|
||||
for($skill = POT::SKILL_FIRST; $skill <= POT::SKILL_LAST; $skill++) {
|
||||
$value = 10;
|
||||
if (config('use_character_sample_skills')) {
|
||||
$value = $char_to_copy->getSkill($i);
|
||||
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` = ' . $i);
|
||||
$skillExists = $db->query('SELECT `skillid` FROM `player_skills` WHERE `player_id` = ' . $player->getId() . ' AND `skillid` = ' . $skill);
|
||||
if($skillExists->rowCount() <= 0) {
|
||||
$db->query('INSERT INTO `player_skills` (`player_id`, `skillid`, `value`, `count`) VALUES ('.$player->getId().', '.$i.', ' . $value . ', 0)');
|
||||
$db->query('INSERT INTO `player_skills` (`player_id`, `skillid`, `value`, `count`) VALUES ('.$player->getId().', '.$skill.', ' . $value . ', 0)');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
598
system/libs/Settings.php
Normal file
598
system/libs/Settings.php
Normal file
@@ -0,0 +1,598 @@
|
||||
<?php
|
||||
/**
|
||||
* CreateCharacter
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2020 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
|
||||
class Settings implements ArrayAccess
|
||||
{
|
||||
static private $instance;
|
||||
private $settingsFile = [];
|
||||
private $settingsDatabase = [];
|
||||
private $cache = [];
|
||||
private $valuesAsked = [];
|
||||
private $errors = [];
|
||||
|
||||
/**
|
||||
* @return Settings
|
||||
*/
|
||||
public static function getInstance(): Settings
|
||||
{
|
||||
if (!self::$instance) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function load()
|
||||
{
|
||||
$cache = Cache::getInstance();
|
||||
if ($cache->enabled()) {
|
||||
$tmp = '';
|
||||
if ($cache->fetch('settings', $tmp)) {
|
||||
$this->settingsDatabase = unserialize($tmp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
global $db;
|
||||
$settings = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'settings`');
|
||||
|
||||
if($settings->rowCount() > 0) {
|
||||
foreach ($settings->fetchAll(PDO::FETCH_ASSOC) as $setting) {
|
||||
$this->settingsDatabase[$setting['name']][$setting['key']] = $setting['value'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($cache->enabled()) {
|
||||
$cache->set('settings', serialize($this->settingsDatabase), 600);
|
||||
}
|
||||
}
|
||||
|
||||
public function save($pluginName, $values) {
|
||||
global $db;
|
||||
|
||||
if (!isset($this->settingsFile[$pluginName])) {
|
||||
throw new RuntimeException('Error on save settings: plugin does not exist');
|
||||
}
|
||||
|
||||
$settings = $this->settingsFile[$pluginName];
|
||||
if (isset($settings['callbacks']['beforeSave'])) {
|
||||
if (!$settings['callbacks']['beforeSave']($settings, $values)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->errors = [];
|
||||
$db->query('DELETE FROM `' . TABLE_PREFIX . 'settings` WHERE `name` = ' . $db->quote($pluginName) . ';');
|
||||
foreach ($values as $key => $value) {
|
||||
$errorMessage = '';
|
||||
if (isset($settings['settings'][$key]['callbacks']['beforeSave']) && !$settings['settings'][$key]['callbacks']['beforeSave']($key, $value, $errorMessage)) {
|
||||
$this->errors[] = $errorMessage;
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$db->insert(TABLE_PREFIX . 'settings', ['name' => $pluginName, 'key' => $key, 'value' => $value]);
|
||||
} catch (PDOException $error) {
|
||||
$this->errors[] = 'Error while saving setting (' . $pluginName . ' - ' . $key . '): ' . $error->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
$cache = Cache::getInstance();
|
||||
if ($cache->enabled()) {
|
||||
$cache->delete('settings');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function updateInDatabase($pluginName, $key, $value)
|
||||
{
|
||||
global $db;
|
||||
$db->update(TABLE_PREFIX . 'settings', ['value' => $value], ['name' => $pluginName, 'key' => $key]);
|
||||
}
|
||||
|
||||
public function deleteFromDatabase($pluginName, $key = null)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (!isset($key)) {
|
||||
$db->delete(TABLE_PREFIX . 'settings', ['name' => $pluginName], -1);
|
||||
}
|
||||
else {
|
||||
$db->delete(TABLE_PREFIX . 'settings', ['name' => $pluginName, 'key' => $key]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function display($plugin, $settings): array
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = 'SELECT `key`, `value` FROM `' . TABLE_PREFIX . 'settings` WHERE `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'];
|
||||
}
|
||||
}
|
||||
|
||||
$config = [];
|
||||
require BASE . 'config.local.php';
|
||||
|
||||
foreach ($config as $key => $value) {
|
||||
if (is_bool($value)) {
|
||||
$settingsDb[$key] = $value ? 'true' : 'false';
|
||||
}
|
||||
else {
|
||||
$settingsDb[$key] = (string)$value;
|
||||
}
|
||||
}
|
||||
|
||||
$javascript = '';
|
||||
ob_start();
|
||||
?>
|
||||
<ul class="nav nav-tabs" id="myTab">
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach($settings as $setting) {
|
||||
if (isset($setting['script'])) {
|
||||
$javascript .= $setting['script'] . PHP_EOL;
|
||||
}
|
||||
|
||||
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 . '_' . ($type ? 'yes' : 'no') . '" 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) { // close previous category
|
||||
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) { // close previous section
|
||||
echo '</tbody></table>';
|
||||
}
|
||||
?>
|
||||
<h3 id="row_<?= $key ?>" style="text-align: center"><strong><?= $setting['title']; ?></strong></h3>
|
||||
<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 id="row_<?= $key ?>">
|
||||
<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'])) {
|
||||
if ($setting['type'] === 'number') {
|
||||
$min = (isset($setting['min']) ? ' min="' . $setting['min'] . '"' : '');
|
||||
$max = (isset($setting['max']) ? ' max="' . $setting['max'] . '"' : '');
|
||||
$step = (isset($setting['step']) ? ' step="' . $setting['step'] . '"' : '');
|
||||
}
|
||||
else {
|
||||
$min = $max = $step = '';
|
||||
}
|
||||
|
||||
echo '<input class="form-control" type="' . $setting['type'] . '" name="settings[' . $key . ']" value="' . ($settingsDb[$key] ?? ($setting['default'] ?? '')) . '" id="' . $key . '"' . $min . $max . $step . '/>';
|
||||
}
|
||||
|
||||
else if($setting['type'] === 'textarea') {
|
||||
$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 '<textarea class="form-control" rows="' . $rows . '" name="settings[' . $key . ']" id="' . $key . '">' . $value . '</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 ($setting['options'] == '$timezones') {
|
||||
$timezones = [];
|
||||
foreach (DateTimeZone::listIdentifiers() as $value) {
|
||||
$timezones[$value] = $value;
|
||||
}
|
||||
|
||||
$setting['options'] = $timezones;
|
||||
}
|
||||
|
||||
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 = ($settingsDb[$key] ?? ($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 setting-default"><?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') {
|
||||
if (!empty($setting['default'])) {
|
||||
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 ['content' => ob_get_clean(), 'script' => $javascript];
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
throw new \RuntimeException("Settings: You cannot set empty offset with value: $value!");
|
||||
}
|
||||
|
||||
$this->loadPlugin($offset);
|
||||
|
||||
$pluginKeyName = $this->valuesAsked['pluginKeyName'];
|
||||
$key = $this->valuesAsked['key'];
|
||||
|
||||
// remove whole plugin settings
|
||||
if (!isset($value)) {
|
||||
$this->offsetUnset($offset);
|
||||
$this->deleteFromDatabase($pluginKeyName, $key);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->settingsDatabase[$pluginKeyName][$key] = $value;
|
||||
$this->updateInDatabase($pluginKeyName, $key, $value);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
$this->loadPlugin($offset);
|
||||
|
||||
$pluginKeyName = $this->valuesAsked['pluginKeyName'];
|
||||
$key = $this->valuesAsked['key'];
|
||||
|
||||
// remove specified plugin settings (all)
|
||||
if(is_null($key)) {
|
||||
return isset($this->settingsDatabase[$offset]);
|
||||
}
|
||||
|
||||
return isset($this->settingsDatabase[$pluginKeyName][$key]);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
$this->loadPlugin($offset);
|
||||
|
||||
$pluginKeyName = $this->valuesAsked['pluginKeyName'];
|
||||
$key = $this->valuesAsked['key'];
|
||||
|
||||
if (isset($this->cache[$offset])) {
|
||||
unset($this->cache[$offset]);
|
||||
}
|
||||
|
||||
// remove specified plugin settings (all)
|
||||
if(!isset($key)) {
|
||||
unset($this->settingsFile[$pluginKeyName]);
|
||||
unset($this->settingsDatabase[$pluginKeyName]);
|
||||
$this->deleteFromDatabase($pluginKeyName);
|
||||
return;
|
||||
}
|
||||
|
||||
unset($this->settingsFile[$pluginKeyName]['settings'][$key]);
|
||||
unset($this->settingsDatabase[$pluginKeyName][$key]);
|
||||
$this->deleteFromDatabase($pluginKeyName, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get settings
|
||||
* Usage: $setting['plugin_name.key']
|
||||
* Example: $settings['shop_system.paypal_email']
|
||||
*
|
||||
* @param mixed $offset
|
||||
* @return array|mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
// try cache hit
|
||||
if(isset($this->cache[$offset])) {
|
||||
return $this->cache[$offset];
|
||||
}
|
||||
|
||||
$this->loadPlugin($offset);
|
||||
|
||||
$pluginKeyName = $this->valuesAsked['pluginKeyName'];
|
||||
$key = $this->valuesAsked['key'];
|
||||
|
||||
// return specified plugin settings (all)
|
||||
if(!isset($key)) {
|
||||
if (!isset($this->settingsFile[$pluginKeyName]['settings'])) {
|
||||
throw new RuntimeException('Unknown plugin settings: ' . $pluginKeyName);
|
||||
}
|
||||
return $this->settingsFile[$pluginKeyName]['settings'];
|
||||
}
|
||||
|
||||
$ret = [];
|
||||
if(isset($this->settingsFile[$pluginKeyName]['settings'][$key])) {
|
||||
$ret = $this->settingsFile[$pluginKeyName]['settings'][$key];
|
||||
}
|
||||
|
||||
if(isset($this->settingsDatabase[$pluginKeyName][$key])) {
|
||||
$value = $this->settingsDatabase[$pluginKeyName][$key];
|
||||
|
||||
$ret['value'] = $value;
|
||||
}
|
||||
else {
|
||||
$ret['value'] = $this->settingsFile[$pluginKeyName]['settings'][$key]['default'];
|
||||
}
|
||||
|
||||
if(isset($ret['type'])) {
|
||||
switch($ret['type']) {
|
||||
case 'boolean':
|
||||
$ret['value'] = getBoolean($ret['value']);
|
||||
break;
|
||||
|
||||
case 'number':
|
||||
if (!isset($ret['step']) || (int)$ret['step'] == 1) {
|
||||
$ret['value'] = (int)$ret['value'];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($ret['callbacks']['get'])) {
|
||||
$ret['value'] = $ret['callbacks']['get']($ret['value']);
|
||||
}
|
||||
|
||||
$this->cache[$offset] = $ret;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function updateValuesAsked($offset)
|
||||
{
|
||||
$pluginKeyName = $offset;
|
||||
if (strpos($offset, '.')) {
|
||||
$explode = explode('.', $offset, 2);
|
||||
|
||||
$pluginKeyName = $explode[0];
|
||||
$key = $explode[1];
|
||||
|
||||
$this->valuesAsked = ['pluginKeyName' => $pluginKeyName, 'key' => $key];
|
||||
}
|
||||
else {
|
||||
$this->valuesAsked = ['pluginKeyName' => $pluginKeyName, 'key' => null];
|
||||
}
|
||||
}
|
||||
|
||||
private function loadPlugin($offset)
|
||||
{
|
||||
$this->updateValuesAsked($offset);
|
||||
|
||||
$pluginKeyName = $this->valuesAsked['pluginKeyName'];
|
||||
$key = $this->valuesAsked['key'];
|
||||
|
||||
if (!isset($this->settingsFile[$pluginKeyName])) {
|
||||
if ($pluginKeyName === 'core') {
|
||||
$settingsFilePath = SYSTEM . 'settings.php';
|
||||
} else {
|
||||
//$pluginSettings = Plugins::getPluginSettings($pluginKeyName);
|
||||
$settings = Plugins::getAllPluginsSettings();
|
||||
if (!isset($settings[$pluginKeyName])) {
|
||||
warning("Setting $pluginKeyName does not exist or does not have settings defined.");
|
||||
return;
|
||||
}
|
||||
|
||||
$settingsFilePath = BASE . $settings[$pluginKeyName]['settingsFilename'];
|
||||
}
|
||||
|
||||
if (!file_exists($settingsFilePath)) {
|
||||
throw new \RuntimeException('Failed to load settings file for plugin: ' . $pluginKeyName);
|
||||
}
|
||||
|
||||
$this->settingsFile[$pluginKeyName] = require $settingsFilePath;
|
||||
}
|
||||
}
|
||||
|
||||
public static function saveConfig($config, $filename, &$content = '')
|
||||
{
|
||||
$content = "<?php" . PHP_EOL .
|
||||
"\$config['installed'] = true;" . PHP_EOL;
|
||||
|
||||
foreach ($config as $key => $value) {
|
||||
$content .= "\$config['$key'] = ";
|
||||
$content .= var_export($value, true);
|
||||
$content .= ';' . PHP_EOL;
|
||||
}
|
||||
|
||||
$success = file_put_contents($filename, $content);
|
||||
|
||||
// we saved new config.php, need to revalidate cache (only if opcache is enabled)
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate($filename);
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
public static function testDatabaseConnection($config): bool
|
||||
{
|
||||
$user = null;
|
||||
$password = null;
|
||||
$dns = [];
|
||||
|
||||
if( isset($config['database_name']) ) {
|
||||
$dns[] = 'dbname=' . $config['database_name'];
|
||||
}
|
||||
|
||||
if( isset($config['database_user']) ) {
|
||||
$user = $config['database_user'];
|
||||
}
|
||||
|
||||
if( isset($config['database_password']) ) {
|
||||
$password = $config['database_password'];
|
||||
}
|
||||
|
||||
if( isset($config['database_host']) ) {
|
||||
$dns[] = 'host=' . $config['database_host'];
|
||||
}
|
||||
|
||||
if( isset($config['database_port']) ) {
|
||||
$dns[] = 'port=' . $config['database_port'];
|
||||
}
|
||||
|
||||
try {
|
||||
$connectionTest = new PDO('mysql:' . implode(';', $dns), $user, $password);
|
||||
$connectionTest->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
catch(PDOException $error) {
|
||||
error('MySQL connection failed. Settings has been reverted.');
|
||||
error($error->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getErrors() {
|
||||
return $this->errors;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -168,6 +168,36 @@ class Plugins {
|
||||
return $hooks;
|
||||
}
|
||||
|
||||
public static function getAllPluginsSettings()
|
||||
{
|
||||
$cache = Cache::getInstance();
|
||||
if ($cache->enabled()) {
|
||||
$tmp = '';
|
||||
if ($cache->fetch('plugins_settings', $tmp)) {
|
||||
return unserialize($tmp);
|
||||
}
|
||||
}
|
||||
|
||||
$settings = [];
|
||||
foreach (self::getAllPluginsJson() as $plugin) {
|
||||
if (isset($plugin['settings'])) {
|
||||
$settingsFile = require BASE . $plugin['settings'];
|
||||
if (!isset($settingsFile['key'])) {
|
||||
warning("Settings file for plugin - {$plugin['name']} does not contain 'key' field");
|
||||
continue;
|
||||
}
|
||||
|
||||
$settings[$settingsFile['key']] = ['pluginFilename' => $plugin['filename'], 'settingsFilename' => $plugin['settings']];
|
||||
}
|
||||
}
|
||||
|
||||
if ($cache->enabled()) {
|
||||
$cache->set('plugins_settings', serialize($settings), 600); // cache for 10 minutes
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
public static function getAllPluginsJson($disabled = false)
|
||||
{
|
||||
$cache = Cache::getInstance();
|
||||
@@ -180,30 +210,66 @@ class Plugins {
|
||||
|
||||
$plugins = [];
|
||||
foreach (get_plugins($disabled) as $filename) {
|
||||
$string = file_get_contents(PLUGINS . $filename . '.json');
|
||||
$plugin = json_decode($string, true);
|
||||
self::$plugin_json = $plugin;
|
||||
if ($plugin == null) {
|
||||
self::$warnings[] = 'Cannot load ' . $filename . '.json. File might be not a valid json code.';
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($plugin['enabled']) && !getBoolean($plugin['enabled'])) {
|
||||
self::$warnings[] = 'Skipping ' . $filename . '... The plugin is disabled.';
|
||||
$plugin = self::getPluginJson($filename);
|
||||
|
||||
if (!$plugin) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$plugin['filename'] = $filename;
|
||||
$plugins[] = $plugin;
|
||||
}
|
||||
|
||||
if ($cache->enabled()) {
|
||||
$cache->set('plugins', serialize($plugins), 600);
|
||||
$cache->set('plugins', serialize($plugins), 600); // cache for 10 minutes
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
public static function install($file) {
|
||||
public static function getPluginSettings($filename)
|
||||
{
|
||||
$plugin_json = self::getPluginJson($filename);
|
||||
if (!$plugin_json) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($plugin_json['settings']) || !file_exists(BASE . $plugin_json['settings'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $plugin_json['settings'];
|
||||
}
|
||||
|
||||
public static function getPluginJson($filename = null)
|
||||
{
|
||||
if(!isset($filename)) {
|
||||
return self::$plugin_json;
|
||||
}
|
||||
|
||||
$pathToPlugin = PLUGINS . $filename . '.json';
|
||||
if (!file_exists($pathToPlugin)) {
|
||||
self::$warnings[] = "Cannot load $filename.json. File doesn't exist.";
|
||||
return false;
|
||||
}
|
||||
|
||||
$string = file_get_contents($pathToPlugin);
|
||||
$plugin_json = json_decode($string, true);
|
||||
if ($plugin_json == null) {
|
||||
self::$warnings[] = "Cannot load $filename.json. File might be not a valid json code.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($plugin_json['enabled']) && !getBoolean($plugin_json['enabled'])) {
|
||||
self::$warnings[] = 'Skipping ' . $filename . '... The plugin is disabled.';
|
||||
return false;
|
||||
}
|
||||
|
||||
return $plugin_json;
|
||||
}
|
||||
|
||||
public static function install($file): bool
|
||||
{
|
||||
global $db;
|
||||
|
||||
if(!\class_exists('ZipArchive')) {
|
||||
@@ -242,6 +308,12 @@ class Plugins {
|
||||
return false;
|
||||
}
|
||||
|
||||
$pluginFilename = str_replace('.json', '', basename($json_file));
|
||||
if (self::existDisabled($pluginFilename)) {
|
||||
success('The plugin already existed, but was disabled. It has been enabled again and will be now reinstalled.');
|
||||
self::enable($pluginFilename);
|
||||
}
|
||||
|
||||
$string = file_get_contents($file_name);
|
||||
$plugin_json = json_decode($string, true);
|
||||
self::$plugin_json = $plugin_json;
|
||||
@@ -442,13 +514,23 @@ class Plugins {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function enable($pluginFileName): bool
|
||||
public static function isEnabled($pluginFileName): bool
|
||||
{
|
||||
$filenameJson = $pluginFileName . '.json';
|
||||
return !is_file(PLUGINS . 'disabled.' . $filenameJson) && is_file(PLUGINS . $filenameJson);
|
||||
}
|
||||
|
||||
public static function existDisabled($pluginFileName): bool
|
||||
{
|
||||
$filenameJson = $pluginFileName . '.json';
|
||||
return is_file(PLUGINS . 'disabled.' . $filenameJson);
|
||||
}
|
||||
|
||||
public static function enable($pluginFileName): bool {
|
||||
return self::enableDisable($pluginFileName, true);
|
||||
}
|
||||
|
||||
public static function disable($pluginFileName): bool
|
||||
{
|
||||
public static function disable($pluginFileName): bool {
|
||||
return self::enableDisable($pluginFileName, false);
|
||||
}
|
||||
|
||||
@@ -526,7 +608,8 @@ class Plugins {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function is_installed($plugin_name, $version) {
|
||||
public static function is_installed($plugin_name, $version): bool
|
||||
{
|
||||
$filename = BASE . 'plugins/' . $plugin_name . '.json';
|
||||
if(!file_exists($filename)) {
|
||||
return false;
|
||||
@@ -534,7 +617,7 @@ class Plugins {
|
||||
|
||||
$string = file_get_contents($filename);
|
||||
$plugin_info = json_decode($string, true);
|
||||
if($plugin_info == false) {
|
||||
if(!$plugin_info) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -557,10 +640,6 @@ class Plugins {
|
||||
return self::$error;
|
||||
}
|
||||
|
||||
public static function getPluginJson() {
|
||||
return self::$plugin_json;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install menus
|
||||
* Helper function for plugins
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
/**
|
||||
* Various server status querying methods.
|
||||
*
|
||||
*
|
||||
* @package POT
|
||||
* @property-read OTS_InfoRespond|bool $status status() method wrapper.
|
||||
* @property-read OTS_ServerStatus|bool $info Full info() method wrapper.
|
||||
@@ -23,21 +23,21 @@ class OTS_ServerInfo
|
||||
{
|
||||
/**
|
||||
* Server address.
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $server;
|
||||
|
||||
/**
|
||||
* Connection port.
|
||||
*
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $port;
|
||||
|
||||
/**
|
||||
* Creates handler for new server.
|
||||
*
|
||||
*
|
||||
* @param string $server Server IP/domain.
|
||||
* @param int $port OTServ port.
|
||||
*/
|
||||
@@ -49,7 +49,7 @@ class OTS_ServerInfo
|
||||
|
||||
/**
|
||||
* Sends packet to server.
|
||||
*
|
||||
*
|
||||
* @param OTS_Buffer|string $packet Buffer to send.
|
||||
* @return OTS_Buffer|null Respond buffer (null if server is offline).
|
||||
* @throws E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
|
||||
@@ -57,7 +57,7 @@ class OTS_ServerInfo
|
||||
private function send(OTS_Buffer $packet)
|
||||
{
|
||||
// connects to server
|
||||
$socket = @fsockopen($this->server, $this->port, $error, $message, config('status_timeout'));
|
||||
$socket = @fsockopen($this->server, $this->port, $error, $message, setting('core.status_timeout'));
|
||||
|
||||
// if connected then checking statistics
|
||||
if($socket)
|
||||
@@ -75,7 +75,7 @@ class OTS_ServerInfo
|
||||
|
||||
// reads respond
|
||||
//$data = stream_get_contents($socket);
|
||||
$data = '';
|
||||
$data = '';
|
||||
while (!feof($socket))
|
||||
$data .= fgets($socket, 1024);
|
||||
|
||||
@@ -97,11 +97,11 @@ class OTS_ServerInfo
|
||||
|
||||
/**
|
||||
* Queries server status.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Sends 'info' packet to OTS server and return output. Returns {@link OTS_InfoRespond OTS_InfoRespond} (wrapper for XML data) with results or <var>false</var> if server is online.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return OTS_InfoRespond|bool Respond content document (false when server is offline).
|
||||
* @throws DOMException On DOM operation error.
|
||||
* @throws E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
|
||||
@@ -135,11 +135,11 @@ class OTS_ServerInfo
|
||||
|
||||
/**
|
||||
* Queries server information.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method uses binary info protocol. It provides more infromation then {@link OTS_Toolbox::serverStatus() XML way}.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param int $flags Requested info flags.
|
||||
* @return OTS_ServerStatus|bool Respond content document (false when server is offline).
|
||||
* @throws E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
|
||||
@@ -169,11 +169,11 @@ class OTS_ServerInfo
|
||||
|
||||
/**
|
||||
* Checks player online status.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method uses binary info protocol.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param string $name Player name.
|
||||
* @return bool True if player is online, false if player or server is online.
|
||||
* @throws E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
|
||||
@@ -204,7 +204,7 @@ class OTS_ServerInfo
|
||||
|
||||
/**
|
||||
* Magic PHP5 method.
|
||||
*
|
||||
*
|
||||
* @param string $name Property name.
|
||||
* @param mixed $value Property value.
|
||||
* @throws OutOfBoundsException For non-supported properties.
|
||||
|
@@ -117,7 +117,7 @@ class Validator
|
||||
return false;
|
||||
}
|
||||
|
||||
if(config('account_mail_block_plus_sign')) {
|
||||
if(setting('core.account_mail_block_plus_sign')) {
|
||||
$explode = explode('@', $email);
|
||||
if(isset($explode[0]) && (strpos($explode[0],'+') !== false)) {
|
||||
self::$lastError = 'Please do not use plus (+) sign in your e-mail.';
|
||||
@@ -180,15 +180,16 @@ class Validator
|
||||
return false;
|
||||
}
|
||||
|
||||
$minLength = config('character_name_min_length');
|
||||
$maxLength = config('character_name_max_length');
|
||||
|
||||
// installer doesn't know config.php yet
|
||||
// that's why we need to ignore the nulls
|
||||
if(is_null($minLength) || is_null($maxLength)) {
|
||||
if(defined('MYAAC_INSTALL')) {
|
||||
$minLength = 4;
|
||||
$maxLength = 21;
|
||||
}
|
||||
else {
|
||||
$minLength = setting('core.create_character_name_min_length');
|
||||
$maxLength = setting('core.create_character_name_max_length');
|
||||
}
|
||||
|
||||
$length = strlen($name);
|
||||
if($length < $minLength)
|
||||
@@ -221,16 +222,6 @@ class Validator
|
||||
return false;
|
||||
}
|
||||
|
||||
$npcCheck = config('character_name_npc_check');
|
||||
if ($npcCheck) {
|
||||
require_once LIBS . 'npc.php';
|
||||
NPCS::load();
|
||||
if(NPCS::$npcs && in_array(strtolower($name), NPCS::$npcs)) {
|
||||
self::$lastError = "Invalid name format. Do not use NPC Names";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -246,14 +237,9 @@ class Validator
|
||||
global $db, $config;
|
||||
|
||||
$name_lower = strtolower($name);
|
||||
$custom_first_words_blocked = [];
|
||||
if (isset($config['character_name_blocked']['prefix']) && $config['character_name_blocked']['prefix']) {
|
||||
$custom_first_words_blocked = $config['character_name_blocked']['prefix'];
|
||||
}
|
||||
|
||||
$first_words_blocked = array_merge($custom_first_words_blocked, array('admin ', 'administrator ', 'gm ', 'cm ', 'god ','tutor ', "'", '-'));
|
||||
foreach($first_words_blocked as $word)
|
||||
{
|
||||
$first_words_blocked = array_merge(["'", '-'], setting('core.create_character_name_blocked_prefix'));
|
||||
foreach($first_words_blocked as $word) {
|
||||
if($word == substr($name_lower, 0, strlen($word))) {
|
||||
self::$lastError = 'Your name contains blocked words.';
|
||||
return false;
|
||||
@@ -275,8 +261,7 @@ class Validator
|
||||
return false;
|
||||
}
|
||||
|
||||
if(preg_match('/ {2,}/', $name))
|
||||
{
|
||||
if(preg_match('/ {2,}/', $name)) {
|
||||
self::$lastError = 'Invalid character name format. Use only A-Z and numbers 0-9 and no double spaces.';
|
||||
return false;
|
||||
}
|
||||
@@ -286,26 +271,16 @@ class Validator
|
||||
return false;
|
||||
}
|
||||
|
||||
$custom_names_blocked = [];
|
||||
if (isset($config['character_name_blocked']['names']) && $config['character_name_blocked']['names']) {
|
||||
$custom_names_blocked = $config['character_name_blocked']['names'];
|
||||
}
|
||||
$names_blocked = array_merge($custom_names_blocked, array('admin', 'administrator', 'gm', 'cm', 'god', 'tutor'));
|
||||
foreach($names_blocked as $word)
|
||||
{
|
||||
$names_blocked = setting('core.create_character_name_blocked_names');
|
||||
foreach($names_blocked as $word) {
|
||||
if($word == $name_lower) {
|
||||
self::$lastError = 'Your name contains blocked words.';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$custom_words_blocked = [];
|
||||
if (isset($config['character_name_blocked']['words']) && $config['character_name_blocked']['words']) {
|
||||
$custom_words_blocked = $config['character_name_blocked']['words'];
|
||||
}
|
||||
$words_blocked = array_merge($custom_words_blocked, array('admin', 'administrator', 'gamemaster', 'game master', 'game-master', "game'master", '--', "''","' ", " '", '- ', ' -', "-'", "'-", 'fuck', 'sux', 'suck', 'noob', 'tutor'));
|
||||
foreach($words_blocked as $word)
|
||||
{
|
||||
$words_blocked = array_merge(['--', "''","' ", " '", '- ', ' -', "-'", "'-"], setting('core.create_character_name_blocked_words'));
|
||||
foreach($words_blocked as $word) {
|
||||
if(!(strpos($name_lower, $word) === false)) {
|
||||
self::$lastError = 'Your name contains illegal words.';
|
||||
return false;
|
||||
@@ -321,7 +296,7 @@ class Validator
|
||||
}
|
||||
}
|
||||
|
||||
//check if was namelocked previously
|
||||
// check if was namelocked previously
|
||||
if($db->hasTable('player_namelocks') && $db->hasColumn('player_namelocks', 'name')) {
|
||||
$namelock = $db->query('SELECT `player_id` FROM `player_namelocks` WHERE `name` = ' . $db->quote($name));
|
||||
if($namelock->rowCount() > 0) {
|
||||
@@ -330,39 +305,41 @@ class Validator
|
||||
}
|
||||
}
|
||||
|
||||
$monsters = $db->query('SELECT `name` FROM `' . TABLE_PREFIX . 'monsters` WHERE `name` LIKE ' . $db->quote($name_lower));
|
||||
if($monsters->rowCount() > 0) {
|
||||
self::$lastError = 'Your name cannot contains monster name.';
|
||||
return false;
|
||||
}
|
||||
|
||||
$spells_name = $db->query('SELECT `name` FROM `' . TABLE_PREFIX . 'spells` WHERE `name` LIKE ' . $db->quote($name_lower));
|
||||
if($spells_name->rowCount() > 0) {
|
||||
self::$lastError = 'Your name cannot contains spell name.';
|
||||
return false;
|
||||
}
|
||||
|
||||
$spells_words = $db->query('SELECT `words` FROM `' . TABLE_PREFIX . 'spells` WHERE `words` = ' . $db->quote($name_lower));
|
||||
if($spells_words->rowCount() > 0) {
|
||||
self::$lastError = 'Your name cannot contains spell name.';
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isset($config['npc']))
|
||||
{
|
||||
if(in_array($name_lower, $config['npc'])) {
|
||||
self::$lastError = 'Your name cannot contains NPC name.';
|
||||
$monstersCheck = setting('core.create_character_name_monsters_check');
|
||||
if ($monstersCheck) {
|
||||
$monsters = $db->query('SELECT `name` FROM `' . TABLE_PREFIX . 'monsters` WHERE `name` LIKE ' . $db->quote($name_lower));
|
||||
if ($monsters->rowCount() > 0) {
|
||||
self::$lastError = 'Your name cannot contains monster name.';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$npcCheck = config('character_name_npc_check');
|
||||
$spellsCheck = setting('core.create_character_name_spells_check');
|
||||
if ($spellsCheck) {
|
||||
$spells_name = $db->query('SELECT `name` FROM `' . TABLE_PREFIX . 'spells` WHERE `name` LIKE ' . $db->quote($name_lower));
|
||||
if ($spells_name->rowCount() > 0) {
|
||||
self::$lastError = 'Your name cannot contains spell name.';
|
||||
return false;
|
||||
}
|
||||
|
||||
$spells_words = $db->query('SELECT `words` FROM `' . TABLE_PREFIX . 'spells` WHERE `words` = ' . $db->quote($name_lower));
|
||||
if ($spells_words->rowCount() > 0) {
|
||||
self::$lastError = 'Your name cannot contains spell name.';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$npcCheck = setting('core.create_character_name_npc_check');
|
||||
if ($npcCheck) {
|
||||
require_once LIBS . 'npc.php';
|
||||
NPCS::load();
|
||||
if(NPCS::$npcs && in_array($name_lower, NPCS::$npcs)) {
|
||||
self::$lastError = "Invalid name format. Do not use NPC Names";
|
||||
return false;
|
||||
if(NPCS::$npcs) {
|
||||
foreach (NPCs::$npcs as $npc) {
|
||||
if(strpos($name_lower, $npc) !== false) {
|
||||
self::$lastError = 'Your name cannot contains NPC name.';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,47 +1,15 @@
|
||||
<?php
|
||||
|
||||
if(!isset($database_migration_20)) {
|
||||
databaseMigration20();
|
||||
$query = $db->query("SELECT `id` FROM `players` WHERE (`name` = " . $db->quote("Rook Sample") . " OR `name` = " . $db->quote("Sorcerer Sample") . " OR `name` = " . $db->quote("Druid Sample") . " OR `name` = " . $db->quote("Paladin Sample") . " OR `name` = " . $db->quote("Knight Sample") . " OR `name` = " . $db->quote("Account Manager") . ") ORDER BY `id`;");
|
||||
|
||||
$highscores_ignored_ids = array();
|
||||
if($query->rowCount() > 0) {
|
||||
foreach($query->fetchAll() as $result)
|
||||
$highscores_ignored_ids[] = $result['id'];
|
||||
}
|
||||
else {
|
||||
$highscores_ignored_ids[] = 0;
|
||||
}
|
||||
|
||||
function databaseMigration20(&$content = '') {
|
||||
global $db;
|
||||
|
||||
$config_file = BASE . 'config.local.php';
|
||||
if(!is_writable($config_file)) { // we can't do anything, just ignore
|
||||
return false;
|
||||
}
|
||||
|
||||
$content_of_file = trim(file_get_contents($config_file));
|
||||
if(strpos($content_of_file, 'highscores_ids_hidden') !== false) { // already present
|
||||
return true;
|
||||
}
|
||||
|
||||
$query = $db->query("SELECT `id` FROM `players` WHERE (`name` = " . $db->quote("Rook Sample") . " OR `name` = " . $db->quote("Sorcerer Sample") . " OR `name` = " . $db->quote("Druid Sample") . " OR `name` = " . $db->quote("Paladin Sample") . " OR `name` = " . $db->quote("Knight Sample") . " OR `name` = " . $db->quote("Account Manager") . ") ORDER BY `id`;");
|
||||
|
||||
$highscores_ignored_ids = array();
|
||||
if($query->rowCount() > 0) {
|
||||
foreach($query->fetchAll() as $result)
|
||||
$highscores_ignored_ids[] = $result['id'];
|
||||
}
|
||||
else {
|
||||
$highscores_ignored_ids[] = 0;
|
||||
}
|
||||
|
||||
$php_on_end = substr($content_of_file, -2, 2) == '?>';
|
||||
$content = PHP_EOL;
|
||||
if($php_on_end) {
|
||||
$content .= '<?php';
|
||||
}
|
||||
|
||||
$content .= PHP_EOL;
|
||||
$content .= '$config[\'highscores_ids_hidden\'] = array(' . implode(', ', $highscores_ignored_ids) . ');';
|
||||
$content .= PHP_EOL;
|
||||
|
||||
if($php_on_end) {
|
||||
$content .= '?>';
|
||||
}
|
||||
|
||||
file_put_contents($config_file, $content, FILE_APPEND);
|
||||
return true;
|
||||
}
|
||||
$settings = Settings::getInstance();
|
||||
$settings->updateInDatabase('core', 'highscores_ids_hidden', implode(', ', $highscores_ignored_ids));
|
||||
|
14
system/migrations/36.php
Normal file
14
system/migrations/36.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
// add settings table
|
||||
if(!$db->hasTable(TABLE_PREFIX . 'settings')) {
|
||||
$db->exec("CREATE TABLE `" . TABLE_PREFIX . "settings`
|
||||
(
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`key` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`value` TEXT NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `key` (`key`)
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;");
|
||||
}
|
@@ -19,17 +19,17 @@ if(!$logged) {
|
||||
|
||||
$player_id = isset($_POST['player_id']) ? (int)$_POST['player_id'] : NULL;
|
||||
$name = isset($_POST['name']) ? stripslashes(ucwords(strtolower($_POST['name']))) : NULL;
|
||||
if((!$config['account_change_character_name']))
|
||||
if((!setting('core.account_change_character_name')))
|
||||
echo 'Changing character name for premium points is disabled on this server.';
|
||||
else
|
||||
{
|
||||
$points = $account_logged->getCustomField('premium_points');
|
||||
$points = $account_logged->getCustomField(setting('core.donate_column'));
|
||||
if(isset($_POST['changenamesave']) && $_POST['changenamesave'] == 1) {
|
||||
if($points < $config['account_change_character_name_points'])
|
||||
$errors[] = 'You need ' . $config['account_change_character_name_points'] . ' premium points to change name. You have <b>'.$points.'<b> premium points.';
|
||||
if($points < setting('core.account_change_character_name_price'))
|
||||
$errors[] = 'You need ' . setting('core.account_change_character_name_price') . ' premium points to change name. You have <b>'.$points.'<b> premium points.';
|
||||
|
||||
$minLength = config('character_name_min_length');
|
||||
$maxLength = config('character_name_max_length');
|
||||
$minLength = setting('core.create_character_name_min_length');
|
||||
$maxLength = setting('core.create_character_name_max_length');
|
||||
|
||||
if(empty($errors) && empty($name))
|
||||
$errors[] = 'Please enter a new name for your character!';
|
||||
@@ -86,7 +86,7 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
$account_logged->setCustomField("premium_points", $points - $config['account_change_character_name_points']);
|
||||
$account_logged->setCustomField(setting('core.donate_column'), $points - setting('core.account_change_character_name_price'));
|
||||
$account_logged->logAction('Changed name from <b>' . $old_name . '</b> to <b>' . $player->getName() . '</b>.');
|
||||
$twig->display('success.html.twig', array(
|
||||
'title' => 'Character Name Changed',
|
||||
|
@@ -69,7 +69,7 @@ else
|
||||
$account_logged->logAction('Account password changed.');
|
||||
|
||||
$message = '';
|
||||
if($config['mail_enabled'] && $config['send_mail_when_change_password']) {
|
||||
if(setting('core.mail_enabled') && setting('core.mail_send_when_change_password')) {
|
||||
$mailBody = $twig->render('mail.password_changed.html.twig', array(
|
||||
'new_password' => $org_pass,
|
||||
'ip' => get_browser_real_ip(),
|
||||
@@ -89,4 +89,4 @@ else
|
||||
));
|
||||
setSession('password', $new_password);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,14 +20,14 @@ if(!$logged) {
|
||||
$sex_changed = false;
|
||||
$player_id = isset($_POST['player_id']) ? (int)$_POST['player_id'] : NULL;
|
||||
$new_sex = isset($_POST['new_sex']) ? (int)$_POST['new_sex'] : NULL;
|
||||
if((!$config['account_change_character_sex']))
|
||||
if((!setting('core.account_change_character_sex')))
|
||||
echo 'You cant change your character sex';
|
||||
else
|
||||
{
|
||||
$points = $account_logged->getCustomField('premium_points');
|
||||
$points = $account_logged->getCustomField(setting('core.donate_column'));
|
||||
if(isset($_POST['changesexsave']) && $_POST['changesexsave'] == 1) {
|
||||
if($points < $config['account_change_character_sex_points'])
|
||||
$errors[] = 'You need ' . $config['account_change_character_sex_points'] . ' premium points to change sex. You have <b>'.$points.'</b> premium points.';
|
||||
if($points < setting('core.account_change_character_sex_price'))
|
||||
$errors[] = 'You need ' . setting('core.account_change_character_sex_price') . ' premium points to change sex. You have <b>'.$points.'</b> premium points.';
|
||||
|
||||
if(empty($errors) && !isset($config['genders'][$new_sex])) {
|
||||
$errors[] = 'This sex is invalid.';
|
||||
@@ -66,7 +66,7 @@ else
|
||||
$new_sex_str = $config['genders'][$new_sex];
|
||||
|
||||
$player->save();
|
||||
$account_logged->setCustomField("premium_points", $points - $config['account_change_character_name_points']);
|
||||
$account_logged->setCustomField(setting('core.donate_column'), $points - setting('core.account_change_character_name_price'));
|
||||
$account_logged->logAction('Changed sex on character <b>' . $player->getName() . '</b> from <b>' . $old_sex_str . '</b> to <b>' . $new_sex_str . '</b>.');
|
||||
$twig->display('success.html.twig', array(
|
||||
'title' => 'Character Sex Changed',
|
||||
|
@@ -219,7 +219,7 @@ if($save)
|
||||
$tmp_account = (USE_ACCOUNT_NAME ? $account_name : $account_id);
|
||||
}
|
||||
|
||||
if($config['mail_enabled'] && $config['account_mail_verify'])
|
||||
if(setting('core.mail_enabled') && $config['account_mail_verify'])
|
||||
{
|
||||
$hash = md5(generateRandomString(16, true, true) . $email);
|
||||
$new_account->setCustomField('email_hash', $hash);
|
||||
@@ -294,7 +294,7 @@ if($save)
|
||||
'custom_buttons' => config('account_create_character_create') ? '' : null
|
||||
));
|
||||
|
||||
if($config['mail_enabled'] && $config['account_welcome_mail'])
|
||||
if(setting('core.mail_enabled') && $config['account_welcome_mail'])
|
||||
{
|
||||
$mailBody = $twig->render('account.welcome_mail.html.twig', array(
|
||||
'account' => $tmp_account
|
||||
@@ -313,7 +313,7 @@ if($save)
|
||||
}
|
||||
|
||||
$country_recognized = null;
|
||||
if($config['account_country_recognize']) {
|
||||
if(setting('core.account_country_recognize')) {
|
||||
$country_session = getSession('country');
|
||||
if($country_session !== false) { // get from session
|
||||
$country_recognized = $country_session;
|
||||
|
@@ -11,7 +11,7 @@
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Lost Account Interface';
|
||||
|
||||
if(!$config['mail_enabled'])
|
||||
if(!setting('core.mail_enabled'))
|
||||
{
|
||||
echo '<b>Account maker is not configured to send e-mails, you can\'t use Lost Account Interface. Contact with admin to get help.</b>';
|
||||
return;
|
||||
@@ -59,7 +59,7 @@ elseif($action == 'step1' && $action_type == 'email')
|
||||
$minutesleft = floor($insec / 60);
|
||||
$secondsleft = $insec - ($minutesleft * 60);
|
||||
$timeleft = $minutesleft.' minutes '.$secondsleft.' seconds';
|
||||
echo 'Account of selected character (<b>'.$nick.'</b>) received e-mail in last '.ceil($config['email_lai_sec_interval'] / 60).' minutes. You must wait '.$timeleft.' before you can use Lost Account Interface again.';
|
||||
echo 'Account of selected character (<b>'.$nick.'</b>) received e-mail in last '.ceil(setting('core.mail_lost_account_interval') / 60).' minutes. You must wait '.$timeleft.' before you can use Lost Account Interface again.';
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -104,7 +104,7 @@ elseif($action == 'sendcode')
|
||||
if(_mail($account_mail, $config['lua']['serverName'].' - Recover your account', $mailBody))
|
||||
{
|
||||
$account->setCustomField('email_code', $newcode);
|
||||
$account->setCustomField('email_next', (time() + $config['email_lai_sec_interval']));
|
||||
$account->setCustomField('email_next', (time() + setting('core.mail_lost_account_interval')));
|
||||
echo '<br />Details about steps required to recover your account has been sent to <b>' . $account_mail . '</b>. You should receive this email within 15 minutes. Please check your inbox/spam directory.';
|
||||
}
|
||||
else
|
||||
@@ -122,7 +122,7 @@ elseif($action == 'sendcode')
|
||||
$minutesleft = floor($insec / 60);
|
||||
$secondsleft = $insec - ($minutesleft * 60);
|
||||
$timeleft = $minutesleft.' minutes '.$secondsleft.' seconds';
|
||||
echo 'Account of selected character (<b>'.$nick.'</b>) received e-mail in last '.ceil($config['email_lai_sec_interval'] / 60).' minutes. You must wait '.$timeleft.' before you can use Lost Account Interface again.';
|
||||
echo 'Account of selected character (<b>'.$nick.'</b>) received e-mail in last '.ceil(setting('core.mail_lost_account_interval') / 60).' minutes. You must wait '.$timeleft.' before you can use Lost Account Interface again.';
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@@ -35,7 +35,7 @@ if(empty($recovery_key))
|
||||
$account_registered = '<b><span style="color: red">No</span></b>';
|
||||
else
|
||||
{
|
||||
if($config['generate_new_reckey'] && $config['mail_enabled'])
|
||||
if(setting('core.account_generate_new_reckey') && setting('core.mail_enabled'))
|
||||
$account_registered = '<b><span style="color: green">Yes ( <a href="' . getLink('account/register/new') . '"> Buy new Recovery Key </a> )</span></b>';
|
||||
else
|
||||
$account_registered = '<b><span style="color: green">Yes</span></b>';
|
||||
|
@@ -31,7 +31,7 @@ if(isset($_POST['registeraccountsave']) && $_POST['registeraccountsave'] == "1")
|
||||
$account_logged->logAction('Generated recovery key.');
|
||||
$message = '';
|
||||
|
||||
if($config['mail_enabled'] && $config['send_mail_when_generate_reckey'])
|
||||
if(setting('core.mail_enabled') && setting('core.mail_send_when_generate_reckey'))
|
||||
{
|
||||
$mailBody = $twig->render('mail.account.register.html.twig', array(
|
||||
'recovery_key' => $new_rec_key
|
||||
|
@@ -21,18 +21,18 @@ if(isset($_POST['reg_password']))
|
||||
$reg_password = encrypt((USE_ACCOUNT_SALT ? $account_logged->getCustomField('salt') : '') . $_POST['reg_password']);
|
||||
|
||||
$reckey = $account_logged->getCustomField('key');
|
||||
if((!$config['generate_new_reckey'] || !$config['mail_enabled']) || empty($reckey)) {
|
||||
if((!setting('core.account_generate_new_reckey') || !setting('core.mail_enabled')) || empty($reckey)) {
|
||||
$errors[] = 'You cant get new recovery key.';
|
||||
$twig->display('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
else
|
||||
{
|
||||
$points = $account_logged->getCustomField('premium_points');
|
||||
$points = $account_logged->getCustomField(setting('core.donate_column'));
|
||||
if(isset($_POST['registeraccountsave']) && $_POST['registeraccountsave'] == '1')
|
||||
{
|
||||
if($reg_password == $account_logged->getPassword())
|
||||
{
|
||||
if($points >= $config['generate_new_reckey_price'])
|
||||
if($points >= setting('core.account_generate_new_reckey_price'))
|
||||
{
|
||||
$show_form = false;
|
||||
$new_rec_key = generateRandomString(10, false, true, true);
|
||||
@@ -43,10 +43,10 @@ else
|
||||
|
||||
if(_mail($account_logged->getEMail(), $config['lua']['serverName']." - new recovery key", $mailBody))
|
||||
{
|
||||
$account_logged->setCustomField("key", $new_rec_key);
|
||||
$account_logged->setCustomField("premium_points", $account_logged->getCustomField("premium_points") - $config['generate_new_reckey_price']);
|
||||
$account_logged->logAction('Generated new recovery key for ' . $config['generate_new_reckey_price'] . ' premium points.');
|
||||
$message = '<br />Your recovery key were send on email address <b>'.$account_logged->getEMail().'</b> for '.$config['generate_new_reckey_price'].' premium points.';
|
||||
$account_logged->setCustomField('key', $new_rec_key);
|
||||
$account_logged->setCustomField(setting('core.donate_column'), $account_logged->getCustomField(setting('core.donate_column')) - setting('core.account_generate_new_reckey_price'));
|
||||
$account_logged->logAction('Generated new recovery key for ' . setting('core.account_generate_new_reckey_price') . ' premium points.');
|
||||
$message = '<br />Your recovery key were send on email address <b>'.$account_logged->getEMail().'</b> for '.setting('core.account_generate_new_reckey_price').' premium points.';
|
||||
}
|
||||
else
|
||||
$message = '<br /><p class="error">An error occurred while sending email ( <b>'.$account_logged->getEMail().'</b> ) with recovery key! Recovery key not changed. Try again later. For Admin: More info can be found in system/logs/mailer-error.log</p>';
|
||||
@@ -57,7 +57,7 @@ else
|
||||
));
|
||||
}
|
||||
else
|
||||
$errors[] = 'You need '.$config['generate_new_reckey_price'].' premium points to generate new recovery key. You have <b>'.$points.'<b> premium points.';
|
||||
$errors[] = 'You need ' . setting('core.account_generate_new_reckey_price') . ' premium points to generate new recovery key. You have <b>'.$points.'<b> premium points.';
|
||||
}
|
||||
else
|
||||
$errors[] = 'Wrong password to account.';
|
||||
|
@@ -340,8 +340,8 @@ WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, kil
|
||||
}
|
||||
|
||||
// signature
|
||||
if($config['signature_enabled']) {
|
||||
$signature_url = BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . urlencode($player->getName()) . '.png';
|
||||
if(setting('core.signature_enabled')) {
|
||||
$signature_url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . urlencode($player->getName()) . '.png';
|
||||
}
|
||||
|
||||
$hidden = $player->isHidden();
|
||||
|
@@ -14,7 +14,7 @@ $title = 'Creatures';
|
||||
|
||||
if (empty($_REQUEST['name'])) {
|
||||
// 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();
|
||||
|
||||
if ($preview) {
|
||||
@@ -62,7 +62,7 @@ if (isset($creature['name'])) {
|
||||
$item['name'] = getItemNameById($item['id']);
|
||||
$item['rarity_chance'] = round($item['chance'] / 1000, 2);
|
||||
$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;
|
||||
|
@@ -11,9 +11,9 @@ defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Experience Table';
|
||||
|
||||
$experience = array();
|
||||
$columns = $config['experiencetable_columns'];
|
||||
$columns = setting('core.experience_table_columns');
|
||||
for($i = 0; $i < $columns; $i++) {
|
||||
for($level = $i * $config['experiencetable_rows'] + 1; $level < $i * $config['experiencetable_rows'] + ($config['experiencetable_rows'] + 1); $level++) {
|
||||
for($level = $i * setting('core.experience_table_rows') + 1; $level < $i * setting('core.experience_table_rows') + (setting('core.experience_table_rows') + 1); $level++) {
|
||||
$experience[$level] = OTS_Toolbox::experienceForLevel($level);
|
||||
}
|
||||
}
|
||||
|
@@ -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 = [];
|
||||
|
@@ -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. <a href="?subtopic=accountmanagement&redirect=' . BASE_URL . urlencode('?subtopic=forum') . '">Log in</a> to post on the forum.<br /><br />';
|
||||
return false;
|
||||
}
|
||||
|
||||
require_once LIBS . 'forum.php';
|
||||
|
||||
$sections = array();
|
||||
foreach(getForumBoards() as $section) {
|
||||
$sections[$section['id']] = array(
|
||||
|
@@ -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 '<br />Thank you for editing post.<br /><a href="' . getForumThreadLink($thread['first_post'], $_page) . '">GO BACK TO LAST THREAD</a>';
|
||||
}
|
||||
@@ -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'));
|
||||
}
|
||||
|
@@ -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.';
|
||||
|
@@ -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 '<br />Thank you for posting.<br /><a href="' . getForumThreadLink($thread_id, $_page) . '">GO BACK TO LAST THREAD</a>';
|
||||
}
|
||||
@@ -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'));
|
||||
}
|
||||
|
||||
|
@@ -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'));
|
||||
}
|
||||
|
@@ -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));
|
||||
}
|
||||
|
@@ -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 .= '<a href="' . getForumBoardLink($section_id, $i) . '">'.($i + 1).'</a> ';
|
||||
else
|
||||
@@ -44,7 +47,7 @@ if(!$sections[$section_id]['closed'] || Forum::isModerator()) {
|
||||
}
|
||||
|
||||
echo '<br /><br />Page: '.$links_to_pages.'<br />';
|
||||
$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 '<table width="100%">
|
||||
|
@@ -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 = '';
|
||||
$thread_id = (int) $_REQUEST['id'];
|
||||
@@ -30,14 +33,14 @@ if(!Forum::hasAccess($thread_starter['section'])) {
|
||||
}
|
||||
|
||||
$posts_count = $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`.`first_post` = ".(int) $thread_id)->fetch();
|
||||
for($i = 0; $i < $posts_count['posts_count'] / $config['forum_threads_per_page']; $i++) {
|
||||
for($i = 0; $i < $posts_count['posts_count'] / setting('core.forum_threads_per_page'); $i++) {
|
||||
if($i != $_page)
|
||||
$links_to_pages .= '<a href="' . getForumThreadLink($thread_id, $i) . '">'.($i + 1).'</a> ';
|
||||
else
|
||||
$links_to_pages .= '<b>'.($i + 1).' </b>';
|
||||
}
|
||||
|
||||
$posts = $db->query("SELECT `players`.`id` as `player_id`, `" . FORUM_TABLE_PREFIX . "forum`.`id`,`" . FORUM_TABLE_PREFIX . "forum`.`first_post`, `" . FORUM_TABLE_PREFIX . "forum`.`section`,`" . FORUM_TABLE_PREFIX . "forum`.`post_text`, `" . FORUM_TABLE_PREFIX . "forum`.`post_topic`, `" . FORUM_TABLE_PREFIX . "forum`.`post_date` AS `date`, `" . FORUM_TABLE_PREFIX . "forum`.`post_smile`, `" . FORUM_TABLE_PREFIX . "forum`.`post_html`, `" . FORUM_TABLE_PREFIX . "forum`.`author_aid`, `" . FORUM_TABLE_PREFIX . "forum`.`author_guid`, `" . FORUM_TABLE_PREFIX . "forum`.`last_edit_aid`, `" . FORUM_TABLE_PREFIX . "forum`.`edit_date` FROM `players`, `" . FORUM_TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . FORUM_TABLE_PREFIX . "forum`.`author_guid` AND `" . FORUM_TABLE_PREFIX . "forum`.`first_post` = ".$thread_id." ORDER BY `" . FORUM_TABLE_PREFIX . "forum`.`post_date` LIMIT ".$config['forum_posts_per_page']." OFFSET ".($_page * $config['forum_posts_per_page']))->fetchAll();
|
||||
$posts = $db->query("SELECT `players`.`id` as `player_id`, `" . FORUM_TABLE_PREFIX . "forum`.`id`,`" . FORUM_TABLE_PREFIX . "forum`.`first_post`, `" . FORUM_TABLE_PREFIX . "forum`.`section`,`" . FORUM_TABLE_PREFIX . "forum`.`post_text`, `" . FORUM_TABLE_PREFIX . "forum`.`post_topic`, `" . FORUM_TABLE_PREFIX . "forum`.`post_date` AS `date`, `" . FORUM_TABLE_PREFIX . "forum`.`post_smile`, `" . FORUM_TABLE_PREFIX . "forum`.`post_html`, `" . FORUM_TABLE_PREFIX . "forum`.`author_aid`, `" . FORUM_TABLE_PREFIX . "forum`.`author_guid`, `" . FORUM_TABLE_PREFIX . "forum`.`last_edit_aid`, `" . FORUM_TABLE_PREFIX . "forum`.`edit_date` FROM `players`, `" . FORUM_TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . FORUM_TABLE_PREFIX . "forum`.`author_guid` AND `" . FORUM_TABLE_PREFIX . "forum`.`first_post` = ".$thread_id." ORDER BY `" . FORUM_TABLE_PREFIX . "forum`.`post_date` LIMIT " . setting('core.forum_posts_per_page') . " OFFSET ".($_page * setting('core.forum_posts_per_page')))->fetchAll();
|
||||
|
||||
if(isset($posts[0]['player_id'])) {
|
||||
$db->query("UPDATE `" . FORUM_TABLE_PREFIX . "forum` SET `views`=`views`+1 WHERE `id` = ".(int) $thread_id);
|
||||
|
@@ -11,8 +11,8 @@
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Highscores';
|
||||
|
||||
$configHighscoresCountryBox = config('highscores_country_box');
|
||||
if(config('account_country') && $configHighscoresCountryBox)
|
||||
$settingHighscoresCountryBox = setting('core.highscores_country_box');
|
||||
if(config('account_country') && $settingHighscoresCountryBox)
|
||||
require SYSTEM . 'countries.conf.php';
|
||||
|
||||
$list = $_GET['list'] ?? 'experience';
|
||||
@@ -25,11 +25,11 @@ if(!is_numeric($page) || $page < 1 || $page > PHP_INT_MAX) {
|
||||
|
||||
$add_sql = '';
|
||||
|
||||
$configHighscoresVocationBox = config('highscores_vocation_box');
|
||||
$settingHighscoresVocationBox = setting('core.highscores_vocation_box');
|
||||
$configVocations = config('vocations');
|
||||
$configVocationsAmount = config('vocations_amount');
|
||||
|
||||
if($configHighscoresVocationBox && $vocation !== 'all')
|
||||
if($settingHighscoresVocationBox && $vocation !== 'all')
|
||||
{
|
||||
foreach($configVocations as $id => $name) {
|
||||
if(strtolower($name) == $vocation) {
|
||||
@@ -99,12 +99,12 @@ else
|
||||
break;
|
||||
|
||||
case 'frags':
|
||||
if(config('highscores_frags'))
|
||||
if(setting('core.highscores_frags'))
|
||||
$skill = SKILL_FRAGS;
|
||||
break;
|
||||
|
||||
case 'balance':
|
||||
if(config('highscores_balance'))
|
||||
if(setting('core.highscores_balance'))
|
||||
$skill = SKILL_BALANCE;
|
||||
break;
|
||||
}
|
||||
@@ -125,9 +125,9 @@ if($db->hasColumn('players', 'deletion'))
|
||||
$outfit_addons = false;
|
||||
$outfit = '';
|
||||
|
||||
$configHighscoresOutfit = config('highscores_outfit');
|
||||
$settingHighscoresOutfit = setting('core.highscores_outfit');
|
||||
|
||||
if($configHighscoresOutfit) {
|
||||
if($settingHighscoresOutfit) {
|
||||
$outfit = ', lookbody, lookfeet, lookhead, looklegs, looktype';
|
||||
if($db->hasColumn('players', 'lookaddons')) {
|
||||
$outfit .= ', lookaddons';
|
||||
@@ -135,7 +135,7 @@ if($configHighscoresOutfit) {
|
||||
}
|
||||
}
|
||||
|
||||
$configHighscoresPerPage = config('highscores_per_page');
|
||||
$configHighscoresPerPage = setting('core.highscores_per_page');
|
||||
$limit = $configHighscoresPerPage + 1;
|
||||
|
||||
$needReCache = true;
|
||||
@@ -164,15 +164,15 @@ if (!isset($highscores) || empty($highscores)) {
|
||||
POT::SKILL_FISH => 'skill_fishing',
|
||||
);
|
||||
|
||||
$highscores = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,vocation' . $promotion . $outfit . ', ' . $skill_ids[$skill] . ' as value FROM accounts,players WHERE players.id NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ') AND players.' . $deleted . ' = 0 AND players.group_id < ' . config('highscores_groups_hidden') . ' ' . $add_sql . ' AND accounts.id = players.account_id ORDER BY ' . $skill_ids[$skill] . ' DESC LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
|
||||
$highscores = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,vocation' . $promotion . $outfit . ', ' . $skill_ids[$skill] . ' as value FROM accounts,players WHERE players.id NOT IN (' . implode(', ', setting('core.highscores_ids_hidden')) . ') AND players.' . $deleted . ' = 0 AND players.group_id < ' . setting('core.highscores_groups_hidden') . ' ' . $add_sql . ' AND accounts.id = players.account_id ORDER BY ' . $skill_ids[$skill] . ' DESC LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
|
||||
} else
|
||||
$highscores = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',value,level,vocation' . $promotion . $outfit . ' FROM accounts,players,player_skills WHERE players.id NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ') AND players.' . $deleted . ' = 0 AND players.group_id < ' . config('highscores_groups_hidden') . ' ' . $add_sql . ' AND players.id = player_skills.player_id AND player_skills.skillid = ' . $skill . ' AND accounts.id = players.account_id ORDER BY value DESC, count DESC LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
|
||||
$highscores = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',value,level,vocation' . $promotion . $outfit . ' FROM accounts,players,player_skills WHERE players.id NOT IN (' . implode(', ', setting('core.highscores_ids_hidden')) . ') AND players.' . $deleted . ' = 0 AND players.group_id < ' . setting('core.highscores_groups_hidden') . ' ' . $add_sql . ' AND players.id = player_skills.player_id AND player_skills.skillid = ' . $skill . ' AND accounts.id = players.account_id ORDER BY value DESC, count DESC LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
|
||||
} else if ($skill == SKILL_FRAGS) // frags
|
||||
{
|
||||
if ($db->hasTable('player_killers')) {
|
||||
$highscores = $db->query('SELECT accounts.country, players.id, players.name' . $online . ',level, vocation' . $promotion . $outfit . ', COUNT(`player_killers`.`player_id`) as value' .
|
||||
' FROM `accounts`, `players`, `player_killers` ' .
|
||||
' WHERE players.id NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ') AND players.' . $deleted . ' = 0 AND players.group_id < ' . config('highscores_groups_hidden') . ' ' . $add_sql . ' AND players.id = player_killers.player_id AND accounts.id = players.account_id' .
|
||||
' WHERE players.id NOT IN (' . implode(', ', setting('core.highscores_ids_hidden')) . ') AND players.' . $deleted . ' = 0 AND players.group_id < ' . setting('core.highscores_groups_hidden') . ' ' . $add_sql . ' AND players.id = player_killers.player_id AND accounts.id = players.account_id' .
|
||||
' GROUP BY `player_id`' .
|
||||
' ORDER BY value DESC' .
|
||||
' LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
|
||||
@@ -183,9 +183,9 @@ if (!isset($highscores) || empty($highscores)) {
|
||||
FROM `players` p
|
||||
LEFT JOIN `accounts` a ON `a`.`id` = `p`.`account_id`
|
||||
LEFT JOIN `player_deaths` pd ON `pd`.`killed_by` = `p`.`name`
|
||||
WHERE `p`.id NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ')
|
||||
WHERE `p`.id NOT IN (' . implode(', ', setting('core.highscores_ids_hidden')) . ')
|
||||
AND `p`.' . $deleted . ' = 0
|
||||
AND `p`.group_id < ' . config('highscores_groups_hidden') . ' ' . $add_sql . '
|
||||
AND `p`.group_id < ' . setting('core.highscores_groups_hidden') . ' ' . $add_sql . '
|
||||
AND `pd`.`unjustified` = 1
|
||||
GROUP BY `killed_by`
|
||||
ORDER BY value DESC
|
||||
@@ -193,19 +193,19 @@ if (!isset($highscores) || empty($highscores)) {
|
||||
}
|
||||
} else if ($skill == SKILL_BALANCE) // balance
|
||||
{
|
||||
$highscores = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,balance as value,vocation' . $promotion . $outfit . ' FROM accounts,players WHERE players.id NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ') AND players.' . $deleted . ' = 0 AND players.group_id < ' . config('highscores_groups_hidden') . ' ' . $add_sql . ' AND accounts.id = players.account_id ORDER BY value DESC LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
|
||||
$highscores = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,balance as value,vocation' . $promotion . $outfit . ' FROM accounts,players WHERE players.id NOT IN (' . implode(', ', setting('core.highscores_ids_hidden')) . ') AND players.' . $deleted . ' = 0 AND players.group_id < ' . setting('core.highscores_groups_hidden') . ' ' . $add_sql . ' AND accounts.id = players.account_id ORDER BY value DESC LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
|
||||
} else {
|
||||
if ($skill == POT::SKILL__MAGLEVEL) {
|
||||
$highscores = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',maglevel,level,vocation' . $promotion . $outfit . ' FROM accounts, players WHERE players.id NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ') AND players.' . $deleted . ' = 0 ' . $add_sql . ' AND players.group_id < ' . config('highscores_groups_hidden') . ' AND accounts.id = players.account_id ORDER BY maglevel DESC, manaspent DESC LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
|
||||
$highscores = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',maglevel,level,vocation' . $promotion . $outfit . ' FROM accounts, players WHERE players.id NOT IN (' . implode(', ', setting('core.highscores_ids_hidden')) . ') AND players.' . $deleted . ' = 0 ' . $add_sql . ' AND players.group_id < ' . setting('core.highscores_groups_hidden') . ' AND accounts.id = players.account_id ORDER BY maglevel DESC, manaspent DESC LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
|
||||
} else { // level
|
||||
$highscores = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,experience,vocation' . $promotion . $outfit . ' FROM accounts, players WHERE players.id NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ') AND players.' . $deleted . ' = 0 ' . $add_sql . ' AND players.group_id < ' . config('highscores_groups_hidden') . ' AND accounts.id = players.account_id ORDER BY level DESC, experience DESC LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
|
||||
$highscores = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,experience,vocation' . $promotion . $outfit . ' FROM accounts, players WHERE players.id NOT IN (' . implode(', ', setting('core.highscores_ids_hidden')) . ') AND players.' . $deleted . ' = 0 ' . $add_sql . ' AND players.group_id < ' . setting('core.highscores_groups_hidden') . ' AND accounts.id = players.account_id ORDER BY level DESC, experience DESC LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
|
||||
$list = 'experience';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($cache->enabled() && $needReCache) {
|
||||
$cache->set($cacheKey, serialize($highscores), config('highscores_cache_ttl') * 60);
|
||||
$cache->set($cacheKey, serialize($highscores), setting('core.highscores_cache_ttl') * 60);
|
||||
}
|
||||
|
||||
$online_exist = false;
|
||||
@@ -227,7 +227,7 @@ if($db->hasTable('players_online') && count($players) > 0) {
|
||||
$show_link_to_next_page = false;
|
||||
$i = 0;
|
||||
|
||||
$configHighscoresVocation = config('highscores_vocation');
|
||||
$settingHighscoresVocation = setting('core.highscores_vocation');
|
||||
|
||||
foreach($highscores as $id => &$player)
|
||||
{
|
||||
@@ -248,7 +248,7 @@ foreach($highscores as $id => &$player)
|
||||
$player['experience'] = number_format($player['experience']);
|
||||
}
|
||||
|
||||
if($configHighscoresVocation) {
|
||||
if($settingHighscoresVocation) {
|
||||
if(isset($player['promotion'])) {
|
||||
if((int)$player['promotion'] > 0) {
|
||||
$player['vocation'] += ($player['promotion'] * $configVocationsAmount);
|
||||
@@ -266,7 +266,7 @@ foreach($highscores as $id => &$player)
|
||||
|
||||
$player['link'] = getPlayerLink($player['name'], false);
|
||||
$player['flag'] = getFlagImage($player['country']);
|
||||
if($configHighscoresOutfit) {
|
||||
if($settingHighscoresOutfit) {
|
||||
$player['outfit'] = '<img style="position:absolute;margin-top:' . (in_array($player['looktype'], config('outfit_images_wrong_looktypes')) ? '-15px;margin-left:5px' : '-45px;margin-left:-25px') . ';" src="' . config('outfit_images_url') . '?id=' . $player['looktype'] . ($outfit_addons ? '&addons=' . $player['lookaddons'] : '') . '&head=' . $player['lookhead'] . '&body=' . $player['lookbody'] . '&legs=' . $player['looklegs'] . '&feet=' . $player['lookfeet'] . '" alt="" />';
|
||||
}
|
||||
$player['rank'] = $offset + $i;
|
||||
@@ -302,10 +302,10 @@ $types = array(
|
||||
'fishing' => 'Fishing',
|
||||
);
|
||||
|
||||
if(config('highscores_frags')) {
|
||||
if(setting('core.highscores_frags')) {
|
||||
$types['frags'] = 'Frags';
|
||||
}
|
||||
if(config('highscores_balance'))
|
||||
if(setting('core.highscores_balance'))
|
||||
$types['balance'] = 'Balance';
|
||||
|
||||
/** @var Twig\Environment $twig */
|
||||
|
@@ -23,7 +23,7 @@ if(!$groups->count())
|
||||
|
||||
$outfit_addons = false;
|
||||
$outfit = '';
|
||||
if($config['team_display_outfit']) {
|
||||
if(setting('core.team_outfit')) {
|
||||
$outfit = ', lookbody, lookfeet, lookhead, looklegs, looktype';
|
||||
if($db->hasColumn('players', 'lookaddons')) {
|
||||
$outfit .= ', lookaddons';
|
||||
@@ -56,12 +56,12 @@ foreach($groupList as $id => $group)
|
||||
$members[] = array(
|
||||
'group_name' => $group->getName(),
|
||||
'player' => $member,
|
||||
'outfit' => $config['team_display_outfit'] ? $config['outfit_images_url'] . '?id=' . $member->getLookType() . ($outfit_addons ? '&addons=' . $member->getLookAddons() : '') . '&head=' . $member->getLookHead() . '&body=' . $member->getLookBody() . '&legs=' . $member->getLookLegs() . '&feet=' . $member->getLookFeet() : null,
|
||||
'status' => $config['team_display_status'] ? $member->isOnline() : null,
|
||||
'outfit' => setting('core.team_outfit') ? setting('core.outfit_images_url') . '?id=' . $member->getLookType() . ($outfit_addons ? '&addons=' . $member->getLookAddons() : '') . '&head=' . $member->getLookHead() . '&body=' . $member->getLookBody() . '&legs=' . $member->getLookLegs() . '&feet=' . $member->getLookFeet() : null,
|
||||
'status' => setting('core.team_status') ? $member->isOnline() : null,
|
||||
'link' => getPlayerLink($member->getName()),
|
||||
'flag_image' => $config['account_country'] ? getFlagImage($member->getAccount()->getCountry()) : null,
|
||||
'world_name' => ($config['multiworld'] || $config['team_display_world']) ? getWorldName($member->getWorldId()) : null,
|
||||
'last_login' => $config['team_display_lastlogin'] ? $lastLogin : null
|
||||
'flag_image' => setting('core.account_country') ? getFlagImage($member->getAccount()->getCountry()) : null,
|
||||
'world_name' => (setting('core.multiworld') || setting('core.team_world')) ? getWorldName($member->getWorldId()) : null,
|
||||
'last_login' => setting('core.team_lastlogin') ? $lastLogin : null
|
||||
);
|
||||
}
|
||||
|
||||
|
1638
system/settings.php
Normal file
1638
system/settings.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@ $status['lastCheck'] = 0;
|
||||
$status['uptime'] = '0h 0m';
|
||||
$status['monsters'] = 0;
|
||||
|
||||
if(config('status_enabled') === false) {
|
||||
if(setting('core.status_enabled') === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -37,9 +37,10 @@ else if(isset($config['lua']['status_port'])) {
|
||||
}
|
||||
|
||||
// ip check
|
||||
if(isset($config['status_ip'][0]))
|
||||
$settingIP = setting('core.status_ip');
|
||||
if(isset($settingIP[0]))
|
||||
{
|
||||
$status_ip = $config['status_ip'];
|
||||
$status_ip = $settingIP;
|
||||
}
|
||||
elseif(!isset($status_ip[0])) // try localhost if no ip specified
|
||||
{
|
||||
@@ -48,10 +49,11 @@ elseif(!isset($status_ip[0])) // try localhost if no ip specified
|
||||
|
||||
// port check
|
||||
$status_port = $config['lua']['statusPort'];
|
||||
if(isset($config['status_port'][0])) {
|
||||
$status_port = $config['status_port'];
|
||||
$settingPort = setting('core.status_port');
|
||||
if(isset($settingPort[0])) {
|
||||
$status_port = $settingPort;
|
||||
}
|
||||
elseif(!isset($status_port[0])) // try 7171 if no ip specified
|
||||
elseif(!isset($status_port[0])) // try 7171 if no port specified
|
||||
{
|
||||
$status_port = 7171;
|
||||
}
|
||||
@@ -94,9 +96,9 @@ if(isset($config['lua']['statustimeout']))
|
||||
|
||||
// get status timeout from server config
|
||||
$status_timeout = eval('return ' . $config['lua']['statusTimeout'] . ';') / 1000 + 1;
|
||||
$status_interval = @$config['status_interval'];
|
||||
if($status_interval && $status_timeout < $config['status_interval']) {
|
||||
$status_timeout = $config['status_interval'];
|
||||
$status_interval = setting('core.status_interval');
|
||||
if($status_interval && $status_timeout < $status_interval) {
|
||||
$status_timeout = $status_interval;
|
||||
}
|
||||
|
||||
if($status['lastCheck'] + $status_timeout < time()) {
|
||||
|
@@ -10,8 +10,8 @@
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
// template
|
||||
$template_name = $config['template'];
|
||||
if($config['template_allow_change'])
|
||||
$template_name = setting('core.template');
|
||||
if(setting('core.template_allow_change'))
|
||||
{
|
||||
if(isset($_GET['template']))
|
||||
{
|
||||
@@ -111,12 +111,13 @@ $template['link_screenshots'] = getLink('gallery');
|
||||
$template['link_movies'] = getLink('videos');
|
||||
|
||||
$template['link_gifts_history'] = getLink('gifts', 'history');
|
||||
if($config['forum'] != '')
|
||||
$forumSetting = setting('core.forum');
|
||||
if($forumSetting != '')
|
||||
{
|
||||
if(strtolower($config['forum']) == 'site')
|
||||
if(strtolower($forumSetting) == 'site')
|
||||
$template['link_forum'] = "<a href='" . getLink('forum') . "'>";
|
||||
else
|
||||
$template['link_forum'] = "<a href='" . $config['forum'] . "' target='_blank'>";
|
||||
$template['link_forum'] = "<a href='" . $forumSetting . "' target='_blank'>";
|
||||
}
|
||||
|
||||
$twig->addGlobal('template_path', $template_path);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
To change a name of character select player and choose a new name.<br/>
|
||||
<span style="color: red">Change name cost {{ config.account_change_character_name_points }} premium points. You have {{ points }} premium points.</span><br/><br/>
|
||||
<span style="color: red">Change name cost {{ setting('core.account_change_character_name_price') }} premium points. You have {{ points }} premium points.</span><br/><br/>
|
||||
<form action="{{ getLink('account/character/name') }}" method="post">
|
||||
<input type="hidden" name="changenamesave" value="1">
|
||||
<div class="TableContainer">
|
||||
|
@@ -1,5 +1,5 @@
|
||||
To change a sex of character select player and choose a new sex.<br/>
|
||||
<span style="color: red">Change sex cost {{ config.account_change_character_sex_points }} premium points. You have {{ points }} premium points.</span><br/><br/>
|
||||
<span style="color: red">Change sex cost {{ setting('core.account_change_character_sex_price') }} premium points. You have {{ points }} premium points.</span><br/><br/>
|
||||
<form action="{{ getLink('account/character/sex') }}" method="post">
|
||||
<input type="hidden" name="changesexsave" value="1"/>
|
||||
<div class="TableContainer">
|
||||
@@ -73,4 +73,4 @@ To change a sex of character select player and choose a new sex.<br/>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</table>
|
||||
|
@@ -59,7 +59,7 @@
|
||||
<td></td><td><span id="email_error" class="FormFieldError">{% if errors.email is defined %}{{ errors.email }}{% endif %}</span></td>
|
||||
</tr>
|
||||
|
||||
{% if config.mail_enabled and config.account_mail_verify %}
|
||||
{% if setting('core.mail_enabled') and config.account_mail_verify %}
|
||||
<tr><td></td><td><span><strong>Please use real address!<br/>We will send a link to validate your Email.</strong></span></td></tr>
|
||||
{% endif %}
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
|
||||
{{ hook('HOOK_ACCOUNT_CREATE_BETWEEN_BOXES_1') }}
|
||||
|
||||
{% if (not config.mail_enabled or not config.account_mail_verify) and config.account_create_character_create %}
|
||||
{% if (not setting('core.mail_enabled') or not config.account_mail_verify) and config.account_create_character_create %}
|
||||
<tr>
|
||||
<td>
|
||||
<div class="TableShadowContainerRightTop">
|
||||
@@ -140,7 +140,7 @@
|
||||
<span{% if errors.name is defined %} class="red"{% endif %}>Character Name:</span>
|
||||
</td>
|
||||
<td>
|
||||
<input id="character_name" name="name" size="{{ config.character_name_max_length }}" maxlength="{{ config.character_name_max_length }}" value="{{ name }}"/>
|
||||
<input id="character_name" name="name" size="{{ setting('core.create_character_name_max_length') }}" maxlength="{{ setting('core.create_character_name_max_length') }}" value="{{ name }}"/>
|
||||
<img id="character_indicator" src="images/global/general/{% if not save or errors.name is defined %}n{% endif %}ok.gif" style="display: none;" />
|
||||
<br>
|
||||
</td>
|
||||
|
@@ -45,7 +45,7 @@ In any case the name must not violate the naming conventions stated in the <a hr
|
||||
</tr>
|
||||
<tr class="Odd">
|
||||
<td>
|
||||
<input name="name" id="character_name" value="{{ name }}" size="{{ config.character_name_max_length }}" maxlength="{{ config.character_name_max_length }}" >
|
||||
<input name="name" id="character_name" value="{{ name }}" size="{{ setting('core.create_character_name_max_length') }}" maxlength="{{ setting('core.create_character_name_max_length') }}" >
|
||||
<img id="character_indicator" src="images/global/general/{% if not save or errors.name is defined %}n{% endif %}ok.gif" />
|
||||
<br/>
|
||||
<span style="font-size: 10px">
|
||||
@@ -145,4 +145,4 @@ In any case the name must not violate the naming conventions stated in the <a hr
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<script type="text/javascript" src="tools/check_name.js"></script>
|
||||
<script type="text/javascript" src="tools/check_name.js"></script>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
To generate new recovery key for your account please enter your password.<br/>
|
||||
<span style="color: red"><b>New recovery key cost {{ config.generate_new_reckey_price }} Premium Points.</span> You have {{ points }} premium points. You will receive e-mail with this recovery key.</b><br/>
|
||||
<span style="color: red"><b>New recovery key cost {{ setting('core.account_generate_new_reckey_price') }} Premium Points.</span> You have {{ points }} premium points. You will receive e-mail with this recovery key.</b><br/>
|
||||
<form action="{{ getLink('account/register/new') }}" method="post">
|
||||
<input type="hidden" name="registeraccountsave" value="1">
|
||||
<div class="TableContainer" >
|
||||
@@ -56,4 +56,4 @@ To generate new recovery key for your account please enter your password.<br/>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</table>
|
||||
|
@@ -39,10 +39,10 @@
|
||||
{% for name, link in menus %}
|
||||
<a href="{{ getLink(link) }}">{{ name }}</a>
|
||||
{% endfor %}
|
||||
{% if config.account_change_character_name %}
|
||||
{% if setting('core.account_change_character_name') %}
|
||||
<a href="{{ getLink('account/character/name') }}">Change Name</a>
|
||||
{% endif %}
|
||||
{% if config.account_change_character_sex %}
|
||||
{% if setting('core.account_change_character_sex') %}
|
||||
<a href="{{ getLink('account/character/sex') }}">Change Sex</a>
|
||||
{% endif %}
|
||||
<a href="{{ getLink('account/logout') }}">Logout</a>
|
||||
@@ -192,7 +192,7 @@
|
||||
{% include('buttons.base.html.twig') %}
|
||||
</form>
|
||||
</td>
|
||||
{% if config.account_change_character_name %}
|
||||
{% if setting('core.account_change_character_name') %}
|
||||
<td>
|
||||
<form action="{{ getLink('account/character/name') }}" method="post" >
|
||||
{% set button_name = 'Change Name' %}
|
||||
@@ -200,7 +200,7 @@
|
||||
</form>
|
||||
</td>
|
||||
{% endif %}
|
||||
{% if config.account_change_character_sex %}
|
||||
{% if setting('core.account_change_character_sex') %}
|
||||
<td>
|
||||
<form action="{{ getLink('account/character/sex') }}" method="post" >
|
||||
{% set button_name = 'Change Sex' %}
|
||||
|
105
system/templates/admin.settings.html.twig
Normal file
105
system/templates/admin.settings.html.twig
Normal file
@@ -0,0 +1,105 @@
|
||||
<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 id="settings" 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/>
|
||||
{{ settingsParsed|raw }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
.setting-default {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
function doShowHide(el, show)
|
||||
{
|
||||
if (show) {
|
||||
$(el).show()
|
||||
}
|
||||
else {
|
||||
$(el).hide()
|
||||
}
|
||||
}
|
||||
|
||||
{% for key, value in settings %}
|
||||
{% if value.show_if is defined %}
|
||||
$(function () {
|
||||
$('input[name="settings[{{ value.show_if[0] }}]"]').change(function () {
|
||||
performChecks_{{ key }}(this);
|
||||
});
|
||||
|
||||
{% if settings[value.show_if[0]]['type'] == 'boolean' %}
|
||||
performChecks_{{ key }}('input[name="settings[{{ value.show_if[0] }}]"]:checked');
|
||||
{% else %}
|
||||
performChecks_{{ key }}('input[name="settings[{{ value.show_if[0] }}]"]');
|
||||
{% endif %}
|
||||
});
|
||||
|
||||
function performChecks_{{ key }}(el)
|
||||
{
|
||||
let success = false;
|
||||
let thisVal = $(el).val();
|
||||
|
||||
let operator = '{{ value.show_if[1]|raw }}';
|
||||
if (operator === '>') {
|
||||
success = thisVal > Number('{{ value.show_if[2] }}');
|
||||
}
|
||||
else if (operator === '<') {
|
||||
success = thisVal < Number('{{ value.show_if[2] }}');
|
||||
}
|
||||
else if (operator === '==' || operator === '=') {
|
||||
success = thisVal == '{{ value.show_if[2] }}';
|
||||
}
|
||||
|
||||
doShowHide('#row_{{ key }}', success);
|
||||
}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</script>
|
||||
{{ script|raw }}
|
||||
<!-- jQuery Form Submit No Refresh + Toastify -->
|
||||
<link rel="stylesheet" type="text/css" href="{{ constant('BASE_URL') }}tools/css/toastify.min.css">
|
||||
<script type="text/javascript" src="{{ constant('BASE_URL') }}tools/js/toastify.min.js"></script>
|
||||
<script>
|
||||
$('#settings').submit(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '{{ constant('ADMIN_URL') }}tools/settings_save.php?plugin={{ settingsKeyName }}',
|
||||
data : $(this).serialize(),
|
||||
success : function(response) {
|
||||
Toastify({
|
||||
position: 'center',
|
||||
text: response,
|
||||
duration: 3000,
|
||||
escapeMarkup: false,
|
||||
}).showToast();
|
||||
},
|
||||
error : function(response) {
|
||||
Toastify({
|
||||
position: 'center',
|
||||
text: response.responseText,
|
||||
duration: 3000,
|
||||
style: {
|
||||
background: 'red',
|
||||
},
|
||||
escapeMarkup: false,
|
||||
}).showToast();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
@@ -284,7 +284,7 @@
|
||||
|
||||
{{ hook(constant('HOOK_CHARACTERS_BEFORE_SIGNATURE')) }}
|
||||
|
||||
{% if config.signature_enabled %}
|
||||
{% if setting('core.signature_enabled') %}
|
||||
<!-- SIGNATURE -->
|
||||
<script type="text/javascript">
|
||||
function showSignLinks()
|
||||
|
@@ -155,7 +155,7 @@
|
||||
{% if (item.count > 1) %}
|
||||
<span class="loot_amount">{{ item.count }}</span>
|
||||
{% 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>
|
||||
{% endfor %}
|
||||
</td>
|
||||
|
@@ -6,14 +6,14 @@ Remember you can also check the respective skill bar in your skill window of the
|
||||
<td class="white" colspan="5"><b>Experience Table</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
{% for i in 0..config.experiencetable_columns-1 %}
|
||||
{% for i in 0..setting('core.experience_table_columns')-1 %}
|
||||
<td>
|
||||
<table border="0" cellpadding="2" cellspacing="1" width="100%">
|
||||
<tr bgcolor="{{ config.lightborder }}">
|
||||
<td><b>Level</b></td>
|
||||
<td><b>Experience</b></td>
|
||||
</tr>
|
||||
{% for level in i * config.experiencetable_rows + 1..i * config.experiencetable_rows + (config.experiencetable_rows + 1) - 1 %}
|
||||
{% for level in i * setting('core.experience_table_rows') + 1..i * setting('core.experience_table_rows') + (setting('core.experience_table_rows') + 1) - 1 %}
|
||||
<tr bgcolor="{{ config.lightborder }}">
|
||||
<td>{{ level }}</td>
|
||||
<td>{{ experience[level] }}</td>
|
||||
@@ -23,4 +23,4 @@ Remember you can also check the respective skill bar in your skill window of the
|
||||
</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</table>
|
||||
</table>
|
||||
|
@@ -4,6 +4,6 @@
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', '{{ config.google_analytics_id }}', 'auto');
|
||||
ga('create', '{{ setting('core.google_analytics_id') }}', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
</script>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<form action="{{ constant('BASE_URL') }}install/" method="post" autocomplete="off">
|
||||
<input type="hidden" name="step" id="step" value="database" />
|
||||
|
||||
{% for value in ['server_path', 'mail_admin'] %}
|
||||
{% for value in ['server_path'] %}
|
||||
<div class="form-group mb-2">
|
||||
<label for="vars_{{ value }}">{{ locale['step_config_' ~ value] }}</label>
|
||||
<input class="form-control" type="{% if value == 'mail_admin' %}email{% else %}text{% endif %}" name="vars[{{ value }}]" id="vars_{{ value }}"{% if session['var_' ~ value] is not null %} value="{{ session['var_' ~ value] }}"{% endif %}/>
|
||||
|
@@ -4,4 +4,4 @@ The request was made on {{ "now"|date("F j, Y, g:i a") }} by a user with the IP:
|
||||
<br/><br/>
|
||||
The new password is: <b>{{ new_password }}</b>
|
||||
<br/><br/>
|
||||
If this was you, please ignore this email. If it was not you, please contact our support department at {{ config.mail_admin }}.
|
||||
If this was you, please ignore this email. If it was not you, please contact our support department.
|
||||
|
@@ -25,7 +25,7 @@
|
||||
<b>Group</b>
|
||||
</td>
|
||||
|
||||
{% if config.team_display_outfit %}
|
||||
{% if setting('core.team_outfit') %}
|
||||
<td width="5%" class="white">
|
||||
<b>Outfit</b>
|
||||
</td>
|
||||
@@ -35,19 +35,19 @@
|
||||
<b>Name</b>
|
||||
</td>
|
||||
|
||||
{% if config.team_display_status %}
|
||||
{% if setting('core.team_status') %}
|
||||
<td class="white">
|
||||
<b>Status</b>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if (config.multiworld or config.team_display_world) %}
|
||||
{% if (setting('core.multiworld') or setting('core.team_world')) %}
|
||||
<td class="white">
|
||||
<b>World</b>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if config.team_display_lastlogin %}
|
||||
{% if setting('core.team_lastlogin') %}
|
||||
<td class="white">
|
||||
<b>Last login</b>
|
||||
</td>
|
||||
@@ -61,7 +61,7 @@
|
||||
<tr bgcolor="{{ getStyle(i) }}" style="height: 32px;">
|
||||
<td>{{ group.group_name|capitalize }}</td>
|
||||
|
||||
{% if config.team_display_outfit %}
|
||||
{% if setting('core.team_outfit') %}
|
||||
<td>
|
||||
<img style="position: absolute; margin-top: {% if member.player.looktype in config.outfit_images_wrong_looktypes %}-16px;margin-left:-0px;{% else %} -45px; margin-left: -30px;{% endif %}" src="{{ member.outfit }}" alt="player outfit"/>
|
||||
</td>
|
||||
@@ -74,7 +74,7 @@
|
||||
{{ member.link|raw }}
|
||||
</td>
|
||||
|
||||
{% if config.team_display_status %}
|
||||
{% if setting('core.team_status') %}
|
||||
<td>
|
||||
{% if member.status %}
|
||||
<span style="color: green"><b>Online</b></span>
|
||||
@@ -84,13 +84,13 @@
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if (config.multiworld or config.team_display_world) %}
|
||||
{% if (setting('core.multiworld') or setting('core.team_world')) %}
|
||||
<td>
|
||||
<span><b>{{ member.world_name }}</b></span>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if config.team_display_lastlogin %}
|
||||
{% if setting('core.team_lastlogin') %}
|
||||
<td>
|
||||
<span>{{ member.last_login }}</span>
|
||||
</td>
|
||||
@@ -107,7 +107,7 @@
|
||||
|
||||
<table cellspacing="1" cellpadding="4" border="0" width="100%">
|
||||
<tr bgcolor="{{ config.vdarkborder }}">
|
||||
{% if config.team_display_outfit %}
|
||||
{% if setting('core.team_outfit') %}
|
||||
<td width="5%" class="white">
|
||||
<b>Outfit</b>
|
||||
</td>
|
||||
@@ -117,19 +117,19 @@
|
||||
<b>Name</b>
|
||||
</td>
|
||||
|
||||
{% if config.team_display_status %}
|
||||
{% if setting('core.team_status') %}
|
||||
<td class="white">
|
||||
<b>Status</b>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if (config.multiworld or config.team_display_world) %}
|
||||
{% if (setting('core.multiworld') or setting('core.team_world')) %}
|
||||
<td class="white">
|
||||
<b>World</b>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if config.team_display_lastlogin %}
|
||||
{% if setting('core.team_lastlogin') %}
|
||||
<td class="white">
|
||||
<b>Last login</b>
|
||||
</td>
|
||||
@@ -139,7 +139,7 @@
|
||||
{% for member in group.members %}
|
||||
{% set i = i + 1 %}
|
||||
<tr bgcolor="{{ getStyle(i) }}" style="height: 32px;">
|
||||
{% if config.team_display_outfit %}
|
||||
{% if setting('core.team_outfit') %}
|
||||
<td>
|
||||
<img style="position: absolute; margin-top: {% if member.player.looktype in config.outfit_images_wrong_looktypes %}-16px;margin-left:-0px;{% else %} -45px; margin-left: -30px;{% endif %}" src="{{ member.outfit }}" alt="player outfit"/>
|
||||
</td>
|
||||
@@ -152,7 +152,7 @@
|
||||
{{ member.link|raw }}
|
||||
</td>
|
||||
|
||||
{% if config.team_display_status %}
|
||||
{% if setting('core.team_status') %}
|
||||
<td>
|
||||
{% if member.status %}
|
||||
<span style="color: green"><b>Online</b></span>
|
||||
@@ -162,13 +162,13 @@
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if (config.multiworld or config.team_display_world) %}
|
||||
{% if (setting('core.multiworld') or setting('core.team_world')) %}
|
||||
<td>
|
||||
<span><b>{{ member.world_name }}</b></span>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if config.team_display_lastlogin %}
|
||||
{% if setting('core.team_lastlogin') %}
|
||||
<td>
|
||||
<span>{{ member.last_login }}</span>
|
||||
</td>
|
||||
|
@@ -107,6 +107,11 @@ $function = new TwigFunction('config', function ($key) {
|
||||
});
|
||||
$twig->addFunction($function);
|
||||
|
||||
$function = new TwigFunction('setting', function ($key) {
|
||||
return setting($key);
|
||||
});
|
||||
$twig->addFunction($function);
|
||||
|
||||
$function = new TwigFunction('getCustomPage', function ($name) {
|
||||
$success = false;
|
||||
return getCustomPage($name, $success);
|
||||
|
Reference in New Issue
Block a user