<?
//set the url of the main site - like www.yahoo.com
$site='www.tutorialauto.com';


define('VALID', 'true');
$GLOBALS[path] = '';
require 'classes/class.config.php';
require 'classes/class.lang.php';
require 'classes/class.mysql.php';
require 'classes/class.template.php';
require 'includes/ids.php';
$config_handle = new config;
$GLOBALS[content] = array();
$lang_handle = new lang();
$GLOBALS[lang] = $lang_handle->load_lang('main');
$sql = new mysql();
$template = new template();
$template->debug();
$sql->link = $sql->connect();

$query="SELECT * FROM `tut_tutorials` WHERE active='1' ORDER BY adate DESC LIMIT 10";
$res=mysql_query($query);

$nr=mysql_num_rows($res);

require("xmlwriterclass.php");
require("rss_writer_class.php");

	/*
	 *  First create an object of the class.
	 */
	$rss_writer_object=&new rss_writer_class;
	
	/*
	 *  Choose the version of specification that the generated RSS document should conform.
	 */
	$rss_writer_object->specification='2.0';
	
	/*
	 *  Specify the URL where the RSS document will be made available.
	 */
	$rss_writer_object->about='rss.xml';
	
	/*
	 *  Specify the URL of an optional XSL stylesheet.
	 *  This lets the document be rendered automatically in XML capable browsers.
	 */
	$rss_writer_object->stylesheet='';
	
	/*
	 *  You may declare additional namespaces that enable the use of more property
	 *  tags defined by extension modules of the RSS specification.
	 */
	$rss_writer_object->rssnamespaces['dc']='http://purl.org/dc/elements/1.1/';
	
	/*
	 *  Define the properties of the channel.
	 */
	$properties=array();
	$properties['description']=$site;
	$properties['link']="http://$site/";
	$properties['title']=$site;
	$properties['dc:date']=date("F j, Y, g:i a");
	$rss_writer_object->addchannel($properties);
	
	/*
	 *  If your channel has a logo, before adding any channel items, specify the logo details this way.
	 */
	$properties=array();
	$properties['url']='#';
	$properties['link']='#';
	$properties['title']='#';
	$properties['description']='#';
	$rss_writer_object->addimage($properties);

	$properties=array();

for ($i=0;$i<$nr;$i++)
	{
	$title=mysql_result($res, $i, 'name');
	$description=mysql_result($res, $i, 'descrip');
	$image=mysql_result($res, $i, 'preview');
	$time=mysql_result($res, $i, 'adate');
	$id=mysql_result($res, $i, 'id');

	
	$pieces = explode("keywords", $description);
	$description=$pieces[0];
	$pieces = explode("Keywords", $description);
	$description=$pieces[0];
	$properties['description']="<img src='http://$site/$image' align=left hspace=5 vspace=1 border=1 />".$description;
	$properties['guid']="http://$site/clicks.php?click=$id";
	$properties['link']="http://$site/clicks.php?click=$id";
	$properties['title']=$title;
	$properties['dc:date']=date("F j, Y, g:i a", $time);
	$rss_writer_object->additem($properties);
	}


if($rss_writer_object->writerss($output))
	{
		
		/*
		 *  If the document was generated successfully, you may now output it.
		 */
		Header('Content-Type: text/xml; charset="'.$rss_writer_object->outputencoding.'"');
		Header('Content-Length: '.strval(strlen($output)));
		echo $output;
	}
	else
	{
		
		/*
		 *  If there was an error, output it as well.
		 */
		Header('Content-Type: text/plain');
		echo ('Error: '.$rss_writer_object->error);
	}

?>