<?php
// defaults
// this one is set to the property and should normally not be changed
$mkt = "de";
// those params MUST be defined, either here or via passing it (only true vor $max)
$type = "";
$keywords = "yahoo_" . $mkt . "_cars_1";
if (!isset($max)){$max = 2;}
$server = "http://cmxml." . $mkt . ".overture.com";
$path = "/d/search/p/yahoo/xml/" . $mkt . "/ctxt/standard/v1/";
$partner_kw = "cars";
$partner = "yahoo_xml_" . $mkt . "_ctxt_" . $partner_kw;
// this param CAN be defined, design will be 1 by default
if (!isset($design)){$design = 1;}
// this param CAN be defined, if you don't need a
// redirect just make rd an empty string
$rd = "/overture/${keywords}";
if ($type) { $rd .= "/${type}"; }
// rd must always be with leading "/" but without ending "/"
?><?php
// build the url where we get the xml from overture
$url = $server . $path;
$url .= "?mkt=${mkt}&ctxtId=${keywords}&maxCount=${max}&keywordCharEnc=latin-1";
$url .= "&outputCharEnc=latin-1&adultFilter=clean&Partner=${partner}";
if ($type) { $url .= "&type=${type}"; }
// only for debugging purposes
if (isset($debug)) { print "$url<br>\n"; }
// get and parse the xml from overture
require_once 'Yahoo/Overture/ParseOverture.php';
ovparse($url, $max, $keywords, $mkt, $rd);
// sign the redirect urls in the resultset
for( $i = 0; $i < count($ov_turl) && $i < $max; $i++) {
 $rd_url = ysig_sign_url($ov_turl[$i]);
 if ($rd_url === false) {
 unset ($ov_turl[$i]);
 } else {
 $ov_turl[$i] = $rd_url;
 }
}
?><?php 
$css1 = "<style type=\"text/css\"> ";
$css1 .= ".a {font-size:10px} ";
$css1 .= "#overture-links { ";
$css1 .= "width: 100%; ";
$css1 .= "margin: 15px 0px 2px 0px; ";
$css1 .= "background: url( http://l.yimg.com/i/i/eu/aut/e/hrule.gif ) repeat-x top; ";
$css1 .= "text-align: left; ";
$css1 .= "padding-top: 1px; ";
$css1 .= "} ";
$css1 .= "#overture-links h3, #overture-links h3 a { ";
$css1 .= "padding: 6px; ";
$css1 .= "margin-top: 1px; ";
$css1 .= "color: #666666; ";
$css1 .= "background-color: #ECF1F4; ";
$css1 .= "text-decoration: none !important; ";
$css1 .= "font-weight: normal; ";
$css1 .= "} ";
$css1 .= "#overture-links h3 a:hover { ";
$css1 .= "text-decoration: underline !important; ";
$css1 .= "} ";
$css1 .= "#overture-links .blurb { ";
$css1 .= "margin-top: 12px; ";
$css1 .= "padding: 0px 10px; ";
$css1 .= "font-size: 85%; ";
$css1 .= "} ";
$css1 .= "#overture-links a { ";
$css1 .= "text-decoration: underline; ";
$css1 .= "} ";
$css1 .= "#overture-links a.url { ";
$css1 .= "margin-top: 4px; ";
$css1 .= "color: #008000; ";
$css1 .= "text-decoration: none; ";
$css1 .= "font-weight: normal; ";
$css1 .= "} ";
$css1 .= "</style> ";
?>
<?php
$lp = $mkt;
$up = strtoupper($mkt);
$ov = "";
if ($rd) {
 $ov = "http://${mkt}.rd.yahoo.com${rd}/*";
}
$ov .= "http://searchmarketing.yahoo.de/de_DE/arp/srch.php?mkt=de&o=DE1007";
if ($rd) {
 $rd_url = ysig_sign_url($ov);
 if ($rd_url === false) {
 unset ($ov);
 } else {
 $ov = $rd_url;
 }
}
$out = "";
if ( count( $ov_title) > 0 ) {
if (preg_match("/5\.[0-9]\.[0-9]$/i",phpversion())){
for( $i = 0; $i < count( $ov_title) && $i < $max; $i++) {
 $ov_title[$i]=utf8_decode($ov_title[$i]);
 $ov_description[$i]=utf8_decode($ov_description[$i]);
}}
 if ($design == "" || $design == 1) {
 $out .= "<div id=\"overture-links\">";
 $out .= "<h3><a href=\"$ov\">Sponsorenlinks</a></h3>";
 for( $i = 0; $i < count( $ov_title) && $i < $max; $i++) {
 $out .= "<div class=\"blurb\">";
 $out .= "<a href=\"$ov_turl[$i]\">$ov_title[$i]</a><br />";
 $out .= "$ov_description[$i]<br />";
 $out .= "<a href=\"$ov_turl[$i]\" class=url>$ov_sitehost[$i]</a>";
 $out .= "</div>";
 } ### end for
 $out .= "</div>";
 } elseif ($design == 2) {
 $out .= "<div id=\"overture-links2\">";
 $out .= "<h3><a href=\"$ov\">Sponsorenlinks</a></h3>";
 $out .= "<div class=\"box\">";
 for( $i = 0; $i < count( $ov_title) && $i < $max; $i++) {
 $out .= "<div>";
 $out .= "<a href=\"$ov_turl[$i]\">$ov_title[$i]</a><br />";
 $out .= "$ov_description[$i]<br />";
 $out .= "<a href=\"$ov_turl[$i]\" class=url>$ov_sitehost[$i]</a>";
 $out .= "</div>";
 } ### end for
 $out .= "</div>";
 $out .= "</div>";
 } elseif ($design == 3) {
 $out .= "<div id=\"overture-links2\">";
 $out .= "<h3><a href=\"$ov\">Sponsorenlinks</a></h3>";
 $out .= "<div class=\"box\">";
 for( $i = 0; $i < count( $ov_title) && $i < $max; $i++) {
 $out .= "<div>";
 $out .= "<a href=\"$ov_turl[$i]\" target=\"_top\">$ov_title[$i]</a><br />";
 $out .= "$ov_description[$i]<br />";
 $out .= "<a href=\"$ov_turl[$i]\" class=url target=\"_top\">$ov_sitehost[$i]</a>";
 $out .= "</div>";
 } ### end for
 $out .= "</div>";
 $out .= "</div>";
 } elseif ($design == 4) {
if(!isset($css1)){$css1="";}
 $out .= $css1 . " ";
 $out .= "<font face=\"Arial, Helvetica, sans-serif\">";
 $out .= "<div id=\"overture-links\">";
 $out .= "<h3>Sponsorenlinks</h3>";
 $out .= "<font size=\"-1\">";
 for( $i = 0; $i < count( $ov_title) && $i < $max; $i++) {
 $out .= "<a href=\"$ov_turl[$i]\">$ov_title[$i]</a><br />";
 $out .= "$ov_description[$i]<br />";
 $out .= "<a href=\"$ov_turl[$i]\" class=url>$ov_sitehost[$i]</a>";
 if ( (($i + 1) < count($ov_title)) && (($i + 1) < $max) ) {
 $out .= "<br><br>";
 }
 } ### end for
 $out .= "</font>";
 $out .= "</div>";
 $out .= "</font>";
 
 } elseif ($design == 5) {
 ### put your second design here, and so on
 echo "this design is not defined yet!";
 } ### end if (design ...)
 $jscript = 0;
 if (yahoo_get_data(YIV_GET,'jscript',YIV_FILTER_NUMBER)) {
 $jscript = yahoo_get_data(YIV_GET,'jscript',YIV_FILTER_NUMBER);
 }
 if ($jscript == 1) {
 $out = str_replace( "'", "\'", $out);
 $out = "document.write('" . $out . "');";
 }
 echo $out;
} ### end if (count ...)
?>