<?php

// ***************************************************************************
// * Copyright © 2003 - Thomas Egtvedt - www.evaria.com - thomas@evaria.com  *
// *                                                                         *
// *      ECMS - Content Management System - Support: forum.evaria.com       *
// *                                                                         *
// * This program is commercial software; you can not redistribute/reproduce *
// * it and/or sell it without the prior written consent of www.evaria.com   *
// *                                                                         *
// * This program is distributed in the hope that it will be useful,         *
// * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                    *
// ***************************************************************************

// Connecting to DB to collect info about new links...
$sql_admin = "SELECT nb_days2benew FROM $T_infos ";
$lk = connection_BD();
$res_admin = send_sql($sql_admin,"finding number of days a link is considered new");
$result_admin = mysql_fetch_array($res_admin,MYSQL_ASSOC);
$nb_days2benew = $result_admin["nb_days2benew"];
$sql = "SELECT s.id, titre, description, date_validation, nb_clics, c.id as id_cat, cat_name FROM $T_sites s, $T_categories c WHERE s.id_cat = c.id AND s.activation = 1 AND c.activation = 1 AND date_validation BETWEEN DATE_SUB(CURRENT_DATE,INTERVAL $nb_days2benew DAY) AND DATE_SUB(CURRENT_DATE,INTERVAL 0 DAY) ORDER BY date_validation DESC,niveau ASC,titre ASC ";
$res = send_sql($sql,"finding the new links");
mysql_close($lk);
?>

<TABLE align="center" width="<? echo $table_width; ?>" cellspacing="0" cellpadding="0" border="0">
  <TR>
    <TD class="link_m_head"><img src="./img/h_redirect.gif" width="32" height="32" alt="New Links" border="0" align="absmiddle">  New links added in the last <? echo $nb_days2benew; ?> days »</TD>
  </TR>
</TABLE>

<br><br>

<TABLE align="center" width="<? echo $table_width; ?>" cellspacing="0" cellpadding="0" border="0">
  <TR>
    <TD>
<?
// working the DB input...
if (mysql_num_rows($res))
{
	$date_test = "";
	while ($resultat = mysql_fetch_array($res,MYSQL_ASSOC))
	{
		$date_convertie = convert_date_us2fr($resultat["date_validation"]);
		if ($date_test != $date_convertie)
		{
			if (!empty($date_test))
				echo "<br>";
			$date_test = $date_convertie;
			?>
    <span class="link_date_new">&raquo;&raquo; <? echo $date_convertie; ?></span></TD>
  </TR>
  <TR>
    <TD><br>
			<?
		}
		affiche_site($resultat,"new");
	}
}
else // If no new links...
{
	?>
	<center><br><br><br><br>
	<span class="link_error">
	No new links in the past <? echo $nb_days2benew; ?> days...
	</span>
	</center>
	<?
}
echo "    </TD>\n  </TR>\n</TABLE>\n";
?>
