Bugfix for handling of Flash content in OpenX

Advertising server software OpenX is reasonably user friendly to work with, but also quite insecure and buggy. One of the bugs I came across was that it misidentified Flash banners compiled with Flash version 11.4 as requiring Flash Player 17 (which doesn't exist). Since OpenX checks the version of the Flash plugin against its perceived minimum requirements, this meant that a few ads simply wouldn't display. Here's the fix to the OpenX code.

OpenX / Flash bug

The problem lies in OpenX misinterpreting the version field in the SWF file. Up to and including version 10.1 of the Flash compiler, the 4th byte of the compiled SWF file would be the major version of the compiler. Version 10.2, however, uses the value 0x0B (decimal: 11) and subsequent minor versions have also increased the byte value. OpenX fails to take this into account.

Find the following function in www/admin/lib-swf.inc.php (relative to your OpenX base install directory):

<?php
function phpAds_SWFVersion($buffer)
{
    if (
substr($buffer03) == swf_tag_identify ||
        
substr($buffer03) == swf_tag_compressed)
        return 
ord(substr($buffer31));
    else
        return 
false;
}
?>

And change that to:

<?php
function phpAds_SWFVersion($buffer)
{
    if (
substr($buffer03) == swf_tag_identify ||
        
substr($buffer03) == swf_tag_compressed)
    {
        
$rv ord(substr($buffer31));
        if (
$rv 10 && $rv 13$rv 10;
        elseif (
$rv >= 13 && $rv 23$rv 11;
        elseif (
$rv >= 23$rv -= 11;
        return 
$rv;
    } else
        return 
false;
}
?>

That should handle SWF files built by Flash compiler versions 10.2 and later, at least up to 11.5 12.0 (the current version of Flash, at the time of writing), but may need updating when Flash 12 13 is released (if that unfortunate event ever occurs). It doesn't differentiate between minor versions, as the OpenX table structure doesn't allow for that. But then, anybody who has an older version of the Flash plugin should have their internet browsing license revoked immediately anyway.

Update (2014-03-03): updated the code to correctly identify content for Flash Player 12, according to values in the Flash Player and Air Feature List.

Update (2015-12-30): updated the code to correctly identify content for Flash Player versions 13 and later.

Tags:

Comments

Andrew

It works! Thanks! You should do commit to openx repository.

Thomas

Thank you so much for this!!

Jens

Thank you! Saved our day!

Dan Foley

I hope you don't mind, but i have submit this as a critical bug in openx. So that it will get officially fixed.

yannux

Thanks a lot ! :)

Mauro

Graciela.

You save our day!

Claudiu

You're a lifesaver, thanks a looott !

TeMS

This fixed the ads not showing up...

But looks like the destination url still does not work.
Banner are not clickable anymore.

Alexander

This fix helps us too, Thanks !!!

Marc

Awesome!

Because of you it took me only 2 minutes to get rid of that bug.

Thanks a lot!

giannino

Thank you!
that fixed perfectly!

Joel Eckman

Life-saver stuff right there. Thank you.

Post a comment