adding another include to passthru.php

Discussion in 'PHP' started by jazzylee77, Nov 28, 2005.

  1. #1
    I'm using passthru.php to serve co-op ads on html sites.

    I was looking at including a randomquote.php file.

    my.htaccess file looks like this


    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} ^(.*).htm [NC,OR]
    RewriteCond %{REQUEST_FILENAME} ^(.*).html [NC]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^(.*)       /passthru.php?file=$1
    </IfModule>
    
    AddType text/html .shtml
    AddHandler server-parsed .html
    Options Indexes FollowSymLinks Includes
    Code (markup):

    Using SSI doesn't work unless I remove the first part relating to passthru.php

    So as an alternative I tried adding an include to my passthru.php file like this.

     <?php
    
    if (!function_exists('file_get_contents')) {
    function file_get_contents($url) {
    $handle = fopen($url, 'r');
    $string = fread($handle, 4096000);
    fclose($handle);
    return $string;
    }
    }
    
    
    
    include ('ad_network_216.php');
    echo preg_replace ("/<\/body>/i", $ad_network . '</body>', file_get_contents(str_replace ('../', '', 
    
    $_REQUEST['file'])));
    
    include ("randomquote.php");
    
    ?>
    Code (markup):
    This outputs the quote right below the co-op ads.

    I would like to see them just above the co-op ads.

    Putting the include ("randomquote.php"); before the ad network include shoots the quote to the top of the page.

    Question is: How do I tell passthru.php where to put it?

    Or alternatively: How can I make SSI work in this setup?
     
    jazzylee77, Nov 28, 2005 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    Ideally you would need the output of randomquote.php to simply be dropped into a variable. Then include it before the preg_replace line and spit out the variable within the preg_replace line.
     
    digitalpoint, Nov 29, 2005 IP
  3. jazzylee77

    jazzylee77 Peon

    Messages:
    578
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #3
    So if I want it to walk like the co-op script it has to talk like it.

    I was hoping I could B.S. my way through it since I'm still a cut and paste hack when it comes to PHP.

    Here is the basic random quote file.
    I'm searching for how to "drop this into a variable", but I'm afraid I might learn something.
     
    jazzylee77, Nov 29, 2005 IP
  4. sufyaaan

    sufyaaan Banned

    Messages:
    218
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #4
    $x = file_get_contents("randomquote.php");
    Code (markup):
    include it before the preg_replace line and spit out the variable within the preg_replace line. :D
     
    sufyaaan, Nov 30, 2005 IP
  5. jazzylee77

    jazzylee77 Peon

    Messages:
    578
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks. I've made a few hundred guesses at what "it" is and how to spit out a variable. Haven't figured it out yet and the room is covered in saliva. Maybe I should dry off one of those php books...
     
    jazzylee77, Nov 30, 2005 IP