<?php 

// Include absolute site path.
// DO NOT EDIT or things will break horribly

include("path.php");

// This is the main page

$file = "index";

// Include the header

include("".$path."/templates/header.php");

// Include the POTD

include("".$path."/includes/potd.php");

$potd_verbage = stripslashes($potd_verbage);
$potd_verbage = stripslashes($potd_verbage);

echo "<div class=\"section\">Featured Image</div>
		<div class=\"content\">
			<table width=\"100%\" border=\"0\"><tr>
				<td align=\"center\">
					<a href=\"/potd.php/".$year."/1/".$current_potd."\"><img src=\"/images/potd/".$year."/".$current_potd."\" alt=\"Click to enlarge\" width=\"180\" height=\"121\" border=\"0\" class=\"potdlink\"/></a>
				</td>
				<td align=\"left\" width=\"100%\">
					<p>".$potd_verbage."</p>
					<p class=\"footer\">Got a picture we should feature? <a href=\"/content.php/about/potd.php\">Submit it!</a></p>
				</td>
			</tr></table>
		</div>";

// Include the news page

if($cat != "" or $skip != "" )
{

		echo "<div class=\"section\">News</div>
		<div class=\"content\">";

	  include("news/archive/path.php3");
	  include("$absolutepath/includes/connect.php3");
	  include("$absolutepath/includes/class.FastTemplate.php3");
	  include("$absolutepath/includes/printnewsitem.php3");
	  include("$absolutepath/includes/striphtml.php3");
	  
	  if($cat != "")
	  {
		  $catquery = "select category from categories where autonumber = '$cat'";
		  $catresult = mysql_query($catquery);
		  $category = mysql_result($catresult,0,"category");
		  
		  $where = "WHERE category = '$category'";
	  
	  	  echo "<p>Only displaying <b>".$category."</b> related news. <a href=\"/index.php\">Click here</a> to display all news.</p>";
	  }
	  if($skip != "" && $skip > 0)
	  {
	  	$limit = $skip . "," . $itemsshown;
		$recentlink = "&lt;&lt; <a href='index.php?cat=".$cat."&skip=".$recentskip."'>Recent news</a> |";
	  }
	  else
	  {
	  	$skip = "0";
		$limit = $itemsshown;
	  }
	  
	  $recentskip = $skip;
	  $skip = $skip + $itemsshown;
	  
	  $newsquery = "SELECT * FROM news $where ORDER BY date DESC LIMIT $limit";
	  $newsresult = mysql_query($newsquery);
	  $number = mysql_num_rows($newsresult);
	
	   $date = mysql_result($newsresult,$i,"date");
		  $datequery="select DATE_FORMAT('$date','%b.%e.%Y') as dateme"; 
		  $dateresult = MYSQL_QUERY($datequery);
		  $dateformat = mysql_result($dateresult,0,"dateme");

		  $date2 = mysql_result($newsresult,$g,"date");
		  $datequery2 ="select DATE_FORMAT('$date','%l:%i %p') as dateme"; 
		  $dateresult2 = MYSQL_QUERY($datequery2);
		  $dateformat2 = mysql_result($dateresult2,0,"dateme");
	 
	  for ($i = 0; $i < $number; $i++)
	  {
		  $updater =  stripslashes(mysql_result($newsresult,$i,"news_updater"));
		  $followup = stripslashes(mysql_result($newsresult,$i,"followup"));
		  $news_subject = stripslashes(mysql_result($newsresult,$i,"news_subject"));
		  $news_item = stripslashes(mysql_result($newsresult,$i,"news_item"));
			 $news_item = str_replace("style=\"color: #E7DFE1;\"","style=\"color: #003366;\"",$news_item);
		  $date = mysql_result($newsresult,$i,"date");
		  
		  $datequery="select DATE_FORMAT('$date','%b.%e.%Y') as dateme";
		  $dateresult = MYSQL_QUERY($datequery);
		  $dateformat = mysql_result($dateresult,0,"dateme");
		  $date2 = mysql_result($newsresult,$i,"date");
		 
		  $datequery2="select DATE_FORMAT('$date','%l:%i %p') as dateme";
		  $dateresult2 = MYSQL_QUERY($datequery2);
		  $dateformat2 = mysql_result($dateresult2,0,"dateme");
		  
		  $category = mysql_result($newsresult,$i,"category");
		  $thread_id = mysql_result($newsresult,$i,"thread_id");
		  
		  $newsupdateautonumber = stripslashes(mysql_result($newsresult,$i,"autonumber"));
		  $autonumber = $newsupdateautonumber;
		  
		  printnewsitem($updater,$news_subject,$news_item,$dateformat,$dateformat2,$followup,$autonumber,1,$category,$thread_id);
		  
	  }
	  if($number == "15")
	  {
	  	echo "<p align='right'><b>".$recentlink." <a href='index.php?cat=".$cat."&skip=".$skip."'>Older news</a> &gt;&gt;</b></p>";
	  }
}
else
{
	echo "<div class=\"section\">Latest News</div>
		<div class=\"content\">";

	include("".$path."/news/test.shtml");
	include("".$path."/update_site/news/includes/currentitems.inc.php");
	echo "<p align='right'><b><a href='index.php?skip=".$currentitems."'>Older News</a> &gt;&gt;</b></p>";
}

echo "</div>";

// Include the footer

include("".$path."/templates/footer.php");

?>
