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.

Read This If You Are Not Using stock ad_network.php File

Discussion in 'Co-op Advertising Network' started by digitalpoint, Oct 7, 2004.

  1. #1
    Just a FYI, if you aren't using the stock ad_network.php file for your implementation, you will want to double check that your setup is working properly. Specifically that whatever ad caching mechanism you have in place on your end is not requesting more than 1 ad per hour.

    I've setup a system that completely blocks the IP addresses of machines requesting an excessive amount of ads in a single day (which means their caching system is broken or simply not being used).

    Some IPs have already been blocked.
     
    digitalpoint, Oct 7, 2004 IP
  2. TwisterMc

    TwisterMc Mac Guru

    Messages:
    972
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Crap... now i gotta figure out how to get the new stuff working. ;)
     
    TwisterMc, Oct 7, 2004 IP
  3. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #3
    It's not new actually. :)
     
    digitalpoint, Oct 7, 2004 IP
  4. jontelofot

    jontelofot Peon

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Is this it?

    <b>Warning</b>: halt(): Failed opening './includes/functions_log_error.php' for inclusion (include_path='') in <b>/home/.sites/33/site5/web/includes/db_mysql.php</b> on line <b>318</b><br />

    I had a few of those in my ad_network_ads.txt.
     
    jontelofot, Oct 7, 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
    No, that was a problem with the db server last night.
     
    digitalpoint, Oct 7, 2004 IP
  6. jontelofot

    jontelofot Peon

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Good!

    I did feel guilty when I read this post though. I did semi-spam the adserver a couple of times the last few weeks to see how often my ad was served.

    Sorry about that! I will not happen again.

    I just realized that someone must have gotten a referral bonus from me. I thought I signed up all by my self, but no...

    So, who scored the 8210 referral weight bonus? :)
     
    jontelofot, Oct 7, 2004 IP
  7. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #7
    Individually it's not a big deal, but the ad server is serving up about 80 times more ads than it should be, so that's why it's going to start being enforced. :)
     
    digitalpoint, Oct 7, 2004 IP
  8. kaptain

    kaptain Peon

    Messages:
    194
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #8
    i have three sites in the ad network and they are on the same server and same ip. is this a problem?

    i am using the stock php file and i'm not having any problems.
     
    kaptain, Oct 8, 2004 IP
  9. TwisterMc

    TwisterMc Mac Guru

    Messages:
    972
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I'm still using the code from when i signed up. Not the 'udated' stuff from a month or so ago. Is that bad? :rolleyes:
     
    TwisterMc, Oct 8, 2004 IP
  10. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #10
    kaptain - No, you should be fine.

    TwisterMc - Yeah, you will need to switch over to the new stuff as soon as possible.
     
    digitalpoint, Oct 8, 2004 IP
  11. flawebworks

    flawebworks Tech Services

    Messages:
    991
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    78
    #11
    This is what I'm using:

    ------------------------

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

    if (count ($ads) < 101 || $ads[0] + 3600 < time()) {
    $ads[] = file_get_contents ('http://ads.digitalpoint.com/network.php?type=link');
    $ads[0] = time();
    if (count ($ads) > 101) unset ($ads[1]);
    $file = fopen('ad_network_ads.txt', 'w');
    fwrite ($file, implode ('<ad_break>', $ads));
    fclose ($file);
    $ad_network = end ($ads);
    } else {
    $ad_network = $ads[rand(1,count($ads))];
    }
    $ad_network .= '<!-- an-hl -->';
    } else {
    $ad_network = 'You must set the "ad_network_ads.txt" file to be writable.';
    }
    --------------------------

    Switch?
     
    flawebworks, Oct 8, 2004 IP
  12. leeds1

    leeds1 Peon

    Messages:
    585
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #12
    how do we know if we are being blocked? My stuff is done in the last 2/3 weeks I think - but I would like to check it out
     
    leeds1, Oct 8, 2004 IP
  13. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #13
    flawebworks - That file should be fine as far as caching... although there is a new version you may way to pull that has some extra error checking. Wouldn't be a bad idea to update it, but not necessary.

    leeds1 - Well, you would know right away because you won't get ads on your site.
     
    digitalpoint, Oct 8, 2004 IP
  14. TwisterMc

    TwisterMc Mac Guru

    Messages:
    972
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #14
    I'll try to do it sunday. Last time i tried it didn't work well and my whole site went down. So i reverted to what was working. :D
     
    TwisterMc, Oct 8, 2004 IP
  15. TwisterMc

    TwisterMc Mac Guru

    Messages:
    972
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Yea so I set it up just like you asked and the .htaccess file kills my blog.

    http://www.twistermc.com/twister/blog I've removed the code that makes my site break and asked my server for the error logs but I can't use the new code as it's written right now. :(
     
    TwisterMc, Oct 10, 2004 IP
  16. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #16
    What's the error log say exactly?
     
    digitalpoint, Oct 10, 2004 IP
  17. TwisterMc

    TwisterMc Mac Guru

    Messages:
    972
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #17
    I don't have access to the error logs but my host fixed it. Do you wanna know what they said the problem was? I'm just happy it's working again!!
     
    TwisterMc, Oct 11, 2004 IP
  18. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #18
    Well if it works, then that's cool... I don't need to know. :)
     
    digitalpoint, Oct 11, 2004 IP
  19. clickdoc

    clickdoc Guest

    Messages:
    39
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #19
    Shawn,

    I am fixing the perl version and I have solved the issue with some file locking. However in reviewing your file I can't understand how the php version doesn't also have the problem. Of course I've only played with PHP slightly but I ran the same test on your script I ran on mine and yours appears to have the same issues. The issue arises when a busy site (multiple requests per second) tries to update the ad_network_ads file and the DP server takes a second or more to respond due to network traffic, load, etc. When that happens multiple httpd processes can be trying to grab the new file from your server and all write a new ad_network_ads file.

    I grabbed this php file off the setup page today. I modified it to print to the server logs whenever it writes a new file, and hence accesses your server. I removed the actual access as to not do a bunch of unneeded queries but I simulate your server taking a minute to respond with a sleep(3). I then ran apache bench with 10 concurrent processes each grabbing 10 pages.

    Here is the script. I removed the count check because I found that the file was getting clobbered sometimes and ending up with only one link so I wanted to rule out it writing the file because there were less than 100 links, the time check is only 10 seconds just so I could run it over and over for testing.

    <?php

    $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;
    }
    }
    echo $ad_file;

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

    if ($ads[0] + 10 < time()) {
    //$new_ad = file_get_contents ('http://ads.digitalpoint.com/network.php?type=link');
    $new_ad = 'test';
    sleep(3);
    //$ads[] = $new_ad;
    $oldstamp = $ads[0];
    $ads[0] = time();
    if (count ($ads) > 101) unset ($ads[1]);
    if ($new_ad) {
    error_log("WRITING: old stamp" . $oldstamp . " new stamp = " . $ads[0]);
    $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 . '<!-- an-hl -->';
    } 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);
    }
    ?>

    Here are the results in the logs. All these old stamps being the same after ther first one represent times when your server would have been contacted and shouldn't have.

    [Mon Oct 11 19:02:44 2004] [error] WRITING: old stamp1097546532 new stamp = 1097546564
    [Mon Oct 11 19:02:44 2004] [error] WRITING: old stamp1097546532 new stamp = 1097546564
    [Mon Oct 11 19:02:44 2004] [error] WRITING: old stamp1097546532 new stamp = 1097546564
    [Mon Oct 11 19:02:44 2004] [error] WRITING: old stamp1097546532 new stamp = 1097546564
    [Mon Oct 11 19:02:44 2004] [error] WRITING: old stamp1097546532 new stamp = 1097546564
    [Mon Oct 11 19:02:44 2004] [error] WRITING: old stamp1097546532 new stamp = 1097546564
    [Mon Oct 11 19:02:44 2004] [error] WRITING: old stamp1097546532 new stamp = 1097546564
    [Mon Oct 11 19:02:44 2004] [error] WRITING: old stamp1097546532 new stamp = 1097546564
    [Mon Oct 11 19:02:45 2004] [error] WRITING: old stamp1097546532 new stamp = 1097546565
    [Mon Oct 11 19:02:46 2004] [error] WRITING: old stamp1097546532 new stamp = 1097546566

    Is this correct? I just want to make sure other people don't end up getting locked out simply because they have a server getting mutliple hits every second.

    Jason
     
    clickdoc, Oct 11, 2004 IP
  20. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #20
    Yeah... I know the file locking is something I need to look into. I'll do some testing on this end and address it soon.
     
    digitalpoint, Oct 11, 2004 IP