4 require_once
'./Services/Http/classes/class.ilProxySettings.php';
6 if (!defined(
"MAGPIE_DIR")) {
7 define(
"MAGPIE_DIR",
"./Services/Feeds/magpierss/");
9 define(
"MAGPIE_CACHE_ON",
true);
10 if (defined(
'ILIAS_DATA_DIR') && defined(
'CLIENT_ID')) {
13 define(
'MAGPIE_OUTPUT_ENCODING',
"UTF-8");
14 define(
'MAGPIE_CACHE_AGE', 900);
15 define(
'MAGPIE_DEBUG',
false);
16 include_once(MAGPIE_DIR .
"/rss_fetch.inc");
18 include_once(
"./Services/Feeds/classes/class.ilExternalFeedItem.php");
44 define(
'IL_FEED_PROXY_HOST',
"");
45 define(
'IL_FEED_PROXY_PORT',
"");
76 $this->error = $a_error;
107 if (!defined(
'IL_FEED_PROXY_HOST')) {
114 define(
'IL_FEED_PROXY_HOST',
"");
115 define(
'IL_FEED_PROXY_PORT',
"");
119 $feed = @fetch_rss($a_url);
121 $error = magpie_error();
126 return "Unknown Error.";
138 if ($this->
getUrl() !=
"") {
139 $this->feed = @fetch_rss($this->
getUrl());
143 $error = magpie_error();
152 if (is_array($this->feed->items)) {
153 foreach ($this->feed->items as $item) {
155 $item_obj->setMagpieItem($item);
156 $this->items[] = $item_obj;
171 $request_headers = array();
177 if (!$cache->ERROR) {
179 $cache_status = $cache->check_cache($cache_key);
183 if ($cache_status ==
'HIT') {
195 return $this->feed->channel[
"title"];
203 return $this->feed->channel[
"description"];
221 if (!defined(
'IL_FEED_PROXY_HOST')) {
226 define(
'IL_FEED_PROXY_HOST',
"");
227 define(
'IL_FEED_PROXY_PORT',
"");
231 $res = @fopen($a_url,
"r");
238 while (!feof(
$res)) {
239 $contents .= fread(
$res, 8192);
255 #search through the HTML, save all <link> tags 256 # and store each link's attributes in an associative array 257 preg_match_all(
'/<link\s+(.*?)\s*\/?>/si', $html, $matches);
258 $links = $matches[1];
259 $final_links = array();
260 $link_count = count($links);
261 for (
$n = 0;
$n < $link_count;
$n++) {
264 $att = preg_split(
'/\s*=\s*/s', $attribute, 2);
265 if (isset($att[1])) {
266 $att[1] = preg_replace(
'/([\'"]?)(.*)\1/',
'$2', $att[1]);
267 $final_link[strtolower($att[0])] = $att[1];
270 $final_links[
$n] = $final_link;
272 #now figure out which one points to the RSS file 273 for (
$n = 0;
$n < $link_count;
$n++) {
274 if (strtolower($final_links[
$n][
'rel']) ==
'alternate') {
275 if (strtolower($final_links[$n][
'type']) ==
'application/rss+xml') {
276 $href = $final_links[
$n][
'href'];
278 if (!$href and strtolower($final_links[$n][
'type']) ==
'text/xml') {
279 #kludge to make the first version of this still work 280 $href = $final_links[
$n][
'href'];
283 if (strstr($href,
"http://") !==
false) { #
if it
's absolute 285 } else { #otherwise, 'absolutize
' it 286 $url_parts = parse_url($location); 287 #only made it work for http:// links. Any problem with this? 288 $full_url = "http://$url_parts[host]"; 289 if (isset($url_parts['port
'])) { 290 $full_url .= ":$url_parts[port]"; 292 if ($href[0] != '/
') { #it's a relative link on the domain
293 $full_url .= dirname($url_parts[
'path']);
294 if (substr($full_url, -1) !=
'/') {
295 #if the last character isn't a '/', add it
getChannelDescription()
Get Description.
Wraps $item arrays from magpie.
static _determineFeedUrl($a_url)
Determine Feed Url.
__construct()
Constructor.
const MAGPIE_OUTPUT_ENCODING(defined('ILIAS_DATA_DIR') &&defined('CLIENT_ID'))
getChannelTitle()
Get Channel.
static _checkUrl($a_url)
Check Url.
Handles external Feeds via Magpie library.
foreach($_POST as $key=> $value) $res
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getDataDir()
get data directory (outside webspace)
static _createCacheDirectory()
Create magpie cache directorry (if not existing)
checkCacheHit()
Check cache hit.
setError($a_error)
Set Error.
static _getRSSLocation($html, $location)
This one is by Keith Devens , see http://keithdevens.com/weblog/archive/2002/Jun/03/RSSAuto-Discovery...
static _getInstance()
Getter for unique instance.