42 $fp = fopen(
$file,
"r-");
43 while ($line=fgets($fp))
46 if (preg_match(
'/<!DOCTYPE NETSCAPE-Bookmark-file-1>/i', $line)) {
66 while ($line=fgets($fp))
69 if (preg_match(
'/<DL>/i',$line))
73 elseif (preg_match(
'/<\/DL>/i',$line))
75 $parent_id=array_pop($parent);
77 elseif (preg_match(
'/<DD>(.+)$/i',$line,$match))
82 $result[$parent_id][$id][
'description']=
$desc;
84 elseif (preg_match(
'/<DT><H3[^>]*>(.*)<\/H3>/i',$line,$match))
87 array_push($parent,$parent_id);
91 $result[$parent_id][$id]=array(
96 elseif (preg_match(
'/<DT><A HREF="([^"]*)[^>]*>(.*)<\/A>/i', $line, $match))
105 if (preg_match(
"/ADD_DATE=\"([^\"]*)/i", $line, $match)) $add_date = $match[1];
else $add_date=0;
106 if (preg_match(
"/LAST_VISIT=\"([^\"]*)/i", $line, $match)) $visited = $match[1];
else $visited=0;
107 if (preg_match(
"/LAST_MODIFIED=\"([^\"]*)/i", $line, $match)) $modified = $match[1];
else $modified=0;
108 $result[$parent_id][$id]=array(
112 'add_date'=>$add_date,
114 'modified'=>$modified,
117 elseif (preg_match(
"/<META\s+HTTP-EQUIV=\"Content-Type\".+CONTENT=\"([^\"]*)\"/i", $line, $match))
119 preg_match(
"/charset=([^ ]+)/", $match[1], $match);
134 $htmlCont=
'<!DOCTYPE NETSCAPE-Bookmark-file-1>'.
"\n";
135 $htmlCont.=
'<!-- Created by ilias - www.ilias.de -->'.
"\n";
136 $htmlCont.=
'<!-- on '.date(
'r').
' -->'.
"\n\n";
137 $htmlCont.=
'<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">'.
"\n";
138 $htmlCont.=
'<TITLE>'.ilUtil::prepareFormOutput(
$title).
'</TITLE>'.
"\n";
139 $htmlCont.=
'<H1>'.ilUtil::prepareFormOutput(
$title).
'</H1>'.
"\n\n";
140 $htmlCont.=
'<DL><p>'.
"\n";
141 foreach ($obj_ids as $obj_id) {
145 $htmlCont.=
'</DL><p>'.
"\n";
159 switch ($object[
'type'])
162 $result.=str_repeat(
"\t",$depth);
163 $result.=
'<DT><A HREF="'.ilUtil::prepareFormOutput($object[
'target']).
'" ';
164 $result.=
'ADD_DATE="'.intval(0).
'" ';
165 $result.=
'LAST_VISIT="'.intval(0).
'" ';
166 $result.=
'LAST_MODIFIED="'.intval(0).
'">';
168 if ($object[
'description']) $result.=
'<DD>'.
172 $result.=str_repeat(
"\t",$depth).
'<DT><H3 ADD_DATE="0">'.
174 if ($object[
'description']) $result.=
'<DD>'.
176 $result.=str_repeat(
"\t",$depth).
'<DL><p>'.
"\n";
181 foreach ($sub_objects as $sub_object)
188 $result.=str_repeat(
"\t",$depth).
'</DL><p>'.
"\n";
201 if (function_exists(
'html_entity_decode'))
203 $string= html_entity_decode($string,ENT_QUOTES,
"ISO-8859-15"); #NOTE: UTF-8 does not work!
207 $trans_table = array_flip(get_html_translation_table(HTML_ENTITIES, ENT_QUOTES));
208 $string = strtr($string, $trans_table );
210 $string= preg_replace(
'/&#(\d+);/me',
"chr(\\1)",$string); #decimal notation
211 $string= preg_replace(
'/&#x([a-f0-9]+);/mei',
"chr(0x\\1)",$string); #hex notation
224 if (extension_loaded(
"mbstring"))
229 mb_detect_order(
"ASCII, JIS, UTF-8, EUC-JP, SJIS, ISO-8859-15, Windows-1252");
230 $from_charset=mb_detect_encoding ($string);
232 if (strtoupper($from_charset)!=$to_charset)
234 return @mb_convert_encoding($string,$to_charset,$from_charset);