Compare commits

...

29 Commits

Author SHA1 Message Date
slawkens
925cbfbc95 Merge branch 'main' into develop 2026-04-24 22:18:01 +02:00
slawkens
81b8bd8a2c News: Do not cache if logged as admin, so it shows the admin buttons 2026-04-24 22:12:53 +02:00
slawkens
def432d4b7 tibiacom theme: Fix if gallery table not exist (develop branch) 2026-04-24 22:09:14 +02:00
slawkens
b0edbb79d9 Update characters.php 2026-04-24 21:58:42 +02:00
Gabriel Pedro
04d630d765 feat: debugbar backtrace (#360)
* feat: debugbar backtrace

* chore(copilot): cleanup stmt reference

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: ignoring debug namespace

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-24 21:47:07 +02:00
slawkens
7851e337eb Merge branch 'main' into develop 2026-04-24 21:44:38 +02:00
slawkens
ba1ee4bdb7 Nothing important [skip ci] 2026-04-24 21:22:27 +02:00
slawkens
e61c40d6b3 Merge branch 'main' into develop 2026-04-24 20:37:11 +02:00
slawkens
54bdea85a3 Fix phpstan 2026-04-24 20:36:56 +02:00
slawkens
48284e426f Merge branch 'main' into develop 2026-04-24 16:40:08 +02:00
slawkens
ac9a328206 Highscores: Prevent mass queries amount caused by getPlayerLink 2026-04-24 16:39:55 +02:00
slawkens
0635108d4c Merge branch 'main' into develop 2026-04-24 16:33:07 +02:00
slawkens
47ec36a176 Merge branch 'main' into develop 2026-04-24 16:33:01 +02:00
slawkens
e4a947cabb tibiacom: Reduce queries count from highscores box 2026-04-24 16:32:53 +02:00
slawkens
609cf152af Plugins: Fix uninstall when hook is without HOOK_ prefix 2026-04-24 16:24:06 +02:00
slawkens
c16f95f8d2 Merge branch 'main' into develop 2026-04-17 17:30:53 +02:00
slawkens
ec7079dd57 Bye JetBrains, it was not my decision :( 2026-04-14 19:58:12 +02:00
slawkens
9e0e2601d2 Add indexes to myaac_account_actions table 2026-04-12 14:13:13 +02:00
slawkens
e7198aeb23 Update CHANGELOG-2.x.md 2026-04-12 13:42:25 +02:00
slawkens
1fa3630f86 Update CHANGELOG-2.x.md 2026-04-12 13:33:16 +02:00
slawkens
e274b83504 Fix: Reset settings by plugin name, not the settings key name 2026-04-12 13:20:48 +02:00
slawkens
a467a540b1 Add constant DEFAULT_PRIORITY 2026-04-12 13:14:10 +02:00
slawkens
08507e2940 Plugins: type hints 2026-04-12 13:10:44 +02:00
slawkens
f1aa128408 Feat: plugins autoload init-priority option 2026-04-12 13:10:15 +02:00
slawkens
7104c2258f Settings: Add Reset button 2026-04-12 10:43:09 +02:00
slawkens
f51211d47a Merge branch 'main' into develop 2026-04-12 09:56:10 +02:00
slawkens
fa93187f80 Add $fillable to Account model 2026-04-12 09:56:01 +02:00
slawkens
2c62a97160 Make myaac_config table columns bigger 2026-04-12 08:53:02 +02:00
slawkens
7bc8a66cc1 BugTracker has been moved to plugins, remove the model 2026-04-11 18:13:25 +02:00
22 changed files with 209 additions and 68 deletions

View File

@@ -1,9 +1,12 @@
## [2.0-dev - x.x.2025] ## [2.0-dev - x.x.2025]
### Added ### Added
* Add an "access" option to Menus (#340) * Menus: Add an "access" option to Menus (#340)
* Possibility to hide menus for unauthorized users * Possibility to hide menus for unauthorized users
* Add the possibility to fetch skills, balance and frags in the getTopPlayers function (#347) * Settings: Add Reset button (https://github.com/slawkens/myaac/commit/7104c2258fd724a55239821b46a616dab845b22a, https://github.com/slawkens/myaac/commit/e274b8350451a20c24e652ea05ed1964ebb86b54)
* New Setting: block create account spam by ip (https://github.com/slawkens/myaac/commit/54265f42e987522803288477952d6e5c4daeeb24)
* Functions: Add the possibility to fetch skills, balance and frags in the getTopPlayers function (#347)
* Plugins: autoload init-priority option (https://github.com/slawkens/myaac/commit/f1aa12840875960849fa0c99a2bbe0ad2949bbec)
### Changed ### Changed
* Better handling of vocations: (#345) * Better handling of vocations: (#345)
@@ -11,6 +14,7 @@
* Support for Monk vocation * Support for Monk vocation
* Better gallery, loads images from images/gallery folder * Better gallery, loads images from images/gallery folder
* Reworked account action logs to use a single IP column as varchar(45) for both ipv4 and ipv6 (#289) * Reworked account action logs to use a single IP column as varchar(45) for both ipv4 and ipv6 (#289)
* Make myaac_config table columns bigger (https://github.com/slawkens/myaac/commit/2c62a97160a3ffe9976ee5bd1d770a0abc576742)
* Admin Panel: save menu collapse state (https://github.com/slawkens/myaac/commit/55da00520df7463a1d1ca41931df1598e9f2ffeb) * Admin Panel: save menu collapse state (https://github.com/slawkens/myaac/commit/55da00520df7463a1d1ca41931df1598e9f2ffeb)
### Internal ### Internal

View File

@@ -86,12 +86,6 @@ Look: [Contributing](https://docs.my-aac.org/misc/contributing) in our wiki.
If you have a great idea or want to contribute to the project - visit our website at https://www.my-aac.org If you have a great idea or want to 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
This program and all associated files are released under the GNU Public License. This program and all associated files are released under the GNU Public License.

View File

@@ -46,6 +46,15 @@ if (!is_array($settingsFile)) {
return; return;
} }
if (isset($_POST['reset']) && $_POST['reset'] == '1') {
$settings = Settings::getInstance();
$settings->deleteFromDatabase($settingsFile['key']);
$settings->clearCache();
success('Settings for this plugin has been reset.');
}
$settingsKeyName = ($plugin == 'core' ? $plugin : $settingsFile['key']); $settingsKeyName = ($plugin == 'core' ? $plugin : $settingsFile['key']);
$title = ($plugin == 'core' ? 'Settings' : 'Plugin Settings - ' . $settingsFile['name']); $title = ($plugin == 'core' ? 'Settings' : 'Plugin Settings - ' . $settingsFile['name']);
@@ -57,4 +66,5 @@ $twig->display('admin.settings.html.twig', [
'settings' => $settingsFile['settings'], 'settings' => $settingsFile['settings'],
'script' => $settingsParsed['script'], 'script' => $settingsParsed['script'],
'settingsKeyName' => $settingsKeyName, 'settingsKeyName' => $settingsKeyName,
'pluginName' => $plugin,
]); ]);

View File

@@ -27,7 +27,7 @@ if (version_compare(phpversion(), '8.1', '<')) die('PHP version 8.1 or higher is
const MYAAC = true; const MYAAC = true;
const MYAAC_VERSION = '2.0-dev'; const MYAAC_VERSION = '2.0-dev';
const DATABASE_VERSION = 50; const DATABASE_VERSION = 52;
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'));

View File

@@ -5,7 +5,9 @@ CREATE TABLE IF NOT EXISTS `myaac_account_actions`
`ip` varchar(45) NOT NULL DEFAULT '', `ip` varchar(45) NOT NULL DEFAULT '',
`date` int NOT NULL DEFAULT 0, `date` int NOT NULL DEFAULT 0,
`action` varchar(255) NOT NULL DEFAULT '', `action` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`) PRIMARY KEY (`id`),
INDEX `myaac_account_actions_account_id` (`account_id`),
INDEX `myaac_account_actions_ip` (`ip`)
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8mb4; ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8mb4;
CREATE TABLE IF NOT EXISTS `myaac_account_emails_verify` CREATE TABLE IF NOT EXISTS `myaac_account_emails_verify`
@@ -43,8 +45,8 @@ CREATE TABLE IF NOT EXISTS `myaac_changelog`
CREATE TABLE IF NOT EXISTS `myaac_config` CREATE TABLE IF NOT EXISTS `myaac_config`
( (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
`name` varchar(30) NOT NULL, `name` varchar(255) NOT NULL,
`value` varchar(1000) NOT NULL, `value` varchar(10000) NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE (`name`) UNIQUE (`name`)
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8mb4; ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8mb4;

View File

@@ -30,9 +30,6 @@ parameters:
# Eloquent models # Eloquent models
- '#Call to an undefined method [a-zA-Z0-9\\_]+::[a-zA-Z0-9\\_]+\(\)#' - '#Call to an undefined method [a-zA-Z0-9\\_]+::[a-zA-Z0-9\\_]+\(\)#'
- '#Call to an undefined static method [a-zA-Z0-9\\_]+::[a-zA-Z0-9\\_]+\(\)#' - '#Call to an undefined static method [a-zA-Z0-9\\_]+::[a-zA-Z0-9\\_]+\(\)#'
# system/pages/highscores.php
- '#Access to an undefined property Illuminate\\Database\\Eloquent\\Model::\$online_status#'
- '#Access to an undefined property Illuminate\\Database\\Eloquent\\Model::\$vocation_name#'
- -
message: '#Variable \$tmp in empty\(\) always exists and is always falsy#' message: '#Variable \$tmp in empty\(\) always exists and is always falsy#'
path: templates\kathrine\javascript.php path: templates\kathrine\javascript.php

View File

@@ -372,8 +372,8 @@ class POT
global $debugBar; global $debugBar;
if (isset($debugBar)) { if (isset($debugBar)) {
$this->db = new DebugBar\DataCollector\PDO\TraceablePDO(new OTS_DB_MySQL($params)); $this->db = new \MyAAC\Debug\TraceablePDOWithBacktrace(new OTS_DB_MySQL($params));
$debugBar->addCollector(new DebugBar\DataCollector\PDO\PDOCollector($this->db)); $debugBar->addCollector(new \MyAAC\Debug\PDOCollectorWithBacktrace($this->db));
} }
else { else {
$this->db = new OTS_DB_MySQL($params); $this->db = new OTS_DB_MySQL($params);

10
system/migrations/51.php Normal file
View File

@@ -0,0 +1,10 @@
<?php
$up = function () use ($db) {
$db->modifyColumn(TABLE_PREFIX . 'config', 'name', "varchar(255) NOT NULL");
$db->modifyColumn(TABLE_PREFIX . 'config', 'value', "varchar(10000) NOT NULL");
};
$down = function () {
// nothing to do, to not lose data
};

13
system/migrations/52.php Normal file
View File

@@ -0,0 +1,13 @@
<?php
/**
* 2026-04-12
* Add indexes to myaac_account_actions table
*/
$up = function () use ($db) {
$db->query("CREATE INDEX `myaac_account_actions_account_id` ON `myaac_account_actions` (`account_id`);");
$db->query("CREATE INDEX `myaac_account_actions_ip` ON `myaac_account_actions` (`ip`);");
};
$down = function () {
// nothing to do, to not lose data
};

View File

@@ -47,7 +47,6 @@ if(isset($_REQUEST['name']))
if(empty($name)) if(empty($name))
{ {
$tmp_link = getPlayerLink($name);
echo 'Here you can get detailed information about a certain player on ' . $config['lua']['serverName'] . '.<br/>'; echo 'Here you can get detailed information about a certain player on ' . $config['lua']['serverName'] . '.<br/>';
echo generate_search_form(true); echo generate_search_form(true);
return; return;

View File

@@ -207,10 +207,14 @@ if (empty($highscores)) {
} }
$highscores = $query->get()->map(function($row) { $highscores = $query->get()->map(function($row) {
/**
* @var Player $row
*/
$tmp = $row->toArray(); $tmp = $row->toArray();
$tmp['online'] = $row->online_status; $tmp['online'] = $row->online_status;
$tmp['vocation'] = $row->vocation_name; $tmp['vocation'] = $row->vocation_name;
$tmp['outfit_url'] = $row->outfit_url; // @phpstan-ignore-line $tmp['outfit_url'] = $row->outfit_url;
$tmp['link'] = getPlayerLink($row->name, false);
unset($tmp['online_table']); unset($tmp['online_table']);
return $tmp; return $tmp;
@@ -244,7 +248,6 @@ foreach($highscores as $id => &$player)
$player['experience'] = number_format($player['experience']); $player['experience'] = number_format($player['experience']);
} }
$player['link'] = getPlayerLink($player['name'], false);
$player['flag'] = getFlagImage($player['country']); $player['flag'] = getFlagImage($player['country']);
$player['outfit'] = '<img style="position:absolute;margin-top:-50px;margin-left:-30px" src="' . $player['outfit_url'] . '" alt="" />'; $player['outfit'] = '<img style="position:absolute;margin-top:-50px;margin-left:-30px" src="' . $player['outfit_url'] . '" alt="" />';

View File

@@ -108,8 +108,9 @@ $title = 'Latest News';
$cache = Cache::getInstance(); $cache = Cache::getInstance();
$news_cached = false; $news_cached = false;
if($cache->enabled()) if($cache->enabled() && !admin()) {
$news_cached = News::getCached(NEWS); $news_cached = News::getCached(NEWS);
}
if(!$news_cached) if(!$news_cached)
{ {

View File

@@ -0,0 +1,52 @@
<?php
namespace MyAAC\Debug;
use DebugBar\DataCollector\PDO\PDOCollector;
use DebugBar\DataCollector\PDO\TraceablePDO;
use DebugBar\DataCollector\TimeDataCollector;
class PDOCollectorWithBacktrace extends PDOCollector
{
protected function collectPDO(TraceablePDO $pdo, ?TimeDataCollector $timeCollector = null, $connectionName = null): array
{
$data = parent::collectPDO($pdo, $timeCollector, $connectionName);
if ($pdo instanceof TraceablePDOWithBacktrace) {
$backtraces = $pdo->getBacktraces();
foreach ($data['statements'] as $i => &$stmt) {
if (isset($backtraces[$i])) {
$stmt['backtrace'] = $this->formatBacktrace($backtraces[$i]);
}
}
unset($stmt);
}
return $data;
}
private function formatBacktrace(array $backtrace): array
{
$result = [];
foreach ($backtrace as $frame) {
if (!isset($frame['file'], $frame['line'])) {
continue;
}
if (str_contains($frame['file'], DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR)) {
continue;
}
if (str_contains($frame['file'], DIRECTORY_SEPARATOR . 'Debug' . DIRECTORY_SEPARATOR)) {
continue;
}
$function = isset($frame['class'])
? $frame['class'] . ($frame['type'] ?? '::') . ($frame['function'] ?? '')
: ($frame['function'] ?? '');
$result[] = ($function ? $function . '() ' : '') . $frame['file'] . ':' . $frame['line'];
}
return $result;
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace MyAAC\Debug;
use DebugBar\DataCollector\PDO\TraceablePDO;
use DebugBar\DataCollector\PDO\TracedStatement;
class TraceablePDOWithBacktrace extends TraceablePDO
{
/** @var array[] */
protected array $backtraces = [];
public function addExecutedStatement(TracedStatement $stmt): void
{
$this->backtraces[] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
parent::addExecutedStatement($stmt);
}
/**
* @return array[]
*/
public function getBacktraces(): array
{
return $this->backtraces;
}
}

View File

@@ -18,6 +18,15 @@ class Account extends Model {
public $timestamps = false; public $timestamps = false;
protected $fillable = [
'name', 'number', 'email', 'password',
'key', 'created', 'rlname', 'location', 'country',
'web_lastlogin', 'web_flags',
'email_new', 'email_new_time', 'email_code',
'premium_points', 'coins', 'coins_transferable',
'premium_ends_at', 'premend', 'lastday', 'premdays',
];
protected $casts = [ protected $casts = [
'lastday' => 'integer', 'lastday' => 'integer',
'premdays' => 'integer', 'premdays' => 'integer',

View File

@@ -1,15 +0,0 @@
<?php
namespace MyAAC\Models;
use Illuminate\Database\Eloquent\Model;
class BugTracker extends Model {
protected $table = TABLE_PREFIX . 'bugtracker';
public $timestamps = false;
protected $fillable = ['account', 'type', 'status', 'text', 'id', 'subject', 'reply', 'who', 'uid', 'tag'];
}

View File

@@ -5,8 +5,10 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\Relations\HasOne;
/** /**
* @property string $name
* @property int $level * @property int $level
* @property int $vocation * @property int $vocation
* @property int $promotion
* @property int $online * @property int $online
* @property int $looktype * @property int $looktype
* @property int $lookhead * @property int $lookhead
@@ -14,6 +16,8 @@ use Illuminate\Database\Eloquent\Relations\HasOne;
* @property int $looklegs * @property int $looklegs
* @property int $lookfeet * @property int $lookfeet
* @property int $lookaddons * @property int $lookaddons
* @property bool $online_status
* @property string $vocation_name
* @property string $outfit_url * @property string $outfit_url
* @property hasOne $onlineTable * @property hasOne $onlineTable
*/ */

View File

@@ -7,9 +7,11 @@ use MyAAC\Cache\Cache;
use MyAAC\Models\Menu; use MyAAC\Models\Menu;
class Plugins { class Plugins {
private static $warnings = []; private static array $warnings = [];
private static $error = null; private static string $error = '';
private static $plugin_json = []; private static array $plugin_json = [];
const DEFAULT_PRIORITY = 1000;
public static function getInits() public static function getInits()
{ {
@@ -20,13 +22,31 @@ class Plugins {
continue; continue;
} }
$initPriority = self::DEFAULT_PRIORITY;
if (isset($plugin['autoload']['init-priority'])) {
$initPriority = (int) $plugin['autoload']['init-priority'];
}
$pluginInits = glob(PLUGINS . $plugin['filename'] . '/init.php'); $pluginInits = glob(PLUGINS . $plugin['filename'] . '/init.php');
foreach ($pluginInits as $path) { foreach ($pluginInits as $path) {
$inits[] = $path; $inits[] = [
'file' => $path,
'priority' => $initPriority
];
} }
} }
return $inits; usort($inits, function ($a, $b)
{
return $a['priority'] <=> $b['priority'];
});
$ret = [];
foreach ($inits as $init) {
$ret[] = $init['file'];
}
return $ret;
}); });
} }
@@ -39,7 +59,7 @@ class Plugins {
continue; continue;
} }
$adminPagesDefaultPriority = 1000; $adminPagesDefaultPriority = self::DEFAULT_PRIORITY;
if (isset($plugin['admin-pages-default-priority'])) { if (isset($plugin['admin-pages-default-priority'])) {
$adminPagesDefaultPriority = $plugin['admin-pages-default-priority']; $adminPagesDefaultPriority = $plugin['admin-pages-default-priority'];
} }
@@ -117,7 +137,7 @@ class Plugins {
$routes = []; $routes = [];
foreach(self::getAllPluginsJson() as $plugin) { foreach(self::getAllPluginsJson() as $plugin) {
$routesDefaultPriority = 1000; $routesDefaultPriority = self::DEFAULT_PRIORITY;
if (isset($plugin['routes-default-priority'])) { if (isset($plugin['routes-default-priority'])) {
$routesDefaultPriority = $plugin['routes-default-priority']; $routesDefaultPriority = $plugin['routes-default-priority'];
} }
@@ -165,7 +185,7 @@ class Plugins {
} }
} }
$pagesDefaultPriority = 1000; $pagesDefaultPriority = self::DEFAULT_PRIORITY;
if (isset($plugin['pages-default-priority'])) { if (isset($plugin['pages-default-priority'])) {
$pagesDefaultPriority = $plugin['pages-default-priority']; $pagesDefaultPriority = $plugin['pages-default-priority'];
} }
@@ -318,7 +338,7 @@ 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) {
$priority = 1000; $priority = self::DEFAULT_PRIORITY;
if (str_contains($info['type'], 'HOOK_')) { if (str_contains($info['type'], 'HOOK_')) {
$info['type'] = str_replace('HOOK_', '', $info['type']); $info['type'] = str_replace('HOOK_', '', $info['type']);
@@ -432,7 +452,7 @@ class Plugins {
return $plugins; return $plugins;
} }
public static function getPluginSettings($filename) public static function getPluginSettings($filename): mixed
{ {
$plugin_json = self::getPluginJson($filename); $plugin_json = self::getPluginJson($filename);
if (!$plugin_json) { if (!$plugin_json) {
@@ -870,7 +890,11 @@ class Plugins {
global $hooks; global $hooks;
foreach($plugin_info['hooks'] ?? [] as $name => $info) { foreach($plugin_info['hooks'] ?? [] as $name => $info) {
$hooks->unregister($name, $info['type'], $info['file']); if (str_contains($info['type'], 'HOOK_')) {
$info['type'] = str_replace('HOOK_', '', $info['type']);
}
$hooks->unregister($name, 'HOOK_' . $info['type'], $info['file']);
} }
clearCache(); clearCache();
@@ -897,15 +921,15 @@ class Plugins {
return Semver::satisfies($plugin_info['version'], $version); return Semver::satisfies($plugin_info['version'], $version);
} }
public static function getWarnings() { public static function getWarnings(): array {
return self::$warnings; return self::$warnings;
} }
public static function clearWarnings() { public static function clearWarnings(): void {
self::$warnings = []; self::$warnings = [];
} }
public static function getError() { public static function getError(): string {
return self::$error; return self::$error;
} }
@@ -916,7 +940,7 @@ class Plugins {
* @param string $templateName * @param string $templateName
* @param array $menus * @param array $menus
*/ */
public static function installMenus($templateName, $menus, $clearOld = false) public static function installMenus($templateName, $menus, $clearOld = false): void
{ {
global $db; global $db;
@@ -967,7 +991,7 @@ class Plugins {
} }
} }
private static function getAutoLoadOption(array $plugin, string $optionName, bool $default = true) private static function getAutoLoadOption(array $plugin, string $optionName, bool $default = true): bool
{ {
if (isset($plugin['autoload'])) { if (isset($plugin['autoload'])) {
$autoload = $plugin['autoload']; $autoload = $plugin['autoload'];
@@ -976,7 +1000,7 @@ class Plugins {
return getBoolean($autoload[$optionName]); return getBoolean($autoload[$optionName]);
} }
} }
else if (is_bool($autoload)) { elseif (is_bool($autoload)) {
return $autoload; return $autoload;
} }
} }

View File

@@ -367,6 +367,7 @@ class Settings implements \ArrayAccess
</div> </div>
<div class="box-footer"> <div class="box-footer">
<button name="save" type="submit" class="btn btn-primary">Save</button> <button name="save" type="submit" class="btn btn-primary">Save</button>
<button form="reset-settings-form" name="reset" type="submit" class="btn btn-warning position-absolute" style="right: 0; bottom: 0" onclick="return confirm('Are you sure? This will clear all settings for this plugin!')">Reset</button>
</div> </div>
<?php <?php

View File

@@ -9,7 +9,10 @@
<div class="box"> <div class="box">
<div class="box-body"> <div class="box-body">
<button name="save" type="submit" class="btn btn-primary">Save</button> <button name="save" type="submit" class="btn btn-primary">Save</button>
<button form="reset-settings-form" name="reset" type="submit" class="btn btn-warning position-absolute" style="right: 0; top: 0" onclick="return confirm('Are you sure? This will clear all settings for this plugin!')">Reset</button>
</div> </div>
<br/> <br/>
{{ settingsParsed|raw }} {{ settingsParsed|raw }}
</div> </div>
@@ -18,6 +21,12 @@
</form> </form>
</div> </div>
</div> </div>
<form id="reset-settings-form" method="post" action="{{ constant('ADMIN_URL') }}?p=settings&plugin={{ pluginName }}">
{{ csrf() }}
<input type="hidden" name="reset" value="1">
</form>
<style> <style>
.setting-default { .setting-default {
white-space: pre-wrap; white-space: pre-wrap;
@@ -95,12 +104,12 @@
.on('change input', function(){ .on('change input', function(){
const disable = $(this).serialize() === $(this).data('serialized'); const disable = $(this).serialize() === $(this).data('serialized');
$(this) $(this)
.find('input:submit, button:submit') .find('button[name="save"]')
.prop('disabled', disable) .prop('disabled', disable)
.prop('title', disable ? noChangesText : '') .prop('title', disable ? noChangesText : '')
; ;
}) })
.find('input:submit, button:submit') .find('button[name="save"]')
.prop('disabled', true) .prop('disabled', true)
.prop('title', noChangesText) .prop('title', noChangesText)
; ;
@@ -123,7 +132,7 @@
let $settings = $('#settings'); let $settings = $('#settings');
$settings.data('serialized', $settings.serialize()); $settings.data('serialized', $settings.serialize());
$settings $settings
.find('input:submit, button:submit') .find('button[name="save"]')
.prop('disabled', true) .prop('disabled', true)
.prop('title', noChangesText); .prop('title', noChangesText);
}, },

View File

@@ -1,15 +1,13 @@
<?php <?php
$topPlayers = Cache::remember('tibiacom_highscores_top_players', 10 * 60, function() {
$topPlayers = getTopPlayers(5); $topPlayers = getTopPlayers(5);
foreach($topPlayers as &$player) { foreach($topPlayers as &$player) {
$outfit_url = ''; $player['outfit'] = $player['outfit_url'];
if (setting('core.online_outfit')) { $player['link'] = getPlayerLink($player['id'], false);
$outfit_url = setting('core.outfit_images_url') . '?id=' . $player['looktype'] . (!empty
($player['lookaddons']) ? '&addons=' . $player['lookaddons'] : '') . '&head=' . $player['lookhead'] . '&body=' . $player['lookbody'] . '&legs=' . $player['looklegs'] . '&feet=' . $player['lookfeet'];
$player['outfit'] = $outfit_url;
} }
}
return $topPlayers;
});
$twig->display('highscores.html.twig', array( $twig->display('highscores.html.twig', array(
'topPlayers' => $topPlayers 'topPlayers' => $topPlayers

View File

@@ -44,7 +44,7 @@
<div id="Topbar" class="Themebox" style="background-image:url({{ template_path }}/images/themeboxes/highscores/highscores.png);"> <div id="Topbar" class="Themebox" style="background-image:url({{ template_path }}/images/themeboxes/highscores/highscores.png);">
<div class="top_level" style="background:url({{ template_path }}/images/themeboxes/bg_top.png)" align=" "> <div class="top_level" style="background:url({{ template_path }}/images/themeboxes/bg_top.png)" align=" ">
{% for player in topPlayers %} {% for player in topPlayers %}
<div style="text-align:left"><a href="{{ getPlayerLink(player['name'], false) }} " class="topfont {% if player['online'] %}online{% else %}offline{% endif %}"> <div style="text-align:left"><a href="{{ player['link'] }} " class="topfont {% if player['online'] %}online{% else %}offline{% endif %}">
{% if setting('core.online_outfit') %} {% if setting('core.online_outfit') %}
<img style="position:absolute;margin-top:-45px;margin-left:-25px;" src="{{ player.outfit }}" alt="player outfit"/> <img style="position:absolute;margin-top:-45px;margin-left:-25px;" src="{{ player.outfit }}" alt="player outfit"/>
{% endif %} {% endif %}