<?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                                 */
/************************************************************************/

	incoh();
	include("modules/$module_name/l_config.php");
	menu(1);
	$lid = $db->XMFnum(trim($lid));
	br('1');
	$result = $db->sql_query("SELECT ratinguser, rating, ratingcomments, ratingtimestamp FROM ".TABLE_LINKS_VOTEDATA." WHERE ratinglid = '$lid' AND ratingcomments != '' ORDER BY ratingtimestamp DESC");
	$totalcomments = $db->sql_numrows($result);
	$transfertitle = ereg_replace ("_", " ", $ttitle);
	$displaytitle = $transfertitle;
	Max_OpenTable();
	echo "<center><font class=\"option\"><b>"._LINKPROFILE.": ".htmlentities($displaytitle)."</b></font><br /><br />";
	linkinfomenu($lid, $ttitle);
	echo "<br /><br /><br />"._TOTALOF." $totalcomments "._COMMENTS."</font></center><br />"
	."<table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" width=\"450\">";
	$x=0;
	while($row = $db->sql_fetchrow($result)) {
		$ratinguser = $row['ratinguser'];
		$rating = $db->XMFnum($row['rating']);
		$ratingcomments = $row['ratingcomments'];
		$ratingtimestamp = $row['ratingtimestamp'];
		ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $ratingtimestamp, $ratingtime);
		$ratingtime = strftime("%F",mktime($ratingtime[4],$ratingtime[5],$ratingtime[6],$ratingtime[2],$ratingtime[3],$ratingtime[1]));
		$date_array = explode("-", $ratingtime);
		$timestamp = mktime(0, 0, 0, $date_array["1"], $date_array["2"], $date_array["0"]);
		$formatted_date = date("F j, Y", $timestamp);
		/* Individual user information */
		$result2 = $db->sql_query("SELECT rating FROM ".TABLE_LINKS_VOTEDATA." WHERE ratinguser = '$ratinguser'");
		$usertotalcomments = $db->sql_numrows($result2);
		$useravgrating = 0;
		while($row2 = $db->sql_fetchrow($result2))
		$rating2 = $db->XMFnum($row2['rating']);
		$useravgrating = $useravgrating + $rating2;
		$useravgrating = $useravgrating / $usertotalcomments;
		$useravgrating = number_format($useravgrating, 1);
		echo "<tr><td bgcolor=\"$bgcolor2\">"
		."<font class=\"content\"><b> "._USER.": </b><a href=\"$nukeurl/modules.php?name=Your_Account&amp;op=userinfo&amp;username=$ratinguser\">$ratinguser</a></font>"
		."</td>"
		."<td bgcolor=\"$bgcolor2\">"
		."<font class=\"content\"><b>"._RATING.": </b>$rating</font>"
		."</td>"
		."<td bgcolor=\"$bgcolor2\" align=\"right\">"
		."<font class=\"content\">$formatted_date</font>"
		."</td>"
		."</tr>"
		."<tr>"
		."<td valign=\"top\">"
		."<font class=\"tiny\">"._USERAVGRATING.": $useravgrating</font>"
		."</td>"
		."<td valign=\"top\" colspan=\"2\">"
		."<font class=\"tiny\">"._NUMRATINGS.": $usertotalcomments</font>"
		."</td>"
		."</tr>"
		."<tr>"
		."<td colspan=\"3\">"
		."<font class=\"content\">";
		if (defined('ADMIN_ALLOW')) {
			echo "<a href=\"".$admin_file.".php?op=LinksModLink&amp;lid=$lid\"><img src=\"modules/$module_name/images/editicon.gif\" border=\"0\" alt=\""._EDITTHISLINK."\" /></a>";
		}
		echo " $ratingcomments</font>"
		."<br /><br /><br /></td></tr>";
		$x++;
	}
	echo "</table><br /><br /><center>";
	linkfooter($lid,$ttitle);
	echo "</center>";
	Max_CloseTable();
	incof();