public function parse_request($raw_post)
 {
     $this->raw_post = $raw_post;
     // prepare the logger
     $logger = \rtbsellv22\RtbSellV22Logger::get_instance();
     // prepare the response object
     $this->RtbBidResponse = new \model\openrtb\RtbBidResponse();
     // Initialize Data
     try {
         \sellrtb\parsers\openrtb\parselets\common\Init::execute($logger, $this, $this->RtbBidResponse);
     } catch (Exception $e) {
         throw new Exception($e->getMessage(), $e->getCode(), $e->getPrevious());
     }
     // Parse Seat Bids
     try {
         \sellrtb\parsers\openrtb\parselets\common\ParseSeatBids::execute($logger, $this, $this->RtbBidResponse);
     } catch (Exception $e) {
         throw new Exception($e->getMessage(), $e->getCode(), $e->getPrevious());
     }
     return $this->RtbBidResponse;
 }
示例#2
0
 private function process_publisher_tag($config, $banner_request)
 {
     $PublisherAdZoneFactory = \_factory\PublisherAdZone::get_instance();
     $params = array();
     $params["AdStatus"] = 1;
     $params["PublisherAdZoneID"] = $banner_request["publisher_banner_id"];
     $PublisherAdZone = $PublisherAdZoneFactory->get_row_cached($config, $params);
     if ($PublisherAdZone == null) {
         return;
     }
     /*
      * Is this ad zone linked to one or more contract banners?
      * If so forward the request to the contract banner
      * display probability logic.
      */
     if ($PublisherAdZone->PublisherAdZoneTypeID == AD_TYPE_CONTRACT) {
         $LinkedBannerToAdZoneFactory = \_factory\LinkedBannerToAdZone::get_instance();
         $params = array();
         $params["PublisherAdZoneID"] = $banner_request["publisher_banner_id"];
         $LinkedBannerToAdZoneList = $LinkedBannerToAdZoneFactory->get_cached($config, $params);
         if ($LinkedBannerToAdZoneList != null && count($LinkedBannerToAdZoneList) > 0) {
             $this->process_contract_zone_tag($config, $banner_request, $LinkedBannerToAdZoneList);
         } else {
             return;
         }
     } else {
         $banner_request = $this->build_banner_request($config, $banner_request);
         $RtbSellV22Bid = new \rtbsellv22\RtbSellV22Bid();
         $RtbSellV22Bid->create_rtb_request_from_publisher_impression($config, $banner_request);
         $bid_request = $RtbSellV22Bid->build_rtb_bid_request();
         $PingManager = new \pinger\PingManager($config, $bid_request, $PublisherAdZone->AdOwnerID, $PublisherAdZone->PublisherWebsiteID, $PublisherAdZone->FloorPrice, $banner_request["PublisherAdZoneID"], $banner_request["AdName"], $banner_request["WebDomain"]);
         if ($PublisherAdZone->PublisherAdZoneTypeID == AD_TYPE_IN_HOUSE_REMNANT || $PublisherAdZone->PublisherAdZoneTypeID == AD_TYPE_ANY_REMNANT) {
             $PingManager->set_up_local_demand_ping_clients();
         }
         if ($PublisherAdZone->PublisherAdZoneTypeID == AD_TYPE_RTB_REMNANT || $PublisherAdZone->PublisherAdZoneTypeID == AD_TYPE_ANY_REMNANT) {
             $PingManager->set_up_remote_rtb_ping_clients();
         }
         $PingManager->ping_rtb_ping_clients();
         $auction_was_won = $PingManager->process_rtb_ping_responses();
         $winning_ad_tag = $PingManager->winning_ad_tag;
         /*
          * The RTB auction may not have been won because
          * a floor price wasn't met or there simply may not 
          * have been a valid bid on the auction.
          * 
          * Try to set the tag to the publisher's passback tag 
          * if one exists and if not show the default ad
          */
         if ($auction_was_won === false) {
             if ($PublisherAdZone->PassbackAdTag != null && !empty($PublisherAdZone->PassbackAdTag)) {
                 $winning_ad_tag = $PublisherAdZone->PassbackAdTag;
             } else {
                 return;
             }
         }
         $PingManager->process_rtb_ping_statistics();
         // now output the logs to the log file
         \rtbsellv22\RtbSellV22Logger::get_instance()->output_log();
         header("Content-type: application/javascript");
         $output = "document.write(" . json_encode($winning_ad_tag) . ");";
         echo $output;
     }
     exit;
 }
