<?php


$allow_guests = true;

include('core.php');
include('includes/session.php');

$body_id = "news";
$pageid = "4";
//$id = $_GET['id'];
//yaya

if($_GET['id']){
        $news_id = $_GET['id'];
        $main_sql = mysql_query("SELECT * FROM cms_news WHERE num = '".$news_id."'") or die(mysql_error());
        $article_exists = mysql_num_rows($main_sql);
	if($article_exists == "1"){
                $news = mysql_fetch_assoc($main_sql);
                $pagename = "News - " . $news['title'];
                $archive = "0";
	} else {
                $pagename = "Articolo inesistente!";
                $archive = "1";
	}

      
} else {
        $pagename = "News";
        $archive = "1";
}

include('templates/community/subheader.php');
include('templates/community/header.php');

?>


<?php
function FilterNew($str, $news_id)
{
	$str = str_replace("à", "&agrave;",($str));
	$str = str_replace('\r\n', '', ($str));
	$str = str_replace('\"', '', ($str));
	$str = str_replace("è", "&egrave;",($str));
	$str = str_replace("ì", "&igrave;",($str));
	$str = str_replace("ò", "&ograve;",($str));
	$str = str_replace("ù", "&ugrave;",($str));

	
	return $str;
}
?>

<div id="container">
	<div id="content">
    <div id="column1" class="column">
				<div class="habblet-container ">
						<div class="cbb clearfix default ">

							<h2 class="title">News
							</h2>
						<div id="article-archive">



<h2>Tutte le News</h2>
<ul>
	<li>
<?php
	$get_sub_archive = mysql_query("SELECT num, title, date FROM cms_news ORDER BY num DESC LIMIT 50");
	$count = mysql_num_rows($get_sub_archive);

	if($count > 0){
		while ($row = mysql_fetch_array($get_sub_archive, MYSQL_NUM)) {
			printf("<li><a href='news.php?id=%s'>%s</a> &raquo;</li>", $row[0], HoloText($row[1]));
		}
	} else {
		echo "<br />No headlines to display yet.";
	}
	?>
</li>
</ul>

</div>


					</div>
				</div>
				<script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>

</div>
<div id="column2" class="column">
				<div class="habblet-container ">
						<div class="cbb clearfix notitle ">

<?php if($archive < 1){ ?>
						<div id="article-wrapper">
	<h2><?php echo$news['title']; ?></h2>
	<div class="article-meta">Postata il <?php echo $news['date']; ?>
             <a href="news.php?category=<?php echo $news['category']; ?>"><?php echo $news['category']; ?></a>
</div>
	<p class="summary"><?php echo nl2br(htmlspecialchars(stripslashes($news['short_story']))); ?></p>

	<div class="article-body">
	<p><?php echo stripslashes(FilterNew($news['story'], $news['id'])); ?></p>


	    <div class="article-body"><a href='user_profile.php?name=<?php echo $news['author']; ?>' target='_self'><img src='./web-gallery/album1/users_online.PNG' alt='User Profile' border='0'></a><b><?php echo $news['author']; ?></b>






			</div>

	</div>
</div>
<?php } elseif($archive == "1"){ ?>
<div id="article-wrapper">

				<h2>Articolo inesistente</h2>
	<div class="article-meta" style="height: 1px">&nbsp;</div>
	L'articolo non esiste: clicca su un Articolo esistente!
</div>

<?php } ?>



					</div>
				</div>


</div>

<div id="column3" class="column">
</div>

<?php

include('templates/community/footer.php');

?>