/**
  * @todo calls functions that calls database/cache retrieval methods
  *     cannot mock database
  *     need to decide where/how to test this
  *
  * This library contains the functions to select and generate the HTML for an ad
  *
  */
 function test_MAX_adSelect()
 {
     $this->sendMessage('test_adSelect');
     require_once MAX_PATH . '/lib/max/Delivery/common.php';
     $what = 'zone:1';
     $campaignid = '';
     $target = 'http://www.target.com';
     $source = 'http://www.source.com';
     $withText = false;
     $charset = '';
     $context = array();
     $richMedia = true;
     $ct0 = '';
     $loc = 0;
     $referer = 'http://some.referrer.com/';
     $return = MAX_adSelect($what, $campaignid, $target, $source, $withtext, $charset, $context, $richmedia, $ct0, $loc, $referer);
     $this->assertTrue(TRUE);
 }
Example #2
0
if (!preg_match('/^[a-z0-9-]{1,64}$/Di', $layerstyle) || !@(include $plugin)) {
    MAX_sendStatusCode(404);
    echo '// Cannot load required layerstyle file. Check if openXInvocationTags plugin is installed';
    exit;
}
MAX_commonRegisterGlobalsArray(array('block', 'blockcampaign', 'exclude', 'mmm_fo', 'q'));
if (isset($context) && !is_array($context)) {
    $context = MAX_commonUnpackContext($context);
}
if (!is_array($context)) {
    $context = array();
}
$limitations = MAX_layerGetLimitations();
MAX_commonSendContentTypeHeader("application/x-javascript", $charset);
if ($limitations['compatible']) {
    $output = MAX_adSelect($what, $campaignid, $target, $source, $withtext, $charset, $context, $limitations['richmedia'], $GLOBALS['ct0'], $GLOBALS['loc'], $GLOBALS['referer']);
    MAX_cookieFlush();
    $uniqid = substr(md5(uniqid('', 1)), 0, 8);
    if (empty($output['bannerid'])) {
        echo MAX_javascriptToHTML($output['html'], "MAX_{$uniqid}");
        exit;
    }
    if (!empty($block) && !empty($output['bannerid'])) {
        $output['context'][] = array('!=' => 'bannerid:' . $output['bannerid']);
    }
    if (!empty($blockcampaign) && !empty($output['campaignid'])) {
        $output['context'][] = array('!=' => 'campaignid:' . $output['campaignid']);
    }
    if (!empty($blockcampaign) && !empty($output['campaignid'])) {
        $output['context'][] = array('!=' => 'campaignid:' . $output['campaignid']);
    }
Example #3
0
}
$aBanners = array();
$zones = explode('|', $zones);
foreach ($zones as $thisZone) {
    if (empty($thisZone)) {
        continue;
    }
    if (!empty($nz)) {
        list($zonename, $thisZoneid) = explode('=', $thisZone);
        $varname = $zonename;
    } else {
        $thisZoneid = $varname = $thisZone;
    }
    unset($GLOBALS['_MAX']['deliveryData']);
    $what = "zone:" . $thisZoneid;
    $banner = MAX_adSelect($what, $campaignid, $target, $source, $withtext, $charset, $context, true, $ct0, $loc, $referer);
    if (!empty($block) && !empty($banner['bannerid'])) {
        $banner['context'][] = array('!=' => 'bannerid:' . $banner['bannerid']);
    }
    if (!empty($blockcampaign) && !empty($banner['campaignid'])) {
        $banner['context'][] = array('!=' => 'campaignid:' . $banner['campaignid']);
    }
    if (!empty($banner['context'])) {
        foreach ($banner['context'] as $id => $contextArray) {
            if (!in_array($contextArray, $context)) {
                $context[] = $contextArray;
            }
        }
    }
    $aResponse = array('html' => $banner['html'], 'context' => MAX_commonPackContext($banner['context']));
    foreach ($banner['aRow']['aSearch'] as $index => $value) {
Example #4
0
    $string = addcslashes($string, "\\/\"\n\r\t");
    $string = str_replace("", "\\b", $string);
    $string = str_replace("\f", "\\f", $string);
    return '"' . $string . '"';
}
MAX_commonSetNoCacheHeaders();
MAX_commonRegisterGlobalsArray(array('zones', 'source', 'block', 'blockcampaign', 'exclude', 'q', 'prefix'));
$source = MAX_commonDeriveSource($source);
$spc_output = array();
if (!empty($zones)) {
    $zones = explode('|', $zones);
    foreach ($zones as $id => $thisZoneid) {
        $zonename = $prefix . $id;
        unset($GLOBALS['_MAX']['deliveryData']);
        $what = 'zone:' . $thisZoneid;
        $output = MAX_adSelect($what, $clientid, $target, $source, $withtext, $charset, $context, true, $ct0, $GLOBALS['loc'], $GLOBALS['referer']);
        $spc_output[$zonename] = array('html' => $output['html'], 'width' => isset($output['width']) ? $output['width'] : 0, 'height' => isset($output['height']) ? $output['height'] : 0, 'iframeFriendly' => isset($output['iframeFriendly']) ? $output['iframeFriendly'] : false);
        if (!empty($block) && !empty($output['bannerid'])) {
            $output['context'][] = array('!=' => 'bannerid:' . $output['bannerid']);
        }
        if (!empty($blockcampaign) && !empty($output['campaignid'])) {
            $output['context'][] = array('!=' => 'campaignid:' . $output['campaignid']);
        }
        if (!empty($output['context'])) {
            foreach ($output['context'] as $id => $contextArray) {
                if (!in_array($contextArray, $context)) {
                    $context[] = $contextArray;
                }
            }
        }
    }
Example #5
0
/**
 * A function to handle XML-RPC advertisement SPC requests.
 *
 * @param XML_RPC_Message $params An XML_RPC_Message containing the parameters. The expected parameters
 *                              are (in order):
 *                              - An XML_RPC_Value of type "struct"  containing remote informations
 *                                which needs at least two members:
 *                                - remote_addr (string) and
 *                                - cookies     (struct);
 *                              - An XML_RPC_Value of type "string"  containing the "what" value;
 *                              - An XML_RPC_Value of type "string"  containing the "target" value;
 *                              - An XML_RPC_Value of type "string"  containing the "source" value;
 *                              - An XML_RPC_Value of type "boolean" containing the "withtext" value;
 *                              - An XML_RPC_Value of type "boolean" containing the "block" value;
 *                              - An XML_RPC_Value of type "boolean" containing the "blockcampaign" value;
 * @return XML_RPC_Response The response. The XML_RPC_Value of the response can be one of
 *                          a number of different values:
 *                          - Error Code 21: wrong number of parameters.
 *                          - Error Code 22: remote_addr element missing from the remote info struct.
 *                          - Error Code 23: cookies element missing from the remote info struct.
 *                          - An XML_RPC_Value of type "struct" with the HTML details required
 *                            for displaying the advertisement stored as in XML_RPC_Value of
 *                            type "string" in the "html" index, and other elements returned by the
 *                            MAX_asSelect call. A special "cookies" element is either:
 *                            - An empty XML_RPC_Value if there are no cookies to be set, or
 *                            - An XML_RPC_Value of type "array", containing a number of XML_RPC_Values
 *                              of tpye "array", each with 3 items:
 *                              - An XML_RPC_Value of type "string" with the cookie name;
 *                              - An XML_RPC_Value of type "string" with the cookie value; and
 *                              - An XML_RPC_Value of type "string" with the cookie expiration time.
 */
function OA_Delivery_XmlRpc_SPC($params)
{
    global $XML_RPC_erruser;
    global $XML_RPC_String, $XML_RPC_Struct, $XML_RPC_Array;
    // Check the parameters exist
    $numParams = $params->getNumParams();
    if ($numParams != 7) {
        // Return an error
        $errorCode = $XML_RPC_erruser + 21;
        $errorMsg = 'Incorrect number of parameters';
        return new XML_RPC_Response(0, $errorCode, $errorMsg);
    }
    // Set the XML values into their correct variables to make life easier
    $vars = array(1 => 'what', 2 => 'target', 3 => 'source', 4 => 'withtext', 5 => 'block', 6 => 'blockcampaign');
    // Parse parameters
    for ($i = 0; $i < $numParams; $i++) {
        $p = $params->getParam($i);
        if ($i) {
            // Put the decoded value the view arg array
            ${$vars}[$i] = XML_RPC_decode($p);
        } else {
            // First parameter: environment information supplied be XML-RPC client
            $p = XML_RPC_decode($p);
            if (!isset($p['remote_addr'])) {
                // Return an error
                $errorCode = $XML_RPC_erruser + 22;
                $errorMsg = "Missing 'remote_addr' member";
                return new XML_RPC_Response(0, $errorCode, $errorMsg);
            }
            if (!isset($p['cookies']) || !is_array($p['cookies'])) {
                // Return an error
                $errorCode = $XML_RPC_erruser + 23;
                $errorMsg = "Missing 'cookies' member";
                return new XML_RPC_Response(0, $errorCode, $errorMsg);
            }
            $aServerVars = array('remote_addr' => 'REMOTE_ADDR', 'remote_host' => 'REMOTE_HOST', 'request_uri' => 'REQUEST_URI', 'https' => 'HTTPS', 'server_name' => 'SERVER_NAME', 'http_host' => 'HTTP_HOST', 'accept_language' => 'HTTP_ACCEPT_LANGUAGE', 'referer' => 'HTTP_REFERER', 'user_agent' => 'HTTP_USER_AGENT', 'via' => 'HTTP_VIA', 'forwarded' => 'HTTP_FORWARDED', 'forwarded_for' => 'HTTP_FORWARDED_FOR', 'x_forwarded' => 'HTTP_X_FORWARDED', 'x_forwarded_for' => 'HTTP_X_FORWARDED_FOR', 'client_ip' => 'HTTP_CLIENT_IP');
            // Extract environment vars to $_SERVER
            foreach ($aServerVars as $xmlName => $varName) {
                if (isset($p[$xmlName])) {
                    $_SERVER[$varName] = $p[$xmlName];
                }
            }
            // Extract cookie vars to $_COOKIE
            foreach ($p['cookies'] as $key => $value) {
                $_COOKIE[$key] = MAX_commonAddslashesRecursive($value);
            }
            MAX_cookieUnpackCapping();
        }
    }
    // Add defaults for not-applicable values
    $richmedia = true;
    $ct0 = '';
    $context = array();
    // Make loc and referer global to ensure that the delivery limitations work correctly
    global $loc, $referer;
    $loc = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http') . '://' . OX_getHostName() . $_SERVER['REQUEST_URI'];
    // Add $referer parameter
    $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
    // If the what parameter is an int, it is the affiliateid, otherwise it's a serialized array of name=zone pairs
    // This convention is inline with the parameters passed into local-mode SPC
    if (is_numeric($what)) {
        $zones = OA_cacheGetPublisherZones($what);
        $nz = false;
    } else {
        $zones = unserialize($what);
        $nz = true;
    }
    $spc_output = array();
    foreach ($zones as $zone => $data) {
        if (empty($zone)) {
            continue;
        }
        // nz is set when "named zones" are being used, this allows a zone to be selected more than once
        if ($nz) {
            $varname = $zone;
            $zoneid = $data;
        } else {
            $varname = $zoneid = $zone;
        }
        // Get the banner
        $output = MAX_adSelect('zone:' . $zoneid, '', $target, $source, $withtext, '', $context, $richmedia, $ct0, $GLOBALS['loc'], $GLOBALS['referer']);
        $spc_output[$varname] = $output;
        // Block this banner for next invocation
        if (!empty($block) && !empty($output['bannerid'])) {
            $output['context'][] = array('!=' => 'bannerid:' . $output['bannerid']);
        }
        // Block this campaign for next invocation
        if (!empty($blockcampaign) && !empty($output['campaignid'])) {
            $output['context'][] = array('!=' => 'campaignid:' . $output['campaignid']);
        }
        // Pass the context array back to the next call, have to iterate over elements to prevent duplication
        if (!empty($output['context'])) {
            foreach ($output['context'] as $id => $contextArray) {
                if (!in_array($contextArray, $context)) {
                    $context[] = $contextArray;
                }
            }
        }
    }
    return new XML_RPC_Response(XML_RPC_encode($spc_output));
    // Now we have all the parameters we need to select the ad
    // Call MAX_adSelect with supplied parameters
    $output = call_user_func_array('MAX_adSelect', $view_params);
    // Prepare output as PHP array
    if (!is_array($output)) {
        $output = array();
    } elseif (isset($output['contenttype']) && $output['contenttype'] == 'swf') {
        $output['html'] = MAX_flashGetFlashObjectExternal() . $output['html'];
    }
    MAX_cookieFlush();
    // Add cookie information
    $output['cookies'] = $GLOBALS['_OA']['COOKIE']['XMLRPC_CACHE'];
    // Return response
    return new XML_RPC_Response(XML_RPC_encode($output));
}
 function view_raw($what, $clientid = 0, $target = '', $source = '', $withtext = 0, $context = 0, $richmedia = true)
 {
     $output = MAX_adSelect($what, $clientid, $target, $source, $withtext, '', $context, $richmedia, '', '', '');
     return $output;
 }
 /**
  * make a request via adSelect function
  *
  * @param stdClass object $oRequest
  * @return array of ad info
  */
 function _makeRequest($oRequest)
 {
     if ($this->profileOn) {
         $start = microtime_float();
     }
     $adSelect = MAX_adSelect($oRequest->what, '', $oRequest->target, $oRequest->source, $oRequest->withText, $oRequest->charset, $oRequest->context, $oRequest->richMedia, $oRequest->ct0, $oRequest->loc, $oRequest->referer);
     if ($this->adSelectCallback) {
         call_user_method($this->adSelectCallback, $this);
     }
     if ($this->profileOn) {
         $this->aProfile[] = array('bannerid' => $adSelect['bannerid'], 'lapsed' => sprintf("%.11f", microtime_float() - $start));
     }
     return $adSelect;
 }
Example #8
0
function view_spc($what, $target = '', $source = '', $withtext = 0, $block = 0, $blockcampaign = 0)
{
    global $context;
    if (is_numeric($what)) {
        $zones = OA_cacheGetPublisherZones($what);
        $nz = false;
    } else {
        $zones = $what;
        $nz = true;
    }
    $spc_output = array();
    $fo_required = false;
    foreach ($zones as $zone => $data) {
        if (empty($zone)) {
            continue;
        }
        // nz is set when "named zones" are being used, this allows a zone to be selected more than once
        if ($nz) {
            $varname = $zone;
            $zoneid = $data;
        } else {
            $varname = $zoneid = $zone;
        }
        // Get the banner
        $output = MAX_adSelect('zone:' . $zoneid, '', $target, $source, $withtext, $charset, $context, true, '', $GLOBALS['loc'], $GLOBALS['referer']);
        if (isset($output['contenttype']) && $output['contenttype'] == 'swf') {
            $fo_required = true;
        }
        $spc_output[$varname] = $output['html'];
        // Block this banner for next invocation
        if (!empty($block) && !empty($output['bannerid'])) {
            $output['context'][] = array('!=' => 'bannerid:' . $output['bannerid']);
        }
        // Block this campaign for next invocation
        if (!empty($blockcampaign) && !empty($output['campaignid'])) {
            $output['context'][] = array('!=' => 'campaignid:' . $output['campaignid']);
        }
        // Pass the context array back to the next call, have to iterate over elements to prevent duplication
        if (!empty($output['context'])) {
            foreach ($output['context'] as $id => $contextArray) {
                if (!in_array($contextArray, $context)) {
                    $context[] = $contextArray;
                }
            }
        }
    }
    // Make sure the FlashObject library is available if required
    if ($fo_required) {
        echo MAX_flashGetFlashObjectExternal();
    }
    return $spc_output;
}
Example #9
0
function view_spc($what, $target = '', $source = '', $withtext = 0, $block = 0, $blockcampaign = 0)
{
    global $context;
    if (is_numeric($what)) {
        $zones = OA_cacheGetPublisherZones($what);
        $nz = false;
    } else {
        $zones = $what;
        $nz = true;
    }
    $spc_output = array();
    $fo_required = false;
    foreach ($zones as $zone => $data) {
        if (empty($zone)) {
            continue;
        }
        if ($nz) {
            $varname = $zone;
            $zoneid = $data;
        } else {
            $varname = $zoneid = $zone;
        }
        $output = MAX_adSelect('zone:' . $zoneid, '', $target, $source, $withtext, $charset, $context, true, '', $GLOBALS['loc'], $GLOBALS['referer']);
        if (isset($output['contenttype']) && $output['contenttype'] == 'swf') {
            $fo_required = true;
        }
        $spc_output[$varname] = $output['html'];
        if (!empty($block) && !empty($output['bannerid'])) {
            $output['context'][] = array('!=' => 'bannerid:' . $output['bannerid']);
        }
        if (!empty($blockcampaign) && !empty($output['campaignid'])) {
            $output['context'][] = array('!=' => 'campaignid:' . $output['campaignid']);
        }
        if (!empty($output['context'])) {
            foreach ($output['context'] as $id => $contextArray) {
                if (!in_array($contextArray, $context)) {
                    $context[] = $contextArray;
                }
            }
        }
    }
    if ($fo_required) {
        echo MAX_flashGetFlashObjectExternal();
    }
    return $spc_output;
}
Example #10
0
function OA_Delivery_XmlRpc_SPC($params)
{
    global $XML_RPC_erruser;
    global $XML_RPC_String, $XML_RPC_Struct, $XML_RPC_Array;
    $numParams = $params->getNumParams();
    if ($numParams != 7) {
        $errorCode = $XML_RPC_erruser + 21;
        $errorMsg = 'Incorrect number of parameters';
        return new XML_RPC_Response(0, $errorCode, $errorMsg);
    }
    $vars = array(1 => 'what', 2 => 'target', 3 => 'source', 4 => 'withtext', 5 => 'block', 6 => 'blockcampaign');
    for ($i = 0; $i < $numParams; $i++) {
        $p = $params->getParam($i);
        if ($i) {
            ${$vars}[$i] = XML_RPC_decode($p);
        } else {
            $p = XML_RPC_decode($p);
            if (!isset($p['remote_addr'])) {
                $errorCode = $XML_RPC_erruser + 22;
                $errorMsg = "Missing 'remote_addr' member";
                return new XML_RPC_Response(0, $errorCode, $errorMsg);
            }
            if (!isset($p['cookies']) || !is_array($p['cookies'])) {
                $errorCode = $XML_RPC_erruser + 23;
                $errorMsg = "Missing 'cookies' member";
                return new XML_RPC_Response(0, $errorCode, $errorMsg);
            }
            $aServerVars = array('remote_addr' => 'REMOTE_ADDR', 'remote_host' => 'REMOTE_HOST', 'request_uri' => 'REQUEST_URI', 'https' => 'HTTPS', 'server_name' => 'SERVER_NAME', 'http_host' => 'HTTP_HOST', 'accept_language' => 'HTTP_ACCEPT_LANGUAGE', 'referer' => 'HTTP_REFERER', 'user_agent' => 'HTTP_USER_AGENT', 'via' => 'HTTP_VIA', 'forwarded' => 'HTTP_FORWARDED', 'forwarded_for' => 'HTTP_FORWARDED_FOR', 'x_forwarded' => 'HTTP_X_FORWARDED', 'x_forwarded_for' => 'HTTP_X_FORWARDED_FOR', 'client_ip' => 'HTTP_CLIENT_IP');
            foreach ($aServerVars as $xmlName => $varName) {
                if (isset($p[$xmlName])) {
                    $_SERVER[$varName] = $p[$xmlName];
                }
            }
            foreach ($p['cookies'] as $key => $value) {
                $_COOKIE[$key] = MAX_commonAddslashesRecursive($value);
            }
            MAX_remotehostSetInfo(true);
            OX_Delivery_Common_hook('postInit');
            MAX_cookieUnpackCapping();
        }
    }
    $richmedia = true;
    $ct0 = '';
    $context = array();
    global $loc, $referer;
    $loc = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http') . '://' . OX_getHostName() . $_SERVER['REQUEST_URI'];
    $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
    if (is_numeric($what)) {
        $zones = OA_cacheGetPublisherZones($what);
        $nz = false;
    } else {
        $zones = unserialize($what);
        $nz = true;
    }
    $spc_output = array();
    foreach ($zones as $zone => $data) {
        if (empty($zone)) {
            continue;
        }
        if ($nz) {
            $varname = $zone;
            $zoneid = $data;
        } else {
            $varname = $zoneid = $zone;
        }
        unset($GLOBALS['_MAX']['deliveryData']);
        $output = MAX_adSelect('zone:' . $zoneid, '', $target, $source, $withtext, '', $context, $richmedia, $ct0, $GLOBALS['loc'], $GLOBALS['referer']);
        $spc_output[$varname] = $output;
        if (!empty($block) && !empty($output['bannerid'])) {
            $output['context'][] = array('!=' => 'bannerid:' . $output['bannerid']);
        }
        if (!empty($blockcampaign) && !empty($output['campaignid'])) {
            $output['context'][] = array('!=' => 'campaignid:' . $output['campaignid']);
        }
        if (!empty($output['context'])) {
            foreach ($output['context'] as $id => $contextArray) {
                if (!in_array($contextArray, $context)) {
                    $context[] = $contextArray;
                }
            }
        }
    }
    return new XML_RPC_Response(XML_RPC_encode($spc_output));
    $output = call_user_func_array('MAX_adSelect', $view_params);
    if (!is_array($output)) {
        $output = array();
    } elseif (isset($output['contenttype']) && $output['contenttype'] == 'swf') {
        $output['html'] = MAX_flashGetFlashObjectExternal() . $output['html'];
    }
    MAX_cookieFlush();
    $output['cookies'] = $GLOBALS['_OA']['COOKIE']['XMLRPC_CACHE'];
    return new XML_RPC_Response(XML_RPC_encode($output));
}
Example #11
0
if (!isset($location)) {
    $location = 0;
}
if (!isset($menubar)) {
    $menubar = 0;
}
if (!isset($status)) {
    $status = 0;
}
if (!isset($resizable)) {
    $resizable = 0;
}
if (!isset($scrollbars)) {
    $scrollbars = 0;
}
$row = MAX_adSelect($what, $campaignid, $target, $source, $withtext, $charset, $context, true, $ct0, $GLOBALS['loc'], $GLOBALS['referer']);
$row['zoneid'] = 0;
if (isset($zoneid)) {
    $row['zoneid'] = $zoneid;
}
if (!$row['bannerid']) {
    exit;
}
$contenturl = MAX_commonGetDeliveryUrl($conf['file']['content']) . "?bannerid={$row['bannerid']}&zoneid={$row['zoneid']}&target={$target}&withtext={$withtext}&source=" . urlencode($source) . "&timeout={$timeout}&ct0={$ct0}";
MAX_commonSendContentTypeHeader("application/x-javascript");
echo "\nvar MAX_errorhandler = null;\n\nif (window.captureEvents && Event.ERROR)\n  window.captureEvents (Event.ERROR);\n\n// Error handler to prevent 'Access denied' errors\nfunction MAX_onerror(e) {\n  window.onerror = MAX_errorhandler;\n  return true;\n}\n\nfunction MAX_{$row['bannerid']}_pop() {\n  MAX_errorhandler = window.onerror;\n  window.onerror = MAX_onerror;\n\n  // Determine the size of the window\n  var X={$row['width']};\n  var Y={$row['height']};\n\n  // If Netscape 3 is used add 20 to the size because it doesn't support a margin of 0\n  if(!window.resizeTo) {\n    X+=20;\n    Y+=20;\n  }\n\n  // Open the window if needed\n  window.MAX_{$row['bannerid']}=window.open('', 'MAX_{$row['bannerid']}','height='+Y+',width='+X+',toolbar=" . ($toolbars == 1 ? 'yes' : 'no') . ",location=" . ($location == 1 ? 'yes' : 'no') . ",menubar=" . ($menubar == 1 ? 'yes' : 'no') . ",status=" . ($status == 1 ? 'yes' : 'no') . ",resizable=" . ($resizable == 1 ? 'yes' : 'no') . ",scrollbars=" . ($scrollbars == 1 ? 'yes' : 'no') . "');\n\n  if (window.MAX_{$row['bannerid']}.document.title == '' || window.MAX_{$row['bannerid']}.location == 'about:blank' || window.MAX_{$row['bannerid']}.location == '') {\n    var browser = navigator.userAgent.toLowerCase();\n\n    // Resize window to correct size on IE < 6, determine outer width and height - IE 5.1x on MAC should't resize!\n    if (window.resizeTo && browser.match(/msie [345]/) && browser.indexOf('msie 5.1') == -1 && browser.indexOf('mac') == -1) {\n      if(MAX_{$row['bannerid']}.innerHeight) {\n        var diffY = MAX_{$row['bannerid']}.outerHeight-Y;\n        var diffX = MAX_{$row['bannerid']}.outerWidth-X;\n        var outerX = X+diffX;\n        var outerY = Y+diffY;\n      } else {\n        MAX_{$row['bannerid']}.resizeTo(X, Y);\n        var time = new Date().getTime();\n        while (!MAX_{$row['bannerid']}.document.body) {\n          if (new Date().getTime() - time > 250) {\n            MAX_{$row['bannerid']}.close();\n            return false;\n          }\n        }\n        var diffY = MAX_{$row['bannerid']}.document.body.clientHeight-Y;\n        var diffX = MAX_{$row['bannerid']}.document.body.clientWidth-X;\n        var outerX = X-diffX;\n        var outerY = Y-diffY;\n      }\n      MAX_{$row['bannerid']}.resizeTo(outerX, outerY);\n    }";
if (!empty($left) && !empty($top)) {
    echo "\n    if (window.moveTo) {";
    if ($left == 'center') {
        echo "\n      var posX = parseInt((screen.width/2)-(outerX/2));";
    } elseif ($left >= 0) {
Example #12
0
// Register any script specific input variables
MAX_commonRegisterGlobalsArray(array('n'));
if (!isset($n)) {
    $n = 'default';
}
$richMedia = false;
// This is an image tag - we only need the filename (or URL?) of the image...
$target = '';
// Target cannot be dynamically set in basic tags.
$context = array();
// I don't think that $context is valid in adview.php...
$ct0 = '';
// Click tracking should be done using external tags rather than this way...
$withText = 0;
// Cannot write text using a simple tag...
$row = MAX_adSelect($what, $campaignid, $target, $source, $withText, $charset, $context, $richMedia, $ct0, $loc, $referer);
if (!empty($row['html'])) {
    // Send bannerid headers
    $cookie = array();
    $cookie[$conf['var']['adId']] = $row['bannerid'];
    // Send zoneid headers
    if ($zoneid != 0) {
        $cookie[$conf['var']['zoneId']] = $zoneid;
    }
    // Send source headers
    if (!empty($source)) {
        $cookie[$conf['var']['channel']] = $source;
    }
    if (!empty($row['clickwindow'])) {
        $cookie[$conf['var']['lastClick']] = 1;
    }
function prepareCompanionBanner(&$aOutputParams, $aBanner, $zoneId = 0, $source = '', $ct0 = '', $withText = false, $logClick = true, $logView = true, $useAlt = false, $loc, $referer)
{
    // If we have a companion banner to serve
    if (isset($aBanner['vast_companion_banner_id']) && $aBanner['vast_companion_banner_id'] != 0) {
        $companionBannerId = $aBanner['vast_companion_banner_id'];
        // VAST supports the concept of an ad having multlple  companions returned(each with different formats and sizes
        // its then the role of the player to choose the appropriate companion ad to display based on users screen size etc
        // However for now we just focus on serving a single companion banner. Also in vast - I think - the player should be adding the click tracking
        // for now we are doing this server side.
        global $context;
        if (isset($context) && !is_array($context)) {
            $context = MAX_commonUnpackContext($context);
        }
        if (!is_array($context)) {
            $context = array();
        }
        $companionOutput = MAX_adSelect("bannerid:{$companionBannerId}", '', "", $source, $withText, '', $context, true, $ct0, $loc, $referer);
        //$aBanner = _adSelectDirect("bannerid:$companionBannerId", '', $context, $source);
        //$companionOutput = MAX_adRender($aBanner, 0, '', '', '', true, '', false, false);
        //$aOutputParams['companionId'] = $companionBannerId;
        if (!empty($companionOutput['html'])) {
            // We only regard  a companion existing, if we have some markup to output
            $html = $companionOutput['html'];
            // deal with the case where the companion code itself contains a CDATA
            $html = str_replace(']]>', ']]]]><![CDATA[>', $html);
            $aOutputParams['companionMarkup'] = $html;
            $aOutputParams['companionWidth'] = $companionOutput['width'];
            $aOutputParams['companionHeight'] = $companionOutput['height'];
            $aOutputParams['companionClickUrl'] = $companionOutput['url'];
        }
    }
}