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.

Way of running 5 ads using one include

Discussion in 'Co-op Advertising Network' started by Patient, Dec 5, 2004.

  1. #1
    I am running 5 ads and at present including ad_network.php 5 times to get the ads.
    SEMrush
    To speed things up a bit can I include once and get all 5 ads in one go? If yes can you point me in the right direction re modifying the code please.
     
    Patient, Dec 5, 2004 IP
    SEMrush
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,299
    Likes Received:
    2,603
    Best Answers:
    461
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    Use the latest ad_network.php file. You only need to include once.
     
    digitalpoint, Dec 5, 2004 IP
  3. Patient

    Patient Raider

    Messages:
    336
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    123
    #3
    I believe I am up to date but only including once only brings one ad:

    This is my ad_network.php file:
    <?php

    if (!function_exists('file_get_contents')) {
    function file_get_contents($url) {
    $handle = fopen($url, 'r');
    $string = fread($handle, 4096000);
    fclose($handle);
    return $string;
    }
    }

    if (!function_exists('make_seed')) {
    function make_seed() {
    list($usec, $sec) = explode(' ', microtime());
    return (float) $sec + ((float) $usec * 100000);
    }
    srand (make_seed());
    }

    $ad_file = 'ad_network_ads.txt';
    for ($i = 0; $i <= 11; $i++) {
    $p = substr ('../../../../../../../../../../', 0, $i * 3);
    if (file_exists ($p . $ad_file)) {
    $ad_file = $p . $ad_file;
    break;
    }
    }

    if (is_writable ($ad_file)) {
    $ads = file_get_contents ($ad_file);
    $ads = explode ('<ad_break>', $ads);

    if (count ($ads) < 401 || $ads[0] + 900 < time()) {
    $new_ad = file_get_contents ('http://ads.digitalpoint.com/network.php?s=' . $_SERVER['SERVER_NAME'] . '&type=link');
    $ads[] = $new_ad;
    $ads[0] = time();
    if (count ($ads) > 401) unset ($ads[1]);
    if ($new_ad) {
    $file = fopen($ad_file, 'w');
    fwrite ($file, implode ('<ad_break>', $ads));
    fclose ($file);
    }
    $ad = end ($ads);
    } else {
    $ad = $ads[rand(1,count($ads) - 1)];
    }
    $ad_network[] = $ad;
    } else {
    $ad_network[] = 'You must set the "ad_network_ads.txt" file to be writable.';
    }
    if (substr (@$_SERVER['DOCUMENT_NAME'], -6) == '.shtml') {
    ini_set ('zlib.output_compression', 0);
    echo end ($ad_network);
    }

    ?>

    This is my current code to call ads:
    <?php
    echo '<DIV class="box2"><DIV class="box2_t">Our Sponsors:</DIV>';
    echo '<DIV Class="tc">';
    ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
    include ('ad_network.php');
    echo '<img src="'.$dir.'images/2-but-1.jpg" width="6" height="7"> '.$ad_network[0].'<br>';
    echo '<img src="'.$dir.'images/2-but-1.jpg" width="6" height="7"> '.$ad_network[1].'<br>';
    echo '<img src="'.$dir.'images/2-but-1.jpg" width="6" height="7"> '.$ad_network[2].'<br>';
    echo '<img src="'.$dir.'images/2-but-1.jpg" width="6" height="7"> '.$ad_network[3].'<br>';
    echo '<img src="'.$dir.'images/2-but-1.jpg" width="6" height="7"> '.$ad_network[4];
    echo '</DIV></DIV>';
    ?>
     
    Patient, Dec 5, 2004 IP
  4. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,299
    Likes Received:
    2,603
    Best Answers:
    461
    Trophy Points:
    710
    Digital Goods:
    29
    #4
    It's an old ad_network.php file.
     
    digitalpoint, Dec 5, 2004 IP
  5. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #5
    All my files are up to date and I use this code in my footer:

    <?php
    ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
    include ('ad_network.php');
    echo $ad_network [0] . ', ';
    include ('ad_network.php');
    echo $ad_network [1] . ', ';
    include ('ad_network.php');
    echo $ad_network [2] . ', ';
    include ('ad_network.php');
    echo $ad_network [3] . ', ';
    include ('ad_network.php');
    echo $ad_network [4];
    ?>
     
    ResaleBroker, Dec 5, 2004 IP
  6. rvarcher

    rvarcher Peon

    Messages:
    69
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    See if this works for you.

    include ('ad_network.php');

    echo implode(" ", $ad_network);


    - Bob Archer
    http://www.tropicrentals.com
     
    rvarcher, Dec 5, 2004 IP
  7. Patient

    Patient Raider

    Messages:
    336
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    123
    #7
    My apologies - I was certain I had updated ad_network.php on all my domains.

    I have updated the file and it now works with a single include.

    Thanks.
     
    Patient, Dec 6, 2004 IP
  8. eduardomaio

    eduardomaio Peon

    Messages:
    450
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Why don't you use only this...
    
    <?php
    ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
    include ('ad_network.php');
    echo $ad_network[0] $ad_network[1] $ad_network[2] $ad_network[3] $ad_network[4];
    ?>
    
    Code (markup):
    Or even, to have something between anchor text...
    
    <?php
    ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
    include ('ad_network.php');
    echo (''.$ad_network[0].' | '.$ad_network[1].' | '.$ad_network[2] $ad_network[3].' | '.$ad_network[4].'');
    ?>
    
    Code (markup):
    I don't think the inicial and final ' ' are needed, but i'm too lazy to find out...
     
    eduardomaio, Dec 6, 2004 IP
  9. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #9
    I tried both of your codes and neither worked. They both only showed the first ad. :confused:

    EDIT: I uploaded the latest ad_network.php file and now your code works great. Thanks! :)

    NOTE: The initial code was missing a few characters. Here is the corrected version:
    <?php
    ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
    include ('ad_network.php');
    echo (''.$ad_network[0].' | '.$ad_network[1].' | '.$ad_network[2].' | '.$ad_network[3].' | '.$ad_network[4].'');
    ?>
     
    ResaleBroker, Dec 6, 2004 IP
  10. yfs1

    yfs1 User Title Not Found

    Messages:
    13,798
    Likes Received:
    922
    Best Answers:
    0
    Trophy Points:
    0
    #10
    I believe there should be commas between each new ad like:

    <?php
    	ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
    	include ('ad_network.php');
    	echo $ad_network[0].' | ',$ad_network[1].' | ', $ad_network[2];
    ?>
    Code (markup):
     
    yfs1, Dec 6, 2004 IP
  11. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,299
    Likes Received:
    2,603
    Best Answers:
    461
    Trophy Points:
    710
    Digital Goods:
    29
    #11
    No, you don't need commas... and an easier way to do it is like so:

    echo implode (' | ', $ad_network);
    PHP:
     
    digitalpoint, Dec 6, 2004 IP
  12. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #12
    Sweet!:) Thanks Shawn!
     
    ResaleBroker, Dec 6, 2004 IP