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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.