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 for VB3.x not working? Tried all previous posts.

Discussion in 'Co-op Advertising Network' started by amaze, Dec 7, 2004.

  1. #1
    Hi,

    The main site (www.myprotein.co.uk) is running Coldfusion and I have successfully added 5 text-link's to the footer of each of .CFM pages using the script posted on this forum - this works great!

    The forum (www.myprotein.co.uk/forum) is part of the site runs VB3 and is running PHP on Windows Server 2003. I have followed the set-up instructions and edited the ad_network.php (its the latest one) file so its uses the a shared ad_network_txt.txt file in the root. This is what I changed it too:

    $ad_file = '../ad_network_ads.txt';
    PHP:
    I made all the other changes per setup.

    Within the footer i added:

    $ad_network[0] $ad_network[1] $ad_network[2] $ad_network[0] $ad_network[3] $ad_network[4]

    The problem is I just get one link repeated 5 times?

    I tried using implode but then it returns nothing?

    Can anyone help as Im pulling my hair out!

    Thanks
     
    amaze, Dec 7, 2004 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    Are you using the updated ad_network.php file?
     
    digitalpoint, Dec 7, 2004 IP
  3. amaze

    amaze Active Member

    Messages:
    594
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    This is it:

    <?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);
    	}
    
    ?>
    PHP:
     
    amaze, Dec 7, 2004 IP
  4. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #4
    That's the right one... Try using the full absolute path to the ad_network_ads.txt file, rather than a relative one.
     
    digitalpoint, Dec 7, 2004 IP
  5. amaze

    amaze Active Member

    Messages:
    594
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Ok changed to abs path:

    $ad_file = 'D:\Inetpub\myprotein\ad_network_ads.txt';
    PHP:
    ...but it still dupes the links? You can see it here: (www[dot]myprotein co.uk/forum/)

    This is the code I have in the footer:

    $ad_network[0] $ad_network[1]
    PHP:
    Please help as this is very fustrating. :p
     
    amaze, Dec 7, 2004 IP
  6. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #6
    If you look in your ad_network_ads.txt file, is there a bunch of ads, or just one?
     
    digitalpoint, Dec 7, 2004 IP
  7. amaze

    amaze Active Member

    Messages:
    594
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #7
    There is 7k's worth... (thanks for your cont. help)
     
    amaze, Dec 7, 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
    I really don't know... the only thing I can think of is your server isn't properly seeding it's internal random number generator or something.
     
    digitalpoint, Dec 7, 2004 IP
  9. amaze

    amaze Active Member

    Messages:
    594
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #9
    Darn it is a werid one.

    Im hosting @ crystaltech.com on Win Server 2003 box which has windows PHP support so that maybe is the issue?

    Is there any other way of getting it to work using a HTML or CFML method?
     
    amaze, Dec 7, 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
    What version of PHP are you using?
     
    digitalpoint, Dec 7, 2004 IP
  11. amaze

    amaze Active Member

    Messages:
    594
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #11
    PHP Version 4.x (windows) the box also supports CFMX and ActiveState Perl.
     
    amaze, Dec 7, 2004 IP
  12. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #12
    Do you know exactly what 4.x version it is though?
     
    digitalpoint, Dec 7, 2004 IP
  13. amaze

    amaze Active Member

    Messages:
    594
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #13
    Ah sorry.

    Taken from phpinfo()

    PHP Version 4.3.9
     
    amaze, Dec 7, 2004 IP
  14. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #14
    I'm at a loss to be honest. I know PHP on Windows does do some things a little screwy sometimes, but I've never heard of a random number generator not seeding properly.
     
    digitalpoint, Dec 7, 2004 IP
  15. rvarcher

    rvarcher Peon

    Messages:
    69
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #15
    It looks like you might have quotes around part of an implode statement.

    
    echo "(\" \", $ad_network)";
    
    PHP:
    using the above statement I come close to duplicating the output I see on your page. It needs to be

    
    echo implode(' ', $ad_network);   //  without any extra quotes.
    
    PHP:
     
    rvarcher, Dec 7, 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
    You're right... but they said the only thing they added to the template was $ad_network[0] $ad_network[1] It's not straight PHP, just a template that can take variables. So the implode wouldn't work in this case even if you had it.
     
    digitalpoint, Dec 7, 2004 IP
  17. amaze

    amaze Active Member

    Messages:
    594
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #17
    I did try adding the implode function to the "footer style" as I read this fix on another post. Your correct it doesn't work.

    Well I'm stumped which is a shame as my forum is PR6 so was hoping to get multiple links on there...

    Is there anyway of me hacking a .php file and adding the implode function to it instead?
     
    amaze, Dec 7, 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
    Ad this to the end of the ad_network.php file (before the closing PHP tag though)...
    $ad_output = implode (' | ', $ad_network);
    PHP:
    Then use $ad_output as your variable in the footer.
     
    digitalpoint, Dec 7, 2004 IP
  19. amaze

    amaze Active Member

    Messages:
    594
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #19
    Ahhh I thought that was going to work but it just repeats the link 5 times. Werid!
     
    amaze, Dec 7, 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
    Well it's not going to solve the problem of the same ad being in the array to begin with, so it's about what I would expect.
     
    digitalpoint, Dec 7, 2004 IP