Example #1
0
 private function process_contract_zone_tag($config, $banner_request, $linked_banner_to_ad_zone_list)
 {
     /*
      * Add publisher statistics logging
      */
     $banner_request["demand_banner_id"] = $this->get_banner_id_from_display_probability($linked_banner_to_ad_zone_list);
     $AdCampaignBannerFactory = \_factory\AdCampaignBanner::get_instance();
     $params = array();
     $params["AdCampaignBannerID"] = $banner_request["demand_banner_id"];
     $AdCampaignBanner = $AdCampaignBannerFactory->get_row_cached($config, $params);
     if ($AdCampaignBanner != null) {
         $cpm_price = $AdCampaignBanner->BidAmount;
     } else {
         $cpm_price = 0;
     }
     $ContractPublisherZoneHourlyImpressions = new \model\ContractPublisherZoneHourlyImpressions();
     $ContractPublisherZoneHourlyImpressions->AdCampaignBannerID = $banner_request["demand_banner_id"];
     $ContractPublisherZoneHourlyImpressions->PublisherAdZoneID = $banner_request["publisher_banner_id"];
     $ContractPublisherZoneHourlyImpressions->Impressions = 1;
     $ContractPublisherZoneHourlyImpressions->SpendTotalGross = floatval($cpm_price) / 1000;
     $ContractPublisherZoneHourlyImpressions->SpendTotalNet = $ContractPublisherZoneHourlyImpressions->SpendTotalGross;
     \util\CachedStatsWrites::incrementContractPublisherZoneHourlyImpressionsCached($config, $ContractPublisherZoneHourlyImpressions);
     $this->process_demand_tag($config, $banner_request);
 }
Example #2
0
 public function incrementBuySideHourlyImpressionsByTLDCached($config, $banner_id, $tld)
 {
     $params = array();
     $params["AdCampaignBannerID"] = $banner_id;
     $params["PublisherTLD"] = $tld;
     $class_dir_name = 'BuySideHourlyImpressionsByTLD';
     $cached_key_exists = \util\CacheSql::does_cached_write_exist_apc($config, $params, $class_dir_name);
     if ($cached_key_exists) {
         // increment bucket
         \util\CachedStatsWrites::increment_cached_write_result_int_apc($config, $params, $class_dir_name, 1);
     } else {
         // get value sum from apc
         $current = \util\CacheSql::get_cached_read_result_apc($config, $params, $class_dir_name);
         if ($current != null) {
             $bucket_value = $current["value"];
             // write out value
             $this->incrementBuySideHourlyImpressionsByTLD($banner_id, $tld, $bucket_value);
         }
         // delete existing key - reset bucket
         \util\CacheSql::delete_cached_write_apc($config, $params, $class_dir_name);
         // increment bucket
         \util\CachedStatsWrites::increment_cached_write_result_int_apc($config, $params, $class_dir_name, 1);
     }
 }
