<?php

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

  Script: Maian Events v2.0
  Written by: David Ian Bennett
  E-Mail: support@maianscriptworld.co.uk
  Website: http://www.maianscriptworld.co.uk

  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  
  This File: class_rss.inc.php
  Description: RSS Feed Class
  New in v2.0

  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

class rss_Feed {

var $xml_version  = '1.0';
var $encoding     = 'utf-8';
var $rss_version  = '2.0';
var $path;

// Open channel..
function open_channel()
{
  $xml_string = '<?xml version="'.$this->xml_version.'" encoding="'.$this->encoding.'"?>
  <?xml-stylesheet type="text/css" href="'.$this->path.'/rss_style.css" ?>
  <rss version="'.$this->rss_version.'">
  <channel>
  ';

  return $xml_string;
}

// Loads data into feed..
function add_item($title='',$link='',$date='',$desc='')
{
  $xml_string = '
  <item>
   <title>'.$this->render($title).'</title>
    <link>'.$link.'</link>
    <pubDate>'.$date.'</pubDate>
    <guid>'.$link.'</guid>
    <description>'.$this->render($desc,true).'</description>
  </item>
  ';

  return $xml_string;
}

// Feed info..
function feed_info($title='',$link='',$date='',$desc='',$site='')
{
  $xml_string = '<title>'.$this->clean($title).'</title>
  <link>'.$link.'</link>
  <description>'.$this->clean($desc).'</description>
  <lastBuildDate>'.$date.'</lastBuildDate>
  <language>en-us</language>
  <generator>'.$this->render($site).'</generator>
  ';

  return $xml_string;
}

// Close channel..
function close_channel()
{
  $xml_string = '
  </channel>
  </rss>
  ';

  return $xml_string;
}

// Render data..
function render($data,$clean_tags=false)
{
  if ($clean_tags) {
    $data = $this->remove_tags($data);
  }
  
  return '<![CDATA['.$this->clean($data).']]>';
}

// Remove tags..
function remove_tags($data)
{
  return strip_tags($data,'<b><strong><p><br><img><i><a><u>');
}

// Cleans data..
function clean($data)
{
  return (get_magic_quotes_gpc() ? stripslashes($data) : $data);
}

}

?>
