If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

Reading a script from PHP

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.

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.

PHP Code:

header('HTTP/1.1 420 Enhance Your Calm');

Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

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.

PHP Code:

header('HTTP/1.1 420 Enhance Your Calm');

Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

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.

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.

PHP Code:

header('HTTP/1.1 420 Enhance Your Calm');

Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

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.