Pradinukas

Reputacija:
0
Pranešimai: 41
Įstojo: 2011-01-28
|
Sveiki, jei galit pataisykit, kad STARS bt per vidur, nes man dabar kairj pusj i?band?iau vairiausius variantus ir vis tiek nepavyko pavyko tik tekst padaryti per vidur o STARS pasilieka kairje pusje...
Code
/*-------------------------------------------------------+
| Dynamic Star Rating Redux
| Developed by Jordan Boesch
| www.boedesign.com
| Licensed under Creative Commons - http://creativecommons.org/licenses/by-nc-nd/2.5/ca/
| Used CSS from komodomedia.com.
+--------------------------------------------------------+
| Ajax Rating System mSF For PHP-Fusion 7.xx v.1.1
| Copyright 2008-2009 Powered by .:MeF:.
| URL: http://x-iweb.ru/
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once \"maincore.php\";
function getRating($id, $rtype) {
$total = 0;
$rows = 0;
$sel = dbquery(\"SELECT rating_vote FROM \".DB_RATINGS.\" WHERE rating_item_id = '$id' AND rating_type = '\".$rtype.\"'\");
if(dbrows($sel) != 0){
while($data = dbarray($sel)) {
$total = $total + $data['rating_vote'];
$rows++;
}
$perc = ($total/$rows) * 20;
//$newPerc = round($perc/5)*5;
//return $newPerc.'%';
$newPerc = round($perc,2);
return $newPerc.'%';
} else { return '0%'; }
return '0%';
}
function outOfFive($id, $rtype) {
$total = 0;
$rows = 0;
$sel = dbquery(\"SELECT rating_vote FROM \".DB_RATINGS.\" WHERE rating_item_id = '\".$id.\"' AND rating_type = '\".$rtype.\"'\");
if(dbrows($sel) != 0) {
while($data = dbarray($sel)){
$total = $total + $data['rating_vote'];
$rows++;
}
$perc = ($total/$rows);
return round($perc,2);
//return round(($perc*2), 0)/2; // 3.5
} else { return '0'; }
return '0';
}
function getVotes($id, $rtype){
$sel = dbquery(\"SELECT rating_vote FROM \".DB_RATINGS.\" WHERE rating_item_id = '$id' AND rating_type = '\".$rtype.\"'\");
$rows = mysql_num_rows($sel);
if ($rows == 0) {
$votes = \"0 balsu\";
} else if($rows == 1) {
$votes = \"1 balsas\";
} else if($rows > 1 && $rows < 5) {
$votes = $rows.\" balsai\";
} else {
$votes = $rows.\" balsu\";
}
return $votes;
}
function showratings($rtype, $id, $rating_link = true) {
global $show5, $showPerc, $showVotes, $static;
$show5 = false; $showPerc = false; $showVotes = false; $static = NULL;
// Check if they have already voted...
$text = '';
$sel = dbquery(\"SELECT rating_item_id FROM \".DB_RATINGS.\" WHERE rating_ip = '\".USER_IP.\"' AND rating_item_id = '$id' AND rating_type='\".$rtype.\"'\");
if(dbrows($sel) != 0 || $static == 'novote') {
echo '';
echo 'Dabartinis: '.outOfFive($id, $rtype).'/5';
echo ' ('.getRating($id, $rtype).')';
echo ' (Viso: '.getVotes($id, $rtype).')';
echo ' ';
echo '';
echo '';
echo '- >1
';
echo '- >2
';
echo '- >3
';
echo '- >4
';
echo '- >5
';
echo ' ';
echo '';
} else {
echo '';
$show5bool = 'true';
echo 'Dabartinis: '.outOfFive($id, $rtype).'/5';
$showPercbool = 'true';
echo ' ('.getRating($id, $rtype).')';
$showVotesbool = 'true';
echo ' ('.getVotes($id, $rtype).')';
echo ' ';
echo '';
echo '';
echo '- >1
';
echo '- >2
';
echo '- >3
';
echo '- >4
';
echo '- >5
';
echo ' ';
echo '';
}
}
/*
// Added in version 1.5
// Fixed sort in version 1.7
function getTopRated($limit, $table, $idfield, $namefield){
$result = '';
$sql = \"
SELECT COUNT(ratings.rating_id) as rates,ratings.rating_item_id,\".DB_RATINGS.\".\".$namefield.\" as thenamefield,
ROUND(AVG(ratings.rating_vote),2) as rating
FROM ratings,\".DB_RATINGS.\" WHERE \".DB_RATINGS.\".\".$idfield.\" = ratings.rating_item_id GROUP BY rating_id
ORDER BY rates DESC,rating DESC LIMIT \".$limit.\"
\";
$sel = dbquery($sql);
$result .= ''.\"\n\";
while($data = dbarray($sel)){
$result .= '- '.$data['thenamefield'].' ('.$data['rating'].')
'.\"\n\";
}
$result .= ' '.\"\n\";
return $result;
}
*/
?>
|