View Full Version : Reading a script from PHP
12-18-2008, 09:49 PM
We need to read (not execute) a script from a PHP script running on our server. Essentially we need to parse some data from the script. Most users of the script can use it directly, but because we're doing this using other people's tools we have to go in, get the data, and do the work ourselves.
We're using curl_exec, which works fine for reading data from HTML pages, but some very odd things happen when we try to do it on a page that starts with document.write. Any suggestions would be greatly appreciated.
12-19-2008, 02:55 PM
On you're own host accessing you're own files any file reading with the exception of include and require will let you extract the contents. On you're own system it reads it as an unparsed file, while over a remote host its parsed first and you're given the html as a result. There is no way (to my knowledge) to get around this using standard PHP functionality. This is simply for security - it would be pretty easy to gain access to any site database with the ability to view their authentication credentials.
12-19-2008, 06:09 PM
Thanks. That's not the answer I was hoping for, but at least it gets us out of a blind alley.
12-20-2008, 12:51 AM
You could try to attach via FTP or SSH to perform this. There are built in methods in PHP to handle these. Configurations on the server end would be required to allow you to open these files though, and if you can't alter the server end you will be out of luck on that.
I forgot about this when I posted my last one. So I guess in PHP you can read remote files.
12-20-2008, 07:57 PM
Let me put the question another way- is there a way for a script to read the output from a document.write call? That's all we need to do. In a sense we're pretending to be a browser and need to see what the script on the other server is writing to the screen.
12-20-2008, 08:29 PM
No, document.write is done after the fact. Since it doesn't place the written value into the source code, you cannot detect this with PHP. You can detect the existence of document.write and write to compensate for it, but I don't recommend doing that - it would be a lot of work to see what it does.
Document.write is old school though, its should be re-written to cover more dom-compliant coding practices. That sounds like its out of you're control though (on the remote server), so nothing can be done about that.
12-20-2008, 08:33 PM
Yes, it's out of our control. The page we're trying to read puts up an ad- a bitmap with an underlying clickthrough URL. We just need to extract the address of the bitmap and the clickthrough URL so that we can serve the ad through a different mechanism.
We're basically stuck inbetween two systems that were not designed to work together. Neither wants to change what they do, but they would both be very happy if we can find a way to bridge the gap.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.