$types = set_array($field['cards'][$i]['types'], true);
     $colors = set_array($field['cards'][$i]['colors'], true);
     $multiverseid = set_val($field['cards'][$i]['multiverseid'], true);
     $name = set_val($field['cards'][$i]['name'], true);
     $subtypes = set_array($field['cards'][$i]['subtypes'], true);
     $power = set_val($field['cards'][$i]['power'], true);
     $toughness = set_val($field['cards'][$i]['toughness'], true);
     $mana_cost = set_val($field['cards'][$i]['manaCost'], true);
     $text = set_val($field['cards'][$i]['text'], true);
     $flavor = set_val($field['cards'][$i]['flavor'], true);
     $variations = set_array($field['cards'][$i]['variations'], true);
     $image_name = set_val($field['cards'][$i]['imageName'], true);
     $cmc = set_val($field['cards'][$i]['cmc'], true);
     $rarity = set_val($field['cards'][$i]['rarity'], true);
     $artist = set_val($field['cards'][$i]['artist'], true);
     $reserved = set_val($field['cards'][$i]['reserved'], true);
     // Adding the cards to the database table
     // Implode all dis shiittt boii
     $imploded_supertypes = implode(',', $supertypes);
     $imploded_types = implode(',', $types);
     $imploded_colors = implode(',', $colors);
     $imploded_subtypes = implode(',', $subtypes);
     $imploded_variations = implode(',', $variations);
     $sql = "INSERT INTO card_database (layout, supertypes, type, types, colors,\n\t\t\t\t\t\t\tmultiverseid, name, subtypes, power, toughness, manaCost, text, flavor,\n\t\t\t\t\t\t\tvariations, imageName, cmc, rarity, artist, reserved) \n\t\t\t\t\t\tVALUES ('{$layout}',\n\t\t\t\t\t\t\t\t'{$imploded_supertypes}', \n\t\t\t\t\t\t\t\t'{$type}', \n\t\t\t\t\t\t\t\t'{$imploded_types}', \n\t\t\t\t\t\t\t\t'{$imploded_colors}',\n\t\t\t\t\t\t\t \t'{$multiverseid}',\n\t\t\t\t\t\t\t \t'{$name}', \n\t\t\t\t\t\t\t \t'{$imploded_subtypes}',\n\t\t\t\t\t\t\t\t'{$power}', \n\t\t\t\t\t\t\t\t'{$toughness}', \n\t\t\t\t\t\t\t\t'{$mana_cost}', \n\t\t\t\t\t\t\t\t'{$text}', \n\t\t\t\t\t\t\t\t'{$flavor}', \n\t\t\t\t\t\t\t\t'{$imploded_variations}', \n\t\t\t\t\t\t\t\t'{$image_name}', \n\t\t\t\t\t\t\t\t'{$cmc}', \n\t\t\t\t\t\t\t\t'{$rarity}',\n\t\t\t\t\t\t\t    '{$artist}', \n\t\t\t\t\t\t\t    '{$reserved}')";
     //$set_query = mysqli_query($link, $sql);
     if (mysqli_query($link, $sql)) {
         echo "New record created successfully";
     } else {
         echo "Error: " . $sql_set . "<br>" . mysqli_error($link);
     }
 } catch (Excepion $e) {
    function contentflexfilelist($file = '', $tpl_head = '', $tpl_dir_start = '', $tpl_row = '', $tpl_between_row = '', $tpl_dir_end = '', $tpl_foot = '', $frontendsubfolders = 'false', $modconfsubfolders = 'true', $modconfavailfolders = '', $modconfavailfiletypes = '', $modconftplbetweenrowcounter = '1', $modconftplbetweenrowcounterreset = '', $modconfdirtplon1stlevel = 'true', $modconflabelselection = '', $modconflabelsubfolders = '', $modconfslashreplacement = '/', $modconfdatetimeformat = 'Y-m-d', $modconfcomplfolderstring = 'true', $modconftreemode = 'false', $modconffiletypeiconpath = '', $modconfselectmode = '', $modconflistselectedfile = 'true', $modconfselectrights = '', $modconffilelimit = '', $modconffilesort = 'filename > ASC', $modv)
    {
        global $db;
        $cfg = sf_api('LIB', 'Config');
        $modinfo = sf_api('LIB', 'Modinfo');
        $req = sf_api('LIB', 'WebRequest');
        $pi = sf_api('LIB', 'Pageinfos');
        $idcatside = $cfg->env('idcatside');
        $lang = $cfg->env('idlang');
        $client = $cfg->env('idclient');
        $view = $cfg->env('view');
        $sess = $cfg->sess();
        $modconffilelimit = (int) $modconffilelimit;
        $modconftplbetweenrowcounter = (int) $modconftplbetweenrowcounter;
        //
        // sorting preperation
        //
        if (empty($modconffilesort)) {
            $modconffilesort = 'filename > ASC';
        }
        $filelist_filesort['array'] = array();
        $filelist_filesort['raw'] = trim(str_replace(' > ', '>', $modconffilesort));
        $filelist_filesort['raw_vals'] = explode("\n", $filelist_filesort['raw']);
        foreach ($filelist_filesort['raw_vals'] as $v) {
            $filelist_filesort['sorting_pieces'] = explode('>', trim($v));
            $filelist_filesort['array'][] = $filelist_filesort['sorting_pieces']['0'] . ' ' . $filelist_filesort['sorting_pieces']['1'];
        }
        // get content id
        $sql = "SELECT\r\n\t\t\t\t\tidcontent\r\n\t\t\t\tFROM\r\n\t\t\t\t\t" . $cfg->db('content') . "\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tidsidelang='" . $pi->getIdsidelang($idcatside) . "'\r\n\t\t\t\t\tAND container='" . $modinfo->getIdContainer() . "'\r\n\t\t\t\t\tAND number='" . $modinfo->getEntryNr() . "'";
        $db->query($sql);
        $db->next_record();
        $entry_content_id = "id" . $db->f('idcontent');
        $filelist_output = '';
        if ($modconfselectmode == 'fsb') {
            $file = '';
            $mod['cf_fl_dir'] = get_val('cf_fl_folder_' . $entry_content_id);
            $mod['cf_fl_subdirs'] = get_val('cf_fl_show_subfolders_' . $entry_content_id);
            if ($modconfsubfolders != 'true') {
                $mod['cf_fl_subdirs'] = 0;
            }
        }
        $filelist_dirs_all = array();
        $sql = "SELECT \r\n\t\t\t\t\t*\r\n\t\t\t\tFROM\r\n\t\t\t\t\t" . $cfg->db('directory') . "\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tidclient=" . $client . "\r\n\t\t\t\t\tAND status=0 ";
        $db->query($sql);
        while ($db->next_record()) {
            $filelist_dirs_all[$db->f('iddirectory')] = $db->f('dirname');
        }
        if (!empty($file) && $modconfselectmode == 'rb') {
            $selected_file = basename($file);
        }
        // get base-path
        if (!empty($file)) {
            $filelist_path = str_replace($cfg->env('path_frontend_fm'), '', dirname($file)) . "/";
        }
        if (empty($file) || $modconfselectmode == 'fsb') {
            $sql = "SELECT * FROM " . $cfg->db('directory') . " WHERE idclient=" . $client . " AND status=0 ";
        } elseif ($frontendsubfolders == "true") {
            $sql = "SELECT * FROM " . $cfg->db('directory') . " WHERE idclient=" . $client . " AND dirname like '{$filelist_path}%' AND  status=0 ";
        } else {
            $sql = "SELECT * FROM " . $cfg->db('directory') . " WHERE idclient=" . $client . " AND dirname like '{$filelist_path}' AND  status=0 ";
        }
        // filter modulconfig selected pathes
        if ($modconfavailfolders != '' && $modconfavailfolders != 'true') {
            $thisdirsonly = array();
            $thisdirsonly = explode(',', $modconfavailfolders);
            $sql_addondirs = array();
            foreach ($thisdirsonly as $k => $v) {
                $sql_addondirs[] = " dirname like '" . $filelist_dirs_all[$v] . ($modconfsubfolders == 'true' ? '%' : '') . "' ";
            }
            $sql_addon = implode('OR', $sql_addondirs);
        } else {
            $sql_addon = '';
        }
        // get dir(s)
        $filelist_dirs = array();
        // filter modulconfig selected pathes
        if (!empty($sql_addon)) {
            $sql .= " AND (" . $sql_addon . ")";
        }
        $db->query($sql);
        while ($db->next_record()) {
            $filelist_dirs[$db->f('iddirectory')] = $db->f('dirname');
        }
        natsort($filelist_dirs);
        // frontendselectbox
        if ($modconfselectmode == 'fsb') {
            if ($sess->name == 'sefrengo' && $view == 'edit' && _type_check_editable($modconfselectrights)) {
                $cf_fl_subdirs = $req->post($entry_content_id . 'cf_fl_subdirs');
                $cf_fl_dir = $req->post($entry_content_id . 'cf_fl_dir');
                if ($cf_fl_dir != '' && $mod['cf_fl_dir'] != $cf_fl_dir) {
                    set_val('cf_fl_folder_' . $entry_content_id, $cf_fl_dir);
                    $mod['cf_fl_dir'] = $cf_fl_dir;
                }
                if ($req->post($entry_content_id . 'cf_fl_dir') != '' && !$cf_fl_subdirs && $mod['cf_fl_subdirs'] != 0) {
                    set_val('cf_fl_show_subfolders_' . $entry_content_id, 0);
                    $mod['cf_fl_subdirs'] = 0;
                } else {
                    if ($req->post($entry_content_id . 'cf_fl_dir') != '' && $cf_fl_subdirs != '' && $mod['cf_fl_subdirs'] != 1) {
                        set_val('cf_fl_show_subfolders_' . $entry_content_id, 1);
                        $mod['cf_fl_subdirs'] = 1;
                    }
                }
                // form
                $fsb_out = "\n" . '<form style="font-size:8pt;" class="contentflex_fl_form" method="post" name="' . $entry_content_id . '" action="' . $con_side[$idcatside]['link'] . '">' . "\n";
                $fsb_out .= '<label class="contentflex_fl_select_label" for="' . $entry_content_id . 'cf_fl_dir">' . $modconflabelselection . '</label>' . "\n" . '
										<select id="' . $entry_content_id . 'cf_fl_dir"  class="contentflex_fl_select" name="' . $entry_content_id . 'cf_fl_dir" size="1" onchange="document.' . $entry_content_id . '.submit();">' . "\n";
                if ($mod['cf_fl_dir'] == '0') {
                    $fsb_out .= '<option value="0" selected>----------------</option>' . "\n";
                } else {
                    $fsb_out .= '<option value="0">----------------</option>' . "\n";
                }
                foreach ($filelist_dirs as $k => $v) {
                    if ($v == $mod['cf_fl_dir']) {
                        $fsb_out .= '<option value="' . $v . '" selected>' . htmlentities($v, ENT_COMPAT, 'UTF-8') . '</option>' . "\n";
                    } else {
                        $fsb_out .= '<option value="' . $v . '">' . htmlentities($v, ENT_COMPAT, 'UTF-8') . '</option>' . "\n";
                    }
                }
                $fsb_out .= '</select>' . "\n";
                if ($modconfsubfolders == 'true') {
                    $fsb_out .= '<input id="' . $entry_content_id . 'cf_fl_subdirs" class="contentflex_fl_checkbox" type="checkbox" name="' . $entry_content_id . 'cf_fl_subdirs" value="checkbox" ' . ($mod['cf_fl_subdirs'] == 1 ? 'checked="checked"' : '') . ' onclick="document.' . $entry_content_id . '.submit();"/>' . "\n" . '<label class="contentflex_fl_checkbox_label" for="' . $entry_content_id . 'cf_fl_subdirs">' . $modconflabelsubfolders . '</label>' . "\n";
                }
                $fsb_out .= '</form>' . "\n";
            }
        }
        if (empty($mod['cf_fl_dir']) && $modconfselectmode == 'fsb') {
            return $fsb_out;
        } elseif (empty($file) && $modconfselectmode != 'fsb') {
            return;
        }
        // get files
        if (!empty($filelist_dirs)) {
            if (count($filelist_dirs) > 0) {
                $sql_addon = " U.iddirectory IN (" . implode(',', array_keys($filelist_dirs)) . ")";
            }
            $sql = "SELECT\r\n                                    U.*,\r\n                                    UNIX_TIMESTAMP(U.lastmodified) AS lastmodified,\r\n                                    UNIX_TIMESTAMP(U.created) AS created,\r\n                                    UL.*\r\n                                FROM\r\n                                        " . $cfg->db('upl') . " U\r\n                                LEFT JOIN\r\n                                        " . $cfg->db('upl_lang') . " UL\r\n                                        USING(idupl)\r\n                                WHERE " . $sql_addon . "\r\n                                ORDER BY\r\n                                        " . implode(',', $filelist_filesort['array']);
            $db->query($sql);
            while ($db->next_record()) {
                $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['filename'] = $db->f('filename');
                $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['title'] = $db->f('title');
                $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['description'] = $db->f('description');
                $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['filesize'] = $db->f('filesize');
                $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['pictwidth'] = $db->f('pictwidth');
                $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['pictheight'] = $db->f('pictheight');
                $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['pictthumbwidth'] = $db->f('pictthumbwidth');
                $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['pictthumbheight'] = $db->f('pictthumbheight');
                $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['iddirectory'] = $db->f('iddirectory');
                $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['idfiletype'] = $db->f('idfiletype');
                $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['idfile'] = $db->f('idupl');
                $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['created'] = date($modconfdatetimeformat, $db->f('created'));
                $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['lastmodified'] = date($modconfdatetimeformat, $db->f('lastmodified'));
            }
            // get filetypes
            $sql = "SELECT * FROM " . $cfg->db('filetype');
            $db->query($sql);
            $filelist_filetypes = array();
            while ($db->next_record()) {
                $filelist_filetypes[$db->f('idfiletype')]['filetype'] = $db->f('filetype');
                $filelist_filetypes[$db->f('idfiletype')]['filetypepict'] = $db->f('filetypepict');
                $filelist_filetypes[$db->f('idfiletype')]['filetypedesc'] = $db->f('description');
                $filelist_filetypes[$db->f('idfiletype')]['filemimetype'] = $db->f('mimetype');
            }
            // ouput creation
            $filelist_output = $fsb_out . $tpl_head;
            $tpl_dir_end_collected = '';
            $dir_count = 0;
            $file_count = 0;
            $filelist_dir_level_mem = 0;
            $all_count = 0;
            $all_file_count = 0;
            $dirname_mem = '';
            $new_dir_name = '';
            if (strpos($modconfavailfiletypes, ',') !== false) {
                $filetypes = explode(',', strtolower($modconfavailfiletypes));
            }
            // list creation
            foreach ($filelist_dirs as $k => $v) {
                // filtering
                if (strpos($v, $mod['cf_fl_dir']) !== false && $modconfselectmode == 'fsb' && $mod['cf_fl_subdirs'] == 1 || $modconfselectmode == 'fsb' && $mod['cf_fl_subdirs'] == 0 && strpos($v, $mod['cf_fl_dir']) !== false && strlen($v) == strlen($mod['cf_fl_dir']) || !empty($file)) {
                    $dir_count++;
                    $all_count++;
                    if ($dir_count > 1 || $modconfdirtplon1stlevel != 'false') {
                        $tpl_dir_output = str_replace('{dir_no}', $dir_count, $tpl_dir_start);
                        $tpl_dir_output = str_replace('{all_no}', $all_count, $tpl_dir_output);
                        if ($modconfcomplfolderstring == "false" && substr_count($filelist_dirs[$k], '/') > 1) {
                            $new_dir_name = substr(strrchr(substr($filelist_dirs[$k], 0, -1), "/"), 1) . '/';
                        } else {
                            $new_dir_name = $filelist_dirs[$k];
                        }
                        $filelist_output .= str_replace('{dirname}', str_replace('/', $modv['MOD_VALUE_2005'], $new_dir_name), $tpl_dir_output);
                    }
                    if (is_array($filelist_files[$k])) {
                        foreach ($filelist_files[$k] as $v1) {
                            $mod['thumbfile_ext'] = substr(strrchr($v1['filename'], "."), 1);
                            if ((strpos($modconfavailfiletypes, strtolower($mod['thumbfile_ext'])) !== false || $modconfavailfiletypes == "true" || empty($modconfavailfiletypes)) && ($modconfselectmode != 'rb' || $modconflistselectedfile != 'false' || $modconflistselectedfile == 'false' && strpos($v1['filename'], $selected_file) === false)) {
                                $file_count++;
                                $all_file_count++;
                                $all_count++;
                                if ($all_file_count <= $modconffilelimit || $modconffilelimit == 0) {
                                    $filelist_output_row = $tpl_row;
                                    $filelist_output_row_array = array();
                                    $filelist_output_row_array['all_no'] = $all_count;
                                    $filelist_output_row_array['file_no'] = $file_count;
                                    $filelist_output_row_array['file_no_rev'] = count($filelist_files[$k]) - $file_count;
                                    $filelist_output_row_array['all_file_no'] = $all_file_count;
                                    $filelist_output_row_array['dir_no'] = $dir_count;
                                    $filelist_output_row_array['dirname'] = str_replace($dirname_mem, '', str_replace('/', $modv['MOD_VALUE_2005'], $new_dir_name));
                                    $filelist_output_row_array['filepath'] = $cfg->env('path_frontend_fm_http') . $filelist_dirs[$k];
                                    $filelist_output_row_array['filename'] = $v1['filename'];
                                    $filelist_output_row_array['fileurl'] = 'cms://idfile=' . $v1['idfile'];
                                    $filelist_output_row_array['file'] = '<a href="cms://idfile=' . $v1['idfile'] . '">cms://idfile=' . $v1['idfile'] . '</a>';
                                    $filelist_output_row_array['filefmtitle'] = $v1['title'];
                                    $filelist_output_row_array['filefmdesc'] = $v1['description'];
                                    $filelist_output_row_array['filecreated'] = $v1['created'];
                                    $filelist_output_row_array['filemodified'] = $v1['lastmodified'];
                                    // filesize
                                    if ($v1['filesize'] > 1048576) {
                                        $v1['filesize'] = sprintf("%01." . $modv['val_fsplaces'] . "f", $v1['filesize'] / 1048576) . ' ' . $modv['str_megabyte'];
                                    } else {
                                        $v1['filesize'] = $v1['filesize'] > 1024 ? sprintf("%01." . $modv['val_fsplaces'] . "f", $v1['filesize'] / 1024) . ' ' . $modv['str_kilobyte'] : $v1['filesize'] . ' ' . $modv['str_byte'];
                                    }
                                    $filelist_output_row_array['filesize'] = $v1['filesize'];
                                    //thumburl
                                    $mod['thumbfile'] = substr($v1['filename'], 0, -strlen($mod['thumbfile_ext']) - 1) . $cfg->client('thumbext') . '.' . $mod["thumbfile_ext"];
                                    $filelist_output_row_array['imagethumb'] = '<img src="' . $cfg->env('path_frontend_fm_http') . $filelist_dirs[$k] . $mod['thumbfile'] . '" height="' . $v1['pictthumbheight'] . '" width="' . $v1['pictthumbwidth'] . '"/>';
                                    $filelist_output_row_array['imagethumburl'] = $cfg->env('path_frontend_fm_http') . $filelist_dirs[$k] . $mod['thumbfile'];
                                    $filelist_output_row_array['imagewidth'] = $v1['pictwidth'];
                                    $filelist_output_row_array['imageheight'] = $v1['pictheight'];
                                    $filelist_output_row_array['imagethumbwidth'] = $v1['pictthumbwidth'];
                                    $filelist_output_row_array['imagethumbheight'] = $v1['pictthumbheight'];
                                    $filelist_output_row_array['imagethumbhalfwidth'] = round($v1['pictthumbwidth'] / 2);
                                    $filelist_output_row_array['imagethumbhalfheight'] = round($v1['pictthumbheight'] / 2);
                                    $filelist_output_row_array['iddirectory'] = $v1['iddirectory'];
                                    $filelist_output_row_array['filetypeicon'] = '<img src="' . $modconffiletypeiconpath . $filelist_filetypes[$v1['idfiletype']]['filetypepict'] . '" alt=""/>';
                                    $filelist_output_row_array['filetypeiconurl'] = $modconffiletypeiconpath . $filelist_filetypes[$v1['idfiletype']]['filetypepict'];
                                    $filelist_output_row_array['filetype'] = $filelist_filetypes[$v1['idfiletype']]['filetype'];
                                    $filelist_output_row_array['filetypeiconname'] = $filelist_filetypes[$v1['idfiletype']]['filetypepict'];
                                    $filelist_output_row_array['filetypedesc'] = $filelist_filetypes[$v1['idfiletype']]['filetypedesc'];
                                    $filelist_output_row_array['filemimetype'] = $filelist_filetypes[$v1['idfiletype']]['filemimetype'];
                                    foreach ($filelist_output_row_array as $k2 => $v2) {
                                        // global if-statement
                                        if (strpos($filelist_output_row, '{if_' . $k2 . '}') !== false) {
                                            if (empty($v2)) {
                                                $filelist_output_row = preg_replace('#\\{if_' . $k2 . '\\}(.*)\\{/if_' . $k2 . '\\}#sU', '', $filelist_output_row);
                                            } else {
                                                $filelist_output_row = str_replace(array('{if_' . $k2 . '}', '{/if_' . $k2 . '}'), array('', ''), $filelist_output_row);
                                            }
                                        }
                                        // global if-not-statement
                                        if (strpos($filelist_output_row, '{if_not_' . $k2 . '}') !== false) {
                                            if (empty($v2)) {
                                                $filelist_output_row = str_replace(array('{if_not_' . $k2 . '}', '{/if_not_' . $k2 . '}'), array('', ''), $filelist_output_row);
                                            } else {
                                                $filelist_output_row = preg_replace('#\\{if_not_' . $k2 . '\\}(.*)\\{/if_not_' . $k2 . '\\}#sU', '', $filelist_output_row);
                                            }
                                        }
                                        // global if-statement
                                        if (strpos($filelist_output_row, '{if_' . $k2 . '=') !== false) {
                                            preg_match_all('/\\{if_' . $k2 . '=(.*?)\\}/', $filelist_output_row, $modv['temp_results']);
                                            foreach ($modv['temp_results'][0] as $ek => $ev) {
                                                if ($v2 != $modv['temp_results'][1][$ek]) {
                                                    $filelist_output_row = preg_replace('#\\{if_' . $k2 . '=' . $modv['temp_results'][1][$ek] . '\\}(.*)\\{/if_' . $k2 . '=' . $modv['temp_results'][1][$ek] . '\\}#sU', '', $filelist_output_row);
                                                } else {
                                                    $filelist_output_row = str_replace(array('{if_' . $k2 . '=' . $modv['temp_results'][1][$ek] . '}', '{/if_' . $k2 . '=' . $modv['temp_results'][1][$ek] . '}'), array('', ''), $filelist_output_row);
                                                }
                                            }
                                        }
                                        // global if-not-statement
                                        if (strpos($filelist_output_row, '{if_not_' . $k2 . '=') !== false) {
                                            preg_match_all('/\\{if_not_' . $k2 . '=(.*?)\\}/', $filelist_output_row, $modv['temp_results']);
                                            foreach ($modv['temp_results'][0] as $ek => $ev) {
                                                if ($v2 != $modv['temp_results'][1][$ek]) {
                                                    $filelist_output_row = str_replace(array('{if_not_' . $k2 . '=' . $modv['temp_results'][1][$ek] . '}', '{/if_not_' . $k2 . '=' . $modv['temp_results'][1][$ek] . '}'), array('', ''), $filelist_output_row);
                                                } else {
                                                    $filelist_output_row = preg_replace('#\\{if_not_' . $k2 . '=' . $modv['temp_results'][1][$ek] . '\\}(.*)\\{/if_not_' . $k2 . '=' . $modv['temp_results'][1][$ek] . '\\}#sU', '', $filelist_output_row);
                                                }
                                            }
                                        }
                                        $filelist_output_row = str_replace('{' . $k2 . '}', $v2, $filelist_output_row);
                                    }
                                    $filelist_output .= $filelist_output_row;
                                    if ($modconftplbetweenrowcounter > 0) {
                                        if ($modconftplbetweenrowcounterreset == 1) {
                                            if ($file_count % $modconftplbetweenrowcounter == 0) {
                                                $filelist_output .= $tpl_between_row;
                                            }
                                        } else {
                                            if ($all_file_count % $modconftplbetweenrowcounter == 0) {
                                                $filelist_output .= $tpl_between_row;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    $filelist_output = str_replace('{file_count}', $file_count, $filelist_output);
                    $file_count = 0;
                    // tree mode?
                    if ($dir_count > ($modconftreemode == 'false' ? 1 : 0) || $modconfdirtplon1stlevel != 'false') {
                        if ($modconftreemode != "false") {
                            if (substr_count($filelist_dirs[$k], '/') - $filelist_dir_level_mem != 0 && $filelist_dir_level_mem != 0) {
                                $filelist_output .= $tpl_dir_end;
                            } else {
                                $tpl_dir_end_collected .= $tpl_dir_end;
                            }
                        } else {
                            $filelist_output .= $tpl_dir_end;
                        }
                        $filelist_dir_level_mem = substr_count($filelist_dirs[$k], '/');
                    }
                    unset($mod['thumbfile_ext'], $mod['thumbfile']);
                }
            }
            $filelist_output .= $tpl_dir_end_collected;
            $filelist_output .= $tpl_foot;
        }
        return $filelist_output;
    }