Da ich gerade wieder ein paar Dinge bei eBay versteigere, habe ich nach einer Möglichkeit gesucht, meine Auktionen als RSS/RDF-Feed auf meine HP zu bringen.
Gelungen ist mir das mit einer Kombination aus dem ebayfeed-PHP-Skript von Alexander Turcic (http://www.mobileread.com) und dem von mir modifzierten RDF-Parser von http://www.x28.de. Zu bestaunen unter http://www.kashban.de.
Benötigt wird folgendes:
ebayfeed_de.php und config.inc (im gleichen Verzeichnis, z.b. contenido/external/ebayfeed/)
Code: Alles auswählen
<?php
/**
* ebayfeed.php
*
* Note: This script requires CURL support in your PHP installation
*
* @author Alexander Turcic (http://www.mobileread.com)
*
* @version 1.12, 11/12/04
* @version 1.11, 10/29/04
* @version 1.10, 09/01/04
* @version 1.00, 08/16/04
*
* This work is licensed under the Creative Commons Attribution License.
*
* To view a copy of this license, visit
*
* http://creativecommons.org/licenses/by/2.0/
*
* or send a letter to:
*
* Creative Commons
* 559 Nathan Abbott Way
* Stanford, California 94305, USA.
*
*/
define('RELEASE', 'eBayFeed/1.12');
define('GENERATOR', RELEASE . ' (+http://www.mobileread.com/)');
function parse_ebay_ini($filename, $process_sections = false)
{
$ini_array = array();
$sec_name = "";
$lines = file($filename);
foreach($lines as $line) {
$line = trim($line);
if (($line == "") || ($line[0] == ";" )) {
continue;
}
if ($line[0] == "[" && $line[strlen($line) - 1] == "]") {
$sec_name = substr($line, 1, strlen($line) - 2);
} else {
$pos = strpos($line, "=");
$property = trim(substr($line, 0, $pos));
$value = trim(substr($line, $pos + 1));
if ($process_sections) {
$ini_array[$sec_name][$property] = $value;
} else {
$ini_array[$property] = $value;
}
}
}
return $ini_array;
}
function display_form() {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title><?php echo RELEASE ?></title>
<meta name="description" content="eBayFeed converts custom eBay searches into RSS 2.0 feeds" />
<meta name="keywords" content="eBayFeed, ebay, rss, feed, blogs" />
<style type="text/css">
body {
margin: 0em;
padding: 0em;
font:12px/1.3 Verdana,Geneva,Arial,Helvetica,sans-serif;
color: black;
}
#title {
padding: 0.5em;
color: white;
background-color: #003471; }
#container {
border: 1px solid #888888; border-width: 0 0 1px 1px;
margin-left: 146px;
padding: 1em 0 0.5em 2em;}
#container h3 {
padding: 0;
margin: 0 0 1.2em 0;
font-size: 1.2em; }
#container p {
margin: 0 10% 1.5em 0; }
#container a:link {
color: #000; text-decoration: underline; }
#container a:visited {
color: #000; text-decoration: underline; }
#container a:link:hover {
color: #888; text-decoration: underline;}
#container a:visited:hover {
color: #888;}
.smallcap {
font-variant: small-caps;}
.yellbox {
padding: 1.0em;
margin: 0 10% 1.5em 0;
color: black;
background-color: #F3F324; }
.right {
text-align: right; }
</style>
</head>
<body>
<div id="title">
<h1>
<?php echo RELEASE ?>
</h1>
</div>
<div id="container">
<h3>Welcome to <span class="smallcap"><?php echo RELEASE ?></span>!</h3>
<p><?php echo RELEASE ?> allows you to create customized RSS 2.0 feeds of your favorite eBay searches. It offers several advantages to other eBay-to-RSS solutions:</p>
<ul>
<li>is fully customizable and extensible (open-source)</li>
<li>supports eBay platforms of other countries (take a look at <em>config.inc</em>)</li>
<li>can run on your own server</li>
<li>doesn't log your clicks on items, nor does it advertise your search habits to others (such as qksrv.net)</li>
<li>allows you to fully utilize eBay's advanced search forms</li>
</ul>
<p><?php echo RELEASE ?> was written in PHP and <strong>requires</strong> the cURL extension.</p>
<h3><strong>How to use:</strong></h3>
<p>If you know exactly what you're looking for, just type a few words into the search box on eBay's home page. You can also use eBay's more <a href="http://search.ebay.com/_W0QQtZvbQQsofindtypeZ1">advanced options</a> to customize your search as needed.</p>
<p>When you get to the page with the search results, copy & paste the entire url in the box below. Then hit 'Submit Query'. </p>
<?php
if (isset($_POST['query'])) {
// 1. Parse query entered by the user
if (!$eBay = @parse_ebay_ini('config.inc', 1)) $feedback = "<div class=\"yellbox\">Couldn't find or open <i>config.inc</i>.</div>";
else
{
$url = trim($_POST['query']);
foreach ($eBay as $country => $countryspecific) {
if (preg_match("#^$countryspecific[url]#i", $url)) {
preg_match("#^$countryspecific[url]/(.+?)(_W0QQ|$)#i", $url, $keywords);
break;
}
}
if (!isset($keywords)) {
$feedback = "<div class=\"yellbox\">Something went wrong processing your url. The following eBay platforms are currently added to your <i>config.inc</i>:<br />";
foreach ($eBay as $country => $countryspecific) {
$feedback .= "$countryspecific[name], ";
}
$feedback = substr($feedback, 0, -2);
$feedback .= "</div>";
}
else {
$url = base64_encode($url);
$feedback = "<div class=\"yellbox\">Add this <strong><a href=\"http://$_SERVER[HTTP_HOST]$_SERVER[PHP_SELF]?feed=$url\">Feed</a></strong> to your favorite feed aggregator for tracking <strong>'$keywords[1]'</strong> on <strong>$countryspecific[name]</strong>.</div>";
}
}
}
?>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<p><input type="text" name="query" size="50" /></p>
<p><input type="submit" name="submit" /></p>
</form>
<?php echo $feedback ?>
<h3>History:</h3>
<p>1.12, 11/12/04 eBay globally standardized Sotheby removal, required fix in config <br />
1.11, 10/29/04 eBay USA removed Sothebys option, required fix in config <br />
1.10, 09/01/04 eBay globally standardized its time output (some code + regex changes) <br />
1.00, 08/16/04 first release</p>
<h3>To do's:</h3>
<ul>
<li>support for other feed formats (ATOM, ...)</li>
<li>MySQL database backend</li>
<li>gzip support </li>
<li>you name it!</li>
</ul>
<h3>Contact:</h3>
<p>If you have problems running this script, or any other kind of questions, please contact me <a href="http://www.mobileread.com/forums/showthread.php?p=9111">here</a>. </p>
<p class="right">This script was written by A. Turcic (<a href="http://www.mobileread.com">www.mobileread.com</a>)<br />and is licensed under a <a href="http://creativecommons.org/licenses/by/2.0/">Creative Commons License</a>.</p>
</div>
</body>
</html>
<?
}
function parse_html()
{
$url = base64_decode($_GET['feed']);
$eBay = parse_ebay_ini('config.inc', 1);
// 1. Parse search query
foreach ($eBay as $country => $countryspecific) {
if (preg_match("#^$countryspecific[url]#i", $url)) {
preg_match("#^$countryspecific[url]/(.+?)(_W0QQ|$)#i", $url, $keywords);
break;
}
}
if (!isset($keywords)) die ("Oups, unexpected error! Please contact me if the problem persists.");
// 1. Fetch eBay results
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_ENCODING,"gzip");
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt ($ch, CURLOPT_COOKIE, $eBay[$country]['cookie']);
curl_setopt ($ch, CURLOPT_REFERER, $eBay[$country]['referer']);
$data = curl_exec($ch);
curl_close ($ch);
// 2. Strip everything from the HTML output that is not relevant to our script
$data = strstr($data,"dSI"); // strip before...
$data = preg_replace("/findItems\(''\).*/si", "", $data); // ...and strip after!
// 3. Preamble of our RSS 2.0 feed
header("Content-Type: application/xml; {$eBay[$country]['encoding']}");
$feed .= "<?xml version=\"1.0\" encoding=\"{$eBay[$country]['encoding']}\" ?>\n";
$feed .= "<rss version=\"2.0\">\n";
$feed .= " <channel>\n";
$feed .= " <title>Meine eBay-Auktionen</title>\n";
$feed .= " <link>". htmlspecialchars($url) ."</link>\n";
$feed .= " <description>eBayFeed converts custom eBay searches into RSS 2.0 feeds</description>\n";
$feed .= " <language>{$eBay[$country]['language']}</language>\n";
$feed .= " <generator>". GENERATOR ."</generator>\n";
$feed .= " <ttl>60</ttl>\n";
// 4. Parse each line with comma delimited data (each representing an auction) and make it an RSS 2.0 item
$lines = preg_split("/\n/", $data); // get all lines, then process each one individually
foreach ($lines as $line_num => $line) {
if (preg_match("/dSI/", $line)) { // we're only interested in lines beginning with dSI...
preg_match($eBay[$country]['targetregex'], $line, $matches); // pick out what is relevant to our script
list(, $paypalPayment, $pbpEligible, $galleryType, $saleType, $IsNewItem, $offerCount, $ItemId, $ItemTitle, $ItemSubTitle, $ItemURL, $CurrentPriceMoneyStandard, $BinPriceMoneyStandard, $TimeType, $Date, $Time) = $matches;
$ItemTitle = strip_tags($ItemTitle);
$ItemTitle = preg_replace('/( ){2,}/', ' ', $ItemTitle); // strip excessive space from titles
if($ItemSubTitle) $ItemSubTitle=strip_tags($ItemSubTitle);
$ItemURL = $eBay[$country]['itemurl'] . $ItemURL;
$desc = "";
if($ItemSubTitle) $desc .= "<h5>$ItemSubTitle</h5>";
if($saleType != 9) $desc .= "Gebote: $offerCount<br />"; // see one line below for explanation
switch ($saleType) { // 9 = we're dealing with a Buy-It-Now Price (bidding not possible); otherwise default to Current Price
case '9':
$desc .= "Sofortkauf-";
break;
default: // other types such as live auctions or Sotheby not added yet
$desc .= "Aktueller ";
break;
}
$desc .= "Preis: ". strip_tags($CurrentPriceMoneyStandard) ."<br />";
if($BinPriceMoneyStandard) $desc .= "Sofortkauf-Preis: ". strip_tags($BinPriceMoneyStandard) ."<br />";
// 09/01/04 eBayFeed 1.10: eBay globally standardized its time output, relief!
switch ($TimeType) {
case "1":
$desc .= "Verbleibende Zeit: $Time";
break;
case "2":
$desc .= "Verbleibende Zeit: <font color=\"red\">$Time</font>";
break;
default:
$desc .= "Endet in: $Date $Time";
break;
}
$desc .= "<br />";
if($paypalPayment != 0) $desc .= "Paypal Bezahlung! <br />";
if($pbpEligible != 0) $desc .= "Paypal Käuferschutz! <br />";
if($IsNewItem == 1) $desc .= "Neuer Artikel! <br />";
if($galleryType != 0) $desc .= "<img src=\"http://thumbs.ebaystatic.com/pict/" . $ItemId . "6464.jpg\" /> <br />";
$feed .= " <item>\n";
$feed .= " <title>". trim(htmlspecialchars($ItemTitle)) ."</title>\n";
$feed .= " <link>". htmlspecialchars($ItemURL) ."</link>\n";
$feed .= " <description>" . trim($desc) . "</description>\n";
$feed .= " </item>\n";
}
}
// 5. Postamble of our RSS 2.0 feed
$feed .= " </channel>\n";
$feed .= "</rss>\n";
print $feed;
}
// Script starts here!
if (isset($_GET['feed'])) {
parse_html();
}
else {
display_form();
}
?>
Code: Alles auswählen
; This is the eBayFeed configuration file
; with eBayFeed/1.12 targetregex is the same for each local eBay again.
[us]
name = eBay USA
url = http://search.*?.ebay.com
cookie = ebay=%5Ejs%3D1%5Ecompare-items%3D%7Edomain%3D.ebay.com%7E%5Ejs%3D1%5E
itemurl = http://cgi.ebay.com
targetregex = /^dSI\((\d+),(\d+),\d+,(\d+),\d+,\d+,(\d+),\d+,\d+,\d+,(\d+),\d+,(\d+),\d+,(\d+),\"(.+?)\",\"(.*?)\",\"(.+?)\",'.*?','(.*?)','.*?','(.*?)',(\d+),\"(.*?)\",\"(.*?)\"/
referer = http://www.ebay.com/index.html
encoding = ISO-8859-1
language = en-us
[uk]
name = eBay UK
url = http://search.*?.ebay.co.uk
cookie = ebay=%5Ejs%3D1%5Ecompare-items%3D%7Edomain%3D.ebay.co.uk%7E%5Ejs%3D1%5E
itemurl = http://cgi.ebay.co.uk
targetregex = /^dSI\((\d+),(\d+),\d+,(\d+),\d+,\d+,(\d+),\d+,\d+,\d+,(\d+),\d+,(\d+),\d+,(\d+),\"(.+?)\",\"(.*?)\",\"(.+?)\",'.*?','(.*?)','.*?','(.*?)',(\d+),\"(.*?)\",\"(.*?)\"/
referer = http://www.ebay.co.uk/index.html
encoding = ISO-8859-1
language = en-uk
[de]
name = eBay Germany
url = http://search.*?.ebay.de
cookie = ebay=%5Ejs%3D1%5Ecompare-items%3D%7Edomain%3D.ebay.de%7E%5Ed%3Djs%2F1%5E
itemurl = http://cgi.ebay.de
targetregex = /^dSI\((\d+),(\d+),\d+,(\d+),\d+,\d+,(\d+),\d+,\d+,\d+,(\d+),\d+,(\d+),\d+,(\d+),\"(.+?)\",\"(.*?)\",\"(.+?)\",'.*?','(.*?)','.*?','(.*?)',(\d+),\"(.*?)\",\"(.*?)\"/
referer = http://www.ebay.de/index.html
encoding = ISO-8859-1
language = de-de
[fr]
name = eBay France
url = http://search.*?.ebay.fr
cookie = ebay=%5Ejs%3D1%5Ecompare-items%3D%7Edomain%3D.ebay.fr%7E%5Ejs%3D1%5E
itemurl = http://cgi.ebay.fr
targetregex = /^dSI\((\d+),(\d+),\d+,(\d+),\d+,\d+,(\d+),\d+,\d+,\d+,(\d+),\d+,(\d+),\d+,(\d+),\"(.+?)\",\"(.*?)\",\"(.+?)\",'.*?','(.*?)','.*?','(.*?)',(\d+),\"(.*?)\",\"(.*?)\"/
referer = http://www.ebay.fr/index.html
encoding = ISO-8859-1
language = fr-fr
[it]
name = eBay Italy
url = http://search.*?.ebay.it
cookie = ebay=%5Ejs%3D1%5Ecompare-items%3D%7Edomain%3D.ebay.it%7E%5Ejs%3D1%5E
itemurl = http://cgi.ebay.it
targetregex = /^dSI\((\d+),(\d+),\d+,(\d+),\d+,\d+,(\d+),\d+,\d+,\d+,(\d+),\d+,(\d+),\d+,(\d+),\"(.+?)\",\"(.*?)\",\"(.+?)\",'.*?','(.*?)','.*?','(.*?)',(\d+),\"(.*?)\",\"(.*?)\"/
referer = http://www.ebay.it/index.html
encoding = ISO-8859-1
language = it-it
Dazu die Hintergrundlogik von cafeRSS:
cafeRSS.php
Code: Alles auswählen
<?php
/*
CaféRSS 1.1
Copyright (C) 2002 Michel Valdrighi
Copyright (C) 2004 BarkerJr <http://barkerjr.net>
Modified 2005 Juergen "Kashban" Wahlmann <http://www.kashban.de>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
class cafeRSS {
var $url;
var $debugtimer;
/* defaut values */
var $items = 'all';
var $template_string = '';
var $template_file = 'cafeRSS_template.txt';
var $use_cache = 0;
var $cache_dir = 'cafeRSS_cache'; # if you want to cache, chmod a directory 777 and put its name here
var $refresh_time = 900; # in seconds - has no effect if $use_cache = 0;
var $echo = 1;
var $debug = 0;
/* usage: $this->assign('var','value'); */
function assign($var, $value) {
$this->$var = $value;
}
/* usage: $this->display('url' [, those optional parameters below ]); */
function display($rss_file = 'blah', $rss_items = 'blah', $rss_template_string = 'blah', $rss_template_file = 'blah', $rss_use_cache= 'blah', $rss_cache_dir = 'blah', $rss_refresh_time = 'blah', $rss_echo = 'blah', $rss_debug = 'blah') {
if ($rss_file == 'blah') { $rss_file = $this->url; }
if ($rss_items == 'blah') { $rss_items = $this->items; }
if ($rss_template_string == 'blah') { $rss_template_string = $this->template_string; }
if ($rss_template_file == 'blah') { $rss_template_file = $this->template_file; }
if ($rss_use_cache == 'blah') { $rss_use_cache = $this->use_cache; }
if ($rss_cache_dir == 'blah') { $rss_cache_dir = $this->cache_dir; }
if ($rss_refresh_time == 'blah') { $rss_refresh_time = $this->refresh_time; }
if ($rss_echo == 'blah') { $rss_echo = $this->echo; }
if ($rss_debug == 'blah') { $rss_debug = $this->debug; }
$rss_cache_file = $rss_cache_dir.'/'.preg_replace('/[^a-zA-Z0-9_\.-]/', '_', $rss_file).'.cache';
if (preg_match('/</', $rss_file)) {
$content = $rss_file;
} else {
/* the secret cache ops, part I */
$isCached = false;
if (($rss_cache_dir != '') && ($rss_use_cache)) {
clearstatcache();
$get_rss = 1;
$cache_rss = 1;
if (file_exists($rss_cache_file)) {
if ((time() - filemtime($rss_cache_file)) < $rss_refresh_time) {
$this->timer_start();
$f = fopen($rss_cache_file, 'r');
$content = fread($f, filesize($rss_cache_file));
fclose($f);
$debugfopencachetime = $this->timer_stop(0);
$get_rss = 0;
$isCached = true;
}
}
} else {
$get_rss = 1;
$cache_rss = 0;
}
/* opens the RSS file */
$this->timer_start();
if ($get_rss) {
$f = fopen($rss_file,'r') or $nocon = true;
if ($nocon)
{
echo '<p><i>(error displaying RSS feed)</i></p>';
return;
}
while (!feof($f)) {
$content .= fgets($f, 4096);
}
fclose($f);
}
$debugfopentime = $this->timer_stop(0);
/* the secret cache ops, part II */
if (($cache_rss) && ($rss_use_cache) && (!$isCached)) {
$this->timer_start();
$f = fopen($rss_cache_file, 'w+');
fwrite($f, $content);
fclose($f);
$debugcachetime = $this->timer_stop(0);
} else {
$debugcachetime = 0;
}
}
/* gets RSS channel info and RSS items info */
$this->timer_start();
preg_match_all("'<channel>(.+?)<title>(.*?)</title>(.+?)</channel>'si",$content,$rss_title);
preg_match_all("'<channel>(.+?)<link>(.*?)</link>(.+?)</channel>'si",$content,$rss_link);
preg_match_all("'<channel>(.+?)<description>(.*?)</description>(.+?)</channel>'si",$content,$rss_description);
preg_match_all("'<channel>(.+?)<lastBuildDate>(.*?)</lastBuildDate>(.+?)</channel>'si",$content,$rss_lastBuildDate);
preg_match_all("'<channel>(.+?)<docs>(.*?)</docs>(.+?)</channel>'si",$content,$rss_docs);
preg_match_all("'<channel>(.+?)<managingEditor>(.*?)</managingEditor>(.+?)</channel>'si",$content,$rss_managingEditor);
preg_match_all("'<channel>(.+?)<webMaster>(.*?)</webMaster>(.+?)</channel>'si",$content,$rss_webMaster);
preg_match_all("'<channel>(.+?)<language>(.*?)</language>(.+?)</channel>'si",$content,$rss_language);
preg_match_all("'<image>(.+?)<title>(.*?)</title>(.+?)</image>'si",$content,$rss_image_title);
preg_match_all("'<image>(.+?)<url>(.*?)</url>(.+?)</image>'si",$content,$rss_image_url);
preg_match_all("'<image>(.+?)<link>(.*?)</link>(.+?)</image>'si",$content,$rss_image_link);
preg_match_all("'<item>(.+?)<title>(.*?)</title>(.+?)</item>'si",$content,$rss_item_titles);
preg_match_all("'<item>(.+?)<link>(.*?)</link>(.+?)</item>'si",$content,$rss_item_links);
preg_match_all("'<item>(.+?)<description>(.*?)</description>(.+?)</item>'si",$content,$rss_item_descriptions);
$rss_title = $rss_title[2][0];
$rss_link = $rss_link[2][0];
$rss_description = $rss_description[2][0];
$rss_lastBuildDate = $rss_lastBuildDate[2][0];
$rss_docs = $rss_docs[2][0];
$rss_managingEditor = $rss_managingEditor[2][0];
$rss_webMaster = $rss_webMaster[2][0];
$rss_language = $rss_language[2][0];
$rss_image_title = $rss_image_title[2][0];
$rss_image_url = $rss_image_url[2][0];
$rss_image_link = $rss_image_link[2][0];
$debugparsersstime = $this->timer_stop(0);
/* gets the template */
$this->timer_start();
if (empty($rss_template_string)) {
$f = fopen($rss_template_file,'r');
$rss_template = fread($f, filesize($rss_template_file));
fclose($f);
} else {
$rss_template = $rss_template_string;
}
$debugfopentemplatetime = $this->timer_stop(0);
preg_match_all("'{rss_items}(.+?){/rss_items}'si",$rss_template,$rss_template_loop);
$rss_template_loop = $rss_template_loop[1][0];
$rss_template = str_replace('{rss_items}','',$rss_template);
$rss_template = str_replace('{/rss_items}','',$rss_template);
/* processes the template - rss channel info */
$this->timer_start();
$rss_template = str_replace('{$rss_title}',$rss_title, $rss_template);
$rss_template = str_replace('{$rss_link}',$rss_link, $rss_template);
$rss_template = str_replace('{$rss_description}',$rss_description, $rss_template);
$rss_template = str_replace('{$rss_lastBuildDate}',$rss_lastBuildDate, $rss_template);
$rss_template = str_replace('{$rss_docs}',$rss_docs, $rss_template);
$rss_template = str_replace('{$rss_managingEditor}',$rss_managingEditor, $rss_template);
$rss_template = str_replace('{$rss_webMaster}',$rss_webMaster, $rss_template);
$rss_template = str_replace('{$rss_language}',$rss_language, $rss_template);
/* processes the template - rss image info */
if ($rss_image_url != '') {
$rss_template = str_replace('{rss_image}','',$rss_template);
$rss_template = str_replace('{/rss_image}','',$rss_template);
$rss_template = str_replace('{$rss_image_title}',$rss_image_title, $rss_template);
$rss_template = str_replace('{$rss_image_link}',$rss_image_link, $rss_template);
$rss_template = str_replace('{$rss_image_url}',$rss_image_url, $rss_template);
} else {
$rand = md5(rand(1,5)); /* now there's an ugly hack that I'll have to fix */
$rss_template = preg_replace('/(\015\012)|(\015)|(\012)/', $rand, $rss_template);
$rss_template = preg_replace('/{rss_image}(.*?){\/rss_image}/', '', $rss_template);
$rss_template = preg_replace("/$rand/", "\n", $rss_template);
}
/* processes the template - rss items info */
$rss_template_loop_processed = '';
$k = count($rss_item_titles[2]);
$j = (($rss_items == 'all') || ($rss_items > $k)) ? $k : intval($rss_items);
for ($i = 0; $i<$j; $i++) {
$tmp_template = $rss_template_loop;
$tmp_title = $rss_item_titles[2][$i];
$tmp_link = $rss_item_links[2][$i];
$tmp_description = $rss_item_descriptions[2][$i];
if ($tmp_description == '') {
$tmp_description = '-';
}
if ($tmp_title == '') {
$tmp_title = substr($tmp_description,0,20);
if (strlen($tmp_description) > 20) {
$tmp_title .= '...';
}
}
$tmp_template = str_replace('{$rss_item_title}',$tmp_title, $tmp_template);
$tmp_template = str_replace('{$rss_item_link}',$tmp_link, $tmp_template);
$tmp_template = str_replace('{$rss_item_description}',$tmp_description, $tmp_template);
$rss_template_loop_processed .= $tmp_template;
}
$rss_template = str_replace($rss_template_loop, $rss_template_loop_processed, $rss_template);
$debugprocesstemplatetime = $this->timer_stop(0);
clearstatcache();
/* echoes or returns the processed template :) */
if ($rss_echo) {
echo $rss_template;
if ($rss_debug) {
echo '<p>';
echo $debugfopentime.' seconds to load the remote RSS file.<br />';
echo $debugparsersstime.' seconds to parse the RSS.<br />';
echo $debugfopentemplatetime.' seconds to load the template file.<br />';
echo $debugprocesstemplatetime.' seconds to process the template.<br />';
if ($cache_rss) {
echo $debugcachetime.' seconds to cache the parsing+processing.<br />';
}
echo '<br />';
$debugtotaltime = ($debugfopentime+$debugparsersstime+$debugfopentemplatetime+$debugfopentemplatetime+$debugprocesstemplatetime+$debugcachetime);
echo 'Total: '.$debugtotaltime.' seconds.';
echo '</p>';
}
} else {
return $rss_template;
}
}
function timer_start() {
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$this->debugtimer = $mtime;
return true;
}
function timer_stop($display=0,$precision=3) {
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$this->debugtimer = $mtime - $this->debugtimer;
if ($display)
echo number_format($this->debugtimer,$precision);
return($this->debugtimer);
}
}
?>
cafeRSS_template_desc.txt
Code: Alles auswählen
{rss_image}
<p>
<a href="{$rss_image_url}" title="{$rss_image_title}"><img src="{$rss_image_url}" alt="{$rss_image_title}"
border="0" /></a>
</p>
{/rss_image}
<p>{$rss_title} <i>{$rss_lastBuildDate}</i></p>
<ul class="rsslist">
{rss_items}
<li>
<a href="{$rss_item_link}" target="_blank">{$rss_item_title}
<div>{$rss_item_description}</div></a>
</li>
{/rss_items}
</ul>
Code: Alles auswählen
/* Ausgabe des RSS News Moduls - RDFParser */
.rsslist
{
margin: 0 0 0 0;
font: 10px;
width: 100%;
padding: 0;
border: 0;
}
.rsslist li
{
margin: 0 0 0 0;
list-style-image: none;
list-style: none;
text-align: left;
padding-top: 1px;
padding-left: 0px;
}
.rsslist li a
{
display: block;
padding: 3px 5px 3px 5px;
border-left: 2px solid white ;
border-bottom: 1px dotted gray;
text-decoration: none;
background: white;
}
.rsslist li a:link { color: #448; }
.rsslist li a:visited { color: #667; }
.rsslist li a:hover
{
border-left: 2px solid lightblue;
}
.rsslist li div
{
display: block;
padding: 3px 5px 3px 5px;
border-top: 1px solid lightgray;
border-left: 1px solid lightgray;
border-right: 1px solid darkgray;
border-bottom: 1px solid darkgray;
text-decoration: none;
background: lightblue;
color:black;
}
Input:
Code: Alles auswählen
echo "<table align=\"left\" cellpadding=\"0\" cellspacing=\"0\" class=\"text_medium\">
<tr>
<td>RDF URL:</td>
<td colspan=2> <INPUT TYPE=\"text\" NAME=\"CMS_VAR[0]\" VALUE=\"CMS_VALUE[0]\" style=\"width: 300px;\"></td>
<td width=\"20\"> </td>
</tr>
<tr>
<td>Anzahl News:</td>
<td><INPUT TYPE=\"text\" NAME=\"CMS_VAR[1]\" VALUE=\"CMS_VALUE[1]\" style=\"width: 30px;\"></td>
<td width=\"20\"> </td>
</tr>
<tr>
<td>Cache (0/1):</td>
<td><INPUT TYPE=\"text\" NAME=\"CMS_VAR[2]\" VALUE=\"CMS_VALUE[2]\" style=\"width: 30px;\"></td>
<td width=\"20\"> </td>
</tr>
<tr>
<td>Template:</td>
<td><INPUT TYPE=\"text\" NAME=\"CMS_VAR[3]\" VALUE=\"CMS_VALUE[3]\" style=\"width: 300px;\"></td>
<td width=\"20\"> </td>
</tr>
</table>";
Code: Alles auswählen
<?php
if (!class_exists("cafeRSS"))
{
include($cfg['path']['contenido'].'external/cafeRSS/cafeRSS.php');
}
$rss1feedURL = "CMS_VALUE[0]";
$rss1Items = "CMS_VALUE[1]";
$rss1Cache = "CMS_VALUE[2]";
$rssTemplateFile = "CMS_VALUE[3]";
$rss = new cafeRSS();
$rss->assign('items', $rss1Items);
$rss->assign('use_cache', $rss1Cache);
$rss->assign('template_file', $cfg['path']['contenido'].'external/cafeRSS/'.$rssTemplateFile);
$rss->assign('cache_dir', $cfg['path']['contenido'].'external/cafeRSS/cache');
$rss->display($rss1feedURL);
?>
Den Cache von cafeRSS sollte man bei eBay-Feeds ausschalten, da die Dateinamen zu lang werden. Alternativ kann sich auch jemand dran machen und dafür eine sinnvolle Kürzung einbauen

cafeRSS und ebayfeed habe ich unter contenido/external jeweils in eigenen Verzeichnissen untergebracht (cafeRSS und ebayfeed). Die Dateirechte müssen für cafeRSS so gesetzt werden, dass das Skript ggf. in ein Unterverzeichnis "cache" schreiben kann. Bei ebayfeed reichen Lese- und Ausführungsrechte.
Viel Spaß damit!
Ciao,
Kashban