<?

$D = date('d');

$A = date('Y');

$M = date('m');

$date = "$A$M$D";

$esta = "NO";



$sql = "SELECT n,date FROM visitas";



$consulta = $conn->query($sql);

while ($row = $consulta->fetch_assoc())

{

$n = $row["n"];

$date1 = $row["date"];

if ($date1 == $date) {$esta = "SI";} else {};

}

$consulta->free_result();


if ($esta == 'NO') {



// Consulta SQL
$sSQL = "INSERT INTO `visitas` (`n`, `d`, `m`, `a`, `date`, `URL`, `nombre`, `IP`) 
        VALUES ('0', '$D', '$M', '$A', '$date', '', '', '');";

$conn->query($sSQL);



} else {};






$sql = "SELECT n FROM visitas WHERE date = '$date'";



$consulta = $conn->query($sql);

while ($row = $consulta->fetch_assoc())

{

$n = $row["n"];

}

$consulta->free_result();


$random = rand(1,3);

if ($random == 1) {$n = $n + 2; } else {$n = $n + 1;};






$tabla = "visitas";

$campo = "direccion";






$sSQL = "

UPDATE `$basedatos`.`$tabla` SET `n` =  '$n' WHERE date = '$date'; ";


$conn->query($sSQL);




?>

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/es_LA/all.js#xfbml=1&appId=427523193949843";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<style>

    #facebook-jssdk-iframe { display: none; }

</style>

<?php include 'analitycs.php';?>



