<?php 
define('THIS_SCRIPT', 'ps_platforms');
$loadCacheItems = array('lastFive');
include "admin/main/config.php";
sql_connect();

checkUrlCorrectness('platform');
?>
<?php
$garbage_timeout = 3600; // 3600 seconds = 60 minutes = 1 hour
ini_set('session.gc_maxlifetime', $garbage_timeout);
session_start();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "//www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head>
<title>Operation Sports - Sports Video Games Platforms and Consoles</title>
<meta name="description" content="Operation Sports - is dedicated to information about sports video games, Madden, Fifa, sports news, press releases, reviews, screenshots of games" />
<meta name="keywords" content="Platforms, Consoles, Sports Video Games Platforms, DC, GBA, Mac, NDS, NGC, PC, PS2, PS3, PSOne, PSP, Wii, Wireless, Xbox, Xbox 360, Sports Video Games, Sports Video Games press releases, sports press releases, Madden Screenshots, Madden 09, FIFA reviews, FIFA, sports, video games, Football, Baseball, Basketball, Golf, Hockey " />

<link rel="stylesheet" type="text/css" media="screen" href="/css/gen_stylev3.css?<?=filemtime('css/gen_stylev3.css')?>">
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
<!--
	var minchars = <?php echo $vbulletin->options['postminchars']?>;
	var SECURITYTOKEN = "<?=$vbulletin->userinfo['securitytoken']?>";
	var BBURL = '<?=$vbulletin->options['bburl2']?>';
	var IMGDIR_MISC = "<?=$stylevar['imgdir_misc']?>";
	var SESSIONURL = "<?=$session['sessionurl_js']?>";
//-->
</script>
<script type="text/javascript" src="<?php echo $vbulletin->options['bburl2']; ?>/clientscript/yui/yahoo-dom-event/yahoo-dom-event.js?v=<?php echo $vbulletin->options['simpleversion']; ?>"></script>
<script type="text/javascript" src="<?php echo $vbulletin->options['bburl2']; ?>/clientscript/yui/connection/connection-min.js?v=<?php echo $vbulletin->options['simpleversion']; ?>"></script>
<script type="text/javascript" src="<?php echo $vbulletin->options['bburl2']; ?>/clientscript/vbulletin_global.js?v=<?php echo $vbulletin->options['simpleversion']; ?>"></script>
<script type="text/javascript" src="<?php echo $vbulletin->options['bburl2']; ?>/clientscript/vbulletin_menu.js?v=<?php echo $vbulletin->options['simpleversion']; ?>"></script>
<link rel="shortcut icon" href="favicon.ico" >
</head>
<?php
include ("include/header_intergiv3.inc.php");
include (DIR . "/include/bannerlogin_temp_test_intergi.inc.php");
?>
<?php
$vbulletin->input->clean_array_gpc('r', array(
	'order'  => TYPE_STR,
	'sortby' => TYPE_STR
));

switch(strtolower($vbulletin->GPC['order']))
{
	case 'asc':
	case 'desc':
		break;
	default:
		$vbulletin->GPC['order'] = 'asc';
}

if(empty($vbulletin->GPC['sortby']) OR $vbulletin->GPC['sortby'] == "console")
{
	$sql = "
		SELECT cms_console.id, cms_console.name AS name 
		FROM cms_console, cms_game 
		WHERE cms_console.id = cms_game.console_id
		GROUP BY cms_console.id 
		ORDER BY cms_console.name {$vbulletin->GPC['order']}
	";
}
elseif($vbulletin->GPC['sortby'] == "games")
{
	$sql = "
		SELECT cms_console.id, cms_console.name AS name 
		FROM cms_console, cms_game 
		WHERE cms_console.id = cms_game.console_id
		GROUP BY cms_console.id 
		ORDER BY (SELECT COUNT(*) AS count FROM cms_game WHERE FIND_IN_SET(cms_console.id, cms_game.console_id)) {$vbulletin->GPC['order']}, cms_console.name
	";
}
$cnx = $db->query_read($sql);
?>
	<div id="left">
    	<?php include ("include/nav.inc.php"); ?>
	</div>
	<div id="content">
		<!--reviews content-->
<div id="title_med">
	<div id="title_text">Platforms</div>
</div>
<div id="overview">
<!--News post-->
	<div id="articlewrapp">
			<div id="articletext">
			<div class="articlecontent">





	<div id="over_row">
		<div id="over_column_165" style="width:75%;">&nbsp;&nbsp;<a href="<?if ($vbulletin->GPC['order'] == "desc" AND $vbulletin->GPC['sortby'] == "console"){?>?sortby=console&order=asc<?}else {?>?sortby=console&order=desc<?}?>" class="white">Platform Name</a></div>
        <div id="over_column_58" style="width:20%;"><a href="<?if ($vbulletin->GPC['order'] == "desc" AND $vbulletin->GPC['sortby'] == "games"){?>?sortby=games&order=asc<?}else {?>?sortby=games&order=desc<?}?>" class="white">Games</a></div>
	</div>
<?
	while ($res = $db->fetch_array($cnx))
	{
		$rescount = $db->query_first("
			SELECT COUNT(*) AS count
			FROM cms_game 
			WHERE FIND_IN_SET('" . intval($res["id"]) . "', cms_game.console_id)
		");
?>
		<div id="over_row">
			<div id="over_column0_165" style="width:75%;">&nbsp;&nbsp;<a href="<?php echo getUrl('platform', $res['name'], $res['id']) ?>"  class="news"><? echo $res["name"]; ?></a></div>
			<div id="over_column0_58" style="width:20%;"><? echo $rescount["count"]; ?></div>
		</div>
<?
	}
?>


			</div>
			</div>
	</div>
<!--News post-->
</div>
		<!--/reviews content-->
	</div>
	<div id="right">

		<?php include ("include/last5.inc.php"); ?>

    	<?php include ("include/ad300x250.inc.php"); ?>

		<?php include ("include/games.inc.php"); ?>
		<?php include ("include/poll.inc.php"); ?>
	</div>
<?php 

include ("include/footer.inc.php"); 
exec_shut_down();

?>