Compare commits

..

19 Commits

Author SHA1 Message Date
slawkens
d297e434b8 Add latest clients versions 2023-08-31 14:20:39 +02:00
slawkens
c7966b7c55 Update plugins.php 2023-08-26 07:12:15 +02:00
slawkens
3e12f70861 thanks @elsongabriel, seems str_contains is not available in php 7 2023-08-26 07:11:43 +02:00
slawkens
4aede4c626 Allow hooks to be prefixed with HOOK_ 2023-08-23 11:58:14 +02:00
slawkens
57643bb4aa Patching from develop - twig context for hooks 2023-08-21 12:27:39 +02:00
slawkens
0139e4b446 Update twig.php 2023-08-21 12:20:57 +02:00
slawkens
e15b57f967 Ignore gallery 2023-08-21 09:43:44 +02:00
slawkens
30fe42939d Fix FAQ actions 2023-08-21 09:38:23 +02:00
slawkens
1f95a415aa Fix tabs 2023-08-15 22:06:09 +02:00
slawkens
370cc554ad Fix success & error class (bootstrap) 2023-08-15 22:04:43 +02:00
slawkens
2991696a60 typo 2023-08-12 13:34:53 +02:00
slawkens
a1ecdd228d Fixes in getPlayerNameByAccountId + add getPlayerNameById 2023-08-12 13:34:25 +02:00
slawkens
3dd493b790 banned_by is player_id. type = 2 is namelock in tfs 0.3 2023-08-12 13:23:53 +02:00
slawkens
cfbcabbfdb Fix accounts editor store_history column not found 2023-08-12 08:13:29 +02:00
slawkens
538723c405 Added JetBrains logo + notice, thanks for support! 2023-08-11 22:16:07 +02:00
slawkens
a70daa8830 Add version support table + fix badges 2023-08-11 22:11:10 +02:00
slawkens
d8f1bf0a50 Fix exception when monster doesn't have look defined 2023-08-11 18:52:11 +02:00
Gabriel Pedro
cfc4f3601b feat: add more tests (#229) 2023-08-11 06:40:53 +02:00
slawkens
23266e05ed Update README.md 2023-08-10 12:02:43 +02:00
99 changed files with 1358 additions and 3437 deletions

View File

@@ -1,9 +1,9 @@
name: Cypress name: Cypress
on: on:
pull_request: pull_request:
branches: [develop] branches: [0.9]
push: push:
branches: [develop] branches: [0.9]
jobs: jobs:
cypress: cypress:

6
.gitignore vendored
View File

@@ -35,6 +35,12 @@ images/guilds/*
images/editor/* images/editor/*
!images/editor/index.html !images/editor/index.html
# gallery images
images/gallery/*
!images/gallery/index.html
!images/gallery/demon.jpg
!images/gallery/demon_thumb.gif
# cache # cache
system/cache/* system/cache/*
!system/cache/index.html !system/cache/index.html

View File

@@ -1,23 +1,29 @@
# [MyAAC](https://my-aac.org) # [MyAAC](https://my-aac.org)
[![Build Status Master](https://img.shields.io/travis/slawkens/myaac/master)](https://travis-ci.org/github/slawkens/myaac)
[![License: GPL-3.0](https://img.shields.io/github/license/slawkens/myaac)](https://opensource.org/licenses/gpl-license)
[![Downloads Count](https://img.shields.io/github/downloads/slawkens/myaac/total)](https://github.com/slawkens/myaac/releases)
[![PHP Versions](https://img.shields.io/travis/php-v/slawkens/myaac/master)](https://github.com/slawkens/myaac/blob/d8b3b4135827ee17e3c6d41f08a925e718c587ed/.travis.yml#L3)
[![OpenTibia Discord](https://img.shields.io/discord/288399552581468162)](https://discord.gg/2J39Wus)
[![Closed Issues](https://img.shields.io/github/issues-closed-raw/slawkens/myaac)](https://github.com/slawkens/myaac/issues?q=is%3Aissue+is%3Aclosed)
MyAAC is a free and open-source Automatic Account Creator (AAC) written in PHP. It is a fork of the [Gesior](https://github.com/gesior/Gesior2012) project. It supports only MySQL databases. MyAAC is a free and open-source Automatic Account Creator (AAC) written in PHP. It is a fork of the [Gesior](https://github.com/gesior/Gesior2012) project. It supports only MySQL databases.
Official website: https://my-aac.org Official website: https://my-aac.org
[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/slawkens/myaac/cypress.yml)](https://github.com/slawkens/myaac/actions)
[![License: GPL-3.0](https://img.shields.io/github/license/slawkens/myaac)](https://opensource.org/licenses/gpl-license)
[![Downloads Count](https://img.shields.io/github/downloads/slawkens/myaac/total)](https://github.com/slawkens/myaac/releases)
[![OpenTibia Discord](https://img.shields.io/discord/288399552581468162)](https://discord.gg/2J39Wus)
[![Closed Issues](https://img.shields.io/github/issues-closed-raw/slawkens/myaac)](https://github.com/slawkens/myaac/issues?q=is%3Aissue+is%3Aclosed)
| Version | Status | Branch | Requirements |
|:-----------|:------------------------------------------|:--------|:---------------|
| **0.10.x** | **Active development** | develop | **PHP >= 8.0** |
| 0.9.x | Active support | 0.9 | PHP >= 7.2.5 |
| 0.8.x | Active support | master | PHP >= 7.2.5 |
| 0.7.x | End Of Life | 0.7 | PHP >= 5.3.3 |
### Requirements ### Requirements
- PHP 5.6 or later - PHP 7.2.5 or later
- MySQL database - MySQL database
- PDO PHP Extension - PDO PHP Extension
- XML PHP Extension - XML PHP Extension
- ZIP PHP Extension - (optional) ZIP PHP Extension
- (optional) mod_rewrite to use friendly_urls - (optional) mod_rewrite to use friendly_urls
### Installation ### Installation
@@ -71,7 +77,13 @@ Look: [Contributing](https://github.com/otsoft/myaac/wiki/Contributing) in our w
### Other Notes ### Other Notes
If you have a great idea or want contribute to the project - visit our website at https://www.my-aac.org If you have a great idea or want contribute to the project - visit our website at https://www.my-aac.org
## Project supported by JetBrains
Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.
[![JetBrains](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://www.jetbrains.com/?from=https://github.com/slawkens)
### License ### License

View File

@@ -1,35 +0,0 @@
<?php
$order = 10;
$settingsMenu = [];
$settingsMenu[] = [
'name' => 'MyAAC',
'link' => 'settings&plugin=core',
'icon' => 'list',
'order' => $order,
];
foreach (Plugins::getAllPluginsSettings() as $setting) {
$file = BASE . $setting['settingsFilename'];
if (!file_exists($file)) {
warning('Plugin setting: ' . $file . ' - cannot be loaded.');
continue;
}
$order += 10;
$settings = require $file;
$settingsMenu[] = [
'name' => $settings['name'],
'link' => 'settings&plugin=' . $setting['pluginFilename'],
'icon' => 'list',
'order' => $order,
];
}
unset($settings, $file, $order);
return $settingsMenu;

View File

@@ -6,6 +6,10 @@ require '../common.php';
const ADMIN_PANEL = true; const ADMIN_PANEL = true;
const MYAAC_ADMIN = true; const MYAAC_ADMIN = true;
if(file_exists(BASE . 'config.local.php')) {
require_once BASE . 'config.local.php';
}
if(file_exists(BASE . 'install') && (!isset($config['installed']) || !$config['installed'])) if(file_exists(BASE . 'install') && (!isset($config['installed']) || !$config['installed']))
{ {
header('Location: ' . BASE_URL . 'install/'); header('Location: ' . BASE_URL . 'install/');
@@ -30,6 +34,12 @@ if(!$db->hasTable('myaac_account_actions')) {
throw new RuntimeException('Seems that the table <strong>myaac_account_actions</strong> of MyAAC doesn\'t exist in the database. This is a fatal error. You can try to reinstall MyAAC by visiting <a href="' . BASE_URL . 'install">this</a> url.'); throw new RuntimeException('Seems that the table <strong>myaac_account_actions</strong> of MyAAC doesn\'t exist in the database. This is a fatal error. You can try to reinstall MyAAC by visiting <a href="' . BASE_URL . 'install">this</a> url.');
} }
if(config('env') === 'dev') {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
}
// event system // event system
require_once SYSTEM . 'hooks.php'; require_once SYSTEM . 'hooks.php';
$hooks = new Hooks(); $hooks = new Hooks();
@@ -37,6 +47,7 @@ $hooks->load();
require SYSTEM . 'status.php'; require SYSTEM . 'status.php';
require SYSTEM . 'login.php'; require SYSTEM . 'login.php';
require SYSTEM . 'migrate.php';
require __DIR__ . '/includes/functions.php'; require __DIR__ . '/includes/functions.php';
$twig->addGlobal('config', $config); $twig->addGlobal('config', $config);

View File

@@ -37,7 +37,7 @@ if ($config['account_country']) {
$countries[$code] = $c; $countries[$code] = $c;
} }
$web_acc = ACCOUNT_WEB_FLAGS; $web_acc = ACCOUNT_WEB_FLAGS;
$acc_type = setting('core.account_types'); $acc_type = config('account_types');
?> ?>
<link rel="stylesheet" type="text/css" href="<?php echo BASE_URL; ?>tools/css/jquery.datetimepicker.css"/ > <link rel="stylesheet" type="text/css" href="<?php echo BASE_URL; ?>tools/css/jquery.datetimepicker.css"/ >
@@ -272,7 +272,7 @@ else if (isset($_REQUEST['search'])) {
</li> </li>
<?php endif; <?php endif;
if ($db->hasTable('store_history')) : ?> if ($db->hasTable('store_history') && $db->hasColumn('store_history', 'time')) : ?>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" id="accounts-store-tab" data-toggle="pill" href="#accounts-store">Store History</a> <a class="nav-link" id="accounts-store-tab" data-toggle="pill" href="#accounts-store">Store History</a>
</li> </li>
@@ -361,7 +361,7 @@ else if (isset($_REQUEST['search'])) {
</div> </div>
<div class="form-group row"> <div class="form-group row">
<div class="col-12 col-sm-12 col-lg-6"> <div class="col-12 col-sm-12 col-lg-6">
<label for="email">Email:</label><?php echo (setting('core.mail_enabled') ? ' (<a href="' . ADMIN_URL . '?p=mailer&mail_to=' . $account->getEMail() . '">Send Mail</a>)' : ''); ?> <label for="email">Email:</label><?php echo (config('mail_enabled') ? ' (<a href="' . ADMIN_URL . '?p=mailer&mail_to=' . $account->getEMail() . '">Send Mail</a>)' : ''); ?>
<input type="text" class="form-control" id="email" name="email" autocomplete="off" value="<?php echo $account->getEMail(); ?>"/> <input type="text" class="form-control" id="email" name="email" autocomplete="off" value="<?php echo $account->getEMail(); ?>"/>
</div> </div>
<?php if ($hasCoinsColumn): ?> <?php if ($hasCoinsColumn): ?>
@@ -523,7 +523,7 @@ else if (isset($_REQUEST['search'])) {
} ?> } ?>
</div> </div>
<?php endif; <?php endif;
if ($db->hasTable('store_history')) { ?> if ($db->hasTable('store_history') && $db->hasColumn('store_history', 'time')) { ?>
<div class="tab-pane fade" id="accounts-store"> <div class="tab-pane fade" id="accounts-store">
<?php $store_history = $db->query('SELECT * FROM `store_history` WHERE `account_id` = "' . $account->getId() . '" ORDER BY `time` DESC')->fetchAll(); ?> <?php $store_history = $db->query('SELECT * FROM `store_history` WHERE `account_id` = "' . $account->getId() . '" ORDER BY `time` DESC')->fetchAll(); ?>
<table class="table table-striped table-condensed table-responsive d-md-table"> <table class="table table-striped table-condensed table-responsive d-md-table">

View File

@@ -47,11 +47,12 @@ $tmp = '';
if (fetchDatabaseConfig('site_closed_message', $tmp)) if (fetchDatabaseConfig('site_closed_message', $tmp))
$closed_message = $tmp; $closed_message = $tmp;
$settingAdminPanelModules = setting('core.admin_panel_modules'); $configAdminPanelModules = config('admin_panel_modules');
if (count($settingAdminPanelModules) > 0) { if (isset($configAdminPanelModules)) {
echo '<div class="row">'; echo '<div class="row">';
$configAdminPanelModules = explode(',', $configAdminPanelModules);
$twig_loader->prependPath(__DIR__ . '/modules/templates'); $twig_loader->prependPath(__DIR__ . '/modules/templates');
foreach ($settingAdminPanelModules as $box) { foreach ($configAdminPanelModules as $box) {
$file = __DIR__ . '/modules/' . $box . '.php'; $file = __DIR__ . '/modules/' . $box . '.php';
if (file_exists($file)) { if (file_exists($file)) {
include($file); include($file);

View File

@@ -15,7 +15,7 @@ if (!hasFlag(FLAG_CONTENT_MAILER) && !superAdmin()) {
return; return;
} }
if (!setting('core.mail_enabled')) { if (!config('mail_enabled')) {
echo 'Mail support disabled in config.'; echo 'Mail support disabled in config.';
return; return;
} }

View File

@@ -152,8 +152,8 @@ class Pages
$errors[] = 'Enable PHP is wrong.'; $errors[] = 'Enable PHP is wrong.';
return false; return false;
} }
if ($php == 1 && !getBoolean(setting('core.admin_pages_php_enable'))) { if ($php == 1 && !getBoolean(config('admin_pages_php_enable'))) {
$errors[] = 'PHP pages disabled on this server. To enable go to Settings in Admin Panel and enable <strong>Enable PHP Pages</strong>.'; $errors[] = 'PHP pages disabled on this server. To enable go to config.php and change admin_pages_php_enable to "yes".';
return false; return false;
} }
if(!isset($enable_tinymce) || ($enable_tinymce != 0 && $enable_tinymce != 1)) { if(!isset($enable_tinymce) || ($enable_tinymce != 0 && $enable_tinymce != 1)) {

View File

@@ -13,8 +13,8 @@ $use_datatable = true;
require_once LIBS . 'plugins.php'; require_once LIBS . 'plugins.php';
if (!getBoolean(setting('core.admin_plugins_manage_enable'))) { if (!getBoolean(config('admin_plugins_manage_enable'))) {
warning('Plugin installation and management is disabled in Settings.<br/>If you wish to enable, go to Settings and enable <strong>Enable Plugins Manage</strong>.'); warning('Plugin installation and management is disabled in config.<br/>If you wish to enable, go to config.php and change <b>admin_plugins_manage_enable</b> to "yes".');
} }
else { else {
$twig->display('admin.plugins.form.html.twig'); $twig->display('admin.plugins.form.html.twig');

View File

@@ -1,56 +0,0 @@
<?php
/**
* Menus
*
* @package MyAAC
* @author Slawkens <slawkens@gmail.com>
* @copyright 2019 MyAAC
* @link https://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Settings';
require_once SYSTEM . 'clients.conf.php';
if (empty($_GET['plugin'])) {
error('Please select plugin from left Panel.');
return;
}
$plugin = $_GET['plugin'];
if($plugin != 'core') {
$pluginSettings = Plugins::getPluginSettings($plugin);
if (!$pluginSettings) {
error('This plugin does not exist or does not have settings defined.');
return;
}
$settingsFilePath = BASE . $pluginSettings;
}
else {
$settingsFilePath = SYSTEM . 'settings.php';
}
if (!file_exists($settingsFilePath)) {
error("Plugin $plugin does not exist or does not have settings defined.");
return;
}
$settingsFile = require $settingsFilePath;
if (!is_array($settingsFile)) {
error("Cannot load settings file for plugin $plugin");
return;
}
$settingsKeyName = ($plugin == 'core' ? $plugin : $settingsFile['key']);
$title = ($plugin == 'core' ? 'Settings' : 'Plugin Settings - ' . $plugin);
$settingsParsed = Settings::display($settingsKeyName, $settingsFile['settings']);
$twig->display('admin.settings.html.twig', [
'settingsParsed' => $settingsParsed['content'],
'settings' => $settingsFile['settings'],
'script' => $settingsParsed['script'],
'settingsKeyName' => $settingsKeyName,
]);

View File

@@ -16,7 +16,7 @@ use DeviceDetector\Parser\OperatingSystem;
$title = 'Visitors'; $title = 'Visitors';
$use_datatable = true; $use_datatable = true;
if (!setting('core.visitors_counter')): ?> if (!$config['visitors_counter']): ?>
Visitors counter is disabled.<br/> Visitors counter is disabled.<br/>
You can enable it by editing this configurable in <b>config.local.php</b> file:<br/> You can enable it by editing this configurable in <b>config.local.php</b> file:<br/>
<p style="margin-left: 3em;"><b>$config['visitors_counter'] = true;</b></p> <p style="margin-left: 3em;"><b>$config['visitors_counter'] = true;</b></p>
@@ -25,9 +25,10 @@ if (!setting('core.visitors_counter')): ?>
endif; endif;
require SYSTEM . 'libs/visitors.php'; require SYSTEM . 'libs/visitors.php';
$visitors = new Visitors(setting('core.visitors_counter_ttl')); $visitors = new Visitors($config['visitors_counter_ttl']);
function compare($a, $b): int { function compare($a, $b)
{
return $a['lastvisit'] > $b['lastvisit'] ? -1 : 1; return $a['lastvisit'] > $b['lastvisit'] ? -1 : 1;
} }
@@ -60,7 +61,7 @@ foreach ($tmp as &$visitor) {
} }
$twig->display('admin.visitors.html.twig', array( $twig->display('admin.visitors.html.twig', array(
'config_visitors_counter_ttl' => setting('core.visitors_counter_ttl'), 'config_visitors_counter_ttl' => $config['visitors_counter_ttl'],
'visitors' => $tmp 'visitors' => $tmp
)); ));
?> ?>

View File

@@ -1,10 +1,7 @@
<?php <?php
return [ $menus = [
['name' => 'Dashboard', 'icon' => 'tachometer-alt', 'order' => 10, 'link' => 'dashboard'], ['name' => 'Dashboard', 'icon' => 'tachometer-alt', 'order' => 10, 'link' => 'dashboard'],
['name' => 'Settings', 'icon' => 'edit', 'order' => 19, 'link' =>
require ADMIN . 'includes/settings_menus.php'
],
['name' => 'News', 'icon' => 'newspaper', 'order' => 20, 'link' => ['name' => 'News', 'icon' => 'newspaper', 'order' => 20, 'link' =>
[ [
['name' => 'View', 'link' => 'news', 'icon' => 'list', 'order' => 10], ['name' => 'View', 'link' => 'news', 'icon' => 'list', 'order' => 10],
@@ -19,7 +16,7 @@ return [
['name' => 'Add', 'link' => 'changelog&action=new', 'icon' => 'plus', 'order' => 20], ['name' => 'Add', 'link' => 'changelog&action=new', 'icon' => 'plus', 'order' => 20],
], ],
], ],
['name' => 'Mailer', 'icon' => 'envelope', 'order' => 40, 'link' => 'mailer', 'disabled' => !setting('core.mail_enabled')], ['name' => 'Mailer', 'icon' => 'envelope', 'order' => 40, 'link' => 'mailer', 'disabled' => !config('mail_enabled')],
['name' => 'Pages', 'icon' => 'book', 'order' => 50, 'link' => ['name' => 'Pages', 'icon' => 'book', 'order' => 50, 'link' =>
[ [
['name' => 'View', 'link' => 'pages', 'icon' => 'list', 'order' => 10], ['name' => 'View', 'link' => 'pages', 'icon' => 'list', 'order' => 10],

View File

@@ -1,34 +0,0 @@
<?php
const MYAAC_ADMIN = true;
require '../../common.php';
require SYSTEM . 'functions.php';
require SYSTEM . 'init.php';
require SYSTEM . 'login.php';
if(!admin()) {
http_response_code(500);
die('Access denied.');
}
if (!isset($_REQUEST['plugin'])) {
http_response_code(500);
die('Please enter plugin name.');
}
if (!isset($_POST['settings'])) {
http_response_code(500);
die('Please enter settings.');
}
$settings = Settings::getInstance();
$settings->save($_REQUEST['plugin'], $_POST['settings']);
$errors = $settings->getErrors();
if (count($errors) > 0) {
http_response_code(500);
die(implode('<br/>', $errors));
}
echo 'Saved at ' . date('H:i');

View File

@@ -26,8 +26,8 @@
if (version_compare(phpversion(), '7.2.5', '<')) die('PHP version 7.2.5 or higher is required.'); if (version_compare(phpversion(), '7.2.5', '<')) die('PHP version 7.2.5 or higher is required.');
const MYAAC = true; const MYAAC = true;
const MYAAC_VERSION = '0.10.0-dev'; const MYAAC_VERSION = '0.9.0-alpha';
const DATABASE_VERSION = 36; const DATABASE_VERSION = 35;
const TABLE_PREFIX = 'myaac_'; const TABLE_PREFIX = 'myaac_';
define('START_TIME', microtime(true)); define('START_TIME', microtime(true));
define('MYAAC_OS', stripos(PHP_OS, 'WIN') === 0 ? 'WINDOWS' : (strtoupper(PHP_OS) === 'DARWIN' ? 'MAC' : 'LINUX')); define('MYAAC_OS', stripos(PHP_OS, 'WIN') === 0 ? 'WINDOWS' : (strtoupper(PHP_OS) === 'DARWIN' ? 'MAC' : 'LINUX'));
@@ -143,22 +143,6 @@ if(!IS_CLI) {
//define('CURRENT_URL', BASE_URL . $_SERVER['REQUEST_URI']); //define('CURRENT_URL', BASE_URL . $_SERVER['REQUEST_URI']);
} }
if (file_exists(BASE . 'config.local.php')) {
require BASE . 'config.local.php';
}
ini_set('log_errors', 1);
if(@$config['env'] === 'dev') {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
}
else {
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
}
$autoloadFile = VENDOR . 'autoload.php'; $autoloadFile = VENDOR . 'autoload.php';
if (!is_file($autoloadFile)) { if (!is_file($autoloadFile)) {
throw new RuntimeException('The vendor folder is missing. Please download Composer: <a href="https://getcomposer.org/download">https://getcomposer.org/download</a>, install it and execute in the main MyAAC directory this command: <b>composer install</b>. Or download MyAAC from <a href="https://github.com/slawkens/myaac/releases">GitHub releases</a>, which includes Vendor folder.'); throw new RuntimeException('The vendor folder is missing. Please download Composer: <a href="https://getcomposer.org/download">https://getcomposer.org/download</a>, install it and execute in the main MyAAC directory this command: <b>composer install</b>. Or download MyAAC from <a href="https://github.com/slawkens/myaac/releases">GitHub releases</a>, which includes Vendor folder.');

318
config.php Normal file
View File

@@ -0,0 +1,318 @@
<?php
/**
* This is MyAAC's Main Configuration file
*
* All the default values are kept here, you should not modify it but use
* a config.local.php file instead to override the settings from here.
*
* This is a piece of PHP code so PHP syntax applies!
* For boolean values please use true/false.
*
* Minimally 'server_path' directive have to be filled, other options are optional.
*
* @package MyAAC
* @author Slawkens <slawkens@gmail.com>
* @copyright 2019 MyAAC
* @link https://my-aac.org
*/
$config = array(
// directories & files
'server_path' => '', // path to the server directory (same directory where config file is located)
/**
* Environment Setting
*
* if you use this script on your live server - set to 'prod' (production)
* if you want to test and debug the script locally, or develop plugins, set to 'dev' (development)
* WARNING: on 'dev' cache is disabled, so site will be significantly slower !!!
* WARNING2: on 'dev' all PHP errors/warnings are displayed
* Recommended: 'prod' cause of speed (page load time is better)
*/
'env' => 'prod', // 'prod' for production and 'dev' for development
'template' => 'kathrine', // template used by website (kathrine, tibiacom)
'template_allow_change' => true, // allow users to choose their own template while browsing website?
'vocations_amount' => 4, // how much basic vocations your server got (without promotion)
// what client version are you using on this OT?
// used for the Downloads page and some templates aswell
'client' => 1098, // 954 = client 9.54
'session_prefix' => 'myaac_', // must be unique for every site on your server
'friendly_urls' => false, // mod_rewrite is required for this, it makes links looks more elegant to eye, and also are SEO friendly (example: https://my-aac.org/guilds/Testing instead of https://my-aac.org/?subtopic=guilds&name=Testing). Remember to rename .htaccess.dist to .htaccess
'gzip_output' => false, // gzip page content before sending it to the browser, uses less bandwidth but more cpu cycles
// gesior backward support (templates & pages)
// allows using gesior templates and pages with myaac
// might bring some performance when disabled
'backward_support' => true,
// head options (html)
'meta_description' => 'Tibia is a free massive multiplayer online role playing game (MMORPG).', // description of the site
'meta_keywords' => 'free online game, free multiplayer game, ots, open tibia server', // keywords list separated by commas
// footer
'footer' => ''/*'<br/>Your Server &copy; 2016. All rights reserved.'*/,
'language' => 'en', // default language (currently only 'en' available)
'language_allow_change' => false,
'visitors_counter' => true,
'visitors_counter_ttl' => 10, // how long visitor will be marked as online (in minutes)
'views_counter' => true,
// cache system. by default file cache is used
'cache_engine' => 'auto', // apc, apcu, eaccelerator, xcache, file, auto, or blank to disable.
'cache_prefix' => 'myaac_', // have to be unique if running more MyAAC instances on the same server (except file system cache)
// database details (leave blank for auto detect from config.lua)
'database_host' => '',
'database_port' => '', // leave blank to default 3306
'database_user' => '',
'database_password' => '',
'database_name' => '',
'database_log' => false, // should database queries be logged and saved into system/logs/database.log?
'database_socket' => '', // set if you want to connect to database through socket (example: /var/run/mysqld/mysqld.sock)
'database_persistent' => false, // use database permanent connection (like server), may speed up your site
// multiworld system (only TFS 0.3)
'multiworld' => false, // use multiworld system?
'worlds' => array( // list of worlds
//'1' => 'Your World Name',
//'2' => 'Your Second World Name'
),
// images
'outfit_images_url' => 'https://outfit-images.ots.me/outfit.php', // set to animoutfit.php for animated outfit
'outfit_images_wrong_looktypes' => [75, 126, 127, 266, 302], // this looktypes needs to have different margin-top and margin-left because they are wrong positioned
'item_images_url' => 'https://item-images.ots.me/1092/', // set to images/items if you host your own items in images folder
'item_images_extension' => '.gif',
// creatures
'creatures_images_url' => 'images/monsters/', // set to images/monsters if you host your own creatures in images folder
'creatures_images_extension' => '.gif',
'creatures_images_preview' => false, // set to true to allow picture previews for creatures
'creatures_items_url' => 'https://tibia.fandom.com/wiki/', // set to website which shows details about items.
'creatures_loot_percentage' => true, // set to true to show the loot tooltip percent
// account
'account_management' => true, // disable if you're using other method to manage users (fe. tfs account manager)
'account_login_by_email' => false, // use email instead of Account Name like in latest Tibia
'account_login_by_email_fallback' => false, // allow also additionally login by Account Name/Number (for users that might forget their email)
'account_create_auto_login' => false, // auto login after creating account?
'account_create_character_create' => true, // allow directly to create character on create account page?
'account_mail_verify' => false, // force users to confirm their email addresses when registering
'account_mail_confirmed_reward' => [ // reward users for confirming their E-Mails
// account_mail_verify needs to be enabled too
'premium_days' => 0,
'premium_points' => 0,
'coins' => 0,
'message' => 'You received %d %s for confirming your E-Mail address.' // example: You received 20 premium points for confirming your E-Mail address.
],
'account_mail_unique' => true, // email addresses cannot be duplicated? (one account = one email)
'account_mail_block_plus_sign' => true, // block email with '+' signs like test+box@gmail.com (help protect against spamming accounts)
'account_premium_days' => 0, // default premium days on new account
'account_premium_points' => 0, // default premium points on new account
'account_welcome_mail' => true, // send welcome email when user registers
'account_mail_change' => 2, // how many days user need to change email to account - block hackers
'account_country' => true, // user will be able to set country of origin when registering account, this information will be viewable in others places aswell
'account_country_recognize' => true, // should country of user be automatically recognized by his IP? This makes an external API call to http://ipinfo.io
'account_change_character_name' => false, // can user change their character name for premium points?
'account_change_character_name_points' => 30, // cost of name change
'account_change_character_sex' => false, // can user change their character sex for premium points?
'account_change_character_sex_points' => 30, // cost of sex change
'characters_per_account' => 10, // max. number of characters per account
// mail
'mail_enabled' => false, // is aac maker configured to send e-mails?
'mail_address' => 'no-reply@your-server.org', // server e-mail address (from:)
'mail_admin' => 'your-address@your-server.org', // admin email address, where mails from contact form will be sent
'mail_signature' => array( // signature that will be included at the end of every message sent using _mail function
'plain' => ""/*"--\nMy Server,\nhttp://www.myserver.com"*/,
'html' => ''/*'<br/>My Server,\n<a href="http://www.myserver.com">myserver.com</a>'*/
),
'smtp_enabled' => false, // send by smtp or mail function (set false if use mail function, set to true if you use GMail or Microsoft Outlook)
'smtp_host' => '', // mail host. smtp.gmail.com for GMail / smtp-mail.outlook.com for Microsoft Outlook
'smtp_port' => 25, // 25 (default) / 465 (ssl, GMail) / 587 (tls, Microsoft Outlook)
'smtp_auth' => true, // need authorization?
'smtp_user' => 'admin@example.org', // here your email username
'smtp_pass' => '',
'smtp_secure' => '', // What kind of encryption to use on the SMTP connection. Options: '', 'ssl' (GMail) or 'tls' (Microsoft Outlook)
'smtp_debug' => false, // set true to debug (you will see more info in error.log)
//
'generate_new_reckey' => true, // let player generate new recovery key, he will receive e-mail with new rec key (not display on page, hacker can't generate rec key)
'generate_new_reckey_price' => 20, // price for new recovery key
'send_mail_when_change_password' => true, // send e-mail with new password when change password to account
'send_mail_when_generate_reckey' => true, // send e-mail with rec key (key is displayed on page anyway when generate)
// you may need to adjust this for older tfs versions
// by removing Community Manager
'account_types' => [
'None',
'Normal',
'Tutor',
'Senior Tutor',
'Gamemaster',
'Community Manager',
'God',
],
// genders (aka sex)
'genders' => array(
0 => 'Female',
1 => 'Male'
),
// new character config
'character_samples' => array( // vocations, format: ID_of_vocation => 'Name of Character to copy'
//0 => 'Rook Sample',
1 => 'Sorcerer Sample',
2 => 'Druid Sample',
3 => 'Paladin Sample',
4 => 'Knight Sample'
),
'use_character_sample_skills' => false,
// it must show limited number of players after using search in character page
'characters_search_limit' => 15,
// town list used when creating character
// won't be displayed if there is only one item (rookgaard for example)
'character_towns' => array(1),
// characters length
// This is the minimum and the maximum length that a player can create a character. It is highly recommend the maximum length to be 21.
'character_name_min_length' => 4,
'character_name_max_length' => 21,
'character_name_npc_check' => true,
// list of towns
// if you use TFS 1.3 with support for 'towns' table in database, then you can ignore this - it will be configured automatically (from MySQL database - Table - towns)
// otherwise it will try to load from your .OTBM map file
// if you don't see towns on website, then you need to fill this out
'towns' => array(
0 => 'No town',
1 => 'Sample town'
),
// guilds
'guild_management' => true, // enable guild management system on the site?
'guild_need_level' => 1, // min. level to form a guild
'guild_need_premium' => true, // require premium account to form a guild?
'guild_image_size_kb' => 80, // maximum size of the guild logo image in KB (kilobytes)
'guild_description_default' => 'New guild. Leader must edit this text :)',
'guild_description_chars_limit' => 1000, // limit of guild description
'guild_description_lines_limit' => 6, // limit of lines, if description has more lines it will be showed as long text, without 'enters'
'guild_motd_chars_limit' => 150, // limit of MOTD (message of the day) that is shown later in the game on the guild channel
// online page
'online_record' => true, // display players record?
'online_vocations' => false, // display vocation statistics?
'online_vocations_images' => false, // display vocation images?
'online_skulls' => false, // display skull images
'online_outfit' => true,
'online_afk' => false,
// support list page
'team_style' => 2, // 1/2 (1 - normal table, 2 - in boxes, grouped by group id)
'team_display_status' => true,
'team_display_lastlogin' => true,
'team_display_world' => false,
'team_display_outfit' => true,
// bans page
'bans_per_page' => 20,
// highscores page
'highscores_vocation_box' => true, // show 'Choose a vocation' box on the highscores (allowing peoples to sort highscores by vocation)?
'highscores_vocation' => true, // show player vocation under his nickname?
'highscores_frags' => false, // show 'Frags' tab (best fraggers on the server)?
'highscores_balance' => false, // show 'Balance' tab (richest players on the server)
'highscores_outfit' => true, // show player outfit?
'highscores_country_box' => false, // doesnt work yet! (not implemented)
'highscores_groups_hidden' => 3, // this group id and higher won't be shown on the highscores
'highscores_ids_hidden' => array(0), // this ids of players will be hidden on the highscores (should be ids of samples)
'highscores_per_page' => 100, // how many records per page on highscores
'highscores_cache_ttl' => 15, // how often to update highscores from database in minutes (default 15 minutes)
// characters page
'characters' => array( // what things to display on character view page (true/false in each option)
'level' => true,
'experience' => false,
'magic_level' => false,
'balance' => false,
'marriage_info' => true, // only 0.3
'outfit' => true,
'creation_date' => true,
'quests' => true,
'skills' => true,
'equipment' => true,
'frags' => false,
'deleted' => false, // should deleted characters from same account be still listed on the list of characters? When enabled it will show that character is "[DELETED]"
),
'quests' => array(
//'Some Quest' => 123,
//'Some Quest Two' => 456,
), // quests list (displayed in character view), name => storage
'signature_enabled' => true,
'signature_type' => 'tibian', // signature engine to use: tibian, mango, gesior
'signature_cache_time' => 5, // how long to store cached file (in minutes), default 5 minutes
'signature_browser_cache' => 60, // how long to cache by browser (in minutes), default 1 hour
// news page
'news_limit' => 5, // limit of news on the latest news page
'news_ticker_limit' => 5, // limit of news in tickers (mini news) (0 to disable)
'news_date_format' => 'j.n.Y', // check php manual date() function for more info about this
'news_author' => true, // show author of the news
// gifts/shop system
'gifts_system' => false,
// support/system
'bug_report' => true, // this configurable has no effect, its always enabled
// forum
'forum' => 'site', // link to the server forum, set to "site" if you want to use build in forum system, otherwise leave empty if you aren't going to use any forum
'forum_level_required' => 0, // level required to post, 0 to disable
'forum_post_interval' => 30, // in seconds
'forum_posts_per_page' => 20,
'forum_threads_per_page' => 20,
// uncomment to force use table for forum
//'forum_table_prefix' => 'z_', // what forum mysql table to use, z_ (for gesior old forum) or myaac_ (for myaac)
// last kills
'last_kills_limit' => 50, // max. number of deaths shown on the last kills page
// status, took automatically from config file if empty
'status_enabled' => true, // you can disable status checking by settings this to "false"
'status_ip' => '',
'status_port' => '',
'status_timeout' => 2.0, // how long to wait for the initial response from the server (default: 2 seconds)
// how often to connect to server and update status (default: every minute)
// if your status timeout in config.lua is bigger, that it will be used instead
// when server is offline, it will be checked every time web refreshes, ignoring this variable
'status_interval' => 60,
// admin panel
'admin_plugins_manage_enable' => 'yes', // you can disable possibility to upload and uninstall plugins, for security
// enable support for plain php pages in admin panel, for security
// existing pages still will be working, so you need to delete them manually
'admin_pages_php_enable' => 'no',
'admin_panel_modules' => 'statistics,web_status,server_status,lastlogin,created,points,coins,balance', // default - statistics,web_status,server_status,lastlogin,created,points,coins,balance
// other
'anonymous_usage_statistics' => true,
'email_lai_sec_interval' => 60, // time in seconds between e-mails to one account from lost account interface, block spam
'google_analytics_id' => '', // e.g.: UA-XXXXXXX-X
'experiencetable_columns' => 3, // how many columns to display in experience table page. * experiencetable_rows, 5 = 500 (will show up to 500 level)
'experiencetable_rows' => 200, // till how many levels in one column
'date_timezone' => 'Europe/Berlin', // more info at http://php.net/manual/en/timezones.php
'footer_show_load_time' => true, // display load time of the page in the footer
'npc' => array()
);

View File

@@ -0,0 +1,174 @@
describe('Check Public Pages', () => {
/// news
it('Go to news page', () => {
cy.visit({
url: Cypress.env('URL') + '/news',
method: 'GET',
})
})
it('Go to news archive page', () => {
cy.visit({
url: Cypress.env('URL') + '/news/archive',
method: 'GET',
})
})
it('Go to changelog page', () => {
cy.visit({
url: Cypress.env('URL') + '/changelog',
method: 'GET',
})
})
/// account management
it('Go to account manage page', () => {
cy.visit({
url: Cypress.env('URL') + '/account/manage',
method: 'GET',
})
})
it('Go to account create page', () => {
cy.visit({
url: Cypress.env('URL') + '/account/create',
method: 'GET',
})
})
it('Go to account lost page', () => {
cy.visit({
url: Cypress.env('URL') + '/account/lost',
method: 'GET',
})
})
it('Go to rules page', () => {
cy.visit({
url: Cypress.env('URL') + '/rules',
method: 'GET',
})
})
// community
it('Go to online page', () => {
cy.visit({
url: Cypress.env('URL') + '/online',
method: 'GET',
})
})
it('Go to characters list page', () => {
cy.visit({
url: Cypress.env('URL') + '/characters',
method: 'GET',
})
})
it('Go to guilds page', () => {
cy.visit({
url: Cypress.env('URL') + '/guilds',
method: 'GET',
})
})
it('Go to highscores page', () => {
cy.visit({
url: Cypress.env('URL') + '/highscores',
method: 'GET',
})
})
it('Go to last kills page', () => {
cy.visit({
url: Cypress.env('URL') + '/lastkills',
method: 'GET',
})
})
it('Go to houses page', () => {
cy.visit({
url: Cypress.env('URL') + '/houses',
method: 'GET',
})
})
it('Go to bans page', () => {
cy.visit({
url: Cypress.env('URL') + '/bans',
method: 'GET',
})
})
it('Go to forum page', () => {
cy.visit({
url: Cypress.env('URL') + '/forum',
method: 'GET',
})
})
it('Go to team page', () => {
cy.visit({
url: Cypress.env('URL') + '/team',
method: 'GET',
})
})
// library
it('Go to creatures page', () => {
cy.visit({
url: Cypress.env('URL') + '/creatures',
method: 'GET',
})
})
it('Go to spells page', () => {
cy.visit({
url: Cypress.env('URL') + '/spells',
method: 'GET',
})
})
it('Go to server info page', () => {
cy.visit({
url: Cypress.env('URL') + '/serverInfo',
method: 'GET',
})
})
it('Go to commands page', () => {
cy.visit({
url: Cypress.env('URL') + '/commands',
method: 'GET',
})
})
it('Go to downloads page', () => {
cy.visit({
url: Cypress.env('URL') + '/downloads',
method: 'GET',
})
})
it('Go to gallery page', () => {
cy.visit({
url: Cypress.env('URL') + '/gallery',
method: 'GET',
})
})
it('Go to experience table page', () => {
cy.visit({
url: Cypress.env('URL') + '/experienceTable',
method: 'GET',
})
})
it('Go to faq page', () => {
cy.visit({
url: Cypress.env('URL') + '/faq',
method: 'GET',
})
})
})

View File

@@ -0,0 +1,81 @@
const REQUIRED_LOGIN_MESSAGE = 'Please enter your account name and your password.';
const YOU_ARE_NOT_LOGGEDIN = 'You are not logged in.';
describe('Check Protected Pages', () => {
// character actions
it('Go to accouht character creation page', () => {
cy.visit({
url: Cypress.env('URL') + '/account/character/create',
method: 'GET',
})
cy.contains(REQUIRED_LOGIN_MESSAGE)
})
it('Go to accouht character deletion page', () => {
cy.visit({
url: Cypress.env('URL') + '/account/character/delete',
method: 'GET',
})
cy.contains(REQUIRED_LOGIN_MESSAGE)
})
// account actions
it('Go to accouht email change page', () => {
cy.visit({
url: Cypress.env('URL') + '/account/email',
method: 'GET',
})
cy.contains(REQUIRED_LOGIN_MESSAGE)
})
it('Go to accouht password change page', () => {
cy.visit({
url: Cypress.env('URL') + '/account/password',
method: 'GET',
})
cy.contains(REQUIRED_LOGIN_MESSAGE)
})
it('Go to accouht info change page', () => {
cy.visit({
url: Cypress.env('URL') + '/account/info',
method: 'GET',
})
cy.contains(REQUIRED_LOGIN_MESSAGE)
})
it('Go to accouht logout change page', () => {
cy.visit({
url: Cypress.env('URL') + '/account/logout',
method: 'GET',
})
cy.contains(REQUIRED_LOGIN_MESSAGE)
})
// guild actions
it('Go to guild creation page', () => {
cy.visit({
url: Cypress.env('URL') + '/?subtopic=guilds&action=create',
method: 'GET',
})
cy.contains(YOU_ARE_NOT_LOGGEDIN)
})
it('Go to guilds cleanup players action page', () => {
cy.visit({
url: Cypress.env('URL') + '/?subtopic=guilds&action=cleanup_players',
method: 'GET',
})
cy.contains(YOU_ARE_NOT_LOGGEDIN)
})
it('Go to guilds cleanup guilds action page', () => {
cy.visit({
url: Cypress.env('URL') + '/?subtopic=guilds&action=cleanup_guilds',
method: 'GET',
})
cy.contains(YOU_ARE_NOT_LOGGEDIN)
})
})

View File

View File

@@ -56,6 +56,22 @@ if(preg_match("/^(.*)\.(gif|jpg|png|jpeg|tiff|bmp|css|js|less|map|html|zip|rar|g
exit; exit;
} }
if(file_exists(BASE . 'config.local.php')) {
require_once BASE . 'config.local.php';
}
ini_set('log_errors', 1);
if(config('env') === 'dev') {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
}
else {
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
}
if((!isset($config['installed']) || !$config['installed']) && file_exists(BASE . 'install')) if((!isset($config['installed']) || !$config['installed']) && file_exists(BASE . 'install'))
{ {
header('Location: ' . BASE_URL . 'install/'); header('Location: ' . BASE_URL . 'install/');
@@ -84,11 +100,13 @@ $twig->addGlobal('status', $status);
require_once SYSTEM . 'router.php'; require_once SYSTEM . 'router.php';
require SYSTEM . 'migrate.php';
$hooks->trigger(HOOK_STARTUP); $hooks->trigger(HOOK_STARTUP);
// anonymous usage statistics // anonymous usage statistics
// sent only when user agrees // sent only when user agrees
if(setting('core.anonymous_usage_statistics')) { if(isset($config['anonymous_usage_statistics']) && $config['anonymous_usage_statistics']) {
$report_time = 30 * 24 * 60 * 60; // report one time per 30 days $report_time = 30 * 24 * 60 * 60; // report one time per 30 days
$should_report = true; $should_report = true;
@@ -121,16 +139,17 @@ if(setting('core.anonymous_usage_statistics')) {
} }
} }
if(setting('core.views_counter')) if($config['views_counter'])
require_once SYSTEM . 'counter.php'; require_once SYSTEM . 'counter.php';
if(setting('core.visitors_counter')) { if($config['visitors_counter'])
{
require_once SYSTEM . 'libs/visitors.php'; require_once SYSTEM . 'libs/visitors.php';
$visitors = new Visitors(setting('core.visitors_counter_ttl')); $visitors = new Visitors($config['visitors_counter_ttl']);
} }
// backward support for gesior // backward support for gesior
if(setting('core.backward_support')) { if($config['backward_support']) {
define('INITIALIZED', true); define('INITIALIZED', true);
$SQL = $db; $SQL = $db;
$layout_header = template_header(); $layout_header = template_header();
@@ -146,7 +165,7 @@ if(setting('core.backward_support')) {
$config['site'] = &$config; $config['site'] = &$config;
$config['server'] = &$config['lua']; $config['server'] = &$config['lua'];
$config['site']['shop_system'] = setting('core.gifts_system'); $config['site']['shop_system'] = $config['gifts_system'];
$config['site']['gallery_page'] = true; $config['site']['gallery_page'] = true;
if(!isset($config['vdarkborder'])) if(!isset($config['vdarkborder']))
@@ -160,9 +179,8 @@ if(setting('core.backward_support')) {
$config['site']['serverinfo_page'] = true; $config['site']['serverinfo_page'] = true;
$config['site']['screenshot_page'] = true; $config['site']['screenshot_page'] = true;
$forumSetting = setting('core.forum'); if($config['forum'] != '')
if($forumSetting != '') $config['forum_link'] = (strtolower($config['forum']) === 'site' ? getLink('forum') : $config['forum']);
$config['forum_link'] = (strtolower($forumSetting) === 'site' ? getLink('forum') : $forumSetting);
foreach($status as $key => $value) foreach($status as $key => $value)
$config['status']['serverStatus_' . $key] = $value; $config['status']['serverStatus_' . $key] = $value;

View File

@@ -1,4 +1,4 @@
SET @myaac_database_version = 36; SET @myaac_database_version = 35;
CREATE TABLE `myaac_account_actions` CREATE TABLE `myaac_account_actions`
( (
@@ -303,16 +303,6 @@ CREATE TABLE `myaac_gallery`
INSERT INTO `myaac_gallery` (`id`, `ordering`, `comment`, `image`, `thumb`, `author`) VALUES (NULL, 1, 'Demon', 'images/gallery/demon.jpg', 'images/gallery/demon_thumb.gif', 'MyAAC'); INSERT INTO `myaac_gallery` (`id`, `ordering`, `comment`, `image`, `thumb`, `author`) VALUES (NULL, 1, 'Demon', 'images/gallery/demon.jpg', 'images/gallery/demon_thumb.gif', 'MyAAC');
CREATE TABLE `myaac_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;
CREATE TABLE `myaac_spells` CREATE TABLE `myaac_spells`
( (
`id` INT(11) NOT NULL AUTO_INCREMENT, `id` INT(11) NOT NULL AUTO_INCREMENT,

View File

@@ -12,7 +12,9 @@ require SYSTEM . 'functions.php';
require BASE . 'install/includes/functions.php'; require BASE . 'install/includes/functions.php';
require BASE . 'install/includes/locale.php'; require BASE . 'install/includes/locale.php';
require SYSTEM . 'clients.conf.php'; require SYSTEM . 'clients.conf.php';
require LIBS . 'settings.php';
if(file_exists(BASE . 'config.local.php'))
require BASE . 'config.local.php';
// ignore undefined index from Twig autoloader // ignore undefined index from Twig autoloader
$config['env'] = 'prod'; $config['env'] = 'prod';
@@ -89,6 +91,10 @@ if($step == 'database') {
break; break;
} }
} }
else if($key == 'mail_admin' && !Validator::email($value)) {
$errors[] = $locale['step_config_mail_admin_error'];
break;
}
else if($key == 'timezone' && !in_array($value, DateTimeZone::listIdentifiers())) { else if($key == 'timezone' && !in_array($value, DateTimeZone::listIdentifiers())) {
$errors[] = $locale['step_config_timezone_error']; $errors[] = $locale['step_config_timezone_error'];
break; break;

View File

@@ -11,12 +11,16 @@ if(!isset($_SESSION['var_server_path'])) {
} }
if(!$error) { if(!$error) {
$configToSave = [ $content = "<?php";
$content .= PHP_EOL;
$content .= '// place for your configuration directives, so you can later easily update myaac';
$content .= PHP_EOL;
$content .= '$config[\'installed\'] = true;';
$content .= PHP_EOL;
// by default, set env to prod // by default, set env to prod
// user can disable when he wants // user can disable when he wants
'env' => 'prod', $content .= '$config[\'env\'] = \'prod\'; // dev or prod';
]; $content .= PHP_EOL;
foreach($_SESSION as $key => $value) foreach($_SESSION as $key => $value)
{ {
if(strpos($key, 'var_') !== false) if(strpos($key, 'var_') !== false)
@@ -28,14 +32,17 @@ if(!$error) {
$value .= '/'; $value .= '/';
} }
if(!in_array($key, ['var_usage', 'var_date_timezone', 'var_client', 'var_account', 'var_account_id', 'var_password', 'var_password_confirm', 'var_step', 'var_email', 'var_player_name'], true)) { if($key === 'var_usage') {
$configToSave[str_replace('var_', '', $key)] = $value; $content .= '$config[\'anonymous_usage_statistics\'] = ' . ((int)$value == 1 ? 'true' : 'false') . ';';
$content .= PHP_EOL;
}
else if(!in_array($key, array('var_account', 'var_account_id', 'var_password', 'var_step', 'var_email', 'var_player_name'), true)) {
$content .= '$config[\'' . str_replace('var_', '', $key) . '\'] = \'' . $value . '\';';
$content .= PHP_EOL;
} }
} }
} }
$configToSave['cache_prefix'] = 'myaac_' . generateRandomString(8, true, false, true);
require BASE . 'install/includes/config.php'; require BASE . 'install/includes/config.php';
if(!$error) { if(!$error) {
@@ -72,17 +79,31 @@ if(!$error) {
'message' => $locale['loading_spinner'] 'message' => $locale['loading_spinner']
)); ));
$content = ''; if(!Validator::email($_SESSION['var_mail_admin'])) {
$saved = Settings::saveConfig($configToSave, BASE . 'config.local.php', $content); error($locale['step_config_mail_admin_error']);
$error = true;
}
$content .= '$config[\'session_prefix\'] = \'myaac_' . generateRandomString(8, true, false, true, false) . '_\';';
$content .= PHP_EOL;
$content .= '$config[\'cache_prefix\'] = \'myaac_' . generateRandomString(8, true, false, true, false) . '_\';';
$saved = true;
if(!$error) {
$saved = file_put_contents(BASE . 'config.local.php', $content);
}
if($saved) { if($saved) {
success($locale['step_database_config_saved']); success($locale['step_database_config_saved']);
if(!$error) {
$_SESSION['saved'] = true; $_SESSION['saved'] = true;
} }
}
else { else {
$_SESSION['config_content'] = $content; $_SESSION['config_content'] = $content;
unset($_SESSION['saved']); unset($_SESSION['saved']);
$locale['step_database_error_file'] = str_replace('$FILE$', '<b>' . BASE . 'config.php</b>', $locale['step_database_error_file']); $locale['step_database_error_file'] = str_replace('$FILE$', '<b>' . BASE . 'config.local.php</b>', $locale['step_database_error_file']);
error($locale['step_database_error_file'] . '<br/> error($locale['step_database_error_file'] . '<br/>
<textarea cols="70" rows="10">' . $content . '</textarea>'); <textarea cols="70" rows="10">' . $content . '</textarea>');
} }

View File

@@ -116,23 +116,6 @@ else {
} }
} }
$settings = Settings::getInstance();
foreach($_SESSION as $key => $value) {
if (in_array($key, ['var_usage', 'var_date_timezone', 'var_client'])) {
if ($key == 'var_usage') {
$key = 'anonymous_usage_statistics';
$value = ((int)$value == 1 ? 'true' : 'false');
} elseif ($key == 'var_date_timezone') {
$key = 'date_timezone';
} elseif ($key == 'var_client') {
$key = 'client';
}
$settings->updateInDatabase('core', $key, $value);
}
}
success('Settings saved.');
$twig->display('install.installer.html.twig', array( $twig->display('install.installer.html.twig', array(
'url' => 'tools/7-finish.php', 'url' => 'tools/7-finish.php',
'message' => $locale['importing_spinner'] 'message' => $locale['importing_spinner']

View File

@@ -11,11 +11,11 @@ ini_set('max_execution_time', 300);
ob_implicit_flush(); ob_implicit_flush();
ob_end_flush(); ob_end_flush();
header('X-Accel-Buffering: no'); header('X-Accel-Buffering: no');
/*
if(isset($config['installed']) && $config['installed'] && !isset($_SESSION['saved'])) { if(isset($config['installed']) && $config['installed'] && !isset($_SESSION['saved'])) {
warning($locale['already_installed']); warning($locale['already_installed']);
return; return;
}*/ }
require SYSTEM . 'init.php'; require SYSTEM . 'init.php';
@@ -51,6 +51,13 @@ DataLoader::load();
// update config.highscores_ids_hidden // update config.highscores_ids_hidden
require_once SYSTEM . 'migrations/20.php'; require_once SYSTEM . 'migrations/20.php';
$database_migration_20 = true;
$content = '';
if(!databaseMigration20($content)) {
$locale['step_database_error_file'] = str_replace('$FILE$', '<b>' . BASE . 'config.local.php</b>', $locale['step_database_error_file']);
warning($locale['step_database_error_file'] . '<br/>
<textarea cols="70" rows="10">' . $content . '</textarea>');
}
// add z_polls tables // add z_polls tables
require_once SYSTEM . 'migrations/22.php'; require_once SYSTEM . 'migrations/22.php';

View File

@@ -1,5 +1,7 @@
<?php <?php
require_once 'common.php'; require_once 'common.php';
require_once 'config.php';
require_once 'config.local.php';
require_once SYSTEM . 'functions.php'; require_once SYSTEM . 'functions.php';
require_once SYSTEM . 'init.php'; require_once SYSTEM . 'init.php';
require_once SYSTEM . 'status.php'; require_once SYSTEM . 'status.php';

View File

@@ -1,4 +1,7 @@
{ {
"scripts": {
"cypress:open": "cypress open"
},
"devDependencies": { "devDependencies": {
"cypress": "^12.12.0" "cypress": "^12.12.0"
} }

View File

@@ -39,6 +39,5 @@
"redirect_from": "/redirectExample", "redirect_from": "/redirectExample",
"redirect_to": "account/manage" "redirect_to": "account/manage"
} }
}, }
"settings": "plugins/your-plugin-folder/settings.php"
} }

View File

@@ -22,7 +22,7 @@ if [ $1 = "prepare" ]; then
mkdir -p tmp mkdir -p tmp
# get myaac from git archive # get myaac from git archive
git archive --format zip --output tmp/myaac.zip develop git archive --format zip --output tmp/myaac.zip 0.9
cd tmp/ || exit cd tmp/ || exit

View File

@@ -99,4 +99,10 @@ $config['clients'] = [
1291, 1291,
1300, 1300,
1310,
1311,
1312,
1316,
1320,
1321,
]; ];

View File

@@ -1,103 +0,0 @@
<?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);

View File

@@ -9,11 +9,7 @@
*/ */
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
if (!isset($config['database_overwrite'])) { if(!isset($config['database_user'][0], $config['database_password'][0], $config['database_name'][0]))
$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']['sqlType'])) {// tfs 0.3
if(isset($config['lua']['mysqlHost'])) {// tfs 0.2 if(isset($config['lua']['mysqlHost'])) {// tfs 0.2

View File

@@ -44,37 +44,43 @@ 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): string function longToIp($ip)
{ {
$exp = explode(".", long2ip($ip)); $exp = explode(".", long2ip($ip));
return $exp[3].".".$exp[2].".".$exp[1].".".$exp[0]; return $exp[3].".".$exp[2].".".$exp[1].".".$exp[0];
} }
function generateLink($url, $name, $blank = false): string { function generateLink($url, $name, $blank = false) {
return '<a href="' . $url . '"' . ($blank ? ' target="_blank"' : '') . '>' . $name . '</a>'; return '<a href="' . $url . '"' . ($blank ? ' target="_blank"' : '') . '>' . $name . '</a>';
} }
function getFullLink($page, $name, $blank = false): string { function getFullLink($page, $name, $blank = false) {
return generateLink(getLink($page), $name, $blank); return generateLink(getLink($page), $name, $blank);
} }
function getLink($page, $action = null): string { function getLink($page, $action = null)
return BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . $page . ($action ? '/' . $action : '');
}
function internalLayoutLink($page, $action = null): string {
return getLink($page, $action);
}
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 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
{ {
global $config;
return BASE_URL . ($config['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 getForumBoardLink($board_id, $page = NULL)
{
global $config;
return BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . 'forum/board/' . (int)$board_id . (isset($page) ? '/' . $page : '');
}
function getPlayerLink($name, $generate = true)
{
global $config;
if(is_numeric($name)) if(is_numeric($name))
{ {
$player = new OTS_Player(); $player = new OTS_Player();
@@ -83,23 +89,25 @@ function getPlayerLink($name, $generate = true): string
$name = $player->getName(); $name = $player->getName();
} }
$url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'characters/' . urlencode($name); $url = BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . 'characters/' . urlencode($name);
if(!$generate) return $url; if(!$generate) return $url;
return generateLink($url, $name); return generateLink($url, $name);
} }
function getMonsterLink($name, $generate = true): string function getMonsterLink($name, $generate = true)
{ {
$url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'creatures/' . urlencode($name); global $config;
$url = BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . 'creatures/' . urlencode($name);
if(!$generate) return $url; if(!$generate) return $url;
return generateLink($url, $name); return generateLink($url, $name);
} }
function getHouseLink($name, $generate = true): string function getHouseLink($name, $generate = true)
{ {
global $db; global $db, $config;
if(is_numeric($name)) if(is_numeric($name))
{ {
@@ -109,14 +117,16 @@ function getHouseLink($name, $generate = true): string
$name = $house->fetchColumn(); $name = $house->fetchColumn();
} }
$url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'houses/' . urlencode($name); $url = BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . 'houses/' . urlencode($name);
if(!$generate) return $url; if(!$generate) return $url;
return generateLink($url, $name); return generateLink($url, $name);
} }
function getGuildLink($name, $generate = true): string function getGuildLink($name, $generate = true)
{ {
global $config;
if(is_numeric($name)) { if(is_numeric($name)) {
$name = getGuildNameById($name); $name = getGuildNameById($name);
if ($name === false) { if ($name === false) {
@@ -124,7 +134,7 @@ function getGuildLink($name, $generate = true): string
} }
} }
$url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'guilds/' . urlencode($name); $url = BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . 'guilds/' . urlencode($name);
if(!$generate) return $url; if(!$generate) return $url;
return generateLink($url, $name); return generateLink($url, $name);
@@ -170,7 +180,7 @@ function getItemRarity($chance) {
return ''; return '';
} }
function getFlagImage($country): string function getFlagImage($country)
{ {
if(!isset($country[0])) if(!isset($country[0]))
return ''; return '';
@@ -192,7 +202,7 @@ function getFlagImage($country): string
* @param mixed $v Variable to check. * @param mixed $v Variable to check.
* @return bool Value boolean status. * @return bool Value boolean status.
*/ */
function getBoolean($v): bool function getBoolean($v)
{ {
if(is_bool($v)) { if(is_bool($v)) {
return $v; return $v;
@@ -215,7 +225,7 @@ function getBoolean($v): bool
* @param bool $special Should special characters by used? * @param bool $special Should special characters by used?
* @return string Generated string. * @return string Generated string.
*/ */
function generateRandomString($length, $lowCase = true, $upCase = false, $numeric = false, $special = false): string function generateRandomString($length, $lowCase = true, $upCase = false, $numeric = false, $special = false)
{ {
$characters = ''; $characters = '';
if($lowCase) if($lowCase)
@@ -455,7 +465,7 @@ function tickers()
* Types: head_start, head_end, body_start, body_end, center_top * Types: head_start, head_end, body_start, body_end, center_top
* *
*/ */
function template_place_holder($type): string function template_place_holder($type)
{ {
global $twig, $template_place_holders; global $twig, $template_place_holders;
$ret = ''; $ret = '';
@@ -479,7 +489,7 @@ function template_place_holder($type): string
/** /**
* Returns <head> content to be used by templates. * Returns <head> content to be used by templates.
*/ */
function template_header($is_admin = false): string function template_header($is_admin = false)
{ {
global $title_full, $config, $twig; global $title_full, $config, $twig;
$charset = isset($config['charset']) ? $config['charset'] : 'utf-8'; $charset = isset($config['charset']) ? $config['charset'] : 'utf-8';
@@ -496,32 +506,29 @@ function template_header($is_admin = false): string
/** /**
* Returns footer content to be used by templates. * Returns footer content to be used by templates.
*/ */
function template_footer(): string function template_footer()
{ {
global $views_counter; global $config, $views_counter;
$ret = ''; $ret = '';
if(admin()) { if(admin())
$ret .= generateLink(ADMIN_URL, 'Admin Panel', true); $ret .= generateLink(ADMIN_URL, 'Admin Panel', true);
}
if(setting('core.visitors_counter')) { if($config['visitors_counter'])
{
global $visitors; global $visitors;
$amount = $visitors->getAmountVisitors(); $amount = $visitors->getAmountVisitors();
$ret .= '<br/>Currently there ' . ($amount > 1 ? 'are' : 'is') . ' ' . $amount . ' visitor' . ($amount > 1 ? 's' : '') . '.'; $ret .= '<br/>Currently there ' . ($amount > 1 ? 'are' : 'is') . ' ' . $amount . ' visitor' . ($amount > 1 ? 's' : '') . '.';
} }
if(setting('core.views_counter')) { if($config['views_counter'])
$ret .= '<br/>Page has been viewed ' . $views_counter . ' times.'; $ret .= '<br/>Page has been viewed ' . $views_counter . ' times.';
}
if(setting('core.footer_load_time')) { if(config('footer_show_load_time')) {
$ret .= '<br/>Load time: ' . round(microtime(true) - START_TIME, 4) . ' seconds.'; $ret .= '<br/>Load time: ' . round(microtime(true) - START_TIME, 4) . ' seconds.';
} }
$settingFooter = setting('core.footer'); if(isset($config['footer'][0]))
if(isset($settingFooter[0])) { $ret .= '<br/>' . $config['footer'];
$ret .= '<br/>' . $settingFooter;
}
// please respect my work and help spreading the word, thanks! // please respect my work and help spreading the word, thanks!
return $ret . '<br/>' . base64_decode('UG93ZXJlZCBieSA8YSBocmVmPSJodHRwOi8vbXktYWFjLm9yZyIgdGFyZ2V0PSJfYmxhbmsiPk15QUFDLjwvYT4='); return $ret . '<br/>' . base64_decode('UG93ZXJlZCBieSA8YSBocmVmPSJodHRwOi8vbXktYWFjLm9yZyIgdGFyZ2V0PSJfYmxhbmsiPk15QUFDLjwvYT4=');
@@ -529,8 +536,8 @@ function template_footer(): string
function template_ga_code() function template_ga_code()
{ {
global $twig; global $config, $twig;
if(!isset(setting('core.google_analytics_id')[0])) if(!isset($config['google_analytics_id'][0]))
return ''; return '';
return $twig->render('google_analytics.html.twig'); return $twig->render('google_analytics.html.twig');
@@ -815,7 +822,7 @@ function getWorldName($id)
/** /**
* Mailing users. * Mailing users.
* Mailing has to be enabled in settings (in Admin Panel). * $config['mail_enabled'] have to be enabled.
* *
* @param string $to Recipient email address. * @param string $to Recipient email address.
* @param string $subject Subject of the message. * @param string $subject Subject of the message.
@@ -827,9 +834,8 @@ function _mail($to, $subject, $body, $altBody = '', $add_html_tags = true)
{ {
global $mailer, $config; global $mailer, $config;
if (!setting('core.mail_enabled')) { if (!config('mail_enabled')) {
log_append('mailer-error.log', '_mail() function has been used, but Mail Support is disabled.'); log_append('mailer-error.log', '_mail() function has been used, but config.mail_enabled is disabled.');
return false;
} }
if(!$mailer) if(!$mailer)
@@ -841,60 +847,47 @@ function _mail($to, $subject, $body, $altBody = '', $add_html_tags = true)
$mailer->clearAllRecipients(); $mailer->clearAllRecipients();
} }
$signature_html = setting('core.mail_signature_html'); $signature_html = '';
if(isset($config['mail_signature']['html']))
$signature_html = $config['mail_signature']['html'];
if($add_html_tags && isset($body[0])) if($add_html_tags && isset($body[0]))
$tmp_body = '<html><head></head><body>' . $body . '<br/><br/>' . $signature_html . '</body></html>'; $tmp_body = '<html><head></head><body>' . $body . '<br/><br/>' . $signature_html . '</body></html>';
else else
$tmp_body = $body . '<br/><br/>' . $signature_html; $tmp_body = $body . '<br/><br/>' . $signature_html;
define('MAIL_MAIL', 0); if($config['smtp_enabled'])
define('MAIL_SMTP', 1);
$mailOption = setting('core.mail_option');
if($mailOption == MAIL_SMTP)
{ {
$mailer->isSMTP(); $mailer->isSMTP();
$mailer->Host = setting('core.smtp_host'); $mailer->Host = $config['smtp_host'];
$mailer->Port = setting('core.smtp_port'); $mailer->Port = (int)$config['smtp_port'];
$mailer->SMTPAuth = setting('core.smtp_auth'); $mailer->SMTPAuth = $config['smtp_auth'];
$mailer->Username = setting('core.smtp_user'); $mailer->Username = $config['smtp_user'];
$mailer->Password = setting('core.smtp_pass'); $mailer->Password = $config['smtp_pass'];
$mailer->SMTPSecure = isset($config['smtp_secure']) ? $config['smtp_secure'] : '';
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 { else {
$mailer->isMail(); $mailer->isMail();
} }
$mailer->isHTML(isset($body[0]) > 0); $mailer->isHTML(isset($body[0]) > 0);
$mailer->From = setting('core.mail_address'); $mailer->From = $config['mail_address'];
$mailer->Sender = setting('core.mail_address'); $mailer->Sender = $config['mail_address'];
$mailer->CharSet = 'utf-8'; $mailer->CharSet = 'utf-8';
$mailer->FromName = $config['lua']['serverName']; $mailer->FromName = $config['lua']['serverName'];
$mailer->Subject = $subject; $mailer->Subject = $subject;
$mailer->addAddress($to); $mailer->addAddress($to);
$mailer->Body = $tmp_body; $mailer->Body = $tmp_body;
if(setting('core.smtp_debug')) { if(config('smtp_debug')) {
$mailer->SMTPDebug = 2; $mailer->SMTPDebug = 2;
$mailer->Debugoutput = 'echo'; $mailer->Debugoutput = 'echo';
} }
$signature_plain = setting('core.mail_signature_plain'); $signature_plain = '';
if(isset($config['mail_signature']['plain']))
$signature_plain = $config['mail_signature']['plain'];
if(isset($altBody[0])) { if(isset($altBody[0])) {
$mailer->AltBody = $altBody . $signature_plain; $mailer->AltBody = $altBody . $signature_plain;
} }
@@ -1054,7 +1047,7 @@ function getTopPlayers($limit = 5) {
$deleted = 'deletion'; $deleted = 'deletion';
$is_tfs10 = $db->hasTable('players_online'); $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` < ' . 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(); $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();
if($is_tfs10) { if($is_tfs10) {
foreach($players as &$player) { foreach($players as &$player) {
@@ -1107,9 +1100,6 @@ function deleteDirectory($dir, $ignore = array(), $contentOnly = false) {
function config($key) { function config($key) {
global $config; global $config;
if (is_array($key)) { if (is_array($key)) {
if (is_null($key[1])) {
unset($config[$key[0]]);
}
return $config[$key[0]] = $key[1]; return $config[$key[0]] = $key[1];
} }
@@ -1125,21 +1115,6 @@ function configLua($key) {
return @$config['lua'][$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() function clearCache()
{ {
require_once LIBS . 'news.php'; require_once LIBS . 'news.php';
@@ -1387,39 +1362,48 @@ function getChangelogWhere($v)
return 'unknown'; return 'unknown';
} }
function getPlayerNameByAccount($id)
function getPlayerNameByAccountId($id)
{ {
global $vowels, $ots, $db; global $db;
if(is_numeric($id))
{ if (!is_numeric($id)) {
return '';
}
$account = new OTS_Account();
$account->load($id);
if ($account->isLoaded()) {
$query = $db->query('SELECT `name` FROM `players` WHERE `account_id` = ' . $id . ' ORDER BY `lastlogin` DESC LIMIT 1;');
if (!$query || !$query->rowCount()) {
return '';
}
return $query->fetch(PDO::FETCH_ASSOC)['name'];
}
return '';
}
function getPlayerNameByAccount($account) {
if (is_numeric($account)) {
return getPlayerNameByAccountId($account);
}
return '';
}
function getPlayerNameById($id)
{
if (!is_numeric($id)) {
return '';
}
$player = new OTS_Player(); $player = new OTS_Player();
$player->load($id); $player->load($id);
if($player->isLoaded()) if ($player->isLoaded()) {
return $player->getName(); return $player->getName();
else
{
$playerQuery = $db->query('SELECT `id` FROM `players` WHERE `account_id` = ' . $id . ' ORDER BY `lastlogin` DESC LIMIT 1;')->fetch();
$tmp = "*Error*";
/*
$acco = new OTS_Account();
$acco->load($id);
if(!$acco->isLoaded())
return "Unknown name";
foreach($acco->getPlayersList() as $p)
{
$player= new OTS_Player();
$player->find($p);*/
$player->load($playerQuery['id']);
//echo 'id gracza = ' . $p . '<br/>';
if($player->isLoaded())
$tmp = $player->getName();
// break;
//}
return $tmp;
}
} }
return ''; return '';
@@ -1427,13 +1411,13 @@ function getPlayerNameByAccount($id)
function echo_success($message) function echo_success($message)
{ {
echo '<div class="col-12 success mb-2">' . $message . '</div>'; echo '<div class="col-12 alert alert-success mb-2">' . $message . '</div>';
} }
function echo_error($message) function echo_error($message)
{ {
global $error; global $error;
echo '<div class="col-12 error mb-2">' . $message . '</div>'; echo '<div class="col-12 alert alert-error mb-2">' . $message . '</div>';
$error = true; $error = true;
} }
@@ -1508,8 +1492,8 @@ function right($str, $length) {
} }
function getCreatureImgPath($creature){ function getCreatureImgPath($creature){
$creature_path = config('monsters_images_url'); $creature_path = config('creatures_images_url');
$creature_gfx_name = trim(strtolower($creature)) . config('monsters_images_extension'); $creature_gfx_name = trim(strtolower($creature)) . config('creatures_images_extension');
if (!file_exists($creature_path . $creature_gfx_name)) { if (!file_exists($creature_path . $creature_gfx_name)) {
$creature_gfx_name = str_replace(" ", "", $creature_gfx_name); $creature_gfx_name = str_replace(" ", "", $creature_gfx_name);
if (file_exists($creature_path . $creature_gfx_name)) { if (file_exists($creature_path . $creature_gfx_name)) {

View File

@@ -69,10 +69,6 @@ define('HOOK_ADMIN_LOGIN_AFTER_PASSWORD', ++$i);
define('HOOK_ADMIN_LOGIN_AFTER_SIGN_IN', ++$i); define('HOOK_ADMIN_LOGIN_AFTER_SIGN_IN', ++$i);
define('HOOK_ADMIN_ACCOUNTS_SAVE_POST', ++$i); define('HOOK_ADMIN_ACCOUNTS_SAVE_POST', ++$i);
define('HOOK_EMAIL_CONFIRMED', ++$i); define('HOOK_EMAIL_CONFIRMED', ++$i);
define('HOOK_GUILDS_BEFORE_GUILD_HEADER', ++$i);
define('HOOK_GUILDS_AFTER_GUILD_HEADER', ++$i);
define('HOOK_GUILDS_AFTER_GUILD_INFORMATION', ++$i);
define('HOOK_GUILDS_AFTER_GUILD_MEMBERS', ++$i);
define('HOOK_GUILDS_AFTER_INVITED_CHARACTERS', ++$i); define('HOOK_GUILDS_AFTER_INVITED_CHARACTERS', ++$i);
const HOOK_FIRST = HOOK_STARTUP; const HOOK_FIRST = HOOK_STARTUP;

View File

@@ -9,6 +9,11 @@
*/ */
defined('MYAAC') or die('Direct access not allowed!'); 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']) { if(!isset($config['installed']) || !$config['installed']) {
throw new RuntimeException('MyAAC has not been installed yet or there was error during installation. Please install again.'); throw new RuntimeException('MyAAC has not been installed yet or there was error during installation. Please install again.');
} }
@@ -17,16 +22,13 @@ if(config('env') === 'dev') {
require SYSTEM . 'exception.php'; require SYSTEM . 'exception.php';
} }
if(empty($config['server_path'])) { date_default_timezone_set($config['date_timezone']);
throw new RuntimeException('Server Path has been not set. Go to config.php and set it.');
}
// take care of trailing slash at the end // take care of trailing slash at the end
if($config['server_path'][strlen($config['server_path']) - 1] !== '/') if($config['server_path'][strlen($config['server_path']) - 1] !== '/')
$config['server_path'] .= '/'; $config['server_path'] .= '/';
// enable gzip compression if supported by the browser // enable gzip compression if supported by the browser
if(isset($config['gzip_output']) && $config['gzip_output'] && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('ob_gzhandler')) if($config['gzip_output'] && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('ob_gzhandler'))
ob_start('ob_gzhandler'); ob_start('ob_gzhandler');
// cache // cache
@@ -94,6 +96,9 @@ if(isset($config['lua']['servername']))
if(isset($config['lua']['houserentperiod'])) if(isset($config['lua']['houserentperiod']))
$config['lua']['houseRentPeriod'] = $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 // localize data/ directory based on data directory set in config.lua
foreach(array('dataDirectory', 'data_directory', 'datadir') as $key) { foreach(array('dataDirectory', 'data_directory', 'datadir') as $key) {
if(!isset($config['lua'][$key][0])) { if(!isset($config['lua'][$key][0])) {
@@ -117,34 +122,51 @@ if(!isset($foundValue)) {
$config['data_path'] = $foundValue; $config['data_path'] = $foundValue;
unset($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 // POT
require_once SYSTEM . 'libs/pot/OTS.php'; require_once SYSTEM . 'libs/pot/OTS.php';
$ots = POT::getInstance(); $ots = POT::getInstance();
require_once SYSTEM . 'database.php'; 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_NAME', $db->hasColumn('accounts', 'name'));
define('USE_ACCOUNT_NUMBER', $db->hasColumn('accounts', 'number')); define('USE_ACCOUNT_NUMBER', $db->hasColumn('accounts', 'number'));
define('USE_ACCOUNT_SALT', $db->hasColumn('accounts', 'salt')); define('USE_ACCOUNT_SALT', $db->hasColumn('accounts', 'salt'));
// load vocation names
$tmp = '';
if($cache->enabled() && $cache->fetch('vocations', $tmp)) {
$config['vocations'] = unserialize($tmp);
}
else {
if(!class_exists('DOMDocument')) {
throw new RuntimeException('Please install PHP xml extension. MyAAC will not work without it.');
}
$vocations = new DOMDocument();
$file = $config['data_path'] . 'XML/vocations.xml';
if(!@file_exists($file))
$file = $config['data_path'] . 'vocations.xml';
if(!$vocations->load($file))
throw new RuntimeException('ERROR: Cannot load <i>vocations.xml</i> - the file is malformed. Check the file with xml syntax validator.');
$config['vocations'] = array();
foreach($vocations->getElementsByTagName('vocation') as $vocation) {
$id = $vocation->getAttribute('id');
$config['vocations'][$id] = $vocation->getAttribute('name');
}
if($cache->enabled()) {
$cache->set('vocations', serialize($config['vocations']), 120);
}
}
unset($tmp, $id, $vocation);
require LIBS . 'Towns.php'; require LIBS . 'Towns.php';
Towns::load(); Towns::load();

View File

@@ -18,8 +18,8 @@ class CreateCharacter
*/ */
public function checkName($name, &$errors) public function checkName($name, &$errors)
{ {
$minLength = setting('core.create_character_name_min_length'); $minLength = config('character_name_min_length');
$maxLength = setting('core.create_character_name_max_length'); $maxLength = config('character_name_max_length');
if(empty($name)) { if(empty($name)) {
$errors['name'] = 'Please enter a name for your character!'; $errors['name'] = 'Please enter a name for your character!';
@@ -149,7 +149,7 @@ class CreateCharacter
$char_to_copy = new OTS_Player(); $char_to_copy = new OTS_Player();
$char_to_copy->find($char_to_copy_name); $char_to_copy->find($char_to_copy_name);
if(!$char_to_copy->isLoaded()) if(!$char_to_copy->isLoaded())
$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.'; $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.';
} }
if(!empty($errors)) { if(!empty($errors)) {
@@ -195,7 +195,7 @@ class CreateCharacter
for($skill = POT::SKILL_FIRST; $skill <= POT::SKILL_LAST; $skill++) { for($skill = POT::SKILL_FIRST; $skill <= POT::SKILL_LAST; $skill++) {
$value = 10; $value = 10;
if (setting('core.use_character_sample_skills')) { if (config('use_character_sample_skills')) {
$value = $char_to_copy->getSkill($skill); $value = $char_to_copy->getSkill($skill);
} }
@@ -239,14 +239,14 @@ class CreateCharacter
} }
if($db->hasTable('player_skills')) { if($db->hasTable('player_skills')) {
for($skill = POT::SKILL_FIRST; $skill <= POT::SKILL_LAST; $skill++) { for($i=0; $i<7; $i++) {
$value = 10; $value = 10;
if (setting('core.use_character_sample_skills')) { if (config('use_character_sample_skills')) {
$value = $char_to_copy->getSkill($skill); $value = $char_to_copy->getSkill($i);
} }
$skillExists = $db->query('SELECT `skillid` FROM `player_skills` WHERE `player_id` = ' . $player->getId() . ' AND `skillid` = ' . $skill); $skillExists = $db->query('SELECT `skillid` FROM `player_skills` WHERE `player_id` = ' . $player->getId() . ' AND `skillid` = ' . $i);
if($skillExists->rowCount() <= 0) { if($skillExists->rowCount() <= 0) {
$db->query('INSERT INTO `player_skills` (`player_id`, `skillid`, `value`, `count`) VALUES ('.$player->getId().', '.$skill.', ' . $value . ', 0)'); $db->query('INSERT INTO `player_skills` (`player_id`, `skillid`, `value`, `count`) VALUES ('.$player->getId().', '.$i.', ' . $value . ', 0)');
} }
} }
} }

View File

@@ -1,598 +0,0 @@
<?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;
}
}

View File

@@ -10,7 +10,7 @@
*/ */
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
$configForumTablePrefix = setting('core.forum_table_prefix'); $configForumTablePrefix = config('forum_table_prefix');
if(null !== $configForumTablePrefix && !empty(trim($configForumTablePrefix))) { if(null !== $configForumTablePrefix && !empty(trim($configForumTablePrefix))) {
if(!in_array($configForumTablePrefix, array('myaac_', 'z_'))) { 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_".'); 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 return
$db->query( $db->query(
'SELECT `id` FROM `players` WHERE `account_id` = ' . $db->quote($account->getId()) . 'SELECT `id` FROM `players` WHERE `account_id` = ' . $db->quote($account->getId()) .
' AND `level` >= ' . $db->quote(setting('core.forum_level_required')) . ' AND `level` >= ' . $db->quote($config['forum_level_required']) .
' LIMIT 1')->rowCount() > 0; ' LIMIT 1')->rowCount() > 0;
} }

View File

@@ -151,6 +151,10 @@ class Plugins {
foreach(self::getAllPluginsJson() as $plugin) { foreach(self::getAllPluginsJson() as $plugin) {
if (isset($plugin['hooks'])) { if (isset($plugin['hooks'])) {
foreach ($plugin['hooks'] as $_name => $info) { foreach ($plugin['hooks'] as $_name => $info) {
if (strpos($info['type'], 'HOOK_') !== false) {
$info['type'] = str_replace('HOOK_', '', $info['type']);
}
if (defined('HOOK_'. $info['type'])) { if (defined('HOOK_'. $info['type'])) {
$hook = constant('HOOK_'. $info['type']); $hook = constant('HOOK_'. $info['type']);
$hooks[] = ['name' => $_name, 'type' => $hook, 'file' => $info['file']]; $hooks[] = ['name' => $_name, 'type' => $hook, 'file' => $info['file']];
@@ -168,36 +172,6 @@ class Plugins {
return $hooks; 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) public static function getAllPluginsJson($disabled = false)
{ {
$cache = Cache::getInstance(); $cache = Cache::getInstance();
@@ -210,66 +184,30 @@ class Plugins {
$plugins = []; $plugins = [];
foreach (get_plugins($disabled) as $filename) { foreach (get_plugins($disabled) as $filename) {
$plugin = self::getPluginJson($filename); $string = file_get_contents(PLUGINS . $filename . '.json');
$plugin = json_decode($string, true);
if (!$plugin) { 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.';
continue; continue;
} }
$plugin['filename'] = $filename;
$plugins[] = $plugin; $plugins[] = $plugin;
} }
if ($cache->enabled()) { if ($cache->enabled()) {
$cache->set('plugins', serialize($plugins), 600); // cache for 10 minutes $cache->set('plugins', serialize($plugins), 600);
} }
return $plugins; return $plugins;
} }
public static function getPluginSettings($filename) public static function install($file) {
{
$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; global $db;
if(!\class_exists('ZipArchive')) { if(!\class_exists('ZipArchive')) {
@@ -308,12 +246,6 @@ class Plugins {
return false; 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); $string = file_get_contents($file_name);
$plugin_json = json_decode($string, true); $plugin_json = json_decode($string, true);
self::$plugin_json = $plugin_json; self::$plugin_json = $plugin_json;
@@ -514,23 +446,13 @@ class Plugins {
return false; return false;
} }
public static function isEnabled($pluginFileName): bool public static function enable($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); return self::enableDisable($pluginFileName, true);
} }
public static function disable($pluginFileName): bool { public static function disable($pluginFileName): bool
{
return self::enableDisable($pluginFileName, false); return self::enableDisable($pluginFileName, false);
} }
@@ -608,8 +530,7 @@ class Plugins {
return false; return false;
} }
public static function is_installed($plugin_name, $version): bool public static function is_installed($plugin_name, $version) {
{
$filename = BASE . 'plugins/' . $plugin_name . '.json'; $filename = BASE . 'plugins/' . $plugin_name . '.json';
if(!file_exists($filename)) { if(!file_exists($filename)) {
return false; return false;
@@ -617,7 +538,7 @@ class Plugins {
$string = file_get_contents($filename); $string = file_get_contents($filename);
$plugin_info = json_decode($string, true); $plugin_info = json_decode($string, true);
if(!$plugin_info) { if($plugin_info == false) {
return false; return false;
} }
@@ -640,6 +561,10 @@ class Plugins {
return self::$error; return self::$error;
} }
public static function getPluginJson() {
return self::$plugin_json;
}
/** /**
* Install menus * Install menus
* Helper function for plugins * Helper function for plugins

View File

@@ -286,6 +286,10 @@ class OTS_Monster extends DOMDocument
$element = $this->documentElement->getElementsByTagName('look')->item(0); $element = $this->documentElement->getElementsByTagName('look')->item(0);
if (!$element) {
return $look;
}
$look['type'] = $element->getAttribute('type'); $look['type'] = $element->getAttribute('type');
$look['typeex'] = $element->getAttribute('typeex'); $look['typeex'] = $element->getAttribute('typeex');
$look['head'] = $element->getAttribute('head'); $look['head'] = $element->getAttribute('head');

View File

@@ -57,7 +57,7 @@ class OTS_ServerInfo
private function send(OTS_Buffer $packet) private function send(OTS_Buffer $packet)
{ {
// connects to server // connects to server
$socket = @fsockopen($this->server, $this->port, $error, $message, setting('core.status_timeout')); $socket = @fsockopen($this->server, $this->port, $error, $message, config('status_timeout'));
// if connected then checking statistics // if connected then checking statistics
if($socket) if($socket)

View File

@@ -117,7 +117,7 @@ class Validator
return false; return false;
} }
if(setting('core.account_mail_block_plus_sign')) { if(config('account_mail_block_plus_sign')) {
$explode = explode('@', $email); $explode = explode('@', $email);
if(isset($explode[0]) && (strpos($explode[0],'+') !== false)) { if(isset($explode[0]) && (strpos($explode[0],'+') !== false)) {
self::$lastError = 'Please do not use plus (+) sign in your e-mail.'; self::$lastError = 'Please do not use plus (+) sign in your e-mail.';
@@ -180,16 +180,15 @@ class Validator
return false; return false;
} }
$minLength = config('character_name_min_length');
$maxLength = config('character_name_max_length');
// installer doesn't know config.php yet // installer doesn't know config.php yet
// that's why we need to ignore the nulls // that's why we need to ignore the nulls
if(defined('MYAAC_INSTALL')) { if(is_null($minLength) || is_null($maxLength)) {
$minLength = 4; $minLength = 4;
$maxLength = 21; $maxLength = 21;
} }
else {
$minLength = setting('core.create_character_name_min_length');
$maxLength = setting('core.create_character_name_max_length');
}
$length = strlen($name); $length = strlen($name);
if($length < $minLength) if($length < $minLength)
@@ -222,6 +221,16 @@ class Validator
return false; 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; return true;
} }
@@ -238,8 +247,9 @@ class Validator
$name_lower = strtolower($name); $name_lower = strtolower($name);
$first_words_blocked = array_merge(["'", '-'], setting('core.create_character_name_blocked_prefix')); $first_words_blocked = array('admin ', 'administrator ', 'gm ', 'cm ', 'god ','tutor ', "'", '-');
foreach($first_words_blocked as $word) { foreach($first_words_blocked as $word)
{
if($word == substr($name_lower, 0, strlen($word))) { if($word == substr($name_lower, 0, strlen($word))) {
self::$lastError = 'Your name contains blocked words.'; self::$lastError = 'Your name contains blocked words.';
return false; return false;
@@ -261,7 +271,8 @@ class Validator
return false; 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.'; self::$lastError = 'Invalid character name format. Use only A-Z and numbers 0-9 and no double spaces.';
return false; return false;
} }
@@ -271,16 +282,18 @@ class Validator
return false; return false;
} }
$names_blocked = setting('core.create_character_name_blocked_names'); $names_blocked = array('admin', 'administrator', 'gm', 'cm', 'god', 'tutor');
foreach($names_blocked as $word) { foreach($names_blocked as $word)
{
if($word == $name_lower) { if($word == $name_lower) {
self::$lastError = 'Your name contains blocked words.'; self::$lastError = 'Your name contains blocked words.';
return false; return false;
} }
} }
$words_blocked = array_merge(['--', "''","' ", " '", '- ', ' -', "-'", "'-"], setting('core.create_character_name_blocked_words')); $words_blocked = array('admin', 'administrator', 'gamemaster', 'game master', 'game-master', "game'master", '--', "''","' ", " '", '- ', ' -', "-'", "'-", 'fuck', 'sux', 'suck', 'noob', 'tutor');
foreach($words_blocked as $word) { foreach($words_blocked as $word)
{
if(!(strpos($name_lower, $word) === false)) { if(!(strpos($name_lower, $word) === false)) {
self::$lastError = 'Your name contains illegal words.'; self::$lastError = 'Your name contains illegal words.';
return false; return false;
@@ -296,7 +309,7 @@ class Validator
} }
} }
// check if was namelocked previously //check if was namelocked previously
if($db->hasTable('player_namelocks') && $db->hasColumn('player_namelocks', 'name')) { if($db->hasTable('player_namelocks') && $db->hasColumn('player_namelocks', 'name')) {
$namelock = $db->query('SELECT `player_id` FROM `player_namelocks` WHERE `name` = ' . $db->quote($name)); $namelock = $db->query('SELECT `player_id` FROM `player_namelocks` WHERE `name` = ' . $db->quote($name));
if($namelock->rowCount() > 0) { if($namelock->rowCount() > 0) {
@@ -305,41 +318,39 @@ class Validator
} }
} }
$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)); $monsters = $db->query('SELECT `name` FROM `' . TABLE_PREFIX . 'monsters` WHERE `name` LIKE ' . $db->quote($name_lower));
if ($monsters->rowCount() > 0) { if($monsters->rowCount() > 0) {
self::$lastError = 'Your name cannot contains monster name.'; self::$lastError = 'Your name cannot contains monster name.';
return false; return false;
} }
}
$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)); $spells_name = $db->query('SELECT `name` FROM `' . TABLE_PREFIX . 'spells` WHERE `name` LIKE ' . $db->quote($name_lower));
if ($spells_name->rowCount() > 0) { if($spells_name->rowCount() > 0) {
self::$lastError = 'Your name cannot contains spell name.'; self::$lastError = 'Your name cannot contains spell name.';
return false; return false;
} }
$spells_words = $db->query('SELECT `words` FROM `' . TABLE_PREFIX . 'spells` WHERE `words` = ' . $db->quote($name_lower)); $spells_words = $db->query('SELECT `words` FROM `' . TABLE_PREFIX . 'spells` WHERE `words` = ' . $db->quote($name_lower));
if ($spells_words->rowCount() > 0) { if($spells_words->rowCount() > 0) {
self::$lastError = 'Your name cannot contains spell name.'; self::$lastError = 'Your name cannot contains spell name.';
return false; return false;
} }
}
$npcCheck = setting('core.create_character_name_npc_check'); if(isset($config['npc']))
if ($npcCheck) { {
require_once LIBS . 'npc.php'; if(in_array($name_lower, $config['npc'])) {
NPCS::load();
if(NPCS::$npcs) {
foreach (NPCs::$npcs as $npc) {
if(strpos($name_lower, $npc) !== false) {
self::$lastError = 'Your name cannot contains NPC name.'; self::$lastError = 'Your name cannot contains NPC name.';
return false; return false;
} }
} }
$npcCheck = config('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;
} }
} }

View File

@@ -1,15 +1,47 @@
<?php <?php
$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`;"); if(!isset($database_migration_20)) {
databaseMigration20();
}
$highscores_ignored_ids = array(); function databaseMigration20(&$content = '') {
if($query->rowCount() > 0) { 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) foreach($query->fetchAll() as $result)
$highscores_ignored_ids[] = $result['id']; $highscores_ignored_ids[] = $result['id'];
} }
else { else {
$highscores_ignored_ids[] = 0; $highscores_ignored_ids[] = 0;
} }
$settings = Settings::getInstance(); $php_on_end = substr($content_of_file, -2, 2) == '?>';
$settings->updateInDatabase('core', 'highscores_ids_hidden', implode(', ', $highscores_ignored_ids)); $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;
}

View File

@@ -1,14 +0,0 @@
<?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;");
}

View File

@@ -19,17 +19,17 @@ if(!$logged) {
$player_id = isset($_POST['player_id']) ? (int)$_POST['player_id'] : NULL; $player_id = isset($_POST['player_id']) ? (int)$_POST['player_id'] : NULL;
$name = isset($_POST['name']) ? stripslashes(ucwords(strtolower($_POST['name']))) : NULL; $name = isset($_POST['name']) ? stripslashes(ucwords(strtolower($_POST['name']))) : NULL;
if((!setting('core.account_change_character_name'))) if((!$config['account_change_character_name']))
echo 'Changing character name for premium points is disabled on this server.'; echo 'Changing character name for premium points is disabled on this server.';
else else
{ {
$points = $account_logged->getCustomField(setting('core.donate_column')); $points = $account_logged->getCustomField('premium_points');
if(isset($_POST['changenamesave']) && $_POST['changenamesave'] == 1) { if(isset($_POST['changenamesave']) && $_POST['changenamesave'] == 1) {
if($points < setting('core.account_change_character_name_price')) if($points < $config['account_change_character_name_points'])
$errors[] = 'You need ' . setting('core.account_change_character_name_price') . ' premium points to change name. You have <b>'.$points.'<b> premium points.'; $errors[] = 'You need ' . $config['account_change_character_name_points'] . ' premium points to change name. You have <b>'.$points.'<b> premium points.';
$minLength = setting('core.create_character_name_min_length'); $minLength = config('character_name_min_length');
$maxLength = setting('core.create_character_name_max_length'); $maxLength = config('character_name_max_length');
if(empty($errors) && empty($name)) if(empty($errors) && empty($name))
$errors[] = 'Please enter a new name for your character!'; $errors[] = 'Please enter a new name for your character!';
@@ -86,7 +86,7 @@ else
} }
} }
$account_logged->setCustomField(setting('core.donate_column'), $points - setting('core.account_change_character_name_price')); $account_logged->setCustomField("premium_points", $points - $config['account_change_character_name_points']);
$account_logged->logAction('Changed name from <b>' . $old_name . '</b> to <b>' . $player->getName() . '</b>.'); $account_logged->logAction('Changed name from <b>' . $old_name . '</b> to <b>' . $player->getName() . '</b>.');
$twig->display('success.html.twig', array( $twig->display('success.html.twig', array(
'title' => 'Character Name Changed', 'title' => 'Character Name Changed',

View File

@@ -69,7 +69,7 @@ else
$account_logged->logAction('Account password changed.'); $account_logged->logAction('Account password changed.');
$message = ''; $message = '';
if(setting('core.mail_enabled') && setting('core.mail_send_when_change_password')) { if($config['mail_enabled'] && $config['send_mail_when_change_password']) {
$mailBody = $twig->render('mail.password_changed.html.twig', array( $mailBody = $twig->render('mail.password_changed.html.twig', array(
'new_password' => $org_pass, 'new_password' => $org_pass,
'ip' => get_browser_real_ip(), 'ip' => get_browser_real_ip(),

View File

@@ -20,14 +20,14 @@ if(!$logged) {
$sex_changed = false; $sex_changed = false;
$player_id = isset($_POST['player_id']) ? (int)$_POST['player_id'] : NULL; $player_id = isset($_POST['player_id']) ? (int)$_POST['player_id'] : NULL;
$new_sex = isset($_POST['new_sex']) ? (int)$_POST['new_sex'] : NULL; $new_sex = isset($_POST['new_sex']) ? (int)$_POST['new_sex'] : NULL;
if((!setting('core.account_change_character_sex'))) if((!$config['account_change_character_sex']))
echo 'You cant change your character sex'; echo 'You cant change your character sex';
else else
{ {
$points = $account_logged->getCustomField(setting('core.donate_column')); $points = $account_logged->getCustomField('premium_points');
if(isset($_POST['changesexsave']) && $_POST['changesexsave'] == 1) { if(isset($_POST['changesexsave']) && $_POST['changesexsave'] == 1) {
if($points < setting('core.account_change_character_sex_price')) if($points < $config['account_change_character_sex_points'])
$errors[] = 'You need ' . setting('core.account_change_character_sex_price') . ' premium points to change sex. You have <b>'.$points.'</b> premium points.'; $errors[] = 'You need ' . $config['account_change_character_sex_points'] . ' premium points to change sex. You have <b>'.$points.'</b> premium points.';
if(empty($errors) && !isset($config['genders'][$new_sex])) { if(empty($errors) && !isset($config['genders'][$new_sex])) {
$errors[] = 'This sex is invalid.'; $errors[] = 'This sex is invalid.';
@@ -66,7 +66,7 @@ else
$new_sex_str = $config['genders'][$new_sex]; $new_sex_str = $config['genders'][$new_sex];
$player->save(); $player->save();
$account_logged->setCustomField(setting('core.donate_column'), $points - setting('core.account_change_character_name_price')); $account_logged->setCustomField("premium_points", $points - $config['account_change_character_name_points']);
$account_logged->logAction('Changed sex on character <b>' . $player->getName() . '</b> from <b>' . $old_sex_str . '</b> to <b>' . $new_sex_str . '</b>.'); $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( $twig->display('success.html.twig', array(
'title' => 'Character Sex Changed', 'title' => 'Character Sex Changed',

View File

@@ -219,7 +219,7 @@ if($save)
$tmp_account = (USE_ACCOUNT_NAME ? $account_name : $account_id); $tmp_account = (USE_ACCOUNT_NAME ? $account_name : $account_id);
} }
if(setting('core.mail_enabled') && $config['account_mail_verify']) if($config['mail_enabled'] && $config['account_mail_verify'])
{ {
$hash = md5(generateRandomString(16, true, true) . $email); $hash = md5(generateRandomString(16, true, true) . $email);
$new_account->setCustomField('email_hash', $hash); $new_account->setCustomField('email_hash', $hash);
@@ -294,7 +294,7 @@ if($save)
'custom_buttons' => config('account_create_character_create') ? '' : null 'custom_buttons' => config('account_create_character_create') ? '' : null
)); ));
if(setting('core.mail_enabled') && $config['account_welcome_mail']) if($config['mail_enabled'] && $config['account_welcome_mail'])
{ {
$mailBody = $twig->render('account.welcome_mail.html.twig', array( $mailBody = $twig->render('account.welcome_mail.html.twig', array(
'account' => $tmp_account 'account' => $tmp_account
@@ -313,7 +313,7 @@ if($save)
} }
$country_recognized = null; $country_recognized = null;
if(setting('core.account_country_recognize')) { if($config['account_country_recognize']) {
$country_session = getSession('country'); $country_session = getSession('country');
if($country_session !== false) { // get from session if($country_session !== false) { // get from session
$country_recognized = $country_session; $country_recognized = $country_session;

View File

@@ -11,7 +11,7 @@
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
$title = 'Lost Account Interface'; $title = 'Lost Account Interface';
if(!setting('core.mail_enabled')) if(!$config['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>'; 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; return;
@@ -59,7 +59,7 @@ elseif($action == 'step1' && $action_type == 'email')
$minutesleft = floor($insec / 60); $minutesleft = floor($insec / 60);
$secondsleft = $insec - ($minutesleft * 60); $secondsleft = $insec - ($minutesleft * 60);
$timeleft = $minutesleft.' minutes '.$secondsleft.' seconds'; $timeleft = $minutesleft.' minutes '.$secondsleft.' seconds';
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.'; 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.';
} }
} }
else else
@@ -104,7 +104,7 @@ elseif($action == 'sendcode')
if(_mail($account_mail, $config['lua']['serverName'].' - Recover your account', $mailBody)) if(_mail($account_mail, $config['lua']['serverName'].' - Recover your account', $mailBody))
{ {
$account->setCustomField('email_code', $newcode); $account->setCustomField('email_code', $newcode);
$account->setCustomField('email_next', (time() + setting('core.mail_lost_account_interval'))); $account->setCustomField('email_next', (time() + $config['email_lai_sec_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.'; 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 else
@@ -122,7 +122,7 @@ elseif($action == 'sendcode')
$minutesleft = floor($insec / 60); $minutesleft = floor($insec / 60);
$secondsleft = $insec - ($minutesleft * 60); $secondsleft = $insec - ($minutesleft * 60);
$timeleft = $minutesleft.' minutes '.$secondsleft.' seconds'; $timeleft = $minutesleft.' minutes '.$secondsleft.' seconds';
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.'; 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.';
} }
} }
else else

View File

@@ -35,7 +35,7 @@ if(empty($recovery_key))
$account_registered = '<b><span style="color: red">No</span></b>'; $account_registered = '<b><span style="color: red">No</span></b>';
else else
{ {
if(setting('core.account_generate_new_reckey') && setting('core.mail_enabled')) if($config['generate_new_reckey'] && $config['mail_enabled'])
$account_registered = '<b><span style="color: green">Yes ( <a href="' . getLink('account/register/new') . '"> Buy new Recovery Key </a> )</span></b>'; $account_registered = '<b><span style="color: green">Yes ( <a href="' . getLink('account/register/new') . '"> Buy new Recovery Key </a> )</span></b>';
else else
$account_registered = '<b><span style="color: green">Yes</span></b>'; $account_registered = '<b><span style="color: green">Yes</span></b>';

View File

@@ -31,7 +31,7 @@ if(isset($_POST['registeraccountsave']) && $_POST['registeraccountsave'] == "1")
$account_logged->logAction('Generated recovery key.'); $account_logged->logAction('Generated recovery key.');
$message = ''; $message = '';
if(setting('core.mail_enabled') && setting('core.mail_send_when_generate_reckey')) if($config['mail_enabled'] && $config['send_mail_when_generate_reckey'])
{ {
$mailBody = $twig->render('mail.account.register.html.twig', array( $mailBody = $twig->render('mail.account.register.html.twig', array(
'recovery_key' => $new_rec_key 'recovery_key' => $new_rec_key

View File

@@ -21,18 +21,18 @@ if(isset($_POST['reg_password']))
$reg_password = encrypt((USE_ACCOUNT_SALT ? $account_logged->getCustomField('salt') : '') . $_POST['reg_password']); $reg_password = encrypt((USE_ACCOUNT_SALT ? $account_logged->getCustomField('salt') : '') . $_POST['reg_password']);
$reckey = $account_logged->getCustomField('key'); $reckey = $account_logged->getCustomField('key');
if((!setting('core.account_generate_new_reckey') || !setting('core.mail_enabled')) || empty($reckey)) { if((!$config['generate_new_reckey'] || !$config['mail_enabled']) || empty($reckey)) {
$errors[] = 'You cant get new recovery key.'; $errors[] = 'You cant get new recovery key.';
$twig->display('error_box.html.twig', array('errors' => $errors)); $twig->display('error_box.html.twig', array('errors' => $errors));
} }
else else
{ {
$points = $account_logged->getCustomField(setting('core.donate_column')); $points = $account_logged->getCustomField('premium_points');
if(isset($_POST['registeraccountsave']) && $_POST['registeraccountsave'] == '1') if(isset($_POST['registeraccountsave']) && $_POST['registeraccountsave'] == '1')
{ {
if($reg_password == $account_logged->getPassword()) if($reg_password == $account_logged->getPassword())
{ {
if($points >= setting('core.account_generate_new_reckey_price')) if($points >= $config['generate_new_reckey_price'])
{ {
$show_form = false; $show_form = false;
$new_rec_key = generateRandomString(10, false, true, true); $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)) if(_mail($account_logged->getEMail(), $config['lua']['serverName']." - new recovery key", $mailBody))
{ {
$account_logged->setCustomField('key', $new_rec_key); $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->setCustomField("premium_points", $account_logged->getCustomField("premium_points") - $config['generate_new_reckey_price']);
$account_logged->logAction('Generated new recovery key for ' . setting('core.account_generate_new_reckey_price') . ' premium points.'); $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 '.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 '.$config['generate_new_reckey_price'].' premium points.';
} }
else 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>'; $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 else
$errors[] = 'You need ' . setting('core.account_generate_new_reckey_price') . ' premium points to generate new recovery key. You have <b>'.$points.'<b> premium points.'; $errors[] = 'You need '.$config['generate_new_reckey_price'].' premium points to generate new recovery key. You have <b>'.$points.'<b> premium points.';
} }
else else
$errors[] = 'Wrong password to account.'; $errors[] = 'Wrong password to account.';

View File

@@ -50,7 +50,8 @@ if(!$bansQuery->rowCount())
$nextPage = false; $nextPage = false;
$i = 0; $i = 0;
$bans = $bansQuery->fetchAll(); $bans = $bansQuery->fetchAll(PDO::FETCH_ASSOC);
foreach ($bans as $id => &$ban) foreach ($bans as $id => &$ban)
{ {
if(++$i > $configBansPerPage) if(++$i > $configBansPerPage)
@@ -69,11 +70,22 @@ foreach ($bans as $id => &$ban)
$accountId = $ban['account_id']; $accountId = $ban['account_id'];
} }
$ban['player'] = getPlayerLink(getPlayerNameByAccount($accountId)); $playerName = 'Unknown';
if ($configBans['hasType']) { if ($configBans['hasType']) {
$ban['type'] = getBanType($ban['type']); $ban['type'] = getBanType($ban['type']);
if ($ban['type'] == 2) { // namelock
$playerName = getPlayerNameById($accountId);
} }
else {
$playerName = getPlayerNameByAccount($accountId);
}
}
else {
$playerName = getPlayerNameByAccount($accountId);
}
$ban['player'] = getPlayerLink($playerName);
$expiresColumn = 'expires_at'; $expiresColumn = 'expires_at';
if ($db->hasColumn('bans', 'expires')) { if ($db->hasColumn('bans', 'expires')) {
@@ -104,7 +116,7 @@ foreach ($bans as $id => &$ban)
} }
} }
else { else {
$addedBy = getPlayerLink(getPlayerNameByAccount($ban['banned_by'])); $addedBy = getPlayerLink(getPlayerNameById($ban['banned_by']));
} }
if ($db->hasColumn('bans', 'added')) { if ($db->hasColumn('bans', 'added')) {

View File

@@ -340,8 +340,8 @@ WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, kil
} }
// signature // signature
if(setting('core.signature_enabled')) { if($config['signature_enabled']) {
$signature_url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . urlencode($player->getName()) . '.png'; $signature_url = BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . urlencode($player->getName()) . '.png';
} }
$hidden = $player->isHidden(); $hidden = $player->isHidden();
@@ -396,7 +396,7 @@ WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, kil
'rank' => isset($guild_name) ? $rank_of_player->getName() : null, 'rank' => isset($guild_name) ? $rank_of_player->getName() : null,
'link' => isset($guild_name) ? getGuildLink($guild_name) : null 'link' => isset($guild_name) ? getGuildLink($guild_name) : null
), ),
'comment' => !empty($comment) ? nl2br($comment) : null, 'comment' => !empty($comment) ? wordwrap(nl2br($comment), 60, "<br/>", true) : null,
'skills' => isset($skills) ? $skills : null, 'skills' => isset($skills) ? $skills : null,
'quests_enabled' => $quests_enabled, 'quests_enabled' => $quests_enabled,
'quests' => isset($quests) ? $quests : null, 'quests' => isset($quests) ? $quests : null,

View File

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

View File

@@ -11,9 +11,9 @@ defined('MYAAC') or die('Direct access not allowed!');
$title = 'Experience Table'; $title = 'Experience Table';
$experience = array(); $experience = array();
$columns = setting('core.experience_table_columns'); $columns = $config['experiencetable_columns'];
for($i = 0; $i < $columns; $i++) { for($i = 0; $i < $columns; $i++) {
for($level = $i * setting('core.experience_table_rows') + 1; $level < $i * setting('core.experience_table_rows') + (setting('core.experience_table_rows') + 1); $level++) { for($level = $i * $config['experiencetable_rows'] + 1; $level < $i * $config['experiencetable_rows'] + ($config['experiencetable_rows'] + 1); $level++) {
$experience[$level] = OTS_Toolbox::experienceForLevel($level); $experience[$level] = OTS_Toolbox::experienceForLevel($level);
} }
} }

View File

@@ -10,11 +10,7 @@
*/ */
defined('MYAAC') or exit; defined('MYAAC') or exit;
$ret = require __DIR__ . '/forum/base.php'; require __DIR__ . '/forum/base.php';
if ($ret === false) {
return;
}
require __DIR__ . '/forum/admin.php'; require __DIR__ . '/forum/admin.php';
$errors = []; $errors = [];

View File

@@ -14,33 +14,29 @@ $canEdit = Forum::isModerator();
if($canEdit) { if($canEdit) {
$groups = new OTS_Groups_List(); $groups = new OTS_Groups_List();
if(!empty($action)) { if(!empty($action))
{
if($action == 'delete_board' || $action == 'edit_board' || $action == 'hide_board' || $action == 'moveup_board' || $action == 'movedown_board') if($action == 'delete_board' || $action == 'edit_board' || $action == 'hide_board' || $action == 'moveup_board' || $action == 'movedown_board')
$id = $_REQUEST['id']; $id = $_REQUEST['id'];
if(isset($_REQUEST['access'])) { if(isset($_REQUEST['access']))
$access = $_REQUEST['access']; $access = $_REQUEST['access'];
}
if(isset($_REQUEST['guild'])) { if(isset($_REQUEST['guild']))
$guild = $_REQUEST['guild']; $guild = $_REQUEST['guild'];
}
if(isset($_REQUEST['name'])) { if(isset($_REQUEST['name']))
$name = $_REQUEST['name']; $name = $_REQUEST['name'];
}
if(isset($_REQUEST['description'])) { if(isset($_REQUEST['description']))
$description = stripslashes($_REQUEST['description']); $description = stripslashes($_REQUEST['description']);
}
$errors = []; $errors = array();
if($action == 'add_board') { if($action == 'add_board') {
if(Forum::add_board($name, $description, $access, $guild, $errors)) { if(Forum::add_board($name, $description, $access, $guild, $errors))
$action = $name = $description = ''; $action = $name = $description = '';
} }
}
else if($action == 'delete_board') { else if($action == 'delete_board') {
Forum::delete_board($id, $errors); Forum::delete_board($id, $errors);
$action = ''; $action = '';

View File

@@ -11,26 +11,26 @@
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
$title = 'Forum'; $title = 'Forum';
require_once LIBS . 'forum.php'; if(strtolower($config['forum']) != 'site')
{
$forumSetting = setting('core.forum'); if($config['forum'] != '')
if(strtolower($forumSetting) != 'site') { {
if($forumSetting != '') { header('Location: ' . $config['forum']);
header('Location: ' . $forumSetting);
exit; exit;
} }
echo 'Forum is disabled on this site.'; echo 'Forum is disabled on this site.';
return false; return;
} }
if(!$logged) { 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 />'; 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(); $sections = array();
foreach(getForumBoards() as $section) { foreach(getForumBoards() as $section)
{
$sections[$section['id']] = array( $sections[$section['id']] = array(
'id' => $section['id'], 'id' => $section['id'],
'name' => $section['name'], 'name' => $section['name'],

View File

@@ -10,10 +10,7 @@
*/ */
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
$ret = require __DIR__ . '/base.php'; require __DIR__ . '/base.php';
if ($ret === false) {
return;
}
if(Forum::canPost($account_logged)) if(Forum::canPost($account_logged))
{ {
@@ -25,15 +22,17 @@ if(Forum::canPost($account_logged))
} }
$thread = $db->query("SELECT `author_guid`, `author_aid`, `first_post`, `post_topic`, `post_date`, `post_text`, `post_smile`, `post_html`, `id`, `section` FROM `" . FORUM_TABLE_PREFIX . "forum` WHERE `id` = ".$post_id." LIMIT 1")->fetch(); $thread = $db->query("SELECT `author_guid`, `author_aid`, `first_post`, `post_topic`, `post_date`, `post_text`, `post_smile`, `post_html`, `id`, `section` FROM `" . FORUM_TABLE_PREFIX . "forum` WHERE `id` = ".$post_id." LIMIT 1")->fetch();
if(isset($thread['id'])) { if(isset($thread['id']))
{
$first_post = $db->query("SELECT `" . FORUM_TABLE_PREFIX . "forum`.`author_guid`, `" . FORUM_TABLE_PREFIX . "forum`.`author_aid`, `" . FORUM_TABLE_PREFIX . "forum`.`first_post`, `" . FORUM_TABLE_PREFIX . "forum`.`post_topic`, `" . FORUM_TABLE_PREFIX . "forum`.`post_text`, `" . FORUM_TABLE_PREFIX . "forum`.`post_smile`, `" . FORUM_TABLE_PREFIX . "forum`.`id`, `" . FORUM_TABLE_PREFIX . "forum`.`section` FROM `" . FORUM_TABLE_PREFIX . "forum` WHERE `" . FORUM_TABLE_PREFIX . "forum`.`id` = ".(int) $thread['first_post']." LIMIT 1")->fetch(); $first_post = $db->query("SELECT `" . FORUM_TABLE_PREFIX . "forum`.`author_guid`, `" . FORUM_TABLE_PREFIX . "forum`.`author_aid`, `" . FORUM_TABLE_PREFIX . "forum`.`first_post`, `" . FORUM_TABLE_PREFIX . "forum`.`post_topic`, `" . FORUM_TABLE_PREFIX . "forum`.`post_text`, `" . FORUM_TABLE_PREFIX . "forum`.`post_smile`, `" . FORUM_TABLE_PREFIX . "forum`.`id`, `" . FORUM_TABLE_PREFIX . "forum`.`section` FROM `" . FORUM_TABLE_PREFIX . "forum` WHERE `" . FORUM_TABLE_PREFIX . "forum`.`id` = ".(int) $thread['first_post']." LIMIT 1")->fetch();
echo '<a href="' . getLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($thread['section']) . '">'.$sections[$thread['section']]['name'].'</a> >> <a href="' . getForumThreadLink($thread['first_post']) . '">'.$first_post['post_topic'].'</a> >> <b>Edit post</b>'; echo '<a href="' . getLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($thread['section']) . '">'.$sections[$thread['section']]['name'].'</a> >> <a href="' . getForumThreadLink($thread['first_post']) . '">'.$first_post['post_topic'].'</a> >> <b>Edit post</b>';
if(Forum::hasAccess($thread['section'] && ($account_logged->getId() == $thread['author_aid'] || Forum::isModerator())))
if(Forum::hasAccess($thread['section'] && ($account_logged->getId() == $thread['author_aid'] || Forum::isModerator()))) { {
$char_id = $post_topic = $text = $smile = $html = null; $char_id = $post_topic = $text = $smile = $html = null;
$players_from_account = $db->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll(); $players_from_account = $db->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll();
$saved = false; $saved = false;
if(isset($_REQUEST['save'])) { if(isset($_REQUEST['save']))
{
$text = stripslashes(trim($_REQUEST['text'])); $text = stripslashes(trim($_REQUEST['text']));
$char_id = (int) $_REQUEST['char_id']; $char_id = (int) $_REQUEST['char_id'];
$post_topic = stripslashes(trim($_REQUEST['topic'])); $post_topic = stripslashes(trim($_REQUEST['topic']));
@@ -41,35 +40,28 @@ if(Forum::canPost($account_logged))
$html = isset($_REQUEST['html']) ? (int)$_REQUEST['html'] : 0; $html = isset($_REQUEST['html']) ? (int)$_REQUEST['html'] : 0;
$length = strlen($post_topic); $length = strlen($post_topic);
if(($length < 1 || $length > 60) && $thread['id'] == $thread['first_post']) { if(($length < 1 || $length > 60) && $thread['id'] == $thread['first_post'])
$errors[] = "Too short or too long topic (Length: $length letters). Minimum 1 letter, maximum 60 letters."; $errors[] = "Too short or too long topic (Length: $length letters). Minimum 1 letter, maximum 60 letters.";
}
$length = strlen($text); $length = strlen($text);
if($length < 1 || $length > 15000) { if($length < 1 || $length > 15000)
$errors[] = "Too short or too long post (Length: $length letters). Minimum 1 letter, maximum 15000 letters."; $errors[] = "Too short or too long post (Length: $length letters). Minimum 1 letter, maximum 15000 letters.";
}
if($char_id == 0) { if($char_id == 0)
$errors[] = 'Please select a character.'; $errors[] = 'Please select a character.';
}
if(empty($post_topic) && $thread['id'] == $thread['first_post']) { if(empty($post_topic) && $thread['id'] == $thread['first_post'])
$errors[] = 'Thread topic can\'t be empty.'; $errors[] = 'Thread topic can\'t be empty.';
}
$player_on_account = false; $player_on_account = false;
if(count($errors) == 0) { if(count($errors) == 0)
foreach($players_from_account as $player) { {
if ($char_id == $player['id']) { foreach($players_from_account as $player)
if($char_id == $player['id'])
$player_on_account = true; $player_on_account = true;
} if(!$player_on_account)
} $errors[] = 'Player with selected ID '.$char_id.' doesn\'t exist or isn\'t on your account';
if(!$player_on_account) {
$errors[] = 'Player with selected ID ' . $char_id . ' doesn\'t exist or isn\'t on your account';
}
} }
if(count($errors) == 0) { if(count($errors) == 0) {
@@ -78,7 +70,7 @@ if(Forum::canPost($account_logged))
$char_id = $thread['author_guid']; $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']); $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(); $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'] / setting('core.forum_threads_per_page')) - 1; $_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
header('Location: ' . getForumThreadLink($thread['first_post'], $_page)); 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>'; echo '<br />Thank you for editing post.<br /><a href="' . getForumThreadLink($thread['first_post'], $_page) . '">GO BACK TO LAST THREAD</a>';
} }
@@ -91,10 +83,10 @@ if(Forum::canPost($account_logged))
$html = (int) $thread['post_html']; $html = (int) $thread['post_html'];
} }
if(!$saved) { if(!$saved)
if(!empty($errors)) { {
if(!empty($errors))
$twig->display('error_box.html.twig', array('errors' => $errors)); $twig->display('error_box.html.twig', array('errors' => $errors));
}
$twig->display('forum.edit_post.html.twig', array( $twig->display('forum.edit_post.html.twig', array(
'post_id' => $post_id, 'post_id' => $post_id,
@@ -120,6 +112,6 @@ if(Forum::canPost($account_logged))
} }
} }
else { else {
$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."; $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.";
displayErrorBoxWithBackButton($errors, getLink('forum')); displayErrorBoxWithBackButton($errors, getLink('forum'));
} }

View File

@@ -10,10 +10,7 @@
*/ */
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
$ret = require __DIR__ . '/base.php'; require __DIR__ . '/base.php';
if ($ret === false) {
return;
}
if(!Forum::isModerator()) { if(!Forum::isModerator()) {
echo 'You are not logged in or you are not moderator.'; echo 'You are not logged in or you are not moderator.';

View File

@@ -10,12 +10,10 @@
*/ */
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
$ret = require __DIR__ . '/base.php'; require __DIR__ . '/base.php';
if ($ret === false) {
return;
}
if(!$logged) { if(!$logged)
{
$extra_url = ''; $extra_url = '';
if(isset($_GET['thread_id'])) { if(isset($_GET['thread_id'])) {
$extra_url = '&action=new_post&thread_id=' . $_GET['thread_id']; $extra_url = '&action=new_post&thread_id=' . $_GET['thread_id'];
@@ -25,7 +23,8 @@ if(!$logged) {
return; return;
} }
if(Forum::canPost($account_logged)) { 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(); $players_from_account = $db->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll();
$thread_id = isset($_REQUEST['thread_id']) ? (int) $_REQUEST['thread_id'] : 0; $thread_id = isset($_REQUEST['thread_id']) ? (int) $_REQUEST['thread_id'] : 0;
if($thread_id == 0) { if($thread_id == 0) {
@@ -36,47 +35,43 @@ if(Forum::canPost($account_logged)) {
$thread = $db->query("SELECT `" . FORUM_TABLE_PREFIX . "forum`.`post_topic`, `" . FORUM_TABLE_PREFIX . "forum`.`id`, `" . FORUM_TABLE_PREFIX . "forum`.`section` FROM `" . FORUM_TABLE_PREFIX . "forum` WHERE `" . FORUM_TABLE_PREFIX . "forum`.`id` = ".(int) $thread_id." AND `" . FORUM_TABLE_PREFIX . "forum`.`first_post` = ".$thread_id." LIMIT 1")->fetch(); $thread = $db->query("SELECT `" . FORUM_TABLE_PREFIX . "forum`.`post_topic`, `" . FORUM_TABLE_PREFIX . "forum`.`id`, `" . FORUM_TABLE_PREFIX . "forum`.`section` FROM `" . FORUM_TABLE_PREFIX . "forum` WHERE `" . FORUM_TABLE_PREFIX . "forum`.`id` = ".(int) $thread_id." AND `" . FORUM_TABLE_PREFIX . "forum`.`first_post` = ".$thread_id." LIMIT 1")->fetch();
if(isset($thread['id']) && Forum::hasAccess($thread['section'])) { if(isset($thread['id']) && Forum::hasAccess($thread['section']))
{
echo '<a href="' . getLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($thread['section']) . '">'.$sections[$thread['section']]['name'].'</a> >> <a href="' . getForumThreadLink($thread_id) . '">'.$thread['post_topic'].'</a> >> <b>Post new reply</b><br /><h3>'.$thread['post_topic'].'</h3>'; echo '<a href="' . getLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($thread['section']) . '">'.$sections[$thread['section']]['name'].'</a> >> <a href="' . getForumThreadLink($thread_id) . '">'.$thread['post_topic'].'</a> >> <b>Post new reply</b><br /><h3>'.$thread['post_topic'].'</h3>';
$quote = isset($_REQUEST['quote']) ? (int) $_REQUEST['quote'] : NULL; $quote = isset($_REQUEST['quote']) ? (int) $_REQUEST['quote'] : NULL;
$text = isset($_REQUEST['text']) ? stripslashes(trim($_REQUEST['text'])) : NULL; $text = isset($_REQUEST['text']) ? stripslashes(trim($_REQUEST['text'])) : NULL;
$char_id = (int) ($_REQUEST['char_id'] ?? 0); $char_id = (int) ($_REQUEST['char_id'] ?? 0);
$post_topic = isset($_REQUEST['topic']) ? stripslashes(trim($_REQUEST['topic'])) : ''; $post_topic = isset($_REQUEST['topic']) ? stripslashes(trim($_REQUEST['topic'])) : '';
$smile = (int)($_REQUEST['smile'] ?? 0); $smile = (isset($_REQUEST['smile']) ? (int)$_REQUEST['smile'] : 0);
$html = (int)($_REQUEST['html'] ?? 0); $html = (isset($_REQUEST['html']) ? (int)$_REQUEST['html'] : 0);
$saved = false; $saved = false;
if(isset($_REQUEST['quote']))
if(isset($_REQUEST['quote'])) { {
$quoted_post = $db->query("SELECT `players`.`name`, `" . FORUM_TABLE_PREFIX . "forum`.`post_text`, `" . 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`.`id` = ".(int) $quote)->fetchAll(); $quoted_post = $db->query("SELECT `players`.`name`, `" . FORUM_TABLE_PREFIX . "forum`.`post_text`, `" . 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`.`id` = ".(int) $quote)->fetchAll();
if(isset($quoted_post[0]['name'])) { if(isset($quoted_post[0]['name']))
$text = '[i]Originally posted by ' . $quoted_post[0]['name'] . ' on ' . date('d.m.y H:i:s', $quoted_post[0]['post_date']) . ':[/i][quote]' . $quoted_post[0]['post_text'] . '[/quote]'; $text = '[i]Originally posted by '.$quoted_post[0]['name'].' on '.date('d.m.y H:i:s', $quoted_post[0]['post_date']).':[/i][quote]'.$quoted_post[0]['post_text'].'[/quote]';
} }
} elseif(isset($_REQUEST['save']))
elseif(isset($_REQUEST['save'])) { {
$length = strlen($text); $length = strlen($text);
if($length < 1 || strlen($text) > 15000) { if($length < 1 || strlen($text) > 15000)
$errors[] = 'Too short or too long post (Length: $length letters). Minimum 1 letter, maximum 15000 letters.'; $errors[] = 'Too short or too long post (Length: $length letters). Minimum 1 letter, maximum 15000 letters.';
}
if($char_id == 0) { if($char_id == 0)
$errors[] = 'Please select a character.'; $errors[] = 'Please select a character.';
}
$player_on_account = false; $player_on_account = false;
if(count($errors) == 0) { if(count($errors) == 0)
foreach($players_from_account as $player) { {
if ($char_id == $player['id']) { foreach($players_from_account as $player)
if($char_id == $player['id'])
$player_on_account = true; $player_on_account = true;
if(!$player_on_account)
$errors[] = 'Player with selected ID '.$char_id.' doesn\'t exist or isn\'t on your account';
} }
} if(count($errors) == 0)
{
if(!$player_on_account) {
$errors[] = 'Player with selected ID ' . $char_id . ' doesn\'t exist or isn\'t on your account';
}
}
if(count($errors) == 0) {
$last_post = 0; $last_post = 0;
$query = $db->query('SELECT post_date FROM ' . FORUM_TABLE_PREFIX . 'forum ORDER BY post_date DESC LIMIT 1'); $query = $db->query('SELECT post_date FROM ' . FORUM_TABLE_PREFIX . 'forum ORDER BY post_date DESC LIMIT 1');
if($query->rowCount() > 0) if($query->rowCount() > 0)
@@ -84,28 +79,27 @@ if(Forum::canPost($account_logged)) {
$query = $query->fetch(); $query = $query->fetch();
$last_post = $query['post_date']; $last_post = $query['post_date'];
} }
if($last_post+setting('core.forum_post_interval')-time() > 0 && !Forum::isModerator()) if($last_post+$config['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).'; $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(count($errors) == 0)
if(count($errors) == 0) { {
$saved = true; $saved = true;
Forum::add_post($thread['id'], $thread['section'], $account_logged->getId(), $char_id, $text, $post_topic, $smile, $html); Forum::add_post($thread['id'], $thread['section'], $account_logged->getId(), (int) $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); $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(); $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'] / setting('core.forum_threads_per_page')) - 1; $_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
header('Location: ' . getForumThreadLink($thread_id, $_page)); 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>'; echo '<br />Thank you for posting.<br /><a href="' . getForumThreadLink($thread_id, $_page) . '">GO BACK TO LAST THREAD</a>';
} }
} }
if(!$saved) { if(!$saved)
if(!empty($errors)) { {
if(!empty($errors))
$twig->display('error_box.html.twig', array('errors' => $errors)); $twig->display('error_box.html.twig', array('errors' => $errors));
}
$threads = $db->query("SELECT `players`.`name`, `" . FORUM_TABLE_PREFIX . "forum`.`post_text`, `" . FORUM_TABLE_PREFIX . "forum`.`post_topic`, `" . FORUM_TABLE_PREFIX . "forum`.`post_smile`, `" . FORUM_TABLE_PREFIX . "forum`.`post_html`, `" . FORUM_TABLE_PREFIX . "forum`.`author_aid` 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." ORDER BY `" . FORUM_TABLE_PREFIX . "forum`.`post_date` DESC LIMIT 5")->fetchAll(); $threads = $db->query("SELECT `players`.`name`, `" . FORUM_TABLE_PREFIX . "forum`.`post_text`, `" . FORUM_TABLE_PREFIX . "forum`.`post_topic`, `" . FORUM_TABLE_PREFIX . "forum`.`post_smile`, `" . FORUM_TABLE_PREFIX . "forum`.`post_html`, `" . FORUM_TABLE_PREFIX . "forum`.`author_aid` 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." ORDER BY `" . FORUM_TABLE_PREFIX . "forum`.`post_date` DESC LIMIT 5")->fetchAll();
foreach($threads as &$thread) { foreach($threads as &$thread) {
$player_account = new OTS_Account(); $player_account = new OTS_Account();
$player_account->load($thread['author_aid']); $player_account->load($thread['author_aid']);
@@ -134,7 +128,7 @@ if(Forum::canPost($account_logged)) {
} }
} }
else { else {
$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."; $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.";
displayErrorBoxWithBackButton($errors, getLink('forum')); displayErrorBoxWithBackButton($errors, getLink('forum'));
} }

View File

@@ -10,17 +10,14 @@
*/ */
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
$ret = require __DIR__ . '/base.php'; require __DIR__ . '/base.php';
if ($ret === false) {
return;
}
if(Forum::canPost($account_logged)) { 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(); $players_from_account = $db->query('SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = '.(int) $account_logged->getId())->fetchAll();
$section_id = $_REQUEST['section_id'] ?? null; $section_id = $_REQUEST['section_id'] ?? null;
if($section_id !== null) { if($section_id !== null) {
echo '<a href="' . getLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($section_id) . '">' . $sections[$section_id]['name'] . '</a> >> <b>Post new thread</b><br />'; echo '<a href="' . getLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($section_id) . '">' . $sections[$section_id]['name'] . '</a> >> <b>Post new thread</b><br />';
if(isset($sections[$section_id]['name']) && Forum::hasAccess($section_id)) { if(isset($sections[$section_id]['name']) && Forum::hasAccess($section_id)) {
if ($sections[$section_id]['closed'] && !Forum::isModerator()) if ($sections[$section_id]['closed'] && !Forum::isModerator())
$errors[] = 'You cannot create topic on this board.'; $errors[] = 'You cannot create topic on this board.';
@@ -34,64 +31,48 @@ if(Forum::canPost($account_logged)) {
$saved = false; $saved = false;
if (isset($_REQUEST['save'])) { if (isset($_REQUEST['save'])) {
$length = strlen($post_topic); $length = strlen($post_topic);
if ($length < 1 || $length > 60) { if ($length < 1 || $length > 60)
$errors[] = "Too short or too long topic (Length: $length letters). Minimum 1 letter, maximum 60 letters."; $errors[] = "Too short or too long topic (Length: $length letters). Minimum 1 letter, maximum 60 letters.";
}
$length = strlen($text); $length = strlen($text);
if ($length < 1 || $length > 15000) { if ($length < 1 || $length > 15000)
$errors[] = "Too short or too long post (Length: $length letters). Minimum 1 letter, maximum 15000 letters."; $errors[] = "Too short or too long post (Length: $length letters). Minimum 1 letter, maximum 15000 letters.";
}
if ($char_id == 0) { if ($char_id == 0)
$errors[] = 'Please select a character.'; $errors[] = 'Please select a character.';
}
$player_on_account = false; $player_on_account = false;
if (count($errors) == 0) { if (count($errors) == 0) {
foreach ($players_from_account as $player) { foreach ($players_from_account as $player)
if ($char_id == $player['id']) { if ($char_id == $player['id'])
$player_on_account = true; $player_on_account = true;
} if (!$player_on_account)
} $errors[] = 'Player with selected ID ' . $char_id . ' doesn\'t exist or isn\'t on your account';
if (!$player_on_account) {
$errors[] = "Player with selected ID $char_id doesn't exist or isn't on your account";
}
} }
if (count($errors) == 0) { if (count($errors) == 0) {
$last_post = 0; $last_post = 0;
$query = $db->query('SELECT `post_date` FROM `' . FORUM_TABLE_PREFIX . 'forum` ORDER BY `post_date` DESC LIMIT 1'); $query = $db->query('SELECT `post_date` FROM `' . FORUM_TABLE_PREFIX . 'forum` ORDER BY `post_date` DESC LIMIT 1');
if ($query->rowCount() > 0) { if ($query->rowCount() > 0) {
$query = $query->fetch(); $query = $query->fetch();
$last_post = $query['post_date']; $last_post = $query['post_date'];
} }
if ($last_post + $config['forum_post_interval'] - time() > 0 && !Forum::isModerator())
if ($last_post + setting('core.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).';
$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) { if (count($errors) == 0) {
$saved = true; $saved = true;
$db->query("INSERT INTO `" . FORUM_TABLE_PREFIX . "forum` (`first_post` ,`last_post` ,`section` ,`replies` ,`views` ,`author_aid` ,`author_guid` ,`post_text` ,`post_topic` ,`post_smile`, `post_html` ,`post_date` ,`last_edit_aid` ,`edit_date`, `post_ip`) VALUES ('0', '" . time() . "', '" . (int)$section_id . "', '0', '0', '" . $account_logged->getId() . "', '" . (int)$char_id . "', " . $db->quote($text) . ", " . $db->quote($post_topic) . ", '" . (int)$smile . "', '" . (int)$html . "', '" . time() . "', '0', '0', '" . $_SERVER['REMOTE_ADDR'] . "')");
$db->query("INSERT INTO `" . FORUM_TABLE_PREFIX . "forum` (`first_post` ,`last_post` ,`section` ,`replies` ,`views` ,`author_aid` ,`author_guid` ,`post_text` ,`post_topic` ,`post_smile`, `post_html` ,`post_date` ,`last_edit_aid` ,`edit_date`, `post_ip`) VALUES ('0', '" . time() . "', '" . (int)$section_id . "', '0', '0', '" . $account_logged->getId() . "', '" . $char_id . "', " . $db->quote($text) . ", " . $db->quote($post_topic) . ", '" . $smile . "', '" . $html . "', '" . time() . "', '0', '0', '" . $_SERVER['REMOTE_ADDR'] . "')");
$thread_id = $db->lastInsertId(); $thread_id = $db->lastInsertId();
$db->query("UPDATE `" . FORUM_TABLE_PREFIX . "forum` SET `first_post`=" . (int)$thread_id . " WHERE `id` = " . (int)$thread_id); $db->query("UPDATE `" . FORUM_TABLE_PREFIX . "forum` SET `first_post`=" . (int)$thread_id . " WHERE `id` = " . (int)$thread_id);
header('Location: ' . getForumThreadLink($thread_id)); header('Location: ' . getForumThreadLink($thread_id));
echo '<br />Thank you for posting.<br /><a href="' . getForumThreadLink($thread_id) . '">GO BACK TO LAST THREAD</a>'; echo '<br />Thank you for posting.<br /><a href="' . getForumThreadLink($thread_id) . '">GO BACK TO LAST THREAD</a>';
} }
} }
if (!$saved) { if (!$saved) {
if (!empty($errors)) { if (!empty($errors))
$twig->display('error_box.html.twig', array('errors' => $errors)); $twig->display('error_box.html.twig', array('errors' => $errors));
}
$twig->display('forum.new_thread.html.twig', array( $twig->display('forum.new_thread.html.twig', array(
'section_id' => $section_id, 'section_id' => $section_id,
@@ -116,6 +97,6 @@ if(Forum::canPost($account_logged)) {
} }
} }
else { else {
$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.'; $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.';
displayErrorBoxWithBackButton($errors, getLink('forum')); displayErrorBoxWithBackButton($errors, getLink('forum'));
} }

View File

@@ -10,23 +10,23 @@
*/ */
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
$ret = require __DIR__ . '/base.php'; require __DIR__ . '/base.php';
if ($ret === false) {
return;
}
if(Forum::isModerator()) { if(Forum::isModerator())
{
$id = (int) $_REQUEST['id']; $id = (int) $_REQUEST['id'];
$post = $db->query("SELECT `id`, `first_post`, `section` FROM `" . FORUM_TABLE_PREFIX . "forum` WHERE `id` = ".$id." LIMIT 1")->fetch(); $post = $db->query("SELECT `id`, `first_post`, `section` FROM `" . FORUM_TABLE_PREFIX . "forum` WHERE `id` = ".$id." LIMIT 1")->fetch();
if($post['id'] == $id && Forum::hasAccess($post['section']))
if($post['id'] == $id && Forum::hasAccess($post['section'])) { {
if($post['id'] == $post['first_post']) { if($post['id'] == $post['first_post'])
{
$db->query("DELETE FROM `" . FORUM_TABLE_PREFIX . "forum` WHERE `first_post` = ".$post['id']); $db->query("DELETE FROM `" . FORUM_TABLE_PREFIX . "forum` WHERE `first_post` = ".$post['id']);
header('Location: ' . getForumBoardLink($post['section'])); header('Location: ' . getForumBoardLink($post['section']));
} }
else { 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(); $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'] / setting('core.forum_threads_per_page')) - 1; $_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
$db->query("DELETE FROM `" . FORUM_TABLE_PREFIX . "forum` WHERE `id` = ".$post['id']); $db->query("DELETE FROM `" . FORUM_TABLE_PREFIX . "forum` WHERE `id` = ".$post['id']);
header('Location: ' . getForumThreadLink($post['first_post'], (int) $_page)); header('Location: ' . getForumThreadLink($post['first_post'], (int) $_page));
} }
@@ -38,5 +38,5 @@ if(Forum::isModerator()) {
} }
else { else {
$errors[] = 'You are not logged in or you are not moderator.'; $errors[] = 'You are not logged in or you are not moderator.';
displayErrorBoxWithBackButton($errors, getLink('forum')); displayErrorBoxWithBackButton($errors, getLink('forum'));
} }

View File

@@ -10,16 +10,13 @@
*/ */
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
$ret = require __DIR__ . '/base.php'; require __DIR__ . '/base.php';
if ($ret === false) {
return;
}
$links_to_pages = ''; $links_to_pages = '';
$section_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : null; $section_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : null;
if($section_id == null || !isset($sections[$section_id])) { if($section_id == null || !isset($sections[$section_id])) {
$errors[] = "Board with this id doesn't exist."; $errors[] = "Board with this id does't exist.";
displayErrorBoxWithBackButton($errors, getLink('forum')); displayErrorBoxWithBackButton($errors, getLink('forum'));
return; return;
} }
@@ -32,24 +29,24 @@ if(!Forum::hasAccess($section_id)) {
$_page = (int) (isset($_REQUEST['page']) ? $_REQUEST['page'] : 0); $_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(); $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'] / setting('core.forum_threads_per_page'); $i++) { for($i = 0; $i < $threads_count['threads_count'] / $config['forum_threads_per_page']; $i++)
{
if($i != $_page) if($i != $_page)
$links_to_pages .= '<a href="' . getForumBoardLink($section_id, $i) . '">'.($i + 1).'</a> '; $links_to_pages .= '<a href="' . getForumBoardLink($section_id, $i) . '">'.($i + 1).'</a> ';
else else
$links_to_pages .= '<b>'.($i + 1).' </b>'; $links_to_pages .= '<b>'.($i + 1).' </b>';
} }
echo '<a href="' . getLink('forum') . '">Boards</a> >> <b>'.$sections[$section_id]['name'].'</b>'; echo '<a href="' . getLink('forum') . '">Boards</a> >> <b>'.$sections[$section_id]['name'].'</b>';
if(!$sections[$section_id]['closed'] || Forum::isModerator())
if(!$sections[$section_id]['closed'] || Forum::isModerator()) { {
echo '<br /><br /> echo '<br /><br />
<a href="?subtopic=forum&action=new_thread&section_id='.$section_id.'"><img src="images/forum/topic.gif" border="0" /></a>'; <a href="?subtopic=forum&action=new_thread&section_id='.$section_id.'"><img src="images/forum/topic.gif" border="0" /></a>';
} }
echo '<br /><br />Page: '.$links_to_pages.'<br />'; 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 ".setting('core.forum_threads_per_page')." OFFSET ".($_page * setting('core.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` = ".(int) $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();
if(isset($last_threads[0]))
if(isset($last_threads[0])) { {
echo '<table width="100%"> echo '<table width="100%">
<tr bgcolor="'.$config['vdarkborder'].'" align="center"> <tr bgcolor="'.$config['vdarkborder'].'" align="center">
<td class="white"> <td class="white">
@@ -61,7 +58,8 @@ if(isset($last_threads[0])) {
</tr>'; </tr>';
$player = new OTS_Player(); $player = new OTS_Player();
foreach($last_threads as $thread) { foreach($last_threads as $thread)
{
echo '<tr bgcolor="' . getStyle($number_of_rows++) . '"><td>'; echo '<tr bgcolor="' . getStyle($number_of_rows++) . '"><td>';
if(Forum::isModerator()) { if(Forum::isModerator()) {
echo '<a href="?subtopic=forum&action=move_thread&id='.$thread['id'].'"\')"><span style="color:darkgreen">[MOVE]</span></a>'; echo '<a href="?subtopic=forum&action=move_thread&id='.$thread['id'].'"\')"><span style="color:darkgreen">[MOVE]</span></a>';
@@ -77,24 +75,21 @@ if(isset($last_threads[0])) {
$canEditForum = $player_account->hasFlag(FLAG_CONTENT_FORUM) || $player_account->isAdmin(); $canEditForum = $player_account->hasFlag(FLAG_CONTENT_FORUM) || $player_account->isAdmin();
echo '<a href="' . getForumThreadLink($thread['id']) . '">'.($canEditForum ? $thread['post_topic'] : htmlspecialchars($thread['post_topic'])) . '</a><br /><small>'.($canEditForum ? substr(strip_tags($thread['post_text']), 0, 50) : htmlspecialchars(substr($thread['post_text'], 0, 50))).'...</small></td><td>' . getPlayerLink($thread['name']) . '</td><td>'.(int) $thread['replies'].'</td><td>'.(int) $thread['views'].'</td><td>'; echo '<a href="' . getForumThreadLink($thread['id']) . '">'.($canEditForum ? $thread['post_topic'] : htmlspecialchars($thread['post_topic'])) . '</a><br /><small>'.($canEditForum ? substr(strip_tags($thread['post_text']), 0, 50) : htmlspecialchars(substr($thread['post_text'], 0, 50))).'...</small></td><td>' . getPlayerLink($thread['name']) . '</td><td>'.(int) $thread['replies'].'</td><td>'.(int) $thread['views'].'</td><td>';
if($thread['last_post'] > 0) { if($thread['last_post'] > 0)
{
$last_post = $db->query("SELECT `players`.`name`, `" . FORUM_TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . FORUM_TABLE_PREFIX . "forum` WHERE `" . FORUM_TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['id']." AND `players`.`id` = `" . FORUM_TABLE_PREFIX . "forum`.`author_guid` ORDER BY `post_date` DESC LIMIT 1")->fetch(); $last_post = $db->query("SELECT `players`.`name`, `" . FORUM_TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . FORUM_TABLE_PREFIX . "forum` WHERE `" . FORUM_TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['id']." AND `players`.`id` = `" . FORUM_TABLE_PREFIX . "forum`.`author_guid` ORDER BY `post_date` DESC LIMIT 1")->fetch();
if(isset($last_post['name'])) if(isset($last_post['name']))
echo date('d.m.y H:i:s', $last_post['post_date']).'<br />by ' . getPlayerLink($last_post['name']); echo date('d.m.y H:i:s', $last_post['post_date']).'<br />by ' . getPlayerLink($last_post['name']);
else else
echo 'No posts.'; echo 'No posts.';
} }
else { else
echo date('d.m.y H:i:s', $thread['post_date']) . '<br />by ' . getPlayerLink($thread['name']); echo date('d.m.y H:i:s', $thread['post_date']).'<br />by ' . getPlayerLink($thread['name']);
}
echo '</td></tr>'; echo '</td></tr>';
} }
echo '</table>'; echo '</table>';
if(!$sections[$section_id]['closed'] || Forum::isModerator()) { if(!$sections[$section_id]['closed'] || Forum::isModerator())
echo '<br /><a href="?subtopic=forum&action=new_thread&section_id=' . $section_id . '"><img src="images/forum/topic.gif" border="0" /></a>'; echo '<br /><a href="?subtopic=forum&action=new_thread&section_id='.$section_id.'"><img src="images/forum/topic.gif" border="0" /></a>';
}
} }
else { else
echo '<h3>No threads in this board.</h3>'; echo '<h3>No threads in this board.</h3>';
}

View File

@@ -10,10 +10,7 @@
*/ */
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
$ret = require __DIR__ . '/base.php'; require __DIR__ . '/base.php';
if ($ret === false) {
return;
}
$links_to_pages = ''; $links_to_pages = '';
$thread_id = (int) $_REQUEST['id']; $thread_id = (int) $_REQUEST['id'];
@@ -33,22 +30,22 @@ 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(); $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'] / setting('core.forum_threads_per_page'); $i++) { for($i = 0; $i < $posts_count['posts_count'] / $config['forum_threads_per_page']; $i++)
{
if($i != $_page) if($i != $_page)
$links_to_pages .= '<a href="' . getForumThreadLink($thread_id, $i) . '">'.($i + 1).'</a> '; $links_to_pages .= '<a href="' . getForumThreadLink($thread_id, $i) . '">'.($i + 1).'</a> ';
else else
$links_to_pages .= '<b>'.($i + 1).' </b>'; $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` = ".(int) $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'])) { if(isset($posts[0]['player_id'])) {
$db->query("UPDATE `" . FORUM_TABLE_PREFIX . "forum` SET `views`=`views`+1 WHERE `id` = ".(int) $thread_id); $db->query("UPDATE `" . FORUM_TABLE_PREFIX . "forum` SET `views`=`views`+1 WHERE `id` = ".(int) $thread_id);
} }
$lookaddons = $db->hasColumn('players', 'lookaddons'); $lookaddons = $db->hasColumn('players', 'lookaddons');
$groups = new OTS_Groups_List(); $groups = new OTS_Groups_List();
foreach($posts as &$post) { foreach($posts as &$post)
{
$post['player'] = new OTS_Player(); $post['player'] = new OTS_Player();
$player = $post['player']; $player = $post['player'];
$player->load($post['player_id']); $player->load($post['player_id']);

View File

@@ -27,7 +27,7 @@ if(count($guilds_list) > 0)
$description = $guild->getCustomField('description'); $description = $guild->getCustomField('description');
$description_with_lines = str_replace(array("\r\n", "\n", "\r"), '<br />', $description, $count); $description_with_lines = str_replace(array("\r\n", "\n", "\r"), '<br />', $description, $count);
if ($count < $config['guild_description_lines_limit']) if ($count < $config['guild_description_lines_limit'])
$description = nl2br($description); $description = wordwrap(nl2br($description), 60, "<br />", true);
$guildName = $guild->getName(); $guildName = $guild->getName();
$guilds[] = array('name' => $guildName, 'logo' => $guild_logo, 'link' => getGuildLink($guildName, false), 'description' => $description); $guilds[] = array('name' => $guildName, 'logo' => $guild_logo, 'link' => getGuildLink($guildName, false), 'description' => $description);

View File

@@ -86,7 +86,7 @@ if(empty($guild_logo) || !file_exists(GUILD_IMAGES_DIR . $guild_logo))
$description = $guild->getCustomField('description'); $description = $guild->getCustomField('description');
$description_with_lines = str_replace(array("\r\n", "\n", "\r"), '<br />', $description, $count); $description_with_lines = str_replace(array("\r\n", "\n", "\r"), '<br />', $description, $count);
if($count < $config['guild_description_lines_limit']) if($count < $config['guild_description_lines_limit'])
$description = nl2br($description); $description = wordwrap(nl2br($description), 60, "<br />", true);
//$description = $description_with_lines; //$description = $description_with_lines;
$guild_owner = $guild->getOwner(); $guild_owner = $guild->getOwner();

View File

@@ -11,8 +11,8 @@
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
$title = 'Highscores'; $title = 'Highscores';
$settingHighscoresCountryBox = setting('core.highscores_country_box'); $configHighscoresCountryBox = config('highscores_country_box');
if(config('account_country') && $settingHighscoresCountryBox) if(config('account_country') && $configHighscoresCountryBox)
require SYSTEM . 'countries.conf.php'; require SYSTEM . 'countries.conf.php';
$list = $_GET['list'] ?? 'experience'; $list = $_GET['list'] ?? 'experience';
@@ -25,11 +25,11 @@ if(!is_numeric($page) || $page < 1 || $page > PHP_INT_MAX) {
$add_sql = ''; $add_sql = '';
$settingHighscoresVocationBox = setting('core.highscores_vocation_box'); $configHighscoresVocationBox = config('highscores_vocation_box');
$configVocations = config('vocations'); $configVocations = config('vocations');
$configVocationsAmount = config('vocations_amount'); $configVocationsAmount = config('vocations_amount');
if($settingHighscoresVocationBox && $vocation !== 'all') if($configHighscoresVocationBox && $vocation !== 'all')
{ {
foreach($configVocations as $id => $name) { foreach($configVocations as $id => $name) {
if(strtolower($name) == $vocation) { if(strtolower($name) == $vocation) {
@@ -99,12 +99,12 @@ else
break; break;
case 'frags': case 'frags':
if(setting('core.highscores_frags')) if(config('highscores_frags'))
$skill = SKILL_FRAGS; $skill = SKILL_FRAGS;
break; break;
case 'balance': case 'balance':
if(setting('core.highscores_balance')) if(config('highscores_balance'))
$skill = SKILL_BALANCE; $skill = SKILL_BALANCE;
break; break;
} }
@@ -125,9 +125,9 @@ if($db->hasColumn('players', 'deletion'))
$outfit_addons = false; $outfit_addons = false;
$outfit = ''; $outfit = '';
$settingHighscoresOutfit = setting('core.highscores_outfit'); $configHighscoresOutfit = config('highscores_outfit');
if($settingHighscoresOutfit) { if($configHighscoresOutfit) {
$outfit = ', lookbody, lookfeet, lookhead, looklegs, looktype'; $outfit = ', lookbody, lookfeet, lookhead, looklegs, looktype';
if($db->hasColumn('players', 'lookaddons')) { if($db->hasColumn('players', 'lookaddons')) {
$outfit .= ', lookaddons'; $outfit .= ', lookaddons';
@@ -135,7 +135,7 @@ if($settingHighscoresOutfit) {
} }
} }
$configHighscoresPerPage = setting('core.highscores_per_page'); $configHighscoresPerPage = config('highscores_per_page');
$limit = $configHighscoresPerPage + 1; $limit = $configHighscoresPerPage + 1;
$needReCache = true; $needReCache = true;
@@ -164,15 +164,15 @@ if (!isset($highscores) || empty($highscores)) {
POT::SKILL_FISH => 'skill_fishing', 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(', ', 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(); $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();
} else } 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(', ', 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(); $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();
} else if ($skill == SKILL_FRAGS) // frags } else if ($skill == SKILL_FRAGS) // frags
{ {
if ($db->hasTable('player_killers')) { 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' . $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` ' . ' FROM `accounts`, `players`, `player_killers` ' .
' 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' . ' 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' .
' GROUP BY `player_id`' . ' GROUP BY `player_id`' .
' ORDER BY value DESC' . ' ORDER BY value DESC' .
' LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll(); ' LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
@@ -183,9 +183,9 @@ if (!isset($highscores) || empty($highscores)) {
FROM `players` p FROM `players` p
LEFT JOIN `accounts` a ON `a`.`id` = `p`.`account_id` LEFT JOIN `accounts` a ON `a`.`id` = `p`.`account_id`
LEFT JOIN `player_deaths` pd ON `pd`.`killed_by` = `p`.`name` LEFT JOIN `player_deaths` pd ON `pd`.`killed_by` = `p`.`name`
WHERE `p`.id NOT IN (' . implode(', ', setting('core.highscores_ids_hidden')) . ') WHERE `p`.id NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ')
AND `p`.' . $deleted . ' = 0 AND `p`.' . $deleted . ' = 0
AND `p`.group_id < ' . setting('core.highscores_groups_hidden') . ' ' . $add_sql . ' AND `p`.group_id < ' . config('highscores_groups_hidden') . ' ' . $add_sql . '
AND `pd`.`unjustified` = 1 AND `pd`.`unjustified` = 1
GROUP BY `killed_by` GROUP BY `killed_by`
ORDER BY value DESC ORDER BY value DESC
@@ -193,19 +193,19 @@ if (!isset($highscores) || empty($highscores)) {
} }
} else if ($skill == SKILL_BALANCE) // balance } 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(', ', 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(); $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();
} else { } else {
if ($skill == POT::SKILL__MAGLEVEL) { 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(', ', 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(); $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();
} else { // level } 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(', ', 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(); $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();
$list = 'experience'; $list = 'experience';
} }
} }
} }
if ($cache->enabled() && $needReCache) { if ($cache->enabled() && $needReCache) {
$cache->set($cacheKey, serialize($highscores), setting('core.highscores_cache_ttl') * 60); $cache->set($cacheKey, serialize($highscores), config('highscores_cache_ttl') * 60);
} }
$online_exist = false; $online_exist = false;
@@ -227,7 +227,7 @@ if($db->hasTable('players_online') && count($players) > 0) {
$show_link_to_next_page = false; $show_link_to_next_page = false;
$i = 0; $i = 0;
$settingHighscoresVocation = setting('core.highscores_vocation'); $configHighscoresVocation = config('highscores_vocation');
foreach($highscores as $id => &$player) foreach($highscores as $id => &$player)
{ {
@@ -248,7 +248,7 @@ foreach($highscores as $id => &$player)
$player['experience'] = number_format($player['experience']); $player['experience'] = number_format($player['experience']);
} }
if($settingHighscoresVocation) { if($configHighscoresVocation) {
if(isset($player['promotion'])) { if(isset($player['promotion'])) {
if((int)$player['promotion'] > 0) { if((int)$player['promotion'] > 0) {
$player['vocation'] += ($player['promotion'] * $configVocationsAmount); $player['vocation'] += ($player['promotion'] * $configVocationsAmount);
@@ -266,7 +266,7 @@ foreach($highscores as $id => &$player)
$player['link'] = getPlayerLink($player['name'], false); $player['link'] = getPlayerLink($player['name'], false);
$player['flag'] = getFlagImage($player['country']); $player['flag'] = getFlagImage($player['country']);
if($settingHighscoresOutfit) { if($configHighscoresOutfit) {
$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['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; $player['rank'] = $offset + $i;
@@ -302,10 +302,10 @@ $types = array(
'fishing' => 'Fishing', 'fishing' => 'Fishing',
); );
if(setting('core.highscores_frags')) { if(config('highscores_frags')) {
$types['frags'] = 'Frags'; $types['frags'] = 'Frags';
} }
if(setting('core.highscores_balance')) if(config('highscores_balance'))
$types['balance'] = 'Balance'; $types['balance'] = 'Balance';
/** @var Twig\Environment $twig */ /** @var Twig\Environment $twig */

View File

@@ -23,7 +23,7 @@ if(!$groups->count())
$outfit_addons = false; $outfit_addons = false;
$outfit = ''; $outfit = '';
if(setting('core.team_outfit')) { if($config['team_display_outfit']) {
$outfit = ', lookbody, lookfeet, lookhead, looklegs, looktype'; $outfit = ', lookbody, lookfeet, lookhead, looklegs, looktype';
if($db->hasColumn('players', 'lookaddons')) { if($db->hasColumn('players', 'lookaddons')) {
$outfit .= ', lookaddons'; $outfit .= ', lookaddons';
@@ -56,12 +56,12 @@ foreach($groupList as $id => $group)
$members[] = array( $members[] = array(
'group_name' => $group->getName(), 'group_name' => $group->getName(),
'player' => $member, 'player' => $member,
'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, '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' => setting('core.team_status') ? $member->isOnline() : null, 'status' => $config['team_display_status'] ? $member->isOnline() : null,
'link' => getPlayerLink($member->getName()), 'link' => getPlayerLink($member->getName()),
'flag_image' => setting('core.account_country') ? getFlagImage($member->getAccount()->getCountry()) : null, 'flag_image' => $config['account_country'] ? getFlagImage($member->getAccount()->getCountry()) : null,
'world_name' => (setting('core.multiworld') || setting('core.team_world')) ? getWorldName($member->getWorldId()) : null, 'world_name' => ($config['multiworld'] || $config['team_display_world']) ? getWorldName($member->getWorldId()) : null,
'last_login' => setting('core.team_lastlogin') ? $lastLogin : null 'last_login' => $config['team_display_lastlogin'] ? $lastLogin : null
); );
} }

View File

@@ -206,6 +206,7 @@ else {
$_REQUEST = array_merge($_REQUEST, $vars); $_REQUEST = array_merge($_REQUEST, $vars);
$_GET = array_merge($_GET, $vars); $_GET = array_merge($_GET, $vars);
extract($vars);
if (strpos($path, '__database__/') !== false) { if (strpos($path, '__database__/') !== false) {
$pageName = str_replace('__database__/', '', $path); $pageName = str_replace('__database__/', '', $path);

View File

@@ -34,7 +34,7 @@ return [
['GET', 'changelog[/{page:int}]', 'changelog.php'], ['GET', 'changelog[/{page:int}]', 'changelog.php'],
[['GET', 'POST'], 'creatures[/{name:string}]', 'creatures.php'], [['GET', 'POST'], 'creatures[/{name:string}]', 'creatures.php'],
['GET', 'faq[/{action:string}]', 'faq.php'], [['GET', 'POST'], 'faq[/{action:string}]', 'faq.php'],
[['GET', 'POST'], 'forum/{action:string}[/]', 'forum.php'], [['GET', 'POST'], 'forum/{action:string}[/]', 'forum.php'],
['GET', 'forum/board/{id:int}[/]', 'forum/show_board.php'], ['GET', 'forum/board/{id:int}[/]', 'forum/show_board.php'],

File diff suppressed because it is too large Load Diff

View File

@@ -17,7 +17,7 @@ $status['lastCheck'] = 0;
$status['uptime'] = '0h 0m'; $status['uptime'] = '0h 0m';
$status['monsters'] = 0; $status['monsters'] = 0;
if(setting('core.status_enabled') === false) { if(config('status_enabled') === false) {
return; return;
} }
@@ -37,10 +37,9 @@ else if(isset($config['lua']['status_port'])) {
} }
// ip check // ip check
$settingIP = setting('core.status_ip'); if(isset($config['status_ip'][0]))
if(isset($settingIP[0]))
{ {
$status_ip = $settingIP; $status_ip = $config['status_ip'];
} }
elseif(!isset($status_ip[0])) // try localhost if no ip specified elseif(!isset($status_ip[0])) // try localhost if no ip specified
{ {
@@ -49,11 +48,10 @@ elseif(!isset($status_ip[0])) // try localhost if no ip specified
// port check // port check
$status_port = $config['lua']['statusPort']; $status_port = $config['lua']['statusPort'];
$settingPort = setting('core.status_port'); if(isset($config['status_port'][0])) {
if(isset($settingPort[0])) { $status_port = $config['status_port'];
$status_port = $settingPort;
} }
elseif(!isset($status_port[0])) // try 7171 if no port specified elseif(!isset($status_port[0])) // try 7171 if no ip specified
{ {
$status_port = 7171; $status_port = 7171;
} }
@@ -96,9 +94,9 @@ if(isset($config['lua']['statustimeout']))
// get status timeout from server config // get status timeout from server config
$status_timeout = eval('return ' . $config['lua']['statusTimeout'] . ';') / 1000 + 1; $status_timeout = eval('return ' . $config['lua']['statusTimeout'] . ';') / 1000 + 1;
$status_interval = setting('core.status_interval'); $status_interval = @$config['status_interval'];
if($status_interval && $status_timeout < $status_interval) { if($status_interval && $status_timeout < $config['status_interval']) {
$status_timeout = $status_interval; $status_timeout = $config['status_interval'];
} }
if($status['lastCheck'] + $status_timeout < time()) { if($status['lastCheck'] + $status_timeout < time()) {

View File

@@ -10,8 +10,8 @@
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
// template // template
$template_name = setting('core.template'); $template_name = $config['template'];
if(setting('core.template_allow_change')) if($config['template_allow_change'])
{ {
if(isset($_GET['template'])) if(isset($_GET['template']))
{ {
@@ -111,13 +111,12 @@ $template['link_screenshots'] = getLink('gallery');
$template['link_movies'] = getLink('videos'); $template['link_movies'] = getLink('videos');
$template['link_gifts_history'] = getLink('gifts', 'history'); $template['link_gifts_history'] = getLink('gifts', 'history');
$forumSetting = setting('core.forum'); if($config['forum'] != '')
if($forumSetting != '')
{ {
if(strtolower($forumSetting) == 'site') if(strtolower($config['forum']) == 'site')
$template['link_forum'] = "<a href='" . getLink('forum') . "'>"; $template['link_forum'] = "<a href='" . getLink('forum') . "'>";
else else
$template['link_forum'] = "<a href='" . $forumSetting . "' target='_blank'>"; $template['link_forum'] = "<a href='" . $config['forum'] . "' target='_blank'>";
} }
$twig->addGlobal('template_path', $template_path); $twig->addGlobal('template_path', $template_path);

View File

@@ -1,5 +1,5 @@
To change a name of character select player and choose a new name.<br/> To change a name of character select player and choose a new name.<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/> <span style="color: red">Change name cost {{ config.account_change_character_name_points }} premium points. You have {{ points }} premium points.</span><br/><br/>
<form action="{{ getLink('account/character/name') }}" method="post"> <form action="{{ getLink('account/character/name') }}" method="post">
<input type="hidden" name="changenamesave" value="1"> <input type="hidden" name="changenamesave" value="1">
<div class="TableContainer"> <div class="TableContainer">

View File

@@ -1,5 +1,5 @@
To change a sex of character select player and choose a new sex.<br/> To change a sex of character select player and choose a new sex.<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/> <span style="color: red">Change sex cost {{ config.account_change_character_sex_points }} premium points. You have {{ points }} premium points.</span><br/><br/>
<form action="{{ getLink('account/character/sex') }}" method="post"> <form action="{{ getLink('account/character/sex') }}" method="post">
<input type="hidden" name="changesexsave" value="1"/> <input type="hidden" name="changesexsave" value="1"/>
<div class="TableContainer"> <div class="TableContainer">

View File

@@ -59,7 +59,7 @@
<td></td><td><span id="email_error" class="FormFieldError">{% if errors.email is defined %}{{ errors.email }}{% endif %}</span></td> <td></td><td><span id="email_error" class="FormFieldError">{% if errors.email is defined %}{{ errors.email }}{% endif %}</span></td>
</tr> </tr>
{% if setting('core.mail_enabled') and config.account_mail_verify %} {% if config.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> <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 %} {% endif %}
@@ -122,7 +122,7 @@
{{ hook('HOOK_ACCOUNT_CREATE_BETWEEN_BOXES_1') }} {{ hook('HOOK_ACCOUNT_CREATE_BETWEEN_BOXES_1') }}
{% if (not setting('core.mail_enabled') or not config.account_mail_verify) and config.account_create_character_create %} {% if (not config.mail_enabled or not config.account_mail_verify) and config.account_create_character_create %}
<tr> <tr>
<td> <td>
<div class="TableShadowContainerRightTop"> <div class="TableShadowContainerRightTop">
@@ -140,7 +140,7 @@
<span{% if errors.name is defined %} class="red"{% endif %}>Character Name:</span> <span{% if errors.name is defined %} class="red"{% endif %}>Character Name:</span>
</td> </td>
<td> <td>
<input id="character_name" name="name" size="{{ setting('core.create_character_name_max_length') }}" maxlength="{{ setting('core.create_character_name_max_length') }}" value="{{ name }}"/> <input id="character_name" name="name" size="{{ config.character_name_max_length }}" maxlength="{{ config.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;" /> <img id="character_indicator" src="images/global/general/{% if not save or errors.name is defined %}n{% endif %}ok.gif" style="display: none;" />
<br> <br>
</td> </td>

View File

@@ -45,7 +45,7 @@ In any case the name must not violate the naming conventions stated in the <a hr
</tr> </tr>
<tr class="Odd"> <tr class="Odd">
<td> <td>
<input name="name" id="character_name" value="{{ name }}" size="{{ setting('core.create_character_name_max_length') }}" maxlength="{{ setting('core.create_character_name_max_length') }}" > <input name="name" id="character_name" value="{{ name }}" size="{{ config.character_name_max_length }}" maxlength="{{ config.character_name_max_length }}" >
<img id="character_indicator" src="images/global/general/{% if not save or errors.name is defined %}n{% endif %}ok.gif" /> <img id="character_indicator" src="images/global/general/{% if not save or errors.name is defined %}n{% endif %}ok.gif" />
<br/> <br/>
<span style="font-size: 10px"> <span style="font-size: 10px">

View File

@@ -1,5 +1,5 @@
To generate new recovery key for your account please enter your password.<br/> To generate new recovery key for your account please enter your password.<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/> <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/>
<form action="{{ getLink('account/register/new') }}" method="post"> <form action="{{ getLink('account/register/new') }}" method="post">
<input type="hidden" name="registeraccountsave" value="1"> <input type="hidden" name="registeraccountsave" value="1">
<div class="TableContainer" > <div class="TableContainer" >

View File

@@ -39,10 +39,10 @@
{% for name, link in menus %} {% for name, link in menus %}
<a href="{{ getLink(link) }}">{{ name }}</a> <a href="{{ getLink(link) }}">{{ name }}</a>
{% endfor %} {% endfor %}
{% if setting('core.account_change_character_name') %} {% if config.account_change_character_name %}
<a href="{{ getLink('account/character/name') }}">Change Name</a> <a href="{{ getLink('account/character/name') }}">Change Name</a>
{% endif %} {% endif %}
{% if setting('core.account_change_character_sex') %} {% if config.account_change_character_sex %}
<a href="{{ getLink('account/character/sex') }}">Change Sex</a> <a href="{{ getLink('account/character/sex') }}">Change Sex</a>
{% endif %} {% endif %}
<a href="{{ getLink('account/logout') }}">Logout</a> <a href="{{ getLink('account/logout') }}">Logout</a>
@@ -192,7 +192,7 @@
{% include('buttons.base.html.twig') %} {% include('buttons.base.html.twig') %}
</form> </form>
</td> </td>
{% if setting('core.account_change_character_name') %} {% if config.account_change_character_name %}
<td> <td>
<form action="{{ getLink('account/character/name') }}" method="post" > <form action="{{ getLink('account/character/name') }}" method="post" >
{% set button_name = 'Change Name' %} {% set button_name = 'Change Name' %}
@@ -200,7 +200,7 @@
</form> </form>
</td> </td>
{% endif %} {% endif %}
{% if setting('core.account_change_character_sex') %} {% if config.account_change_character_sex %}
<td> <td>
<form action="{{ getLink('account/character/sex') }}" method="post" > <form action="{{ getLink('account/character/sex') }}" method="post" >
{% set button_name = 'Change Sex' %} {% set button_name = 'Change Sex' %}

View File

@@ -1,105 +0,0 @@
<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>

View File

@@ -142,7 +142,7 @@
{% set rows = rows + 1 %} {% set rows = rows + 1 %}
<tr bgcolor="{{ getStyle(rows) }}"> <tr bgcolor="{{ getStyle(rows) }}">
<td valign="top">Comment:</td> <td valign="top">Comment:</td>
<td style="word-break: break-all">{{ comment|raw }}</td> <td>{{ comment|raw }}</td>
</tr> </tr>
{% endif %} {% endif %}
@@ -284,7 +284,7 @@
{{ hook(constant('HOOK_CHARACTERS_BEFORE_SIGNATURE')) }} {{ hook(constant('HOOK_CHARACTERS_BEFORE_SIGNATURE')) }}
{% if setting('core.signature_enabled') %} {% if config.signature_enabled %}
<!-- SIGNATURE --> <!-- SIGNATURE -->
<script type="text/javascript"> <script type="text/javascript">
function showSignLinks() function showSignLinks()

View File

@@ -155,7 +155,7 @@
{% if (item.count > 1) %} {% if (item.count > 1) %}
<span class="loot_amount">{{ item.count }}</span> <span class="loot_amount">{{ item.count }}</span>
{% endif %} {% endif %}
<a href="{{ config.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> <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>
</span> </span>
{% endfor %} {% endfor %}
</td> </td>

View File

@@ -57,7 +57,7 @@
} }
</style> </style>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="tools/js/html5shiv.min.js"></script> <script src="tools/js/html5shiv.js"></script>
<![endif]--> <![endif]-->
</head> </head>
<body> <body>

View File

@@ -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> <td class="white" colspan="5"><b>Experience Table</b></td>
</tr> </tr>
<tr> <tr>
{% for i in 0..setting('core.experience_table_columns')-1 %} {% for i in 0..config.experiencetable_columns-1 %}
<td> <td>
<table border="0" cellpadding="2" cellspacing="1" width="100%"> <table border="0" cellpadding="2" cellspacing="1" width="100%">
<tr bgcolor="{{ config.lightborder }}"> <tr bgcolor="{{ config.lightborder }}">
<td><b>Level</b></td> <td><b>Level</b></td>
<td><b>Experience</b></td> <td><b>Experience</b></td>
</tr> </tr>
{% for level in i * setting('core.experience_table_rows') + 1..i * setting('core.experience_table_rows') + (setting('core.experience_table_rows') + 1) - 1 %} {% for level in i * config.experiencetable_rows + 1..i * config.experiencetable_rows + (config.experiencetable_rows + 1) - 1 %}
<tr bgcolor="{{ config.lightborder }}"> <tr bgcolor="{{ config.lightborder }}">
<td>{{ level }}</td> <td>{{ level }}</td>
<td>{{ experience[level] }}</td> <td>{{ experience[level] }}</td>

View File

@@ -4,6 +4,6 @@
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) 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'); })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', '{{ setting('core.google_analytics_id') }}', 'auto'); ga('create', '{{ config.google_analytics_id }}', 'auto');
ga('send', 'pageview'); ga('send', 'pageview');
</script> </script>

View File

@@ -44,7 +44,7 @@
<img src="{{ constant('GUILD_IMAGES_DIR') }}{{ guild.logo }}" width="64" height="64"> <img src="{{ constant('GUILD_IMAGES_DIR') }}{{ guild.logo }}" width="64" height="64">
</td> </td>
<td style="word-break: break-all"> <td>
<span{% if guild.description is not empty %} valign="top"{% endif %}> <span{% if guild.description is not empty %} valign="top"{% endif %}>
<b>{{ guild.name }}</b>{% if isAdmin %}<a href="?subtopic=guilds&action=delete_by_admin&guild={{ guild.name }}"> - Delete this guild (for ADMIN only!)</a>{% endif %} <b>{{ guild.name }}</b>{% if isAdmin %}<a href="?subtopic=guilds&action=delete_by_admin&guild={{ guild.name }}"> - Delete this guild (for ADMIN only!)</a>{% endif %}
</span> </span>

View File

@@ -1,7 +1,6 @@
<div class="Border_2"> <div class="Border_2">
<div class="Border_3"> <div class="Border_3">
<div class="BoxContent"> <div class="BoxContent">
{{ hook('HOOK_GUILDS_BEFORE_GUILD_HEADER') }}
<table border="0" width="100%"> <table border="0" width="100%">
<tbody> <tbody>
<tr> <tr>
@@ -17,9 +16,7 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<br/> <br>
{{ hook('HOOK_GUILDS_AFTER_GUILD_HEADER') }}
<table width="100%"> <table width="100%">
<tbody> <tbody>
@@ -50,7 +47,7 @@
<table style="width:100%;"> <table style="width:100%;">
<tbody> <tbody>
<tr> <tr>
<td style="word-break: break-all"> <td>
<div id="GuildInformationContainer"> <div id="GuildInformationContainer">
{% if description is not empty %} {% if description is not empty %}
{{ description|raw }} {{ description|raw }}
@@ -86,10 +83,8 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<br/>
{{ hook('HOOK_GUILDS_AFTER_GUILD_INFORMATION') }}
<br>
<div class="TableContainer"> <div class="TableContainer">
<div class="TableContainer"> <div class="TableContainer">
<div class="CaptionContainer"> <div class="CaptionContainer">
@@ -198,9 +193,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<br/> <br>
{{ hook('HOOK_GUILDS_AFTER_GUILD_MEMBERS') }}
<div class="TableContainer"> <div class="TableContainer">
<div class="CaptionContainer"> <div class="CaptionContainer">
@@ -270,9 +263,9 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<br/> <br>
{{ hook('HOOK_GUILDS_AFTER_INVITED_CHARACTERS', { 'guild': guild, 'isLeader': isLeader }) }} {{ hook(constant('HOOK_GUILDS_AFTER_INVITED_CHARACTERS'), { 'guild': guild, 'isLeader': isLeader }) }}
<div class="TableContainer"> <div class="TableContainer">
<table class="Table3" cellpadding="0" cellspacing="0"> <table class="Table3" cellpadding="0" cellspacing="0">

View File

@@ -9,7 +9,7 @@
<form action="{{ constant('BASE_URL') }}install/" method="post" autocomplete="off"> <form action="{{ constant('BASE_URL') }}install/" method="post" autocomplete="off">
<input type="hidden" name="step" id="step" value="database" /> <input type="hidden" name="step" id="step" value="database" />
{% for value in ['server_path'] %} {% for value in ['server_path', 'mail_admin'] %}
<div class="form-group mb-2"> <div class="form-group mb-2">
<label for="vars_{{ value }}">{{ locale['step_config_' ~ value] }}</label> <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 %}/> <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 %}/>

View File

@@ -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/> <br/><br/>
The new password is: <b>{{ new_password }}</b> The new password is: <b>{{ new_password }}</b>
<br/><br/> <br/><br/>
If this was you, please ignore this email. If it was not you, please contact our support department. If this was you, please ignore this email. If it was not you, please contact our support department at {{ config.mail_admin }}.

View File

@@ -25,7 +25,7 @@
<b>Group</b> <b>Group</b>
</td> </td>
{% if setting('core.team_outfit') %} {% if config.team_display_outfit %}
<td width="5%" class="white"> <td width="5%" class="white">
<b>Outfit</b> <b>Outfit</b>
</td> </td>
@@ -35,19 +35,19 @@
<b>Name</b> <b>Name</b>
</td> </td>
{% if setting('core.team_status') %} {% if config.team_display_status %}
<td class="white"> <td class="white">
<b>Status</b> <b>Status</b>
</td> </td>
{% endif %} {% endif %}
{% if (setting('core.multiworld') or setting('core.team_world')) %} {% if (config.multiworld or config.team_display_world) %}
<td class="white"> <td class="white">
<b>World</b> <b>World</b>
</td> </td>
{% endif %} {% endif %}
{% if setting('core.team_lastlogin') %} {% if config.team_display_lastlogin %}
<td class="white"> <td class="white">
<b>Last login</b> <b>Last login</b>
</td> </td>
@@ -61,7 +61,7 @@
<tr bgcolor="{{ getStyle(i) }}" style="height: 32px;"> <tr bgcolor="{{ getStyle(i) }}" style="height: 32px;">
<td>{{ group.group_name|capitalize }}</td> <td>{{ group.group_name|capitalize }}</td>
{% if setting('core.team_outfit') %} {% if config.team_display_outfit %}
<td> <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"/> <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> </td>
@@ -74,7 +74,7 @@
{{ member.link|raw }} {{ member.link|raw }}
</td> </td>
{% if setting('core.team_status') %} {% if config.team_display_status %}
<td> <td>
{% if member.status %} {% if member.status %}
<span style="color: green"><b>Online</b></span> <span style="color: green"><b>Online</b></span>
@@ -84,13 +84,13 @@
</td> </td>
{% endif %} {% endif %}
{% if (setting('core.multiworld') or setting('core.team_world')) %} {% if (config.multiworld or config.team_display_world) %}
<td> <td>
<span><b>{{ member.world_name }}</b></span> <span><b>{{ member.world_name }}</b></span>
</td> </td>
{% endif %} {% endif %}
{% if setting('core.team_lastlogin') %} {% if config.team_display_lastlogin %}
<td> <td>
<span>{{ member.last_login }}</span> <span>{{ member.last_login }}</span>
</td> </td>
@@ -107,7 +107,7 @@
<table cellspacing="1" cellpadding="4" border="0" width="100%"> <table cellspacing="1" cellpadding="4" border="0" width="100%">
<tr bgcolor="{{ config.vdarkborder }}"> <tr bgcolor="{{ config.vdarkborder }}">
{% if setting('core.team_outfit') %} {% if config.team_display_outfit %}
<td width="5%" class="white"> <td width="5%" class="white">
<b>Outfit</b> <b>Outfit</b>
</td> </td>
@@ -117,19 +117,19 @@
<b>Name</b> <b>Name</b>
</td> </td>
{% if setting('core.team_status') %} {% if config.team_display_status %}
<td class="white"> <td class="white">
<b>Status</b> <b>Status</b>
</td> </td>
{% endif %} {% endif %}
{% if (setting('core.multiworld') or setting('core.team_world')) %} {% if (config.multiworld or config.team_display_world) %}
<td class="white"> <td class="white">
<b>World</b> <b>World</b>
</td> </td>
{% endif %} {% endif %}
{% if setting('core.team_lastlogin') %} {% if config.team_display_lastlogin %}
<td class="white"> <td class="white">
<b>Last login</b> <b>Last login</b>
</td> </td>
@@ -139,7 +139,7 @@
{% for member in group.members %} {% for member in group.members %}
{% set i = i + 1 %} {% set i = i + 1 %}
<tr bgcolor="{{ getStyle(i) }}" style="height: 32px;"> <tr bgcolor="{{ getStyle(i) }}" style="height: 32px;">
{% if setting('core.team_outfit') %} {% if config.team_display_outfit %}
<td> <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"/> <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> </td>
@@ -152,7 +152,7 @@
{{ member.link|raw }} {{ member.link|raw }}
</td> </td>
{% if setting('core.team_status') %} {% if config.team_display_status %}
<td> <td>
{% if member.status %} {% if member.status %}
<span style="color: green"><b>Online</b></span> <span style="color: green"><b>Online</b></span>
@@ -162,13 +162,13 @@
</td> </td>
{% endif %} {% endif %}
{% if (setting('core.multiworld') or setting('core.team_world')) %} {% if (config.multiworld or config.team_display_world) %}
<td> <td>
<span><b>{{ member.world_name }}</b></span> <span><b>{{ member.world_name }}</b></span>
</td> </td>
{% endif %} {% endif %}
{% if setting('core.team_lastlogin') %} {% if config.team_display_lastlogin %}
<td> <td>
<span>{{ member.last_login }}</span> <span>{{ member.last_login }}</span>
</td> </td>

View File

@@ -30,7 +30,7 @@ if($dev_mode) {
} }
unset($dev_mode); unset($dev_mode);
$filter = new Twig_SimpleFilter('timeago', function ($datetime) { $filter = new TwigFilter('timeago', function ($datetime) {
$time = time() - strtotime($datetime); $time = time() - strtotime($datetime);
@@ -107,11 +107,6 @@ $function = new TwigFunction('config', function ($key) {
}); });
$twig->addFunction($function); $twig->addFunction($function);
$function = new TwigFunction('setting', function ($key) {
return setting($key);
});
$twig->addFunction($function);
$function = new TwigFunction('getCustomPage', function ($name) { $function = new TwigFunction('getCustomPage', function ($name) {
$success = false; $success = false;
return getCustomPage($name, $success); return getCustomPage($name, $success);

View File

@@ -470,7 +470,7 @@
</form> </form>
</table> </table>
</td> </td>
{% if setting('core.account_change_character_name') %} {% if config.account_change_character_name %}
<td> <td>
<table border="0" cellspacing="0" cellpadding="0" > <table border="0" cellspacing="0" cellpadding="0" >
<form action="{{ getLink('account/character/name') }}" method="post" > <form action="{{ getLink('account/character/name') }}" method="post" >
@@ -483,7 +483,7 @@
</table> </table>
</td> </td>
{% endif %} {% endif %}
{% if setting('core.account_change_character_sex') %} {% if config.account_change_character_sex %}
<td> <td>
<table border="0" cellspacing="0" cellpadding="0" > <table border="0" cellspacing="0" cellpadding="0" >
<form action="{{ getLink('account/character/sex') }}" method="post" > <form action="{{ getLink('account/character/sex') }}" method="post" >

View File

@@ -289,7 +289,7 @@ if(isset($config['boxes']))
<img id="TibiaLogoArtworkTop" src="<?php echo $template_path; ?>/images/header/<?php echo $config['logo_image']; ?>" onClick="window.location = '<?php echo getLink('news')?>';" alt="logoartwork" /> <img id="TibiaLogoArtworkTop" src="<?php echo $template_path; ?>/images/header/<?php echo $config['logo_image']; ?>" onClick="window.location = '<?php echo getLink('news')?>';" alt="logoartwork" />
<img id="TibiaLogoArtworkBottom" src="<?php echo $template_path; ?>/images/header/tibia-logo-artwork-bottom.gif" alt="logoartwork" /> <img id="TibiaLogoArtworkBottom" src="<?php echo $template_path; ?>/images/header/tibia-logo-artwork-bottom.gif" alt="logoartwork" />
<img id="Statue_2" src="<?php echo $template_path; ?>/images/header/animated-statue.gif" alt="logoartwork" /> <img id="Statue_2" src="<?php echo $template_path; ?>/images/header/animated-statue.gif" alt="logoartwork" />
<img id="LogoLink" src="<?php echo $template_path; ?>/images/header/tibia-logo-artwork-string.gif" onClick="window.location = 'mailto:<?php echo setting('core.mail_address'); ?>';" alt="logoartwork" /> <img id="LogoLink" src="<?php echo $template_path; ?>/images/header/tibia-logo-artwork-string.gif" onClick="window.location = 'mailto:<?php echo $config['mail_address']; ?>';" alt="logoartwork" />
</div> </div>
<div id="Loginbox" > <div id="Loginbox" >

View File

@@ -1,15 +0,0 @@
/**
* Minified by jsDelivr using clean-css v5.3.0.
* Original file: /npm/toastify-js@1.12.0/src/toastify.css
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
/*!
* Toastify js 1.12.0
* https://github.com/apvarun/toastify-js
* @license MIT licensed
*
* Copyright (C) 2018 Varun A P
*/
.toastify{padding:12px 20px;color:#fff;display:inline-block;box-shadow:0 3px 6px -1px rgba(0,0,0,.12),0 10px 36px -4px rgba(77,96,232,.3);background:-webkit-linear-gradient(315deg,#73a5ff,#5477f5);background:linear-gradient(135deg,#73a5ff,#5477f5);position:fixed;opacity:0;transition:all .4s cubic-bezier(.215, .61, .355, 1);border-radius:2px;cursor:pointer;text-decoration:none;max-width:calc(50% - 20px);z-index:2147483647}.toastify.on{opacity:1}.toast-close{background:0 0;border:0;color:#fff;cursor:pointer;font-family:inherit;font-size:1em;opacity:.4;padding:0 5px}.toastify-right{right:15px}.toastify-left{left:15px}.toastify-top{top:-150px}.toastify-bottom{bottom:-150px}.toastify-rounded{border-radius:25px}.toastify-avatar{width:1.5em;height:1.5em;margin:-7px 5px;border-radius:2px}.toastify-center{margin-left:auto;margin-right:auto;left:0;right:0;max-width:fit-content;max-width:-moz-fit-content}@media only screen and (max-width:360px){.toastify-left,.toastify-right{margin-left:auto;margin-right:auto;left:0;right:0;max-width:fit-content}}
/*# sourceMappingURL=/sm/cb4335d1b03e933ed85cb59fffa60cf51f07567ed09831438c60f59afd166464.map */

File diff suppressed because one or more lines are too long

View File

@@ -21,14 +21,12 @@
define('SIGNATURES_IMAGES', SIGNATURES . 'images/'); define('SIGNATURES_IMAGES', SIGNATURES . 'images/');
define('SIGNATURES_ITEMS', BASE . 'images/items/'); define('SIGNATURES_ITEMS', BASE . 'images/items/');
if(!setting('core.signature_enabled')) { if(!$config['signature_enabled'])
die('Signatures are disabled on this server.'); die('Signatures are disabled on this server.');
}
$file = trim(strtolower(setting('core.signature_type'))) . '.php'; $file = trim(strtolower($config['signature_type'])) . '.php';
if(!file_exists($file)) { if(!file_exists($file))
die('ERROR: Wrong signature_type in Settings.'); die('ERROR: Wrong signature_type in config.');
}
putenv('GDFONTPATH=' . SIGNATURES_FONTS); putenv('GDFONTPATH=' . SIGNATURES_FONTS);
@@ -54,7 +52,7 @@
} }
$cached = SIGNATURES_CACHE.$player->getId() . '.png'; $cached = SIGNATURES_CACHE.$player->getId() . '.png';
if(file_exists($cached) && (time() < (filemtime($cached) + (60 * setting('core.signature_cache_time'))))) if(file_exists($cached) && (time() < (filemtime($cached) + (60 * $config['signature_cache_time']))))
{ {
header( 'Content-type: image/png' ); header( 'Content-type: image/png' );
readfile( SIGNATURES_CACHE.$player->getId().'.png' ); readfile( SIGNATURES_CACHE.$player->getId().'.png' );
@@ -63,7 +61,7 @@
require $file; require $file;
header('Content-type: image/png'); header('Content-type: image/png');
$seconds_to_cache = setting('core.signature_browser_cache') * 60; $seconds_to_cache = $config['signature_browser_cache'] * 60;
$ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT"; $ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
header('Expires: ' . $ts); header('Expires: ' . $ts);
header('Pragma: cache'); header('Pragma: cache');