<?php
// $Id: mod_mostread.php,v 1.14 2004/04/07 11:56:03 rcastley Exp $
/**
* Most Read Items Module
* @package Mambo Open Source
* @Copyright (C) 2000 - 2003 Miro International Pty Ltd
* @ All rights reserved
* @ Mambo Open Source is Free Software
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
* @version $Revision: 1.14 $
**/

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

global $mosConfig_offset;

$count = @$params->count ? intval( $params->count ) : 5;

$now = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 );

$content = "";
$query = "SELECT id, title, created, hits FROM #__content"
."\n WHERE (state='1' AND checked_out='0')"
. "\n	AND (publish_up = '0000-00-00 00:00:00' OR publish_up <= '$now')"
. "\n	AND (publish_down = '0000-00-00 00:00:00' OR publish_down >= '$now')"
."\n ORDER BY hits DESC LIMIT $count";
$database->setQuery($query);
$rows =$database->loadObjectList();
$content .="<table cellpadding=\"1\" border=\"0\">";
foreach($rows as $row) {
	$content .="<tr><td valign=\"top\"><img src=\"$mosConfig_live_site/images/M_images/arrow.png\" alt=\"\" /></td>";
	$content .="<td><a href=\"". sefRelToAbs("index.php?option=content&task=view&id=$row->id") . "\">".$row->title."</a></td></tr>";
}
$content .="</table>";
?>
