function build_cats_tree_select($tree, $ident = 0, $selected = 0)
{
    if (is_array($tree)) {
        $tree_select = "";
        foreach ($tree as $item) {
            $tree_select .= "<option value='" . $item['ctg_cat_id'] . "'" . ($selected == $item['ctg_cat_id'] ? " selected='selected'" : "") . ">" . make_ident($ident) . " " . $item['ctg_cat_title'] . "</option>";
            if (isset($item['childs'])) {
                $tree_select .= build_cats_tree_select($item['childs'], $ident + 1, $selected);
            }
        }
    } else {
        return null;
    }
    return $tree_select;
}
 function insert($info)
 {
     // First try to update an existing entry in the current servers table.
     $up = 'UPDATE ' . PREFIX . 'servers SET time=NULL';
     append_assign($up, 'name', $info);
     append_assign($up, 'info', $info);
     append_assign($up, 'ver', $info);
     append_assign($up, 'game', $info);
     append_assign($up, 'mode', $info);
     append_assign($up, 'setup', $info);
     append_assign($up, 'iwad', $info);
     append_assign($up, 'pwads', $info);
     append_assign($up, 'wcrc', $info);
     append_assign($up, 'plrn', $info);
     append_assign($up, 'map', $info);
     append_assign($up, 'nump', $info);
     append_assign($up, 'maxp', $info);
     append_assign($up, 'open', $info);
     append_assign($up, 'data0', $info);
     append_assign($up, 'data1', $info);
     append_assign($up, 'data2', $info);
     $up = $up . ' WHERE id=' . quote_smart(make_ident($info));
     $res = $this->query($up);
     if (mysql_affected_rows() > 0) {
         // Done.
         return;
     }
     // Insert it as a new entry.
     $q = 'REPLACE INTO ' . PREFIX . "servers (id, at, port, firstseentime, ";
     $q .= "time, name, info, ver, game, mode, setup, iwad, pwads, wcrc, plrn, ";
     $q .= "map, nump, maxp, open, data0, data1, data2) VALUES (";
     $q .= quote_smart(make_ident($info)) . "," . quote_smart($info['at']) . "," . quote_smart($info['port']) . ", NULL,NULL," . quote_smart($info['name']) . "," . quote_smart($info['info']) . "," . quote_smart($info['ver']) . "," . quote_smart($info['game']) . "," . quote_smart($info['mode']) . "," . quote_smart($info['setup']) . "," . quote_smart($info['iwad']) . "," . quote_smart($info['pwads']) . "," . quote_smart($info['wcrc']) . "," . quote_smart($info['plrn']) . "," . quote_smart($info['map']) . "," . quote_smart($info['nump']) . "," . quote_smart($info['maxp']) . "," . quote_smart($info['open']) . "," . quote_smart($info['data0']) . "," . quote_smart($info['data1']) . "," . quote_smart($info['data2']) . ")";
     $this->query($q);
 }