Running scripts inside PHP page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dcortez
    DINO CORTEZ™
    • Jun 2003
    • 2145

    #1

    Running scripts inside PHP page

    Hi,

    Is running a web script possible from inside a PHP page as part of building the content of that page?

    Eg.
    <% SomehowMagicallyCall:

    http://SomeFarAwayDomain.com/cgi-bin/make-some-html.cgi

    %>

    For understandable security, I know server side includes (SSI) generally lock out outside scripts.

    What's the climate like with PHP for this?

    A snippet of syntax please?

    If PHP can call external scripts which return text (like SSI), can the parent PHP page pass basic authentication info to the script (username/password) if the script has a cover charge?

    Thanks,
    -Dino
  • NastyJack
    Registered User
    • Dec 2002
    • 1291

    #2
    not too sure exactly what you are trying to do but just calling the include function should work.

    <?php

    include("http://somefarawayplace.com/cgi-bin/makehtml.cgi");

    ?>

    would work.

    if the dir is pw protected, you can do this:

    PHP Code:
    <?php
    
    $fp = fopen("http://user:[email protected]/protected/file.cgi");
    while (!feof($fp)) {
      $data = fgets($fp, 255);
    }
    
    fclose($fp);
    
    echo $data;
    
    ?>
    Last edited by NastyJack; 12-09-2004, 10:01 PM.

    Comment

    • Bro Media - BANNED FOR LIFE
      MOBILE PORN: IMOBILEPORN
      • Jan 2004
      • 16502

      #3
      Originally posted by NastyJack
      not too sure exactly what you are trying to do but just calling the include function should work.

      <?php

      include("http://somefarawayplace.com/cgi-bin/makehtml.cgi");

      ?>

      would work.

      if the dir is pw protected, you can do this:

      PHP Code:
      <?php
      
      $fp = fopen("http://user:[email protected]/protected/file.cgi");
      while (!feof($fp)) {
        $data = fgets($fp, 255);
      }
      
      fclose($fp);
      
      echo $data;
      
      ?>
      that will work, but since your calling an offsite script, it can shoot some errors your way, so try to put a at "@" symbol infront of the include and fopen like this

      PHP Code:
      <?php
      
      @include("http://somefarawayplace.com/cgi-bin/makehtml.cgi");
      
      ?>
      and

      PHP Code:
      <?php
      
      $fp = @fopen("http://user:[email protected]/protected/file.cgi");
      while (!feof($fp)) {
        $data = fgets($fp, 255);
      }
      
      fclose($fp);
      
      echo $data;
      
      ?>
      that will supress the errors

      Comment

      • dcortez
        DINO CORTEZ™
        • Jun 2003
        • 2145

        #4
        Thanks guys!

        -Dino

        Comment

        Working...