You didn't insert a Google Key Yet ! Get one at www.google.com/apis/ ..";
break;
}
$www="false";
//utf8_encode() wenn posted
/*
if ($referer == "wirres.net") { $q = utf8_encode(urldecode($q)); }
else {$q=utf8_encode(htmlspecialchars($q, ENT_QUOTES));}
*/
//$q = utf8_decode(urldecode($q));
//$q = htmlspecialchars($q, ENT_QUOTES);
if ($q && $www) {
//$qs = utf8_encode($q);
$qs = $q;
if ($www != "true") { $qs.= "%20site:$yourWebsite"; }
if(!$start) { $start=0; } else { $start = intval($start); }
$parameters = array(
"key" => $yourGoogleKey, // google developer key
//"q" => $qs." inurl:article/view OR inurl:article/articleview -inurl:ste.wirres.net ", // search query
"q" => $qs, // search query
"start" => $start, // result start index
"maxResults" => 10, // 10 is the maximum
"filter" => 1, // filtering similar entries
"restrict" => "", // country and topic restrictions
"safeSearch" => false, // adult content filter
"lr" => "", // language restrictions
"ie" => "", // deprecated and ignored parameter
"oe" => "" // deprecated and ignored parameter
);
// include_once('../ez/ezping/classes/json.class.php');
$url = "https://api.datamarket.azure.com/Bing/SearchWeb/v1/Web"
."?Query=%27".urlencode($q)."%20site:$yourWebsite%20%27"
."&\$skip=".urlencode($parameters["start"])
."&\$top=".urlencode($parameters["maxResults"])
."&WebFileType=%27HTML%27"
// ."&Options=%27EnableHighlighting%27"
."&\$format=json"
;
//echo $url;
// sendRequest
// note how referer is set manually
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, ":bUDu3Gt0AoDwyjddmOIleqfomokdFoLArK+Yz2eUT50");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, 'http://wirres.net/');
$body = curl_exec($ch);
curl_close($ch);
//print_r( $body ) ;
// now, process the JSON string
$result = json_decode($body);
//print_r($result);
// get total
$url = "https://api.datamarket.azure.com/Bing/SearchWeb/v1/Composite"
."?Query=%27".urlencode($q)."%20site:$yourWebsite%20%27"
."&\$skip=".urlencode($parameters["start"])
."&\$top=".urlencode($parameters["maxResults"])
."&WebFileType=%27HTML%27"
// ."&Options=%27EnableHighlighting%27"
."&\$format=json"
;
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, ":bUDu3Gt0AoDwyjddmOIleqfomokdFoLArK+Yz2eUT50");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, 'http://wirres.net/');
$body = curl_exec($ch);
curl_close($ch);
$c_result = json_decode($body);
//$total = 100;
$total = $c_result->d->results[0]->WebTotal;
//$results = count($result->d->results);
$begin = $start + 1;
if ( ($total-$start) >= $parameters["maxResults"]) {
$end = $start + $parameters["maxResults"]; // 8 + 8
}
elseif ( ($begin-$total) <= 0 ) {
$end = $total;
}
else {
$end = $total - $start + $parameters["maxResults"];
}
// echo $result->responseData->cursor->estimatedResultCount;
//print_r($result);
}
//----------------------------------------------------------------------------------------------
// html headers, stylesheet and search form
//----------------------------------------------------------------------------------------------
// nur 1 ergebnis? weiterleiten!
if ($total == 1) {
$url = $result->d->results[0]->Url;
$referer = "http://wirres.net/suche/index.php&q=".$q;
Header( "Referer: $referer" );
Header( "Location: $url" );
exit;
} else {
?>
';
if ($q && $www) {
//header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
$SiteTitleAppend = "suche nach „".$q."“";
if ($total>0) {
if (($total<$end) OR ($total==$end)) {
echo "suchergebnisse $begin bis $total für ".$q."
";
}
else {
echo "suchergebnisse $begin bis $end von $total für ".$q."
";
}
}
echo '';
if ($end <= $total) {
if($begin > 1) { echo "".$parameters["maxResults"]." zurück | "; }
if($end!=$total) {echo "".$parameters["maxResults"]." vor"; }
}
echo "
";
echo "\n";
if ($total == 0){
echo "nix gefunden …
\n";
}
if ($total > 0) {
// $result = $result["resultElements"];
$result = $result->d->results;
echo "";
for ($i = 0; $i < $parameters["maxResults"]; $i++) {
$element = $result[$i];
$url = $element->Url;
if (strpos($url,"widgets")) { // widget, nix anzeigen
} else {
$title = $element->Title;
$title = str_replace("- wirres, fachblog für irrelevanz","",$title);
$title = str_replace("- wirres.net, fachblog für irrelevanz","",$title);
$title = str_replace("- wirres.net","",$title);
$title = str_replace("- Wirres.net","",$title);
$title = str_replace(" - Wirres.net","",$title);
$title = str_replace("- fachdings in eigener sache","",$title);
$temp_title = explode("- wirres.", $title);
// echo "".$temp_title[0];
// if (stripos($temp_title[1],"- wi")) { $title = $temp_title[0]; }
$title = $temp_title[0];
$title = (str_replace($badwordchars,$fixedwordchars,$title));
if ($title=="") {$title="... (hier hat bing was verpasst)";}
$snippet = $element->Description;
$snippet = str_replace("privates weblog von felix schwenzel","",$snippet);
$snippet = (str_replace($badwordchars,$fixedwordchars,$snippet));
if ( ($url != "") ){
echo "- $snippet
\n";
}
}
}
echo "
";
}
echo '';
if ($end <= $total) {
if($begin > 1) { echo "".$parameters["maxResults"]." zurück | "; }
if($end!=$total) {echo "".$parameters["maxResults"]." vor"; }
}
echo ' 
';
}
//----------------------------------------------------------------------------------------------
// html credits and footer
//----------------------------------------------------------------------------------------------
?>