Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Nov 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    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'); 

  • #3
    New to the CF scene
    Join Date
    Nov 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks. That's not the answer I was hoping for, but at least it gets us out of a blind alley.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    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'); 

  • #5
    New to the CF scene
    Join Date
    Nov 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    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'); 

  • #7
    New to the CF scene
    Join Date
    Nov 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •