���� JFIF �� � ( %"1"%)+...383,7(-.-
![]() Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20 System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64 User : apache ( 48) PHP Version : 7.4.20 Disable Function : NONE Directory : /var/www/html/vidoe.top/code/ |
<?php class rating{ function rating() { global $CORE; switch ($CORE->input['code']) { default : $this -> goList(); break; } } function goList(){ global $DB; $units=5; $id_sent = preg_replace("/[^0-9]/","",$_REQUEST['id']); $vote_sent = preg_replace("/[^0-9]/","",$_REQUEST['stars']); $ip =$_SERVER['REMOTE_ADDR'] ; $q = $DB->get_num_rows($DB->query("select id from gtdesign_rating where id=$id_sent")); if(!$q) $DB->query("insert into gtdesign_rating (`id`,`date`) values ($id_sent,curdate())"); //connecting to the database to get some information $query = $DB->query("SELECT total_votes, total_value, used_ips FROM gtdesign_rating WHERE id='$id_sent' ")or die(" Error: ".mysql_error()); $numbers = mysql_fetch_assoc($query); $checkIP = unserialize($numbers['used_ips']); $count = $numbers['total_votes']; //how many votes total $current_rating = $numbers['total_value']; //total number of rating added together and stored $sum = $vote_sent+$current_rating; // add together the current vote value and the total vote value $tense = ($count==1) ? "vote" : "votes"; //plural form votes/vote // checking to see if the first vote has been tallied // or increment the current number of votes ($sum==0 ? $added=0 : $added=$count+1); // if it is an array i.e. already has entries the push in another value ((is_array($checkIP)) ? array_push($checkIP,$ip) : $checkIP=array($ip)); $insertip=serialize($checkIP); //IP check when voting if(!isset($_COOKIE['rating_'.$id_sent])){ $voted = $DB->get_num_rows($DB->query("SELECT used_ips FROM gtdesign_rating WHERE used_ips LIKE '%".$ip."%' AND id='".$id_sent."' ")); } else{ $voted=1; } if(!$voted) { //if the user hasn't yet voted, then vote normally... if (($vote_sent >= 1 && $vote_sent <= $units)) { // keep votes within range, make sure IP matches $update = "UPDATE gtdesign_rating SET total_votes='".$added."', total_value='".$sum."', used_ips='".$insertip."' WHERE id='$id_sent'"; $result = $DB->query($update); if($result) setcookie("rating_".$id_sent,1, time()+ 2592000); } } // these are new queries to get the new values! $newtotals = $DB->query("SELECT total_votes, total_value, used_ips FROM gtdesign_rating WHERE id='$id_sent' ")or die(" Error: ".mysql_error()); $numbers = mysql_fetch_assoc($newtotals); $count = $numbers['total_votes'];//how many votes total $current_rating = $numbers['total_value'];//total number of rating added together and stored $tense = ($count==1) ? "vote" : "votes"; //plural form votes/vote // $new_back is what gets 'drawn' on your page after a successful 'AJAX/Javascript' vote if($voted){$sum=$current_rating; $added=$count;} $new_back = array(); for($i=0;$i<5;$i++){ $j=$i+1; if($i<@number_format($current_rating/$count,1)-0.5) $class="ratings_stars ratings_vote"; else $class="ratings_stars"; $new_back[] .= '<div class="star_'.$j.' '.$class.'"></div>'; } $new_back[] .= ' <div class="total_votes"><p class="voted"> Rating: <strong>'.@number_format($sum/$added,1).'</strong>/'.$units.' ('.$count.' '.$tense.' cast) '; if(!$voted)$new_back[] .= '<span class="thanks">Thanks for voting!</span></p>'; else {$new_back[] .= '<span class="invalid">Already voted for this item</span></p></div>';} $allnewback = join("\n", $new_back); $output = $allnewback; echo $output; exit(); } }//end class // Run class $run = new rating(); ?>