// +-----------------------------------------------------------------------+
// |                          perform actions                              |
// +-----------------------------------------------------------------------+
if (isset($_GET['action']) and isset($_GET['theme'])) {
    $page['errors'] = $themes->perform_action($_GET['action'], $_GET['theme']);
    if (empty($page['errors'])) {
        if ($_GET['action'] == 'activate' or $_GET['action'] == 'deactivate') {
            $template->delete_compiled_templates();
        }
        redirect($base_url);
    }
}
// +-----------------------------------------------------------------------+
// |                     start template output                             |
// +-----------------------------------------------------------------------+
$themes->sort_fs_themes();
$default_theme = get_default_theme();
$db_themes = $themes->get_db_themes();
$db_theme_ids = array();
foreach ($db_themes as $db_theme) {
    $db_theme_ids[] = $db_theme['id'];
}
$tpl_themes = array();
foreach ($themes->fs_themes as $theme_id => $fs_theme) {
    if ($theme_id == 'default') {
        continue;
    }
    $tpl_theme = array('ID' => $theme_id, 'NAME' => $fs_theme['name'], 'VISIT_URL' => $fs_theme['uri'], 'VERSION' => $fs_theme['version'], 'DESC' => $fs_theme['description'], 'AUTHOR' => $fs_theme['author'], 'AUTHOR_URL' => @$fs_theme['author uri'], 'PARENT' => @$fs_theme['parent'], 'SCREENSHOT' => $fs_theme['screenshot'], 'IS_MOBILE' => $fs_theme['mobile'], 'ADMIN_URI' => @$fs_theme['admin_uri']);
    if (in_array($theme_id, $db_theme_ids)) {
        $tpl_theme['STATE'] = 'active';
        $tpl_theme['IS_DEFAULT'] = $theme_id == $default_theme;