获取页面内容,就像用户打开一样

I'm trying to get some of IPBoard registry data by using external site since 777 chmoding on whole forum registry would be a terrible idea. Registry returns user data for user if he's logged in on forums. I've created a page which initiates the registry and prints the data. Loading the registry and getting the data to page is quite simple

//userQuery.php
<?php
define("ALLOW_FURLS", false);
require_once 'forum/initdata.php';
require_once IPS_ROOT_PATH . 'sources/base/ipsRegistry.php';
$registry = ipsRegistry::instance();
$registry->init();

$member = $registry->member()->fetchMemberData();
$data = json_encode($member);

print $data;
?>

and if opened by user works perfectly. Problems started when I tried accessing my userQuery.php through external site as intended. Both curl and fopen from external site acts as requested by server not user visiting the site and returns Guest data since server is not logged in.

So doing

<?php
$url = "http://foo.bar/userQuery.php";
$handle = fopen($url, "r");
$result = fread($handle, 8192);

var_dump($result);
?>

Returns server memberdata which is Guest, instead of user memberdata as userQuery would if accessed normally by opening it in a browser.

Is there a way to open that page (userQuery.php) as if user requested its content using php or js as the last resort? I'm not looking forward to rewriting IPBoard registry just to provide external access checks with the forums.

I am assuming you want this to happen as your users visit the site right? So, when Bob shows up on the site and logs in, you get his data. And later, when Lucy logs in, you get her data.

If that assumption is right, you could put a little script on your site that would post data back to your server via an AJAX call.

Your userQuery.php would look like the following (if you use jQuery for the AJAX call) and you'd need to include it in one of the pages on your site so it gets loaded when users visit the site.

//userQuery.php
<?php
define("ALLOW_FURLS", false);
require_once 'forum/initdata.php';
require_once IPS_ROOT_PATH . 'sources/base/ipsRegistry.php';
$registry = ipsRegistry::instance();
$registry->init();

$member = $registry->member()->fetchMemberData();
$data = json_encode($member);

echo "<script>var data = {$data}; $.post('/some/url/on/your/site/receiver.php', data);</script>";
?>

Then you'd need to have a script at /some/url/on/your/site/receiver.php that grabs the data out of $_['POST'] and does something with it.

Or, I'm totally misinterpreting what you want and you can ignore this answer. :)