function OA_SPCGetJavaScript($affiliateid)
{
    $aConf = $GLOBALS['_MAX']['CONF'];
    $varprefix = $aConf['var']['prefix'];
    $aZones = OA_cacheGetPublisherZones($affiliateid);
    foreach ($aZones as $zoneid => $aZone) {
        $zones[$aZone['type']][] = "            '" . addslashes($aZone['name']) . "' : {$zoneid}";
    }
    $additionalParams = '';
    $magic_quotes_gpc = ini_get('magic_quotes_gpc');
    foreach ($_GET as $key => $value) {
        if ($key == 'id') {
            continue;
        }
        if ($magic_quotes_gpc) {
            $value = stripslashes($value);
        }
        $additionalParams .= htmlspecialchars('&' . urlencode($key) . '=' . urlencode($value), ENT_QUOTES);
    }
    $script = "\n    if (typeof({$varprefix}zones) != 'undefined') {\n        var {$varprefix}zoneids = '';\n        for (var zonename in {$varprefix}zones) {$varprefix}zoneids += escape(zonename+'=' + {$varprefix}zones[zonename] + \"|\");\n        {$varprefix}zoneids += '&amp;nz=1';\n    } else {\n        var {$varprefix}zoneids = escape('" . implode('|', array_keys($aZones)) . "');\n    }\n\n    if (typeof({$varprefix}source) == 'undefined') { {$varprefix}source = ''; }\n    var {$varprefix}p=location.protocol=='https:'?'" . MAX_commonConstructSecureDeliveryUrl($aConf['file']['singlepagecall'], true) . "':'" . MAX_commonConstructDeliveryUrl($aConf['file']['singlepagecall']) . "';\n    var {$varprefix}r=Math.floor(Math.random()*99999999);\n    {$varprefix}output = new Array();\n\n    var {$varprefix}spc=\"<\"+\"script type='text/javascript' \";\n    {$varprefix}spc+=\"src='\"+{$varprefix}p+\"?zones=\"+{$varprefix}zoneids;\n    {$varprefix}spc+=\"&amp;source=\"+escape({$varprefix}source)+\"&amp;r=\"+{$varprefix}r;" . (!empty($additionalParams) ? "\n    {$varprefix}spc+=\"{$additionalParams}\";" : '') . "\n    ";
    if (empty($_GET['charset'])) {
        $script .= "{$varprefix}spc+=(document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));\n";
    }
    $script .= "\n    if (window.location) {$varprefix}spc+=\"&amp;loc=\"+escape(window.location);\n    if (document.referrer) {$varprefix}spc+=\"&amp;referer=\"+escape(document.referrer);\n    {$varprefix}spc+=\"'><\"+\"/script>\";\n    document.write({$varprefix}spc);\n\n    function {$varprefix}show(name) {\n        if (typeof({$varprefix}output[name]) == 'undefined') {\n            return;\n        } else {\n            document.write({$varprefix}output[name]);\n        }\n    }\n\n    function {$varprefix}showpop(name) {\n        zones = window.{$varprefix}zones ? window.{$varprefix}zones : false;\n        var zoneid = name;\n        if (typeof(window.{$varprefix}zones) != 'undefined') {\n            if (typeof(zones[name]) == 'undefined') {\n                return;\n            }\n            zoneid = zones[name];\n        }\n\n        {$varprefix}p=location.protocol=='https:'?'" . MAX_commonConstructSecureDeliveryUrl($aConf['file']['popup'], true) . "':'" . MAX_commonConstructDeliveryUrl($aConf['file']['popup']) . "';\n\n        var {$varprefix}pop=\"<\"+\"script type='text/javascript' \";\n        {$varprefix}pop+=\"src='\"+{$varprefix}p+\"?zoneid=\"+zoneid;\n        {$varprefix}pop+=\"&amp;source=\"+escape({$varprefix}source)+\"&amp;r=\"+{$varprefix}r;" . (!empty($additionalParams) ? "\n        {$varprefix}spc+=\"{$additionalParams}\";" : '') . "\n        if (window.location) {$varprefix}pop+=\"&amp;loc=\"+escape(window.location);\n        if (document.referrer) {$varprefix}pop+=\"&amp;referer=\"+escape(document.referrer);\n        {$varprefix}pop+=\"'><\"+\"/script>\";\n\n        document.write({$varprefix}pop);\n    }\n";
    // Add the FlashObject include to the SPC output
    $script .= MAX_javascriptToHTML(MAX_flashGetFlashObjectExternal(), $varprefix . 'fo');
    return $script;
}
 /**
  * Test1 return a URL
  * A function to generate the URL for delivery scripts.
  *
  * @param string $file The file name of the delivery script.
  * @return string The URL to the delivery script.
  */
 function test_MAX_commonConstructDeliveryUrl()
 {
     $this->sendMessage('test_MAX_commonConstructDeliveryUrl');
     $GLOBALS['_MAX']['CONF']['webpath']['delivery'] = 'www.maxstore.net/www/delivery';
     $file = 'test.html';
     $ret = MAX_commonConstructDeliveryUrl($file);
     $this->assertEqual($ret, 'http://www.maxstore.net/www/delivery/test.html');
 }
