Jump to content

How do I communicate between 2 servers?


mattd8752

Recommended Posts

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.

Link to comment
Share on other sites

Guest prozente

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

Link to comment
Share on other sites

Guest prozente

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.

 

 

 

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.