function get_category_info($catid)
{
    global $db_con, $mysql_table_prefix, $debug;
    $categories['main_list'] = sqli_fetch_all("SELECT * FROM " . $mysql_table_prefix . "categories ORDER BY category");
    if (is_array($categories['main_list'])) {
        foreach ($categories['main_list'] as $_val) {
            $categories['categories'][$_val['category_id']] = $_val;
            $categories['subcats'][$_val['parent_num']][] = $_val;
        }
    }
    $categories['subcats'] = $categories['subcats'][$_REQUEST['catid']];
    /* count sites */
    if (is_array($categories['subcats'])) {
        foreach ($categories['subcats'] as $_key => $_val) {
            $categories['subcats'][$_key]['count'] = sqli_fetch_all('SELECT count(*) FROM ' . $mysql_table_prefix . 'site_category WHERE 	category_id=' . (int) $_val['category_id']);
        }
    }
    /* make tree */
    $_parent = $catid;
    while ($_parent) {
        $categories['cat_tree'][] = $categories['categories'][$_parent];
        $_parent = $categories['categories'][$_parent]['parent_num'];
    }
    $categories['cat_tree'] = array_reverse($categories['cat_tree']);
    /* list category sites */
    $categories['cat_sites'] = sqli_fetch_all('SELECT url, title, short_desc FROM ' . $mysql_table_prefix . 'sites, ' . $mysql_table_prefix . 'site_category WHERE category_id=' . $catid . ' AND ' . $mysql_table_prefix . 'sites.site_id=' . $mysql_table_prefix . 'site_category.site_id order by title');
    $count = '0';
    if ($categories['cat_sites'] != '') {
        foreach ($categories['cat_sites'] as $value) {
            $mytitle = $categories['cat_sites'][$count][1];
            // try to fetch title as defined in admin settings for each site
            if ($mytitle == '') {
                //  if no personal title is available, try to take title and description from HTML header
                $thisurl = $categories['cat_sites'][$count][0];
                $sql_query = "SELECT * from " . $mysql_table_prefix . "links where url like '{$thisurl}%'";
                $result = $db_con->query($sql_query);
                if ($debug > 0 && $db_con->errno) {
                    $err_row = __LINE__ - 2;
                    printf("MySQL failure: %s\n", $db_con->error);
                    echo "<br />Invalid query causing this failure:";
                    echo "<br />{$sql_query}";
                    echo "<br />Script .../include/categoryfuncs.php aborted in row: {$err_row}.";
                    exit;
                }
                $num_rows = $result->num_rows;
                if ($num_rows) {
                    //      hopefully the webmaster included some title and description into the site header
                    $thisrow = $result->fetch_array(MYSQLI_NUM);
                    $thistitle = $thisrow[3];
                    if ($thistitle == '') {
                        //   if no HTML title available, alternative output
                        $thistitle = "No title available for this site.";
                    }
                    $thisdescr = $thisrow[4];
                    if ($thisdescr == '') {
                        //   if no HTML description available, alternative output
                        $thisdescr = "No description available for this site.";
                    }
                    //      now include HTML title and description into array, so we may output them
                    $categories['cat_sites'][$count][1] = $thistitle;
                    $categories['cat_sites'][$count]['title'] = $thistitle;
                    $categories['cat_sites'][$count][2] = $thisdescr;
                    $categories['cat_sites'][$count]['short_desc'] = $thisdescr;
                }
            }
            $count++;
        }
    }
    return $categories;
}
 // this is the standard results header
 $result = $sph_messages['Results'];
 $result = str_replace('%from', $from, $result);
 $result = str_replace('%to', $to, $result);
 $result = str_replace('%all', $total_results, $result);
 if ($elapsed) {
     $result = str_replace('%secs', $time, $result);
 } else {
     $result = preg_replace("/\\(.*?\\)/", "", $result);
     //  kill elapsed time info in result header
 }
 //  prepare result header, showing the cateory
 if ($advanced_search == 1 && $show_categories == 1 && $category) {
     // additional headline for category search results
     // fetch again the up to date catname (just to be sure)
     $tpl_['category'] = sqli_fetch_all('SELECT category FROM ' . $mysql_table_prefix . 'categories WHERE category_id=' . $category);
     $catname = $tpl_['category'][0]['category'];
     if ($catname) {
         if ($mark == 'markbold') {
             $highlight = "span class=\"mak_1\"";
         }
         if ($mark == 'markblue') {
             $highlight = "span class=\"mak_2\"";
         }
         if ($mark == 'markyellow') {
             $highlight = "span class=\"mak_3\"";
         }
         if ($mark == 'markgreen') {
             $highlight = "span class=\"mak_4\"";
         }
         if ($mark == 'markred') {
}
$checked_cat = '';
$checked_all = '';
if ($category == '-1') {
    $checked_all = 'checked="checked"';
    //  remember that last query was for all sites
} else {
    $checked_cat = 'checked="checked"';
    //  remember that last query was in category
}
if ($catid && is_numeric($catid)) {
    $result = sqli_fetch_all('SELECT * FROM ' . $mysql_table_prefix . 'categories WHERE category_id=' . (int) $_REQUEST['catid']);
    $tpl_['category'] = $result[0]['category'];
}
$has_categories = 0;
$count_level0 = sqli_fetch_all('SELECT * FROM ' . $mysql_table_prefix . 'categories WHERE parent_num=0');
if ($count_level0) {
    $has_categories = $count_level0[0]['0'];
}
$type_rem = $type;
$result_rem = $results_per_page;
$mark_rem = $mark;
$sort_rem = $sort;
$catid_rem = $catid;
$cat_rem = $category;
$query = str_replace("\\", "", $query);
//      kill remained backslash
$query = preg_replace("/&apos;/", "'", $query);
//      replace '&nbsp;' with " ' "  else: print quote_replace($query);
$query_t = str_replace("\\", "", $query_t);
//      kill remained backslash