View file wu-engine/wu-actions/adm_eshop_rating.php

File size: 796B
<?php
require_once('../wu_init.php');
include('wu_checkadmin.php');
if (!wu_token()) { exit('wu-error'); }
if (!USER_LOGGED) { exit('wu-error'); }

if(isset($_POST['id']) && isset($_POST['val'])){
if(!empty($_POST['id']) && !empty($_POST['val'])){
$id = intval($_POST['id']);
$val = intval($_POST['val']);
if ($val < 1 || $val > 5) { exit('3'); }
$qu = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT id,vo,va,u FROM ".DB_PREFIX."_es WHERE id='$id' LIMIT 1"));
if (empty($qu['id'])) { exit('3'); }
$rated = explode("|",$qu['u']);
if(in_array($u_id,$rated)) { exit('0'); }
$rat = $qu['u'].'|'.$u_id;
mysqli_query($connect_db, "UPDATE ".DB_PREFIX."_es SET `vo` = `vo` + '1', `va` = `va` + '$val', `u` = '$rat' WHERE id='$id' LIMIT 1");
exit('1');
} else { exit('3'); }
} else { exit('3'); }
?>