| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/clients/client2/web20/web/wp-content/themes/old_backup/include/ |
Upload File : |
<?php
/**
* rdfparser
* class to parse newsfeeds into arrays
* @author clemens krack
* @link [url]http://www.tripdown.de[/url]
* @access public
**/
class rdfparser {
var $_items; // array the items
var $_may; // array what may be done
var $_act; // string current active
var $_index; // integer current index
var $_url; // url to open
/**
* rdfparser::rdfparser()
*
* @param $url url of the feed
* @return void
**/
function rdfparser($url) {
$this->_url = $url;
}
/**
* rdfparser::parse()
* parses a newsfeed an returns an array containing the items.
* @return array
**/
function parse() {
$this->_items = array();
$this->_index = 0;
$this->_may['parse'] = false;
$parser = xml_parser_create();
xml_set_object($parser, $this);
xml_set_element_handler($parser, "_startElement", "_endElement");
xml_set_character_data_handler($parser, "_charHandler");
$fp = fopen($this->_url, "r");
while(!feof($fp)) {
$line = fgets($fp, 4096);
xml_parse($parser, $line);
}
fclose($fp);
xml_parser_free($parser);
return $this->_items;
}
function _startElement($parser, $name, $attrs) {
// allow parsing chardata as soon as an element is opened
$this->_may['char'] = true;
if ($name=="ITEM") {
// allow parsing as soon as an item element was opened
$this->_may['parse'] = true;
// one more item -> increment index
$this->_index++;
$this->_items[$this->_index] = Array('title' => '', 'link' => '', 'description' => '');
} else if ($name=="TITLE") {
// current active: title
$this->_act = "TITLE";
} else if($name=="LINK") {
// current active: link
$this->_act = "LINK";
} else if($name=="DESCRIPTION") {
// current active: description
$this->_act = "DESCRIPTION";
} else {
// unknown tag, don't allow adding chardata
$this->_may['char'] = false;
}
$this->_act = strtolower($this->_act);
}
function _endElement($parser, $name) {
if($name=="ITEM") {
// item tag closed: parsing not allowed
$this->_may['parse'] = false;
} elseif($name=="TITLE" || $name=="LINK" || $name="DESCRIPTION") {
// datatag closed, we don't want different chardata
$this->_may['char'] = false;
}
}
function _charHandler($parser, $data) {
$data = trim($data);
if(!$this->_may['char'] OR !$this->_may['parse']) {
return;
}
if (isset($this->_items[$this->_index][$this->_act])) {
$this->_items[$this->_index][$this->_act] .= $data;
} else {
$this->_items[$this->_index][$this->_act] = $data;
}
}
} ?>