Getting the output of a script into the variable of another

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pixelfreak
Forum Newbie
Posts: 4
Joined: Tue Nov 11, 2008 2:43 pm
Location: Brisbane, Australia

Getting the output of a script into the variable of another

Post by pixelfreak »

I have 2 systems that I need to integrate, lets call these Vanilla and Chocalate. From vanilla I need to call chocolate code but the problem is that both systems share global variables and classes with the same names so I need to run them in different memory spaces.

My first though was to run the script with the chocolate code in an iFrame but
  • I don't want the user to see the parameters (if they did a view source)
  • I need to pass information back to the main vanilla script
So what I'm thinking now is something like this

Code: Select all

$returnvalue=executescript('chocolate_integration_script.php?some_vanilla_param='.$somevalue); 
Is this possible ?
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Getting the output of a script into the variable of another

Post by Mark Baker »

Ajax call, and display the response in a div
User avatar
pixelfreak
Forum Newbie
Posts: 4
Joined: Tue Nov 11, 2008 2:43 pm
Location: Brisbane, Australia

Re: Getting the output of a script into the variable of another

Post by pixelfreak »

But what if I need the return value server side ?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Getting the output of a script into the variable of another

Post by John Cartwright »

Code: Select all

$returnvalue=file_get_contents('http://somedomain.com/chocolate_integration_script.php?some_vanilla_param='.$somevalue);
User avatar
pixelfreak
Forum Newbie
Posts: 4
Joined: Tue Nov 11, 2008 2:43 pm
Location: Brisbane, Australia

Re: Getting the output of a script into the variable of another

Post by pixelfreak »

Now, clearly chocolate_integration_script.php cannot create cookies on the client machine, but can it create a session or update session variables that the parent script can read ?

Thu purpose of chocolate_integration_script.php is to log a user in and the returned data will be a session ID. Since the script woun't be able to create cookies, this will be a cookieless session and the session ID will be passed around in the querystring.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Getting the output of a script into the variable of another

Post by John Cartwright »

Is this a cross-domain script?

If not, it sounds like your not wanting to make an HTTP request to fetch the "response". Is there a reason you can't just implement this as a function on the initial page?
User avatar
pixelfreak
Forum Newbie
Posts: 4
Joined: Tue Nov 11, 2008 2:43 pm
Location: Brisbane, Australia

Re: Getting the output of a script into the variable of another

Post by pixelfreak »

No, not cross domain.

The vanilla system in the logon processing page has a bunch of includes and a whole lot of globals and classes are declared.
Now to peform the logon in the chocolate system I need to include chocolate code which declares other globals and classes. Problem is many of these have the same name as those in the vanilla system.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Getting the output of a script into the variable of another

Post by John Cartwright »

If nothing sensitive is passed to this chocolate_integration_script.php, I would suggest redirectingthe user to another page which can process the users session details without any compatability conflicts, and afterwards redirect again to a page such as their profile.

Code: Select all

header('Location: http://yourdomain.com/chocolate_integration_script.php');
exit();
Post Reply