Hille schriebHaste mal einen Script-Ausschnitt, wo der $PHP_SELF bzw. die $_POST und $_GET Angaben stehen?
Vielleicht kann ich Dir helfen. #paralyzed#
Hille
Hallo Hille,
hier ist ein Codeausschnitt (ok, fast der komplette):
global $myrooturl,$searchstring,$filename;
$filename = $PHP_SELF;
?>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<?
$sponsor_file_search = "sponsor.php"; // default
$sponsor_file_browse = "sponsor.php"; // default
// replacement variables
$replace = $filename . "?browse=";
$linkstr = '<a href="';
$odp_image_path = '/img/';
$your_image_path = '';
$search_next = '<a href="search';
$search_next_replace = '<a href="' . $filename;
$searchurl = "http://search.dmoz.org/cgi-bin/search?search=";
$startstr = "<table cellspacing"; // start str to search for on the main page
$endstr = "</td></tr></table>"; // end str to search for on the main page
$startbrws = "<hr>"; // start str to search for when browsing
$endbrws = '<table width="95%" cellpadding=0'; // end str to search for when browsing
$startsrch = '<CENTER>Search:'; // start str to search for when searching
$endsrch = '<TABLE cellpadding=0'; // end str to search for when searching
$noresult = ' results found'; // feedback from dmoz.org when no sites are found
/****************************************************************************
* Some useful functions
****************************************************************************/
/**
* urlencode the link
*/
function linkencode($url) {
$odpurl = urlencode($url);
return str_replace (
array("%2F", "%26","%3A", "%3F", "%3D", "%2C"),
array("/","&",":","?","=",",")
, $odpurl);
}
/**
* Make sure incomming $browse variable is 'clean'
*/
function cleanBrowse($browse) {
if($browse == "/") return "";
else {
if(get_magic_quotes_gpc()) {
return stripslashes($browse);
} else {
return $browse;
}
}
}
/**
* Make sure incomming search variable is 'clean'
*/
function cleanSearch($search) {
return strip_tags($search);
}
/**
* Will display an error message to the webmaster
*/
function errorMsg( $msg ) {
echo "<center><table width='300' border='0' cellspacing='1' cellpadding='0' bgcolor='#000000'><tr><td>";
echo "<table width='100%' bgcolor='#CC0033' border='0' cellspacing='4' cellpadding='0'>";
echo "<tr><td align='center'><font face='Arial' size=3 color='#FFFF00'><b>ERROR</b></font><br><br>";
echo "<font face='Arial' size=2 color='#ffffff'>$msg</font>";
echo "</td></tr></table></td></tr></table></center>";
}
/**
* Will read data from dmoz, or the local cache (if enabled)
*/
function readData( $odpurl ) {
global $enable_cache, $cache_folder, $cache_timeout;
if($enable_cache) {
$filename = md5($odpurl);
$fullpath = $cache_folder."/".$filename;
if(file_exists($fullpath)) { // already cached
if($cache_timeout == 0) {
$odpurl = $fullpath;
} else {
$diff = time()-filemtime($fullpath);
if($diff > $cache_timeout) {
$savecache = true;
} else {
$odpurl = $fullpath;
}
}
} else {
$savecache = true;
}
}
if((@$fp = fopen( $odpurl, "r" )) != false) {
$html = join( "", file( $odpurl ) );
fclose ( $fp );
if($savecache) {
if((@$cf = fopen( $fullpath, "w" )) != false) {
fwrite($cf, $html);
fclose( $cf );
} else {
errorMsg("Error writing to cache!<br>Make sure the cache folder exists and is writable by this script (you may also disable the cache)");
}
}
} else {
errorMsg("Error reading data from dmoz!<br>Make sure the dmoz url is correct");
}
return $html;
}
/****************************************************************************
* Main script start
****************************************************************************/
$browse = cleanBrowse($HTTP_GET_VARS["browse"]);
$ver = $HTTP_GET_VARS["ver"];
$searchstring = $HTTP_POST_VARS["search"];
if($searchstring == "") $searchstring = $HTTP_GET_VARS["search"];
$searchstring = cleanSearch($searchstring);
$start = intval($HTTP_GET_VARS["start"]);
$morecat = htmlspecialchars($HTTP_GET_VARS["morecat"]);
if( $browse != "" ) { // the user is browsing the categories
include("includes/browse_header.php");
include("includes/" . $sponsor_file_browse);
$browselink = linkencode($rooturl.$browse);
$html = readData($browselink);
if($html != "") {
$startpos = strpos( $html, "[ <a" );
if($startpos != FALSE) $abc = TRUE;
if($abc == FALSE) $startpos = strpos( $html, $startbrws );
$html = substr( $html, $startpos, strlen($html));
if($abc == TRUE) $html = "<br><center>" . $html;
$endpos = strpos( $html, $endbrws );
$html = substr( $html, 0, $endpos );
$html = str_replace( $linkstr . "/", $linkstr . $replace . "/", $html );
$html = str_replace( '<img src="' . $odp_image_path, '<img src="' . $your_image_path, $html );
if($show_thumbnails) {
$lines = explode("
", $html);
for($i=0; $i<count($lines); $i++) {
$curline = $lines[$i] ;
if(eregi("<li><a href="(.*)">(.*)</a> - (.*)", $curline, $info)) {
$url = $info[1];
$title = $info[2];
$desc = $info[3];
if(eregi("(.*)<a", $desc, $descarr)) {
$senddesc = htmlentities($descarr[1]);
} else {
$senddesc = htmlentities($desc);
}
$gourl = $url;
if(strpos($url, $HTTP_SERVER_VARS["PHP_SELF"]) === false) {
echo "<table><tr><td width='120'><img src='http://open.thumbshots.org/image.pxf?url=$url' border='0' onload='if (this.width>50) this.border=1'></td>"
."<td><li><a href="$gourl">$title</a> - $desc.</td></tr></table>";
} else {
echo $curline;
}
} else {
echo $curline;
}
}
} else {
echo $html;
}
} else { // open failed
include("includes/404.php");
}
echo "<br><center>";
echo "<table border='0' bgcolor='#336600' cellpadding='3' cellspacing='0'>";
echo "<tr>";
echo "<td>";
echo " <table width='100%' cellpadding='2' cellspacing='0' border='0'>";
echo " <tr align='center'>";
echo " <td><font face='sans-serif, Arial, Helvetica' size='2'";
echo " color='#FFFFFF'>Hilf, das grösste von Menschen editierte";
echo " Verzeichnis des WWW zu erstellen.</font></td></tr>";
echo " <tr bgcolor='#CCCCCC' align='center'>";
echo " <td><font face='sans-serif, Arial, Helvetica' size='2'> <a";
echo " href='http://dmoz.org/cgi-bin/add.cgi?where=$browse'>URL";
echo " vorschlagen</a> - <a href='http://dmoz.org/World/Deutsch/about.html'><b>Open Directory";
echo " Project</b></a> -";
echo " <a href='http://dmoz.org/cgi-bin/apply.cgi?where=$browse'>Werde";
echo " Editor</a> </font>";
echo " </td></tr>";
echo " </table>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<br></center>";
include("includes/footer.php");
include("includes/copyright.php");
}
else if( $searchstring != "" ) { // the user is searching
include("includes/header.php");
include("includes/" . $sponsor_file_search);
$searchurl = linkencode($searchurl . $searchstring . ($start == "" ? "" : "&start=" . $start ) . ($morecat == "" ? "" : "&morecat=" . $morecat));
$html = readData( $searchurl );
if( strpos( $html, $noresult) != FALSE ) { // no results found
include("includes/no_result.php");
} else {
$startpos = strpos( $html, $startsrch );
$html = substr( $html, $startpos, strlen($html));
$endpos = strpos( $html, $endsrch );
$html = substr( $html, 0, $endpos );
$html = str_replace( $linkstr . "/", $linkstr . $replace . "/", $html );
$html = str_replace( "http://dmoz.org", "$filename?browse=", $html );
$html = str_replace( $search_next, $search_next_replace, $html );
$html = str_replace( $filename . '?browse=search?', $filename . '?', $html );
$html = str_replace( '<img src="' . $odp_image_path, '<img src="' . $your_image_path, $html );
if($show_thumbnails) {
$lines = explode("
", $html);
for($i=0; $i<count($lines); $i++) {
$curline = $lines[$i] ;
if(eregi("<li><a href="(.*)">(.*)</a> - (.*)", $curline, $info)) {
$url = $info[1];
$title = $info[2];
$desc = $info[3];
if(eregi("(.*)<a", $desc, $descarr)) {
$senddesc = htmlentities($descarr[1]);
} else {
$senddesc = htmlentities($desc);
}
$gourl = $url;
if(strpos($url, $HTTP_SERVER_VARS["PHP_SELF"]) === false) {
echo "<table border='0'><tr><td><img src='http://open.thumbshots.org/image.pxf?url=$url' border='0' onload='if (this.width>50) this.border=1'></td><td>"
."<li><a href="$gourl">$title</a> - $desc."
."</td></tr></table>";
} else {
echo $curline;
}
} else {
echo $curline;
}
}
} else {
echo $html;
}
}
include("includes/footer.php");
}
else { // show main page
include("includes/header.php");
if($rootcategory == "") {
$html = readData($rooturl);
$startpos = strpos( $html, $startstr );
$html = substr( $html, $startpos, strlen($html));
$endpos = strpos( $html, $endstr );
$html = substr( $html, 0, $endpos );
$html = str_replace( $linkstr , $linkstr . $replace, $html );
$html = str_replace( '<img src="' . $odp_image_path, '<img src="' . $your_image_path, $html );
Ich sag schon mal DANKE für Deine Bemühungen.
Gruß
juelobe