<?php
$location = '1';
include '../inc/conf.php';
include '../inc/auth.php';
echo $head;
include '../inc/block.php';
 
$act=trim($_GET['act']);
 
if (isset($_POST['submit'])&&$act == 'pay'){
    $err = array();
    if (!preg_match("/^\d+$/",$_POST['money'])){
        $err[] = "Сумма только из цифр!";
    }
    if (!preg_match("/^([a-zA-Z0-9]){15}$/i",$_POST['check'])||preg_match("/^([a-zA-Z]){15}$/i",$_POST['check'])||preg_match("/^([0-9]){15}$/i",$_POST['check'])){
        $err[] = "В номере счёта только: латинские символы, цифры, длина 15 символов!";
    }
    if (trim($_POST['check']) == ''){
        $err[] = "Введите ваш счет!";
    }
    if (trim($_POST['money']) == ''){
        $err[] = "Введите сумму!";
    }
    if (count($err) != 0) {
        $error = '';
        foreach ($err as $i => $value) {
            $error .= $value.'</br>';
        }
    }
 
    $check = htmlspecialchars($_POST['check']); // Номер
    $money = htmlspecialchars($_POST['money']); // Сумма
   
    # Данные для смс и отправка
    $num = $userdata['login']; // Номер
    $api = $userdata['api_sms']; // Апи
    echo SMS($num, $api); // Функция смс
 
    # Подтверждение
    $lol = '<font color="green"><center>Вы подтверждаете, что хотите отправить на номер: <b>'.$check.'</b><br>Сумму в размере: <b>'.$money.' RUB</b></center></font></br>';
}
 
if (isset($_POST['submit2'])&&$act == 'pay'){
        $gen2 = $_COOKIE["KEK"]; // дублируем куку
        $kod = trim($_POST['kod']); // Код смс
        $result = ($kod == $gen2) ? 'Операция успешно завершена!' : 'Вы ввели неверный код!';
}
 
?>
<div class="tab-pane fade in active" id="send">
    <div class="row text-left">
        <div class="col-lg-12">
            <ul class="nav nav-rates nav-tabs nav-justified" role="tablist">
                <li class="active"><a href="#sendtoaddress" role="tab" data-toggle="tab">Отправить по адресу</a></li>
            </ul>
            <div class="tab-content">
                <div class="tab-pane active" id="sendtoaddress">
                    </br></br>
<?php
if (!isset($_POST['submit'])||count($err) != 0){
    echo
    '<form method="post" action="?act=pay">
        <div class="row text-center">
            <div class="col-sm-6 col-sm-offset-3">
                <div class="form-group">
                    <p>'.$result.$error.'</p>
                    <label for="walletSendConfirmModal-code">Номер счета [BTC]</label>
                    <input type="text" id="walletSendConfirmModal-code" class="form-control input-lg" data-isotp="false" name="check" value="'.$_POST['check'].'" required/>
                    <p class="error text-danger" style="display:none;border:0px;margin-top:5px;padding:5px;"></p>
                    <label for="walletSendConfirmModal-code">Сумма [RUB]</label>
                    <input type="text" id="walletSendConfirmModal-code" class="form-control input-lg" data-isotp="false" name="money" value="'.$_POST['money'].'" required/>
                    <p class="error text-danger" style="display:none;border:0px;margin-top:5px;padding:5px;"></p>
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <input type="submit" name="submit" class="btn btn-info modalFormSubmitButton" id="walletSendToEmailConfirmModal-send" value="Далее">
        </div>
    </form>';
} else {
    echo
    '<form method="post" action="?act=pay">
        <div class="row text-center">
            <div class="col-sm-6 col-sm-offset-3">
                <div class="form-group">
                    <p>'.$lol.'</p>
                    <label for="walletSendConfirmModal-code">СМС-код</label>
                    <input type="text" id="walletSendConfirmModal-code" class="form-control input-lg" data-isotp="false" name="kod" required/>
                    <p class="error text-danger" style="display:none;border:0px;margin-top:5px;padding:5px;"></p>
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <input type="submit" name="submit2" class="btn btn-info modalFormSubmitButton" id="walletSendToEmailConfirmModal-send" value="Подтвердить и отправить">
            <button type="button" onclick="javascript:document.location.href=\'/send\'" class="btn btn-default" data-dismiss="modal">Отменить</button>
        </div>
    </form>';
}
?>
                </div>
</selection>
<?php echo $foot; ?>