mattd8752 Posted April 15, 2007 Share Posted April 15, 2007 I am creating a stats suite. I don't have access to run Command Line scripts so I can't rely on a socket server. I want to have the user's server message mine a few details (the page loaded, a code to verify that it is the real server not someone trying to screw up the records, the users IP, and the refferer). I need this to be sent from a script on their server to my server to be added to the logs. Quote Link to comment https://forums.phpfreaks.com/topic/47052-how-do-i-communicate-between-2-servers/ Share on other sites More sharing options...
Guest prozente Posted April 15, 2007 Share Posted April 15, 2007 You can use POST or GET and just direct it to a script on the other server. On that script you can check $_SERVER['REMOTE_ADDR'] to ensure it is the server before taking any action Quote Link to comment https://forums.phpfreaks.com/topic/47052-how-do-i-communicate-between-2-servers/#findComment-229486 Share on other sites More sharing options...
mattd8752 Posted April 15, 2007 Author Share Posted April 15, 2007 You can use POST or GET and just direct it to a script on the other server. On that script you can check $_SERVER['REMOTE_ADDR'] to ensure it is the server before taking any action Okay, that makes sense. How would I do that exactly though? Quote Link to comment https://forums.phpfreaks.com/topic/47052-how-do-i-communicate-between-2-servers/#findComment-229490 Share on other sites More sharing options...
MadTechie Posted April 15, 2007 Share Posted April 15, 2007 <form action="http:\\host\remotefile.php" method="post"> <input name="data" type="text" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/47052-how-do-i-communicate-between-2-servers/#findComment-229495 Share on other sites More sharing options...
mattd8752 Posted April 15, 2007 Author Share Posted April 15, 2007 <form action="http:\\host\remotefile.php" method="post"> <input name="data" type="text" /> </form> I want to do this silently. So as a page is loaded the script is run. Quote Link to comment https://forums.phpfreaks.com/topic/47052-how-do-i-communicate-between-2-servers/#findComment-229497 Share on other sites More sharing options...
MadTechie Posted April 15, 2007 Share Posted April 15, 2007 humm javascript or sockets.. Quote Link to comment https://forums.phpfreaks.com/topic/47052-how-do-i-communicate-between-2-servers/#findComment-229499 Share on other sites More sharing options...
mattd8752 Posted April 15, 2007 Author Share Posted April 15, 2007 How would I do this with Javascript then? Quote Link to comment https://forums.phpfreaks.com/topic/47052-how-do-i-communicate-between-2-servers/#findComment-229500 Share on other sites More sharing options...
Guest prozente Posted April 15, 2007 Share Posted April 15, 2007 With PHP you'd make a connection using sockets to the other server on port 80, this is to the webserver Then you'd send your packet, if you were using GET it would look something like this $http_request = "GET /script.php?variable1=123&foo=bar HTTP/1.0\r\n"; $http_request .= "Host: example.com\r\n"; $http_request .= "User-Agent: bot\r\n\r\n"; See the PHP manual for information on using sockets, I don't want to do it all for you. The examples on the page are well enough. http://us2.php.net/manual/en/ref.sockets.php then on your script.php you'd check $_SERVER['REMOTE_ADDR'] to make sure it was your other servers IP address and not just someone trying to send fake information. This is far better than using any type of password since your servers IP is static. once you check the IP Address and it is correct you would use $_GET['variable1'] and $_GET['foo'] to access the data When crafting the packet use urlencode on data you plan to put in a variable This should be enough to get you started. Quote Link to comment https://forums.phpfreaks.com/topic/47052-how-do-i-communicate-between-2-servers/#findComment-229507 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.