Exemple #3
0
/**
 * A function that can be used to get the delivery URL,
 * or the delivery URL prefix (sans-file) if no filname
 * is passed in.
 *
 * @param string $file Optional delivery file name.
 * @return string The delivery URL.
 */
function MAX_commonGetDeliveryUrl($file = null)
{
    $conf = $GLOBALS['_MAX']['CONF'];
    if ($GLOBALS['_MAX']['SSL_REQUEST']) {
        $url = MAX_commonConstructSecureDeliveryUrl($file);
    } else {
        $url = MAX_commonConstructDeliveryUrl($file);
    }
    return $url;
}
Exemple #4
0
/**
 * A function that can be used to get the delivery URL,
 * or the delivery URL prefix (sans-file) if no filname
 * is passed in.
 *
 * @param string $file Optional delivery file name.
 * @return string The delivery URL.
 */
function MAX_commonGetDeliveryUrl($file = null)
{
    $conf = $GLOBALS['_MAX']['CONF'];
    if (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == $conf['openads']['sslPort']) {
        $url = MAX_commonConstructSecureDeliveryUrl($file);
    } else {
        $url = MAX_commonConstructDeliveryUrl($file);
    }
    return $url;
}
Exemple #5
0
/**
 * This function sets the viewerid cookie, and does a header redirect to self
 * this lets us tell if a user allows permenant cookies to be set
 *
 * @param string $viewerId The viewerId value to attempt to set
 */
