mirror of
https://github.com/slawkens/myaac.git
synced 2026-04-26 20:33:31 +02:00
Compare commits
29 Commits
feature/da
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
925cbfbc95 | ||
|
|
81b8bd8a2c | ||
|
|
def432d4b7 | ||
|
|
b0edbb79d9 | ||
|
|
04d630d765 | ||
|
|
7851e337eb | ||
|
|
ba1ee4bdb7 | ||
|
|
e61c40d6b3 | ||
|
|
54bdea85a3 | ||
|
|
48284e426f | ||
|
|
ac9a328206 | ||
|
|
0635108d4c | ||
|
|
47ec36a176 | ||
|
|
e4a947cabb | ||
|
|
609cf152af | ||
|
|
c16f95f8d2 | ||
|
|
ec7079dd57 | ||
|
|
9e0e2601d2 | ||
|
|
e7198aeb23 | ||
|
|
1fa3630f86 | ||
|
|
e274b83504 | ||
|
|
a467a540b1 | ||
|
|
08507e2940 | ||
|
|
f1aa128408 | ||
|
|
7104c2258f | ||
|
|
f51211d47a | ||
|
|
fa93187f80 | ||
|
|
2c62a97160 | ||
|
|
7bc8a66cc1 |
@@ -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
|
||||||
|
|||||||
@@ -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.
|
|
||||||
|
|
||||||
[](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.
|
||||||
|
|||||||
@@ -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,
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -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'));
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
10
system/migrations/51.php
Normal 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
13
system/migrations/52.php
Normal 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
|
||||||
|
};
|
||||||
@@ -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;
|
||||||
|
|||||||
@@ -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="" />';
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
52
system/src/Debug/PDOCollectorWithBacktrace.php
Normal file
52
system/src/Debug/PDOCollectorWithBacktrace.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
26
system/src/Debug/TraceablePDOWithBacktrace.php
Normal file
26
system/src/Debug/TraceablePDOWithBacktrace.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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',
|
||||||
|
|||||||
@@ -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'];
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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'];
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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 %}
|
||||||
|
|||||||
Reference in New Issue
Block a user