}
    if (is_array($_GET[importfolder])) {
        foreach ($_GET[importfolder] as $var) {
            if ($handle = opendir($FILE_PATH . $var)) {
                while (false !== ($file = readdir($handle))) {
                    if ($file != "." && $file != "..") {
                        unset($MEDIA);
                        $THIS_PATH = $FILE_PATH . $var . "/" . $file;
                        // prepare data for media_savefile();
                        $MEDIA[name] = $file;
                        $MEDIA[tmp_name] = $THIS_PATH;
                        $MEDIA[type] = mime_content_type($THIS_PATH);
                        $MEDIA[size] = filesize($THIS_PATH);
                        $MEDIA_CATEGORY = $_GET[importcategory];
                        //trägt dateinamen als title ein
                        $RESULT = media_savefile($MEDIA, $MEDIA_CATEGORY, array(title => $file));
                        $cnt++;
                    }
                }
                closedir($handle);
            }
        }
    }
    $msg = $cnt . " File wurden erfolgreich importiert";
}
// ----- METHOD IMPORT LIST DIRS
if ($mode == 'import') {
    print "<form name=rex_file_import action=index.php method=get>\n";
    print "<input type=hidden name=page value=medienpool>\n";
    print "<input type=hidden name=mode value=import>\n";
    print "<input type=hidden name=method value=do>\n";
echo "<html>\r\n<head>\r\n<title>" . $REX[SERVERNAME] . " - " . $I18N->msg('pool_media') . "</title>\r\n<link rel=stylesheet type=text/css href=css/style.css>\r\n<script language=Javascript>\r\n<!--\r\nvar redaxo = true;\r\nfunction selectMedia(filename)\r\n{\r\n        opener.document.REX_FORM.{$opener_input_field}.value = filename;\r\n        self.close();\r\n}\r\nfunction openImage(image){\r\n         window.open('index.php?page=medienpool&popimage='+image,'popview','width=123,height=111');\r\n}\r\nfunction insertHTMLArea(html){\r\n        window.opener." . $insert_area . ".insertHTML(html);\r\n        self.close();\r\n\r\n}\r\n\r\n//-->\r\n</script>\r\n</head>\r\n\r\n<body bgcolor=#ffffff>\r\n\r\n<table border=0 cellpadding=5 cellspacing=0 width=100%>\r\n<tr><td colspan=3 class=grey align=right><b>" . $I18N->msg('pool_media') . " " . $REX[SERVERNAME] . "</b></td></tr>\r\n<tr><td class=greenwhite><b>\r\n\t<a href=index.php?page=medienpool&rex_file_category={$rex_file_category} class=white>" . $I18N->msg('pool_file_list') . "</a> | \r\n\t<!-- <a href=index.php?page=medienpool&mode=search class=white>Mediensuche</a> |  -->\r\n\t<a href=index.php?page=medienpool&mode=add&rex_file_category={$rex_file_category} class=white>" . $I18N->msg('pool_file_insert') . "</a> | \r\n\t<a href=index.php?page=medienpool&mode=categories class=white>" . $I18N->msg('pool_cat_list') . "</a>\r\n\t\r\n\t</b></td></tr>\r\n<tr><td colspan=3></td></tr>\r\n</table>";
// ----- MESSAGE
if ($msg != "") {
    print "<table border=0 cellpadding=5 cellspacing=0 width=100%><tr><td width=20><img src=pics/warning.gif width=16 height=16></td><td class=warning>{$msg}</td></tr></table>";
    $msg = "";
}
// ------------------------------------- Datei hinzufügen
// ----- METHOD ADD FILE
if ($media_method == 'add_file') {
    // echo $_FILES[file_new][name];
    // function in function.rex_medienpool.inc.php
    if ($_FILES[file_new][name] != "" and $_FILES[file_new][name] != "none") {
        $FILEINFOS[title] = $ftitle;
        $FILEINFOS[description] = $fdescription;
        $FILEINFOS[copyright] = $fcopyright;
        $return = media_savefile($_FILES[file_new], $rex_file_category, $FILEINFOS);
        $msg = $return[msg];
        $mode = "";
        if ($saveandexit != "" && $return[ok] == 1) {
            $file_name = $return[filename];
            if ($_SESSION[myarea] == '') {
                $js = "selectMedia('" . $file_name . "');";
            } else {
                $html_source = str_replace("###URL###", $REX[WWW_PATH] . "/files/" . $file_name, $htmlarea['default']);
                $html_source = str_replace("###FILE_NAME###", $file_name, $html_source);
                $file_ext = strrchr($file_name, ".");
                foreach ($htmlarea as $key => $var) {
                    if (eregi($file_ext, $key)) {
                        $html_source = str_replace("###URL###", $REX[WWW_PATH] . "/files/" . $file_name, $htmlarea[$key]);
                        $html_source = str_replace("###FILE_NAME###", $file_name, $html_source);
                    }