Example #3
0
 public function process_rtb_ping_statistics(&$AuctionPopo)
 {
     /*
      * COLLECT STATS FOR THE BID LOGS
      */
     $bids_total = 0;
     $bids_won = 0;
     $bids_lost = 0;
     $bid_errors = 0;
     $spend_total_gross = 0;
     $spend_total_private_exchange_gross = 0;
     $spend_total_net = 0;
     $error_list = array();
     foreach ($this->RTBPingerList as $RTBPinger) {
         $SellSidePartnerHourlyBids = new \model\SellSidePartnerHourlyBids();
         $SellSidePartnerHourlyBids->SellSidePartnerID = $RTBPinger->partner_id;
         $SellSidePartnerHourlyBids->PublisherAdZoneID = $this->PublisherAdZoneID;
         $SellSidePartnerHourlyBids->BidsWonCounter = 0;
         $SellSidePartnerHourlyBids->BidsLostCounter = 0;
         $SellSidePartnerHourlyBids->BidsErrorCounter = 0;
         $SellSidePartnerHourlyBids->SpendTotalGross = 0;
         $SellSidePartnerHourlyBids->SpendTotalPrivateExchangeGross = 0;
         $SellSidePartnerHourlyBids->SpendTotalNet = 0;
         if ($RTBPinger->ping_success == true) {
             $bids_total += $RTBPinger->total_bids;
             if ($RTBPinger->won_auction === true) {
                 $bids_won += $RTBPinger->won_bids;
                 $bids_lost += $RTBPinger->lost_bids;
                 $SellSidePartnerHourlyBids->BidsWonCounter = $RTBPinger->won_bids;
                 if ($AuctionPopo->is_second_price_auction === true) {
                     $SellSidePartnerHourlyBids->SpendTotalGross = floatval($AuctionPopo->second_price_winning_bid_price) / 1000;
                     $SellSidePartnerHourlyBids->SpendTotalPrivateExchangeGross = floatval($AuctionPopo->second_price_winning_adjusted_amount_before_private_exchange_markup_bid_price) / 1000;
                 } else {
                     $SellSidePartnerHourlyBids->SpendTotalGross = floatval($RTBPinger->winning_bid) / 1000;
                     $SellSidePartnerHourlyBids->SpendTotalPrivateExchangeGross = floatval($RTBPinger->winning_amount_before_private_exchange_markup_bid) / 1000;
                 }
                 $spend_total_gross = $SellSidePartnerHourlyBids->SpendTotalGross;
                 $spend_total_private_exchange_gross = $SellSidePartnerHourlyBids->SpendTotalPrivateExchangeGross;
                 // Subtract Global Ad Exchange Publisher markup
                 $mark_down = floatval($SellSidePartnerHourlyBids->SpendTotalGross) * floatval($this->publisher_markup_rate);
                 $adusted_amount_before_private_exchange_markup = floatval($SellSidePartnerHourlyBids->SpendTotalGross) - floatval($mark_down);
                 $SellSidePartnerHourlyBids->SpendTotalPrivateExchangeGross = $adusted_amount_before_private_exchange_markup;
                 $spend_total_private_exchange_gross = $SellSidePartnerHourlyBids->SpendTotalPrivateExchangeGross;
                 // Subtract Private Ad Exchange Publisher markup
                 $mark_down_private_exchange = floatval($SellSidePartnerHourlyBids->SpendTotalPrivateExchangeGross) * floatval($this->private_exchange_publisher_markup_rate);
                 $adusted_amount = floatval($adusted_amount_before_private_exchange_markup) - floatval($mark_down_private_exchange);
                 $SellSidePartnerHourlyBids->SpendTotalNet = $adusted_amount;
                 $spend_total_net = $SellSidePartnerHourlyBids->SpendTotalNet;
             } else {
                 $bids_lost += $RTBPinger->lost_bids;
                 $SellSidePartnerHourlyBids->BidsLostCounter = $RTBPinger->lost_bids;
             }
         } else {
             $bid_errors++;
             $SellSidePartnerHourlyBids->BidsErrorCounter = 1;
             $error_list[] = "PartnerID: " . $RTBPinger->partner_id . " Error Message: " . $RTBPinger->ping_error_message;
         }
         \util\CachedStatsWrites::incrementSellSideBidsCounterCached($this->config, $SellSidePartnerHourlyBids);
     }
     $PublisherHourlyBids = new \model\PublisherHourlyBids();
     $PublisherHourlyBids->PublisherAdZoneID = $this->PublisherAdZoneID;
     $PublisherHourlyBids->AuctionCounter = 1;
     $PublisherHourlyBids->BidsWonCounter = $bids_won;
     $PublisherHourlyBids->BidsLostCounter = $bids_lost;
     $PublisherHourlyBids->BidsErrorCounter = $bid_errors;
     $PublisherHourlyBids->SpendTotalGross = $spend_total_gross;
     $PublisherHourlyBids->SpendTotalPrivateExchangeGross = $spend_total_private_exchange_gross;
     $PublisherHourlyBids->SpendTotalNet = $spend_total_net;
     if ($AuctionPopo->ImpressionType == "video" && $AuctionPopo->auction_was_won && \util\ParseHelper::isVastURL($AuctionPopo->winning_ad_tag) === true) {
         /*
          * If this is a video impression record the winning auction 
          * information when the VASTAdTagURI is loaded from the 
          * publisher's video player.
          */
         $PublisherHourlyBidsCopy = new \model\PublisherHourlyBids();
         $PublisherHourlyBidsCopy->PublisherAdZoneID = $this->PublisherAdZoneID;
         $PublisherHourlyBidsCopy->AuctionCounter = 0;
         $PublisherHourlyBidsCopy->BidsWonCounter = 1;
         $PublisherHourlyBidsCopy->BidsLostCounter = 0;
         $PublisherHourlyBidsCopy->BidsErrorCounter = 0;
         $PublisherHourlyBidsCopy->SpendTotalGross = $spend_total_gross;
         $PublisherHourlyBidsCopy->SpendTotalPrivateExchangeGross = $spend_total_private_exchange_gross;
         $PublisherHourlyBidsCopy->SpendTotalNet = $spend_total_net;
         $AuctionPopo->vast_publisher_imp_obj = $PublisherHourlyBidsCopy;
         /*
          * Record the general impression auction information here now.
          */
         $PublisherHourlyBids->BidsWonCounter = 0;
         $PublisherHourlyBids->SpendTotalGross = 0;
         $PublisherHourlyBids->SpendTotalPrivateExchangeGross = 0;
         $PublisherHourlyBids->SpendTotalNet = 0;
     }
     \util\CachedStatsWrites::incrementPublisherBidsCounterCached($this->config, $PublisherHourlyBids);
     $log_header = "----------------------------------------------------------------\n";
     $log_header .= "NEW BID RESPONSE, WEBSITE: " . $this->WebDomain . ", PubZoneID: " . $this->PublisherAdZoneID . ", AD: " . $this->AdName;
     \rtbsellv22\RtbSellV22Logger::get_instance()->log[] = $log_header;
     $log_header = "NEW BID RESPONSE, WEBSITE: " . $this->WebDomain . ", PubZoneID: " . $this->PublisherAdZoneID . ", AD: " . $this->AdName;
     \rtbsellv22\RtbSellV22Logger::get_instance()->min_log[] = $log_header;
     $log = "----------------------------------------------------------------";
     $log .= "\nDate: " . date('m-d-Y H:i:s');
     $log .= "\nTotal Bids: " . $bids_total;
     $log .= "\nBids Won: " . $bids_won;
     $log .= "\nBids Lost: " . $bids_lost;
     $log .= "\nBid Errors: " . $bid_errors;
     $log .= "\nError List: " . implode(",", $error_list);
     foreach ($this->skipped_partner_list as $skipped_partner) {
         $log .= "\nSkipped Partner: " . $skipped_partner;
     }
     $log .= "\n----------------------------------------------------------------\n";
     \rtbsellv22\RtbSellV22Logger::get_instance()->log[] = $log;
     \rtbsellv22\RtbSellV22Logger::get_instance()->min_log[] = $log;
 }
