function xtc_count_products_in_category($category_id, $include_inactive = false)
{
    $group_check = '';
    //DokuMan - 2010-03-12 - set undefined variable
    //BOF - Dokuman - 2009-09-02: do not count products when GROUP_CHECK disabled
    if (GROUP_CHECK == 'true') {
        $group_check = " AND p.group_permission_" . xtc_db_input((int) $_SESSION['customers_status']['customers_status_id']) . "=1 ";
    }
    //EOF - Dokuman - 2009-09-02: do not count products when GROUP_CHECK disabled
    $products_count = 0;
    if ($include_inactive == true) {
        //BOF - Dokuman - 2009-09-02: do not count products when GROUP_CHECK disabled
        //$products_query = "select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . $category_id . "'";
        $products_query = "select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . xtc_db_input((int) $category_id) . "'" . $group_check;
        //EOF - Dokuman - 2009-09-02: do not count products when GROUP_CHECK disabled
    } else {
        //BOF - Dokuman - 2009-09-02: do not count products when GROUP_CHECK disabled
        //$products_query = "select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . $category_id . "'";
        $products_query = "select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . xtc_db_input((int) $category_id) . "'" . $group_check;
        //EOF - Dokuman - 2009-09-02: do not count products when GROUP_CHECK disabled
    }
    $products_query = xtDBquery($products_query);
    $products = xtc_db_fetch_array($products_query, true);
    $products_count += $products['total'];
    //BOF - Dokuman - 2009-09-02: do not count products when GROUP_CHECK disabled
    if (GROUP_CHECK == 'true') {
        $group_check = " AND group_permission_" . xtc_db_input((int) $_SESSION['customers_status']['customers_status_id']) . "=1 ";
    }
    //$child_categories_query = "select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . $category_id . "'";
    $child_categories_query = "select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . xtc_db_input((int) $category_id) . "'" . $group_check;
    //EOF - Dokuman - 2009-09-02: do not count products when GROUP_CHECK disabled
    $child_categories_query = xtDBquery($child_categories_query);
    if (xtc_db_num_rows($child_categories_query, true)) {
        while ($child_categories = xtc_db_fetch_array($child_categories_query, true)) {
            $products_count += xtc_count_products_in_category($child_categories['categories_id'], $include_inactive);
        }
    }
    return $products_count;
}
function xtc_show_category($counter, $oldlevel = 1)
{
    global $foo, $categories_string, $id, $cPath;
    $level = $foo[$counter]['level'] + 1;
    //BOF +++ UL LI Verschachtelung  mit Quelltext Tab Einzügen +++
    $ul = $tab = '';
    for ($i = 1; $i <= $level; $i++) {
        $tab .= "\t";
    }
    if ($level > $oldlevel) {
        //neue Unterebene
        $ul = "\n" . $tab . '<ul class="nav nav-pills nav-stacked">' . "\n";
        $categories_string = rtrim($categories_string, "\n");
        //Zeilenumbruch entfernen
        $categories_string = substr($categories_string, 0, strlen($categories_string) - 5);
        //letztes  </li>  entfernen
    } elseif ($level < $oldlevel) {
        //zurück zur höheren Ebene
        $ul = close_ul_tags($level, $oldlevel);
    }
    //EOF +++ UL LI Verschachtelung  mit Quelltext Tab Einzügen +++
    //BOF +++ Kategorien markieren +++
    $category_path = explode('_', $cPath);
    //Kategoriepfad in Array einlesen
    //Elternkategorie markieren
    $cat_active_parent = '';
    $in_path = in_array($counter, $category_path);
    //Testen, ob aktuelle Kategorie ID im Kategoriepfad enthalten ist
    if ($in_path) {
        $cat_active_parent = " activeparent" . $level;
    }
    //Aktive Kategorie markieren
    $cat_active = '';
    $this_category = array_pop($category_path);
    //Letzter Eintrag im Array ist die aktuelle Kategorie
    if ($this_category == $counter) {
        $cat_active = " active" . $level;
    }
    //EOF +++ Kategorien markieren +++
    //BOF +++ Kategorie Linkerstellung +++
    $cPath_new = xtc_category_link($counter, $foo[$counter]['name']);
    if (trim($categories_string == '')) {
        $categories_string = "\n";
    }
    //Zeilenschaltung Codedarstellung
    $categories_string .= $ul;
    //UL LI Versschachtelung
    $categories_string .= $tab;
    //Tabulator Codedarstellung
    $categories_string .= '<li class="level' . $level . $cat_active . $cat_active_parent . '">';
    $categories_string .= '<a href="' . xtc_href_link(FILENAME_DEFAULT, $cPath_new) . '" title="' . $foo[$counter]['name'] . '">';
    $categories_string .= '<h3 class="h6">' . $foo[$counter]['name'] . '</h3>';
    //Anzeige Anzahl der Produkte in Kategorie, für bessere Performance im Admin deaktivieren
    if (SHOW_COUNTS == 'true') {
        $products_in_category = xtc_count_products_in_category($counter);
        if ($products_in_category > 0) {
            $categories_string .= '&nbsp;(' . $products_in_category . ')';
        }
    }
    $categories_string .= '</a></li>';
    $categories_string .= "\n";
    //Zeilenschaltung Codedarstellung
    //EOF  +++ Kategorie Linkerstellung +++
    //Nächste Kategorie
    if ($foo[$counter]['next_id']) {
        xtc_show_category($foo[$counter]['next_id'], $level);
    } else {
        if ($level > 1) {
            $categories_string .= close_ul_tags(1, $level);
        }
        return;
    }
}