0 && $_POST['rating'] < 6 && !isset($d_rating['rating_vote'])) { $result = dbquery("INSERT INTO ".DB_RATINGS." (rating_item_id, rating_type, rating_user, rating_vote, rating_datestamp, rating_ip, rating_ip_type) VALUES ('$rating_item_id', '$rating_type', '".$userdata['user_id']."', '".$_POST['rating']."', '".time()."', '".USER_IP."', '".USER_IP_TYPE."')"); if ($result) { defender::unset_field_session(); } } redirect($rating_link); } else if (isset($_POST['remove_rating'])) { // Unrate $result = dbquery("DELETE FROM ".DB_RATINGS." WHERE rating_item_id='$rating_item_id' AND rating_type='$rating_type' AND rating_user='".$userdata['user_id']."'"); if ($result) { defender::unset_field_session(); } redirect($rating_link); } } $ratings = [ 5 => $locale['r120'], 4 => $locale['r121'], 3 => $locale['r122'], 2 => $locale['r123'], 1 => $locale['r124'] ]; if (!iMEMBER) { $message = str_replace("[RATING_ACTION]", "".$locale['login']."", $locale['r104']); if (fusion_get_settings("enable_registration") == TRUE) { $message = str_replace("[RATING_ACTION]", "".$locale['login']." ".$locale['or']." ".$locale['register']."", $locale['r104']); } echo "
".$message."
\n"; } else if (!empty($d_rating['rating_vote'])) { echo "
\n"; echo openform('removerating', 'post', $rating_link, ['class' => 'display-block text-center']); echo sprintf($locale['r105'], $ratings[$d_rating['rating_vote']], showdate("longdate", $d_rating['rating_datestamp']))."

\n"; echo form_button('remove_rating', $locale['r102'], $locale['r102'], ['class' => 'btn-default m-b-10', 'icon' => 'fa fa-times m-r-10']); echo closeform(); echo "
\n"; } else { echo "
\n"; echo openform('postrating', 'post', $rating_link, ['notice' => 0, 'class' => 'm-b-20 text-center']); echo form_select('rating', $locale['r106'], '', [ 'options' => $ratings, 'inner_width' => '200px', 'width' => '200px', 'allowclear' => TRUE, 'display_search_count' => -1 ]); echo form_button('post_rating', $locale['r103'], $locale['r103'], ['class' => 'btn-primary btn-block']); echo closeform(); echo "
\n"; } $rating_votes = dbarray(dbquery(" SELECT SUM(IF(rating_vote='5', 1, 0)) as r120, SUM(IF(rating_vote='4', 1, 0)) as r121, SUM(IF(rating_vote='3', 1, 0)) as r122, SUM(IF(rating_vote='2', 1, 0)) as r123, SUM(IF(rating_vote='1', 1, 0)) as r124 FROM ".DB_RATINGS." WHERE rating_type='".$rating_type."' and rating_item_id='".intval($rating_item_id)."' ")); if (!empty($rating_votes)) { $rating_sum = dbcount("(rating_id)", DB_RATINGS, "rating_type='".$rating_type."' AND rating_item_id='".intval($rating_item_id)."'"); echo "
\n"; foreach ($rating_votes as $key => $num) { $num = intval($num); $percentage = $rating_sum == 0 ? 0 : round((($num / $rating_sum) * 100), 1); echo progress_bar($percentage, $locale[$key]." ($num)", ['height' => '10px']); } echo "
\n"; } else { echo "
".$locale['r101']."
\n"; } } }