I have a page with a <script> tag in it pointing to a PHP script that generates JavaScript.
In this PHP script, I verify the remote IP to see if this IP has the right to use the script.
My question is: how do I get the IP from the machine that embeds the <script> tag?
In $_SERVER, I have REMOTE_ADDR which is my IP address (the client) and SERVER_ADDR which is the IP of the machine that runs the PHP script that generates JavaScript (the server).
But in between those, there’s the page that embeds the <script> tag and I need its server IP address.
Any ideas about how I’m gonna find it?
Thanks
Pictures:
Assuming: You control the Javascript server but not the html page server
Answer: Your javascript (JS) program could send your JS Server the value of window.location. That will tell your JS Server where the page was loaded from (html page server).
Since your JS can’t do an Ajax call (different domains), it will have to load something (a script or a web bug img) from your js server and include the window.location and session info it received in the original js file as url parameters.
Notes: