Skip to content

Commit

Permalink
fix: uninstall module amendments
Browse files Browse the repository at this point in the history
  • Loading branch information
samerton committed Jun 7, 2024
1 parent 93ffa85 commit de406f3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions core/classes/Core/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ public static function recursiveRemoveDirectory(string $directory): bool
// safety precaution, only allow deleting files in "custom", "modules" or "uploads" directory
if (
str_contains($directory, 'Core') ||
!str_contains($directory, 'custom') ||
!str_contains($directory, 'modules') ||
!str_contains($directory, 'uploads')
(
!str_contains(realpath($directory), 'custom') &&
!str_contains(realpath($directory), 'modules') &&
!str_contains(realpath($directory), 'uploads')
)
) {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions modules/Core/language/en_UK.json
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@
"admin/module": "Module",
"admin/module_disabled": "Module disabled.",
"admin/module_enabled": "Module enabled.",
"admin/module_uninstalled": "Module uninstalled.",
"admin/module_outdated": "We have detected that this module is intended for Nameless version {{intendedVersion}}, but you are running Nameless version {{actualVersion}}",
"admin/module_x": "Module: {{module}}",
"admin/modules": "Modules",
Expand Down
7 changes: 3 additions & 4 deletions modules/Core/pages/panel/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@
}

if ($_GET['action'] === 'uninstall') {
// Disable a module
// Uninstall a module
if (!isset($_GET['m']) || !is_numeric($_GET['m']) || $_GET['m'] == 1) {
die('Invalid module!');
}
Expand All @@ -357,9 +357,7 @@
}
}

DB::getInstance()->delete('modules', [
'id' => $_GET['m'],
]);
DB::getInstance()->delete('modules', ['id', $_GET['m']]);

// Cache
$cache->setCache('modulescache');
Expand Down Expand Up @@ -390,6 +388,7 @@
}

Session::flash('admin_modules', $language->get('admin', 'module_uninstalled'));
Redirect::to(URL::build('/panel/core/modules'));

} else {
Session::flash('admin_modules_error', $language->get('general', 'invalid_token'));
Expand Down

0 comments on commit de406f3

Please sign in to comment.