* Just put this page in your apb root directory and call it when * logged in and it'll print out a file that you can import using Netscape compatible * browsers. (Firefox, Mozilla :P) */ include_once ('apb.php'); if (empty ($APB_SETTINGS['auth_user_id'])) header ('location: index.php'); $query = 'SELECT bookmark_title AS title, bookmark_url AS url, bookmark_description AS description, group_id FROM apb_bookmarks WHERE bookmark_deleted = 0'; $data = mysql_query ($query) or die ('Error with query: ' . mysql_error ()); $bookmarks = array (); // Sort up the bookmarks by their group_id for later when we're printing groups while ($row = mysql_fetch_assoc ($data)) { $bookmarks[$row['group_id']][] = array ( 'url' => $row['url'], 'title' => $row['title'], 'description' => $row['description'], ); } // Now for the groups $group_query = 'SELECT group_id, group_parent_id, group_title, group_description FROM apb_groups WHERE group_deleted = 0'; $group_data = mysql_query ($group_query) or die ('Error with group query: ' . mysql_error ()); $groups = array (); while ($row = mysql_fetch_assoc ($group_data)) { /* We need to know the relationsship of a subgroup if there is one * so we save the subgroup in the maingroup so we can call them * on their own when we call them. */ if (!empty ($row['group_parent_id'])) $groups[$row['group_parent_id']]['childs'][] = $row['group_id']; $groups[$row['group_id']]['data'] = array ( 'title' => $row['group_title'], 'description' => ((!empty ($row['description'])) ? $row['description'] : false), 'child' => ((!empty ($row['group_parent_id'])) ? true : false), ); } /* Prints out the bookmark itself */ function print_row_data ($arr, $iter = 0) { print str_repeat ("\t", $iter); printf ("
%s%s
", $arr['url'], $arr['title'], ((!empty ($arr['description'])) ? "\n". str_repeat ("\t", $iter +1) ."
{$arr['description']}
" : '')); print "\n"; } /* Iterates through a cathegory. * Takes the id of the cathegory to search and a number which indicates * the levels of iterations (or number of tabs we want ;) ) */ function iterate_cat ($group_id, $iter = 0) { global $groups; global $bookmarks; $cathegory = $groups[$group_id]; print str_repeat ("\t", $iter) .'

'. $cathegory['data']['title'] ."

\n". str_repeat ("\t", $iter). "

\n"; if (!empty ($cathegory['data']['description'])) print str_repeat ("\t", $iter +1) .'

'. $cathegory['data']['description'] ."
\n"; if (!empty ($bookmarks[$group_id])) { foreach ($bookmarks[$group_id] as $data) { print_row_data ($data, $iter); } } if (!empty ($cathegory['childs'])) { foreach ($cathegory['childs'] as $child_id) { iterate_cat ($child_id, $iter +1); } } print str_repeat ("\t", $iter) ."

\n"; } ?> Bookmarks

Bookmarks

\n"; foreach ($groups as $id => $stuff) { if ($stuff['data']['child']) continue; iterate_cat ($id); } print "\n"; ?>