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

if(isset($_POST['id'])){
if(!empty($_POST['id'])){
$id = intval($_POST['id']);
$qu = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT uid,log FROM ".DB_PREFIX."_users WHERE uid='$id' LIMIT 1"));
$usr = $qu['uid'];
$ulog = $qu['log'];
if (empty($usr)) { exit('3'); }
if ($usr == $u_id) { exit('0'); }
$how = mysqli_num_rows(mysqli_query($connect_db, "SELECT id FROM ".DB_PREFIX."_es_s WHERE usr='$u_id' AND tou='$id' LIMIT 1"));
if ($how > 0) { exit('4'); }
mysqli_query($connect_db, "INSERT INTO `".DB_PREFIX."_es_s` (usr,tou) VALUES ('$u_id','$id')");
exit('1');
} else { exit('3'); }
} else { exit('3'); }
?>