}
             } else {
                 $FILE[] = $file;
             }
         }
     }
 }
 // Now parse these values to the template
 $temp_id = 0;
 $row_bg_color = 'FFF';
 if (isset($DIR)) {
     sort($DIR);
     foreach ($DIR as $name) {
         $link_name = str_replace(' ', '%20', $name);
         $temp_id++;
         $template->set_var(array('NAME' => $name, 'NAME_SLASHED' => addslashes($name), 'TEMP_ID' => $admin->getIDKEY($temp_id), 'LINK' => "browse.php?dir={$directory}/{$link_name}", 'LINK_TARGET' => '_self', 'ROW_BG_COLOR' => $row_bg_color, 'FT_ICON' => THEME_URL . '/images/folder_16.png', 'FILETYPE_ICON' => THEME_URL . '/images/folder_16.png', 'MOUSEOVER' => '', 'IMAGEDETAIL' => '', 'SIZE' => '', 'DATE' => '', 'PREVIEW' => '', 'IMAGE_TITLE' => $name, 'IMAGE_EXIST' => 'blank_16.gif'));
         $template->parse('list', 'list_block', true);
         // Code to alternate row colors
         if ($row_bg_color == 'FFF') {
             $row_bg_color = 'ECF1F3';
         } else {
             $row_bg_color = 'FFF';
         }
     }
 }
 if (isset($FILE)) {
     sort($FILE);
     $filepreview = array('jpg', 'gif', 'tif', 'tiff', 'png', 'txt', 'css', 'js', 'cfg', 'conf', 'pdf', 'zip', 'gz', 'doc');
     foreach ($FILE as $name) {
         $size = filesize('../../' . MEDIA_DIRECTORY . $directory . '/' . $name);
         $bytes = byte_convert($size);
// Get existing value from database
$query = 'SELECT `group_id`, `name` FROM `' . TABLE_PREFIX . 'groups` WHERE `group_id` != 1';
$results = $database->query($query);
if ($database->is_error()) {
    $admin->print_error($database->get_error(), 'index.php');
}
// Insert values into the modify/remove menu
$template->set_block('main_block', 'list_block', 'list');
if ($results->numRows() > 0) {
    // Insert first value to say please select
    $template->set_var('VALUE', '');
    $template->set_var('NAME', $TEXT['PLEASE_SELECT'] . '...');
    $template->parse('list', 'list_block', true);
    // Loop through groups
    while ($group = $results->fetchRow(MYSQLI_ASSOC)) {
        $template->set_var('VALUE', $admin->getIDKEY($group['group_id']));
        $template->set_var('NAME', $group['name']);
        $template->parse('list', 'list_block', true);
    }
} else {
    // Insert single value to say no groups were found
    $template->set_var('NAME', $TEXT['NONE_FOUND']);
    $template->parse('list', 'list_block', true);
}
// Insert permissions values
if ($admin->get_permission('groups_add') != true) {
    $template->set_var('DISPLAY_ADD', 'hide');
}
if ($admin->get_permission('groups_modify') != true) {
    $template->set_var('DISPLAY_MODIFY', 'hide');
}
            }
        }
    }
}
if (!isset($rename_file)) {
    $admin->print_error($MESSAGE['MEDIA_FILE_NOT_FOUND'], $dirlink, false);
}
// Setup template object, parse vars to it, then parse it
// Create new template object
$template = new Template(dirname($admin->correct_theme_source('media_rename.htt')));
$template->set_file('page', 'media_rename.htt');
$template->set_block('page', 'main_block', 'main');
//echo WB_PATH.'/media/'.$directory.'/'.$rename_file;
if ($type == 'folder') {
    $template->set_var('DISPlAY_EXTENSION', 'hide');
    $extension = '';
} else {
    $template->set_var('DISPlAY_EXTENSION', '');
    $extension = strstr($rename_file, '.');
}
if ($type == 'folder') {
    $type = $TEXT['FOLDER'];
} else {
    $type = $TEXT['FILE'];
}
$template->set_var(array('THEME_URL' => THEME_URL, 'FILENAME' => $rename_file, 'DIR' => $directory, 'FILE_ID' => $admin->getIDKEY($file_id), 'TYPE' => $type, 'EXTENSION' => $extension, 'FTAN' => $admin->getFTAN()));
// Insert language text and messages
$template->set_var(array('TEXT_TO' => $TEXT['TO'], 'TEXT_RENAME' => $TEXT['RENAME'], 'TEXT_CANCEL' => $TEXT['CANCEL'], 'TEXT_UP' => $TEXT['UP'], 'TEXT_OVERWRITE_EXISTING' => $TEXT['OVERWRITE_EXISTING']));
// Parse template object
$template->parse('main', 'main_block', false);
$template->pparse('output', 'page');
 *
 */
