5

Let's see if I make myself clear. I have an old set of scripts that run well on PHP4 and better don't thouch em. I have to integrate a new functionality implemented on PHP5, I need just to invoke a script on the new app from the old one.

To not have to touch the old stuff I think to somehow "kin of remotely" invoke the new one, need only to pass the $_REQUEST[] data. I can not include it as that would require migrating to another PHP version (and some name clashing). I don't need any output from the new one.

What would be the cleaner way to "call" that script passing parameters, fopen("http://theserver.com/thescript.php"....) and then passing all the necessary headers to pass the parameters? or there's somethign more direct?

Thanks!

3 Answers 3

3

You're going to give yourself nightmares with this.

But if you really need to do it, you're not going to be able to rely on fopen. I would recommend using cURL, as Piskvor suggests.

But please, make sure you're validating and escaping any data you're pushing across correctly, or you're in for a world of hurt - the fact that you're making a cURL request to the other part of the system means that in theory, anyone else can do exactly the same thing.

This is most definitely not a long term solution, I would advise you rewrite the old parts as a priority.

Sign up to request clarification or add additional context in comments.

1 Comment

You're right with the security concern... I think I will do what Piskvor suggests passing the request as parameteres but first I will study the possible security problems. Thanks!
2

If you need to pass POST data, you can use cURL; otherwise, you can just do file_get_contents('http://example.com/yourscript.php?param1=x&param2=y&param3=...'); and the HTTP wrapper will do the request for you (simplest way).

1 Comment

Great, really simple. I will have to think of possible security problems but I guess it in this specific case it will not be too complex. thanks!
0

After considering what you suggested on previous answers and considering safety I thought something: If both scripts are on the same server the "called" one should be on the same IP than the caller so if ips differ the invoked should not run. Is that a good idea?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.