当前位置: 首页>>代码示例>>PHP>>正文


PHP Date::toUTC方法代码示例

本文整理汇总了PHP中Date::toUTC方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::toUTC方法的具体用法?PHP Date::toUTC怎么用?PHP Date::toUTC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Date的用法示例。


在下文中一共展示了Date::toUTC方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setTimeAndReturnUTC

 /**
  * A private method used to return a copy of a Date object after altering its time. It can work using
  * either UTC or the current TZ and eventually converting the result back to UTC.
  *
  * @param Date $oDate
  * @param bool $localTZ
  * @param int $hour
  * @param int $minute
  * @param int $second
  * @return Date
  */
 private function setTimeAndReturnUTC($oDate, $localTZ = false, $hour = 0, $minute = 0, $second = 0)
 {
     $oTz = $this->getTimeZone($localTZ);
     $oDateCopy = new Date($oDate);
     $oDateCopy->setHour($hour);
     $oDateCopy->setMinute($minute);
     $oDateCopy->setSecond($second);
     $oDateCopy->setTZ($oTz);
     $oDateCopy->toUTC();
     return $oDateCopy;
 }
开发者ID:Jaree,项目名称:revive-adserver,代码行数:22,代码来源:Statistics.php

示例2: Date

 /**
  * A method that uses the getAllCampaigns() method to obtain all campaigns
  * that meet the requirements of this class. That is:
  *
  * - The campaign has an expiration date (that is not already passed); and
  * - As a result of the above, the campaign must have an activation date that has
  *   passed, or has the default fake activation date; and
  * - The campaign is active, and has a priority of at least 1; and
  * - The campaign has inventory requirements for the duration of its activation.
  *
  * @access private
  * @return array An array of {@link OX_Maintenance_Priority_Campaign} objects.
  */
 function _getValidCampaigns()
 {
     $conf = $GLOBALS['_MAX']['CONF'];
     // Get current date
     $oDate = new Date($this->_getDate());
     $oDate->toUTC();
     $dateYMD = $oDate->getDate(DATE_FORMAT_ISO);
     $oDbh = OA_DB::singleton();
     $table = $oDbh->quoteIdentifier($conf['table']['prefix'] . $conf['table']['campaigns'], true);
     $aWheres = array(array("{$table}.priority >= 1", 'AND'), array("{$table}.status = " . OA_ENTITY_STATUS_RUNNING, 'AND'), array("{$table}.expire_time >= '{$dateYMD}'", 'AND'), array("({$table}.views > 0 OR {$table}.clicks > 0 OR {$table}.conversions > 0)", 'AND'));
     return $this->_getAllCampaigns($aWheres);
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:25,代码来源:GetRequiredAdImpressionsLifetime.php

示例3: getStats

 function getStats()
 {
     // Set time zone to local
     OA_setTimeZoneLocal();
     $oEnd = new Date();
     $oEnd->setHour(0);
     $oEnd->setMinute(0);
     $oEnd->setSecond(0);
     $oEnd->toUTC();
     $oStart = new Date($oEnd);
     $oStart->subtractSpan(new Date_Span('7-0-0-0'));
     $oStart->toUTC();
     $doDsah = OA_Dal::factoryDO('data_summary_ad_hourly');
     $doDsah->selectAdd();
     $doDsah->selectAdd("DATE_FORMAT(date_time, '%Y-%m-%d') AS day");
     $doDsah->selectAdd('SUM(' . $doDsah->tableName() . '.impressions) AS total_impressions');
     $doDsah->selectAdd('SUM(' . $doDsah->tableName() . '.clicks) AS total_clicks');
     $doDsah->whereAdd("date_time >= '" . $doDsah->escape($oStart->format('%Y-%m-%d %H:%M:%S')) . "'");
     $doDsah->whereAdd("date_time < '" . $doDsah->escape($oEnd->format('%Y-%m-%d %H:%M:%S')) . "'");
     if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
         $doBanners = OA_Dal::factoryDO('banners');
         $doCampaigns = OA_Dal::factoryDO('campaigns');
         $doClients = OA_Dal::factoryDO('clients');
         $doClients->agencyid = OA_Permission::getEntityId();
         $doCampaigns->joinAdd($doClients);
         $doBanners->joinAdd($doCampaigns);
         $doBanners->selectAdd();
         $doBanners->selectAdd("bannerid");
         $doBanners->find();
         $ad_ids = array();
         while ($doBanners->fetch()) {
             $ad_ids[] = $doBanners->bannerid;
         }
         if (empty($ad_ids)) {
             return array();
         }
         $doDsah->whereAdd("ad_id IN (" . implode(",", $ad_ids) . ")");
     }
     $doDsah->groupBy('day');
     $doDsah->orderBy('day');
     $doDsah->find();
     $aStats = array();
     while ($doDsah->fetch()) {
         $row = $doDsah->toArray();
         $aStats[0][date('D', strtotime($row['day']))] = $row['total_impressions'];
         $aStats[1][date('D', strtotime($row['day']))] = $row['total_clicks'];
     }
     return $aStats;
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:49,代码来源:GraphOAP.php

示例4: distributeCampaignImpressions

 /**
  * A method to distribute the calculated required campaign impressions between the campaign's
  * children advertisements. Impression allocation takes in to account ad weight, and the number
  * of operations intervals the ad will be active in given date/time delivery limitations, and
  * the pattern of available impressions for the zone(s) the advertisements are linked to.
  *
  * The calculated ad impressions are written to the temporary table tmp_ad_required_impression
  * for later analysis by the {@link OA_Maintenance_Priority_AdServer_Task_AllocateZoneImpressions}
  * class.
  *
  * @param array $aCampaigns An array of {@link OX_Maintenance_Priority_Campaign} objects which require
  *                          that their total required impressions be distributed between the
  *                          component advertisements.
  */
 function distributeCampaignImpressions($aCampaigns)
 {
     // Create an array for storing required ad impressions
     $aRequiredAdImpressions = array();
     // Get the current operation interval start/end dates
     $aCurrentOperationIntervalDates = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($this->_getDate());
     // For each campaign
     foreach ($aCampaigns as $oCampaign) {
         OA::debug('  - Distributing impression inventory requirements for campaign ID: ' . $oCampaign->id, PEAR_LOG_DEBUG);
         $adsCount = count($oCampaign->aAds);
         OA::debug("    - Campaign has {$adsCount} ads.", PEAR_LOG_DEBUG);
         // Get date object to represent campaign expiration date
         if ($oCampaign->impressionTargetDaily > 0 || $oCampaign->clickTargetDaily > 0 || $oCampaign->conversionTargetDaily > 0) {
             // The campaign has a daily target to meet, so treat the
             // campaign as if it expires at the end of "today", regardless
             // of the existance of any activation or expiration dates that
             // may (or may not) be set for the campaign
             $oCampaignExpiryDate = new Date($this->_getDate());
             $oCampaignExpiryDate->setTZ($this->currentTz);
             $oCampaignExpiryDate->setHour(23);
             $oCampaignExpiryDate->setMinute(59);
             $oCampaignExpiryDate->setSecond(59);
             $oCampaignExpiryDate->toUTC();
             // Unless the campaign has an expiry date and it happens before the end of today
             if (!empty($oCampaign->expireTime)) {
                 if ($oCampaignExpiryDate->after($this->_getDate($oCampaign->expireTime))) {
                     $oCampaignExpiryDate = $this->_getDate($oCampaign->expireTime);
                 }
             }
         } else {
             if (!empty($oCampaign->expireTime) && ($oCampaign->impressionTargetTotal > 0 || $oCampaign->clickTargetTotal > 0 || $oCampaign->conversionTargetTotal > 0)) {
                 // The campaign has an expiration date, and has some kind of
                 // (total) inventory requirement, so treat the campaign as if
                 // it expires at the expiration date/time
                 $oCampaignExpiryDate = $this->_getDate($oCampaign->expireTime);
             } else {
                 // Error! There should not be any other kind of high-priority
                 // campaign in terms of activation/expiration dates and
                 // either (total) inventory requirements or daily targets
                 $message = "- Error calculating the end date for Campaign ID {$oCampaign->id}";
                 OA::debug($message, PEAR_LOG_ERR);
                 continue;
             }
         }
         // Determine number of remaining operation intervals for campaign
         $message = "    - Calculating campaign remaining operation intervals.";
         OA::debug($message, PEAR_LOG_DEBUG);
         $campaignRemainingOperationIntervals = OX_OperationInterval::getIntervalsRemaining($aCurrentOperationIntervalDates['start'], $oCampaignExpiryDate);
         // For all ads in the campaign, determine:
         // - If the ad is capable of delivery in the current operation
         //   interval, or not, based on if it is linked to any zones, and,
         //   if so:
         // - If the ad is capable of delivery in the current operation
         //   interval, or not, based on delivery limitation(s), and if so;
         // - The result of the weight of the ad multiplied by the
         //   number of operation intervals remaining in which the ad
         //   is capable of delivering
         $aAdZones = array();
         $aAdDeliveryLimitations = array();
         $aAdBlockedForCurrentOI = array();
         $aAdWeightRemainingOperationIntervals = array();
         $aInvalidAdIds = array();
         reset($oCampaign->aAds);
         while (list($key, $oAd) = each($oCampaign->aAds)) {
             // Only calculate values for active ads
             if ($oAd->active && $oAd->weight > 0) {
                 $message = "    - Calculating remaining operation intervals for ad ID: {$oAd->id}";
                 OA::debug($message, PEAR_LOG_DEBUG);
                 // Get all zones associated with the ad
                 $aAdsZones = $this->oDal->getAdZoneAssociationsByAds(array($oAd->id));
                 $aAdZones[$oAd->id] = @$aAdsZones[$oAd->id];
                 if (is_null($aAdZones[$oAd->id])) {
                     $aInvalidAdIds[] = $oAd->id;
                     $message = "      - Ad ID {$oAd->id} has no linked zones, will skip...";
                     OA::debug($message, PEAR_LOG_ERR);
                     continue;
                 }
                 // Prepare a delivery limitation object for the ad
                 $aAdDeliveryLimitations[$oAd->id] = new OA_Maintenance_Priority_DeliveryLimitation($oAd->getDeliveryLimitations());
                 // Is the ad blocked from delivering in the current operation interval?
                 $aAdBlockedForCurrentOI[$oAd->id] = $aAdDeliveryLimitations[$oAd->id]->deliveryBlocked($aCurrentOperationIntervalDates['start']);
                 // Determine how many operation intervals remain that the ad can deliver in
                 $adRemainingOperationIntervals = $aAdDeliveryLimitations[$oAd->id]->getActiveAdOperationIntervals($campaignRemainingOperationIntervals, $aCurrentOperationIntervalDates['start'], $oCampaignExpiryDate);
                 // Determine the value of the ad weight multiplied by the number
                 // of operation intervals remaining that the ad can deliver in
                 if ($oAd->weight > 0) {
//.........这里部分代码省略.........
开发者ID:akirsch,项目名称:revive-adserver,代码行数:101,代码来源:GetRequiredAdImpressions.php

示例5: processCampaignForm

/**
 * Processes submit values of campaign form
 *
 * @param OA_Admin_UI_Component_Form $form form to process
 * @return An array of Pear::Error objects if any
 */
function processCampaignForm($form, &$oComponent = null)
{
    $aFields = $form->exportValues();
    if (!empty($aFields['start'])) {
        $oDate = new Date(date('Y-m-d 00:00:00', strtotime($aFields['start'])));
        $oDate->toUTC();
        $activate = $oDate->getDate();
    } else {
        $oDate = new Date(date('Y-m-d 00:00:00'));
        $oDate->toUTC();
        $activate = $oDate->getDate();
    }
    if (!empty($aFields['end'])) {
        $oDate = new Date(date('Y-m-d 23:59:59', strtotime($aFields['end'])));
        $oDate->toUTC();
        $expire = $oDate->getDate();
    } else {
        $expire = null;
    }
    if (empty($aFields['campaignid'])) {
        // The form is submitting a new campaign, so, the ID is not set;
        // set the ID to the string "null" so that the table auto_increment
        // or sequence will be used when the campaign is created
        $aFields['campaignid'] = "null";
    } else {
        // The form is submitting a campaign modification; need to test
        // if any of the banners in the campaign are linked to an email zone,
        // and if so, if the link(s) would still be valid if the change(s)
        // to the campaign were made...
        $dalCampaigns = OA_Dal::factoryDAL('campaigns');
        $aCurrentLinkedEmalZoneIds = $dalCampaigns->getLinkedEmailZoneIds($aFields['campaignid']);
        if (PEAR::isError($aCurrentLinkedEmalZoneIds)) {
            OX::disableErrorHandling();
            $errors[] = PEAR::raiseError($GLOBALS['strErrorDBPlain']);
            OX::enableErrorHandling();
        }
        $errors = array();
        foreach ($aCurrentLinkedEmalZoneIds as $zoneId) {
            $thisLink = Admin_DA::_checkEmailZoneAdAssoc($zoneId, $aFields['campaignid'], $activate, $expire);
            if (PEAR::isError($thisLink)) {
                $errors[] = $thisLink;
                break;
            }
        }
    }
    //correct and check revenue and ecpm
    correctAdnCheckNumericFormField($aFields, $errors, 'revenue', $GLOBALS['strErrorEditingCampaignRevenue']);
    correctAdnCheckNumericFormField($aFields, $errors, 'ecpm', $GLOBALS['strErrorEditingCampaignECPM']);
    if (empty($errors)) {
        //check booked limits values
        // If this is a remnant, ecpm or exclusive campaign with an expiry date, set the target's to unlimited
        if (!empty($expire) && ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_REMNANT || $aFields['campaign_type'] == OX_CAMPAIGN_TYPE_ECPM || $aFields['campaign_type'] == OX_CAMPAIGN_TYPE_CONTRACT_EXCLUSIVE)) {
            $aFields['impressions'] = $aFields['clicks'] = $aFields['conversions'] = -1;
        } else {
            if (!empty($aFields['impr_unlimited']) && $aFields['impr_unlimited'] == 't') {
                $aFields['impressions'] = -1;
            } else {
                if (empty($aFields['impressions']) || $aFields['impressions'] == '-') {
                    $aFields['impressions'] = 0;
                }
            }
            if (!empty($aFields['click_unlimited']) && $aFields['click_unlimited'] == 't') {
                $aFields['clicks'] = -1;
            } else {
                if (empty($aFields['clicks']) || $aFields['clicks'] == '-') {
                    $aFields['clicks'] = 0;
                }
            }
            if (!empty($aFields['conv_unlimited']) && $aFields['conv_unlimited'] == 't') {
                $aFields['conversions'] = -1;
            } else {
                if (empty($aFields['conversions']) || $aFields['conversions'] == '-') {
                    $aFields['conversions'] = 0;
                }
            }
        }
        //pricing model - reset fields not applicable to model to 0,
        //note that in new flow MAX_FINANCE_CPA allows all limits to be set
        if ($aFields['revenue_type'] == MAX_FINANCE_CPM) {
            $aFields['clicks'] = -1;
            $aFields['conversions'] = -1;
        } else {
            if ($aFields['revenue_type'] == MAX_FINANCE_CPC) {
                $aFields['conversions'] = -1;
            } else {
                if ($aFields['revenue_type'] == MAX_FINANCE_MT) {
                    $aFields['impressions'] = -1;
                    $aFields['clicks'] = -1;
                    $aFields['conversions'] = -1;
                }
            }
        }
        //check type and set priority
        if ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_REMNANT) {
//.........这里部分代码省略.........
开发者ID:Apeplazas,项目名称:plazadelatecnologia,代码行数:101,代码来源:campaign-edit.php

示例6: getCampaignDeliveryToday

 /**
  * A method to get the details of the total number of advertisements
  * delivered, today, for a specified placement.
  *
  * @param integer $id The placement ID.
  * @param string $today A "CCYY-MM-DD" formatted representation of today's date.
  * @return array An array of arrays, with each containing the "placement_id",
  *               "sum_requests", "sum_views", "sum_clicks" and "sum_conversions"
  *               for that placement.
  */
 function getCampaignDeliveryToday($id, $today)
 {
     $tz = $this->getTimezoneForCampaign($id);
     $oStartDate = new Date($today);
     $oStartDate->setTZ($tz);
     $oStartDate->setHour(0);
     $oStartDate->setMinute(0);
     $oStartDate->setSecond(0);
     $oStartDate->toUTC();
     $oEndDate = new Date($today);
     $oEndDate->setTZ($tz);
     $oEndDate->setHour(23);
     $oEndDate->setMinute(59);
     $oEndDate->setSecond(59);
     $oEndDate->toUTC();
     $aConf = $GLOBALS['_MAX']['CONF'];
     $query = array();
     $table = $this->_getTablenameUnquoted('campaigns');
     $joinTable1 = $this->_getTablenameUnquoted('banners');
     $joinTable2 = $this->_getTablenameUnquoted('data_intermediate_ad');
     $query['table'] = $table;
     $query['fields'] = array("SUM({$joinTable2}.requests) AS sum_requests", "SUM({$joinTable2}.impressions) AS sum_views", "SUM({$joinTable2}.clicks) AS sum_clicks", "SUM({$joinTable2}.conversions) AS sum_conversions", "{$table}.campaignid AS placement_id");
     $query['wheres'] = array(array("{$table}.campaignid = {$id}", 'AND'));
     $query['joins'] = array(array($joinTable1, "{$table}.campaignid = {$joinTable1}.campaignid"), array($joinTable2, "{$joinTable1}.bannerid = {$joinTable2}.ad_id AND {$joinTable2}.date_time >= '" . $oStartDate->format('%Y-%m-%d %H:%M:%S') . "' AND {$joinTable2}.date_time <= '" . $oEndDate->format('%Y-%m-%d %H:%M:%S') . "'"));
     $query['group'] = "placement_id";
     return $this->_get($query);
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:37,代码来源:Priority.php

示例7: testGetDaysLeftString


//.........这里部分代码省略.........
     $conversions = 1;
     $doDSAH = OA_Dal::factoryDO('data_intermediate_ad');
     $doDSAH->day = $oDate->format('%Y-%m-%d');
     $doDSAH->hour = 10;
     $doDSAH->ad_id = $bannerId;
     $doDSAH->impressions = $impressions;
     $doDSAH->clicks = $clicks;
     $doDSAH->conversions = $conversions;
     $dsahId = DataGenerator::generateOne($doDSAH);
     // Delivered 50 impressions in 1 day. So, expect to take 19 days to
     // deliver remaining 950
     // Delivered 5 clicks in 1 day. So, expect to take 99 days to deliver
     // remaining 495
     // Delivered 1 conversion in 1 day. So, expect to take 9 days to deliver
     // remaining 9
     // The estimated expiration will be calucalated based on impression targets
     // or based on click targets or based on conversion targets (following this order).
     $daysLeft = 19;
     $oExpirationDate = new Date();
     $oExpirationDate->copy($oDate);
     $oExpirationDate->addSeconds($daysLeft * SECONDS_PER_DAY);
     $expected = array('estimatedExpiration' => $GLOBALS['strEstimated'] . ": " . $oExpirationDate->format('%d.%m.%Y') . " (" . $GLOBALS['strDaysLeft'] . ": " . $daysLeft . ")", 'campaignExpiration' => $GLOBALS['strNoExpiration']);
     $actual = $this->oDalCampaigns->getDaysLeftString($campaignId);
     $this->assertEqual($actual, $expected);
     // Case 3
     // Test a campaign with expiration date and without a estimated expiration date
     // Prepare a date 10 days in the future
     $daysLeft = 10;
     $oDate = new Date();
     $oDate->setHour(23);
     $oDate->setMinute(59);
     $oDate->setSecond(59);
     $oDate->addSeconds($daysLeft * SECONDS_PER_DAY);
     $oDate->toUTC();
     // Test an unlimited campaign which expires 10 days in the future
     $doCampaigns = OA_Dal::factoryDO('campaigns');
     $doCampaigns->views = 0;
     $doCampaigns->clicks = 0;
     $doCampaigns->conversions = 0;
     $doCampaigns->expire_time = $oDate->getDate(DATE_FORMAT_ISO);
     $aData = array('reportlastdate' => array('2007-04-03 18:39:45'));
     $dg = new DataGenerator();
     $dg->setData('clients', $aData);
     $aCampaignIds = $dg->generate($doCampaigns, 1, true);
     $campaignId = $aCampaignIds[0];
     // Link a banner to this campaign
     $doBanners = OA_Dal::factoryDO('banners');
     $doBanners->campaignid = $campaignId;
     $doBanners->acls_updated = '2007-04-03 18:39:45';
     $bannerId = DataGenerator::generateOne($doBanners);
     $expected = array('estimatedExpiration' => $GLOBALS['strEstimated'] . ": " . $GLOBALS['strNoExpirationEstimation'], 'campaignExpiration' => $GLOBALS['strExpirationDate'] . ": " . $oDate->format('%d.%m.%Y') . " (" . $GLOBALS['strDaysLeft'] . ": " . $daysLeft . ")");
     $actual = $this->oDalCampaigns->getDaysLeftString($campaignId);
     $this->assertEqual($actual, $expected);
     // Case 4
     // Campaign with expiration date reached
     // Prepare a campaign with expiration date reached
     $daysExpired = 5;
     $oDate = new Date();
     $oDate->setHour(23);
     $oDate->setMinute(59);
     $oDate->setSecond(59);
     $oDate->subtractSeconds($daysExpired * SECONDS_PER_DAY);
     $oDate->toUTC();
     // Test an unlimited campaign which expired 5 days ago
     $doCampaigns = OA_Dal::factoryDO('campaigns');
     $doCampaigns->views = 0;
开发者ID:Jaree,项目名称:revive-adserver,代码行数:67,代码来源:Campaigns.dal.test.php

示例8: manageCampaigns


//.........这里部分代码省略.........
                         $message = '- Exceeded a campaign quota: Deactivating campaign ID ' . "{$aCampaign['campaign_id']}: {$aCampaign['campaign_name']}";
                         OA::debug($message, PEAR_LOG_INFO);
                         $report .= $message . "\n";
                         $doCampaigns = OA_Dal::factoryDO('campaigns');
                         $doCampaigns->campaignid = $aCampaign['campaign_id'];
                         $doCampaigns->find();
                         $doCampaigns->fetch();
                         $doCampaigns->status = OA_ENTITY_STATUS_EXPIRED;
                         $result = $doCampaigns->update();
                         if ($result == false) {
                             return MAX::raiseError($rows, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
                         }
                         phpAds_userlogSetUser(phpAds_userMaintenance);
                         phpAds_userlogAdd(phpAds_actionDeactiveCampaign, $aCampaign['campaign_id']);
                     } else {
                         // The campaign didn't have a diable reason,
                         // it *might* possibly be diabled "soon"...
                         $canExpireSoon = true;
                     }
                 }
             }
             // Does the campaign need to be disabled due to the date?
             if ($aCampaign['end'] != OA_Dal::noDateValue()) {
                 // The campaign has a valid end date, stored in the timezone of the advertiser;
                 // create an end date in the advertiser's timezone, set the time, and then
                 // convert to UTC so that it can be compared with the MSE run time, which is
                 // in UTC
                 $aAdvertiserPrefs = OA_Preferences::loadAccountPreferences($aCampaign['advertiser_account_id'], true);
                 $oTimezone = new Date_Timezone($aAdvertiserPrefs['timezone']);
                 $oEndDate = new Date();
                 $oEndDate->convertTZ($oTimezone);
                 $oEndDate->setDate($aCampaign['end'] . ' 23:59:59');
                 // Campaigns end at the end of the day
                 $oEndDate->toUTC();
                 if ($oDate->after($oEndDate)) {
                     // The end date has been passed; disable the campaign
                     $disableReason |= OX_CAMPAIGN_DISABLED_DATE;
                     $message = "- Passed campaign end time of '{$aCampaign['end']} 23:59:59 {$aAdvertiserPrefs['timezone']} (" . $oEndDate->format('%Y-%m-%d %H:%M:%S') . ' ' . $oEndDate->tz->getShortName() . ")': Deactivating campaign ID {$aCampaign['campaign_id']}: {$aCampaign['campaign_name']}";
                     OA::debug($message, PEAR_LOG_INFO);
                     $report .= $message . "\n";
                     $doCampaigns = OA_Dal::factoryDO('campaigns');
                     $doCampaigns->campaignid = $aCampaign['campaign_id'];
                     $doCampaigns->find();
                     $doCampaigns->fetch();
                     $doCampaigns->status = OA_ENTITY_STATUS_EXPIRED;
                     $result = $doCampaigns->update();
                     if ($result == false) {
                         return MAX::raiseError($rows, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
                     }
                     phpAds_userlogSetUser(phpAds_userMaintenance);
                     phpAds_userlogAdd(phpAds_actionDeactiveCampaign, $aCampaign['campaign_id']);
                 } else {
                     // The campaign wasn't disabled based on the end
                     // date, to it *might* possibly be disabled "soon"...
                     $canExpireSoon = true;
                 }
             }
             if ($disableReason) {
                 // The campaign was disabled, so send the appropriate
                 // message to the campaign's contact
                 $query = "\n                        SELECT\n                            bannerid AS advertisement_id,\n                            description AS description,\n                            alt AS alt,\n                            url AS url\n                        FROM\n                            " . $this->oDbh->quoteIdentifier($aConf['table']['prefix'] . $aConf['table']['banners'], true) . "\n                        WHERE\n                            campaignid = {$aCampaign['campaign_id']}";
                 OA::debug("- Getting the advertisements for campaign ID {$aCampaign['campaign_id']}", PEAR_LOG_DEBUG);
                 $rsResultAdvertisement = $this->oDbh->query($query);
                 if (PEAR::isError($rsResultAdvertisement)) {
                     return MAX::raiseError($rsResultAdvertisement, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
                 }
开发者ID:villos,项目名称:tree_admin,代码行数:67,代码来源:Statistics.php

示例9: foreach

 // Connection was changed to conversion (or conversion was changed to connection)
 $aConVariables = Admin_DA::fromCache('getConnectionVariables', $conversionId);
 // Sum up basket values
 $basketValue = 0;
 $numItems = 0;
 foreach ($aConVariables as $conVariable) {
     if ($conVariable['purpose'] == 'basket_value') {
         $basketValue += $conVariable['value'];
     } elseif ($conVariable['purpose'] == 'num_items') {
         $numItems += $conVariable['value'];
     }
 }
 // Get day, $hour and operation interval
 $dateTime = $aConversions[$conversionId]['date_time'];
 $oConnectionDate = new Date($dateTime);
 $oConnectionDate->toUTC();
 $optIntID = OX_OperationInterval::convertDateToOperationIntervalID($oConnectionDate);
 $opDay = $oConnectionDate->format('%Y-%m-%d');
 $opHour = $oConnectionDate->format('%H');
 // Get ad_id, creative_id and zone_id
 $ad_id = $aConversions[$conversionId]['ad_id'];
 $creative_id = $aConversions[$conversionId]['creative_id'];
 $zone_id = $aConversions[$conversionId]['zone_id'];
 $operation = null;
 // If conversion was changed to connection
 if ($aConversions[$conversionId]['connection_status'] == MAX_CONNECTION_STATUS_APPROVED) {
     // Substract conversion from "data_intermediate_ad" and from "data_summary_ad_hourly"
     // and remove $connectionBasketValue from total_basket_value
     $operation = '-';
 }
 // If connection was changed to conversion
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:31,代码来源:connections-modify.php

示例10: Date

 /**
  * A method to check if the campaign is expired
  *
  * @return bool
  */
 function _isExpired()
 {
     static $oServiceLocator;
     if (!empty($this->expire_time) && $this->expire_time != OX_DATAOBJECT_NULL) {
         if (!isset($oServiceLocator)) {
             $oServiceLocator =& OA_ServiceLocator::instance();
         }
         if (!($oNow = $oServiceLocator->get('now'))) {
             $oNow = new Date();
         }
         $oNow->toUTC();
         $oExpire = new Date($this->expire_time);
         $oExpire->setTZbyID('UTC');
         if ($oNow->after($oExpire)) {
             return true;
         }
     }
     return false;
 }
开发者ID:Apeplazas,项目名称:plazadelatecnologia,代码行数:24,代码来源:Campaigns.php

示例11: mergeConversions

 /**
  * Add the fields needed for conversions stats
  *
  * @param array Row of stats
  * @param string Invocated method
  * @param array Parameter array
  * @param array Empty row
  */
 function mergeConversions(&$aRows, $method, $aParams, $emptyRow)
 {
     $conf = $GLOBALS['_MAX']['CONF'];
     $aParams['include'] = isset($aParams['include']) ? array_flip($aParams['include']) : array();
     $aParams['exclude'] = isset($aParams['exclude']) ? array_flip($aParams['exclude']) : array();
     // Primary key
     if ($method == 'getEntitiesStats') {
         if (!isset($aParams['exclude']['ad_id']) && !isset($aParams['exclude']['zone_id'])) {
             $aFields[] = "CONCAT(diac.ad_id, '_', diac.zone_id) AS pkey";
         } elseif (!isset($aParams['exclude']['ad_id'])) {
             $aFields[] = "diac.ad_id AS pkey";
         } else {
             $aFields[] = "diac.zone_id AS pkey";
         }
     } else {
         $aParams['exclude']['ad_id'] = true;
         $aParams['exclude']['zone_id'] = true;
         if ($method == 'getDayHistory') {
             $tzMethod = 'format';
             $tzArgs = array('%Y-%m-%d');
         } elseif ($method == 'getMonthHistory') {
             $tzMethod = 'format';
             $tzArgs = array('%Y-%m');
         } elseif ($method == 'getDayOfWeekHistory') {
             $tzMethod = 'getDayOfWeek';
             $tzArgs = array();
         } elseif ($method == 'getHourHistory') {
             $tzMethod = 'getHour';
             $tzArgs = array();
         }
         $aFields[] = "DATE_FORMAT(diac.tracker_date_time, '%Y-%m-%d %H:00:00') AS day_and_hour";
         $aGroupBy = array('day_and_hour');
     }
     $aFrom = array("{$conf['table']['prefix']}{$conf['table']['data_intermediate_ad_connection']} diac");
     $aWhere = array("diac.inside_window = 1");
     $aFields[] = "SUM(IF(diac.connection_status = " . MAX_CONNECTION_STATUS_APPROVED . " AND diac.connection_action = " . MAX_CONNECTION_AD_IMPRESSION . ",1,0)) AS sum_conversions_" . MAX_CONNECTION_AD_IMPRESSION;
     $aFields[] = "SUM(IF(diac.connection_status = " . MAX_CONNECTION_STATUS_APPROVED . " AND diac.connection_action = " . MAX_CONNECTION_AD_CLICK . ",1,0)) AS sum_conversions_" . MAX_CONNECTION_AD_CLICK;
     $aFields[] = "SUM(IF(diac.connection_status = " . MAX_CONNECTION_STATUS_APPROVED . " AND diac.connection_action = " . MAX_CONNECTION_AD_ARRIVAL . ",1,0)) AS sum_conversions_" . MAX_CONNECTION_AD_ARRIVAL;
     $aFields[] = "SUM(IF(diac.connection_status = " . MAX_CONNECTION_STATUS_APPROVED . " AND diac.connection_action = " . MAX_CONNECTION_MANUAL . ",1,0)) AS sum_conversions_" . MAX_CONNECTION_MANUAL;
     $aFields[] = "SUM(IF(diac.connection_status = " . MAX_CONNECTION_STATUS_APPROVED . ",1,0)) AS sum_conversions";
     $aFields[] = "SUM(IF(diac.connection_status = " . MAX_CONNECTION_STATUS_PENDING . ",1,0)) AS sum_conversions_pending";
     if (!empty($aParams['day_begin']) && !empty($aParams['day_end'])) {
         $oStartDate = new Date("{$aParams['day_begin']} 00:00:00");
         $oEndDate = new Date("{$aParams['day_end']} 23:59:59");
         $oStartDate->toUTC();
         $oEndDate->toUTC();
         $aWhere[] = "diac.tracker_date_time BETWEEN '" . $oStartDate->format('%Y-%m-%d %H:%M:%S') . "'" . " AND '" . $oEndDate->format('%Y-%m-%d %H:%M:%S') . "'";
     }
     if (!empty($aParams['agency_id'])) {
         $aFrom['b'] = "JOIN {$conf['table']['prefix']}{$conf['table']['banners']} b ON (b.bannerid = diac.ad_id)";
         $aFrom['m'] = "JOIN {$conf['table']['prefix']}{$conf['table']['campaigns']} m ON (m.campaignid = b.campaignid)";
         $aFrom['c'] = "JOIN {$conf['table']['prefix']}{$conf['table']['clients']} c ON (c.clientid = m.clientid)";
         $aFrom['z'] = "LEFT JOIN {$conf['table']['prefix']}{$conf['table']['zones']} z ON (z.zoneid = diac.zone_id)";
         $aFrom['p'] = "LEFT JOIN {$conf['table']['prefix']}{$conf['table']['affiliates']} p ON (p.affiliateid = z.affiliateid AND p.agencyid = '{$aParams['agency_id']}')";
         $aWhere[] = "c.agencyid = '{$aParams['agency_id']}'";
     }
     if (!empty($aParams['advertiser_id']) || isset($aParams['include']['advertiser_id'])) {
         $aFrom['b'] = "JOIN {$conf['table']['prefix']}{$conf['table']['banners']} b ON (b.bannerid = diac.ad_id)";
         $aFrom['m'] = "JOIN {$conf['table']['prefix']}{$conf['table']['campaigns']} m ON (m.campaignid = b.campaignid)";
         if (!empty($aParams['advertiser_id'])) {
             $aWhere[] = "m.clientid = '{$aParams['advertiser_id']}'";
         }
         if (isset($aParams['include']['advertiser_id']) && !isset($aParams['exclude']['advertiser_id'])) {
             $aFields[] = "m.clientid AS advertiser_id";
             $aGroupBy[] = "advertiser_id";
         }
     }
     if (!empty($aParams['placement_id']) || isset($aParams['include']['placement_id'])) {
         $aFrom['b'] = "JOIN {$conf['table']['prefix']}{$conf['table']['banners']} b ON (b.bannerid = diac.ad_id)";
         if (!empty($aParams['placement_id'])) {
             $aWhere[] = "b.campaignid = '{$aParams['placement_id']}'";
         }
         if (isset($aParams['include']['placement_id']) && !isset($aParams['exclude']['placement_id'])) {
             $aFields[] = "b.campaignid AS placement_id";
             $aGroupBy[] = "placement_id";
         }
     }
     if (!empty($aParams['publisher_id']) || isset($aParams['include']['publisher_id'])) {
         $aFrom['z'] = "JOIN {$conf['table']['prefix']}{$conf['table']['zones']} z ON (z.zoneid = diac.zone_id)";
         if (!empty($aParams['publisher_id'])) {
             $aWhere[] = "z.affiliateid = '{$aParams['publisher_id']}'";
         }
         if (isset($aParams['include']['publisher_id']) && !isset($aParams['exclude']['publisher_id'])) {
             $aFields[] = "z.affiliateid AS publisher_id";
             $aGroupBy[] = "publisher_id";
         }
     }
     if (!empty($aParams['ad_id'])) {
         $aWhere[] = "diac.ad_id = '{$aParams['ad_id']}'";
     }
     if (!isset($aParams['exclude']['ad_id'])) {
         $aFields[] = "diac.ad_id AS ad_id";
//.........这里部分代码省略.........
开发者ID:hostinger,项目名称:revive-adserver,代码行数:101,代码来源:Delivery.php

示例12: Date

 function test_getAuditLogForAuditWidget()
 {
     $dllAuditPartialMock = new PartialMockOA_Dll_Audit($this);
     $oSpanDay = new Date_Span('1-0-0-0');
     $oDate = new Date(OA::getNow());
     $oDate->toUTC();
     $oDate->subtractSpan(new Date_Span('8-0-0-0'));
     // add 1 hour to make sure that the test passes even if it takes some time
     $oDate->addSpan(new Date_Span('0-1-0-0'));
     // record 1 - more than 7 days old so should not be returned
     $oAudit = OA_Dal::factoryDO('audit');
     $oAudit->account_id = 1;
     $oAudit->context = 'campaigns';
     $oAudit->contextid = 1;
     $oAudit->parentid = null;
     $oAudit->username = 'user1';
     $oAudit->actionid = OA_AUDIT_ACTION_UPDATE;
     $oAudit->updated = $oDate->getDate();
     $aDetails['campaignname'] = 'Campaign 1';
     $aDetails['status'] = OA_ENTITY_STATUS_EXPIRED;
     $oAudit->details = serialize($aDetails);
     $oAudit->insert();
     // record 2
     $oDate->addSpan($oSpanDay);
     $oAudit->updated = $oDate->getDate();
     $oAudit->username = 'user2';
     $aDetails['status'] = OA_ENTITY_STATUS_RUNNING;
     $oAudit->details = serialize($aDetails);
     $idAudit = $oAudit->insert();
     $aExpect[$idAudit] = $oAudit->toArray();
     $aExpect[$idAudit]['details'] = $aDetails;
     // record 3
     $oDate->addSpan($oSpanDay);
     $oAudit->updated = $oDate->getDate();
     $oAudit->username = 'user3';
     $aDetails['status'] = OA_ENTITY_STATUS_PAUSED;
     $oAudit->details = serialize($aDetails);
     $idAudit = $oAudit->insert();
     $aExpect[$idAudit] = $oAudit->toArray();
     $aExpect[$idAudit]['details'] = $aDetails;
     // record 4
     $oDate->addSpan($oSpanDay);
     $oAudit->contextid = 2;
     $oAudit->updated = $oDate->getDate();
     $aDetails['campaignname'] = 'Campaign 2';
     $aDetails['status'] = OA_ENTITY_STATUS_RUNNING;
     $oAudit->details = serialize($aDetails);
     $idAudit = $oAudit->insert();
     $aExpect[$idAudit] = $oAudit->toArray();
     $aExpect[$idAudit]['details'] = $aDetails;
     // record 5
     $oDate->addSpan($oSpanDay);
     $oAudit->updated = $oDate->getDate();
     $oAudit->username = 'user2';
     $aDetails['status'] = OA_ENTITY_STATUS_EXPIRED;
     $oAudit->details = serialize($aDetails);
     $idAudit = $oAudit->insert();
     $aExpect[$idAudit] = $oAudit->toArray();
     $aExpect[$idAudit]['details'] = $aDetails;
     // record 6
     $oDate->addSpan($oSpanDay);
     $oAudit->account_id = 2;
     $oAudit->contextid = 3;
     $oAudit->username = 'user1';
     $oAudit->updated = $oDate->getDate();
     $aDetails['campaignname'] = 'Campaign 3';
     $aDetails['status'] = OA_ENTITY_STATUS_RUNNING;
     $oAudit->details = serialize($aDetails);
     $idAudit = $oAudit->insert();
     $aExpect[$idAudit] = $oAudit->toArray();
     $aExpect[$idAudit]['details'] = $aDetails;
     // record 7 - is a maintenance audit rec so should not be returned
     $oDate->addSpan($oSpanDay);
     $oAudit->username = 'Maintenance';
     $oAudit->contextid = 1;
     $oAudit->updated = $oDate->getDate();
     $aDetails['campaignname'] = 'Campaign 1';
     $aDetails['status'] = OA_ENTITY_STATUS_RUNNING;
     $oAudit->details = serialize($aDetails);
     $oAudit->insert();
     $aParams = array();
     $aResults = $dllAuditPartialMock->getAuditLogForAuditWidget($aParams);
     $this->assertIsA($aResults, 'array');
     $this->assertEqual(count($aResults), 5);
     foreach ($aResults as $i => $aResRow) {
         $aExpRow = $aExpect[$aResRow['auditid']];
         $this->assertEqual($aResRow['auditid'], $aExpRow['auditid']);
         $this->assertEqual($aResRow['actionid'], $aExpRow['actionid']);
         $this->assertEqual($aResRow['context'], $dllAuditPartialMock->getContextDescription($aExpRow['context']));
         $this->assertEqual($aResRow['contextid'], $aExpRow['contextid']);
         $this->assertEqual($aResRow['parentid'], $aExpRow['parentid']);
         $this->assertEqual($aResRow['username'], $aExpRow['username']);
         $this->assertEqual($aResRow['details']['campaignname'], $aExpRow['details']['campaignname']);
         $this->assertEqual($aResRow['details']['status'], $aExpRow['details']['status']);
         $oDate = new Date($aResRow['updated']);
         $oDate->toUTC();
         $this->assertEqual($oDate->getDate(), $aExpRow['updated']);
     }
     // Check that the account_id filter is working
     $aParams = array('account_id' => 2);
//.........这里部分代码省略.........
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:101,代码来源:Audit.dll.test.php

示例13: Date

 function _convertDate($date, $tz, $end)
 {
     if (empty($date) || $date == '0000-00-00') {
         return null;
     }
     $oDate = new Date($date);
     $oDate->setTZByID($tz);
     if ($end) {
         $oDate->setHour(23);
         $oDate->setMinute(59);
         $oDate->setSecond(59);
     }
     $oDate->toUTC();
     return $oDate->getDate(DATE_FORMAT_ISO);
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:15,代码来源:migration_tables_core_609.php

示例14: getWeeklyReport

 /**
  * Returns the data used by the weekly report.
  *
  * @access  public
  * @param   string $usr_id The ID of the user this report is for.
  * @param   string The start date of this report.
  * @param   string The end date of this report.
  * @param   boolean If closed issues should be separated from other issues.
  * @return  array An array of data containing all the elements of the weekly report.
  */
 function getWeeklyReport($usr_id, $start, $end, $separate_closed = false)
 {
     $usr_id = Misc::escapeInteger($usr_id);
     // figure out timezone
     $user_prefs = Prefs::get($usr_id);
     $tz = @$user_prefs["timezone"];
     $start_dt = new Date();
     $end_dt = new Date();
     // set timezone to that of user.
     $start_dt->setTZById($tz);
     $end_dt->setTZById($tz);
     // set the dates in the users time zone
     $start_dt->setDate($start . " 00:00:00");
     $end_dt->setDate($end . " 23:59:59");
     // convert time to GMT
     $start_dt->toUTC();
     $end_dt->toUTC();
     $start_ts = $start_dt->getDate();
     $end_ts = $end_dt->getDate();
     $time_tracking = Time_Tracking::getSummaryByUser($usr_id, $start_ts, $end_ts);
     // replace spaces in index with _ and calculate total time
     $total_time = 0;
     foreach ($time_tracking as $category => $data) {
         unset($time_tracking[$category]);
         $time_tracking[str_replace(" ", "_", $category)] = $data;
         $total_time += $data["total_time"];
     }
     // get count of issues assigned in week of report.
     $stmt = "SELECT\n                    COUNT(*)\n                 FROM\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue,\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user,\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status\n                 WHERE\n                    iss_id = isu_iss_id AND\n                    iss_sta_id = sta_id AND\n                    isu_usr_id = {$usr_id} AND\n                    isu_assigned_date BETWEEN '{$start_ts}' AND '{$end_ts}'";
     $newly_assigned = $GLOBALS["db_api"]->dbh->getOne($stmt);
     if (PEAR::isError($newly_assigned)) {
         Error_Handler::logError(array($newly_assigned->getMessage(), $newly_assigned->getDebugInfo()), __FILE__, __LINE__);
     }
     $email_count = array("associated" => Support::getSentEmailCountByUser($usr_id, $start_ts, $end_ts, true), "other" => Support::getSentEmailCountByUser($usr_id, $start_ts, $end_ts, false));
     $data = array("start" => str_replace('-', '.', $start), "end" => str_replace('-', '.', $end), "user" => User::getDetails($usr_id), "group_name" => Group::getName(User::getGroupID($usr_id)), "issues" => History::getTouchedIssuesByUser($usr_id, $start_ts, $end_ts, $separate_closed), "status_counts" => History::getTouchedIssueCountByStatus($usr_id, $start_ts, $end_ts), "new_assigned_count" => $newly_assigned, "time_tracking" => $time_tracking, "email_count" => $email_count, "phone_count" => Phone_Support::getCountByUser($usr_id, $start_ts, $end_ts), "note_count" => Note::getCountByUser($usr_id, $start_ts, $end_ts), "total_time" => Misc::getFormattedTime($total_time, false));
     return $data;
 }
开发者ID:juliogallardo1326,项目名称:proc,代码行数:47,代码来源:class.report.php

示例15: getAuditLogForAuditWidget

 /**
  * requires permission checks
  *
  * @param array $aParam
  * @return array
  */
 function getAuditLogForAuditWidget($aParam = array())
 {
     $oAudit = OA_Dal::factoryDO('audit');
     // Apply account level filters
     if (!empty($aParam['account_id'])) {
         $oAudit->account_id = $aParam['account_id'];
     }
     if (!empty($aParam['advertiser_account_id'])) {
         $oAudit->advertiser_account_id = $aParam['advertiser_account_id'];
     }
     if (!empty($aParam['website_account_id'])) {
         $oAudit->website_account_id = $aParam['website_account_id'];
     }
     $oDate = new Date();
     $oDate->toUTC();
     $oDate->subtractSpan(new Date_Span('7-0-0-0'));
     $oAudit->whereAdd("username <> 'Maintenance'");
     $oAudit->whereAdd('parentid IS NULL');
     $oAudit->whereAdd("updated >= " . DBC::makeLiteral($oDate->format('%Y-%m-%d %H:%M:%S')));
     $oAudit->orderBy('auditid DESC');
     $oAudit->limit(0, 5);
     $numRows = $oAudit->find();
     $oNow = new Date();
     $aResult = array();
     while ($oAudit->fetch()) {
         $aAudit = $oAudit->toArray();
         $oDate = new Date($aAudit['updated']);
         $oDate->setTZbyID('UTC');
         $oDate->convertTZ($oNow->tz);
         $aAudit['updated'] = $oDate->format('%Y-%m-%d %H:%M:%S');
         $aAudit['details'] = unserialize($aAudit['details']);
         $aAudit['context'] = $this->getContextDescription($aAudit['context']);
         $aResult[] = $aAudit;
     }
     return $aResult;
 }
开发者ID:hostinger,项目名称:revive-adserver,代码行数:42,代码来源:Audit.php


注:本文中的Date::toUTC方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。