Re: Bug #14165 Updated: No way to return variables from remote include()
| From: | Steve Rapaport | Date: | Wed, 21 Nov 2001 23:09:45 +0000 |
| Subject: | Re: Bug #14165 Updated: No way to return variables from remote include() | ||
| References: | 1 2 3 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-71331@lists.php.net to get a copy of this message | ||
Thanks, Lars! I never would have thought of this, and yes it works!
Best,
Steve.
Lars Torben Wilson wrote:
steve@petabit.com writes:-- Steve Rapaport Under ConstructionDear Brian, Marco et al: Sorry to be persistent, but I am pretty sure that my postings have been misunderstood, and the last reply I just got from Marco confirms it. I'm hoping once you understand the question, the "bogus" nature of the question will go away. According to the php "include()" manual, and in my own experience, it is perfectly valid to request that a remote file be executed as php, using include() or require(). One need only compile using "URL fopen wrappers": (manual quotes in [[[ ]]])Maybe I'm just dense, but if this is what you need to have happen (execute the code on the remote server and pass back the data), then why not use fopen() or file() instead of include(), and echo a serialization of your retrieved data? For instance, something like: --main.php-- <?php /* -*- mode: c++; minor-mode: font -*- */ error_reporting(E_ALL); $fp = fopen('http://shanna.outlander.ca/~torben/phptest/includechild.php', 'r'); $retval = fread($fp, 200000); fclose($fp); $returned_data = wddx_deserialize($retval); print_r($returned_data); ?> --includechild.php-- <?php /* -*- mode: c++; minor-mode: font -*- */ mysql_connect('localhost', 'user', 'pass'); mysql_select_db('somedb'); $result = mysql_query('select * from sometable'); $return_data = array(); while ($return_data[] = mysql_fetch_array($result, MYSQL_ASSOC)) {} echo wddx_serialize_value($return_data); ?> Now, I'd not like to speculate on what you might want to do to that to decrease the security risks, but the general idea works. Could use some error checking, too. ;) Is this something like what you wanted?