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

checkUrlCorrectness('feature');
?>
<!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 Features</title>
<meta name="description" content="Operation Sports - is dedicated to information about sports video games, Madden, Fifa, sports news, press, reviews, screenshots of games" />
<meta name="keywords" content="Sports Video Games, Sports Video Games features, sports features, Madden Screenshots, Madden 25, FIFA Review, FIFA, sports, video games, Football features, Baseball features, Basketball features, Golf features, Hockey features, operation sports features, games features, sports features " />
<link rel="stylesheet" type="text/css" media="screen" href="//forums.operationsports.com/css/gen_stylev3_<?=filemtime('css/gen_stylev3.css')?>.css">
	<link rel="stylesheet" type="text/css" media="screen" href="//forums.operationsports.com/css/profilev4_responsive.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>
<?php
	/*
	<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="//forums.operationsports.com/js/yahoo/yahoo-dom-event.js?v=<?php echo $vbulletin->options['simpleversion']; ?>"></script>
	<script type="text/javascript" src="//forums.operationsports.com/js/yahoo/connection-min.js?v=<?php echo $vbulletin->options['simpleversion']; ?>"></script>

<script type="text/javascript" src="//forums.operationsports.com<?php echo $vbulletin->options['bburl2']; ?>/clientscript/vbulletin_global.js?v=<?php echo $vbulletin->options['simpleversion']; ?>"></script>
<script type="text/javascript" src="//forums.operationsports.com<?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
/* if filter */

$vbulletin->input->clean_array_gpc('r', array(
	'Filter' => TYPE_STR,
	'sport' => TYPE_STR,
	'added' => TYPE_STR,
	'order' => TYPE_STR,
	'sortby' => TYPE_STR,
	'page' => TYPE_UINT
));

if($vbulletin->GPC["Filter"] == "Filter")
{
	$where="";
	$and="";

	if(!empty($vbulletin->GPC["sport"]))
	{
		$where = " WHERE sport_id LIKE '%" . $db->escape_string_like($vbulletin->GPC["sport"]) . "%' ";
		$and = " AND ";
	}
	if(!empty($vbulletin->GPC["added"]))
	{
		if(empty($where))
		{
			$where = " WHERE ";
		}

		$where .= " $and date_format(feature_date,'%Y')='" . $db->escape_string($vbulletin->GPC["added"]) . "' ";
	}

	$sql = "SELECT *, date_format(feature_date,'%m/%d/%y') AS nicedate FROM cms_feature $where ORDER BY title";
}

$order = $vbulletin->GPC["order"];
if(empty($vbulletin->GPC["sortby"]))
{
	$sql = "
		SELECT *,date_format(feature_date,'%m/%d/%y') AS nicedate 
		FROM cms_feature 
		$where 
		ORDER BY feature_date DESC
	";
}
elseif($vbulletin->GPC["sortby"] == "sport")
{
	$sql = "
		SELECT cms_feature.title,cms_feature.id,cms_feature.sport_id,cms_feature.console_id,cms_feature.game_id,date_format(feature_date,'%m/%d/%y') AS nicedate 
		FROM cms_sport,cms_feature 
		" . iif($where, "$where AND", "WHERE") ." cms_feature.sport_id = cms_sport.id 
		ORDER BY cms_sport.name $order
	";
}
elseif($vbulletin->GPC["sortby"] == "title")
{
	$sql = "
		SELECT *,date_format(feature_date,'%m/%d/%y') AS nicedate 
		FROM cms_feature $where 
		ORDER BY title $order
	";
}
elseif($vbulletin->GPC["sortby"] == "date")
{
	$sql = "
		SELECT *,date_format(feature_date,'%m/%d/%y') AS nicedate 
		FROM cms_feature $where 
		ORDER BY feature_date $order
	";
}

