Status
Not open for further replies.

MortysTW

Customer
When vbShout is activated, it works fine, but it causes my advertiser's footer text links to NOT appear. No actual error breaking the site. The advertiser's text links just don't appear at all.

In my footer template I have:
Code:
<div class="gensmall" align="center">{vb:raw ad_network}</div>

This hook basically is a php include that pulls a file
Code:
ob_start();
$ad_network_output = require_once('--MyServerPath--public_html/ads/ad_network.php');
ob_end_clean();
if($ad_network)
{
 $templater = vB_Template::preRegister('footer', array('ad_network' => $ad_network, 'ad_network_output' => $ad_network_output));

}

Then the content of that ad_network.php file:
Code:
<?php
	// Last update:  July 10, 2006 3:10 pm (PST)
	// $LastChangedRevision: 656 $

	$ad_file = '--MyServerPath--/public_html/ads/ad_network_ads.txt';
	$ad_separator = ' | ';
	$ad_target = '0_blank';
	$ad_class = '';
	$ad_options = 0;
	
	if (false && function_exists('date_default_timezone_set')) {
		if((strlen(ini_get("date.timezone")) < 1) && (strlen(getenv("TZ")) < 1 )) {
			date_default_timezone_set("America/New_York");	
		}
	}
	
	if (!function_exists('file_get_contents_an')) {
		function file_get_contents_an($url) {
			$string = "";
			if (substr ($url, 0, 7) == 'http://') {
				$url = parse_url ($url);
				$handle = @fsockopen ($url['host'], 80, $errno, $errstr, 5);
				if ($handle!==false) {
					fwrite ($handle, "GET $url[path]?$url[query] HTTP/1.0\r\nHost: $url[host]\r\nConnection: Close\r\n\r\n");
					$enableStreamTimeOut = stream_set_timeout($handle, 5);
					while (!feof($handle)) {
						$string .= @fread($handle, 40960);
					}
					$string = explode ("\n", $string);
					$string = array_pop ($string);
					if(true == $enableStreamTimeOut) {
						$info = stream_get_meta_data($handle);
						if($info['timed_out']) {
							echo "Connection timed out";
						}						
					} else {
						echo "unable to set timeout";				
					}
					fclose($handle);
				} else {
					//TODO: Hide during normal operation as server may become unavailable from time to time
					echo "Unable to connect to ad server<br />\n";
					echo "$errstr ($errno)<br />\n";					
				}
			} else {
				$string = file_get_contents($url);
			}
			
			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());
	}
	
	//PHP 4.2.x Compatibility function
	if (!function_exists('file_get_contents')) {
		function file_get_contents($filename, $incpath = false, $resource_context = null)
		{
			if (false === $fh = fopen($filename, 'rb', $incpath)) {
				trigger_error('file_get_contents() failed to open stream: No such file or directory', E_USER_WARNING);
				return false;
			}

			clearstatcache();
			if ($fsize = @filesize($filename)) {
				$data = fread($fh, $fsize);
			} else {
				$data = '';
				while (!feof($fh)) {
					$data .= fread($fh, 8192);
				}
			}

			fclose($fh);
			return $data;
		}
	}

	//if (!isset($_SERVER)) $_SERVER = $HTTP_SERVER_VARS;
	if (!isset($_SERVER) && isset($HTTP_SERVER_VARS)) {
		$_SERVER  = &$HTTP_SERVER_VARS;
	}

	for ($i = 0; $i <= 11; $i++) {
		$path = substr ('../../../../../../../../../../', 0, $i * 3);
		if (file_exists ($path . $ad_file)) {
			$ad_file = $path . $ad_file;
			break;
		}
	}
	
	$server_remote_addr = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : "";
	if(strlen(trim($server_remote_addr)) <= 0) {
		$ad_network = '$_SERVER[\'REMOTE_ADDR\']: ' . $server_remote_addr . 'is unavailable.';
	} else if(false == file_exists($ad_file)) {
		$ad_network = 'Unable to locate the file:' . $ad_file;
	} else if(false == is_writable($ad_file)) {
		$ad_network = 'Unable to write to the file: ' . $ad_file;		
	} else {
		$ad_network = array();
		$ads = file_get_contents_an ($ad_file);
		$ads = explode ('<ad_break>', $ads);
		$ads_temp = explode ('|', $ads[0]);
		
		$NUM_ADS = count($ads);
		$MAX_ADS = $ads_temp[4];
		$LAST_UPDATE = $ads_temp[0];
		$MIN_UPDATE = $ads_temp[6];
		$MAX_UPDATE = $ads_temp[5];
		$CUR_TIME = time();
		#4/24/2007 8:12:52 AM|216.9.35.51|us82jsdd|1000|1800|5|1|MSIE-Firefox-Safari-Netscape-Opera
		#1177716953|36|216.9.35.51|us82jsdd|1000|1800|5|1|MSIE-Firefox-Safari-Netscape-Opera
		#echo $NUM_ADS . ' | ' . $MAX_ADS .' | '.$LAST_UPDATE.' | '.$MAX_UPDATE.' | '.$CUR_TIME;

		$would_block = false;
		$file = fopen($ad_file, 'r+');
		if (flock ($file, LOCK_EX|LOCK_NB, $would_block) && !$would_block) {
			#IF ((NUM_AADS < MAX_ADS+1) AND ((TIMESTAMP+MINIMUM_UPDATE) < CurrentTime)) || 
			if ((count ($ads) < $ads_temp[4] + 1 && $ads_temp[0] + $ads_temp[6] < time()) || $ads_temp[0] + $ads_temp[5] < time()) {
				$new_ad = file_get_contents_an ('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_temp[2] . '|' . $ads_param[0]);
				} else {
					$ads_param = array_slice ($ads_temp, 3, 6);
				}
				$ads_temp[1] = (integer)$ads_temp[1] + 1;
				if ($ads_temp[1] > $ads_temp[4]) $ads_temp[1] = 1;
				$ads[0] = time() . '|' . $ads_temp[1] . '|' . gethostbyname('validate.digitalpoint.com') . '|' . implode ('|', $ads_param);
				
				if ($new_ad) {
					$ads[$ads_temp[1]] = $new_ad;
					if (count ($ads) > $ads_temp[4] + 1) $ads = array_merge ((array)$ads[0], (array)array_slice ($ads, -$ads_temp[4]));
				}
				fwrite ($file, implode ('<ad_break>', $ads));
				ftruncate ($file, ftell($file));
			}
			flock ($file, LOCK_UN);
			fclose ($file);
		}
		$ads_x = 0;
		
		$server_path_info = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : "";
		$hexdecval = hexdec(substr(md5($_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'] . $server_path_info . $_SERVER['QUERY_STRING']), 0, 6));
		
		while (count ($ad_network) < 5) {
			if (count($ad_network) % 2 == 0) {
				$_var = (count($ads) - 1 - $ads_x);
				if($_var == 0) {$_var = 1;}
				$ads_next = ($hexdecval % $_var) + 1;
				$ads_x++;
			} else {
				$ads_next = mt_rand(1,count($ads) - 1);
			}
			$ad_network[] = $ads[$ads_next];
		}
		
		//Added to prevent SERVER_ADDR is undefined
		$ServerAddress = "";
		if(isset($_SERVER['SERVER_ADDR'])) {
			$ServerAddress = $_SERVER['SERVER_ADDR'];
		} else if(isset($_SERVER['LOCAL_ADDR'])) {
			$ServerAddress = $_SERVER['LOCAL_ADDR'];
		}
		
		$ads_output = $ads_temp[2] == $server_remote_addr || $ServerAddress == $server_remote_addr;
		$strValClass = "";
		if($ads_output) {
			$strValClass = "\" class=\"" . $ads_temp[3] . "\">";
		} else if (strlen(trim($ad_class)) > 0) {
			$strValClass = "\" class=\"" . $ad_class . "\">";
		} else {
			$strValClass = "\">";
		}
		
		if (strlen(trim($ad_target)) > 0) {
			$strValClass = "\" target=\"" . $ad_target . $strValClass;
		}
		if (($ad_options & 2) == 2) {
			$strValClass = "\" rel=\"nofollow" . $strValClass;
		}
		
		foreach ($ad_network as $key => $ad) {
			$split = explode ('<id>', $ad);
			$ad_ids[] = $split[1];
			$ad = $split[0];
			
			$ad_network[$key] = str_replace ('" />', $strValClass, $ad);
		}
		$ad_network = implode ($ad_separator, $ad_network);
		$server_https = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : false;
		if ($ads_temp[7] && ($ads_output || preg_match('#(' . str_replace ('-', '|', $ads_temp[8]) . ')#si', $_SERVER['HTTP_USER_AGENT'])) && !$server_https) $ad_network .= ' <img alt="" src="http://ads.digitalpoint.com/t-' . implode ('-', $ad_ids) . '.gif" width="1" height="1" />';
	
	}
	
	if (($ad_options & 1) == 1) {
		echo "<!-- REMOTE_ADDR:" . $server_remote_addr . " -->";
	}
	
	if (substr (@$_SERVER['DOCUMENT_NAME'], -6) == '.shtml') {
		ini_set ('zlib.output_compression', 0);
		echo $ad_network;
	}
?>

The text file that it's referring to is just full of standard html of text links. No php in there or sql calls or anything.

Any ideas? Anything I can provide you to make this more obvious. Once I get this sorted out and I figure out how to get your shoutbox in my header, I'm going Pro if that's any incentive to help me ;)
 
I can't detect any variable conflicts or anything like that, so I really don't know why it isn't showing.

As for your other issue, here's my settings and they're working fine for me:
vbshout.webp

With {vb:raw vbshout} added to the top of the navbar template.
 
With {vb:raw vbshout} added to the top of the navbar template.

Got that to work. placed it in better spot in navbar. Still not luck in the header template to be the top ribbon of my site.

But as for the bug issue of this thread, even if I don't have the shoutbox displayed. Just checking the ACTIVE box to YES kills the advertiser.
 
It's not a bug in vBShout though. It's most likely because the advertiser is using a highly unorthodox method of displaying its code, something that's not compatible with standard vBulletin addons.

Save for rewriting the entire advertiser there's nothing I can do unfortunately :(
 
Ya. Not really asking for that. Was just hoping you'd see a common tag or call-out that looked "familiar" to you that I could go through the advertisers code and change it's name throughout or something.

Appreciate the help. Hopefully the advertiser has experienced this before and has an alternate pack of code I could use. Really want to use this shout. Such an improvement since the last time I had it on MTW a year or so ago. Well done.
 
Status
Not open for further replies.

Legacy vBShout

vBulletin 3.8.x vBulletin 4.x.x
Seller
DragonByte Technologies
Release date
Last update
Total downloads
3,177
Customer rating
5.00 star(s) 1 ratings
Back
Top