<?php
header('Content-type: text/xml');
$date = date(DATE_RFC2822);
include '../opendb.php';
//====================================================================================================
function get_uname($userid){
$quaryu = "SELECT `uname` FROM `users` WHERE `user_id` = '$userid'";
$tempu = mysql_query($quaryu);
$rowu = mysql_fetch_array($tempu);
return $rowu;
}

function alter_char($char){
	$char = str_replace('"', "&quot;", $char);
	$char = str_replace("'", "&apos;", $char);
	$char = str_replace("&", "&amp;", $char);
	$char = str_replace("<", "&lt;", $char);
	$char = str_replace(">", "&gt;", $char);
	$char = preg_replace("/[^A-Za-z0-9\s\s+\.\:\-\/%+\(\)\*\&\$\#\!\@\"\';\n\t\r\>\<]/","",$char);
return $char;
}
//====================================================================================================
$result .= '<?xml version="1.0" encoding="UTF-8"?>';
$result .= '<rss version="2.0">';
$result .= '<channel>
				<title>Wish Bowl Blog - Wishbowl.org</title>
				<description>Find various articles, blogs, posts on wishbowl.org. Share, comments and discover what is happening right now.</description>
				<link>http://www.wishbowl.org/blog/</link>
				<category domain="www.wishbowl.org">Dreams/God/Happiness/Hope/Imagination/Inspiration/Life/Meditation/Motivation/Peace/Relationship/Wisdom</category>
				<docs>http://wishbowl.org/rss/rss-doc.html</docs>
				<language>en-us</language>
				<lastBuildDate>'.$date.'</lastBuildDate>
				<managingEditor>wishbowl.org@gmail.com</managingEditor>
				<pubDate>Tue, 17 Jan 2012 02:00:00 -0800</pubDate>
				<webMaster>wishbowl.org@gmail.com</webMaster>
				<generator>Wishbowl v2.0 (2.0.0.0) http://www.wishbowl.org</generator>
				<image>
					<url>http://wishbowl.org/images/logo.png</url>
					<title>Wish Bowl Blog</title>
					<link>http://www.wishbowl.org/blog</link>
					<description>wishbowl.org. Share, comments and discover what is happening right now.</description>
					<width>144</width>
					<height>35</height>
				</image>';
//====================================================================================================
$quary_own = "SELECT * FROM `articales` WHERE `blog` = '1' ORDER BY `articale_posted` DESC LIMIT 0,1000";
$temp_own = mysql_query($quary_own);
while($row_own = mysql_fetch_array($temp_own)){
$articale_id = $row_own['articale_id'];
$articale_title = $row_own['articale_title'];
$articale_title = alter_char($articale_title);
$articale_url = $row_own['articale_url'];
$articale_body = $row_own['articale_body'];
$articale_body = substr($articale_body, 0, 200);
$articale_body = alter_char($articale_body);
$articale_posted = $row_own['articale_posted'];
$articale_posted = strtotime($articale_posted);
$articale_posted = date(DATE_RFC2822, $articale_posted);
$articales_poster_id = $row_own['articales_poster_id'];
$user_d = get_uname($articales_poster_id);
$poster_uname = $user_d['uname'];
$articale_url = "http://www.wishbowl.org/$poster_uname/$articale_url/";
$result .= '	<item>
					<title>'.$articale_title.'</title>
					<description>'.$articale_body.'...</description>
					<link>'.$articale_url.'</link>
					<guid isPermaLink="true">'.$articale_url.'</guid>
					<pubDate>'.$articale_posted.'</pubDate>
				</item>';
}			
$result .= '</channel>
		</rss>';
echo $result;
?>