<?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.                    *
// ***************************************************************************

$sql_admin = "SELECT nb_sites_in_topclics, nb_days2benew FROM $T_infos ";
$lk = connection_BD();

$res_admin = send_sql($sql_admin,"finding number of sites to be listed in popular");
$result_admin = mysql_fetch_array($res_admin,MYSQL_ASSOC);
$nb_sites_top_clics = $result_admin["nb_sites_in_topclics"];
$nb_days2benew = $result_admin["nb_days2benew"];
$sql = "SELECT s.id, id_cat, titre, description, url, nb_clics, date_validation, cat_name, TO_DAYS(CURRENT_DATE) - TO_DAYS(date_validation) AS dif_days FROM $T_sites AS s, $T_categories AS c WHERE s.id_cat = c.id AND s.activation = 1 AND c.activation = 1 AND nb_clics > 0 ORDER BY nb_clics DESC,titre LIMIT 0,$nb_sites_top_clics";
$res = send_sql($sql,"finding the sites in popular");
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_stats.gif" width="32" height="32" alt="Popular" border="0" align="absmiddle">&nbsp;&nbsp;Top <? echo $nb_sites_top_clics; ?> links based on hits &raquo;</TD>
  </TR>
</TABLE>

<br><br>
<?
if (mysql_num_rows($res))
// building the popular link table (see also dir_functions.php)...
{
	echo "<TABLE width=\"" . $table_width . "\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n  <TR>\n    <TD>";
	$position=1;
	while ($resultat = mysql_fetch_array($res))
	{
		affiche_site($resultat,"topc");
		$position++;
	}
	echo "    </TD>\n  </TR>\n</TABLE>\n";
}
else // no results
{
	?>
	<center><br><br><br><br>
	<span class="link_error">No hits recorded yet...</span>
	</center>
	<?
}
?>
