Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.5 > vBulletin 3.5 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
phpAdsNew Banner Ads integration (advertisements, classified ads, Adsense, etc.) Details »»
phpAdsNew Banner Ads integration (advertisements, classified ads, Adsense, etc.)
Version: 1.0.4, by The M.I.P. The M.I.P. is offline
Developer Last Online: Nov 2023 Show Printable Version Email this Page

Version: 3.5.x Rating:
Released: 11-05-2005 Last Update: 10-11-2006 Installs: 571
Uses Plugins
 
No support by the author.

OpenAds / phpAdsNew Integration 1.0.4 for vBulletin 3.[56].x
2006-06-08 by mip

Integrates the OpenAds / phpAdsNew ads system by introducing a new template tag <ad ... />.
You can even deliver your Adsense stuff via phpAdsNew using HTML banners.

The features of phpAdsNew combined with the power of vBulletin's templating system gives you the possibility to place ads for specific user groups, forums, and keywords.

PREREQUISITES:
This plugin requires a working installation (local or remote) of a recent version ofOpenAds / phpAdsNew (free software released under the GPL).
When using OpenAds, replace phpAdsNew in this documentation with OpenAds (phpAdsNew is just the predecessor of OpenAds).

INSTALLATION:
When having a previous version of this product installed, see section UPGRADE instead.

Install product "phpadsnew-1.0.4.xml".
Set phpAdsNew path in Server Settings and Optimization Options to point to either your local phpAdsNew installation or a remote server (using XML-RPC).
It is strongly recommended to set $phpAds_config['compatibility_mode'] = true; in phpAdsNew config file, to prevent problems when phpAdsNew uses a database different from the one used by your vBulletin board.

When using XML-RPC, make sure to have lib-xmlrpc-class.inc.php and lib-xmlrpc.inc.php copied from phpAdsNew misc/samples/xmlrpc/php/ to your forum's includes/ directory (not necessary when using a local phpAdsNew installation).

Read the NOTES section below.

Click INSTALL in this thread to mark product as "installed" and receive notifications when a new version comes out.

UPGRADE:
  • 1.0.3 --> 1.0.4
    1. Import product as usual, with "Allow Overwrite" set to Yes.
  • 1.0.2 --> 1.0.3
    Upgrading is recommended, as this is a bugfix release.
    1. Import product as usual, with "Allow Overwrite" set to Yes.
    2. Recompile any templates where you experienced problems with the <ad .../> tag (notably those where this tag is used repeatedly on a line).
  • 1.0.1 --> 1.0.2
    1. Import product as usual, with "Allow Overwrite" set to Yes.
    2. Set $phpAds_config['compatibility_mode'] = true; in phpAdsNew config file.
  • 1.0 --> 1.0.1
    There's basically no need to upgrade, as the changes don't affect a working installation, but I recommend to do so, to ease possible upgrades in the future.
    1. Import product as usual, with "Allow Overwrite" set to Yes.
    2. Alter the path to phpAdsNew in vBulletin Server Settings and Optimization Options to point to your phpAdsNew installation.
      As opposed to version 1.0 of this product, a local path is not relative to the DOCUMENT_ROOT.

USAGE:
Use the newly introduced <ad ... /> tag in your templates.
The syntax is similar to phpAdsNew's view_raw() function call - the tag understands what, clientid, target, source, and withtext as arguments.

Please make yourself familiar with phpAdsNew prior to using this product. You can't expect this product to work, if you didn't check if your phpAdsNew is delivering your banners cleanly.

Examples:
  • Get banner using keywords:
    <ad what="foo|bar" />
  • Get banner for guest usergroup (in this case, "ug1" must be set as a keyword in phpADsNew, see 2nd screenshot):
    <ad what="ug$bbuserinfo['usergroupid']" />
    (same technique can be applied to deliver forum-specific ads)
  • Similar invocation using template conditionals:
    <if condition="$bbuserinfo['usergroupid']==1"><ad what="" /></if>

NOTES:
  1. Always use the latest stable version of phpAdsNew.
    Old versions had bugs and some even had severe security issues - I'll give no support for installations with an outdated phpAdsNew.
    At the time of writing, latest version is 2.0.8.
  2. Templates which make use of the ad-tag might need to get recompiled after product change.
  3. Recommendations for heavy-duty servers: Move the plugin code to files; try to avoid using xml-rpc or cache xml-rpc requests (e.g. with memcache).
  4. Have an eye on current phpAdsNew security issues
  5. This product comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.
  6. Support is provided at will.
    Don't expect help if you haven't read instructions or phpAdsNew manual, if you're using non-standard vBulletin software or if your problem descriptions are useless.

PS:
This plugin is donationware - it helps you to make some money, so please be fair and honor my work with an adequate pecuniary donation.
Donate via Paypal

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #572  
Old 06-06-2009, 11:04 AM
stardotstar stardotstar is offline
 
Join Date: May 2008
Location: SYD, AU
Posts: 156
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have a fresh vB3.8.2 with no other mods but this and two themes, one implements the <ad/> tag and another doesn't. The board is natively set to UTC+10 and I have added the time zone to the time stamps when viewing the only post on the board in each style it can be seen that when the ads are on the time stamp is UTC and when off reverts to board time. Board time is correctly reported at the bottom of the main page for the user in either case.
I continue to drill down on this.

