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

if(isset($_POST['usr'])){
if(!empty($_POST['usr'])){

$usr = intval($_POST['usr']);
$referer = intval($_POST['referer']);

$isref = mysqli_num_rows(mysqli_query($connect_db, "SELECT uid FROM `".DB_PREFIX."_users` WHERE uid='$referer' LIMIT 1"));
if ($isref == 0) { exit('0'); }

mysqli_query($connect_db, "UPDATE `".DB_PREFIX."_users` SET `ref` = '$referer' WHERE uid = '$usr' LIMIT 1");
exit('1');

} else { exit('wu-error'); }
} else { exit('wu-error'); }
?>