/** * Populate variables from a specially encoded string. This is used because * in a click URL, a parameter could possibly be another URL. * * The resulting values are set into the $_GET, and $_REQUEST globals */ function MAX_querystringConvertParams() { $conf = $GLOBALS['_MAX']['CONF']; $qs = $_SERVER['QUERY_STRING']; // 1. Strip off the destination $dest = false; $destStr = $conf['var']['dest'] . '='; $pos = strpos($qs, $destStr); if ($pos === false) { $destStr = 'dest='; $pos = strpos($qs, $destStr); } if ($pos !== false) { $dest = urldecode(substr($qs, $pos + strlen($destStr))); $qs = substr($qs, 0, $pos); } // 2. Parse the remaining string $aGet = array(); $paramStr = $conf['var']['params'] . '='; $paramPos = strpos($qs, $paramStr); if (is_numeric($paramPos)) { $qs = urldecode(substr($qs, $paramPos + strlen($paramStr))); $delim = $qs[0]; if (is_numeric($delim)) { $delim = substr($qs, 1, $delim); } $qs = substr($qs, strlen($delim) + 1); MAX_querystringParseStr($qs, $aGet, $delim); // Fix the destination URL since if appended by a form, it will have no '?' $qPos = isset($aGet[$conf['var']['dest']]) ? strpos($aGet[$conf['var']['dest']], '?') : false; $aPos = isset($aGet[$conf['var']['dest']]) ? strpos($aGet[$conf['var']['dest']], '&') : false; if ($aPos && !$qPos) { $desturl = substr($aGet[$conf['var']['dest']], 0, $aPos); $destparams = substr($aGet[$conf['var']['dest']], $aPos + 1); $aGet[$conf['var']['dest']] = $desturl . '?' . $destparams; } } else { parse_str($qs, $aGet); } if ($dest !== false) { $aGet[$conf['var']['dest']] = $dest; } // 3. Add any cookie values to the GET string... $n = isset($_GET[$conf['var']['n']]) ? $_GET[$conf['var']['n']] : ''; if (empty($n)) { // Try from querystring $n = isset($aGet[$conf['var']['n']]) ? $aGet[$conf['var']['n']] : ''; } if (!empty($n) && !empty($_COOKIE[$conf['var']['vars']][$n])) { $aVars = unserialize(stripslashes($_COOKIE[$conf['var']['vars']][$n])); foreach ($aVars as $name => $value) { if (!isset($_GET[$name])) { $aGet[$name] = $value; } } } $_GET = $aGet; $_REQUEST = $_GET + $_POST + $_COOKIE; }
/** * merge the url params with global $_REQUEST * call the lg.php script * * @param int $bannerId - if null then delivery failed * @package string $html */ function _logBeacon($beaconURL) { if ($beaconURL) { $requestSave = $_REQUEST; $getSave = $_GET; $_GET = array(); $request = MAX_querystringParseStr($beaconURL, &$aRequest, '&'); $_REQUEST = $aRequest; chdir(MAX_PATH . '/www/delivery'); include './lg.php'; chdir(SIM_PATH); $_REQUEST = $requestSave; $_GET = $getSave; } else { MAX_cookieFlush(); } }
function MAX_querystringConvertParams() { $conf = $GLOBALS['_MAX']['CONF']; $qs = $_SERVER['QUERY_STRING']; $dest = false; $destStr = $conf['var']['dest'] . '='; $pos = strpos($qs, $destStr); if ($pos === false) { $destStr = 'dest='; $pos = strpos($qs, $destStr); } if ($pos !== false) { $dest = urldecode(substr($qs, $pos + strlen($destStr))); $qs = substr($qs, 0, $pos); } $aGet = array(); $paramStr = $conf['var']['params'] . '='; $paramPos = strpos($qs, $paramStr); if (is_numeric($paramPos)) { $qs = urldecode(substr($qs, $paramPos + strlen($paramStr))); $delim = $qs[0]; if (is_numeric($delim)) { $delim = substr($qs, 1, $delim); } $qs = substr($qs, strlen($delim) + 1); MAX_querystringParseStr($qs, $aGet, $delim); $qPos = isset($aGet[$conf['var']['dest']]) ? strpos($aGet[$conf['var']['dest']], '?') : false; $aPos = isset($aGet[$conf['var']['dest']]) ? strpos($aGet[$conf['var']['dest']], '&') : false; if ($aPos && !$qPos) { $desturl = substr($aGet[$conf['var']['dest']], 0, $aPos); $destparams = substr($aGet[$conf['var']['dest']], $aPos + 1); $aGet[$conf['var']['dest']] = $desturl . '?' . $destparams; } } else { parse_str($qs, $aGet); } if ($dest !== false) { $aGet[$conf['var']['dest']] = $dest; } $n = isset($_GET[$conf['var']['n']]) ? $_GET[$conf['var']['n']] : ''; if (empty($n)) { $n = isset($aGet[$conf['var']['n']]) ? $aGet[$conf['var']['n']] : ''; } if (!empty($n) && !empty($_COOKIE[$conf['var']['vars']][$n])) { $aVars = unserialize(stripslashes($_COOKIE[$conf['var']['vars']][$n])); foreach ($aVars as $name => $value) { if (!isset($_GET[$name])) { $aGet[$name] = $value; } } } $_GET = $aGet; $_REQUEST = $_GET + $_POST + $_COOKIE; }