I searched around and saw there was an old block for coop links, but not a recent one so I wrote a quickie. It is really short but I hope it is useful.
Because other wise I have to put them in the footer file on each template that I use on my site. Since I am planning adding multiple user templates in the near future I did not want to have to update each footer file each time I add a new template and then next time there is an update do it again. This way I only have to change teh minimum of files for updates. Do you use PHPnuke or Platinum or such?
A php-Nuke block is a box that will display the coop ads. You can view other blocks here. http://phpnuke.org/modules.php?name=News&file=categories&op=newindex&catid=5
FYI If you want to see this block in action go to http://www.the-party.org It is at the bottom on the left side
ahhh... I see... I misunderstood it to mean "blocking the display of Coop ads". No, I just use regular phpBB
Nice block! I like now not having to recode all templates that are affected. However I am not sure if it is my custom template or something that the block needs. When using this block...I cannot put it right or left because the window that shows the ads is too wide. But also when I put it to the center position...it stretches out my center column a tad bit. I guess my question is....what edit do I need to make to the block .php file to decrease the window size that the ads show up in. You can see what I mean by checking out the site http://www.supertraxxradio.com Thanks in advance
So to use this block, I just change the one line: include ('ad_network_xxx.php'); Code (markup): right? As long as those numbers match my ad_network_ads.txt I am OK?
So I'm using this block on www.ozband.net but the ads show up twice. You can see if you look at the bottomg left. At the very bottom you see this block with the ads in it. But above that the ads are being shown outside the box. How do I get rid of the mirror ads?
Interesting, can you attach the exact file you are using? I will see what is wrong. PM me if you have any other questions.
For block-coop.php <?php /************************************************************************/ /* PHP-NUKE: Web Portal System */ /* =========================== */ /* */ /* Copyright (c) 2002 by Francisco Burzi */ /* [url]http://phpnuke.org[/url] */ /* */ /* This program is free software. You can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License. */ /************************************************************************/ /************************************************************************/ /* Created by Jeff MacKinnon for use on [url]www.the-party.org[/url] */ /* Use this code however you wish. */ /************************************************************************/ if (eregi("block-Coop_Links.php",$_SERVER['PHP_SELF'])) { Header("Location: index.php"); die(); } $content .= "<br>"; $content .= "<a href=\"http://www.digitalpoint.com/tools/ad-network/?s=8666\" target=\"_blank\">Coop Advertising Network</a>"; $content .= "<br>"; $content .= "<br>"; ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../'); include ('ad_network_xxx.php'); $content .= "<center>"; $content .= $ad_network; $content .= "</center>"; ?> Code (markup): This is the block used on ozband.... Here is the ad_network_xxx.php <?php // Last update: Apr 5, 2005 11:55 am 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); } mt_srand (make_seed()); } if (!isset($_SERVER)) $_SERVER = $HTTP_SERVER_VARS; $ad_file = 'ad_network_ads_236.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)) { $ad_network = array(); $ads = file_get_contents ($ad_file); $ads = explode ('<ad_break>', $ads); $ads_temp = explode ('|', $ads[0]); $file = fopen($ad_file, 'r+'); if (flock ($file, LOCK_EX|LOCK_NB, $would_block) && !$would_block) { if ((count ($ads) < $ads_temp[3] + 1 && $ads_temp[0] + $ads_temp[5] < time()) || $ads_temp[0] + $ads_temp[4] < time()) { $new_ad = file_get_contents ('http://ads.digitalpoint.com/network.php?c=' . $_SERVER['SERVER_NAME'] . '&type=link'); if ($new_ad) { $ads_param = explode ('<ad_param>' , $new_ad); $new_ad = $ads_param[1]; unset ($ads_param[1]); $ads_temp = explode ('|', $ads_temp[0] . '|' . $ads_temp[1] . '|' . $ads_param[0]); } else { $ads_param = array_slice ($ads_temp, 2, 4); } $ads[0] = time() . '|' . gethostbyname('validate.digitalpoint.com') . '|' . implode ('|', $ads_param); if ($new_ad) { $ads[] = $new_ad; if (count ($ads) > $ads_temp[3] + 1) $ads = array_merge ((array)$ads[0], (array)array_slice ($ads, -$ads_temp[3])); } fwrite ($file, implode ('<ad_break>', $ads)); ftruncate ($file, ftell($file)); $ad_network[] = $new_ad; } flock ($file, LOCK_UN); fclose ($file); } while (count ($ad_network) < 5) { $ad_network[] = $ads[mt_rand(1,count($ads) - 1)]; } foreach ($ad_network as $key => $ad) { $split = explode ('<id>', $ad); $ad_ids[] = $split[1]; $ad = $split[0]; $output = $ads_temp[1] == $_SERVER['REMOTE_ADDR'] || $_SERVER['SERVER_ADDR'] == $_SERVER['REMOTE_ADDR']; if ($output) { $ad_network[$key] = str_replace ('" />', '" class="' . $ads_temp[2] . '" />', $ad); } else { $ad_network[$key] = str_replace ('" />', '">', $ad); } } $ad_network = implode (' - ', $ad_network); if ($ads_temp[6] && ($output || preg_match('#(' . str_replace ('-', '|', $ads_temp[7]) . ')#si', $_SERVER['HTTP_USER_AGENT'])) && !$_SERVER['HTTPS']) $ad_network .= '<img src="http://ads.digitalpoint.com/t-' . implode ('-', $ad_ids) . '.gif" width="1" height="1" />'; } else { $ad_network = 'You must set the ad network .txt file to be writable.'; } echo $ad_network; ?> Code (markup):
hmmmmm, I am not sure what is wrong. I updated my code last on Mar31, 2005 and at the end it shows if (substr (@$_SERVER['DOCUMENT_NAME'], -6) == '.shtml') { ini_set ('zlib.output_compression', 0); echo $ad_network; } Code (markup): instead of simply echo $ad_network; Code (markup): I am not sure if this is the problem or not. When I have time I will update my code, are you using ad_network_216?
Why do you ask the number? I thought it made no difference. I think it's 235 or something, but I suppose we could rename it to 216...
Alright Jim, I think that the last time I looked at this that I had a small mental block. Try commenting out the echo $ad_network; Code (markup): in ad_network_xxx.php a the bottom and see if that solves the problem. If it does awesome, if not let me know and I will try something else
I am glad that I could help.....Hopefully in the future I will be ble to come up with one that doesn't require modifying the ad_networkXXX code