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;
}
Exemple #2
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 #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 (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == $conf['openads']['sslPort']) {
        $url = MAX_commonConstructSecureDeliveryUrl($file);
    } else {
        $url = MAX_commonConstructDeliveryUrl($file);
    }
    return $url;
}
Exemple #4
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;
 }
 /**
  * Test1 return secure URL
  * A function to generate the secure 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_commonConstructSecureDeliveryUrl()
 {
     $this->sendMessage('test_MAX_commonConstructSecureDeliveryUrl');
     $GLOBALS['_MAX']['CONF']['webpath']['deliverySSL'] = 'secure.maxstore.net/www/delivery';
     $GLOBALS['_MAX']['CONF']['openads']['sslPort'] = 444;
     $file = 'test.html';
     $ret = MAX_commonConstructSecureDeliveryUrl($file);
     $this->assertEqual($ret, 'https://secure.maxstore.net:444/www/delivery/test.html');
 }
    /**
     * 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;
 }