From 05c83c4322798f1203e2a6c85499c209ded9f77c Mon Sep 17 00:00:00 2001 From: Fawaz Date: Mon, 27 Jun 2011 13:08:08 +0000 Subject: [PATCH] Changed : floor function to round --- upload/includes/classes/video.class.php | 12 +++++------- upload/includes/functions.php | 7 +++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/upload/includes/classes/video.class.php b/upload/includes/classes/video.class.php index 300b674e..28437405 100644 --- a/upload/includes/classes/video.class.php +++ b/upload/includes/classes/video.class.php @@ -796,7 +796,6 @@ class CBvideo extends CBCategory $result = $db->select(tbl('video,users'),tbl('video.*,users.userid,users.username'), $cond." AND ".tbl("video.userid")." = ".tbl("users.userid"),$limit,$order); - if($db->num_rows == 0) { $cond = ""; @@ -1204,19 +1203,18 @@ class CBvideo extends CBCategory $type = $params['type']; //Checking Percent - if($rating<=0) - { $perc = '0'; $disperc = '0'; } - else { - if($total<=1) - $total = 1; + if($total<=10) + $total = 10; $perc = $rating*100/$total; $disperc = 100 - $perc; + if($ratings <= 0 && $disperc == 100) + $disperc = 0; } $perc = $perc.'%'; $disperc = $disperc.'%'; - $likes = floor($ratings*$perc/100); // get lowest integer + $likes = round($ratings*$perc/100); // get lowest integer if($params['is_rating']) { diff --git a/upload/includes/functions.php b/upload/includes/functions.php index e9048f5f..165ed8f7 100644 --- a/upload/includes/functions.php +++ b/upload/includes/functions.php @@ -2820,14 +2820,13 @@ if($total<=10) $total = 10; $perc = $rating*100/$total; - $disperc = 100 - $perc; + $disperc = 100 - $perc; if($ratings <= 0 && $disperc == 100) $disperc = 0; } $perc = $perc.'%'; - $disperc = $disperc."%"; - + $disperc = $disperc."%"; switch($style) { case "percentage": case "percent": @@ -2861,7 +2860,7 @@ case "numerical": case "numbers": case "number": case "num": { - $likes = floor($ratings*$perc/100); + $likes = round($ratings*$perc/100); $dislikes = $ratings - $likes; $ratingTemplate = '