0

I have some customers data in my server A.

My customers with their own server B (I have no control on it) display an IFRAME on their webpage (name it page of origin) calling my server A page that display some info about the customer.

If their page of origin is for example www.serverB.com/theripage.php?var=asdfsddf and has the iframe inside i can easily access the content of the variable VAR using HTTP_REFERER. Because of that actually I can display the data they need.

This setup works, but is complicated for the user that needs to start the request within a page with the querystring in the url.

How can I pass the value in other way to my server?

If the customer delete the querystring in the url and write this code in his page:

<iframe src=http://www.serverA.com/index.php?var=asdfsddf></iframe> 

I cannot acces the GET value for the same domain policy.

If I try to run

$_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']

I get only the result WITHOUT the querystring..... so

http://www.serverA.com/index.php

Any help?

1
  • have you tried $_SERVER['QUERY_STRING'] ? Sep 8, 2013 at 0:16

2 Answers 2

0

I think you need to wrap the output of http://www.serverA.com/index.php?var=asdfsddf, within an iframe to begin with, on serverA (your server). Use javascript and/or jQuery to have the content of the iframe expand to the width and height of the actual page.

Then place javascript within the iframe content to grab the src value of the iframe (from your server), The javascript should grab the frame by id value (which you should have defined for it) and get the url that way.

Look at the answer in this stackoverflow question: How to get variable from parent url or parent iframe?

Basically, what you would be doing is, placing the content of the results in an iframe on your server, serverA, and than when they put it in an iframe on serverB, it would be within 2 iframes in reality. You would have control over the innermost iframe, which is the iframe that has the content being displayed within it.

Within the iframe code on your server, you can use code (jQuery and/or javascript) that will make the iframe completely expand to it's contents, therefore, no one would even know it's in an iframe to begin with.

1
  • Thank you. Actually the solution is working with 2 frames in the server B, but they need to create a page withe the frame iteself to be called by another frame with the querystring in the url. I'm trying to avoid to ask the customer to create an extra page.... I'll check your solution. Thank you Sep 8, 2013 at 0:42
0

I would recommend CURL instead of iFrame. Iframes are not secure and data can be easily tampered with.

cURL executed a GET request to retrieve the page, but cURL can also use other methods, such as POST and PUT.

For this example, let’s simulate logging into a website. Logging in is done by sending a POST request to http://example.com/login.php with the following details:

<?php
$postData = array(
    'login' => 'acogneau',
    'pwd' => 'secretpassword',
    'redirect_to' => 'http://example.com',
    'testcookie' => '1'
);

curl_setopt_array($ch, array(
    CURLOPT_URL => 'http://example.com/login.php',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $postData,
    CURLOPT_FOLLOWLOCATION => true
));

$output = curl_exec($ch);
echo $output;
?>

You can easily use regex to fetch the required data.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.