I am certain it has something to do with the local mode bug in openX but this still shouldn't throw vB - there must be some way of protecting the local variables in vB so that they are not zapped with the call out to openX by a simple plugin.

By the By, something to be aware of is that if you use the disable hooks in config.php to check your board functionality with the way that this plugin works the <ad/> tags break the templates calling for view_ad which (with hooks disabled) is an undefined function - yielding thus a fatal error.

Code:
Fatal error: Call to undefined function view_ad() in /var/www/archq/forums/global.php(614) : eval()'d code on line 1
This applies to disabling the plugin/hook system via the ACP or as below in config.php:
Code:
define('DISABLE_HOOKS', true);
this should be worked around with this mod but that is a secondary concern! Just be aware of it if using since it is sometimes necessary to disable the plugin system that way when problems are being worked on with vB.com folks.
Reply With Quote
  #573  
Old 06-06-2009, 02:54 PM
bertwrld bertwrld is offline
 
Join Date: Nov 2006
Location: Outside of Detroit
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for taking the time to try and get this working.
Reply With Quote
  #574  
Old 06-13-2009, 03:17 PM
bertwrld bertwrld is offline
 
Join Date: Nov 2006
Location: Outside of Detroit
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well, i finally decided to just install a older version of openads.

It works fine with this plugin and does the trick for me.

IF the time problems get fixed, then i might try to upgrade to the new openads
Reply With Quote
  #575  
Old 06-14-2009, 04:12 AM
stardotstar stardotstar is offline
 
Join Date: May 2008
Location: SYD, AU
Posts: 156
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That is good news as a fall back - I have set my board to time display detailed so they get a relative take on the time stamp - but it is far from a workable solution. I have too much running on openX and am going to pursue this to the bitter end

Cheers,
Will
Reply With Quote
  #576  
Old 06-15-2009, 02: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
  #577  
Old 06-23-2009, 07:17 AM
speedway's Avatar
speedway speedway is offline
 
Join Date: Nov 2001
Location: Sydney, Australia
Posts: 87
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Fantastic Will, will try this now, have had to stay on 2.4.3 due to the ad tag bug.

Cheers
Bruce
Reply With Quote
  #578  
Old 06-23-2009, 04:41 PM
Dennis B's Avatar
Dennis B Dennis B is offline
 
Join Date: Jul 2002
Posts: 193
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by stardotstar View Post
I have localmode calls working well (very fast page loads)
Are you using LWillmann's solution or something else? I have quite a few ads running with javascript and it's eating up my servers' resources...
Reply With Quote
  #579  
Old 06-24-2009, 03:37 AM
stardotstar stardotstar is offline
 
Join Date: May 2008
Location: SYD, AU
Posts: 156
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's this Add-on with a modification (one only) to the plugin that delivers the ad.
Reply With Quote
  #580  
Old 06-24-2009, 12:49 PM
Dennis B's Avatar
Dennis B Dennis B is offline
 
Join Date: Jul 2002
Posts: 193
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the answer. Is the modification related to the ability to use local calls or not? I really wanted to get rid of the javascript...
Reply With Quote
  #581  
Old 06-26-2009, 07:48 AM
stardotstar stardotstar is offline
 
Join Date: May 2008
Location: SYD, AU
Posts: 156
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This mod invokes the ads via local mode or xml-rpc calls by defining a template tag <ad />.

The javascript invocation method is not implemented using the <ad /> tag to callout phpAdsNew [openX].

If I understand you correctly, you are using javascript invocation calls generated by the zone defined in phpAdsNew [openX]?

This method is slow and very inefficient compared to local mode therefore I tried this mod in order to improve performance but immediately ran into the problem of it no longer being supported for vB3.8.x or openX (as such).

Having a server with vB3.8.3 and openX 2.8 on the same localhost I thought I'd give this mod a go and see if it works. It does, but with the caveat that as soon as you invoke an ad using the <ad /> tag all timestamps on the board are reverted to UTC (whatever the server config or userCP setting) but the board time remains correct and displays correctly (timezone and all) at the bottom of the pages.

The reason for this is that when making local mode calls to openX 2.8 the timezone is not correctly handled - as reported in this bug.

Several workarounds are suggested and I found that ultimately defining the openX timezone prior to making the callout (with the localhost local timezone - nothing to do with a user's preference setting offset) fixed the problemo.

So that, in a nutshell, is it.

I have not experimented with xml-rpc but since this mod provides it as an alternative call I suspect it works as expected.

You can therefore do away with javascript invocation by implementing this mod with the single plugin modification I posted above.
HTH
Cheers,
\\'

I suppose that this mod could be relaunched as OpenX Banner Ads Integration and stated as compatible with vB 3.8 and OpenX2.8 - much more testing would have to be done though and the local system timezone would have to be implemented as opposed to hardwiring it in the plugin.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:48 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05389 seconds
  • Memory Usage 2,336KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (8)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (2)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete