Error after updating the code

Discussion in 'Co-op Advertising Network' started by stathis, Apr 1, 2005.

  1. #1
    I got this code after updating the code.

    Bear in mind that i kept the old filename and changed them in the php code. Here is what i get


    Warning: Invalid argument supplied for foreach() in /home2/soccerbo/public_html/phpBB2/ad_network.php on line 64

    Warning: implode(): Bad arguments. in /home2/soccerbo/public_html/phpBB2/ad_network.php on line 75
     
    stathis, Apr 1, 2005 IP
  2. stathis

    stathis Peon

    Messages:
    493
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I even changed everything to ad_network_213 etc and nothing changed. Still the same error.
     
    stathis, Apr 1, 2005 IP
  3. Dominic

    Dominic Well-Known Member

    Messages:
    1,725
    Likes Received:
    121
    Best Answers:
    0
    Trophy Points:
    185
    #3
    I'm having dramas too.
     
    Dominic, Apr 1, 2005 IP
  4. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #4
    Can you copy/paste your ad_network PHP file?
     
    digitalpoint, Apr 1, 2005 IP
  5. stathis

    stathis Peon

    Messages:
    493
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    
    
    <?php
    	// Last update:  Mar 31, 2005 2:28 pm
    
    	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_213.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);
    		$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']);
    				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) < 1) {
    			$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 ('<br>', $ad_network);
    		if ($ads_temp[6] && ($output || preg_match('#(' . str_replace ('-', '|', $ads_temp[7]) . ')#si', $_SERVER['HTTP_USER_AGENT']))) $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.';
    	}
    	if (substr (@$_SERVER['DOCUMENT_NAME'], -6) == '.shtml') {
    		ini_set ('zlib.output_compression', 0);
    		echo $ad_network;
    	}
    
    ?>
    
    
    PHP:
     
    stathis, Apr 1, 2005 IP
  6. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #6
    Hmmm... it looks okay, and I installed that version on a setup here and I don't get any errors. When you do get the errors, do you also get ads with it? or none?

    Is there anything in your .txt file?
     
    digitalpoint, Apr 1, 2005 IP
  7. stathis

    stathis Peon

    Messages:
    493
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #7
    sorry about the double post....No i cannot see the ads. Just these errors.
     
    stathis, Apr 1, 2005 IP
  8. stathis

    stathis Peon

    Messages:
    493
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #8
    i deleted and recreated the txt file after the error just to be sure
     
    stathis, Apr 1, 2005 IP
  9. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #9
    Is there anything in your .txt file?
     
    digitalpoint, Apr 1, 2005 IP
  10. stathis

    stathis Peon

    Messages:
    493
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #10
    yes it has data. you want me to paste them here?
     
    stathis, Apr 1, 2005 IP
  11. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #11
    Send it to me in PM if you could.
     
    digitalpoint, Apr 1, 2005 IP