<?php
error_reporting(E_ALL);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE></TITLE>
<META NAME="Generator" CONTENT="TextPad 4.6">
<META NAME="Author" CONTENT="?">
<META NAME="Keywords" CONTENT="?">
<META NAME="Description" CONTENT="?">
<LINK REL='stylesheet' TYPE='text/css' HREF='weather2travel.css'>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" VLINK="#800000" ALINK="#FF00FF" BACKGROUND="?">
<?php
//require("includes/common_functions.php");
require("includes/database_functions.php");
require("includes/affiliate_functions.php");
$rootpath = "";
$keywords = "";
$PageType = "";
$ResortID = 0;
$RegionCode = "";
$RegionType = 0;
$ResortName = "";
$RegionName = "";
echo "<TABLE border='0' CELLSPACING='0' CELLPADDING='0' width='468' align='center'>\n";
echo " <TR>\n";
echo " <TD>\n\n";
If ($keywords == "") {
$keywords = "Cheap Holiday Deals";
}
$yfeed = new CnYahooFeed("distinct_xml_uk_synd_glosupportltd", "weather2travel.com", "uk");
$feeds = $yfeed->getResults($keywords, 5);
foreach ($feeds as $feed) {
$AdvertTitle = $feed["title"];
$AdvertURL = $feed["clickUrl"];
$AdvertSite = $feed["siteHost"];
$AdvertDesc = $feed["description"];
$AdvertTitle = ConvertToHTML($AdvertTitle);
$AdvertDesc = ConvertToHTML($AdvertDesc);
echo "<div class=\"yitem\">\n";
echo " <a href=\"".$AdvertURL."\" title=\"".$AdvertTitle."\" name=\"".$AdvertTitle."\" target=\"new window 1\" class=\"ytitle\" onmouseover=\"self.status='http://".strtolower($AdvertSite)."'; return true;\" onmouseout=\"self.status=''; return true;\">".$AdvertTitle."</a><br />\n";
echo " <a href=\"".$AdvertURL."\" title=\"".$AdvertTitle."\" name=\"".$AdvertTitle."\" target=\"new window 2\" class=\"ydesc\" onmouseover=\"self.status='http://".strtolower($AdvertSite)."'; return true;\" onmouseout=\"self.status=''; return true;\">".$AdvertDesc."</a><br />\n";
echo " <a href=\"".$AdvertURL."\" title=\"".$AdvertTitle."\" name=\"".$AdvertTitle."\" target=\"new window 3\" class=\"yurl\" onmouseover=\"self.status='http://".strtolower($AdvertSite)."'; return true;\" onmouseout=\"self.status=''; return true;\">".$AdvertSite."</a><br />\n";
echo "</div>\n\n";
}
echo "</TD>\n";
//echo " <TR>\n";
//echo " <TD><img src='".$rootpath."images/weather-travel.gif' width='1' height='5' border='0' alt=''></TD>\n";
//echo " </TR>\n";
echo " <TR>\n";
echo " <TD align='right'><FONT face='verdana,helvetica,arial,ms sans serif' size='2' color='#000000'><SPAN class='size11s14'>Sponsored Listings</span></font></TD>\n";
echo " </TR>\n";
echo " </TR>\n";
echo " <TR>\n";
echo " <TD><img src='".$rootpath."images/weather-travel.gif' width='1' height='10' border='0' alt=''></TD>\n";
echo " </TR>\n";
echo " </TR>\n";
echo " <TR>\n";
echo " <TD><img src='".$rootpath."images/weather-travel.gif' width='1' height='10' border='0' alt=''></TD>\n";
echo " </TR>\n";
echo " <TR>\n";
echo " <TD bgcolor='#EEEEEE'>";
PrintAffiliateBanner($rootpath,$PageType,$ResortID,$RegionCode,$RegionType,$ResortName,$RegionName,468,60);
echo "</td>\n";
echo " </tr>\n";
echo " <TR>\n";
echo " <TD><img src='".$rootpath."images/weather-travel.gif' width='1' height='10' border='0' alt=''></TD>\n";
echo " </TR>\n";
echo "</table>\n";
/**
* Lib for fething Yahoo! feeds.
*
* Version: 1.1.0
* Requires PHP 5.x, curl
*/
class CnYahooFeed
{
const BASE_URL = "http://xml.uk.overture.com/d/search/p/standard/eu/xml/rlb/";
private $type = null;
private $partner = null;
private $market = null;
/**
* @param string $partner Partner source tag ("distinct_xml_uk_synd_smth")
* @param string $type Domain for which listings are shown ("domain.co.uk")
* @param string $mkt Geographical market ("uk")
*/
public function __construct($partner, $type, $market = "uk")
{
$this->partner = $partner;
$this->type = $type;
$this->market = $market;
}
/**
* Fetches Yahoo! feeds and returns results as accosiative arrays.
*
* @return Array Array of associative arrays containing following keys: title, description, siteHost, clickUrl.
*
* @param string $keywords The keywords for which listings will be shown ("cheap flights to malaga")
* @param int $maxCount Number of listings, (default 3)
*/
public function getResults($keywords, $maxCount = 3)
{
$affilParams = array();
$affilParams["ip"] = isset($_SERVER["REMOTE_ADDR"])
? $_SERVER["REMOTE_ADDR"]
: (isset($_SERVER["HTTP_CLIENT_IP"]) ? $_SERVER["HTTP_CLIENT_IP"] : "");
if ( isset($_SERVER["HTTP_X_FORWARDED_FOR"]) )
{
$affilParams["xfip"] = $_SERVER["HTTP_X_FORWARDED_FOR"];
}
$affilParams["ua"] = isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : "";
if ( isset($_SERVER["HTTP_REFERER"]) )
{
$affilParams["uref"] = $_SERVER["HTTP_REFERER"];
}
print_r($affilParams);
$serveUri = "http://" . (isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : "localhost") . (isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : "/");
return $this->getResultsImpl(
self::BASE_URL,
$this->market, $maxCount, "clean", $this->partner,
$this->type, $keywords,
http_build_query($affilParams),
$serveUri
);
}
/**
* Fetches Yahoo! feeds and returns results as associative arrays.
*
* @return Array Array of associative arrays containing following keys: title, description, host, url.
*
* @param string $feed Root YSM url including scheme and feed folder and without ending '/' ("http://xml.uk.overture.com/d/search/p/standard/eu/xml/rlb/")
* @param string $mkt Geographical market, "uk"
* @param int $maxCount Number of listings, 5
* @param string $adultFilter Filter adult content ("clean")
* @param string $partner Partner source tag ("distinct_xml_uk_synd_smth")
* @param string $type Domain for which listings are shown ("domain.co.uk")
* @param string $keywords The keywords for which listings will be shown ("cheap flights to malaga")
* @param string $affilData Parameter consists of the user's IP address and browser user agent ( "ip=16.143.215.234&ua=Mozilla ... +.NET+CLR+3.5.30729%29&26uref=domain.com" )
* @param string $serveUrl Url encoded web address of the root domain and page where listings are being served from ("http://www.domain.com/contact.html")
*/
private function getResultsImpl(
$feed,
$mkt, $maxCount, $adultFilter, $partner, $type,
$keywords, $affilData, $serveUrl)
{
$params = array(
"mkt" => $mkt,
"adultFilter" => $adultFilter,
"Partner" => $partner,
"type" => $type,
"maxCount" => $maxCount,
"Keywords" => $keywords,
"affilData" => $affilData,
"serveUrl" => $serveUrl
);
$url = $feed . "?" . http_build_query($params);
echo "<p>" . $url . "</p>";
$feed = $this->getUrl($url);
echo strlen($url);
if ( $feed === false || empty($feed) )
{
return array();
}
$p = new YreslibFeedParser();
$res = $p->parse($feed);
if ( $res === false )
{
return array();
}
return $res;
}
/**
* Retrieves content with curl library
*
* @param string $url Any absolute URL
* @return string Content of the requested page
*/
private function getUrl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$data = curl_exec($ch);
if ($data === false) {
echo "<p>Data fetch error: " . curl_error($ch) . "</p>";
print_r(curl_getinfo($ch));
}
echo "<pre>" . htmlentities($data) . "</pre>";
curl_close($ch);
return $data;
}
}
/**
* Yahoo! feeds parsing helper
*/
class YreslibFeedParser
{
var $_buff = null;
var $_state = "init";
var $_hasError = false;
function parse($feed)
{
$this->_buff = array();
$this->_state = "init";
$this->_hasError = false;
$xmlParser = xml_parser_create();
xml_set_element_handler($xmlParser, array(&$this, "_xml_start_element_handler"), array(&$this, "_xml_end_element_handler"));
xml_set_character_data_handler($xmlParser, array(&$this, "_xml_character_data_handler"));
$res = xml_parse($xmlParser, $feed);
xml_parser_free($xmlParser);
if ( !$res )
{
return false;
}
return $this->_buff;
}
function _xml_start_element_handler($parser, $name, $attribs)
{
switch ($name)
{
case "LISTING":
if ( $this->_state == "init" )
{
$this->_state = "listing";
$link = array(
"title" => $attribs["TITLE"],
"description" => $attribs["DESCRIPTION"],
"siteHost" => $attribs["SITEHOST"]
);
array_push($this->_buff, $link);
}
else
{
$this->_hasError = true;
}
break;
case "CLICKURL":
if ( $this->_state == "listing" )
{
$this->_state = "clickurl";
}
else
{
$this->_hasError = true;
}
break;
default:
// ignore other tags
}
}
function _xml_end_element_handler($parser, $name)
{
switch ( $name )
{
case "CLICKURL":
if ( $this->_state == "clickurl" )
{
$this->_state = "listing";
}
else
{
$this->_hasError = true;
}
break;
case "LISTING":
if ( $this->_state == "listing" )
{
$this->_state = "init";
}
else
{
$this->_hasError = true;
}
break;
default:
// ignore other closing tags
}
}
function _xml_character_data_handler($parser, $data)
{
switch ( $this->_state )
{
case "clickurl":
$this->_buff[count($this->_buff) - 1]["clickUrl"] = $data;
break;
default:
// ignore all other data
}
}
}
Function ConvertToHTML($StringValue) {
$strlength = strlen($StringValue);
$strcount = 0;
$NewString = "";
while ($strcount < $strlength){
$midstring = substr($StringValue,$strcount,1);
//echo "[".$midstring."]";
If ($midstring == "Â") {
} ElseIf ($midstring == "£") {
$NewString = $NewString."£";
} Else {
$NewString = $NewString.htmlentities($midstring);
}
$strcount = $strcount+1;
}
return $NewString;
}
?>
</BODY>
</HTML>