View Single Post
  #576  
Old 06-15-2009, 01:27 AM
stardotstar stardotstar is offline
 
Join Date: May 2008
Location: SYD, AU
Posts: 156
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK.... Drum roll:

The fix is almost absurdly simple.

You have to specify the openads timezone variable before making the callout.

I can only confirm this for vB3.8.3, phpAdsNew Banner Ads Integration 1.0.4, openX 2.8 and php5 so please don't go jumping into your plugins and stuffing up boards without backups and copying and pasting the original code to a text editor.

The line needed is the spec of the local server timezone for your host:
Code:
OA_setTimeZone('Australia/Sydney');
in my case.

To fix this problem with Local Mode (not xml-rpc) method calls to openX 2.8 you need edit the plugin:
view ad function



Select all in the plugin code box and replace with this:

Code:
if (!function_exists('view_ad'))
{
	/**
	* Calls view_raw function from phpAdsNew either locally or via xml-rpc to get HTML advertisement code, see phpAdsNew for infos.
	*
	* @param	string	Zone name (zone:x) or keywords (keyword1|keyword2|...)
	* @param	integer	Client-ID
	* @param	string	Target
	* @param	string	Source
	* @param	integer	Withtext
	*
	* @return	string
	*/
	function view_ad($what, $clientid = 0, $target = '', $source = '', $withtext = 0)
	{
		global $vbulletin;
		static $panpath;
		
		if (!$panpath)
		{
			trim($vbulletin->options['panpath']);
			$panpath = @parse_url($vbulletin->options['panpath']);
		}
		
		// Calculate an identifier for the requested ad - this could be used to cache banners retrieved via xmlrpc in future versions
		$adid = sprintf('%u', crc32($what . $clientid . $target . $source . $withtext));
		
		if ($vbulletion->options['addtemplatename'] or $vbulletin->config['Misc']['debug'])
		{
			// Be verbose
			$adcomment = 'id="' . $adid . '" what="' . htmlspecialchars($what) . '" clientid="' . htmlspecialchars($clientid)
					. '" target="' . htmlspecialchars($target) . '" source="' . htmlspecialchars($source)
					. '" withtext="' . htmlspecialchars($withtext) . '"';
		}
		else
		{
			$adcomment = $adid;
		}
		
		if ($vbulletin->options['panpath'] == '')
		{
			// Path to phpAdsNew is empty - disable ads
			return "<!-- ad {$adcomment} / -->";
		}
		elseif (strtolower($panpath['scheme']) == 'http')
		{
			// get banner from phpAdsNew via xml-rpc
			/*
			//	ATTN:
			//	In phpAdsNew 2.0.6 (and maybe earlier versions) is a tiny bug which prevents xml-rpc from working cleanly.
			//	
			//	Patch:
			//	--- phpAdsNew/misc/samples/xmlrpc/php/lib-xmlrpc.inc.php.orig	Tue Aug 16 10:51:26 2005
			//	+++ phpAdsNew/misc/samples/xmlrpc/php/lib-xmlrpc.inc.php	Thu Oct 27 17:12:26 2005
			//	@@ -76,6 +76,7 @@
			//			global $xmlrpcStruct;
			//	 
			//			global $xmlrpcTypes;
			//	+		global $xmlrpc_valid_parents;
			//			global $xmlEntities;
			//			global $xmlrpcerr;
			//			global $xmlrpcstr;
			//			
			//	See https://sourceforge.net/tracker/?func=detail&atid=111386&aid=1339623&group_id=11386 for details.
			*/
	
			global $xmlrpcbanner, $phpAds_remoteInfo;
			require_once(DIR . '/includes/lib-xmlrpc-class.inc.php');  // see misc/samples/xmlrpc/php/ directory of your phpAdsNew installation
	
			if (!$xmlrpcbanner)
			{
				$xmlrpcbanner = new phpAds_XmlRpc($panpath['host'], $panpath['path'], (intval($panpath['port']) > 0 ? $panpath['port'] : 80));
			}
	
			$ad = $xmlrpcbanner->view_raw($what, $clientid, $target, $source, $withtext);
	
			return "<!-- BEGIN ad {$adcomment} -->{$ad['html']}<!-- END ad {$adid} -->";
		}
		else
		{
			// get banner via direct invocation of phpAdsNew
			// this is basically taken from the invocationcode generated by phpAdsNew - it does its own checks to prevent multiple inclusion
	
			global $phpAds_context;
			
			if (@require($vbulletin->options['panpath'] . (strstr($vbulletin->options['panpath'] , '/phpadsnew.inc.php') ? '' : '/phpadsnew.inc.php' )))
			{
				if (!isset($phpAds_context))
				{
					$phpAds_context = array();
				}
	
				$ad = view_raw($what, $clientid, $target, $source, $withtext, $phpAds_context);
				
				if ($vbulletin->options['panbandupes'])
				{
					// Remember bannerid to prevent showing banner multiple times on same page
					$phpAds_context[] = array('!=' => 'bannerid:'.$ad['bannerid']);
				}
OA_setTimeZone('TIME/ZONE');	
				return "<!-- BEGIN ad {$adcomment} -->{$ad['html']}<!-- END ad {$adid} -->";
			}
		}
	}
}
You MUST then go into the line:
Code:
OA_setTimeZone('TIME/ZONE');
and replace it with the local zone for your server...


OR


if you just want to insert the line yourself find:

Code:
$phpAds_context[] = array('!=' => 'bannerid:'.$ad['bannerid']);
				}
and place
Code:
OA_setTimeZone('TIME/ZONE');
before the next line:
Code:
return "<!-- BEGIN ad {$adcomment} -->{$ad['html']}<!-- END ad {$adid} -->";
			}
and that's it...

or at least that has fixed the issue for me.

Now I must say that I am not sure of what effect this might have on the openX server if it is not in the timezone that the main boards are - this could conceivable cause problems associated with skew of the statistics or other database date and time records within openX.

If I notice anything like this I will report here.

Cheers,
Will
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01785 seconds
  • Memory Usage 1,790KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete