24 define(
"MAGPIE_DIR",
"./Services/Feeds/magpierss/");
25 define(
"MAGPIE_CACHE_ON",
true);
26 define(
"MAGPIE_CACHE_DIR",
"./".
ILIAS_WEB_DIR.
"/".CLIENT_ID.
"/magpie_cache");
27 define(
'MAGPIE_OUTPUT_ENCODING',
"UTF-8");
28 define(
'MAGPIE_CACHE_AGE', 900);
31 include_once(
"./Services/Feeds/classes/class.ilExternalFeedItem.php");
53 define(
'IL_FEED_PROXY_HOST',
$feed_set->get(
"proxy"));
54 define(
'IL_FEED_PROXY_PORT',
$feed_set->get(
"proxy_port"));
84 $this->error = $a_error;
116 if (!defined(
'IL_FEED_PROXY_HOST'))
120 define(
'IL_FEED_PROXY_HOST',
$feed_set->get(
"proxy"));
121 define(
'IL_FEED_PROXY_PORT',
$feed_set->get(
"proxy_port"));
124 $feed = @fetch_rss($a_url);
135 return "Unknown Error.";
147 if ($this->
getUrl() !=
"")
149 $this->feed = @fetch_rss($this->
getUrl());
166 if (is_array($this->feed->items))
168 foreach($this->feed->items as $item)
171 $item_obj->setMagpieItem($item);
172 $this->items[] = $item_obj;
187 $request_headers = array();
191 $cache_key = $this->
getUrl().MAGPIE_OUTPUT_ENCODING;
195 $cache_status =
$cache->check_cache( $cache_key);
199 if ($cache_status ==
'HIT')
212 return $this->feed->channel[
"title"];
220 return $this->feed->channel[
"description"];
238 if (!defined(
'IL_FEED_PROXY_HOST'))
241 define(
'IL_FEED_PROXY_HOST',
$feed_set->get(
"proxy"));
242 define(
'IL_FEED_PROXY_PORT',
$feed_set->get(
"proxy_port"));
245 $res = @fopen($a_url,
"r");
255 $contents.= fread(
$res, 8192);
271 #search through the HTML, save all <link> tags
272 # and store each link's attributes in an associative array
273 preg_match_all(
'/<link\s+(.*?)\s*\/?>/si', $html, $matches);
274 $links = $matches[1];
275 $final_links = array();
276 $link_count = count($links);
277 for(
$n=0;
$n<$link_count;
$n++){
278 $attributes = preg_split(
'/\s+/s', $links[
$n]);
279 foreach($attributes as $attribute){
280 $att = preg_split(
'/\s*=\s*/s', $attribute, 2);
282 $att[1] = preg_replace(
'/([\'"]?)(.*)\1/',
'$2', $att[1]);
283 $final_link[strtolower($att[0])] = $att[1];
286 $final_links[
$n] = $final_link;
288 #now figure out which one points to the RSS file
289 for(
$n=0;
$n<$link_count;
$n++){
290 if(strtolower($final_links[
$n][
'rel']) ==
'alternate'){
291 if(strtolower($final_links[$n][
'type']) ==
'application/rss+xml'){
292 $href = $final_links[
$n][
'href'];
294 if(!$href and strtolower($final_links[$n][
'type']) ==
'text/xml'){
295 #kludge to make the first version of this still work
296 $href = $final_links[
$n][
'href'];
299 if(strstr($href,
"http://") !==
false){ #
if it
's absolute
301 }else{ #otherwise, 'absolutize
' it
302 $url_parts = parse_url($location);
303 #only made it work for http:// links. Any problem with this?
304 $full_url = "http://$url_parts[host]";
305 if(isset($url_parts['port
'])){
306 $full_url .= ":$url_parts[port]";
308 if($href{0} != '/
'){ #it's a relative link on the domain
309 $full_url .= dirname($url_parts[
'path']);
310 if(substr($full_url, -1) !=
'/'){
311 #if the last character isn't a '/', add it