Verfasst: 29.12.2004 23:16
Der .xml oder der .php Datei?
phpBB.de - Die deutsche phpBB-Community
https://www.phpbb.de/community/
Pyramide hat geschrieben:ggf. zuerst eine leere Datei mit dem Namen erstellen
Code: Alles auswählen
$rdftime=0;
$rdfurl="http://www.heise.de/newsticker/heise.rdf";
include('rdf_parser.php');
show_rdf($rdfurl, 'news_item', 'simple_news.cache.xml', ($rdftime*60));
Code: Alles auswählen
$template->assign_block_vars($block_name, array(
'TITLE' => $item['title']));
Da du hier auf phpBB.de bist, ist das Script selbstverständlich zum Einbau in ein phpBB gedacht...lukie hat geschrieben:Ich habe folgenden code in die "phpinclude"-Template des WBBs geschrieben.
Code: Alles auswählen
<?php
//das ist eine modifizierte rdf_parser.php für ein wbb board
function cache_file($url, $cachefile, $cachetime = 900) {
$stat = @stat($cachefile);
if ($stat[9] < (time() - $cachetime)) {
$fp_url = fopen($url, 'r');
$fp_cache = fopen($cachefile, 'w');
while($str = fread($fp_url, 1024)) {
fwrite($fp_cache, $str);
}
fclose($fp_url);
fclose($fp_cache);
return false;
}
else {
return true;
}
}
class rdf_parser {
var $file;
var $cache_file = '';
var $cache_time = 0;
var $cache_used = false;
var $content = '';
var $channel = array();
var $items = array();
function rdf_parser($file, $cache_file='', $cache_time=0) {
$this->file = $file;
$this->cache_file = $cache_file;
$this->cache_time = $cache_time;
//$this->parse();
}
function match($text, $elements) {
$ret = array();
foreach($elements as $element) {
if(preg_match("#<$element>(.*?)</$element>#si", $text, $matches)) {
$ret[$element] = $matches[1];
}
}
return $ret;
}
function parse() {
$file = $this->file;
if($this->cache_file && $this->cache_time) {
$this->cache_used = cache_file($this->file, $this->cache_file, $this->cache_time);
$file = $this->cache_file;
}
$this->content = implode('', file($file));
if(preg_match('#<channel>(.*?)</channel>#si', $this->content, $matches)) {
$this->channel = $this->match($matches[1], array('title', 'description', 'link'));
}
preg_match_all('#<item>(.*?)</item>#si', $this->content, $matches, PREG_PATTERN_ORDER);
foreach($matches[1] as $item) {
$this->items[] = $this->match($item, array('title', 'description', 'link'));
}
}
function template_output($maxNews) {
$row = 0;
global $newstickerHtmlData;
$newstickerHtmlData = ""; //wird an das Javascript übergeben
$counter = 0;
if ( $maxNews == 0 ) $maxNews = 1;
foreach($this->items as $item) {
$counter = $counter + 1;
if ( $counter > $maxNews ) break; //maximale anzahl von nachrichten im ticker
//theNews.addItem('heise.de: TITEL','URL','','','newsTxt1');
//der untere String ist angepasst an den input des javascriptes
$newstickerHtmlData = $newstickerHtmlData."theNews.addItem('heise.de: ".$item['title']."','".$item['link']."','','','newsTxt1');\n";
}
}
}
function show_rdf($url, $maxNews, $cache_file='', $cache_time=0) {
$parser = new rdf_parser($url, $cache_file, $cache_time);
$parser->parse();
$parser->template_output($maxNews);
}
?>
Öhm - bei mir passiert genau das gleicheKiss News hat geschrieben:gut, habe also jetzt eine leere simple_news.cache.xml Datei erstellt, wo nichts drinnen steht, raufgeladen ins root-Verzeuchnis, alle Rechte vergeben..
wenn ich jetzt die Datei aufrufe:
http://web148.silverline-s13.de/phpbb2/ ... sschau.php
kommt nix... (außer Header & foother), nocht einmal ein error, sonst aber auch nix...
Code: Alles auswählen
Warning: fopen(): URL file-access is disabled in the server configuration in /www/www.maidenaustria.at/bb/rdf_parser.php on line 5
Warning: fopen(http://www.ironmaiden.com/rss/index.php): failed to open stream: no suitable wrapper could be found in /www/www.maidenaustria.at/bb/rdf_parser.php on line 5
Warning: fread(): supplied argument is not a valid stream resource in /www/www.maidenaustria.at/bb/rdf_parser.php on line 7
Warning: fclose(): supplied argument is not a valid stream resource in /www/www.maidenaustria.at/bb/rdf_parser.php on line 10