htmlentities($category_name,2,"UTF-8"), "[CATEGORY_PATH]" => htmlentities($category_path,2,"UTF-8")); echo strtr($TEMPLATE["HEADING"],$replace); $c_array = explode("/",$c); echo $TEMPLATE["PATH"]["HEADING"]; if (!$c){ $replace = array("[CATEGORY_NAME]" => $site_title); echo strtr($TEMPLATE["PATH"]["CURRENT_CATEGORY"],$replace); }else{ $replace = array("[CATEGORY_URL]" => $dir, "[CATEGORY_NAME]" => $site_title); echo strtr($TEMPLATE["PATH"]["CATEGORY"],$replace); if (count($c_array) > 1){ for ($x = 0; $x <= count($c_array)-2; $x++){ if ($slash) $accumulated_path .= "/"; $slash = true; $accumulated_path .= $c_array[$x]; $replace = array("[CATEGORY_URL]" => $dir."index.php?c=".$accumulated_path, "[CATEGORY_NAME]" => htmlentities($c_title_array[$x],2,"UTF-8")); echo $TEMPLATE["PATH"]["SEPARATOR"].strtr($TEMPLATE["PATH"]["CATEGORY"],$replace); }; }; $replace = array("[CATEGORY_NAME]" => htmlentities($category_name,2,"UTF-8")); echo $TEMPLATE["PATH"]["SEPARATOR"].strtr($TEMPLATE["PATH"]["CURRENT_CATEGORY"],$replace); }; echo $TEMPLATE["PATH"]["FOOTER"]; flush(); if ($use_cache){ $filename = "{$cache_directory}/browse".md5($path); if (file_exists($filename)){ if (time()- filemtime($filename) < $cache_expiration){ $cache = true; }; }; }; if (!$cache){ $url = "http://dmoz.org/{$path}"; if (strlen($path) > 0 & strpos($path,".html") === false) $url .= "/"; if((@$fp = fopen($url,"r")) != false){ $file = ""; while(!feof($fp)) { $file = $file . fread($fp, 1024); }; fclose($fp); }else{ $error = true; if ($cached){ $cache = true; }else{ $access_error = true; }; }; if (!$error){ if (!$path){ $n_blocks += 1; $n_categories += 1; $odp["categories"][$n_blocks][$n_categories]["category"] = "Adult"; $odp["categories"][$n_blocks][$n_categories]["path"] = "/Adult/"; while (eregi("()([^\n]+)()",$file,$out)){ $n_categories += 1; $odp["categories"][$n_blocks][$n_categories]["category"] = ereg_replace("(<[^>]+>)","",$out[4]); $odp["categories"][$n_blocks][$n_categories]["path"] = $out[2]; $file = substr($file,strpos($file,$out[0])+strlen($out[0])); }; }else{ while (eregi("(\[|\|)( )([^<]+)()",$file,$out)){ $n_bar += 1; $odp["bar"][$n_bar]["category"] = $out[5]; $odp["bar"][$n_bar]["path"] = $out[3]; $file = substr($file,strpos($file,$out[0])+strlen($out[0])); }; while (eregi("()([^<]+)(@?\n  \()([^\)]+)",$file,$out)){ $crossed = false; if (!strpos($out[5],"@") === false) $crossed = "@"; if (strpos($file,$out[0]) > strpos($file,"
")){ $n_blocks += 1; $n_categories = 0; }; if ($c_title_array[0] != "Adult" || $out[5] != "World"){ $n_categories += 1; $odp["categories"][$n_blocks][$n_categories]["category"] = $out[4]; $odp["categories"][$n_blocks][$n_categories]["path"] = $out[2]; $odp["categories"][$n_blocks][$n_categories]["pages"] = $out[6]; if ($crossed) $odp["categories"][$n_blocks][$n_categories]["crossed"] = $crossed; }; $file = substr($file,strpos($file,$out[0])+strlen($out[0])); }; while (eregi("(
  • )([^<]+)()([^-]+)?(- )([^\n]+)(\n)",$file,$out)){ $n_pages += 1; $odp["pages"][$n_pages]["url"] = $out[2]; $odp["pages"][$n_pages]["title"] = $out[4]; $odp["pages"][$n_pages]["description"] = $out[8]; $file = substr($file,strpos($file,$out[0])+strlen($out[0])); }; }; if ($use_cache){ if ((@$cf = fopen($filename,"w")) != false){ fwrite($cf,serialize($odp)); fclose($cf); }; }; }; }; if ($use_cache){ if ($cache){ if((@$fp = fopen($filename,"r")) != false){ $odp = unserialize(stripslashes(fread($fp,filesize($filename)))); fclose($fp); }; }; }; if ($access_error){ echo $TEMPLATE["ERROR"]; }else{ if ($odp["bar"]){ echo $TEMPLATE["BAR"]["HEADING"]; for ($x = 1; $x <= count($odp["bar"]); $x++){ $replace = array("[ITEM_NAME]" => htmlentities($odp["bar"][$x]["category"],2,"UTF-8"), "[ITEM_URL]" => $dir."index.php?c=".shorten_path($odp["bar"][$x]["path"])); echo strtr($TEMPLATE["BAR"]["ITEM"],$replace); }; echo $TEMPLATE["BAR"]["FOOTER"]; }; if ($home_path){ for ($x = 1; $x <= count($odp["categories"]); $x++){ for ($y = 1; $y <= count($odp["categories"][$x]); $y++){ if (strpos($odp["categories"][$x][$y]["path"],"/".$home_path."/") !== 0){ array_splice($odp["categories"][$x],$y-1,1); array_unshift($odp["categories"][$x],""); unset($odp["categories"][$x][0]); $y--; }; }; }; for ($x = 1; $x <= count($odp["categories"]); $x++){ if (!count($odp["categories"][$x])){ array_splice($odp["categories"],$x-1,1); array_unshift($odp["categories"],""); unset($odp["categories"][0]); $x--; }; }; }; if (count($odp["categories"])){ for ($x = 1; $x <= count($odp["categories"]); $x++){ echo $TEMPLATE["SUBCATEGORIES"]["HEADING"]; for ($y = 1; $y <= ceil(count($odp["categories"][$x])/2); $y++){ $category_pages = ($odp["categories"][$x][$y]["pages"])? "(".$odp["categories"][$x][$y]["pages"].")" : ""; $replace = array("[CATEGORY_NAME]" => htmlentities($odp["categories"][$x][$y]["category"],2,"UTF-8"), "[CATEGORY_URL]" => $dir."index.php?c=".shorten_path($odp["categories"][$x][$y]["path"]), "[@]" => $odp["categories"][$x][$y]["crossed"], "[CATEGORY_PAGES]" => $category_pages); echo strtr($TEMPLATE["SUBCATEGORIES"]["CATEGORY"],$replace); }; echo $TEMPLATE["SUBCATEGORIES"]["BETWEEN_COLUMNS"]; for ($y = ceil(count($odp["categories"][$x])/2)+1; $y <= count($odp["categories"][$x]); $y++){ $category_pages = ($odp["categories"][$x][$y]["pages"])? "(".$odp["categories"][$x][$y]["pages"].")" : ""; $replace = array("[CATEGORY_NAME]" => htmlentities($odp["categories"][$x][$y]["category"],2,"UTF-8"), "[CATEGORY_URL]" => $dir."index.php?c=".shorten_path($odp["categories"][$x][$y]["path"]), "[@]" => $odp["categories"][$x][$y]["crossed"], "[CATEGORY_PAGES]" => $category_pages); echo strtr($TEMPLATE["SUBCATEGORIES"]["CATEGORY"],$replace); }; echo $TEMPLATE["SUBCATEGORIES"]["FOOTER"]; }; }; if (count($odp["pages"])){ $replace = array("[TOTAL_PAGES]" => count($odp["pages"]), "[CATEGORY_NAME]" => htmlentities($category_name,2,"UTF-8")); echo strtr($TEMPLATE["PAGES"]["HEADING"],$replace); for ($x = 1; $x <= count($odp["pages"]); $x++){ $odp["pages"][$x]["title"] = decode_title($odp["pages"][$x]["title"]); $replace = array("[PAGE_TITLE]" => htmlentities($odp["pages"][$x]["title"],2,"UTF-8"), "[PAGE_DESCRIPTION]" => htmlentities($odp["pages"][$x]["description"],2,"UTF-8"), "[PAGE_URL]" => $odp["pages"][$x]["url"]); echo strtr($TEMPLATE["PAGES"]["PAGE"],$replace); }; echo $TEMPLATE["PAGES"]["FOOTER"]; }; }; echo <<
    Help build the largest human-edited directory on the web.
      Submit a Site - Open Directory Project - Become an Editor  
    EOF; $path_title_array = urldecode($path); if (get_magic_quotes_gpc()) $path_title_array = stripslashes($path_title_array); $path_title_array = str_replace("_"," ",$path_title_array); $path_title_array = explode("/",$path_title_array); $category_name = ($path)? $path_title_array[count($path_title_array)-1] : "Top"; $category_url = ($path)? "Top/{$path}/" : ""; $replace = array("[CATEGORY_NAME]" => htmlentities($category_name,2,"UTF-8"), "[CATEGORY_URL]" => $category_url); echo strtr($TEMPLATE["FOOTER"],$replace); ?>