<? header('Content-type: text/xml'); ?>
<?
mysql_connect("localhost", "dailyfre_dailydb", "daily123pwd");
mysql_select_db("dailyfre_fghome");
$datetoday = date("Y-m-d H:i:s") ;
?>

<rss version="2.0">
<channel>
<title>Play Free Games - Action Games - Racing Games - Dress Up Games | DailyFreeGames.com</title>
<description>DailyFreeGames is a great place to play free online games, including: action games, racing games, and dress up games.</description>
<link>http://www.dailyfreegames.com/</link>
<language>en-us</language>
<?
//$q="SELECT content_id, content_name, content_var, content_subcat, date_time FROM ec_content where content_trash=1 ORDER BY date_time DESC LIMIT 15;";
//$q = "select * from ec_content where content_trash=0 and date_time <= '".$datetoday."' and content_thumbbig <> '' order by date_time DESC limit 12";
$q = "SELECT * FROM ec_content WHERE content_trash=0 AND date_time <= '".$datetoday."' AND content_thumbbig <> '' AND content_average >= 8.00 AND content_totalvotes >= 5 ORDER BY `date_time` DESC LIMIT 12";
$doGet=mysql_query($q);
function getsubcat($subcatid){
		$subcatsql= "select * from ec_subcat where subcat_id=$subcatid and subcat_trash=0";
		$subcatresults = mysql_query($subcatsql) or die("cannot pull number of sub category");
		$subcatrows = mysql_fetch_array($subcatresults);
		$subcatname = $subcatrows["subcat_name"];
		return $subcatname;
	}
function removespecialchars($string){
		$text = str_replace("/","",$string);
		$text = str_replace("&","",$text);
		$text = preg_replace('/\s\s+/', ' ', $text);
		$text = strtolower($text);
		$text = str_replace(" ","-",$text);
		return $text;
	}
while($result = mysql_fetch_array($doGet)){
$content = unserialize($result["content_var"]);
$subid = $result["content_subcat"];
$subname = getsubcat($subid);
$link = "http://www.dailyfreegames.com/games/".removespecialchars($subname)."/".removespecialchars($result['content_name']).".html";
//$mydate	= date("F j, Y H:i:s", strtotime($result['date_time']));
//$mydate1	= date("F j, Y H:i:s", strtotime($result['date_time']));
$mydate = date('r', strtotime($result['date_time']));
/*
$d = date( 'Y-m-d H:i:s T', time($result['date_time']) );
$mydate = gmdate(DATE_RFC822, strtotime($d));
*/
?> 
     <item> 
        <title> </title> 
        <description> </description> 
        <link></link>
        <guid></guid>
        <pubDate></pubDate>
     </item>
<? } ?>  
</channel>
</rss>