function MAX_cookieSetViewerIdAndRedirect($viewerId)
{
    $aConf = $GLOBALS['_MAX']['CONF'];
    MAX_cookieAdd($aConf['var']['viewerId'], $viewerId, _getTimeYearFromNow());
    MAX_cookieFlush();
    // Determine if the access to OpenX was made using HTTPS
    if ($GLOBALS['_MAX']['SSL_REQUEST']) {
        $url = MAX_commonConstructSecureDeliveryUrl(basename($_SERVER['SCRIPT_NAME']));
    } else {
        $url = MAX_commonConstructDeliveryUrl(basename($_SERVER['SCRIPT_NAME']));
    }
    $url .= "?{$aConf['var']['cookieTest']}=1&" . $_SERVER['QUERY_STRING'];
    MAX_header("Location: {$url}");
    ###START_STRIP_DELIVERY
    if (empty($GLOBALS['is_simulation']) && !defined('TEST_ENVIRONMENT_RUNNING')) {
        ###END_STRIP_DELIVERY
        exit;
        ###START_STRIP_DELIVERY
    }
    ###END_STRIP_DELIVERY
}
 /**
  * Return invocation code for this plugin (codetype)
  *
  * @return string
  */
 function generateInvocationCode()
 {
     $aComments = array('Cache Buster Comment' => '', 'Third Party Comment' => '', 'SSL Delivery Comment' => '', 'SSL Backup Comment' => '', 'Comment' => '');
     parent::prepareCommonInvocationData($aComments);
     $conf = $GLOBALS['_MAX']['CONF'];
     $mi =& $this->maxInvocation;
     if (!isset($mi->clientid) || $mi->clientid == '') {
         $mi->clientid = 0;
     }
     if (empty($mi->campaignid)) {
         $mi->campaignid = 0;
     }
     if ($mi->xmlrpcproto) {
         $mi->params = parse_url(MAX_commonConstructSecureDeliveryUrl($conf['file']['xmlrpc']));
     } else {
         $mi->params = parse_url(MAX_commonConstructDeliveryUrl($conf['file']['xmlrpc']));
     }
     if (!$mi->xmlrpctimeout) {
         $mi->timeout = 15;
     } else {
         $mi->timeout = $mi->xmlrpctimeout;
     }
     switch ($mi->hostlanguage) {
         case 'php':
         default:
             if (!isset($mi->what) or $mi->what == "") {
                 // Need to generate the waht variable here
                 if (isset($mi->zoneid) and $mi->zoneid != "") {
                     $mi->what = "zone:" . $mi->zoneid;
                 } elseif (isset($mi->bannerid) and $mi->bannerid != "") {
                     $mi->what = "bannerid:" . $mi->bannerid;
                 }
             }
             if (!isset($mi->campaignid)) {
                 $mi->campaignid = 0;
             }
             $buffer .= "<" . "?php\n /* " . str_replace(array("\n", '/*', '*/'), array('', '', ''), $mi->buffer);
             if (!isset($mi->comments) || $mi->comments == "1") {
                 $buffer .= "\n  *";
                 $buffer .= $this->translate("\n  * As the PHP script below tries to set cookies, it must be called\n  * before any output is sent to the user's browser. Once the script\n  * has finished running, the HTML code needed to display the ad is\n  * stored in the \$adArray array (so that multiple ads can be obtained\n  * by using mulitple tags). Once all ads have been obtained, and all\n  * cookies set, then you can send output to the user's browser, and\n  * print out the contents of \$adArray where appropriate.\n  *\n  * Example code for printing from \$adArray is at the end of the tag -\n  * you will need to remove this before using the tag in production.\n  * Remember to ensure that the PEAR::XML-RPC package is installed\n  * and available to this script, and to copy over the\n  * lib/xmlrpc/php/openads-xmlrpc.inc.php library file. You may need to\n  * alter the 'include_path' value immediately below.\n  */");
                 $buffer .= "\n\n";
             } else {
                 $buffer .= "  */\n";
             }
             $buffer .= '    //ini_set(\'include_path\', \'.:/usr/local/lib\');' . "\n";
             $buffer .= '    require \'openads-xmlrpc.inc.php\';' . "\n\n";
             $buffer .= '    if (!isset($OA_context)) $OA_context = array();' . "\n\n";
             $buffer .= '    $oaXmlRpc = new OA_XmlRpc(\'' . $mi->params['host'] . '\', \'' . $mi->params['path'] . '\'';
             if (isset($mi->params['port'])) {
                 $buffer .= ', ' . $mi->params['port'] . '';
             } else {
                 $buffer .= $mi->xmlrpcproto ? ', 443' : ', 80';
             }
             if ($mi->xmlrpcproto) {
                 $buffer .= ', true';
             } else {
                 $buffer .= ', false';
             }
             $buffer .= ', ' . $mi->timeout . ');' . "\n";
             if (!empty($mi->comments)) {
                 $buffer .= "\n    //view(\$what='', \$campaignid=0, \$target='', \$source='', \$withText=false, \$context=array(), \$charset='')\n";
             }
             $buffer .= "    \$adArray = \$oaXmlRpc->view('{$mi->what}', {$mi->campaignid}, '{$mi->target}', '{$mi->source}', {$mi->withtext}, \$OA_context, '{$mi->charset}');\n";
             if (isset($mi->block) && $mi->block == '1') {
                 $buffer .= '    $OA_context[] = array(\'!=\' => \'bannerid:\'.$adArray[\'bannerid\']);' . "\n";
             }
             if (isset($mi->blockcampaign) && $mi->blockcampaign == '1') {
                 $buffer .= '    $OA_context[] = array(\'!=\' => \'campaignid:\'.$adArray[\'campaignid\']);' . "\n";
             }
             $buffer .= "\n";
             $buffer .= '    echo $adArray[\'html\'];' . "\n";
             $buffer .= "?" . ">\n";
             break;
     }
     return $buffer;
 }
 /**
  * Return invocation code for this plugin (codetype)
  *
  * @return string
  */
 function generateInvocationCode()
 {
     $aComments = array('Third Party Comment' => $this->translate("\n  -- Don't forget to replace the 'Insert_Clicktrack_URL_Here' text with\n  -- the click tracking URL if this ad is to be delivered through a 3rd\n  -- party (non-Max) adserver.\n  --\n  -- Don't forget to replace the 'Insert_Random_Number_Here' text with\n  -- a cache-buster random number each time you deliver the tag through\n  -- a 3rd party (non-Max) adserver.\n  --"), 'Comment' => $this->translate("\n  -- This tag has been generated for use on a non-SSL page. If this tag\n  -- is to be placed on an SSL page, change all instances of\n  --   'http://%s/...'\n  -- to\n  --   'https://%s/...'\n  --", array($conf['webpath']['delivery'], $conf['webpath']['deliverySSL'])));
     parent::prepareCommonInvocationData($aComments);
     $conf = $GLOBALS['_MAX']['CONF'];
     $mi =& $this->maxInvocation;
     $buffer = $mi->buffer;
     if (isset($mi->popunder) && $mi->popunder == '1') {
         $mi->parameters['popunder'] = "popunder=1";
     }
     if (isset($mi->left) && $mi->left != '' && $mi->left != '-') {
         $mi->parameters['left'] = "left=" . $mi->left;
     }
     if (isset($mi->top) && $mi->top != '' && $mi->top != '-') {
         $mi->parameters['top'] = "top=" . $mi->top;
     }
     if (isset($mi->timeout) && $mi->timeout != '' && $mi->timeout != '-') {
         $mi->parameters['timeout'] = "timeout=" . $mi->timeout;
     }
     if (isset($mi->toolbars) && $mi->toolbars == '1') {
         $mi->parameters['toolbars'] = "toolbars=1";
     }
     if (isset($mi->location) && $mi->location == '1') {
         $mi->parameters['location'] = "location=1";
     }
     if (isset($mi->menubar) && $mi->menubar == '1') {
         $mi->parameters['menubar'] = "menubar=1";
     }
     if (isset($mi->status) && $mi->status == '1') {
         $mi->parameters['status'] = "status=1";
     }
     if (isset($mi->resizable) && $mi->resizable == '1') {
         $mi->parameters['resizable'] = "resizable=1";
     }
     if (isset($mi->scrollbars) && $mi->scrollbars == '1') {
         $mi->parameters['scrollbars'] = "scrollbars=1";
     }
     if (isset($mi->delay_type)) {
         if ($mi->delay_type == 'seconds' && isset($mi->delay) && $mi->delay != '' && $mi->delay != '-') {
             $mi->parameters['delay'] = "delay=" . $mi->delay;
         } elseif ($mi->delay_type == 'exit') {
             $mi->parameters['delay'] = "delay=exit";
         }
     }
     $buffer .= "<script type='text/javascript' src='" . MAX_commonConstructDeliveryUrl($conf['file']['popup']);
     $buffer .= "?n=" . $mi->uniqueid;
     if (sizeof($mi->parameters) > 0) {
         $buffer .= "&" . implode("&", $mi->parameters);
     }
     $buffer .= "'></script>\n";
     return $buffer;
 }
 function addIntroductionInlineHelp(&$form)
 {
     $helpString = $this->getHelpAdTypeDescription();
     $crossdomainUrl = MAX_commonConstructDeliveryUrl('crossdomain.xml');
     // because flash apps look at http://domain/crossdomain.xml, we need to construct this URL and keep only the hostname
     $crossdomainUrl = parse_url($crossdomainUrl);
     $crossdomainUrl = $crossdomainUrl['scheme'] . '://' . $crossdomainUrl['host'] . '/crossdomain.xml';
     $helpString .= "<br/><br/>To setup your " . $this->getBannerShortName() . ", you will need to:\n        <ul style='list-style-type:decimal;padding-left:20px;padding-top:5px'>\n        <li>Enter the information about your Ad in the form below.</li>\n        <li>Link this " . $this->getBannerShortName() . " to the desired zone. The zone must be of the type \"" . $this->getZoneToLinkShortName() . "\". <a href='" . VideoAdsHelper::getHelpLinkOpenXPlugin() . "' target='_blank'>Learn more</a></li>\n        <li>Include the zone in the Ad Schedule of the video player plugin configuration in your webpage. <a href='" . VideoAdsHelper::getHelpLinkVideoPlayerConfig() . "' target='_blank'>Learn more</a></li>\n        <li>Make sure that the flash player is allowed to request ads on this adserver. The <a href='{$crossdomainUrl}' target='_blank'>crossdomain.xml on your adserver</a> should look similar to the <a href='" . VideoAdsHelper::getLinkCrossdomainExample() . "' target='_blank'>recommended crossdomain.xml</a></li>\n    \t</ul>";
     $form->addElement('html', 'video_status_info1', '<span style="font-size:100%;">' . $helpString . '</span>');
 }
