--- import.php.orig Mon Sep 30 12:08:17 2002 +++ import.php Mon Sep 30 12:14:53 2002 @@ -144,11 +144,17 @@ $scat_index = -1; $bookmarker->url_format_check = 0; $bookmarker->url_responds_check = false; - + $utf8flag = False; + while ($line = @fgets($fd, 2048)) { + if ((strcmp('<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">', rtrim($line)) == 0) && + function_exists('iconv')) + { + $utf8flag = True; + } // URLs are recognized by A HREF tags in the NS file. - if (eregi('<A HREF="([^"]*)[^>]*>(.*)</A>', $line, $match)) + elseif (eregi('<A HREF="([^"]*)[^>]*>(.*)</A>', $line, $match)) { $url_parts = @parse_url($match[1]); if ($url_parts[scheme] == 'http' || $url_parts[scheme] == 'https' || $url_parts[scheme] == 'ftp' || $url_parts[scheme] == 'news') @@ -180,7 +186,9 @@ } $values['category'] = sprintf('|',$cid,$scid); $values['url'] = $match[1]; - $values['name'] = $match[2]; + //if iconv fails, fall back to undecoded string + $name_iconv = ($utf8flag ? iconv('UTF-8','ISO-8859-1',$match[2]) : False); + $values['name'] = ($name_iconv ? $name_iconv : $match[2]); $values['rating'] = 0; eregi('ADD_DATE="([^"]*)"',$line,$add_info); @@ -212,21 +220,24 @@ { $folder_index ++; $id = -1; + //if iconv fails, fall back to undecoded string + $folder_name_iconv = ($utf8flag ? iconv('UTF-8','ISO-8859-1',$match[1]) : False); + $folder_name = ($folder_name_iconv ? $folder_name_iconv : $match[1]); if ($folder_index == 0) { $cat_index ++; - $cat_array[$cat_index] = $match[1]; + $cat_array[$cat_index] = $folder_name; $id = $cat_index + $cat_start; } elseif ($folder_index == 1) { $scat_index ++; - $scat_array[$scat_index] = $match[1]; + $scat_array[$scat_index] = $folder_name; $id = $scat_index + $scat_start; } $folder_stack[$folder_index] = $id; - $folder_name_stack[$folder_index] = $match[1]; + $folder_name_stack[$folder_index] = $folder_name; } elseif (eregi('</DL>', $line)) {