<?php 

include('../core.php');
include('../includes/session.php');

if(!$_POST){
exit;
}
$quefry = mysql_query("SELECT COUNT(id) AS count FROM users_referenti WHERE username ='". $name ."' ORDER BY id DESC") or die(mysql_error()); 
$datfa = mysql_fetch_assoc($quefry);

$porv = ($datfa['count']) / ('3');

$mytarg = explode('.', $porv);
if(!$mytarg[0]){
$porv = ($datfa['count']) / ('3');
}
else{
$porv = $mytarg[0];
}
if($datfa['count'] <= '4'){
echo 'Hai bisogno di almeno 10</br>referenti per lo scambio </br>di Bolts</br></br>';
exit;
}
elseif($datfa['count'] >= '5'){
mysql_query("UPDATE users SET vip_points = vip_points + '". $porv ."' WHERE id = '". $my_id ."'");
mysql_query("UPDATE users_referenti SET username = '  ' WHERE username = '".$name."' LIMIT 10");

SendMUS("updatepoints", $my_id);
if($myrow['online'] == '1'){
SendMUS("alert", $my_id ." Tadan!, hai ricevuto : ". $porv ." Bolts.");
}
}

?>