vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   phpAdsNew Banner Ads integration (advertisements, classified ads, Adsense, etc.) (https://vborg.vbsupport.ru/showthread.php?t=100229)

stardotstar 06-06-2009 11:04 AM

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.

bertwrld 06-06-2009 02:54 PM

Thanks for taking the time to try and get this working.

bertwrld 06-13-2009 03:17 PM

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

stardotstar 06-14-2009 04:12 AM

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

stardotstar 06-15-2009 02:27 AM

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
http://www.sourcepoint.com.au/outlin...d_function.png

http://www.sourcepoint.com.au/outlin...d_function.png
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

speedway 06-23-2009 07:17 AM

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

Cheers
Bruce

Dennis B 06-23-2009 04:41 PM

Quote:

Originally Posted by stardotstar (Post 1814002)
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...

stardotstar 06-24-2009 03:37 AM

It's this Add-on with a modification (one only) to the plugin that delivers the ad.

Dennis B 06-24-2009 12:49 PM

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...

stardotstar 06-26-2009 07:48 AM

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.


All times are GMT. The time now is 01:51 PM.

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.04192 seconds
  • Memory Usage 1,798KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (8)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (2)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete