PHP calls another script, but through http (isolating them)

Let's see if I'm clear. I have an old set of scripts that work well in PHP4 and do not understand them better. I need to integrate the new functionality implemented in PHP5, I just need to call the script in the new application from the old one.

In order not to touch the old things, I think that somehow the "kind of remote" will cause a new one, you just need to transfer the data $ _REQUEST []. I can’t turn it on, as this will require a switch to a different version of PHP (and some name match). I do not need any conclusion from the new.

What would be a cleaner way to “call” that script the transfer parameters, fopen (" http://theserver.com/thescript.php " ....), and then pass all the necessary headers to pass the parameters? or is there something more direct?

Thank!

+5
source share
3 answers

If you need to pass POST data, you can use cURL ; otherwise, you can just do it file_get_contents('http://example.com/yourscript.php?param1=x¶m2=y¶m3=...');, and the HTTP wrapper will make a request for you (the easiest way).

+3
source

You are going to give you nightmares.

But if you really need to do this, you cannot count on fopen. I would recommend using cURL as Piskvor suggests.

, , , , , - , cURL , .

, , , .

+3

After considering what you suggested in the previous answers and taking into account security, I thought: if both scripts are on the same server, the “called” should be on the same IP address as the calling one, so if the ip is different called, it should not start. Is that a good idea?

0
source

All Articles