$this->SetPreference("showhiddenfiles", 1);
} else {
    $this->SetPreference("showhiddenfiles", 0);
}
if (isset($params["showthumbnails"])) {
    $this->SetPreference("showthumbnails", 1);
} else {
    $this->SetPreference("showthumbnails", 0);
}
if (isset($params["iconsize"])) {
    $this->SetPreference("iconsize", $params["iconsize"]);
}
if (isset($params["permissionflavor"])) {
    $this->SetPreference("permissionflavor", $params["permissionflavor"]);
}
if (isset($params["uploadboxes"])) {
    $this->SetPreference("uploadboxes", $params["uploadboxes"]);
}
if (isset($params["permissionstyle"])) {
    $this->SetPreference("permissionstyle", $params["permissionstyle"]);
}
if (isset($params["thousanddelimiter"])) {
    $this->SetPreference("thousanddelimiter", $params["thousanddelimiter"]);
}
if (isset($params["create_thumbnails"])) {
    $this->SetPreference('create_thumbnails', (int) $params['create_thumbnails']);
}
filemanager_utils::set_cwd('/');
$this->SetMessage($this->Lang('settingssaved'));
$this->SetCurrentTab('settings');
$this->RedirectToAdminTab();
if (!$this->CheckPermission("Modify Files") && !$this->AdvancedAccessAllowed()) {
    exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'GET' && isset($_GET['showtemplate']) && $_GET['showtemplate'] == 'false') {
    echo filemanager_utils::get_cwd();
    exit;
}
if (!isset($params["newdir"]) || !isset($params["path"])) {
    $this->Redirect($id, 'defaultadmin');
}
$newdir = $params["newdir"];
$path = filemanager_utils::join_path(filemanager_utils::get_cwd(), $newdir);
try {
    if (isset($params['ajax'])) {
        filemanager_utils::set_cwd(trim($newdir));
    } else {
        filemanager_utils::set_cwd($path);
        $this->Redirect($id, 'defaultadmin');
    }
} catch (Exception $e) {
    audit('', 'FileManager', 'Attempt to set working directory to an invalid location: ' . $newdir);
    if (isset($params['ajax'])) {
        exit('ERROR');
    }
}
//echo $params["path"];
if (isset($params['ajax'])) {
    echo 'OK';
}
exit;
$this->Redirect($id, 'defaultadmin', $returnid, array("path" => $path));
            $val = (double) $size / 1024.0 / 1024.0;
            $suffix = 'Mb';
            $val = round($val, 2);
        }
    }
    return $val . $suffix;
}
$filepickerstyle = $this->GetPreference("filepickerstyle", "both");
$smarty->assign("filepickerstyle", $filepickerstyle);
$smarty->assign("rooturl", $config->smart_root_url());
$smarty->assign("filepickertitle", $this->Lang("filepickertitle"));
$smarty->assign("youareintext", $this->Lang("youareintext"));
$tmp = filemanager_utils::get_cwd();
if (isset($_GET['subdir'])) {
    $tmp .= '/' . trim($_GET['subdir']);
    filemanager_utils::set_cwd($tmp);
}
$startpath = filemanager_utils::get_cwd();
if ($type == "image") {
    $smarty->assign("isimage", "1");
} else {
    $smarty->assign("isimage", "0");
}
$starturl = $config['root_url'] . '/' . $startpath;
$startdir = filemanager_utils::join_path($config['root_path'], $startpath);
function sortfiles($file1, $file2)
{
    if ($file1["isdir"] && !$file2["isdir"]) {
        return -1;
    }
    if (!$file1["isdir"] && $file2["isdir"]) {