Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding enhancements #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!DOCTYPE>
<html>
<title>IPLookUp</title>
<head>

<meta name="author" content="Tarunkant Gupta">
Expand All @@ -13,33 +14,33 @@

<script>
window.RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection; //compatibility for firefox and chrome
var pc = new RTCPeerConnection({iceServers:[]}), noop = function(){};
var pc = new RTCPeerConnection({iceServers:[]}), noop = function(){};
pc.createDataChannel(""); //create a bogus data channel
pc.createOffer(pc.setLocalDescription.bind(pc), noop); // create offer and set local description
var myIP;
pc.onicecandidate = function(ice){ //listen for candidate events
if(!ice || !ice.candidate || !ice.candidate.candidate) return;
myIP = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/.exec(ice.candidate.candidate)[1];
document.getElementById("demo").innerHTML = 'Internal IP Addr : ' + myIP;
document.getElementById("demo").innerHTML = 'Internal IP Addr : ' + myIP;
pc.onicecandidate = noop;

var value1 = 'Internal IP Addr : ' + myIP;

if (myIP!=null) {
$.post("post.php", {
intip:value1
});
}


};
</script>

<script>
$.get("http://ipinfo.io", function(response) {
document.getElementById("demo1").innerHTML = 'Public IP Addr : ' + response.ip;
var value = 'Public IP Addr : ' + response.ip;

if (response.ip!=null) {
$.post("post1.php", {
pubip:value
Expand All @@ -51,6 +52,7 @@

</head>
<body>
<h1><u>Welcome to IPLookUp !</u></h1>
<p id="demo"></p>
<p id="demo1"></p>
</body>
Expand Down