<div id="center-column">
<div class="top-bar">
				<a href="index.php?act=newsblogfeed" title="News Feed" class="button">News Feed</a>
				<h1>Cpanel - RSS Feed</h1>
				<div class="breadcrumbs"><a href="index.php?act=sitemap" title="Sitemap">Sitemap</a> / <a href="index.php?act=rssfeed" title="RSS Feed">RSS Feed</a> / <a href="index.php?act=newsblogfeed" title="RSS Feed">News Blog RSS Feed</a></div>
			</div><br />
		  <div class="select-bar">
		    <label>
		    <h3>RSS Game Feed</h3>
		    </label>
		  </div>
    <div align="center">
        <a href="index.php?act=rssfeed&state=create">Click here to generate an RSS file for games</a><br>
        <?php
        if (isset($_GET['state'])) {
		switch($_GET['state']){
            case 'done':
                echo'<center><font size="3" color="#00CC33"><b>RSS file done</b></font><br/><br/>';
				echo 'New games feed at '.$setting['siteurl'].'rss-arcade.xml<br/><br/>';
				echo 'All games feed at '.$setting['siteurl'].'rss-arcade-huge.xml</center>';
                break;
            case 'create':
              echo'<center><font size="3" color="#FF0000"><b>Creating RSS file...</b></font></center><br><br>';
				$rrsfile = '../rss-arcade.xml';
				ob_start();
				print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
				print ""."<rss version=\"2.0\">\n";
				print ""."<channel>\n";
				print ""."<title>" . $setting['sitename'] . "</title>\n";
				print ""."<link>" . $setting['siteurl'] . "</link>\n";

				print ""."<ttl>600</ttl>\n";
				print ""."<description>We love to give you the best in free games.</description>\n";
				print ""."<copyright>".date("Y")." " . $setting['sitename'] . " All rights reserved.</copyright>\n";   
				$query = yasDB_select("SELECT * FROM games order by id DESC LIMIT 40",false);
				while($row = $query->fetch_array(MYSQLI_ASSOC)) {
					$name = $row['title'];
					$ID = $row['id'];
					$description = $row['description'];
					$gameurl = $row['title'];
					$gameurl = str_replace(" ", "-", $gameurl);
					$gameurl = str_replace("'", "_", $gameurl);
					$gameurl = str_replace('"', "_", $gameurl);
					$gameurl = str_replace('/', "_", $gameurl);
					$gameurl = str_replace("\\", "_", $gameurl);
					$gameurl = rawurlencode($gameurl);
					$thumb = $row['thumbnail'];
					$gamename = preg_replace('[^A-Za-z0-9]', '-', $row['title']);
					if ($setting['seo'] == 'yes') { 
						$playlink = ''. $setting['siteurl'] . 'game/' . $ID . '/' . $gameurl . '.html' ;
					} else {
						$playlink = ''. $setting['siteurl'] . 'index.php?act=game&id=' . $ID;
					}
					$thumburl = $setting['siteurl'].$thumb ;
					echo ""."<item>\n";

					echo ""."<title><![CDATA[ $name ]]></title>\n";
					echo ""."<link><![CDATA[ " . $playlink ." ]]></link>\n";
					echo ""."<description><![CDATA[ <img src='$thumburl' > $description ]]></description>\n";
					echo ""."</item>\n";
				}
				echo "</channel>\n";
				echo "</rss>";             
				$query->close();
				
				$fopen = fopen($rrsfile, 'w');
				fwrite($fopen, ob_get_contents());
				fclose($fopen);
				echo '<META http-equiv="refresh" content="2; URL=' . $setting['siteurl'] . 'admin/rss-arcade.php?act=done">';
				ob_end_flush();
				$rrsfile = '../rss-arcade-huge.xml';
				ob_start();
				print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
				print ""."<rss version=\"2.0\">\n";
				print ""."<channel>\n";
				print ""."<title>" . $setting['sitename'] . " - complete listing</title>\n";
				print ""."<link>" . $setting['siteurl'] . "</link>\n";
				print ""."<ttl>600</ttl>\n";
				print ""."<description>We love to give you the best in free games.</description>\n";
				print ""."<copyright>".date("Y")." " . $setting['sitename'] . " All rights reserved.</copyright>\n";   
				$query = yasDB_select("SELECT * FROM games ORDER BY id DESC");
				while($row = $query->fetch_array(MYSQLI_ASSOC)) {
					$name = $row['title'];
					$ID = $row['id'];
					$description = $row['description'];
					$gameurl = $row['title'];
					$gameurl = str_replace(" ", "-", $gameurl);
					$gameurl = str_replace("'", "_", $gameurl);
					$gameurl = str_replace('"', "_", $gameurl);
					$gameurl = str_replace('/', "_", $gameurl);
					$gameurl = str_replace("\\", "_", $gameurl);
					$gameurl = rawurlencode($gameurl);
					$thumb = $row['thumbnail'];
					if ($setting['seo'] == 'yes') {
						$playlink = ''. $setting['siteurl'] . 'game/' . $ID . '/' . $gameurl . '.html';
					} else {
						$playlink = ''. $setting['siteurl'] . 'index.php?act=game&id=' . $ID;
					}
					$thumburl = $setting['siteurl'] . $thumb;
					echo ""."<item>\n";
					echo ""."<title><![CDATA[ $name ]]></title>\n";
					echo ""."<link><![CDATA[ " . $playlink ." ]]></link>\n";
					echo ""."<description><![CDATA[ <img src='$thumburl' > $description ]]></description>\n";
					echo ""."</item>\n";
				}
				$query->close();
				
				echo "</channel>\n";
				echo "</rss>";             
				$fopen = fopen($rrsfile, 'w');
				fwrite($fopen, ob_get_contents());
				fclose($fopen);
				echo '<META http-equiv="refresh" content="2; URL=index.php?act=rssfeed&state=done">';
				ob_end_flush();
				break;
			default:
				break;
        }
		}
?>
    </div>
</div> 