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.

Multiple Ads

Discussion in 'Co-op Advertising Network' started by toddmc, Dec 9, 2004.

  1. #1
    I've read through all of the previous posts and tried all solutions. Still to no avail. I'm getting multiple duplicate ads. Here's what I've got for 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());
    }

    if (!isset($_SERVER)) $_SERVER = $HTTP_SERVER_VARS;

    $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, 'r+');
    if (flock ($file, LOCK_EX)) {
    fwrite ($file, implode ('<ad_break>', $ads));
    ftruncate ($file, ftell($file));
    flock ($file, LOCK_UN);
    }
    fclose ($file);
    }
    $ad = end ($ads);
    } else {
    $ad = $ads[rand(1,count($ads) - 1)];
    }
    $ad_network[] = $ad;
    while (count ($ad_network) < 5) {
    $ad_network[] = $ads[rand(1,count($ads) - 1)];
    }
    } 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);
    }

    ?>

    and here's what I've got for my php code:

    <?php
    ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
    include ('ad_network.php');
    echo implode (' ', $ad_network);
    ?>

    Am I missing something?
     
    toddmc, Dec 9, 2004 IP
  2. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Works for me, out of the box as per the original instructions...

    <?php
    ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
    include ('ad_network.php');
    include ('ad_network.php');
    include ('ad_network.php');
    include ('ad_network.php');
    include ('ad_network.php');
    echo "<p>Some other internet browsing ideas:";
    echo ''.$ad_network[0].' / '.$ad_network[1].' / '.$ad_network[2].' / '.$ad_network[3].' / '.$ad_network[4].'</p>';
    ?>
     
    T0PS3O, Dec 9, 2004 IP
  3. toddmc

    toddmc Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Check out this one: http://www.blueridgelighting dot com/resources/resources.html
     
    toddmc, Dec 9, 2004 IP
  4. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Have you touched the ad_network file? I left that as is... Might then be server settings or whatever it is (beyond my comprehension). Or that Finance person has got an afwul lot of weight...

    Could also be that the 'cache' hasn't populated properly just yet.
     
    T0PS3O, Dec 9, 2004 IP
  5. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #5
    TOPS - You only need to include once as long as you are using the latest ad_network.php file.

    toddmc - What platform is your server running? Someone else had a similar problem on a Windows server that never was resolved. Is your ad_network_ads.txt file full of ads?
     
    digitalpoint, Dec 9, 2004 IP
  6. toddmc

    toddmc Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yeah I'm pretty sure it's a Windows platform. Not a single ad is in the ad_network_ads.txt file
     
    toddmc, Dec 9, 2004 IP
  7. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I thought I was (27th Nov files) but obviously not because when escaping the other 4 includes only one shows up... Oh well, it must be updating faster than a cat can scratch it's ass...
     
    T0PS3O, Dec 9, 2004 IP
  8. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #8
    Double check that the ad_network_ads.txt file is writable on the server (for anyone... specifically the web server "user").
     
    digitalpoint, Dec 9, 2004 IP
  9. toddmc

    toddmc Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Just double checked the write permissions. It wasn't set so I'll give it a little bit and check the txt file again. Thanks for the help!
     
    toddmc, Dec 9, 2004 IP
  10. toddmc

    toddmc Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    I did that and now it's showing ads just fine in the ad_network_ads.txt. I still can't figure out the duplicate multiple ads displaying though.
     
    toddmc, Dec 9, 2004 IP
  11. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #11
    That's about as far as we got with the other Windows server and it never was resolved. They ended up running just a single ad. I'm not sure why, but the only thing I can think of at this point would be the server no seeding it's random number generator properly or something.
     
    digitalpoint, Dec 9, 2004 IP