<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
defined('MAXIMUS') or Header("Location: index.php");

incoh( 'Reviews', 'html', "".CACHE_VREVIEWS."", '1' );

	if ($multilingual == 1) {
		$querylang = "WHERE `rlanguage`='".$GLOBALS['db']->XMFlang($currentlang)."'";
	} else {
		$querylang = "";
	}
	Max_OpenTable();
	echo "<table border=\"0\" width=\"95%\" cellpadding=\"2\" cellspacing=\"4\" align=\"center\">
    <tr><td colspan=\"2\"><center><font class='title'>"._RWELCOME."</font></center><br /><br /><br />";
	$sql = "select `title`, `description` from `".TABLE_REVIEWS_MAIN."`";
	if ( !($result = $GLOBALS['db']->sql_query($sql)) )
{ query_die(CORE_ERROR, 'Could not obtain _reviews_main', '', __LINE__, __FILE__, $sql);}
	$row         = $db->sql_fetchrow($result);
	$title       = stripslashes(check_html($row['title'], "nohtml"));
	$description = stripslashes($row['description']);
	echo "<center><b>$title</b><br /><br />$description</center>";
        $db->sql_freeresult($result);
	br('3');
	alpha();
	echo "</td></tr>";
	echo "<tr><td width=\"50%\" bgcolor=\"$bgcolor2\"><b>"._10MOSTPOP."</b></td>";
	echo "<td width=\"50%\" bgcolor=\"$bgcolor2\"><b>"._10MOSTREC."</b></td></tr>";
	$result_pop = $db->sql_query("SELECT `id`, `title`, `hits` from `".TABLE_REVIEWS."` $querylang order by `hits` DESC limit 10");
	$result_rec = $db->sql_query("SELECT `id`, `title`, `date`, `hits` from `".TABLE_REVIEWS."` $querylang order by `date` DESC limit 10");
	$y = 1;
	for ($x = 0; $x < 10; $x++)	{
		$myrow = $db->sql_fetchrow($result_pop);
		$id    = $db->XMFnum($myrow['id']);
		$title = stripslashes(check_html($myrow['title'], "nohtml"));
		$hits  = $db->XMFnum($myrow['hits']);
		echo "<tr><td width=\"50%\" bgcolor=\"$bgcolor3\">$y) <a href=\"modules.php?name=$module_name&amp;rop=showcontent&amp;id=$id\">$title</a></td>";
		$myrow2 = $db->sql_fetchrow($result_rec);
		$id     = $db->XMFnum($myrow2['id']);
		$title  = stripslashes(check_html($myrow2['title'], "nohtml"));
		$hits   = $db->XMFnum($myrow2['hits']);
		echo "<td width=\"50%\" bgcolor=\"$bgcolor3\">$y) <a href=\"modules.php?name=$module_name&amp;rop=showcontent&amp;id=$id\">$title</a></td></tr>";
		$y++;
	}
	echo "<tr><td colspan=\"2\"><br /></td></tr>";
	$result2    = $db->sql_query("SELECT * FROM ".TABLE_REVIEWS." $querylang");
	$numresults = $db->sql_numrows($result2);
	echo "<tr><td colspan=\"2\"><br /><center>"._THEREARE." $numresults "._REVIEWSINDB."</center></td></tr></table>";
	Max_CloseTable();
	$db->sql_freeresult($result_pop);
	$db->sql_freeresult($result_rec);
	incof( 'Reviews', 'html', "".CACHE_VREVIEWS."", '1' );