Example #4
0
 private function track_video_impression($config, $banner_request)
 {
     $error_message = "Error";
     $ap_param = $this->getRequest()->getQuery('ap');
     $pp_param = $this->getRequest()->getQuery('pp');
     if (empty($ap_param) || empty($pp_param)) {
         die($error_message);
     }
     $encryption_key = $config['settings']['rtb']['encryption_key'];
     $ap = $this->decrypt_vast_auction_params($encryption_key, $ap_param);
     if (empty($ap)) {
         die($error_message);
     }
     $pp = $this->decrypt_vast_auction_params($encryption_key, $pp_param);
     if (empty($ap) || !$pp instanceof \model\PublisherHourlyBids) {
         die($error_message);
     }
     $minutes_to_expire = 5;
     if (intval($ap["auction_timestamp"]) < time() - 60 * $minutes_to_expire) {
         // timestamp token expired
         die($error_message);
     }
     \util\CachedStatsWrites::incrementPublisherBidsCounterCached($config, $pp);
     echo 'tracking_id: ' . $pp->PublisherAdZoneID . '_' . md5($pp_param . $ap_param);
     exit;
 }
 public function incrementBuySideHourlyImpressionsByTLDCached($config, $banner_id, $tld)
 {
     $params = array();
     $params["InsertionOrderLineItemID"] = $banner_id;
     $params["PublisherTLD"] = $tld;
     $class_dir_name = 'BuySideHourlyImpressionsByTLD';
     $cached_key_exists = \util\CacheSql::does_cached_write_exist_apc($config, $params, $class_dir_name);
     if ($cached_key_exists) {
         // increment bucket
         \util\CachedStatsWrites::increment_cached_write_result_int_apc($config, $params, $class_dir_name, 1);
     } else {
         /*
          * DO THIS BEFORE APC RESET OPERATIONS TO AVOID THREAD-LIKE DUPLICATION DUE TO THE LACK OF
          * A SYNCHRONIZED KEYWORD IN PHP
          */
         // SYNCHRONIZED BLOCK START
         \util\CacheSql::create_reset_write_lock($config, $params, $class_dir_name);
         // get value sum from apc
         $current = \util\CacheSql::get_cached_read_result_apc_type_convert($config, $params, $class_dir_name);
         // delete existing key - reset bucket
         \util\CacheSql::delete_cached_write_apc($config, $params, $class_dir_name);
         // increment bucket
         \util\CachedStatsWrites::increment_cached_write_result_int_apc($config, $params, $class_dir_name, 1);
         // SYNCHRONIZED BLOCK END
         \util\CacheSql::reset_write_unlock($config, $params, $class_dir_name);
         if ($current != null) {
             $bucket_value = $current["value"];
             // write out value
             $this->incrementBuySideHourlyImpressionsByTLD($banner_id, $tld, $bucket_value);
         }
     }
 }
 public function incrementPrivateExchangeRtbChannelDailyStatsCached($config, $method_params)
 {
     $publisher_website_id = $method_params["publisher_website_id"] = $method_params["rtb_channel_site_id"];
     $rtb_channel_site_name = $method_params["rtb_channel_site_name"];
     $impressions_offered_counter = $method_params["impressions_offered_counter"];
     $auction_bids_counter = $method_params["auction_bids_counter"];
     $spend_offered_in_bids = $method_params["spend_offered_in_bids"];
     $floor_price_if_any = $method_params["floor_price_if_any"];
     $params = array();
     $class_dir_name = 'PrivateExchangeRtbChannelDailyStats';
     $cached_key_exists = \util\CacheSql::does_cached_write_exist_apc($config, $params, $class_dir_name);
     if ($cached_key_exists) {
         // increment bucket
         \util\CachedStatsWrites::increment_cached_write_result_private_exchange_channel_stats($config, $params, $class_dir_name, $method_params);
     } else {
         /*
          * DO THIS BEFORE APC RESET OPERATIONS TO AVOID THREAD-LIKE DUPLICATION DUE TO THE LACK OF
          * A SYNCHRONIZED KEYWORD IN PHP
          */
         // SYNCHRONIZED BLOCK START
         \util\CacheSql::create_reset_write_lock($config, $params, $class_dir_name);
         // get value sum from apc
         $current = \util\CacheSql::get_cached_read_result_apc_type_convert($config, $params, $class_dir_name);
         // delete existing key - reset bucket
         \util\CacheSql::delete_cached_write_apc($config, $params, $class_dir_name);
         // increment bucket
         \util\CachedStatsWrites::increment_cached_write_result_private_exchange_channel_stats($config, $params, $class_dir_name, $method_params);
         // SYNCHRONIZED BLOCK END
         \util\CacheSql::reset_write_unlock($config, $params, $class_dir_name);
         if ($current != null) {
             // write out values
             $this->incrementPrivateExchangeRtbChannelDailyStats($config, $current);
         }
     }
 }
