Noesis Posted November 19, 2013 Share Posted November 19, 2013 (edited) Have a situation where I need to retrieve a parent variable but am unable to modify the parent source code. I also want to apply any solution in a cross domain situation but using PHP coding techniques. <div class='userbox'> <div class='avatar'><div class='element_avatar simple medium '><a href="http://thetemplars.enjin.com/profile/2819806" data-minitooltip="Noesis"><img src="http://assets-cloud.enjin.com/users/2819806/avatar/medium.1362825808.png"></a></div></div> <div class='username'><a href='/profile/2819806' class='element_username'>Noesis</a></div> <a class='logout' href='/logout'>Logout</a> </div> The above shows the relevant section of the output source code in javascript and at the moment and I'm unawares to the actual variable names applied in the process as it is the intellectual property rights are owned by someone else. I'm in contact with their support team however in the hope they can help support retrieval of this information to help support their modular use of bolt-on php applications and pages with their forum use. I'm using PHP as my coding platform and believe there could be useful techniques to extract data from the above that doesn't require the preferred method of a listener or simply isn't possible in the case of a java process from the child when cross domains are in use. Ideally the textual part associated with the class "element_username" or the "data-minitooltip" value could be used as per the username displayed on the parent frame. Could anyone advise of useful techniques how I could extract this information with only being able to apply coding changes in the child php code? Edited November 19, 2013 by Noesis Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted November 19, 2013 Share Posted November 19, 2013 The only way you're going to get access to the variables set by the script is by including the raw PHP source code. If the PHP script is on a completely different site to yours then you are out of luck. Can you define what you mean by PHP variable? Are you wanting to get the username (Noesis) from the source code? (That you can do with PHP) Quote Link to comment Share on other sites More sharing options...
Noesis Posted November 19, 2013 Author Share Posted November 19, 2013 The only way you're going to get access to the variables set by the script is by including the raw PHP source code. If the PHP script is on a completely different site to yours then you are out of luck. Can you define what you mean by PHP variable? Are you wanting to get the username (Noesis) from the source code? (That you can do with PHP) Yes I simply want to extract that piece of text from the parent source, but from within a child iframe php page. Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted November 19, 2013 Share Posted November 19, 2013 (edited) You can use simplexml xpath for this $doc = new DOMDocument(); $doc->strictErrorChecking = FALSE; $html_source = file_get_contents('http://sitename,com/filename.php'); // url to webpage $doc->loadHTML($html_source); $xml = simplexml_import_dom($doc); $data = $xml->xpath("//a[@class='element_username']"); // finds <a href="..." class="element_username"></a> tags printf('<pre>%s</pre>', print_r($data, true)); // see what was found // echo username $username = (array) $data[0]; echo 'Username: ' . $username[0]; Edited November 19, 2013 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
Noesis Posted November 19, 2013 Author Share Posted November 19, 2013 ty Ch0cu3r, I'll give it a try. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.