require '../../config.php';
require_once WB_PATH . '/framework/class.admin.php';
require_once WB_PATH . '/framework/functions.php';
$admintool_link = ADMIN_URL . '/admintools/index.php';
$module_edit_link = ADMIN_URL . '/admintools/tool.php?tool=droplets';
$admin = new admin('admintools', 'admintools');
// Get id
if (version_compare(WB_VERSION, '2.8.2', '>=') && WB_VERSION != "2.8.x") {
    $droplet_id = intval($admin->checkIDKEY('droplet_id', false, 'GET'));
    if (!$droplet_id) {
        $admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $module_edit_link);
        exit;
    }
    $edit_id = $admin->getIDKEY($droplet_id);
} else {
    if (isset($_GET['droplet_id']) && is_numeric($_GET['droplet_id'])) {
        $droplet_id = $_GET['droplet_id'];
        $edit_id = $droplet_id;
    } else {
        header("Location: " . ADMIN_URL . "/pages/index.php");
    }
}
// check if backend.css file needs to be included into the <body></body> of modify.php
if (!method_exists($admin, 'register_backend_modfiles') && file_exists(WB_PATH . "/modules/droplets/backend.css")) {
    echo '<style type="text/css">';
    include WB_PATH . '/modules/droplets/backend.css';
    echo "n</style>n";
}
// Load Language file
if ($database->is_error()) {
    $admin->print_error($database->get_error(), 'index.php');
}
$sUserList = $TEXT['LIST_OPTIONS'] . ' ';
$sUserList .= $iUserStatus == 1 ? $MENU['USERS'] . ' ' . strtolower($TEXT['ACTIVE']) : $MENU['USERS'] . ' ' . strtolower($TEXT['DELETED']);
// Insert values into the modify/remove menu
$template->set_block('main_block', 'list_block', 'list');
if ($results->numRows() > 0) {
    // Insert first value to say please select
    $template->set_var('VALUE', '');
    $template->set_var('NAME', $sUserList);
    $template->set_var('STATUS', 'class="user-active"');
    $template->parse('list', 'list_block', true);
    // Loop through users
    while ($user = $results->fetchRow()) {
        $template->set_var('VALUE', $admin->getIDKEY($user['user_id']));
        $template->set_var('STATUS', $user['active'] == false ? 'class="user-inactive"' : 'class="user-active"');
        $template->set_var('NAME', $user['display_name'] . ' (' . $user['username'] . ')');
        $template->parse('list', 'list_block', true);
    }
} else {
    // Insert single value to say no users were found
    $template->set_var('NAME', $TEXT['NONE_FOUND']);
    $template->parse('list', 'list_block', true);
}
// Insert permissions values
if ($admin->get_permission('users_add') != true) {
    $template->set_var('DISPLAY_ADD', 'hide');
}
if ($admin->get_permission('users_modify') != true) {
    $template->set_var('DISPLAY_MODIFY', 'hide');
     $edit_page = '';
 }
 $sec_anchor = defined('SEC_ANCHOR') && SEC_ANCHOR != '' ? SEC_ANCHOR : '';
 $edit_page_0 = '<a id="sid' . $section['section_id'] . '" href="' . ADMIN_URL . '/pages/modify.php?page_id=' . $results_array['page_id'];
 $edit_page_1 = $sec_anchor != '' ? '#' . $sec_anchor . $section['section_id'] . '">' : '">';
 $edit_page_1 .= $section['module'] . '</a>';
 if (SECTION_BLOCKS) {
     if ($edit_page == '') {
         if (defined('EDIT_ONE_SECTION') && EDIT_ONE_SECTION) {
             $edit_page = $edit_page_0 . '&amp;wysiwyg=' . $section['section_id'] . $edit_page_1;
         } else {
             $edit_page = $edit_page_0 . $edit_page_1;
         }
     }
     $input_attribute = 'input_normal';
     $tpl->set_var(array('STYLE_DISPLAY_SECTION_BLOCK' => ' style="visibility:visible;"', 'NAME_SIZE' => 300, 'INPUT_ATTRIBUTE' => $input_attribute, 'VAR_SECTION_ID' => $section['section_id'], 'VAR_SECTION_IDKEY' => $admin->getIDKEY($section['section_id']), 'VAR_POSITION' => $section['position'], 'LINK_MODIFY_URL_VAR_MODUL_NAME' => $edit_page, 'SELECT' => '', 'SET_NONE_DISPLAY_OPTION' => ''));
     // Add block options to the section_list
     $tpl->clear_var('block_list');
     foreach ($block as $number => $name) {
         $tpl->set_var('NAME', htmlentities(strip_tags($name)));
         $tpl->set_var('VALUE', $number);
         $tpl->set_var('SIZE', 1);
         if ($section['block'] == $number) {
             $tpl->set_var('SELECTED', ' selected="selected"');
         } else {
             $tpl->set_var('SELECTED', '');
         }
         $tpl->parse('block_list', 'block_block', true);
     }
 } else {
     if ($edit_page == '') {
 }
 if ($group_id < 2) {
     // if($admin_header) { $admin->print_header(); }
     $admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL);
 }
 // Get existing values
 $sql = 'SELECT * FROM  `' . TABLE_PREFIX . 'groups` WHERE `group_id` =  ' . $group_id;
 $results = $database->query($sql);
 $group = $results->fetchRow(MYSQLI_ASSOC);
 // Setup template object, parse vars to it, then parse it
 // Create new template object
 $template = new Template(dirname($admin->correct_theme_source('groups_form.htt')));
 // $template->debug = true;
 $template->set_file('page', 'groups_form.htt');
 $template->set_block('page', 'main_block', 'main');
 $template->set_var(array('ADMIN_URL' => ADMIN_URL, 'WB_URL' => WB_URL, 'THEME_URL' => THEME_URL, 'ACTION_URL' => ADMIN_URL . '/groups/save.php', 'SUBMIT_TITLE' => $TEXT['SAVE'], 'GROUP_ID' => $admin->getIDKEY($group['group_id']), 'GROUP_NAME' => $group['name'], 'ADVANCED_LINK' => ADMIN_URL . '/groups/groups.php', 'CANCEL_LINK' => ADMIN_URL . '/groups/index.php', 'FTAN' => $admin->getFTAN()));
 // Tell the browser whether or not to show advanced options
 if (true == (isset($_POST['advanced']) and strpos($_POST['advanced'], ">>") > 0)) {
     $template->set_var('DISPLAY_ADVANCED', '');
     $template->set_var('DISPLAY_BASIC', 'display:none;');
     $template->set_var('ADVANCED', 'yes');
     $template->set_var('ADVANCED_BUTTON', '&lt;&lt; ' . $TEXT['HIDE_ADVANCED']);
 } else {
     $template->set_var('DISPLAY_ADVANCED', 'display:none;');
     $template->set_var('DISPLAY_BASIC', '');
     $template->set_var('ADVANCED', 'no');
     $template->set_var('ADVANCED_BUTTON', $TEXT['SHOW_ADVANCED'] . '  &gt;&gt;');
 }
 // Explode system permissions
 $system_permissions = explode(',', $group['system_permissions']);
 // Check system permissions boxes
                $type = 'folder';
            }
        }
    }
    if (isset($FILE)) {
        sort($FILE);
        foreach ($FILE as $name) {
            $temp_id++;
            if ($file_id == $temp_id) {
                $rename_file = $name;
                $type = 'file';
            }
        }
    }
}
$file_id = $admin->getIDKEY($file_id);
if (!isset($rename_file)) {
    $admin->print_error($MESSAGE['MEDIA_FILE_NOT_FOUND'], $dirlink, false);
}
// Check if they entered a new name
if (media_filename($admin->get_post('name')) == "") {
    $admin->print_error($MESSAGE['MEDIA_BLANK_NAME'], "rename.php?dir={$directory}&id={$file_id}", false);
} else {
    $old_name = $admin->get_post('old_name');
    $new_name = media_filename($admin->get_post('name'));
}
// Check if they entered an extension
if ($type == 'file') {
    if (media_filename($admin->get_post('extension')) == "") {
        $admin->print_error($MESSAGE['MEDIA_BLANK_EXTENSION'], "rename.php?dir={$directory}&id={$file_id}", false);
    } else {