credits to Mvp for Original code
Open up theme/header.php add
now open up your current theme theme.css add
now open up torrents-details.php find
Replace with
now find
[color=rgb(204, 204, 204)]DELETE IT[/color]
now find
add under
Find
under add
upload js files to root/js folder and starrating.gif to themes/your_theme/images
[ATTACH]5151[/ATTACH]
Open up theme/header.php add
<script type="text/javascript" language="javascript" src="<?php echo $site_config["SITEURL"];?>/js/rating.js"></script>
<script type="text/javascript" language="javascript" src="<?php echo $site_config["SITEURL"];?>/js/behavior.js"></script>
now open up your current theme theme.css add
/*Star Rating css*/
.ratingblock {
display:block;
border-bottom:1px solid #999;
padding-bottom:8px;
margin-bottom:8px;
}
.loading {
height: 30px;
background: url('images/working.gif') 50% 50% no-repeat;
}
.unit-rating { /* the UL */
list-style:none;
margin: 0px;
padding:0px;
height: 30px;
position: relative;
background: url('images/starrating.gif') top left repeat-x;
}
.unit-rating li{
text-indent: -90000px;
padding:0px;
margin:0px;
/**/
float: left;
/* */
}
.unit-rating li a {
outline: none;
display:block;
width:30px;
height: 30px;
text-decoration: none;
text-indent: -9000px;
z-index: 20;
position: absolute;
padding: 0px;
}
.unit-rating li a:hover{
background: url('images/starrating.gif') left center;
z-index: 2;
left: 0px;
}
.unit-rating a.r1-unit{left: 0px;}
.unit-rating a.r1-unit:hover{width:30px;}
.unit-rating a.r2-unit{left:30px;}
.unit-rating a.r2-unit:hover{width: 60px;}
.unit-rating a.r3-unit{left: 60px;}
.unit-rating a.r3-unit:hover{width: 90px;}
.unit-rating a.r4-unit{left: 90px;}
.unit-rating a.r4-unit:hover{width: 120px;}
.unit-rating a.r5-unit{left: 120px;}
.unit-rating a.r5-unit:hover{width: 150px;}
.unit-rating a.r6-unit{left: 150px;}
.unit-rating a.r6-unit:hover{width: 180px;}
.unit-rating a.r7-unit{left: 180px;}
.unit-rating a.r7-unit:hover{width: 210px;}
.unit-rating a.r8-unit{left: 210px;}
.unit-rating a.r8-unit:hover{width: 240px;}
.unit-rating a.r9-unit{left: 240px;}
.unit-rating a.r9-unit:hover{width: 270px;}
.unit-rating a.r10-unit{left: 270px;}
.unit-rating a.r10-unit:hover{width: 300px;}
.unit-rating li.current-rating {
background: url('images/starrating.gif') left bottom;
position: absolute;
height: 30px;
display: block;
text-indent: -9000px;
z-index: 1;
}
.voted {color:#999;}
.thanks {color:#36AA3D;}
.static {color:#5D3126;}
}
now open up torrents-details.php find
//take rating
if ($_GET["takerating"] == 'yes'){
$rating = (int)$_POST['rating'];
if ($rating <= 0 || $rating > 5)
show_error_msg(T_("RATING_ERROR"), T_("INVAILD_RATING"), 1);
$res = SQL_Query_exec("INSERT INTO ratings (torrent, user, rating, added) VALUES ($id, " . $CURUSER["id"] . ", $rating, '".get_date_time()."')");
if (!$res) {
if (mysqli_errno($GLOBALS["DBconnector"]) == 1062)
show_error_msg(T_("RATING_ERROR"), T_("YOU_ALREADY_RATED_TORRENT"), 1);
else
show_error_msg(T_("RATING_ERROR"), T_("A_UNKNOWN_ERROR_CONTACT_STAFF"), 1);
}
SQL_Query_exec("UPDATE torrents SET numratings = numratings + 1, ratingsum = ratingsum + $rating WHERE id = $id");
show_error_msg(T_("RATING_SUCCESS"), T_("RATING_THANK")."<br /><br /><a href='torrents-details.php?id=$id'>" .T_("BACK_TO_TORRENT"). "</a>");
}
Replace with
//take rating
if ($_GET["takerating"] == 'yes'){
$rating = (int)$_GET['j'];
if ($rating <= 0 || $rating > 5)
show_error_msg(T_("RATING_ERROR"), T_("INVAILD_RATING"), 1);
$res = SQL_Query_exec("INSERT INTO ratings (torrent, user, rating, added) VALUES ($id, " . $CURUSER["id"] . ", $rating, '".get_date_time()."')");
if (!$res) {
if (mysqli_errno($GLOBALS["DBconnector"]) == 1062)
show_error_msg(T_("RATING_ERROR"), T_("YOU_ALREADY_RATED_TORRENT"), 1);
else
show_error_msg(T_("RATING_ERROR"), T_("A_UNKNOWN_ERROR_CONTACT_STAFF"), 1);
}
SQL_Query_exec("UPDATE torrents SET numratings = numratings + 1, ratingsum = ratingsum + $rating WHERE id = $id");
show_error_msg(T_("RATING_ERROR"), T_("RATING_THANK")."<br /><br /><a href='torrents-details.php?id=$id'>" .T_("BACK_TO_TORRENT"). "</a>");
}
now find
// $srating IS RATING VARIABLE
$srating = "";
$srating .= "<table class='f-border' cellspacing=\"1\" cellpadding=\"4\" width='100%'><tr><td class='f-title' width='60'><b>".T_("RATINGS").":</b></td><td class='f-title' valign='middle'>";
if (!isset($row["rating"])) {
$srating .= "Not Yet Rated";
}else{
$rpic = ratingpic($row["rating"]);
if (!isset($rpic))
$srating .= "invalid?";
else
$srating .= "$rpic (" . $row["rating"] . " ".T_("OUT_OF")." 5) " . $row["numratings"] . " ".T_("USERS_HAVE_RATED");
}
$srating .= "\n";
if (!isset($CURUSER))
$srating .= "(<a href=\"account-login.php?returnto=" . urlencode($_SERVER["REQUEST_URI"]) . "&nowarn=1\">Log in</a> to rate it)";
else {
$ratings = array(
5 => T_("COOL"),
4 => T_("PRETTY_GOOD"),
3 => T_("DECENT"),
2 => T_("PRETTY_BAD"),
1 => T_("SUCKS")
);
//if (!$owned || $moderator) {
$xres = SQL_Query_exec("SELECT rating, added FROM ratings WHERE torrent = $id AND user = " . $CURUSER["id"]);
$xrow = mysqli_fetch_assoc($xres);
if ($xrow)
$srating .= "<br /><i>(".T_("YOU_RATED")." \"" . $xrow["rating"] . " - " . $ratings[$xrow["rating"]] . "\")</i>";
else {
$srating .= "<form style=\"display:inline;\" method=\"post\" action=\"torrents-details.php?id=$id&takerating=yes\"><input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
$srating .= "<select name=\"rating\">\n";
$srating .= "<option value=\"0\">(".T_("ADD_RATING").")</option>\n";
foreach ($ratings as $k => $v) {
$srating .= "<option value=\"$k\">$k - $v</option>\n";
}
$srating .= "</select>\n";
$srating .= "<input type=\"submit\" value=\"".T_("VOTE")."\" />";
$srating .= "</form>\n";
}
//}
}
$srating .= "</td></tr></table>";
print("<center>". $srating . "</center>");// rating
//END DEFINE RATING VARIABLE
[color=rgb(204, 204, 204)]DELETE IT[/color]
now find
//end download box
add under
// $srating IS RATING VARIABLE
$total_votes = 0;
$total_value = 0;
$query = SQL_Query_exec("SELECT COUNT(torrent) as total_votes, SUM(rating) as total_value FROM `ratings` WHERE `torrent` = '$id'");
while ($rating = mysqli_fetch_array($query)) {
$total_votes = $rating['total_votes'];
$total_value = $rating['total_value'];
}
$voted = get_row_count("ratings", "WHERE `torrent` = '" . $id . "' AND `user` = '" . $CURUSER["id"] . "'");
if ($total_votes < 1) {
$count = 0;
} else {
$count = $total_votes;
}
$current_rating = $total_value;
$tense = ($count == 1) ? "vote" : "votes";
if (is_numeric($current_rating) && is_numeric($count)) {
$rating_width = @number_format($current_rating / $count, 2) * 30;
//$rating_width = @number_format((floatval).$current_rating / $count, 2) * 30;
$rating_1 = @number_format($current_rating / $count, 1);
$rating_2 = @number_format($current_rating / $count, 2);
}
if (!$voted) {
$rater .= '<div id="unit_long' . $id . '">';
$rater .= '<ul id="unit_ul' . $id . '" class="unit-rating" style="width: ' . 30 * 5 . 'px;">';
$rater .= '<li class="current_rating" style="width: ' . $rating_width . '"px;"> Currently ' . $rating_2 . '/' . 5 . '</li>';
for ($ncount = 1; $ncount <= 5; $ncount++) {
if (!$voted) {
if ($CURUSER)
$rater .='<li><a href="torrents-details.php?id=' . $id . '&takerating=yes&j=' . $ncount . '" title="'.$ncount.' out of 5" class="r'.$ncount.'-unit rater" rel="nofollow">'.$ncount.'</a></li>';
else
$rater .='<li><a href="account-login.php?returnto="' . urlencode($_SERVER["REQUEST_URI"]) . '&nowarn=1" title="'.$ncount.' out of '.$units.'" class="r'.$ncount.'-unit rater" rel="nofollow">'.$ncount.'</a></li>';
}
}
$ncount = 0;
}
$rater .= '</ul>';
$rater .= '<p>';
if ($voted) {
$static_rater = array();
$static_rater[] .= '<div id="unit_long'.$id.'">';
$static_rater[] .= '<ul id="unit_ul'.$id.'" class="unit-rating" style="width:'. 30*5 .'px;">';
$static_rater[] .= '<li class="current-rating" style="width:'.$rating_width.'px;">Currently '.$rating2.'/'.$units.'</li>';
$static_rater[] .= '</ul>';
$rater .= join("\n", $static_rater);
}
$rater .= '<strong>' . $rating_1 . '</strong>/5 (' . $count . ' ' . $tense . ' cast)';
$rater .= '</p>';
//END DEFINE RATING VARIABLE
Find
print("<tr><td align='left'><b>".T_("HITS").":</b></td><td>" . number_format($row["hits"]) . "</td></tr>\n");
under add
print("<tr><td align='left'><b>".T_("Rating").":</b></td><td>" . $rater . "</td></tr>\n");
upload js files to root/js folder and starrating.gif to themes/your_theme/images
[ATTACH]5151[/ATTACH]