Example #7
0
 public function process_rtb_ping_statistics()
 {
     /*
      * COLLECT STATS FOR THE BID LOGS
      */
     $bids_total = 0;
     $bids_won = 0;
     $bids_lost = 0;
     $bid_errors = 0;
     $error_list = array();
     foreach ($this->RTBPingerList as $RTBPinger) {
         $SellSidePartnerHourlyBids = new \model\SellSidePartnerHourlyBids();
         $SellSidePartnerHourlyBids->SellSidePartnerID = $RTBPinger->partner_id;
         $SellSidePartnerHourlyBids->PublisherAdZoneID = $this->PublisherAdZoneID;
         $SellSidePartnerHourlyBids->BidsWonCounter = 0;
         $SellSidePartnerHourlyBids->BidsLostCounter = 0;
         $SellSidePartnerHourlyBids->BidsErrorCounter = 0;
         $SellSidePartnerHourlyBids->SpendTotalGross = 0;
         $SellSidePartnerHourlyBids->SpendTotalNet = 0;
         if ($RTBPinger->ping_success == true) {
             $bids_total++;
             if ($RTBPinger->won_auction === true) {
                 $bids_won = 1;
                 $SellSidePartnerHourlyBids->BidsWonCounter = 1;
                 $SellSidePartnerHourlyBids->SpendTotalGross = floatval($RTBPinger->winning_bid) / 1000;
                 // Subtract Ad Exchange Publisher markup
                 $mark_down = floatval($SellSidePartnerHourlyBids->SpendTotalGross) * floatval($this->publisher_markup_rate);
                 $adusted_amount = floatval($SellSidePartnerHourlyBids->SpendTotalGross) - floatval($mark_down);
                 $SellSidePartnerHourlyBids->SpendTotalNet = $adusted_amount;
             } else {
                 $bids_lost++;
                 $SellSidePartnerHourlyBids->BidsLostCounter = 1;
             }
         } else {
             $bid_errors++;
             $SellSidePartnerHourlyBids->BidsErrorCounter = 1;
             $error_list[] = "PartnerID: " . $RTBPinger->partner_id . " Error Message: " . $RTBPinger->ping_error_message;
         }
         \util\CachedStatsWrites::incrementSellSideBidsCounterCached($this->config, $SellSidePartnerHourlyBids);
     }
     $log_header = "----------------------------------------------------------------\n";
     $log_header .= "NEW BID RESPONSE, WEBSITE: " . $this->WebDomain . ", PubZoneID: " . $this->PublisherAdZoneID . ", AD: " . $this->AdName;
     \rtbsellv22\RtbSellV22Logger::get_instance()->log[] = $log_header;
     $log_header = "NEW BID RESPONSE, WEBSITE: " . $this->WebDomain . ", PubZoneID: " . $this->PublisherAdZoneID . ", AD: " . $this->AdName;
     \rtbsellv22\RtbSellV22Logger::get_instance()->min_log[] = $log_header;
     $log = "----------------------------------------------------------------";
     $log .= "\nDate: " . date('m-d-Y H:i:s');
     $log .= "\nTotal Bids: " . $bids_total;
     $log .= "\nBids Won: " . $bids_won;
     $log .= "\nBids Lost: " . $bids_lost;
     $log .= "\nBid Errors: " . $bid_errors;
     $log .= "\nError List: " . implode(",", $error_list);
     foreach ($this->skipped_partner_list as $skipped_partner) {
         $log .= "\nSkipped Partner: " . $skipped_partner;
     }
     $log .= "\n----------------------------------------------------------------\n";
     \rtbsellv22\RtbSellV22Logger::get_instance()->log[] = $log;
     \rtbsellv22\RtbSellV22Logger::get_instance()->min_log[] = $log;
 }