Compare commits

...

6 Commits

Author SHA1 Message Date
slawkens
50d649dbde Release v1.3.3 2025-04-04 21:25:19 +02:00
slawkens
6c568fd36a Fix uninstall plugin when plugin is disabled 2025-04-04 21:08:49 +02:00
slawkens
fa6b6aa153 Display more info when error parsing config.lua value 2025-04-04 20:07:42 +02:00
slawkens
ae639d65b0 PHP 8 things 2025-04-03 20:39:27 +02:00
slawkens
35e2483de8 Change root folder to /var/www/html, like in default config 2025-04-02 19:48:23 +02:00
slawkens
bbf923e1a6 Update common.php 2025-04-01 07:56:29 +02:00
6 changed files with 44 additions and 10 deletions

View File

@@ -1,5 +1,16 @@
# Changelog # Changelog
## [1.3.3 - 04.04.2025]
### Fixed
* Fix uninstall plugin when plugin is disabled (https://github.com/slawkens/myaac/commit/6c568fd36a271270684fc412ccd556b230273a6d)
### Changed
* Display more useful info when error parsing config.lua (https://github.com/slawkens/myaac/commit/fa6b6aa153ffc131e0d1631a4dcd9012a5850c2e)
### Other
* Small adjustments (https://github.com/slawkens/myaac/commit/35e2483de86e295bdf089cceffa25842eeb2e34c, https://github.com/slawkens/myaac/commit/ae639d65b0bfa491e747e907e2ebc77f83f47981)
## [1.3.2 - 01.04.2025] ## [1.3.2 - 01.04.2025]
### Fixed ### Fixed

View File

@@ -26,7 +26,7 @@
if (version_compare(phpversion(), '8.1', '<')) die('PHP version 8.1 or higher is required.'); if (version_compare(phpversion(), '8.1', '<')) die('PHP version 8.1 or higher is required.');
const MYAAC = true; const MYAAC = true;
const MYAAC_VERSION = '1.3.2'; const MYAAC_VERSION = '1.3.3';
const DATABASE_VERSION = 43; const DATABASE_VERSION = 43;
const TABLE_PREFIX = 'myaac_'; const TABLE_PREFIX = 'myaac_';
define('START_TIME', microtime(true)); define('START_TIME', microtime(true));

View File

@@ -31,11 +31,11 @@ require_once 'common.php';
require_once SYSTEM . 'functions.php'; require_once SYSTEM . 'functions.php';
$uri = $_SERVER['REQUEST_URI']; $uri = $_SERVER['REQUEST_URI'];
if(false !== strpos($uri, 'index.php')) { if(str_contains($uri, 'index.php')) {
$uri = str_replace_first('/index.php', '', $uri); $uri = str_replace_first('/index.php', '', $uri);
} }
if(0 === strpos($uri, '/')) { if(str_starts_with($uri, '/')) {
$uri = str_replace_first('/', '', $uri); $uri = str_replace_first('/', '', $uri);
} }

View File

@@ -1,6 +1,6 @@
server { server {
listen 80; listen 80;
root /home/otserv/www/public; root /var/www/html;
index index.php; index index.php;
server_name your-domain.com; server_name your-domain.com;

View File

@@ -1012,12 +1012,19 @@ function load_config_lua($filename)
} }
else else
{ {
foreach($result as $tmp_key => $tmp_value) // load values defined by other keys, like: dailyFragsToBlackSkull = dailyFragsToRedSkull foreach($result as $tmp_key => $tmp_value) { // load values defined by other keys, like: dailyFragsToBlackSkull = dailyFragsToRedSkull
$value = str_replace($tmp_key, $tmp_value, $value); $value = str_replace($tmp_key, $tmp_value, $value);
$ret = @eval("return $value;"); }
if((string) $ret == '' && trim($value) !== '""') // = parser error
{ try {
throw new RuntimeException('ERROR: Loading config.lua file. Line <b>' . ($ln + 1) . '</b> of LUA config file is not valid [key: <b>' . $key . '</b>]'); $ret = eval("return $value;");
}
catch (Throwable $e) {
throw new RuntimeException('ERROR: Loading config.lua file. Line: ' . ($ln + 1) . ' - Unable to parse value "' . $value . '" - ' . $e->getMessage());
}
if((string) $ret == '' && trim($value) !== '""') {
throw new RuntimeException('ERROR: Loading config.lua file. Line ' . ($ln + 1) . ' is not valid [key: ' . $key . ']');
} }
$result[$key] = $ret; $result[$key] = $ret;
} }

View File

@@ -675,26 +675,41 @@ class Plugins {
public static function uninstall($plugin_name): bool public static function uninstall($plugin_name): bool
{ {
$isDisabled = self::existDisabled($plugin_name);
if($isDisabled) {
self::enable($plugin_name);
}
$revertEnable = function() use ($isDisabled, $plugin_name) {
if($isDisabled) {
self::disable($plugin_name);
}
};
$filename = BASE . 'plugins/' . $plugin_name . '.json'; $filename = BASE . 'plugins/' . $plugin_name . '.json';
if(!file_exists($filename)) { if(!file_exists($filename)) {
self::$error = 'Plugin ' . $plugin_name . ' does not exist.'; self::$error = 'Plugin ' . $plugin_name . ' does not exist.';
$revertEnable();
return false; return false;
} }
$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) {
self::$error = 'Cannot load plugin info ' . $plugin_name . '.json'; self::$error = 'Cannot load plugin info ' . $plugin_name . '.json';
$revertEnable();
return false; return false;
} }
if(!isset($plugin_info['uninstall'])) { if(!isset($plugin_info['uninstall'])) {
self::$error = "Plugin doesn't have uninstall options defined. Skipping..."; self::$error = "Plugin doesn't have uninstall options defined. Skipping...";
$revertEnable();
return false; return false;
} }
$success = true; $success = true;
foreach($plugin_info['uninstall'] as $file) { foreach($plugin_info['uninstall'] as $file) {
if(strpos($file, '/') === 0) { if(str_starts_with($file, '/')) {
$success = false; $success = false;
self::$error = "You cannot use absolute paths (starting with slash - '/'): " . $file; self::$error = "You cannot use absolute paths (starting with slash - '/'): " . $file;
break; break;
@@ -726,6 +741,7 @@ class Plugins {
return true; return true;
} }
$revertEnable();
return false; return false;
} }