Page 1 of 1

Getting the output of a script into the variable of another

Posted: Tue Nov 11, 2008 2:57 pm
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 ?

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

Posted: Tue Nov 11, 2008 2:58 pm
by Mark Baker
Ajax call, and display the response in a div

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

Posted: Tue Nov 11, 2008 4:36 pm
by pixelfreak
But what if I need the return value server side ?

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

Posted: Tue Nov 11, 2008 7:45 pm
by John Cartwright

Code: Select all

$returnvalue=file_get_contents('http://somedomain.com/chocolate_integration_script.php?some_vanilla_param='.$somevalue);

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

Posted: Tue Nov 11, 2008 7:55 pm
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.

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

Posted: Tue Nov 11, 2008 8:14 pm
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?

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

Posted: Tue Nov 11, 2008 8:25 pm
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.

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

Posted: Tue Nov 11, 2008 8:50 pm
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();