/** * A private method to prepare the report range information from an * OA_Admin_DaySpan object. * * @access private * @param OA_Admin_DaySpan $oDaySpan The OA_Admin_DaySpan object to set * the report range information from. */ function _prepareReportRange($oDaySpan) { global $date_format; if (!empty($oDaySpan)) { $this->_oDaySpan = $oDaySpan; $this->_startDateString = $oDaySpan->getStartDateString($date_format); $this->_endDateString = $oDaySpan->getEndDateString($date_format); } else { $oDaySpan = new OA_Admin_DaySpan(); // take as the start date the date when adds were serverd $aConf = $GLOBALS['_MAX']['CONF']; $oDbh = OA_DB::singleton(); $query = "SELECT MIN(date_time) as min_datetime FROM " . $oDbh->quoteIdentifier($aConf['table']['prefix'] . $aConf['table']['data_summary_ad_hourly'], true) . " WHERE 1=1"; $startDate = $oDbh->queryRow($query); $startDate = $startDate['min_datetime']; $oStartDate = new Date($startDate); $oEndDate = new Date(); $oDaySpan->setSpanDays($oStartDate, $oEndDate); $this->_oDaySpan =& $oDaySpan; $this->_startDateString = MAX_Plugin_Translation::translate('Beginning', $this->module, $this->package); $this->_endDateString = $oDaySpan->getEndDateString($date_format); } $utcUpdate = OA_Dal_ApplicationVariables::get('utc_update'); if (!empty($utcUpdate)) { $oUpdate = new Date($utcUpdate); $oUpdate->setTZbyID('UTC'); // Add 12 hours $oUpdate->addSeconds(3600 * 12); $startDate = new Date($oDaySpan->oStartDate); $endDate = new Date($oDaySpan->oEndDate); if ($oUpdate->after($endDate) || $oUpdate->after($startDate)) { $this->_displayInaccurateStatsWarning = true; } } }
/** * A method to set the value of the field using the input querystring fields passed in from the HTML. * * @param array $aQuerystring The querystring of this field. */ function setValueFromArray($aFieldValues) { $fieldSelectionName = $aFieldValues[$this->_name . '_preset']; if (!empty($fieldSelectionName)) { if ($fieldSelectionName == 'specific') { $oDaySpan = new OA_Admin_DaySpan(); $sStartDate = $aFieldValues[$this->_name . '_start']; $oStartDate = new Date(); if ($sStartDate == '') { $sStartDate = '1995-01-01'; } $oStartDate->setDate($sStartDate); $sEndDate = $aFieldValues[$this->_name . '_end']; $oEndDate = new Date(); if ($sEndDate != '') { $oEndDate->setDate($sEndDate); } $oDaySpan->setSpanDays($oStartDate, $oEndDate); } elseif ($fieldSelectionName == 'all_stats') { $oDaySpan = null; } else { $oDaySpan = new OA_Admin_DaySpan($fieldSelectionName); } $this->_value = $oDaySpan; $this->_fieldSelectionValue = $fieldSelectionName; } }
/** * A private method to prepare an array of connections and variable values for the * report. * * @access private * @return array An array with the following format: * array( * $trackerId => array( * 'connections' => array( * $connectionId => array( * 'data_intermediate_ad_connection_id' => Integer: The conversion ID * 'tracker_date_time' => Timestamp: The date/time of the conversion * 'tracker_day' => String: The day of the conversion in YYYY-MM-DD format * 'connection_date_time' => Timestamp: The date/time of the ad impression/click * 'connection_status' => Integer: The status of the connection * 'connection_channel' => Integer: The channel ID of the ad impression/click * 'connection_action' => Integer: If it was an ad impression or click * 'connection_ip_address' => String: The IP address of the ad impression/click * 'connection_country' => String: The country of the ad impression/click * 'connection_domain' => String: The domain of the ad impression/click * 'connection_language' => String: The language of the ad impression/click * 'connection_os' => String: The operating system of the ad impression/click * 'connection_browser' => String: The browser of the ad impression/click * 'connection_comments' => String: Any comments associated with the connection * 'advertiser_id' => Integer: The advertiser ID of the ad impression/click * 'advertiser_name' => String: The name of the advertiser of the ad impression/click * 'placement_id' => Integer: The placement ID of the ad impression/click * 'placement_name' => String: The name of the placement of the ad impression/click * 'ad_id' => Integer: The ad ID of the ad impression/click * 'ad_name' => String: The name of the ad of the ad impression/click * 'ad_alt' => String: The alt. name of the ad of the ad impression/click * 'publisher_id' => Integer: The publisher ID of the ad impression/click * 'publisher_name' => String: The name of the publisher of the ad impression/click * 'zone_id' => Integer: The zone ID of the ad impression/click * 'zone_name' => String: The name of the zone of the ad impression/click * 'tracker_id' => Integer: The tracker ID for the conversion * 'variables' => array( * $trackerVariableId => array( * tracker_variable_id => Integer: The tracker variable ID * tracker_variable_value => Mixed: The tracker variable value for the conversion * ) * ) * ) * ) * ) * ) */ function _prepareConnections() { $aConnections = array(); $aConf = $GLOBALS['_MAX']['CONF']; // Prepare the start and end dates for the conversion range $oDaySpan = new OA_Admin_DaySpan(); $oDaySpan->setSpanDays($this->_oDaySpan->oStartDate, $this->_oDaySpan->oEndDate); $oDaySpan->toUTC(); $startDateString = $oDaySpan->getStartDateString('%Y-%m-%d %H:%M:%S'); $endDateString = $oDaySpan->getEndDateString('%Y-%m-%d %H:%M:%S'); // Prepare the agency/advertiser/publisher limitations $agencyId = $this->_oScope->getAgencyId(); $advertiserId = $this->_oScope->getAdvertiserId(); $publisherId = $this->_oScope->getPublisherId(); // Prepare the query to select the required conversions and variable values $query = "\n SELECT\n diac.data_intermediate_ad_connection_id AS data_intermediate_ad_connection_id,\n diac.tracker_date_time AS tracker_date_time,\n diac.tracker_id AS tracker_id,\n diac.connection_date_time AS connection_date_time,\n diac.connection_status AS connection_status,\n diac.connection_channel AS connection_channel,\n diac.connection_action AS connection_action,\n diac.tracker_ip_address AS connection_ip_address,\n diac.tracker_country AS connection_country,\n diac.tracker_domain AS connection_domain,\n diac.tracker_language AS connection_language,\n diac.tracker_os AS connection_os,\n diac.tracker_browser AS connection_browser,\n diac.comments AS connection_comments,\n z.zoneid AS zone_id,\n z.zonename AS zone_name,\n p.affiliateid AS publisher_id,\n p.name AS publisher_name,\n a.clientid AS advertiser_id,\n a.clientname AS advertiser_name,\n c.campaignid AS placement_id,\n c.campaignname AS campaign_name,\n b.bannerid AS ad_id,\n b.description AS ad_name,\n b.alt AS ad_alt,\n diavv.tracker_variable_id AS tracker_variable_id,\n diavv.value AS tracker_variable_value\n FROM\n {$aConf['table']['prefix']}{$aConf['table']['data_intermediate_ad_connection']} AS diac\n JOIN\n {$aConf['table']['prefix']}{$aConf['table']['banners']} AS b\n ON\n (\n diac.ad_id = b.bannerid\n )\n JOIN\n {$aConf['table']['prefix']}{$aConf['table']['campaigns']} AS c\n ON\n (\n b.campaignid = c.campaignid\n )\n JOIN\n {$aConf['table']['prefix']}{$aConf['table']['clients']} AS a\n ON\n (\n c.clientid = a.clientid\n )\n LEFT JOIN\n {$aConf['table']['prefix']}{$aConf['table']['zones']} AS z\n ON\n (\n diac.zone_id = z.zoneid\n )\n LEFT JOIN\n {$aConf['table']['prefix']}{$aConf['table']['affiliates']} AS p\n ON\n (\n z.affiliateid = p.affiliateid\n )\n LEFT JOIN\n {$aConf['table']['prefix']}{$aConf['table']['data_intermediate_ad_variable_value']} AS diavv\n ON\n (\n diac.data_intermediate_ad_connection_id = diavv.data_intermediate_ad_connection_id\n )\n WHERE\n diac.tracker_date_time >= " . DBC::makeLiteral($startDateString, 'string') . "\n AND\n diac.tracker_date_time <= " . DBC::makeLiteral($endDateString, 'string') . "\n AND\n diac.inside_window = 1"; if ($agencyId) { $query .= "\n AND\n a.agencyid = " . DBC::makeLiteral($agencyId, 'integer'); } if ($advertiserId) { $query .= "\n AND\n a.clientid = " . DBC::makeLiteral($advertiserId, 'integer'); } if ($publisherId) { $query .= "\n AND\n z.affiliateid = " . DBC::makeLiteral($publisherId, 'integer'); } $query .= "\n ORDER BY\n tracker_id,\n data_intermediate_ad_connection_id"; // Select the conversions in the report $rsConversions = DBC::NewRecordSet($query); $rsConversions->find(); while ($rsConversions->fetch()) { $aConversion = $rsConversions->toArray(); $trackerId = $aConversion['tracker_id']; $connectionId = $aConversion['data_intermediate_ad_connection_id']; // Does this tracker/connection pair exist in the result array already? // It might, due to multiple attached variable values... if (!isset($aConnections[$trackerId]['connections'][$connectionId])) { // It's not set, store the connection details $oTrackerDate = new Date($aConversion['tracker_date_time']); $oTrackerDate->setTZbyID('UTC'); $oTrackerDate->convertTZ($this->_oDaySpan->oStartDate->tz); $oConnectionDate = new Date($aConversion['connection_date_time']); $oConnectionDate->setTZbyID('UTC'); $oConnectionDate->convertTZ($this->_oDaySpan->oStartDate->tz); $aConnections[$trackerId]['connections'][$connectionId] = array('data_intermediate_ad_connection_id' => $connectionId, 'tracker_date_time' => $oTrackerDate->format('%Y-%m-%d %H:%M:%S'), 'tracker_day' => $oTrackerDate->format('%Y-%m-%d'), 'connection_date_time' => $oConnectionDate->format('%Y-%m-%d %H:%M:%S'), 'connection_status' => $aConversion['connection_status'], 'connection_channel' => $aConversion['connection_channel'], 'connection_action' => $aConversion['connection_action'], 'connection_ip_address' => $aConversion['connection_ip_address'], 'connection_country' => $aConversion['connection_country'], 'connection_domain' => $aConversion['connection_domain'], 'connection_language' => $aConversion['connection_language'], 'connection_os' => $aConversion['connection_os'], 'connection_browser' => $aConversion['connection_browser'], 'connection_comments' => $aConversion['connection_comments'], 'advertiser_id' => $aConversion['advertiser_id'], 'advertiser_name' => $aConversion['advertiser_name'], 'placement_id' => $aConversion['placement_id'], 'placement_name' => $aConversion['placement_name'], 'ad_id' => $aConversion['ad_id'], 'ad_name' => $aConversion['ad_name'], 'ad_alt' => $aConversion['ad_alt'], 'publisher_id' => $aConversion['publisher_id'], 'publisher_name' => $aConversion['publisher_name'], 'zone_id' => $aConversion['zone_id'], 'zone_name' => $aConversion['zone_name'], 'tracker_id' => $aConversion['tracker_id']); } // Store the variable value associated with this connection, if one exists $trackerVariableId = $aConversion['tracker_variable_id']; if (!empty($trackerVariableId)) { $aConnections[$trackerId]['connections'][$connectionId]['variables'][$trackerVariableId] = array('tracker_variable_id' => $trackerVariableId, 'tracker_variable_value' => $aConversion['tracker_variable_value']); } } // Return the connections return $aConnections; }
/** * A method to test the getDayArray() method. */ function testGetDayArray() { $oDaySpan = new OA_Admin_DaySpan(); $oTestStartDate = new Date('2006-09-26'); $oTestEndDate = new Date('2006-09-26'); $aExpectedResult = array('2006-09-26'); $oDaySpan->setSpanDays($oTestStartDate, $oTestEndDate); $this->assertEqual($oDaySpan->getDayArray(), $aExpectedResult); $oTestStartDate = new Date('2006-09-26'); $oTestEndDate = new Date('2006-10-03'); $aExpectedResult = array('2006-09-26', '2006-09-27', '2006-09-28', '2006-09-29', '2006-09-30', '2006-10-01', '2006-10-02', '2006-10-03'); $oDaySpan->setSpanDays($oTestStartDate, $oTestEndDate); $this->assertEqual($oDaySpan->getDayArray(), $aExpectedResult); }
/** * A private method to create an OA_Admin_DaySpan object with the campaign's * start and end date values. * * @access private * @param array $aCampaignData An array of campaign data. * @return OA_Admin_DaySpan The date range of the campaign's activation date and * expiry date. */ function &_rangeFromCampaign($aCampaignData) { $oCampaignDaySpan = new OA_Admin_DaySpan(); $oDate = new Date(); $oBeginDate = new Date($aCampaignData['campaign_start']); $oEndDate = new Date($aCampaignData['campaign_end']); $oBeginDate->setTzByID('UTC'); $oEndDate->setTzByID('UTC'); $oBeginDate->convertTZ($oDate->tz); $oEndDate->convertTZ($oDate->tz); $oCampaignDaySpan->setSpanDays($oBeginDate, $oEndDate); return $oCampaignDaySpan; }
} else { $period_start = htmlspecialchars(MAX_getStoredValue('period_start', date('Y-m-d'))); if (!strstr($period_start, '-')) { $period_start = date('Y-m-d', strtotime($period_start)); MAX_changeStoredValue('period_start', $period_start); } $period_end = htmlspecialchars(MAX_getStoredValue('period_end', date('Y-m-d'))); if (!strstr($period_end, '-')) { $period_end = date('Y-m-d', strtotime($period_end)); MAX_changeStoredValue('period_end', $period_end); } if (!empty($period_start) && !empty($period_end)) { $oStartDate = new Date($period_start); $oEndDate = new Date($period_end); $oDaySpan = new OA_Admin_DaySpan(); $oDaySpan->setSpanDays($oStartDate, $oEndDate); $periodFromDates = $oDaySpan->getPreset(); $_REQUEST['period_preset'] = $periodFromDates; $session['prefs']['GLOBALS']['period_preset'] = $periodFromDates; } else { $_REQUEST['period_preset'] = $periodPreset; $session['prefs']['GLOBALS']['period_preset'] = $periodPreset; } } phpAds_registerGlobal('breakdown', 'entity', 'agency_id', 'advertiser_id', 'clientid', 'campaignid', 'placement_id', 'ad_id', 'bannerid', 'publisher_id', 'affiliateid', 'zone_id', 'zoneid', 'start_date', 'end_date', 'sort', 'asc', 'show', 'expand', 'day', 'plugin', 'peroid_preset', 'tempPeriodPreset', 'GraphFile', 'graphFilter', 'graphFields', 'listorder', 'orderdirection'); $day = htmlspecialchars($day); $listorder = htmlspecialchars($listorder); $orderdirection = htmlspecialchars($orderdirection); if (!($orderdirection == 'up' || $orderdirection == 'down')) { if (stristr($orderdirection, 'down')) { $orderdirection = 'down';