nook6 Posted December 10, 2012 Share Posted December 10, 2012 Hi im fairly new here so i would like to say hello to everyone. Now my Question: Im making a few php scripts and im wondering what if anything i can do to find out what url my scripts are running on. maybe some little bit of code in the script somewhere that takes the url and sends it to a script on my website or something? Any help will be greatly appreciated Thank you Nook Quote Link to comment https://forums.phpfreaks.com/topic/271832-finding-out-where-my-script-is-being-run-from/ Share on other sites More sharing options...
MDCode Posted December 10, 2012 Share Posted December 10, 2012 <?php echo __FILE__; ?> Quote Link to comment https://forums.phpfreaks.com/topic/271832-finding-out-where-my-script-is-being-run-from/#findComment-1398596 Share on other sites More sharing options...
nook6 Posted December 10, 2012 Author Share Posted December 10, 2012 (edited) <?php echo __FILE__; ?> Hi thanks for the reply not sure if you understood the question i am trying to send the url of a php script that is hosted on lets say server1 and send it to a script on server2 (if this is possible) I have the url i just need to find a way of sending it from server 1 to server 2 without any user participation or without the user knowing it has been sent. Nook6 Edited December 10, 2012 by nook6 Quote Link to comment https://forums.phpfreaks.com/topic/271832-finding-out-where-my-script-is-being-run-from/#findComment-1398615 Share on other sites More sharing options...
MDCode Posted December 10, 2012 Share Posted December 10, 2012 <?php echo "$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/271832-finding-out-where-my-script-is-being-run-from/#findComment-1398624 Share on other sites More sharing options...
Christian F. Posted December 11, 2012 Share Posted December 11, 2012 (edited) Or, the slightly more readable version. echo $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] Do take into consideration potential XSS injections and other security risks when doing this, as this will send whatever the user wrote in the address-field unmodified! Edited December 11, 2012 by Christian F. Quote Link to comment https://forums.phpfreaks.com/topic/271832-finding-out-where-my-script-is-being-run-from/#findComment-1398705 Share on other sites More sharing options...
nook6 Posted December 11, 2012 Author Share Posted December 11, 2012 Hi Well i was thinking more of using the url that the end buyer would setup in the config settings for the script to use, then all i need to work out is how to get the script on the end users server to send this url to my server in the background, I could setup a switch somewhere so it only sends the url to me once. so i dont get loads of loads of hits everytime someone goes on one of thier sites. Im getting the feeling this isnt really doable lmao thank you nook6 Quote Link to comment https://forums.phpfreaks.com/topic/271832-finding-out-where-my-script-is-being-run-from/#findComment-1398710 Share on other sites More sharing options...
requinix Posted December 11, 2012 Share Posted December 11, 2012 I'm sure it's doable, but it's so much harder for us to give you an appropriate answer when you have a hard time telling us what the actual problem is. Quote Link to comment https://forums.phpfreaks.com/topic/271832-finding-out-where-my-script-is-being-run-from/#findComment-1398711 Share on other sites More sharing options...
nook6 Posted December 11, 2012 Author Share Posted December 11, 2012 i thought i had explained lol. ok let me try again, lets say someone buys a php script from me to use on www.doable.com, then he decides to give a copy of my script to his friend. now his friend will have a free copy of a script that im selling. so im looking for a way of the script letting me know where its running from so i can see if they have paid or not for that script. have i explained it a little better this time?? nook Quote Link to comment https://forums.phpfreaks.com/topic/271832-finding-out-where-my-script-is-being-run-from/#findComment-1398714 Share on other sites More sharing options...
MDCode Posted December 11, 2012 Share Posted December 11, 2012 Or, the slightly more readable version. Pfft. Mine was so professional (not really now that I look at it). There is no way for a script to tell you where it's being run from without php setting issues Quote Link to comment https://forums.phpfreaks.com/topic/271832-finding-out-where-my-script-is-being-run-from/#findComment-1398729 Share on other sites More sharing options...
kicken Posted December 11, 2012 Share Posted December 11, 2012 so im looking for a way of the script letting me know where its running from so i can see if they have paid or not for that script. Just make a HTTP request to your site to log the URL/IP of the host. $_SERVER['HTTP_HOST'] will contain the domain name of the server. You can use gethostbyname to get the IP if you want. You can do a simple request using file_get_contents or curl to your server to log the information. Keep in mind that anyone with even just a bit of knowledge of PHP could just comment out that phone-home portion of the script (or modify it to always return a valid domain). Quote Link to comment https://forums.phpfreaks.com/topic/271832-finding-out-where-my-script-is-being-run-from/#findComment-1398800 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.