1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Coop Include Code

Discussion in 'PHP' started by T0PS3O, Jan 12, 2005.

  1. #1
    Hi,

    YaBB is giving me some hassle with the coop code.

    I thought of a possible solution but don;t know the correct code.

    I need something similar to the php include command but don't want the code but the output of the included file.

    I thought I'd make an external file which calls ad_network.php and then output them in this external file. Then from within the forum I'd include this output.

    I need something like file_read or fopen is my guess.

    Which function is the one I need?

    Thanks for helping!
     
    T0PS3O, Jan 12, 2005 IP
  2. rvarcher

    rvarcher Peon

    Messages:
    69
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
       // Create file
       $fp = fopen ( "./folder/example.txt", "w" );
       fwrite($fp, $my_data_to_write_to_file);
       fclose($fp);
    
    PHP:
    Are you looking for something like that?
     
    rvarcher, Jan 12, 2005 IP
  3. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #3
    No. The files are created. It'll be a file like show_ads.php with in the code of the coop network in it.

    First it will include the ad_network.php file and secondly it will call the ad_network function and output the ad. So when loading this file in a browser, all yuo would see is 5 ads. Then, from within YaBB I will include this file. But not with the include() function because that will copy/paste the php code in the page where I only require the html output.

    I just need a way to not confuse YaBB code and only 'import' plain html from an external file.
     
    T0PS3O, Jan 12, 2005 IP
  4. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Had another look on php.net but still not sure which function does this.

    It'll be on of these:

    fopen()
    file_get_contents()
    fread()
    fgets()
    etc.

    I have the external file like this:

    code_to_display_ads.php
    <?php
        ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
    	include ('ad_network.php');
        echo "<p>Link Exchange:<br>";
    	echo ' '.$ad_network[0].' / '.$ad_network[1].' / '.$ad_network[2].' / '.$ad_network[3].' / '.$ad_network[4].'</p>';
    ?>
    PHP:
    But I don't want to include this code in my YaBB files. I only want to include its output which when opened in a seperate browser(tab) will look like this html stuff:

    <p>Link Exchange:<br> <a href="http://www.workchairs.com/">Swopper</a> / <a href="http://www.symetrix.net/">symetrix</a> / <a href="http://www.everythingfitness.com">Fitness Equipment</a> / <a href="http://www.tshirtfan.com">Tshirts and Calendars</a> / <a href="http://www.clantt.com/vb/t6462-free-spyware-removal.html">Free Spyware Removal</a></p>
    Code (markup):
    So... Which php function reads in the output instead of the source of a file? And which function does that the fastest, since it will be done on each and every request.

    Or perhaps, am I on to something that wouldn't even validate the ads?
     
    T0PS3O, Jan 13, 2005 IP