Exemplo n.º 1
0
 public static function execute(&$Logger, &$Workflow, \model\openrtb\RtbBidRequest &$RtbBidRequest, \model\openrtb\RtbBidRequestImp &$RtbBidRequestImp, &$InsertionOrderLineItem, &$InsertionOrderLineItemRestrictions)
 {
     /*
      * OK, here's the thing.
      * Normally frequency capping is done on the
      * frequency of impressions on a certain publisher's
      * website, zone or inventory.
      *
      * However, because in RTB we don't know if the bid
      * will win the impression or not ahead of time,
      * we can only calculate frequency against the bids.
      */
     if ($InsertionOrderLineItemRestrictions->Freq === null) {
         return true;
     }
     $frequency = intval($InsertionOrderLineItemRestrictions->Freq);
     return \util\FrequencyHelper::checkLineItemImpressionFrequency($Workflow->config, $frequency, $InsertionOrderLineItem->InsertionOrderLineItemID);
 }
Exemplo n.º 2
0
 public function convert_ads_to_bid_response()
 {
     // init the bid response object
     $RtbBidResponse = new \model\openrtb\RtbBidResponse();
     /*
      * get TLD of the site url or page url for the
      * ad tag in case it's needed for the delivery module
      */
     $tld = "not_available";
     $rtb_ids = null;
     if ($this->RtbBidRequest != null) {
         $rtb_ids = \util\WorkflowHelper::getIdsFromRtbRequest($this->RtbBidRequest);
         $tld = $rtb_ids["tld"];
         $this->user_ip_hash = md5($this->RtbBidRequest->RtbBidRequestDevice->ip);
         $RtbBidResponse->id = $this->RtbBidRequest->id;
     }
     $RtbBidResponse->RtbBidResponseSeatBidList = array();
     $currency = null;
     $total_bids = 0;
     $spend_offered_in_bids = 0;
     foreach ($this->InsertionOrderLineItem_Match_List as $user_id => $InsertionOrderLineItemObjList) {
         $RtbBidResponseSeatBid = new \model\openrtb\RtbBidResponseSeatBid();
         foreach ($InsertionOrderLineItemObjList as $InsertionOrderLineItemObj) {
             $bid_imp_id = $InsertionOrderLineItemObj["impid"];
             $InsertionOrderLineItem = $InsertionOrderLineItemObj["InsertionOrderLineItem"];
             if (isset($InsertionOrderLineItemObj["currency"]) && $currency == null) {
                 $currency = $InsertionOrderLineItemObj["currency"];
             }
             $RtbBidResponseBid = new \model\openrtb\RtbBidResponseBid();
             $RtbBidResponseBid->id = $this->generate_transaction_id();
             $RtbBidResponseBid->adid = $RtbBidResponseBid->id;
             $RtbBidResponseBid->impid = $bid_imp_id;
             $RtbBidResponseBid->price = $InsertionOrderLineItem->BidAmount;
             if ($InsertionOrderLineItem->ImpressionType == 'video') {
                 $RtbBidResponseBid->nurl = $this->get_video_notice_url($InsertionOrderLineItem, $tld);
             } else {
                 $RtbBidResponseBid->adm = $this->get_effective_ad_tag($InsertionOrderLineItem, $tld);
             }
             $RtbBidResponseBid->adomain[] = $InsertionOrderLineItem->LandingPageTLD;
             $RtbBidResponseBid->cid = "nginad_" . $InsertionOrderLineItem->InsertionOrderID;
             $RtbBidResponseBid->crid = "nginad_" . $InsertionOrderLineItem->InsertionOrderLineItemID;
             $this->had_bid_response = true;
             $RtbBidResponseSeatBid->RtbBidResponseBidList[] = $RtbBidResponseBid;
             $spend_offered_in_bids += floatval($InsertionOrderLineItem->BidAmount / 1000);
             $total_bids++;
             \util\FrequencyHelper::incrementLineItemBidFrequencyCount($this->config, $InsertionOrderLineItem->InsertionOrderLineItemID);
         }
         $RtbBidResponseSeatBid->seat = $user_id;
         $RtbBidResponse->RtbBidResponseSeatBidList[] = $RtbBidResponseSeatBid;
     }
     if (isset($InsertionOrderLineItemObj["currency"]) && $currency == null) {
         $RtbBidResponse->cur = $currency;
     } else {
         $RtbBidResponse->cur = $this->config['settings']['rtb']['auction_currency'];
     }
     if (!count($RtbBidResponse->RtbBidResponseSeatBidList)) {
         // implement Rubicon Project's empty bid with $0.00 CPM here
         // also add the rejection code
         unset($RtbBidResponse->id);
         unset($RtbBidResponse->cur);
         if ($this->no_bid_reason != null) {
             $RtbBidResponse->nbr = $this->no_bid_reason;
         } else {
             $RtbBidResponseSeatBid = new \model\openrtb\RtbBidResponseSeatBid();
             $RtbBidResponseBid = new \model\openrtb\RtbBidResponseBid();
             $RtbBidResponseBid->price = 0;
             $RtbBidResponseSeatBid->RtbBidResponseBidList[] = $RtbBidResponseBid;
             $RtbBidResponse->RtbBidResponseSeatBidList[] = $RtbBidResponseSeatBid;
         }
     }
     $this->RtbBidResponse = $RtbBidResponse;
     $this->logImpressionsStatisticsData($tld, $total_bids, $spend_offered_in_bids);
 }