Exemple #9
0
 function _generateTrackerImageBeacon($trackerId)
 {
     $conf = $GLOBALS['_MAX']['CONF'];
     $variables = Admin_DA::getVariables(array('trackerid' => $trackerId), true);
     $beacon = "<div id='m3_tracker_{$trackerId}' style='position: absolute; left: 0px; top: 0px; visibility: hidden;'>";
     $beacon .= "<img src='" . MAX_commonConstructDeliveryUrl($conf['file']['conversion']) . "?trackerid={$trackerId}";
     foreach ($variables as $variable) {
         $beacon .= "&amp;{$variable['name']}=%%" . strtoupper($variable['name']) . "_VALUE%%";
     }
     $beacon .= "&amp;cb=%%RANDOM_NUMBER%%' width='0' height='0' alt='' /></div>";
     return $beacon;
 }
 /**
  * Prepare data before generating the invocation code
  *
  * @param array $aComments Array of comments allowed keys: 'Cache Buster Comment', 'Third Party Comment',
  *                                     'SSL Delivery Comment', 'SSL Backup Comment', 'Comment'
  *
  */
 function prepareCommonInvocationData($aComments)
 {
     $conf = $GLOBALS['_MAX']['CONF'];
     $mi =& $this->maxInvocation;
     // Check if affiliate is on the same server
     if (isset($mi->website) && $mi->website != '') {
         $mi->server_max = parse_url('http://' . $conf['webpath']['delivery'] . '/');
         $mi->server_affilate = parse_url($mi->website);
         $mi->server_same = @gethostbyname($mi->server_max['host']) == @gethostbyname($mi->server_affilate['host']);
     } else {
         $mi->server_same = true;
     }
     $mi->macros = array('cachebuster' => 'INSERT_RANDOM_NUMBER_HERE', 'clickurl' => 'INSERT_ENCODED_CLICKURL_HERE');
     if (!empty($mi->thirdpartytrack) && $mi->thirdpartytrack != 'generic') {
         if ($thirdpartyserver = OX_Component::factoryByComponentIdentifier($mi->thirdpartytrack)) {
             $thirdpartyname = $thirdpartyserver->getName();
             if (!empty($thirdpartyserver->clickurlMacro)) {
                 $mi->macros['clickurl'] = $thirdpartyserver->clickurlMacro;
             }
             if (!empty($thirdpartyserver->cachebusterMacro)) {
                 $mi->macros['cachebuster'] = $thirdpartyserver->cachebusterMacro;
             }
         }
     }
     $mi->parameters = array();
     $imgParams = array();
     // Setup option defaults
     $pluginOptions = new Plugins_InvocationTagsOptions();
     foreach ($pluginOptions->defaultValues as $key => $value) {
         if (!is_array($value) && (!isset($mi->{$key}) || is_null($mi->{$key}))) {
             $mi->{$key} = $mi->parameters[$key] = $value;
         }
     }
     // UniqueID is only necessary for a couple of plugins, so it is not "common"
     //$mi->uniqueid = 'a'.substr(md5(uniqid('', 1)), 0, 7);
     if (!isset($mi->withtext)) {
         $mi->withtext = 0;
     }
     // Set parameters
     if (isset($mi->clientid) && strlen($mi->clientid) && $mi->clientid != '0') {
         $mi->parameters['clientid'] = $this->options['clientid'] = $imgParams['clientid'] = "clientid=" . $mi->clientid;
     }
     if (isset($mi->zoneid) && $mi->zoneid != '') {
         $mi->parameters['zoneid'] = $this->options['zoneid'] = $imgParams['zoneid'] = "zoneid=" . urlencode($mi->zoneid);
     }
     if (isset($mi->campaignid) && strlen($mi->campaignid) && $mi->campaignid != '0') {
         $mi->parameters['campaignid'] = $this->options['campaignid'] = $imgParams['campaignid'] = "campaignid=" . $mi->campaignid;
     }
     if (isset($mi->bannerid) && $mi->bannerid != '') {
         $mi->parameters['bannerid'] = $this->options['bannerid'] = $imgParams['bannerid'] = "bannerid=" . urlencode($mi->bannerid);
     }
     if (isset($mi->what) && $mi->what != '') {
         $mi->parameters['what'] = $this->options['what'] = $imgParams['what'] = "what=" . str_replace(",+", ",_", $mi->what);
     }
     if (isset($mi->source) && $mi->source != '') {
         $mi->parameters['source'] = $this->options['source'] = $imgParams['source'] = "source=" . urlencode($mi->source);
     }
     if (isset($mi->target) && $mi->target != '') {
         $mi->parameters['target'] = $this->options['target'] = $imgParams['target'] = "target=" . urlencode($mi->target);
     }
     if (isset($mi->charset) && $mi->charset != '') {
         $mi->parameters['charset'] = $this->options['charset'] = $imgParams['charset'] = "charset=" . urlencode($mi->charset);
     }
     if (!empty($mi->cachebuster)) {
         $mi->parameters['cb'] = $this->options['cb'] = $imgParams['cb'] = "cb=" . $mi->macros['cachebuster'];
     }
     if (!empty($mi->thirdpartytrack)) {
         $mi->parameters['ct0'] = $this->options['ct0'] = $imgParams['ct0'] = "ct0=" . $mi->macros['clickurl'];
     }
     // Set $mi->buffer to the initial comment
     $name = PRODUCT_NAME;
     if (!empty($GLOBALS['_MAX']['CONF']['ui']['applicationName'])) {
         $name = $GLOBALS['_MAX']['CONF']['ui']['applicationName'];
     }
     $buffer = "<!--/*\n  *\n  * " . $name . " " . $this->getName() . "\n  * - Generated with " . PRODUCT_NAME . " v" . VERSION . "\n";
     if (!empty($thirdpartyname)) {
         $buffer .= "  * - " . $thirdpartyname . "\n";
     }
     $buffer .= "  *\n  */-->\n\n";
     if (!empty($mi->comments)) {
         $oTrans = new OX_Translation();
         $comment = '';
         if (!empty($mi->cachebuster) && ($mi->thirdpartytrack == 'generic' || $mi->thirdpartytrack === 0)) {
             if (isset($aComments['Cache Buster Comment'])) {
                 $cbComment = $aComments['Cache Buster Comment'];
             } else {
                 $cbComment = $GLOBALS['strCacheBusterComment'];
             }
             $comment .= str_replace('{random}', $mi->macros['cachebuster'], $cbComment);
         }
         if (isset($mi->thirdpartytrack) && ($mi->thirdpartytrack == 'generic' || $mi->thirdpartytrack === 0)) {
             if (isset($aComments['Third Party Comment'])) {
                 $clickurlComment = $aComments['Third Party Comment'];
             } else {
                 $clickurlComment = $GLOBALS['strThirdPartyComment'];
             }
             $clickurlComment = $aComments['Third Party Comment'];
             $comment .= str_replace('{clickurl}', $mi->macros['clickurl'], $clickurlComment);
         }
         //SSL Delivery Comment
         if (isset($aComments['SSL Delivery Comment'])) {
             $comment .= $aComments['SSL Delivery Comment'];
         } else {
             $comment .= $oTrans->translate('SSLDeliveryComment', array($conf['webpath']['delivery'], $conf['webpath']['deliverySSL']));
         }
         if (isset($aComments['SSL Backup Comment'])) {
             $comment .= $aComments['SSL Backup Comment'];
         } else {
             $comment .= $oTrans->translate('SSLBackupComment', array($conf['webpath']['delivery'], $conf['webpath']['deliverySSL']));
         }
         if (isset($aComments['Comment'])) {
             $comment .= $aComments['Comment'];
         }
         if ($comment != '') {
             $buffer .= "<!--/*" . $comment . "\n  */-->\n\n";
         }
     }
     $mi->buffer = $buffer;
     // Set $mi->backupImage to the HTML for the backup image (same as used by adview)
     $hrefParams = array();
     $uniqueid = 'a' . substr(md5(uniqid('', 1)), 0, 7);
     if (isset($mi->bannerid) && $mi->bannerid != '') {
         $hrefParams[] = "bannerid=" . $mi->bannerid;
         $hrefParams[] = "zoneid=" . $mi->zoneid;
     } else {
         $hrefParams[] = "n=" . $uniqueid;
         $imgParams[] = "n=" . $uniqueid;
     }
     if (!empty($mi->cachebuster) || !isset($mi->cachebuster)) {
         $hrefParams[] = "cb=" . $mi->macros['cachebuster'];
     }
     // Make sure that ct0= is the last element in the array
     unset($imgParams['ct0']);
     if (!empty($mi->thirdpartytrack)) {
         $imgParams[] = "ct0=" . $mi->macros['clickurl'];
     }
     $backup = "<a href='" . MAX_commonConstructDeliveryUrl($conf['file']['click']) . "?" . implode("&amp;", $hrefParams) . "'";
     if (isset($mi->target) && $mi->target != '') {
         $backup .= " target='" . $mi->target . "'";
     } else {
         $backup .= " target='_blank'";
     }
     $backup .= "><img src='" . MAX_commonConstructDeliveryUrl($conf['file']['view']);
     // Remove any paramaters that should not be passed into the IMG call
     unset($imgParams['target']);
     if (sizeof($imgParams) > 0) {
         $backup .= "?" . implode("&amp;", $imgParams);
     }
     $backup .= "' border='0' alt='' /></a>";
     $mi->backupImage = $backup;
     // Make sure that the parameters being added are accepted by this plugin, else remove them
     foreach ($mi->parameters as $key => $value) {
         if (!in_array($key, array_keys($this->options))) {
             unset($mi->parameters[$key]);
         }
     }
 }
    /**
     * Return invocation code for this plugin (codetype)
     *
     * @return string
     */
    function generateInvocationCode()
    {
        $aComments = array('SSL Backup Comment' => "", 'SSL Delivery Comment' => "", 'Comment' => "");
        parent::prepareCommonInvocationData($aComments);
        $conf = $GLOBALS['_MAX']['CONF'];
        $mi =& $this->maxInvocation;
        $buffer = $mi->buffer;
        if (isset($mi->block) && $mi->block == '1') {
            $mi->parameters['block'] = "block=1";
        }
        if (isset($mi->blockcampaign) && $mi->blockcampaign == '1') {
            $mi->parameters['blockcampaign'] = "blockcampaign=1";
        }
        // The cachebuster for async tags isn't needed
        unset($mi->parameters['cb']);
        // Add ID
        $mi->parameters['id'] = 'id=' . md5("{$conf['webpath']['delivery']}*{$conf['webpath']['deliverySSL']}");
        // Remap as tag attributes with data-revive prefix
        $mi->parameters = array_map(function ($v) use($conf) {
            return preg_replace('#^(.*)=(.*)$#', 'data-' . $conf['var']['product'] . '-$1="$2"', $v);
        }, $mi->parameters);
        $buffer .= '<ins ' . join(' ', $mi->parameters) . '></ins>' . PHP_EOL;
        if ($conf['webpath']['delivery'] == $conf['webpath']['deliverySSL']) {
            // Yes, we can use the short version!
            $buffer .= '<script async src="' . MAX_commonConstructPartialDeliveryUrl($conf['file']['asyncjs']) . '"></script>';
        } else {
            // Bummer, we need the longer variant
            $url = array(MAX_commonConstructDeliveryUrl($conf['file']['asyncjs']), MAX_commonConstructSecureDeliveryUrl($conf['file']['asyncjs']));
            $buffer .= <<<EOF
<script>
(function () {
  var d = document, s = d.createElement('script'), p = d.location.protocol,
      i = d.getElementsByTagName('ins'), j = i[i.length-1];
  try {
    s.src = p === 'http:' ? '{$url[0]}' :
      '{$url[1]}';
    s.async = true; j.appendChild(s);
  } catch (e) {}
})();
</script>
EOF;
        }
        return $buffer;
    }
 function getZoneCode($zone, $affiliate, $zoneAlias = null)
 {
     $mi =& $this->maxInvocation;
     $conf = $GLOBALS['_MAX']['CONF'];
     $zone['n'] = $affiliate['mnemonic'] . substr(md5(uniqid('', 1)), 0, 7);
     $uri = !empty($mi->ssl) ? MAX_commonConstructSecureDeliveryUrl('') : MAX_commonConstructDeliveryUrl('');
     $codeblock = "<script type='text/javascript'><!--// <![CDATA[";
     $js_func = $this->varprefix . ($zone['delivery'] == phpAds_ZonePopup ? 'showpop' : 'show');
     if ($mi->comments) {
         $codeblock .= "\n    /* " . ($zoneAlias ? addcslashes($zoneAlias) . " - " : '') . "[id{$zone['zoneid']}] " . addcslashes($zone['zonename'], '/') . " */";
     }
     $codeblock .= "\n    {$js_func}(" . ($zoneAlias ? "'" . $zoneAlias . "'" : $zone['zoneid']) . ");\n// ]]> --></script>";
     if ($zone['delivery'] != phpAds_ZoneText && $mi->noscript) {
         $codeblock .= "<noscript><a target='_blank' href='{$uri}{$conf['file']['click']}?n={$zone['n']}'>";
         $codeblock .= "<img border='0' alt='' src='{$uri}{$conf['file']['view']}?zoneid={$zone['zoneid']}&amp;n={$zone['n']}' /></a>";
         $codeblock .= "</noscript>";
     }
     return $codeblock;
 }
 /**
  * Return invocation code for this plugin (codetype)
  *
  * @return string
  */
 function generateInvocationCode()
 {
     $aComments['Comment'] = $this->translate("\n  * If iFrames are not supported by the viewer's browser, then this\n  * tag only shows image banners. There is no width or height in these\n  * banners, so if you want these tags to allocate space for the ad\n  * before it shows, you will need to add this information to the <img>\n  * tag.");
     parent::prepareCommonInvocationData($aComments);
     $conf = $GLOBALS['_MAX']['CONF'];
     $mi =& $this->maxInvocation;
     $buffer = $mi->buffer;
     $uniqueid = 'a' . substr(md5(uniqid('', 1)), 0, 7);
     if (!isset($mi->iframetracking) || $mi->iframetracking == 1) {
         // Add n as first parameter
         array_unshift($mi->parameters, "{$conf['var']['n']}={$uniqueid}");
     }
     if (isset($mi->refresh) && $mi->refresh != '') {
         if (is_array($mi->parameters)) {
             $mi->parameters = array('refresh' => "refresh=" . $mi->refresh) + $mi->parameters;
         } else {
             $mi->parameters['refresh'] = "refresh=" . $mi->refresh;
         }
     }
     if (isset($mi->resize) && $mi->resize == '1') {
         if (is_array($mi->parameters)) {
             $mi->parameters = array('resize' => "resize=1") + $mi->parameters;
         } else {
             $mi->parameters['resize'] = "resize=1";
         }
     }
     if (empty($mi->frame_width)) {
         $mi->frame_width = $mi->width;
     }
     if (empty($mi->frame_height)) {
         $mi->frame_height = $mi->height;
     }
     $buffer .= "<iframe id='{$uniqueid}' name='{$uniqueid}' src='" . MAX_commonConstructDeliveryUrl($conf['file']['frame']);
     if (sizeof($mi->parameters) > 0) {
         $buffer .= "?" . implode("&amp;", $mi->parameters);
     }
     $buffer .= "' frameborder='0' scrolling='no'";
     if (isset($mi->frame_width) && $mi->frame_width != '' && $mi->frame_width != '-1') {
         $buffer .= " width='" . $mi->frame_width . "'";
     }
     if (isset($mi->frame_height) && $mi->frame_height != '' && $mi->frame_height != '-1') {
         $buffer .= " height='" . $mi->frame_height . "'";
     }
     if (isset($mi->transparent) && $mi->transparent == '1') {
         $buffer .= " allowtransparency='true'";
     }
     $buffer .= ">";
     if (isset($mi->refresh) && $mi->refresh != '') {
         unset($mi->parameters['refresh']);
     }
     if (isset($mi->resize) && $mi->resize == '1') {
         unset($mi->parameters['resize']);
     }
     if (isset($mi->ilayer) && $mi->ilayer == 1 && isset($mi->frame_width) && $mi->frame_width != '' && $mi->frame_width != '-1' && isset($mi->frame_height) && $mi->frame_height != '' && $mi->frame_height != '-1') {
         $buffer .= "<script type='text/javascript'>\n";
         $buffer .= "<!--// <![CDATA[\n";
         $buffer .= "   document.write (\"<nolayer>\");\n";
         $buffer .= "   document.write (\"{$mi->backupImage}\");\n";
         $buffer .= "   document.write (\"</nolayer>\");\n";
         $buffer .= "   document.write (\"<ilayer id='layer" . $uniqueid . "' visibility='hidden' width='" . $mi->frame_width . "' height='" . $mi->frame_height . "'></ilayer>\");\n";
         $buffer .= "// ]]> -->\n";
         $buffer .= "</script>";
         $buffer .= "<noscript>\n  <a href='" . MAX_commonConstructDeliveryUrl($conf['file']['click']);
         $buffer .= "?n=" . $uniqueid;
         $buffer .= "'";
         if (isset($mi->target) && $mi->target != '') {
             $buffer .= " target='{$mi->target}'";
         }
         $buffer .= ">\n  <img src='" . MAX_commonConstructDeliveryUrl($conf['file']['view']);
         if (sizeof($mi->parameters) > 0) {
             $buffer .= "?" . implode("&", $mi->parameters);
         }
         $buffer .= "' border='0' alt='' /></a></noscript>";
     } else {
         $buffer .= $mi->backupImage;
     }
     $buffer .= "</iframe>\n";
     if (isset($mi->target) && $mi->target != '') {
         $mi->parameters['target'] = "target=" . urlencode($mi->target);
     }
     if (isset($mi->ilayer) && $mi->ilayer == 1 && isset($mi->frame_width) && $mi->frame_width != '' && $mi->frame_width != '-1' && isset($mi->frame_height) && $mi->frame_height != '' && $mi->frame_height != '-1') {
         // Do no rewrite target frames
         $mi->parameters['rewrite'] = 'rewrite=0';
         $buffer .= "\n\n";
         $buffer .= "<!-- " . $this->translate("Placement Comment") . " -->\n";
         $buffer .= "<layer src='" . MAX_commonConstructDeliveryUrl($conf['file']['frame']);
         $buffer .= "?n=" . $uniqueid;
         if (sizeof($mi->parameters) > 0) {
             $buffer .= "&" . implode("&", $mi->parameters);
         }
         $buffer .= "' width='" . $mi->frame_width . "' height='" . $mi->frame_height . "' visibility='hidden' onload=\"moveToAbsolute(layer" . $uniqueid . ".pageX,layer" . $uniqueid . ".pageY);clip.width=" . $mi->frame_width . ";clip.height=" . $mi->frame_height . ";visibility='show';\"></layer>";
     }
     if (!isset($mi->iframetracking) || $mi->iframetracking != 0) {
         $buffer .= "<script type='text/javascript' src='" . MAX_commonConstructDeliveryUrl($conf['file']['google']) . "'></script>";
     }
     return $buffer;
 }
 /**
  * Return invocation code for this plugin (codetype)
  *
  * @return string
  */
 function generateInvocationCode()
 {
     $aComments = array('Third Party Comment' => '', 'SSL Delivery Comment' => '', 'Comment' => '');
     parent::prepareCommonInvocationData($aComments);
     $conf = $GLOBALS['_MAX']['CONF'];
     $mi =& $this->maxInvocation;
     $buffer = $mi->buffer;
     if (!empty($mi->uniqueid) && $mi->extra['delivery'] != MAX_ZoneEmail) {
         $mi->parameters[] = "n=" . $mi->uniqueid;
     }
     $buffer .= "<a href='";
     if (!empty($mi->thirdpartytrack)) {
         $buffer .= $mi->macros['clickurl'];
     }
     $buffer .= MAX_commonConstructDeliveryUrl($conf['file']['click']);
     $mi->clickParams = array();
     // Only need the banner id for direct selection not zone
     if (empty($mi->extra['delivery']) || $mi->extra['delivery'] != MAX_ZoneEmail) {
         //$buffer .= "?bannerid=" . $mi->bannerid;
         $mi->clickParams[] = 'bannerid=' . $mi->bannerid;
     }
     if (isset($mi->zoneid) && $mi->zoneid != '') {
         //$buffer .= "&zoneid=".$mi->zoneid;
         $mi->clickParams[] = 'zoneid=' . $mi->zoneid;
     }
     if (count($mi->clickParams) > 0) {
         $buffer .= '?' . implode('&amp;', $mi->clickParams);
     }
     $buffer .= "'";
     if (isset($mi->target) && $mi->target != '') {
         $buffer .= " target='" . $mi->target . "'";
     } else {
         $buffer .= " target='_blank'";
     }
     $buffer .= "><img src='" . MAX_commonConstructDeliveryUrl($conf['file']['view']);
     // Without cookies, passing in the click URL to view is not possible
     unset($mi->parameters['ct0']);
     if (sizeof($mi->parameters) > 0) {
         $buffer .= "?" . implode("&amp;", $mi->parameters);
     }
     $buffer .= "' border='0' alt='' /></a>\n";
     return $buffer;
 }