Exemple #1
0
<?php

@define('NWNADMIN_BASE', dirname(__FILE__));
require_once NWNADMIN_BASE . '/lib/base.php';
require_once NWNADMIN_BASE . '/lib/ModuleForms.php';
// script global variables
global $nwndriver;
$admin = Auth::isAdmin('nwnadmin:admin');
$adminDelete = Auth::isAdmin('nwnadmin:admin', PERMS_DELETE);
$moduleDir = NWNAdmin::getModulePath();
$moduleDirWritable = is_writable($moduleDir);
$serverUp = $nwndriver->serverRunning();
if ($admin && !$serverUp) {
    $notification->push(_("The server is down; module loading is unavailable."));
}
// figure out what to do
$actionId = Util::getFormData('actionId');
$moduleName = Util::getFormData('moduleName');
if (isset($actionId) && !isset($moduleName)) {
    $notification->push(_("Invalid options! Try again..."), 'horde.warning');
} else {
    switch ($actionId) {
        case 'delete':
            if ($adminDelete && strpos($conf['server']['root'], $moduleName) == 0) {
                $moduleName = str_replace('../', '', $moduleName);
                $result = unlink(escapeshellcmd($moduleName));
                if (!$result) {
                    $notification->push(_("Could not delete the module."), 'horde.error');
                } else {
                    $notification->push(_("Successfully deleted the module."), 'horde.success');
                }