Diese Kategorie in anderen Sprachen:" if ROOT_CAT is World/Deutsch/ define('OTHER_LANG_STR', '

This category in other languages:'); // Replace "Open Directory Categories" in search results to (all search // results have the English "Open Directory Categories" phrase, even in other // languages): define('SEARCH_CATS_REPLACEMENT', 'Web Directory Categories'); // Replace "Open Directory Sites" in search results to: define('SEARCH_SITES_REPLACEMENT', 'Web Directory Sites'); // don't have to change anything below define('TOP_CAT_NAME', 'Top/'); define('STAR_IMAGE', 'images/star.png'); define('ODP_HOST', 'dmoz.org'); define('ODP_DOMAIN', 'http://dmoz.org/'); define('SEARCH_HOST', 'search.dmoz.org'); define('SEARCH_PATH', 'cgi-bin/search?search='); define('BROWSE_START', '
'); define('BROWSE_END','Search: '); define('SEARCH_END', '
' . TOP_BREADCRUMB_NAME . ' » '; for ($i = 0; $i < $cnt - 1; $i++) { $t .= urlencode($cats[$i]) . '/'; // replace underscores with spaces in link text $breadcrumb .= '' . str_replace('_', ' ', $cats[$i]) . ' » '; } // the current category can't be clickable $breadcrumb .= str_replace('_', ' ', $cats[$i]) . '
'; } // change cat to dmoz url if (substr($cat, 0, strlen(TOP_CAT_NAME)) === TOP_CAT_NAME) { $cat = substr($cat, strlen(TOP_CAT_NAME)); } else { $cat = ROOT_CAT . $cat; } // limit characters so it doesn't overload the server $search = (isset($_GET['search'])) ? substr($_GET['search'], 0, 64) : ''; if (get_magic_quotes_gpc()) { $cat = htmlspecialchars(stripslashes($cat)); $search = htmlspecialchars(stripslashes($search)); } else { $cat = htmlspecialchars($cat); $search = htmlspecialchars($search); } // read a page from dmoz function readURL($host, $url, &$str) { $fp = fsockopen($host, 80, $errno, $errstr, 10); if ($fp === false) { //echo "$errstr ($errno)
\n"; return ''; } else { // no space after "/" $out = 'GET /' . $url . ' HTTP/1.1' . "\r\n"; $out .= 'Host: ' . $host . "\r\n"; $out .= 'Connection: Close' . "\r\n\r\n"; fwrite($fp, $out); while (!feof($fp)) { $str .= fgets($fp, 8192); } fclose($fp); $section = explode("\r\n\r\n", $str, 2); $str = $section[1]; } } function readTpl($tpl) { $fp = fopen('templates/' . $tpl . '.tpl', 'r'); $content = fread($fp, filesize('templates/' . $tpl . '.tpl')); fclose($fp); return $content; } ?> <?php if ($breadcrumb !== '') { echo 'Web Directory » ' . strip_tags($breadcrumb); } elseif ($search !== '') { echo 'Web Search: ' . $search; } else { echo 'Web Directory » Main Category'; } ?>
'; $cachePath = CACHE_DIR . strtolower(str_replace('/', '!', substr($cat, 0, -1))) . '.txt'; // if cache file exists, read the cache file and display it if (file_exists($cachePath) && ENABLE_CACHE) { $fp = fopen($cachePath, 'r'); echo fread($fp, filesize($cachePath)); fclose($fp); } else // otherwise, read category from dmoz and replace dmoz data { readURL(ODP_HOST, $cat, $data); // block inappropriate categories if (strtolower(substr($cat, 0, 5)) === 'adult') { $data = ''; } // if successfully read category if ($data !== '' && substr($data, 0, 33) !== 'Page Has Moved') { // don't skip A-Z links if there are any $isAToZ = strpos($data, '[ <a href="'); if ($isAToZ !== false) { $data = '<hr><center>' . substr($data, $isAToZ); } else { $data = substr($data, strpos($data, BROWSE_START)); } // delete dmoz header and footer $data = substr($data, 0, strpos($data, BROWSE_END)); // hide "This category in other languages:" sections if ($t = strpos($data, OTHER_LANG_STR)) { $data = substr($data, 0, $t) . substr($data, strpos($data, '</table></td></tr></table>') + 27); } // remove usenet links if ($t = strpos($data, '<table cellpadding=0 cellspacing=0><tr><td width="100%" valign=top>')) { $data = substr($data, 0, $t); } // replace dmoz links with links that point to this site if (ROOT_CAT) { $data = str_replace( array( '<a href="/', '<a href="' . BROWSE_URL . TOP_CAT_NAME . ROOT_CAT, '<img src="/img/star.gif" width=15 height=16', '"><b>' . str_replace('/', ': ', ROOT_CAT) ) , array( '<a href="' . BROWSE_URL . TOP_CAT_NAME, '<a href="' . BROWSE_URL, '<img src="' . STAR_IMAGE .'"', '"><b>' ) , $data ); } else { $data = str_replace( array( '<a href="/', '<img src="/img/star.gif" width=15 height=16' ) , array( '<a href="' . BROWSE_URL, '<img src="' . STAR_IMAGE .'"' ) , $data ); } // add thumbshots // split dmoz data to an array of lines $lines = explode("\n", $data); // free memory unset($data); // the number of lines $cnt = count($lines) - 2; // remove useless bottom data ob_start(); $i = 1; // remove useless top data while ($i < $cnt && strpos($lines[$i], '://') === false) { echo $lines[$i]; $i++; } // the text between the categories and the listings if ($i !== $cnt) { echo '<!--div class="center"><strong><a href="http://www.farfarfar.com/">Free Online Games</a></strong></div-->'; } for (; $i < $cnt; $i++) { if (strpos($lines[$i], '://') === false) { echo $lines[$i]; continue; } // reformat the line $t1 = explode('</a>', substr($lines[$i], 13)); if (substr($lines[$i+1], 0, 3) === ' - ') { $t1[1] .= $lines[$i+1]; $lines[$i+1] = ''; } $t2 = explode('">', $t1[0]); echo '<table border=0 width=100%><tr><td valign=top width=100%> <img class="thumb" src="http://open.thumbshots.org/image.pxf?url=' . $t2[0] . '" alt="" align=left vspace=3 hspace=3 /><a class="link" href="http://www.sussidiario.co.uk/ssi/href.php?keyword=' . $t2[0] . '">' . $t2[1] .'</a><div class="desc">' . $t1[1] .'</div></table><p align=center><hr width=200></p>'; } if (ENABLE_CACHE) // cache file didn't exist, so write it { if (!$fp = fopen($cachePath, 'w')) { // you can chmod CACHE_DIR to 700 to prevent others from viewing the cache // files except farodp if PHP has owner permissions if (!file_exists(CACHE_DIR)) { if (!mkdir(CACHE_DIR, 0777)) { echo 'Error making cache directory'; } } else { echo 'PHP doesn\'t have write permissions. Chmod the cache directory to 777 otherwise disable caching.'; } } fwrite($fp, ob_get_contents()); fclose($fp); } } else { echo 'This page doesn\'t exist.'; } } echo '</td></tr></table>'; } elseif ($search !== '') // search { echo '<table id="Cobrand" width="780" cellspacing="0" cellpadding="0" border="0"> <tr> <td width="100%" align="left" valign="top"> <font size=2 face=Verdana color=#6699cc>'; // get queries $searchResultStart = (isset($_GET['start'])) ? (int) $_GET['start'] : ''; $searchResultCatAll = (isset($_GET['all'])) ? $_GET['all'] : 'yes'; $searchResultCat = (isset($_GET['cat'])) ? htmlspecialchars($_GET['cat']) : ''; $searchResultMoreCat = (isset($_GET['morecat'])) ? (int) $_GET['morecat'] : 0; // prevent searching the whole directory even if ROOT_CAT is enabled by typing anything other // than 'yes' or 'no' if ($searchResultCatAll !== 'yes') { $searchResultCatAll = 'no'; } // if ROOT_CAT is enabled, only search in the ROOT_CAT if ((ROOT_CAT && $searchResultCatAll !== 'no') || (substr($searchResultCat, 0, strlen(ROOT_CAT)) !== ROOT_CAT)) { $searchResultCatAll = 'no'; $searchResultCat = ROOT_CAT; } // if morecat is searched, then add morecat if ($searchResultMoreCat !== '') { $searchResultOptionalQueries = '&morecat=' . urlencode($searchResultMoreCat); } else { $searchResultOptionalQueries = ''; } // urlencode the searchstring so words with spaces are searched readURL(SEARCH_HOST, SEARCH_PATH . urlencode($search) . '&start=' . urlencode($searchResultStart) . '&all=' . urlencode($searchResultCatAll) . '&cat=' . urlencode($searchResultCat) . $searchResultOptionalQueries, $data); if (strpos($data, 'Adult')) // block inappropriate searches { $search = 'No results found'; echo '<div class="center">No results found</div>'; } elseif ($data === '' || strpos($data, '<CENTER><I>The Open Directory search is temporarily unavailable. Please try back later.</I></CENTER>')) { echo '<div class="center">Error. Currently under a heavy load. Refresh/Reload this page.</div>'; } elseif (strpos($data, 'Try your search on:') !== false) { echo str_replace('{keywords}', urlencode($search), readTpl('NoResults')); } else // if successfully read result { // delete dmoz header and footer $data = substr($data, $t = strpos($data, SEARCH_START), strpos($data, SEARCH_END) - $t); if (ROOT_CAT) { $data = str_replace( array( '<a href="' . ODP_DOMAIN . ROOT_CAT, '<a href="' . 'search?', '">' . str_replace('/', ': ', ROOT_CAT), 'Restricting Search to Category: <B>' . $searchResultCat . '</B>', 'Open Directory Categories', 'Open Directory Sites', '<img src="/img/star.gif" width=15 height=16' ), array( '<a href="' . BROWSE_URL, '<a href="' . FILENAME . '?', '">', '', SEARCH_CATS_REPLACEMENT, SEARCH_SITES_REPLACEMENT, '<img src="' . STAR_IMAGE .'"' ), $data ); } else { $data = str_replace( array( '<a href="' . ODP_DOMAIN, '<a href="' . 'search?', 'Open Directory Categories', 'Open Directory Sites', '<img src="/img/star.gif" width=15 height=16' ), array( '<a href="' . BROWSE_URL, '<a href="' . FILENAME . '?', SEARCH_CATS_REPLACEMENT, SEARCH_SITES_REPLACEMENT, '<img src="' . STAR_IMAGE .'"' ), $data ); } // add thumbshots // split dmoz data to an array of lines $lines = explode("\n", $data); // free memory unset($data); // the number of lines $cnt = count($lines) - 3; ob_start(); $i = 0; while ($i < $cnt && (!(strpos($lines[$i], '://') !== false && substr($lines[$i], 0, 7) !== '<li><b>' && substr($lines[$i], 0, 4) !== '</b>'))) { // see if the line has an external link echo $lines[$i]; $i++; } // the text between the categories and the listings echo '<!--div class="center"><strong><a href="http://www.farfarfar.com/">Free Online Games</a></strong></div-->'; for (; $i < $cnt; $i++) { // note that this is not the same as the browse thumbshots code if (!(strpos($lines[$i], '://') !== false && substr($lines[$i], 0, 7) !== '<li><b>' && substr($lines[$i], 0, 4) !== '</b>')) { echo $lines[$i]; continue; } // reformat the line $t1 = explode('</a>', substr($lines[$i], 13)); if (substr($lines[$i+1], 0, 3) === ' - ') { $t1[1] .= $lines[$i+1]; $lines[$i+1] = ''; } $t2 = explode('">', $t1[0]); echo '<table border=0 width=100%><tr><td valign=top width=100%><img class="thumb" src="http://open.thumbshots.org/image.pxf?url=' . $t2[0] . '" alt="" / align=LEFT vsapce=3 hspace=3><a class="link" href="http://www.sussidiario.co.uk/ssi/href.php?keyword=' . $t2[0] . '">' . $t2[1] .'</a><div class="desc">' . $t1[1] .'</div></td></tr></table><p align=center><hr width=200></p>'; } } echo '</td></tr></table>'; } else // main category { // replace links in the main category echo str_replace('<a href="', '<a href="' . BROWSE_URL , readTpl('MainCat')); } if (($cat === ROOT_CAT . '/') && $search === '') { echo '<script type="text/javascript"><!-- document.getElementById("dirSearchForm").search.focus(); //--></script>'; } if ($search !== '') { ?> <div class="center"> <form class="dirSearchForm" accept-charset="UTF-8" action="<?php echo FILENAME; ?>" method="get"> <input type="text" size="40" maxlength="64" name="search" class="search" value="<?php echo $search; ?>" /> <input type="hidden" name="cs" value="UTF-8" /> <input type="hidden" name="cat" value="<?php echo $cat; ?>" /> <input type="submit" class="submit" value="Search »" /> <?php if ($cat !== '' && (substr($cat, 0, strlen(ROOT_CAT)) === ROOT_CAT)) // hide if outside ROOT_CAT { ?> <br /> <input type="radio" name="all" value="yes" checked="checked" onclick="this.form.search.focus()" />the entire directory <input type="radio" name="all" value="no" onclick="this.form.search.focus()" />only in this category </form> </div> <?php } } ?> <!--hr /--> </div> <?php // You cannot remove this. See: http://dmoz.org/become_an_editor/ ?> <div id="odpAttribution"> <div class="about"> Help build the largest human-edited directory on the web. </div> <div class="links"> <a href="http://dmoz.org/cgi-bin/add.cgi?where=<?php echo ROOT_CAT . $cat; ?>">Submit a Site</a> - <a href="http://dmoz.org/about.html">Open Directory Project</a> - <a href="http://dmoz.org/cgi-bin/apply.cgi?where=<?php echo ROOT_CAT . $cat; ?>">Become an Editor</a> </div> </div> <?php // You cannot remove this. See: http://www.thumbshots.org/attribution.pxf ?> <div class="center"><a href="http://www.thumbshots.org"><img src="http://open.thumbshots.org/attribution.png" alt="Free thumbnail preview by Thumbshots.org" width="88" height="31" /></a></div> <div id="footer"> <a href="http://www.farfarfar.com/">Free Online Games</a> - Powered by <a href="http://www.farfarfar.com/scripts/odp/">FarODP</a></div> <script type="text/javascript" src="<?php echo FILENAME; ?>thumbshots.js"></script> <?echo $footer?> </body> </html>