flash integration problem in main header (using OpenX delivery)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stardotstar
    Member
    • Feb 2007
    • 83

    flash integration problem in main header (using OpenX delivery)

    Hi guys,

    the problems associated with swf and flash delivery seem to be numerous and I have been searching and asking on vb.org and at openx for some time to no avail.

    I thought I might beg your indulgence and try to get my head around the problem by coming back to the source so to speak.

    I will make every effort to clearly describe my approach and avoid any unnecessary conflict between the openx offering and vB supported/unsupported contexts.

    For reference I have been pursuing a solution in these threads:




    The problem is simple:
    1) I have modified some code that uses openx's localmode to invoke an advertising campaign, delivering a banner to the header thus:
    Template: ad_header_logo
    Code:
    <td align="$stylevar[center]"><ad what="zone:1" /></td>
    The ad tag is what calls the banner in:
    Ad tag callback in template_compile
    Code:
    if (!function_exists('_tag_callback'))
    {
        /**
        * Callback-function for process_template_tag() which "parses" arguments and returns PHP code for eval
        *
        * @param    string    Options/arguments of tag
        * @param    string    Name of function to call
        * @param    array    Associative array of argument names and default values
        *
        * @return    string
        */
        function _tag_callback($options, $functionhandle, $arglist)
        {
            $options = stripslashes($options);
            trim($options);
            trim($functionhandle);
    
            if (!function_exists('replace_template_variables'))
            {
                require_once(DIR . '/includes/functions_misc.php');
            }
    
            $param = array();
            if (is_array($arglist))
            {
                reset($arglist);
                foreach ($arglist AS $key => $val)
                {
                    if (preg_match('#'.$key.'=([\\\]["\'])(.*?)\1#', $options, $matches))
                    {
                        $param[] = $matches[2];
                    }
                    else
                    {
                        // default argument
                        $param[] = $val;
                    }
                }
            }
            
            foreach ($param AS $argument)
            {
                if ($return == '')
                {
                    $return = '" . ' . $functionhandle . '(';
                }
                else
                {
                    $return .= ', ';
                }
                // Surround variables with {} - not failsafe, but should do the job in most cases 
                $argument = preg_replace('#\$([a-z0-9_>-]+)((\[\'.*?\'\])+)#i', '{$\\1\\2}', $argument);
                // {{$foo}} --> {$foo}
                $argument = preg_replace('#(\{+)\$(.*?)(\}+)#i', '{$\\2}', $argument);
    
                // Replace legacy variable names in templates with their modern equivalents
                $argument = replace_template_variables($argument, true);
    
                $return .= '"' . $argument . '"';
            }
            $return .= ') . "';
            return $return;
        }
    }
    
    if (!function_exists('process_template_tag'))
    {
        /**
        * Processes user-defined tags <tagname [argument="foo" ...]/> into myfunction() PHP code for eval
        *
        * @param    string    Title of tag
        * @param    string    Un-parsed template HTML
        * @param    string    Name of function to call
        * @param    array    Associative array of argument names and default values, order must be the same as for the function specified previously
        *
        * @return    string
        */
        function process_template_tag($tagname, $text, $functionhandle='', $arglist)
        {
            if ($functionhandle == '')
            {
                // No function specified - remove tag
                return preg_replace("#<{$tagname}\s?/?>|<{$tagname}\s.*?/?>#si", '', $text);
            }
            else
            {
                return preg_replace("#<({$tagname})(\s+(.*?)/?)>#sie", "_tag_callback('\\3', \$functionhandle, \$arglist)", $text);
            }
        }
    }
    
    $template = process_template_tag('ad', $template, 'view_ad', array('what' => '', 'clientid' => 0, 'target' => '', 'source' => '', 'withtext' => 0)  );
    This combines with the view ad function in init_startup
    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('Australia/Sydney');    
                    return "<!-- BEGIN ad {$adcomment} -->{$ad['html']}<!-- END ad {$adid} -->";
                }
            }
        }
    }
    to pull the desired ad.

    So... Why is it that the localmode invocation that gets generated when an swf banner is delivered does not display?
    The very same invocation code when placed in its own php script delivers and displays correctly - this link illustrates the following code:


    PHP Code:
    <?php
      define
    ('MAX_PATH''/var/www/sourcepoint/htdocs/openx');
      if (@include_once(
    MAX_PATH '/www/delivery/alocal.php')) {
        if (!isset(
    $phpAds_context)) {
          
    $phpAds_context = array();
        }
        
    // function view_local($what, $zoneid=0, $campaignid=0, $bannerid=0, $target='', $source='', $withtext='', $context='', $charset='')
        
    $phpAds_raw view_local(''10266'''''0'$phpAds_context'');
      }
      echo 
    $phpAds_raw['html'];
    ?>
    Can anyone see what I need to do to make the ad call back and view plugins overcome the limitation that exists as they are implemented in the vB ad header context. gif and jpg etc all work perfectly - only swf fail and fall back to the static content.
    There must be a fundamental wrapper or declaration statement/condition that I need to add to allow swf to be embedded properly.

    I would very much appreciate any help with this since I have been searching and researching in vain for some time. I am sure it is something rather trivial that I am missing - when I get it sorted I will write up the process at vb.org so others can benefit.

    Please understand that I know this is not core support for vB and I have tried at .org to no avail, openx point to vb since the code works in its own script. given that there are so many questions around flash in headers I thought I might ask. I understand if you won't address the issue however since this is out of scope.

    Will
  • Jake Bunce
    Senior Member
    • Dec 2000
    • 46598
    • 3.6.x

    #2
    You should post on www.vbulletin.org for help with this. They deal with custom code over there. We can't officially support modifications like this.

    Comment

    • stardotstar
      Member
      • Feb 2007
      • 83

      #3
      OK Jake,

      much as I suspected.

      I had seen some helpful guidance on other flash questions here when I searched and having had no reply at all on .org on two occasions I am looking at all sorts of alternative sources of guidance.

      Thanks for the reply and again, I understand and appreciate your official position.

      Will

      Comment

      Related Topics

      Collapse

      Working...