Jump to content

Help With Java Getting IP, URL, and


ryanschefke

Recommended Posts

Hello,

 

I would love to get some help as I am foreign to Java. I am used to writing in php, not java. I am looking to add a couple of lines of code such as the ones similar below to a foreign website to grab the IP address of the user viewing the page, the page URL itself, and the referring page. The goal is to require the user integrating this code into their website to have to enter as little as possible.

 

    <script type="text/javascript" language="javascript">llactid=11222</script>

    <script type="text/javascript" language="javascript" src="http://www.URLHERE.com/trackEngine.js"></script>

 

 

I noticed another application that is doing something similar and used the above lines. I loaded their trackEngine.js file into a browser and the following code came up. Can a java expert help me understand what is going on in this javascript file? I simply want to capture the IP, page, and referring page in an application outside of the foreign application and process store it using PHP/MySQL. Perhaps someone could provide suggestions and/or comment on the script below. Thanks a lot!

 

 

var i;
var llactid;
var myid;

myid = 1;
mypage = escape(location.href);
myref = escape(document.referrer);
myip = escape(location.hostaddress);

if (i!="undefined") {
	if (i>10000) {
		myid = i;
	}
}

if  (llactid!="undefined") {
	if (llactid>10000) {
		myid = llactid;
	}
}

if (myref=="")  {
     myref="None";
    }

if (mypage=="")  {
    mypage="Unavailable";
    }

var linkreefer = "http://www.URL.com/trackEngine.php?r=" + myref + "&p=" + mypage + "&i=" + myid;
document.write ("<img src='" + linkreefer + "'>");

// START FUNCTION TRACK
function Track (myid, page)
{
var mypage = escape(location.href);
var myref = escape(document.referrer);
var myip = escape(location.hostaddress);
var forward = false;

if (page!=null)	{
	mypage=page;
	forward=true;
	};

if (myref=="") {
	 myref="None";
	};

if (mypage=="") {
	mypage="Unavailable";
	};

var linkreefer = "http://www.URL.com/trackEngine.php?i=" + myid + "&r=" + myref + "&p=" + mypage + "&f=" + forward;
document.write ("<img src='" + linkreefer + "'>");

if (forward==true)	{
	window.location = (mypage)
	};
}
// END FUNCTION TRACK

Link to comment
https://forums.phpfreaks.com/topic/110375-help-with-java-getting-ip-url-and/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.