$data_string = json_encode($data);
$url = 'https://bitobmen.pro/api/code-sum/';
function apiRequest($url, $data_string){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$data = json_decode(curl_exec($ch));
$status = curl_getinfo($ch);
return array('data' => $data, 'status' => $status);
}
$resultCodeSum = apiRequest($url, $data_string);
$sum = $resultCodeSum['data']->sum;
if (isset($sum)){
$conect = mysqli_connect('localhost', 'vagrant', 'vagrant', 'xpay');
if (!$conect) {
exit('Ошибка подключеня к MySQL');
}
$username = $_POST['username'];
$sumBalance = mysqli_query($conect,"SELECT balance FROM users where username = '". $username ."'");
$sumBalance = $sumBalance->fetch_assoc();
$sumTotal = $sum + $sumBalance['balance'];
$query = mysqli_query($conect,"UPDATE users SET balance = $sumTotal where username = '". $username ."'");
if ($query){
echo ('Пользователю = ' . $username . ' Зачислено сумму = ' . $sum);
function codeBuy($instant) {
$url = 'https://bitobmen.pro/api/code-buy/';
$data = array("code" => $_POST['code'],
"email" => 'salzsarslimus@gmail.com',
"type" => 'CODE',
"instant" => $instant
);
$data_string = json_encode($data);
$status = apiRequest($url, $data_string);
return $status['status']['http_code'];
}
$codeBuySave = codeBuy(False);
if ($codeBuySave === 200){
$codeBuySave = codeBuy(True);
echo 'Код активирован';
}
} else {
echo ('Пользователю с username = ' . $username . 'не найден');
}
} else {
echo $resultCodeSum['data']->message;
}
}
?>
Охуенно девки пляшут. А ларавел тут где?
Обсуждают сегодня