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

checkUrlCorrectness('press');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "//www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:fb="//www.facebook.com/2008/fbml" dir="ltr" lang="en-US">
<head>
<title>Operation Sports - Sports Video Games Press Releases</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="press releases, Sports Video Games, Sports Video Games press releases, sports press releases, Madden Screenshots, Madden 25, FIFA reviews, FIFA, sports, video games, Football press releases, Baseball press releases, Basketball press releases, Golf press releases, Hockey press releases, operation sports press releases, games press releases, sports press releases " />

<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>
	<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_INT,
	'added' => TYPE_INT,
	'order' => TYPE_STR,
	'sortby' => TYPE_STR,
	'page' => TYPE_UINT
));

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

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

		//$sql_join = " LEFT JOIN cms_sport ON (sport_id = cms_sport.id) ";
		$where.=" sport_id LIKE '%{$vbulletin->GPC["sport"]}%' ";
		$and="and";
	}
	if($vbulletin->GPC["added"]!="")
	{
		if($where=="")
		{
			$where=" where ";
		}

		$where.=" " . $and . " FROM_UNIXTIME(dateline,'%Y')='{$vbulletin->GPC["added"]}' ";
		$and="and";
	}
}

switch($vbulletin->GPC['sortby'])
{
	case 'title':
		$sql_sortby = 'title';
		break;
	case 'sport':
		$sql_sel = ", cms_sport.name AS sport_name";
		$sql_join = " LEFT JOIN cms_sport ON (sport_id = cms_sport.id) ";
		$sql_sortby = 'sport_name';
		break;
	case 'date':
	default:
		$sql_sortby = 'dateline';
		break;
}

$pagedata = $vbulletin->db->query_first("
	SELECT COUNT(*) AS count
	FROM  cms_press
	$sql_join
	$where
");

//$pagedata['count'] = ($pagedata['count'] > 400)? 400 : $pagedata['count'];
$pagedata['pagenumber'] = ($vbulletin->GPC['page'] > 1)? $vbulletin->GPC['page'] : 1;

$pagedata['minlimit']   = ($pagedata['pagenumber'] - 1) * 40;

$cnx = $vbulletin->db->query_read("
	(
		SELECT press.game_id, press.title, press.dateline, press.sport_id, 0 AS threadid, press.id 
			$sql_sel
		FROM `cms_press` AS press
		$sql_join
		$where
	)
	UNION 
	(
		SELECT news.game_id, thread.title, thread.dateline, news.sport_id, news.threadid, 0 AS id
			$sql_sel
		FROM cms_news AS news
		$sql_join
		INNER JOIN thread ON (news.threadid = thread.threadid)
		$where " . iif($where, "AND press=1", "WHERE press = 1") . "
	)
	ORDER BY $sql_sortby {$vbulletin->GPC['order']}
	LIMIT $pagedata[minlimit], 40
");

?>
	<div id="content">
		<!--reviews content-->
<div id="title_med">
	<div id="title_text">Press Releases</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 = mysql_fetch_array($cnxconsole))
		{
			if($vbulletin->GPC["console"]!="" && $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($vbulletin->GPC["sport"]!="" && $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(FROM_UNIXTIME(dateline,'%Y')) AS minyear FROM cms_press");
		$yearstart = $resadded["minyear"];

		$resadded = $db->query_first("SELECT MAX(FROM_UNIXTIME(dateline,'%Y')) AS maxyear FROM cms_press");
		$yearend=$resadded["maxyear"];

		for($k=$yearstart;$k<=$yearend;$k++)
		{
			if($vbulletin->GPC["added"]!="" && $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:74%;">&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">Press Release Title</a></div>
		<div id="over_column_55" 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"]);

		$ressportname="";


		for($count=0;$count<sizeof($sport_id);$count++)
		{
			$cnxsport = $db->query_read("SELECT * FROM cms_sport WHERE hidden = 0 AND id=" . intval($sport_id[$count]));
			$line=0;
			if ($db->num_rows($cnxsport) > 0)
			{
				while ($ressport = $db->fetch_array($cnxsport))
				{
					$ressportname.=$ressport["name"];
					$line=$line+1;
				}
			}
		}

		for($count=0;$count<sizeof($console_id);$count++)
		{
			$cnxconsole = $db->query_read("SELECT * FROM cms_console WHERE id=" . $console_id[$count]);
			$line=0;
			while ($resconsole = $db->fetch_array($cnxconsole))
			{
				$resconsolename.=$resconsole["name"];
				$line=$line+1;
			}
		}

		$resgame = $db->query_first("SELECT * FROM cms_game WHERE id=" . $res["game_id"]);
		$link = ($res['id'] > 0)? getUrl('press', $res['title'], $res['id']) : getUrl('news', $res['title'], $res['threadid']);
	?>




	<div id="over_row">
		<div id="over_column0_165" style="width:74%">&nbsp;&nbsp;<a href="<?php echo $link; ?>"  class="news" title="<?php echo $res["title"]; ?>"><? echo fetch_trimmed_title($res["title"], 50, true); ?></a></div>

		<div id="over_column0_55" class="scHiddenMobile"><?php echo $ressportname; ?></div>
		
		<div id="over_column0_58" class="scHiddenMobile">
		<? 
		if($res["notallowed"]==0)
		{
			echo vbdate("M d, Y", $res["dateline"]); 
		}
		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();

?>