Export Bookmarks

Export Bookmarks to Browser:
Character encoding
Folder to export:
make_tree (0); $tree->print_tree (); ?>
\n"; echo "Bookmarks\n"; echo "

Bookmarks

\n"; echo "

\n"; $export = & new export; $export->make_tree ($folderid); echo "

\n"; } else if ($browser == "opera") { echo "Opera Hotlist version 2.0\n"; echo "Options: encoding = utf8, version=3\n\n"; $export = & new export; $export->make_tree ($folderid); } } class export { function export () { global $settings, $browser; # collect the folder data require_once (ABSOLUTE_PATH . "folders.php"); $this->tree = & new folder; $this->tree->folders[0] = array ('id' => 0, 'childof' => null, 'name' => $settings['root_folder_name']); global $username, $mysql; $this->browser = $browser; $this->counter = 0; # work around PHP < 5 problem # http://bugs.php.net/bug.php?id=25670 if (intval(str_replace('.', '', phpversion())) < 500) { $this->charset = 'iso-8859-1'; } else { $this->charset = set_post_charset (); } # collect the bookmark data $query = sprintf ("SELECT title, url, description, childof, id FROM bookmark WHERE user='%s' AND deleted!='1'", $mysql->escape ($username)); if ($mysql->query ($query)) { while ($row = mysql_fetch_assoc ($mysql->result)) { if (!isset ($this->bookmarks[$row['childof']])) { $this->bookmarks[$row['childof']] = array (); } array_push ($this->bookmarks[$row['childof']], $row); } } else { message ($mysql->error); } } function make_tree ($id) { if (isset ($this->tree->children[$id])) { $this->counter++; foreach ($this->tree->children[$id] as $value) { $this->print_folder ($value); $this->make_tree ($value); $this->print_folder_close (); } $this->counter--; } $this->print_bookmarks ($id); } function print_folder ($folderid) { $spacer = str_repeat (" ", $this->counter); $foldername = html_entity_decode ($this->tree->folders[$folderid]['name'], ENT_QUOTES, $this->charset); if ($this->browser == "netscape") { echo $spacer . "

" . $foldername . "

\n"; echo $spacer . "

\n"; } else if ($this->browser == "IE") { echo $spacer . '

' . $foldername . "

\n"; echo $spacer . "

\n"; } else if ($this->browser == "opera") { echo "\n#FOLDER\n"; echo "\tNAME=" . $foldername . "\n"; } } function print_folder_close () { $spacer = str_repeat (" ", $this->counter); if ($this->browser == "netscape" || $this->browser == "IE"){ echo $spacer . "

\n"; } else if ($this->browser == "opera"){ echo "\n-\n"; } } function print_bookmarks ($folderid) { $spacer = str_repeat (" ", $this->counter); if (isset ($this->bookmarks[$folderid])) { foreach ($this->bookmarks[$folderid] as $value) { $url = html_entity_decode ($value['url'], ENT_QUOTES, $this->charset); $title = html_entity_decode ($value['title'], ENT_QUOTES, $this->charset); if ($value['description'] != '') { $description = html_entity_decode ($value['description'], ENT_QUOTES, $this->charset); } else { $description = ''; } if ($this->browser == 'netscape') { echo $spacer . '

' . $title . "\n"; if ($description != '') { echo $spacer . '
' . $description . "\n"; } } else if ($this->browser == 'IE') { echo $spacer . '
' . $title . "\n"; # unfortunately description for bookmarks in MS Internet Explorer is not supported. # thats why we just ignore the output of the description here. } else if ($this->browser == 'opera') { echo "\n#URL\n"; echo "\tNAME=" . $title . "\n"; echo "\tURL=" . $url . "\n"; if ($description != "") { # opera cannot handle the \r\n character, so we fix this. $description = str_replace ("\r\n", " ", $description); echo "\tDESCRIPTION=" . $description . "\n"; } } } } } } ?>