Anybody know how to setup RSS feed for ATS? I try to find some code but can't find anything, should not be so complicated to pull the game name, description and URL!?
Anybody know how to setup RSS feed for ATS? I try to find some code but can't find anything, should not be so complicated to pull the game name, description and URL!?
Try this, save as rss.php and place into your root (built based on ats-plug-helper.php)
If you find any bugs, let me know and I'll fix em up.PHP Code:<?php
/*
#################################################################
## Script is copyrighted to ArcadeTradeScript.com and you are free
## modify it as you wish as long as credit is given back to us.
##
## This is a free Script provided by Lfhost and
## was made for arcades using ArcadeTradeScript.
#################################################################
*/
include("./inc/main-func.php");
include("./admin/config.php");
//##############################################
// You need to edit this part.
// What is the URL Structure for your hosted game pages?
// Below are the default URL structures. If you have not
// changed them at all then you don't need to edit these.
if ($seoFriendly == 1) {
$preGameStructure = "[basedir][category]/play-[gamename]"; // The exact URL structure for your pre game pages.
$playGameStructure = "[basedir][seodir]/[gamename]"; // The exact URL structure for your play game pages.
} else {
$preGameStructure = "[basedir]index.php?a=play&id=[gameid]"; // The exact URL structure for your pre game pages.
$playGameStructure = "[basedir]index.php?a=play&id=[gameid]&cont=1"; // The exact URL structure for your play game pages.
}
/*
This is made easy to edit by the use of special variables.
[basedir] = this will be replace automatically with the base directory of
your arcade that you set in your admin.
[seodir] = this will be replace automatically with the SEO directory of
play game pages that you set in your admin.
[gameid] = this will be replace automatically with the ID of the game
that is found.
[gamename] = this will be replace automatically with the name of the game
that is found (ex: my-game-name-3).
[category] = this will be replace automatically with the name of the category
for the game that is found (ex: my-category-name).
*/
//##############################################
$result = mysql_query("SELECT gid, gName, cat, tradeType, gDesc, addedOn FROM ats_games WHERE gStatus = 1 ") or die(mysql_error());
if (mysql_num_rows($result)) {
while($row = mysql_fetch_array($result)) {
$gameID = $row['gid'];
$gameName = remove_slashes($row['gName']);
$catID = $row['cat'];
$tradeType = $row['tradeType'];
$gDesc = remove_slashes($row['gDesc']);
$addedOn = $row['addedOn'];
$gameCat = getGameCat($catID);
// Getting the actual game page URL
$preGameStructure2 = str_replace("[basedir]", $baseDir, $preGameStructure);
$preGameStructure2 = str_replace("[seodir]", $seoDir, $preGameStructure2);
$preGameStructure2 = str_replace("[gameid]", $gameID, $preGameStructure2);
$preGameStructure2 = str_replace("[gamename]", seo_str_plain($gameName), $preGameStructure2);
if (preg_match("/\[category\]/",$preGameStructure2)) {
$preGameStructure = str_replace("[category]", seo_str_plain($gameCat), $preGameStructure);
}
$playGameStructure2 = str_replace("[basedir]", $baseDir, $playGameStructure);
$playGameStructure2 = str_replace("[seodir]", $seoDir, $playGameStructure2);
$playGameStructure2 = str_replace("[gameid]", $gameID, $playGameStructure2);
$playGameStructure2 = str_replace("[gamename]", seo_str_plain($gameName), $playGameStructure2);
if (preg_match("/\[category\]/",$playGameStructure)) {
$playGameStructure = str_replace("[category]", seo_str_plain($gameCat), $playGameStructure2);
}
if ($preGamePageStatus == "0" || ($preGamePageStatus == 2 && $tradeType == "0")) {
$items_output .= "<item>
<title><![CDATA[{$gameName}]]></title>
<link>{$preGameStructure2}</link>
<description>
<![CDATA[{$gDesc}]]>
</description>
<category>{$gameCat}</category>
<pubDate>{$addedOn}</pubDate>{$author}
<guid>{$preGameStructure2}</guid>
</item> ";
} elseif (($preGamePageStatus == 1 || $preGamePageStatus == 2) && $tradeType == 1) {
$items_output .= "<item>
<title><![CDATA[{$gameName}]]></title>
<link>{$playGameStructure2}</link>
<description>
<![CDATA[{$gDesc}]]>
</description>
<category>{$gameCat}</category>
<pubDate>{$addedOn}</pubDate>{$author}
<guid>{$playGameStructure2}</guid>
</item> ";
} else {
}
}
}
$pageTitle = seoMiscTitle($siteName,$homePageTitle);
$encoding = 'ISO-8859-1';
$copyright = "<copyright>".date('Y')." ".$pageTitle."</copyright>";
$pubdate = "<pubDate>".gmdate('r')."</pubDate>";
$language = "<language>en-us</language>";
$output = "<?xml version=\"1.0\" encoding=\"{$encoding}\" ?>
<rss version=\"2.0\">
<channel>
<title>{$pageTitle} Feed</title>
<link>".$baseDir."</link>
<description>{$pageTitle}Feed</description>{$copyright}{$pubdate}{$language}{$items_output}
</channel>
</rss>
";
header("Content-type: application/rss+xml; charset={$encoding}");
echo $output;
?>
Hey this works
http://www.sniperflashgames.com/rss.php
Just 3 things:
How to display only the last 20 new games? (don't know if its good to display all?)
How to display the time added
The RSS sign is not showing in the browser
Thanks a lot
try this
fixes,
1, ID in url.
2, 20 Games limit
3, New to Old
4, RSS date added.
It wont show the RSS icon, as its a PHP page, but it is a valid RSS feed, you can use a feed validator.
You could probably add a line to your .htaccess like
then you can call rss.xml instead of the PHP page.PHP Code:##RSS
RewriteRule ^rss.xml rss.php [L]
PHP Code:<?php
/*
#################################################################
## Script is copyrighted to ArcadeTradeScript.com and you are free
## modify it as you wish as long as credit is given back to us.
##
## This is a free Script provided by Lfhost and
## was made for arcades using ArcadeTradeScript.
#################################################################
*/
include("./inc/main-func.php");
include("./admin/config.php");
//##############################################
// You need to edit this part.
// What is the URL Structure for your hosted game pages?
// Below are the default URL structures. If you have not
// changed them at all then you don't need to edit these.
if ($seoFriendly == 1) {
$preGameStructure = "[basedir][category]/[gameid]/play-[gamename]"; // The exact URL structure for your pre game pages.
$playGameStructure = "[basedir][seodir]/[gameid]/[gamename]"; // The exact URL structure for your play game pages.
} else {
$preGameStructure = "[basedir]index.php?a=play&id=[gameid]"; // The exact URL structure for your pre game pages.
$playGameStructure = "[basedir]index.php?a=play&id=[gameid]&cont=1"; // The exact URL structure for your play game pages.
}
/*
This is made easy to edit by the use of special variables.
[basedir] = this will be replace automatically with the base directory of
your arcade that you set in your admin.
[seodir] = this will be replace automatically with the SEO directory of
play game pages that you set in your admin.
[gameid] = this will be replace automatically with the ID of the game
that is found.
[gamename] = this will be replace automatically with the name of the game
that is found (ex: my-game-name-3).
[category] = this will be replace automatically with the name of the category
for the game that is found (ex: my-category-name).
*/
//##############################################
$result = mysql_query("SELECT gid, gName, cat, tradeType, gDesc, addedOn FROM ats_games WHERE gStatus = 1 order by gid DESC limit 0,20 ") or die(mysql_error());
if (mysql_num_rows($result)) {
while($row = mysql_fetch_array($result)) {
$gameID = $row['gid'];
$gameName = remove_slashes($row['gName']);
$catID = $row['cat'];
$tradeType = $row['tradeType'];
$gDesc = remove_slashes($row['gDesc']);
$addedOn = gmdate('r',$row['addedOn']);
$gameCat = getGameCat($catID);
// Getting the actual game page URL
$preGameStructure2 = str_replace("[basedir]", $baseDir, $preGameStructure);
$preGameStructure2 = str_replace("[seodir]", $seoDir, $preGameStructure2);
$preGameStructure2 = str_replace("[gameid]", $gameID, $preGameStructure2);
$preGameStructure2 = str_replace("[gamename]", seo_str_plain($gameName), $preGameStructure2);
if (preg_match("/\[category\]/",$preGameStructure2)) {
$preGameStructure = str_replace("[category]", seo_str_plain($gameCat), $preGameStructure);
}
$playGameStructure2 = str_replace("[basedir]", $baseDir, $playGameStructure);
$playGameStructure2 = str_replace("[seodir]", $seoDir, $playGameStructure2);
$playGameStructure2 = str_replace("[gameid]", $gameID, $playGameStructure2);
$playGameStructure2 = str_replace("[gamename]", seo_str_plain($gameName), $playGameStructure2);
if (preg_match("/\[category\]/",$playGameStructure)) {
$playGameStructure = str_replace("[category]", seo_str_plain($gameCat), $playGameStructure2);
}
if ($preGamePageStatus == "0" || ($preGamePageStatus == 2 && $tradeType == "0")) {
$items_output .= "<item>
<title><![CDATA[{$gameName}]]></title>
<link>{$preGameStructure2}</link>
<description>
<![CDATA[{$gDesc}]]>
</description>
<category>{$gameCat}</category>
<pubDate>{$addedOn}</pubDate>{$author}
<guid>{$preGameStructure2}</guid>
</item> ";
} elseif (($preGamePageStatus == 1 || $preGamePageStatus == 2) && $tradeType == 1) {
$items_output .= "<item>
<title><![CDATA[{$gameName}]]></title>
<link>{$playGameStructure2}</link>
<description>
<![CDATA[{$gDesc}]]>
</description>
<category>{$gameCat}</category>
<pubDate>{$addedOn}</pubDate>{$author}
<guid>{$playGameStructure2}</guid>
</item> ";
} else {
}
}
}
$pageTitle = seoMiscTitle($siteName,$homePageTitle);
$encoding = 'ISO-8859-1';
$copyright = "<copyright>".date('Y')." ".$pageTitle."</copyright>";
$pubdate = "<pubDate>".gmdate('r')."</pubDate>";
$language = "<language>en-us</language>";
$output = "<?xml version=\"1.0\" encoding=\"{$encoding}\" ?>
<rss version=\"2.0\">
<channel>
<title>{$pageTitle} Feed</title>
<link>".$baseDir."</link>
<description>{$pageTitle}Feed</description>{$copyright}{$pubdate}{$language}{$items_output}
</channel>
</rss>
";
header("Content-type: application/rss+xml; charset={$encoding}");
echo $output;
?>
The rewrite rule didn't work bud the feed works very good now
http://www.sniperflashgames.com/rss.php
I will get a twitter account for it now
Thanks a lot!
make sure to put it above all the other rules
it should work, I do it on my custom CMS for the sitemap.
Feel free to share it on the ATS/TA forums if you want to.
Woochoo is free to use it in the core script if he wants it,
Enjoy,
a good option would be to get a random game. That way you can use it to post games on twitter, several times a day :-)