示例#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;
 }
示例#4
0
 private function process_publisher_tag($config, $banner_request)
 {
     $PublisherAdZoneFactory = \_factory\PublisherAdZone::get_instance();
     $PublisherWebsiteFactory = \_factory\PublisherWebsite::get_instance();
     $params = array();
     $params["AdStatus"] = 1;
     $params["PublisherAdZoneID"] = $banner_request["publisher_banner_id"];
     $PublisherAdZone = $PublisherAdZoneFactory->get_row_cached($config, $params);
     if ($PublisherAdZone == null) {
         return;
     }
     $params = array();
     $params["PublisherWebsiteID"] = $PublisherAdZone->PublisherWebsiteID;
     $PublisherWebsite = $PublisherWebsiteFactory->get_row_cached($config, $params);
     if ($PublisherWebsite == null) {
         return;
     }
     /*
      * Does this publisher's website belong to a Domain Admin
      * running a private exchange?
      * 
      * If it does, did the domain admin enable this website's inventory
      * to be available on the platform connection feature to other
      * domain admins running their own private exchanges?
      * 
      * Did he enable platform exchange on the website edit page
      * to enable this publisher's website inventory to be sent to DSPs?
      */
     $banner_request["PrivateExchangeOnly"] = $PublisherWebsite->VisibilityTypeID == 2 ? true : false;
     $banner_request["ImpressionType"] = $PublisherAdZone->ImpressionType;
     $banner_request = $this->build_request_array($config, $banner_request);
     $RtbSellV22Bid = new \rtbsellv22\RtbSellV22Bid();
     $RtbSellV22Bid->create_rtb_request_from_publisher_display_impression($config, $banner_request);
     /* 
      * We build the OpenRTB request destined for demand
      * that is local to this NginAd instance
      */
     $PmpDealPublisherWebsiteToInsertionOrderLineItemFactory = \_factory\PmpDealPublisherWebsiteToInsertionOrderLineItem::get_instance();
     $params = array();
     $params["PublisherWebsiteID"] = $PublisherWebsite->PublisherWebsiteID;
     $params["Enabled"] = 1;
     if ($banner_request["PrivateExchangeOnly"] === true) {
         /*
          * PublisherWebsiteLocal is set to 1 only if the domain admin
          * owns the publishers under their private exchange
          */
         $params["PublisherWebsiteLocal"] = $PublisherWebsite->VisibilityTypeID == 2 ? 1 : 0;
     }
     $PmpDealPublisherWebsiteToInsertionOrderLineItemList = $PmpDealPublisherWebsiteToInsertionOrderLineItemFactory->get_cached($config, $params);
     $RtbSellV22Bid->clone_local_rtb_request_with_pmp($config, $banner_request, $PmpDealPublisherWebsiteToInsertionOrderLineItemList);
     $bid_request_list[self::GENERIC_PARTNER] = $RtbSellV22Bid->build_rtb_bid_request_generic();
     $bid_request_list[self::LOOPBACK_PARTNER] = $RtbSellV22Bid->build_rtb_bid_request_loopback();
     $PingManager = new \pinger\PingManager($config, $bid_request_list, $PublisherAdZone->AdOwnerID, $PublisherAdZone->PublisherWebsiteID, $PublisherAdZone->FloorPrice, $banner_request["PublisherAdZoneID"], $banner_request["AdName"], $banner_request["WebDomain"], $banner_request["ImpressionType"]);
     /*
      * Send the RTB request to local demand
      */
     $PingManager->set_up_local_demand_ping_clients();
     /*
      * Only send the RTB request to DSPs if the source
      * website is not marked for a private exchange only
      */
     if ($banner_request["PrivateExchangeOnly"] === false) {
         $PingManager->set_up_remote_rtb_ping_clients();
     }
     $PingManager->ping_rtb_ping_clients();
     $AuctionPopo = $PingManager->process_rtb_ping_responses();
     $auction_was_won = $AuctionPopo->auction_was_won;
     $winning_ad_tag = $AuctionPopo->winning_ad_tag;
     /*
      * Auction stats should be published to the database
      * regardless of whether there was a winning bid or not.
      */
     $PingManager->process_rtb_ping_statistics($AuctionPopo);
     /*
      * The RTB auction may not have been won because
      * a floor price wasn't met or there simply may not 
      * have been a valid bid on the auction.
      * 
      * Try to set the tag to the publisher's passback tag 
      * if one exists and if not show the default ad
      */
     if ($auction_was_won === false) {
         if ($PublisherAdZone->PassbackAdTag != null && !empty($PublisherAdZone->PassbackAdTag)) {
             $winning_ad_tag = $PublisherAdZone->PassbackAdTag;
         } else {
             return;
         }
     } else {
         /*
          * Process the macro replacements in the winning Ad tag:
          *
          * NGINCLKTRK: The click tracking URL, TBD, generic click tracking not yet implemented.
          * Try implementing your own custom CTR rate tracking
          *
          * NGINWBIDPRC: The winning bid price expressed as CPM.
          * If this was a 2nd price auction, the value would be the second price expressed as CPM
          */
         $winning_ad_tag = str_replace("{NGINCLKTRK}", "", $winning_ad_tag);
         $winning_ad_tag = str_replace("{NGINWBIDPRC}", $AuctionPopo->winning_bid_price, $winning_ad_tag);
     }
     // now output the logs to the log file
     \rtbsellv22\RtbSellV22Logger::get_instance()->output_log();
     $tracker_url = "";
     if ($banner_request["ImpressionType"] == 'video' && \util\ParseHelper::isVastURL($winning_ad_tag) === true && $AuctionPopo->auction_was_won) {
         $encryption_key = $config['settings']['rtb']['encryption_key'];
         $params = array();
         $params["winning_price"] = $AuctionPopo->winning_bid_price;
         $params["auction_timestamp"] = time();
         $vast_auction_param = $this->encrypt_vast_auction_params($encryption_key, $params);
         $vast_publisher_param = $this->encrypt_vast_auction_params($encryption_key, $AuctionPopo->vast_publisher_imp_obj);
         $tracker_url = $this->get_vast_tracker_url($config, $vast_auction_param, $vast_publisher_param);
         $banner_request["tracker_url"] = $tracker_url;
     }
     if ($AuctionPopo->loopback_demand_partner_won === true) {
         $banner_request["demand_banner_id"] = $AuctionPopo->loopback_demand_partner_ad_campaign_banner_id;
         $banner_request["winning_partner_id"] = $AuctionPopo->winning_partner_id;
         $banner_request["winning_seat"] = $AuctionPopo->winning_seat;
         $this->process_demand_tag($config, $banner_request);
         /* 
          * If this is a local auction we don't need to worry about
          * firing off notice urls
          */
     } else {
         if ($banner_request["ImpressionType"] == 'video') {
             header("Content-type: text/xml");
             if (\util\ParseHelper::isVastURL($winning_ad_tag) === true) {
                 echo $this->get_vast_wrapper_xml($config, $winning_ad_tag, $tracker_url);
             } else {
                 echo $winning_ad_tag;
             }
         } else {
             // credit publisher account here
             header("Content-type: application/javascript");
             $output = "document.write(" . json_encode($winning_ad_tag) . ");";
             echo $output;
         }
         if (!empty($AuctionPopo->nurl)) {
             /*
              * If this is a remote RTB auction we do need to worry about
              * firing off notice urls
              *
              * If safe_mode is off we can fire off an asynchronous CURL
              * call which will not block. Otherwise we are stuck
              * with curl call with a timeout.
              * 
              * curl must also be on the path
              */
             // clear output buffer
             ob_end_flush();
             // check if curl is installed
             $has_curl_on_path = $config['settings']['shell']['has_curl_on_path'];
             if (!ini_get('safe_mode') && $has_curl_on_path) {
                 exec('bash -c "exec nohup setsid curl \'' . $AuctionPopo->nurl . '\' > /dev/null 2>&1 &"');
             } else {
                 \util\WorkflowHelper::get_ping_notice_url_curl_request($AuctionPopo->nurl);
             }
         }
     }
     exit;
 }
 private function process_publisher_tag($config, $banner_request)
 {
     $PublisherAdZoneFactory = \_factory\PublisherAdZone::get_instance();
     $params = array();
     $params["AdStatus"] = 1;
     $params["PublisherAdZoneID"] = $banner_request["publisher_banner_id"];
     $PublisherAdZone = $PublisherAdZoneFactory->get_row_cached($config, $params);
     if ($PublisherAdZone == null) {
         return;
     }
     $banner_request["ImpressionType"] = $PublisherAdZone->ImpressionType;
     /*
      * Is this ad zone linked to one or more contract banners?
      * If so forward the request to the contract banner
      * display probability logic.
      */
     if ($PublisherAdZone->PublisherAdZoneTypeID == AD_TYPE_CONTRACT) {
         $LinkedBannerToAdZoneFactory = \_factory\LinkedBannerToAdZone::get_instance();
         $params = array();
         $params["PublisherAdZoneID"] = $banner_request["publisher_banner_id"];
         $LinkedBannerToAdZoneList = $LinkedBannerToAdZoneFactory->get_cached($config, $params);
         if ($LinkedBannerToAdZoneList != null && count($LinkedBannerToAdZoneList) > 0) {
             $this->process_contract_zone_tag($config, $banner_request, $LinkedBannerToAdZoneList);
         } else {
             return;
         }
     } else {
         $banner_request = $this->build_request_array($config, $banner_request);
         $RtbSellV22Bid = new \rtbsellv22\RtbSellV22Bid();
         $RtbSellV22Bid->create_rtb_request_from_publisher_display_impression($config, $banner_request);
         $bid_request = $RtbSellV22Bid->build_rtb_bid_request();
         $PingManager = new \pinger\PingManager($config, $bid_request, $PublisherAdZone->AdOwnerID, $PublisherAdZone->PublisherWebsiteID, $PublisherAdZone->FloorPrice, $banner_request["PublisherAdZoneID"], $banner_request["AdName"], $banner_request["WebDomain"], $banner_request["ImpressionType"]);
         if ($PublisherAdZone->PublisherAdZoneTypeID == AD_TYPE_IN_HOUSE_REMNANT || $PublisherAdZone->PublisherAdZoneTypeID == AD_TYPE_ANY_REMNANT) {
             $PingManager->set_up_local_demand_ping_clients();
         }
         if ($PublisherAdZone->PublisherAdZoneTypeID == AD_TYPE_RTB_REMNANT || $PublisherAdZone->PublisherAdZoneTypeID == AD_TYPE_ANY_REMNANT) {
             $PingManager->set_up_remote_rtb_ping_clients();
         }
         $PingManager->ping_rtb_ping_clients();
         $AuctionPopo = $PingManager->process_rtb_ping_responses();
         $auction_was_won = $AuctionPopo->auction_was_won;
         $winning_ad_tag = $AuctionPopo->winning_ad_tag;
         /*
          * Auction stats should be published to the database
          * regardless of whether there was a winning bid or not.
          */
         $PingManager->process_rtb_ping_statistics($AuctionPopo);
         /*
          * The RTB auction may not have been won because
          * a floor price wasn't met or there simply may not 
          * have been a valid bid on the auction.
          * 
          * Try to set the tag to the publisher's passback tag 
          * if one exists and if not show the default ad
          */
         if ($auction_was_won === false) {
             if ($PublisherAdZone->PassbackAdTag != null && !empty($PublisherAdZone->PassbackAdTag)) {
                 $winning_ad_tag = $PublisherAdZone->PassbackAdTag;
             } else {
                 return;
             }
         } else {
             /*
              * Process the macro replacements in the winning Ad tag:
              *
              * NGINCLKTRK: The click tracking URL, TBD, generic click tracking not yet implemented.
              * Try implementing your own custom CTR rate tracking
              *
              * NGINWBIDPRC: The winning bid price expressed as CPM.
              * If this was a 2nd price auction, the value would be the second price expressed as CPM
              */
             $winning_ad_tag = str_replace("{NGINCLKTRK}", "", $winning_ad_tag);
             $winning_ad_tag = str_replace("{NGINWBIDPRC}", $AuctionPopo->winning_bid_price, $winning_ad_tag);
         }
         // now output the logs to the log file
         \rtbsellv22\RtbSellV22Logger::get_instance()->output_log();
         $tracker_url = "";
         if ($banner_request["ImpressionType"] == 'video' && \util\ParseHelper::isVastURL($winning_ad_tag) === true && $AuctionPopo->auction_was_won) {
             $encryption_key = $config['settings']['rtb']['encryption_key'];
             $params = array();
             $params["winning_price"] = $AuctionPopo->winning_bid_price;
             $params["auction_timestamp"] = time();
             $vast_auction_param = $this->encrypt_vast_auction_params($encryption_key, $params);
             $vast_publisher_param = $this->encrypt_vast_auction_params($encryption_key, $AuctionPopo->vast_publisher_imp_obj);
             $tracker_url = $this->get_vast_tracker_url($config, $vast_auction_param, $vast_publisher_param);
             $banner_request["tracker_url"] = $tracker_url;
         }
         if ($AuctionPopo->loopback_demand_partner_won === true) {
             $banner_request["demand_banner_id"] = $AuctionPopo->loopback_demand_partner_ad_campaign_banner_id;
             $banner_request["winning_partner_id"] = $AuctionPopo->winning_partner_id;
             $banner_request["winning_seat"] = $AuctionPopo->winning_seat;
             $this->process_demand_tag($config, $banner_request);
             /* 
              * If this is a local auction we don't need to worry about
              * firing off notice urls
              */
         } else {
             if ($banner_request["ImpressionType"] == 'video') {
                 header("Content-type: text/xml");
                 if (\util\ParseHelper::isVastURL($winning_ad_tag) === true) {
                     echo $this->get_vast_wrapper_xml($config, $winning_ad_tag, $tracker_url);
                 } else {
                     echo $winning_ad_tag;
                 }
             } else {
                 // credit publisher account here
                 header("Content-type: application/javascript");
                 $output = "document.write(" . json_encode($winning_ad_tag) . ");";
                 echo $output;
             }
             if (!empty($AuctionPopo->nurl)) {
                 /*
                  * If this is a remote RTB auction we do need to worry about
                  * firing off notice urls
                  *
                  * If safe_mode is off we can fire off an asynchronous CURL
                  * call which will not block. Otherwise we are stuck
                  * with curl call with a timeout.
                  * 
                  * curl must also be on the path
                  */
                 // clear output buffer
                 ob_end_flush();
                 // check if curl is installed
                 $has_curl_on_path = $config['settings']['shell']['has_curl_on_path'];
                 if (!ini_get('safe_mode') && $has_curl_on_path) {
                     exec('bash -c "exec nohup setsid curl \'' . $AuctionPopo->nurl . '\' > /dev/null 2>&1 &"');
                 } else {
                     \util\WorkflowHelper::get_ping_notice_url_curl_request($AuctionPopo->nurl);
                 }
             }
         }
     }
     exit;
 }
示例#6
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;
 }