Jump to content

Safe way to post information from 1 website to another?


astralaaron

Recommended Posts

Hello. I am working on an app that keeps track of statistics based on data that needs to come in from other websites.I am not aloud to run the queries from my app to pull the data, I need to come up with a way to send the data from them to me.Does anyone have any ideas? I can only think of using GET array on a header function with a Cron job set up to auto load the php file... does anyone have any ideas how it should be done?thanks!

Link to comment
Share on other sites

You could have the other servers push the data to your server with a normal HTTP post or get request, or they could upload a data file through FTP, or they could email the data out to some address that a script checks. There are several methods to send data from one server to another.

Link to comment
Share on other sites

Yes, PHP has all of the FTP functions available. That would probably be easier than manually opening a socket connection, but that would work also. If you're worried about the safety of the data, you may want to encrypt the data before sending it and then decrypt it on the other end. Here's some code to encrypt and decrypt a string:

$data = 'some data to encrypt';$key = md5('the encryption key');$encrypted_data = trim(  base64_encode(	mcrypt_encrypt(	  MCRYPT_RIJNDAEL_256,	  $key,	  $data,	  MCRYPT_MODE_ECB,	  mcrypt_create_iv(		mcrypt_get_iv_size(		  MCRYPT_RIJNDAEL_256,		  MCRYPT_MODE_ECB		),		MCRYPT_RAND	  )	)  ));echo 'encrypted data: ' . $encrypted_data . '<br>';$decrypted_data = trim(  mcrypt_decrypt(	MCRYPT_RIJNDAEL_256,	$key,	base64_decode($encrypted_data),	MCRYPT_MODE_ECB,	mcrypt_create_iv(	  mcrypt_get_iv_size(		MCRYPT_RIJNDAEL_256,		MCRYPT_MODE_ECB	  ),	  MCRYPT_RAND	)  ));echo 'decrypted data: ' . $decrypted_data;

Link to comment
Share on other sites

Yes, PHP has all of the FTP functions available. That would probably be easier than manually opening a socket connection, but that would work also. If you're worried about the safety of the data, you may want to encrypt the data before sending it and then decrypt it on the other end. Here's some code to encrypt and decrypt a string....(edit)echo 'decrypted data: ' . $decrypted_data;[/code]
thank you very much
Link to comment
Share on other sites

I just confused myself deciding on the method, with these encryption/decryption functions.Would you use fsocket, or the ftp functions, or a normal multi-encrypted html form with that? it seems like fsocket or the multi-encrypted form could work but can you give me a general idea of where the decryption takes place if you use the ftp to upload directly to a folder on the other server?

Link to comment
Share on other sites

You would decrypt it on the server that collects all the data. When it processes the data the other servers have sent, the first step would be to decrypt it. If it's a normal HTTP request, then the script that gets the request would decrypt the data before saving it. If it's FTP or a socket connection, you would need a script to run on a schedule to check for new files which would decrypt the files before processing them. Keep in mind that the servers need to be using the same encryption key in order for the data to be decrypted.

Link to comment
Share on other sites

You would decrypt it on the server that collects all the data. When it processes the data the other servers have sent, the first step would be to decrypt it. If it's a normal HTTP request, then the script that gets the request would decrypt the data before saving it. If it's FTP or a socket connection, you would need a script to run on a schedule to check for new files which would decrypt the files before processing them. Keep in mind that the servers need to be using the same encryption key in order for the data to be decrypted.
ah ok, I understand where I was confused now.I will keep that in mind about the key, thanks again!
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...