$pagedata = $vbulletin->db->query_first("
	SELECT SQL_CACHE COUNT(*) AS count
	FROM  cms_feature
	$where
");
$pagedata['count'] = ($pagedata['count'] > 400)? 400 : $pagedata['count'];
$pagedata['pagenumber'] = ($vbulletin->GPC['page'] > 1)? $vbulletin->GPC['page'] : 1;

$pagedata['minlimit']   = intval(($pagedata['pagenumber'] - 1) * 40);
$sql .= " LIMIT $pagedata[minlimit], 40";

$cnx = $db->query_read($sql);
?>
	<div id="content">
		<!--reviews content-->
<div id="title_med">
	<div id="title_text">Features</div>
</div>
<div id="overview">
<!--News post-->
	<div id="articlewrapp">
			<div id="articletext">
			<div class="articlecontent">
<!--<strong>Filter by:</strong> | Sport | Added |-->

<center>
<form name="frmFilter" method="post">
	<?php
	/*platform*/
/*
	$sqlconsole= "select * from cms_console order by name";
	$cnxconsole = mysql_query($sqlconsole);*/
	?>
	<!--
	<select name="console" size="1" id="topfilter">
		<option value="">Platform</option>
		<?php
		while($resconsole = $db->fetch_array($cnxconsole))
		{
			if(!empty($vbulletin->GPC["console"]) AND $vbulletin->GPC["console"] == $resconsole["id"])
			{
		?>
				<option value="<?php echo $resconsole["id"]; ?>" selected><?php echo $resconsole["name"];  ?></option>
		<?php
			}
			else
			{
		?>
				<option value="<?php echo $resconsole["id"]; ?>"><?php echo $resconsole["name"];  ?></option>
		<?php
			}
		}
		?>
	</select>
	-->
	<?php
	/*sport*/
	$cnxsport = $db->query_read("
		SELECT * 
		FROM cms_sport 
		WHERE hidden = 0 
		ORDER BY name
	");
	?>
	<select name="sport" size="1" id="topfilter">
		<option value="">Sport</option>
		<?php
		while($ressport = $db->fetch_array($cnxsport))
		{
			if(!empty($vbulletin->GPC["sport"]) AND $vbulletin->GPC["sport"] == $ressport["id"])
			{
		?>
				<option value="<?php echo $ressport["id"]; ?>" selected><?php echo $ressport["name"];  ?></option>
		<?php
			}
			else
			{
		?>
				<option value="<?php echo $ressport["id"]; ?>"><?php echo $ressport["name"];  ?></option>
		<?php
			}
		}
		?>
	</select>

	<select name="added" size="1" id="topfilter">
		<option value="">Added</option>
		<?php
		$resadded  = $db->query_first("SELECT MIN(date_format(feature_date, '%Y')) AS minyear FROM cms_feature");
		$yearstart = $resadded["minyear"];

		$resadded = $db->query_first("SELECT MAX(date_format(feature_date, '%Y')) AS maxyear FROM cms_feature");
		$yearend  = $resadded["maxyear"];

		for($k=$yearstart;$k<=$yearend;$k++)
		{
			if(!empty($vbulletin->GPC["added"]) AND $vbulletin->GPC["added"] == $k)
			{
		?>
				<option value="<?php echo $k; ?>" selected><?php echo $k; ?></option>
		<?php
			}
			else
			{
		?>
				<option value="<?php echo $k; ?>"><?php echo $k; ?></option>
		<?php
			}
		}
		?>
	</select>

	<input type="submit" name="Filter" value="Filter"/>

</form>

</center>
<br />
	
	<div id="over_row">
		<div id="over_column_165" style="width:72%;">&nbsp;&nbsp;<a href="?<?php echo "Filter={$vbulletin->GPC['Filter']}&page={$vbulletin->GPC['page']}&sport={$vbulletin->GPC['sport']}&added={$vbulletin->GPC['added']}"; ?>&<?if ($vbulletin->GPC["order"]=="desc" && $vbulletin->GPC["sortby"]=="title") {?>sortby=title&order=asc<?}else {?>sortby=title&order=desc<?}?>" class="white">Feature Title</a></div>
		<div id="over_column_58" class="scHiddenMobile"><a href="?<?php echo "Filter={$vbulletin->GPC['Filter']}&page={$vbulletin->GPC['page']}&sport={$vbulletin->GPC['sport']}&added={$vbulletin->GPC['added']}"; ?>&<?if ($vbulletin->GPC["order"]=="desc"  && $vbulletin->GPC["sortby"]=="sport"){?>sortby=sport&order=asc<?}else {?>sortby=sport&order=desc<?}?>" class="white">Sport</a></div>
		<div id="over_column_58" class="scHiddenMobile"><a href="?<?php echo "Filter={$vbulletin->GPC['Filter']}&page={$vbulletin->GPC['page']}&sport={$vbulletin->GPC['sport']}&added={$vbulletin->GPC['added']}"; ?>&<?if ($vbulletin->GPC["order"]=="desc"  && $vbulletin->GPC["sortby"]=="date"){?>sortby=date&order=asc<?}else {?>sortby=date&order=desc<?}?>" class="white">Added</a></div>
	</div>


	<?php 
	while($res = $vbulletin->db->fetch_array($cnx))
	{
		$sport_id = explode(":", $res["sport_id"]);

		if (sizeof($sport_id) > 0 OR $vbulletin->GPC["sport"] > 0)
		{
			$ressport = &$vbulletin->sportcache[iif($vbulletin->GPC["sport"], $vbulletin->GPC["sport"], $sport_id[0])];
		}

/*
		for($count=0;$count<sizeof($console_id);$count++)
		{
			$sqlconsole= "select * from cms_console where id=" . $console_id[$count];
			$cnxconsole = mysql_query($sqlconsole);
			$line=0;
			while ($resconsole = mysql_fetch_array($cnxconsole))
			{
				$resconsolename.=$resconsole["name"];
				$line=$line+1;
			}
		}*/
/*
		$sqlgame= "select * from cms_game where id=" . $res["game_id"];
		$cnxgame = mysql_query($sqlgame);
		$resgame = mysql_fetch_array($cnxgame);
		*/
	?>




	<div id="over_row">
		<div id="over_column0_165" style="width:72%">&nbsp;&nbsp;<a href="<?php echo getUrl('feature', $res['title'], $res['id'])?>" class="news"><? echo fetch_trimmed_title($res["title"], 55, '...'); ?></a></div>

		<div id="over_column0_58" class="scHiddenMobile"><? echo (!empty($ressport['name']))? $ressport['name'] : "N/A"; ?></div>
		
		<div id="over_column0_58" class="scHiddenMobile">
		<? 
		if($res["notallowed"]==0)
		{
			echo vbdate("M d, Y", strtotime($res["nicedate"])); 
		}
		else
		{
			echo "N/A";
		}
		?></div>
	</div>
	<?
	}
	?>

	


			</div>
			</div>
<?php
if ($pagedata['count'] > 40)
{
?>
<div align="center">
<div id="link_row2">

<div align="center">
<?php
	require_once('include/pagination.inc.php');
	$pagelink = "?Filter=Filter&sport={$vbulletin->GPC['sport']}&added={$vbulletin->GPC['added']}&sortby={$vbulletin->GPC['sortby']}&order={$vbulletin->GPC['order']}&page=";

	echo getPaginationString($pagedata['pagenumber'], $pagedata['count'], 40, 3, $pagelink, $pageand);
?>

</div>

		</div>
	</div>
<?php
}
?>
</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/poll.inc.php"); ?>
	</div>
<?php 

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

?>