/** * Display the publisher index page, and list all domains associated. * * @return \Zend\View\Model\ViewModel */ public function indexAction() { $initialized = $this->initialize(); if ($initialized !== true) { return $initialized; } //Pull list of websites. $PublisherWebsiteFactory = \_factory\PublisherWebsite::get_instance(); $parameters = array(); // Set the parameters to empty first. $parameters['DomainOwnerID'] = $this->PublisherInfoID; $publisher_markup_rate = $this->config_handle['system']['default_publisher_markup_rate']; $publisher_impressions_network_loss_rate = $this->config_handle['system']['default_publisher_impressions_network_loss_rate']; $PublisherWebsiteList = $PublisherWebsiteFactory->get($parameters); if ($this->is_admin) { $headers = array("#", "Domain", "Domain Markup", "Imps Loss Rate", "Domain Owner", "Created", "Updated", "Approval", "Actions"); $meta_data = array("WebDomain", "DomainMarkupRate", "DomainPublisherImpressionsLossRate", "DomainOwnerID", "DateCreated", "DateUpdated", "ApprovalFlag"); // admin is logged in as a user, get the markup if any for that user if ($this->ImpersonateID != 0 && !empty($this->PublisherInfoID)) { $publisher_markup = \util\Markup::getMarkupForPublisher($this->PublisherInfoID, $this->config_handle, false); if ($publisher_markup != null) { $publisher_markup_rate = $publisher_markup->MarkupRate; } $publisher_impressions_network_loss = \util\NetworkLossCorrection::getNetworkLossCorrectionRateForPublisher($this->PublisherInfoID, $this->config_handle, false); if ($publisher_impressions_network_loss != null) { $publisher_impressions_network_loss_rate = $publisher_impressions_network_loss->CorrectionRate; } } } else { $headers = array("#", "Domain", "Created", "Updated", "Approval", "Actions"); $meta_data = array("WebDomain", "AutoApprove", "DateCreated", "DateUpdated", "ApprovalFlag"); } foreach ($PublisherWebsiteList as $PublisherWebsite) { $website_markup = \util\Markup::getMarkupForPublisherWebsite($PublisherWebsite->PublisherWebsiteID, $this->config_handle, false); if ($website_markup != null) { $website_markup_rate_list[$PublisherWebsite->PublisherWebsiteID] = $website_markup->MarkupRate * 100; } else { $website_markup_rate_list[$PublisherWebsite->PublisherWebsiteID] = $publisher_markup_rate * 100; } $website_impressions_network_loss = \util\NetworkLossCorrection::getNetworkLossCorrectionRateForPublisherWebsite($PublisherWebsite->PublisherWebsiteID, $this->config_handle, false); if ($website_impressions_network_loss != null) { $website_impressions_network_loss_rate_list[$PublisherWebsite->PublisherWebsiteID] = $website_impressions_network_loss->CorrectionRate * 100; } else { $website_impressions_network_loss_rate_list[$PublisherWebsite->PublisherWebsiteID] = $publisher_impressions_network_loss_rate * 100; } } $PublisherInfoFactory = \_factory\PublisherInfo::get_instance(); $params = array(); $params["PublisherInfoID"] = $this->PublisherInfoID; $PublisherInfo = $PublisherInfoFactory->get_row($params); $publisher_markup_rate *= 100; $publisher_impressions_network_loss_rate *= 100; $view = new ViewModel(array('true_user_name' => $this->auth->getUserName(), 'domain_list_raw' => $PublisherWebsiteList, 'domain_list' => $this->order_data_table($meta_data, $PublisherWebsiteList, $headers), 'is_admin' => $this->is_admin, 'user_id_list' => $this->user_id_list_publisher, 'domain_owner' => isset($PublisherInfo->Name) ? $PublisherInfo->Name : "", 'impersonate_id' => $this->ImpersonateID, 'effective_id' => $this->auth->getEffectiveIdentityID(), 'publisher_info_id' => $this->PublisherInfoID, 'dashboard_view' => 'publisher', 'user_identity' => $this->identity(), 'publisher_markup_rate' => $publisher_markup_rate, 'publisher_impressions_network_loss_rate' => $publisher_impressions_network_loss_rate, 'website_markup_rate_list' => isset($website_markup_rate_list) ? $website_markup_rate_list : array(), 'website_impressions_network_loss_rate_list' => isset($website_impressions_network_loss_rate_list) ? $website_impressions_network_loss_rate_list : array())); if ($this->is_admin == false || $this->is_admin == true && $this->PublisherInfoID != null && $this->auth->getEffectiveIdentityID() != 0) { $view->header_title = '<a href="/publisher/createdomain">Create New Domain</a>'; } else { $view->header_title = ' '; } return $view; }
public function __construct($config, $ping_request, $PublisherInfoID, $PublisherWebsiteID, $FloorPrice, $PublisherAdZoneID, $AdName, $WebDomain) { $this->config = $config; $this->ping_request = $ping_request; $this->PublisherInfoID = $PublisherInfoID; $this->PublisherWebsiteID = $PublisherWebsiteID; $this->FloorPrice = floatval($FloorPrice); $this->PublisherAdZoneID = $PublisherAdZoneID; $this->AdName = $AdName; $this->WebDomain = $WebDomain; $this->publisher_markup_rate = \util\Markup::getPublisherMarkupRate($this->PublisherWebsiteID, $this->PublisherInfoID, $this->config); }
public function __construct($config, $ping_request_list, $PublisherInfoID, $PublisherWebsiteID, $FloorPrice, $PublisherAdZoneID, $AdName, $WebDomain, $ImpressionType) { $this->config = $config; $this->ping_request_list = $ping_request_list; $this->PublisherInfoID = $PublisherInfoID; $this->PublisherWebsiteID = $PublisherWebsiteID; $this->FloorPrice = floatval($FloorPrice); $this->PublisherAdZoneID = $PublisherAdZoneID; $this->AdName = $AdName; $this->WebDomain = $WebDomain; $this->ImpressionType = $ImpressionType; $this->is_second_price_auction = $this->config['settings']['rtb']['second_price_auction']; $this->publisher_markup_rate = \util\Markup::getPublisherMarkupRate($this->PublisherWebsiteID, $this->PublisherInfoID, $this->config); $this->private_exchange_publisher_markup_rate = \util\Markup::getPrivateExchangePublisherMarkupRate($this->PublisherWebsiteID, $this->PublisherInfoID, $this->config); }
public function __construct($config, $ping_request, $PublisherInfoID, $PublisherWebsiteID, $FloorPrice, $PublisherAdZoneID, $AdName, $WebDomain, $ImpressionType) { $this->config = $config; $this->ping_request = json_decode($ping_request, true); $this->PublisherInfoID = $PublisherInfoID; $this->PublisherWebsiteID = $PublisherWebsiteID; $this->FloorPrice = floatval($FloorPrice); $this->PublisherAdZoneID = $PublisherAdZoneID; $this->AdName = $AdName; $this->WebDomain = $WebDomain; $this->ImpressionType = $ImpressionType; $this->is_second_price_auction = $this->config['settings']['rtb']['second_price_auction']; // is this a 1rst price or 2nd price auction? $this->ping_request["at"] = $this->is_second_price_auction === true ? 2 : 1; $this->publisher_markup_rate = \util\Markup::getPublisherMarkupRate($this->PublisherWebsiteID, $this->PublisherInfoID, $this->config); }
public function process_business_rules_workflow($logger, $config, $rtb_seat_id, &$no_bid_reason, \model\openrtb\RtbBidRequest &$RtbBidRequest) { $this->config = $config; $this->rtb_seat_id = $rtb_seat_id; // $logger = \rtbbuyv22\RtbBuyV22Logger::get_instance(); $InsertionOrderLineItem_Match_List = array(); $InsertionOrderFactory = \_factory\InsertionOrder::get_instance(); $params = array(); $params["Active"] = 1; $InsertionOrderList = $InsertionOrderFactory->get_cached($this->config, $params); $this->current_time = time(); $InsertionOrderLineItemFactory = \_factory\InsertionOrderLineItem::get_instance(); $InsertionOrderLineItemDomainExclusionFactory = \_factory\InsertionOrderLineItemDomainExclusion::get_instance(); $InsertionOrderLineItemExclusiveInclusionFactory = \_factory\InsertionOrderLineItemDomainExclusiveInclusion::get_instance(); $InsertionOrderLineItemRestrictionsFactory = \_factory\InsertionOrderLineItemRestrictions::get_instance(); $InsertionOrderLineItemVideoRestrictionsFactory = \_factory\InsertionOrderLineItemVideoRestrictions::get_instance(); // match ip against country code \buyrtb\workflows\tasklets\common\insertionorder\GetGeoCodeCountry::execute($logger, $this, $RtbBidRequest); foreach ($InsertionOrderList as $InsertionOrder) { // Check campaign date if (\buyrtb\workflows\tasklets\common\insertionorder\CheckCampaignDate::execute($logger, $this, $RtbBidRequest, $InsertionOrder) === false) { continue; } // Check max spend if (\buyrtb\workflows\tasklets\common\insertionorder\CheckMaxSpend::execute($logger, $this, $RtbBidRequest, $InsertionOrder) === false) { continue; } // Check max impressions if (\buyrtb\workflows\tasklets\common\insertionorder\CheckMaxImpressions::execute($logger, $this, $RtbBidRequest, $InsertionOrder) === false) { continue; } // get markup rate for ad campaign $markup_rate = \util\Markup::getMarkupRate($InsertionOrder, $this->config); // iterate the active banners for this ad campaign $params = array(); $params["InsertionOrderID"] = $InsertionOrder->InsertionOrderID; $params["Active"] = 1; $InsertionOrderLineItemList = $InsertionOrderLineItemFactory->get_cached($this->config, $params); foreach ($RtbBidRequest->RtbBidRequestImpList as $RtbBidRequestImp) { foreach ($InsertionOrderLineItemList as $InsertionOrderLineItem) { if (empty($RtbBidRequestImp->RtbBidRequestVideo) && $InsertionOrderLineItem->ImpressionType == 'video' || !empty($RtbBidRequestImp->RtbBidRequestVideo) && ($InsertionOrderLineItem->ImpressionType == 'banner' || $InsertionOrderLineItem->ImpressionType == 'image')) { continue; } /* * check the business rules against the banner */ // Check PMP if (\buyrtb\workflows\tasklets\common\insertionorderlineitem\CheckPrivateMarketPlace::execute($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $InsertionOrderLineItem) === false) { continue; } // Check Domain Admin SSP Channel Selections if (\buyrtb\workflows\tasklets\common\insertionorderlineitem\CheckSspChannelSelections::execute($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $InsertionOrderLineItem) === false) { continue; } // Check banner date if (\buyrtb\workflows\tasklets\common\insertionorderlineitem\CheckBannerDate::execute($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $InsertionOrderLineItem) === false) { continue; } // Check impression price floor if (\buyrtb\workflows\tasklets\common\insertionorderlineitem\CheckPriceFloor::execute($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $InsertionOrderLineItem, $markup_rate) === false) { continue; } // Check banner domain exclusive inclusions if (\buyrtb\workflows\tasklets\common\insertionorderlineitem\CheckExclusiveInclusion::execute($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $InsertionOrderLineItem, $InsertionOrderLineItemExclusiveInclusionFactory) === false) { continue; } // Check banner domain exclusions match if (\buyrtb\workflows\tasklets\common\insertionorderlineitem\CheckDomainExclusion::execute($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $InsertionOrderLineItem, $InsertionOrderLineItemDomainExclusionFactory) === false) { continue; } if (!empty($RtbBidRequestImp->RtbBidRequestVideo)) { // Video Workflow $VideoWorkflow = new \buyrtb\workflows\VideoWorkflow(); $passed_child_workflow = $VideoWorkflow->process_business_rules_workflow($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $InsertionOrderLineItem, $InsertionOrderLineItemVideoRestrictionsFactory); } else { // Display Banner Workflow - Default [ banner/ad tag/image creative types ] $DisplayWorkflow = new \buyrtb\workflows\DisplayWorkflow(); $passed_child_workflow = $DisplayWorkflow->process_business_rules_workflow($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $InsertionOrderLineItem, $InsertionOrderLineItemRestrictionsFactory); } if ($passed_child_workflow === false) { continue; } /* * PASSED ALL THE BUSINESS RULES, ADD TO THE RESULTS */ $InsertionOrderLineItemFactory->incrementInsertionOrderLineItemBidsCounterCached($this->config, $rtb_seat_id, $InsertionOrderLineItem->InsertionOrderLineItemID); /* * Adjust the bid rate according to the markup */ $mark_down = floatval($InsertionOrderLineItem->BidAmount) * floatval($markup_rate); $adusted_amount = floatval($InsertionOrderLineItem->BidAmount) - floatval($mark_down); $InsertionOrderLineItem->BidAmount = sprintf("%1.4f", $adusted_amount); // default in config $currency = $this->config['settings']['rtb']['auction_currency']; if (isset($RtbBidRequest->cur[0])) { $currency = $RtbBidRequest->cur[0]; } $InsertionOrderLineItem_Match_List[(string) $InsertionOrderLineItem->UserID][] = array("currency" => $currency, "impid" => $RtbBidRequestImp->id, "InsertionOrderLineItem" => $InsertionOrderLineItem); } } } if (count($InsertionOrderLineItem_Match_List)) { // Check Publisher Score if (\buyrtb\workflows\tasklets\common\thirdparty\CheckPublisherScore::execute($logger, $this, $RtbBidRequest) === false) { $no_bid_reason = NOBID_BAD_PUBLISHER; return array(); } // Check Ad Fraud if (\buyrtb\workflows\tasklets\common\thirdparty\CheckAdFraud::execute($logger, $this, $RtbBidRequest) === false) { $no_bid_reason = NOBID_AD_FRAUD; return array(); } // Check Cookie Match if (\buyrtb\workflows\tasklets\common\thirdparty\CheckCookieMatch::execute($logger, $this, $RtbBidRequest) === false) { $no_bid_reason = NOBID_UNMATCHED_USER; return array(); } } return $InsertionOrderLineItem_Match_List; }
/** * Will Show the dashboard index page. * (non-PHPdoc) * @see \Zend\Mvc\Controller\AbstractActionController::indexAction() */ public function indexAction() { $initialized = $this->initialize(); if ($initialized !== true) { return $initialized; } $user_markup_rate = $this->config_handle['system']['default_demand_markup_rate']; $campaign_markup_rate_list = array(); if (strpos($this->auth->getPrimaryRole(), $this->config_handle['roles']['admin']) !== false) { // admin is logged in as a user, get the markup if any for that user if ($this->auth->getEffectiveIdentityID() != 0) { $user_markup = \util\Markup::getMarkupForUser($this->auth->getEffectiveIdentityID()); if ($user_markup != null) { $user_markup_rate = $user_markup->MarkupRate; } } } if ($this->config_handle['system']['debug']) { echo "<br />\n"; echo "My role in this application is: "; var_dump($this->auth->getPrimaryRole()); echo "<br />\n"; echo "My UserID in this application is: "; var_dump($this->auth->getUserID()); echo "<br />\n"; } $AdCampaignFactory = \_factory\AdCampaign::get_instance(); $params = array(); $params["Active"] = 1; // admin should see campaigns requiring approval and the user they belong to ONLY $params["UserID"] = $this->auth->getEffectiveUserID(); $_ad_campaign_list = $AdCampaignFactory->get($params); $AdCampaignPreviewFactory = \_factory\AdCampaignPreview::get_instance(); $ad_campaign_list = array(); // admin should see campaigns requiring approval and the user they belong to ONLY foreach ($_ad_campaign_list as $ad_campaign) { $is_preview = \transformation\TransformPreview::doesPreviewAdCampaignExistForAdCampaign($ad_campaign->AdCampaignID, $this->auth); if ($is_preview != true) { $ad_campaign_list[] = $ad_campaign; $ad_campaign_markup = \util\Markup::getMarkupForAdCampaign($ad_campaign->AdCampaignID); if ($ad_campaign_markup != null) { $campaign_markup_rate_list[$ad_campaign->AdCampaignID] = $ad_campaign_markup->MarkupRate * 100; } else { $campaign_markup_rate_list[$ad_campaign->AdCampaignID] = $user_markup_rate * 100; } } } // get previews $params = array(); $params["Active"] = 1; // $params["Deleted"] = 0; if ($this->is_admin == true && $this->auth->getEffectiveIdentityID() != 0) { $params["UserID"] = $this->auth->getEffectiveUserID(); } elseif ($this->is_admin == false) { $params["UserID"] = $this->auth->getUserID(); } $_ad_campaign_preview_list = $AdCampaignPreviewFactory->get($params); foreach ($_ad_campaign_preview_list as $ad_campaign_preview) { if ($ad_campaign_preview != null) { $ad_campaign_list[] = $ad_campaign_preview; if ($ad_campaign_preview->AdCampaignID != null) { $ad_campaign_markup = \util\Markup::getMarkupForAdCampaign($ad_campaign_preview->AdCampaignID); if ($ad_campaign_markup != null) { $campaign_markup_rate_list[$ad_campaign_preview->AdCampaignID] = $ad_campaign_markup->MarkupRate * 100; } else { $campaign_markup_rate_list[$ad_campaign_preview->AdCampaignID] = $user_markup_rate * 100; } } } } $user_markup_rate *= 100; $view = new ViewModel(array('ad_campaigns' => $ad_campaign_list, 'is_admin' => strpos($this->auth->getPrimaryRole(), $this->config_handle['roles']['admin']) !== false, 'user_id_list' => $this->user_id_list_demand_customer, 'effective_id' => $this->auth->getEffectiveIdentityID(), 'campaign_markup_rate_list' => $campaign_markup_rate_list, 'user_markup_rate' => $user_markup_rate, 'dashboard_view' => 'demand', 'user_identity' => $this->identity(), 'true_user_name' => $this->auth->getUserName(), 'is_admin' => $this->is_admin, 'effective_id' => $this->auth->getEffectiveIdentityID(), 'impersonate_id' => $this->ImpersonateID)); if ($this->is_admin == false || $this->is_admin == true && $this->DemandCustomerInfoID != null && $this->auth->getEffectiveIdentityID() != 0) { $view->header_title = '<a href="/demand/createcampaign/">Create Campaign</a>'; } else { $view->header_title = ' '; } return $view; }
/** * Will Show the dashboard index page. * (non-PHPdoc) * @see \Zend\Mvc\Controller\AbstractActionController::indexAction() */ public function indexAction() { $initialized = $this->initialize(); if ($initialized !== true) { return $initialized; } $user_markup_rate = $this->config_handle['system']['default_demand_markup_rate']; $campaign_markup_rate_list = array(); if ($this->is_super_admin) { // admin is logged in as a user, get the markup if any for that user if ($this->ImpersonateID != 0 && !empty($this->DemandCustomerInfoID)) { $user_markup = \util\Markup::getMarkupForUser($this->auth->getEffectiveIdentityID(), $this->config_handle, false); if ($user_markup != null) { $user_markup_rate = $user_markup->MarkupRate; } } } $InsertionOrderFactory = \_factory\InsertionOrder::get_instance(); $params = array(); $params["Active"] = 1; // admin should see campaigns requiring approval and the user they belong to ONLY if ($this->is_domain_admin) { $params["UserID"] = $this->auth->getUserID(); } else { $params["UserID"] = $this->auth->getEffectiveUserID(); } $_ad_campaign_list = $InsertionOrderFactory->get($params); $InsertionOrderPreviewFactory = \_factory\InsertionOrderPreview::get_instance(); $ad_campaign_list = array(); // admin should see campaigns requiring approval and the user they belong to ONLY foreach ($_ad_campaign_list as $ad_campaign) { $is_preview = \transformation\TransformPreview::doesPreviewInsertionOrderExistForInsertionOrder($ad_campaign->InsertionOrderID, $this->auth); if ($is_preview != true) { $ad_campaign_list[] = $ad_campaign; $ad_campaign_markup = \util\Markup::getMarkupForInsertionOrder($ad_campaign->InsertionOrderID, $this->config_handle, false); if ($ad_campaign_markup != null) { $campaign_markup_rate_list[$ad_campaign->InsertionOrderID] = $ad_campaign_markup->MarkupRate * 100; } else { $campaign_markup_rate_list[$ad_campaign->InsertionOrderID] = $user_markup_rate * 100; } } } // get previews $params = array(); $params["Active"] = 1; // $params["Deleted"] = 0; if ($this->is_super_admin == true && $this->auth->getEffectiveIdentityID() != 0) { $params["UserID"] = $this->auth->getEffectiveUserID(); } elseif ($this->is_super_admin == false) { $params["UserID"] = $this->auth->getUserID(); } $_ad_campaign_preview_list = $InsertionOrderPreviewFactory->get($params); foreach ($_ad_campaign_preview_list as $ad_campaign_preview) { if ($ad_campaign_preview != null) { $ad_campaign_list[] = $ad_campaign_preview; if ($ad_campaign_preview->InsertionOrderID != null) { $ad_campaign_markup = \util\Markup::getMarkupForInsertionOrder($ad_campaign_preview->InsertionOrderID, $this->config_handle, false); if ($ad_campaign_markup != null) { $campaign_markup_rate_list[$ad_campaign_preview->InsertionOrderID] = $ad_campaign_markup->MarkupRate * 100; } else { $campaign_markup_rate_list[$ad_campaign_preview->InsertionOrderID] = $user_markup_rate * 100; } } } } $user_markup_rate *= 100; $view = new ViewModel(array('ad_campaigns' => $ad_campaign_list, 'is_super_admin' => $this->auth->isSuperAdmin($this->config_handle), 'is_domain_admin' => $this->auth->isDomainAdmin($this->config_handle), 'user_id_list' => $this->user_id_list_demand_customer, 'effective_id' => $this->auth->getEffectiveIdentityID(), 'campaign_markup_rate_list' => $campaign_markup_rate_list, 'user_markup_rate' => $user_markup_rate, 'dashboard_view' => 'private-exchange', 'user_identity' => $this->identity(), 'true_user_name' => $this->auth->getUserName(), 'is_super_admin' => $this->is_super_admin, 'effective_id' => $this->auth->getEffectiveIdentityID(), 'impersonate_id' => $this->ImpersonateID)); if ($this->is_super_admin == false || $this->is_super_admin == true && $this->DemandCustomerInfoID != null && $this->auth->getEffectiveIdentityID() != 0) { $view->header_title = '<a href="/private-exchange/createinsertionorder/">Create Insertion Order</a>'; } else { $view->header_title = ' '; } return $view; }
private function process_demand_tag($config, $banner_request) { $banner_request_id = intval($banner_request["demand_banner_id"]); if (isset($banner_request["winning_seat"]) && $banner_request["winning_partner_id"]) { $buyer_id = 'local:' . $banner_request["winning_partner_id"] . ':' . $banner_request["winning_seat"]; } else { $buyer_id = $this->getRequest()->getQuery('buyerid'); } $cache_file_dir = $config['delivery']['cache_file_location'] . 'demand/' . date('m.d.Y') . '/' . date('H') . '/' . date('i') . '/'; if (!file_exists($cache_file_dir)) { mkdir($cache_file_dir, 0777, true); } $tag_type = "default"; if (isset($banner_request["dt"]) && $banner_request["dt"]) { $tag_type = trim($banner_request["dt"]); } $cache_file = $cache_file_dir . $banner_request_id . "." . $tag_type . ".zone.txt"; $InsertionOrderLineItemFactory = \_factory\InsertionOrderLineItem::get_instance(); $params = array(); $params["InsertionOrderLineItemID"] = $banner_request_id; $InsertionOrderLineItem = $InsertionOrderLineItemFactory->get_row_cached($config, $params); if ($InsertionOrderLineItem != null) { $banner_impression_cost = $InsertionOrderLineItem->BidAmount; $spend_increase_gross = floatval($banner_impression_cost) / 1000; $spend_increase_net = $spend_increase_gross; $found_second_price = false; if ($banner_request["winbid"] !== null && !empty($banner_request["winbid"])) { $decrypted_second_price = $this->decrypt_second_price($banner_request["winbid"]); if (floatval($decrypted_second_price)) { $spend_increase_net = floatval($decrypted_second_price) / 1000; $found_second_price = true; } } if ($found_second_price === false) { /* * We already marked down this demand customer's bid when we sent it to the DSP * So at this point we have to get the original bid price set by the demand user * in the demand dashboard and set it to the gross cost for the demand customer. * If we got a second price URL Macro parameter from the DSP, then we are finished. * We set the second price to the net price for the impression. * Otherwise we have to calculate the markup on the demand dashboard bid again * and get the net impression price that way. * * Remember that the RTB bid price sent to the DSP was already marked down by the markup * price in class RtbBuyV22Workflow: * Line 544: $adusted_amount = floatval($InsertionOrderLineItem->BidAmount) - floatval($mark_down); */ $InsertionOrderFactory = \_factory\InsertionOrder::get_instance(); $params = array(); $params["InsertionOrderID"] = $InsertionOrderLineItem->InsertionOrderID; $InsertionOrder = $InsertionOrderFactory->get_row_cached($config, $params); $markup_rate = \util\Markup::getMarkupRate($InsertionOrder, $config); $mark_down = floatval($spend_increase_gross) * floatval($markup_rate); $spend_increase_net = floatval($spend_increase_gross) - floatval($mark_down); } $InsertionOrderLineItemFactory->incrementInsertionOrderLineItemImpressionsCounterAndSpendCached($config, $buyer_id, $banner_request_id, $spend_increase_gross, $spend_increase_net); $InsertionOrderLineItemFactory->incrementBuySideHourlyImpressionsByTLDCached($config, $banner_request_id, $banner_request["tld"]); $is_video_impression = false; if (isset($banner_request["ImpressionType"]) && $banner_request["ImpressionType"] == 'video' || isset($banner_request["video"]) && $banner_request["video"] == 'vast') { $is_video_impression = true; } /* * Video can not be cached */ if (file_exists($cache_file) && $is_video_impression === false) { $cached_tag = file_get_contents($cache_file); if ($banner_request["dt"] == "in") { $this->ad_macros_to_adtag($cached_tag, $banner_request); header("Content-type: application/javascript"); } else { $this->ad_macros_to_adtag($cached_tag, $banner_request); } echo $cached_tag; exit; } $tag_cachable = true; if ($is_video_impression === true) { $adtag = $InsertionOrderLineItem->AdTag; if (\util\ParseHelper::isVastURL($adtag) === true) { $tracker_url = ""; if (isset($banner_request["tracker_url"])) { $tracker_url = $banner_request["tracker_url"]; } $output = $this->get_vast_wrapper_xml($config, $adtag, $tracker_url); $tag_cachable = false; } else { $output = $adtag; } header("Content-type: text/xml"); } elseif ($banner_request["dt"] == "in") { header("Content-type: application/javascript"); $output = "document.write(" . json_encode($InsertionOrderLineItem->AdTag) . ");"; } else { $output = "<!DOCTYPE html>\n<html><head></head><body style=\"margin: 0px; padding: 0px;\">" . $InsertionOrderLineItem->AdTag . "\r\n\r\n</body></html>"; } if ($tag_cachable === true) { $fh = fopen($cache_file, "w"); fwrite($fh, $output); fclose($fh); } if ($is_video_impression === false) { $this->ad_macros_to_adtag($output, $banner_request); } echo $output; exit; } echo "NGINAD"; exit; }
public function privateexchangeAction() { $initialized = $this->initialize(); if ($initialized !== true) { return $initialized; } $PrivateExchangeRtbChannelDailyStatsRollUpPxFilterFactory = \_factory\PrivateExchangeRtbChannelDailyStatsRollUpPxFilter::get_instance(); $params = array(); if ($this->auth->isSuperAdmin($this->config_handle)) { $params["ParentID"] = $this->auth->getEffectiveIdentityID(); } else { $params["ParentID"] = $this->auth->getUserID(); } $PrivateExchangeRtbChannelDailyStatsRollUpPxFilterList = $PrivateExchangeRtbChannelDailyStatsRollUpPxFilterFactory->get($params); $insertion_order_id = $this->getRequest()->getQuery('insertion-order-id'); if ($insertion_order_id != null) { $insertion_order_id = intval($insertion_order_id); $markup_rate = \util\Markup::getMarkupRateByInsertionOrderIDAndUserID($insertion_order_id, $this->auth->getEffectiveIdentityID(), $this->config_handle); } else { $user_markup = \util\Markup::getMarkupForUser($this->auth->getEffectiveIdentityID(), $this->config_handle, false); if ($user_markup != null) { $markup_rate = $user_markup->MarkupRate; } else { $markup_rate = $this->config_handle['system']['default_demand_markup_rate']; } } $data = array(); $PublisherWebsiteFactory = \_factory\PublisherWebsite::get_instance(); foreach ($PrivateExchangeRtbChannelDailyStatsRollUpPxFilterList as $PrivateExchangeRtbChannelDailyStatsRollUpPxFilter) { $site_id = $PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->PublisherWebsiteID; $site_name = $PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->RtbChannelSiteName; if (strlen($site_name) > 20) { $site_name = substr($site_name, 0, 20) . '…'; } $publisher_name = $PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->PublisherName; if (strlen($publisher_name) > 20) { $publisher_name = substr($publisher_name, 0, 20) . '…'; } $label_name = $PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->WebDomain . " - " . $site_name . " - " . $publisher_name; $adusted_floor_price = ""; if ($PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->BidFloor) { $floor_price = floatval($PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->BidFloor); $params = array(); $params["PublisherWebsiteID"] = $site_id; $PublisherWebsite = $PublisherWebsiteFactory->get_row_cached($this->config_handle, $params); if ($PublisherWebsite == null) { continue; } // floor should be marked up by the private exchange domain admin rate for this publisher and website $px_markup_rate_for_publisher = \util\Markup::getPrivateExchangePublisherMarkupRate($site_id, $PublisherWebsite->DomainOwnerID, $this->config_handle); $mark_up = $floor_price * floatval($px_markup_rate_for_publisher); $adusted_floor_price = floatval($floor_price) + floatval($mark_up); // floor should be marked up by the global exchange rate for this publisher and website $exchange_markup_rate_for_publisher = \util\Markup::getPublisherMarkupRate($site_id, $PublisherWebsite->DomainOwnerID, $this->config_handle); $mark_up = $adusted_floor_price * floatval($exchange_markup_rate_for_publisher); $adusted_floor_price = floatval($adusted_floor_price) + floatval($mark_up); // floor should be marked up by the IO markup rate // Approximation: actual implementation is mark-down in buyrtb\workflows\OpenRTBWorkflow $mark_up = $adusted_floor_price * floatval($markup_rate); $adusted_floor_price = floatval($adusted_floor_price) + floatval($mark_up); $adusted_floor_price = sprintf("%1.2f", $adusted_floor_price); } $row = array(" " => '<input type="checkbox" labelname="' . rawurlencode($label_name) . '" class="ckssp" name="ckssp[]" value="' . rawurlencode($PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->PublisherWebsiteID . '::' . $label_name) . '" />', "Site ID" => $site_id, "Domain" => $PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->WebDomain, "Name" => $site_name, "IAB Cat" => $PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->IABCategory, "Daily Imps" => number_format($PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->ImpressionsOfferedCounter), "Average CPM" => $PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->BidTotalAverage, "Floor" => $adusted_floor_price, "Exchange" => $PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->BuySidePartnerName); $data[] = $row; } $this->setJsonHeader(); return $this->getResponse()->setContent(json_encode(array("data" => $data))); }
public function process_business_rules_workflow($logger, $config, $rtb_seat_id, &$no_bid_reason, \model\openrtb\RtbBidRequest &$RtbBidRequest) { $this->config = $config; $this->rtb_seat_id = $rtb_seat_id; // $logger = \rtbbuyv22\RtbBuyV22Logger::get_instance(); $AdCampaignBanner_Match_List = array(); $AdCampaignFactory = \_factory\AdCampaign::get_instance(); $params = array(); $params["Active"] = 1; $AdCampaignList = $AdCampaignFactory->get_cached($this->config, $params); $this->current_time = time(); $AdCampaignBannerFactory = \_factory\AdCampaignBanner::get_instance(); $AdCampaignBannerDomainExclusionFactory = \_factory\AdCampaignBannerDomainExclusion::get_instance(); $AdCampaignBannerExclusiveInclusionFactory = \_factory\AdCampaignBannerDomainExclusiveInclusion::get_instance(); $AdCampaignBannerRestrictionsFactory = \_factory\AdCampaignBannerRestrictions::get_instance(); $AdCampaignVideoRestrictionsFactory = \_factory\AdCampaignVideoRestrictions::get_instance(); // match ip against country code \buyrtb\workflows\tasklets\common\adcampaign\GetGeoCodeCountry::execute($logger, $this, $RtbBidRequest); // Check Ad Fraud if (\buyrtb\workflows\tasklets\common\thirdparty\CheckPublisherScore::execute($logger, $this, $RtbBidRequest) === false) { $no_bid_reason = NOBID_BAD_PUBLISHER; return $AdCampaignBanner_Match_List; } // Check Publisher Score if (\buyrtb\workflows\tasklets\common\thirdparty\CheckAdFraud::execute($logger, $this, $RtbBidRequest) === false) { $no_bid_reason = NOBID_AD_FRAUD; return $AdCampaignBanner_Match_List; } // Check Cookie Match if (\buyrtb\workflows\tasklets\common\thirdparty\CheckCookieMatch::execute($logger, $this, $RtbBidRequest) === false) { $no_bid_reason = NOBID_UNMATCHED_USER; return $AdCampaignBanner_Match_List; } foreach ($AdCampaignList as $AdCampaign) { // Check campaign date if (\buyrtb\workflows\tasklets\common\adcampaign\CheckCampaignDate::execute($logger, $this, $RtbBidRequest, $AdCampaign) === false) { continue; } // Check max spend if (\buyrtb\workflows\tasklets\common\adcampaign\CheckMaxSpend::execute($logger, $this, $RtbBidRequest, $AdCampaign) === false) { continue; } // Check max impressions if (\buyrtb\workflows\tasklets\common\adcampaign\CheckMaxImpressions::execute($logger, $this, $RtbBidRequest, $AdCampaign) === false) { continue; } // get markup rate for ad campaign $markup_rate = \util\Markup::getMarkupRate($AdCampaign, $this->config); // iterate the active banners for this ad campaign $params = array(); $params["AdCampaignID"] = $AdCampaign->AdCampaignID; $params["Active"] = 1; $AdCampaignBannerList = $AdCampaignBannerFactory->get_cached($this->config, $params); foreach ($RtbBidRequest->RtbBidRequestImpList as $RtbBidRequestImp) { foreach ($AdCampaignBannerList as $AdCampaignBanner) { if (empty($RtbBidRequestImp->RtbBidRequestVideo) && $AdCampaignBanner->ImpressionType == 'video' || !empty($RtbBidRequestImp->RtbBidRequestVideo) && $AdCampaignBanner->ImpressionType == 'banner') { continue; } /* * check the business rules against the banner */ // Check banner date if (\buyrtb\workflows\tasklets\common\adcampaignbanner\CheckBannerDate::execute($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $AdCampaignBanner) === false) { continue; } // Check to see if this AdCampaginBanner is associated to a contract zone. if (\buyrtb\workflows\tasklets\common\adcampaignbanner\CheckIsContract::execute($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $AdCampaignBanner) === false) { continue; } // Check banner domain exclusive inclusions if (\buyrtb\workflows\tasklets\common\adcampaignbanner\CheckExclusiveInclusion::execute($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $AdCampaignBanner, $AdCampaignBannerExclusiveInclusionFactory) === false) { continue; } // Check banner domain exclusions match if (\buyrtb\workflows\tasklets\common\adcampaignbanner\CheckDomainExclusion::execute($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $AdCampaignBanner, $AdCampaignBannerDomainExclusionFactory) === false) { continue; } if (!empty($RtbBidRequestImp->RtbBidRequestVideo)) { // Video Workflow $VideoWorkflow = new \buyrtb\workflows\VideoWorkflow(); $passed_child_workflow = $VideoWorkflow->process_business_rules_workflow($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $AdCampaignBanner, $AdCampaignVideoRestrictionsFactory); } else { // Display Banner Workflow - Default $DisplayWorkflow = new \buyrtb\workflows\DisplayWorkflow(); $passed_child_workflow = $DisplayWorkflow->process_business_rules_workflow($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $AdCampaignBanner, $AdCampaignBannerRestrictionsFactory); } if ($passed_child_workflow === false) { continue; } /* * PASSED ALL THE BUSINESS RULES, ADD TO THE RESULTS */ $AdCampaignBannerFactory->incrementAdCampaignBannerBidsCounterCached($this->config, $rtb_seat_id, $AdCampaignBanner->AdCampaignBannerID); /* * Adjust the bid rate according to the markup */ $mark_down = floatval($AdCampaignBanner->BidAmount) * floatval($markup_rate); $adusted_amount = floatval($AdCampaignBanner->BidAmount) - floatval($mark_down); $AdCampaignBanner->BidAmount = sprintf("%1.4f", $adusted_amount); // default in config $currency = $this->config['settings']['rtb']['auction_currency']; if (isset($RtbBidRequest->cur[0])) { $currency = $RtbBidRequest->cur[0]; } $AdCampaignBanner_Match_List[(string) $AdCampaignBanner->UserID][] = array("currency" => $currency, "impid" => $RtbBidRequestImp->id, "AdCampaignBanner" => $AdCampaignBanner); } } } return $AdCampaignBanner_Match_List; }
public function process_business_rules_workflow($RtbBid) { $AdCampaignBanner_Match_List = array(); $AdCampaignFactory = \_factory\AdCampaign::get_instance(); $params = array(); $params["Active"] = 1; $AdCampaignList = $AdCampaignFactory->get_cached($RtbBid->config, $params); $current_time = time(); $AdCampaignBannerFactory = \_factory\AdCampaignBanner::get_instance(); $AdCampaignBannerDomainExclusionFactory = \_factory\AdCampaignBannerDomainExclusion::get_instance(); $AdCampaignBannerExclusiveInclusionFactory = \_factory\AdCampaignBannerDomainExclusiveInclusion::get_instance(); $AdCampaignBannerRestrictionsFactory = \_factory\AdCampaignBannerRestrictions::get_instance(); // geocity light $geo_info = null; $maxmind = null; /* * use maxmind incrementally. The geo-Country pay DB we have is only 1 meg * if we need city/state ok, but only load it if absolutely necessary */ if ($RtbBid->bid_request_device_ip !== null && $RtbBid->bid_request_geo === null) { $maxmind = new \geoip\maxmind(); $RtbBid->bid_request_geo["country"] = $maxmind->get_geo_code_country($RtbBid->bid_request_device_ip); } foreach ($AdCampaignList as $AdCampaign) { /* * Check campaign date */ $campaign_startdate = strtotime($AdCampaign->StartDate); $campaign_enddate = strtotime($AdCampaign->EndDate); if ($current_time < $campaign_startdate || $current_time > $campaign_enddate) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check campaign date :: EXPECTED: " . $AdCampaign->StartDate . "->" . $AdCampaign->EndDate . " GOT: " . date('m/d/Y', $current_time); } continue; } /* * Check max spend */ if ($AdCampaign->CurrentSpend >= $AdCampaign->MaxSpend) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Max Campaign Spend Exceeded"; } continue; } /* * Check max impressions */ if ($AdCampaign->ImpressionsCounter >= $AdCampaign->MaxImpressions) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Max Campaign Impressions Exceeded"; } continue; } $markup_rate = \util\Markup::getMarkupRate($AdCampaign, $RtbBid->config); $params = array(); $params["AdCampaignID"] = $AdCampaign->AdCampaignID; $params["Active"] = 1; $AdCampaignBannerList = $AdCampaignBannerFactory->get_cached($RtbBid->config, $params); foreach ($AdCampaignBannerList as $AdCampaignBanner) { /* * check the rules against the banner */ /* * Check banner date */ $banner_startdate = strtotime($AdCampaignBanner->StartDate); $banner_enddate = strtotime($AdCampaignBanner->EndDate); if ($current_time < $banner_startdate || $current_time > $banner_enddate) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check banner date :: EXPECTED: " . $AdCampaignBanner->StartDate . "->" . $AdCampaignBanner->EndDate . " GOT: " . date('m/d/Y', $current_time); } continue; } /* * Check is mobile web, phone, tablet, native iOS or native Android */ if ($RtbBid->bid_request_mobile != $AdCampaignBanner->IsMobile) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check is mobile web :: EXPECTED: " . $AdCampaignBanner->IsMobile . " GOT: " . $RtbBid->bid_request_mobile; } continue; } /* * Check banner height and width match */ if ($AdCampaignBanner->Height != $RtbBid->bid_request_imp_banner_h || $AdCampaignBanner->Width != $RtbBid->bid_request_imp_banner_w) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check banner height match :: EXPECTED: " . $AdCampaignBanner->Height . " GOT: " . $RtbBid->bid_request_imp_banner_h; \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check banner width match :: EXPECTED: " . $AdCampaignBanner->Width . " GOT: " . $RtbBid->bid_request_imp_banner_w; } continue; } /* * Check to see if this AdCampaginBanner is associated to a * contract zone. Contract bound banners are not eligible for * RTB bidding. */ if ($AdCampaignBanner->AdCampaignTypeID == AD_TYPE_CONTRACT) { continue; } elseif ($AdCampaignBanner->AdCampaignTypeID == AD_TYPE_IN_HOUSE_REMNANT && $RtbBid->is_local_request == false) { continue; } elseif ($AdCampaignBanner->AdCampaignTypeID == AD_TYPE_RTB_REMNANT && $RtbBid->is_local_request == true) { continue; } /* * Check banner domain exclusive inclusions * This will narrow the publisher pool down so we * only working with the publishers that the client wants * to advertise on. */ $params = array(); $params["AdCampaignBannerID"] = $AdCampaignBanner->AdCampaignBannerID; $AdCampaignBannerExclusiveInclusionList = $AdCampaignBannerExclusiveInclusionFactory->get_cached($RtbBid->config, $params); foreach ($AdCampaignBannerExclusiveInclusionList as $AdCampaignBannerExclusiveInclusion) { $domain_to_match = strtolower($AdCampaignBannerExclusiveInclusion->DomainName); if ($AdCampaignBannerExclusiveInclusion->InclusionType == "url") { if (strpos(strtolower($RtbBid->bid_request_site_page), $domain_to_match) === false && strpos(strtolower($RtbBid->bid_request_site_domain), $domain_to_match) === false) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check banner page url, site exclusive inclusions do not match :: EXPECTED: " . $domain_to_match . " GOT: bid_request_site_page: " . $RtbBid->bid_request_site_page . ", bid_request_site_domain: " . $RtbBid->bid_request_site_domain; } // goto next in the larger enclosing foreach loop continue 2; } } elseif ($RtbBid->bid_request_refurl && $AdCampaignBannerExclusiveInclusion->InclusionType == "referrer") { if (strpos(strtolower($RtbBid->bid_request_refurl), $domain_to_match) === false) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check banner page referrer url, site exclusive inclusions do not match :: EXPECTED: " . $domain_to_match . " GOT: " . $RtbBid->bid_request_refurl; } continue 2; } } } /* * Check banner domain exclusions match */ $params = array(); $params["AdCampaignBannerID"] = $AdCampaignBanner->AdCampaignBannerID; $AdCampaignBannerDomainExclusionList = $AdCampaignBannerDomainExclusionFactory->get_cached($RtbBid->config, $params); foreach ($AdCampaignBannerDomainExclusionList as $AdCampaignBannerDomainExclusion) { $domain_to_match = strtolower($AdCampaignBannerDomainExclusion->DomainName); if ($AdCampaignBannerDomainExclusion->ExclusionType == "url") { if (strpos(strtolower($RtbBid->bid_request_site_page), $domain_to_match) !== false || strpos(strtolower($RtbBid->bid_request_site_domain), $domain_to_match) !== false) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check banner page url, site exclusions match :: EXPECTED: " . $domain_to_match . " GOT: bid_request_site_page: " . $RtbBid->bid_request_site_page . ", bid_request_site_domain: " . $RtbBid->bid_request_site_domain; } // goto next in the larger enclosing foreach loop continue 2; } } elseif ($RtbBid->bid_request_refurl && $AdCampaignBannerDomainExclusion->ExclusionType == "referrer") { if (strpos(strtolower($RtbBid->bid_request_refurl), $domain_to_match) !== false) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check banner page referrer url, site exclusions match :: EXPECTED: " . $domain_to_match . " GOT: " . $RtbBid->bid_request_refurl; } continue 2; } } } /* * Check banner restrictions (optional fields) */ $params = array(); $params["AdCampaignBannerID"] = $AdCampaignBanner->AdCampaignBannerID; $AdCampaignBannerRestrictions = $AdCampaignBannerRestrictionsFactory->get_row_cached($RtbBid->config, $params); /* * Check banner restrictions */ if ($AdCampaignBannerRestrictions !== null) { /* * Check banner position on page */ /* * Banner position check not supported by OpenRTB 2.1 */ /* * Check banner system fold position (sFoldPos), I don't think we can trust the user fold position (uFoldPos) */ if ($AdCampaignBannerRestrictions->FoldPos !== null && $RtbBid->bid_request_sFoldPos !== null && $AdCampaignBannerRestrictions->FoldPos != $RtbBid->bid_request_sFoldPos) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check banner system fold position :: EXPECTED: " . $AdCampaignBannerRestrictions->FoldPos . " GOT: " . $RtbBid->bid_request_sFoldPos; } continue; } /* * Frequency capping not supported by OpenRTB 2.1 */ /* * Time Zone not supported by OpenRTB 2.1 */ /* * IFrame detection not supported by OpenRTB 2.1 */ /* * Multiple nested IFrames detection not supported by OpenRTB 2.1 */ /* * Client's screen resolution detection not supported by OpenRTB 2.1 */ /* * Check browser language */ if ($AdCampaignBannerRestrictions->HttpLanguage !== null && $RtbBid->bid_request_device_language !== null) { $has_http_language = false; $request_language_list = explode(";", strtolower($RtbBid->bid_request_device_language)); $http_language_list = explode(";", strtolower($AdCampaignBannerRestrictions->HttpLanguage)); foreach ($http_language_list as $http_language) { if (in_array(trim($http_language), $request_language_list)) { $has_http_language = true; break; } } if ($has_http_language === false) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check browser language :: EXPECTED: " . $AdCampaignBannerRestrictions->HttpLanguage . " GOT: " . $RtbBid->bid_request_device_language; } continue; } } /* * Check browser user-agent for string */ if ($AdCampaignBannerRestrictions->BrowserUserAgentGrep !== null && $RtbBid->bid_request_device_ua !== null) { if (strpos(strtolower($RtbBid->bid_request_device_ua), strtolower($AdCampaignBannerRestrictions->BrowserUserAgentGrep)) === false) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check browser user-agent for string :: EXPECTED: " . $AdCampaignBannerRestrictions->BrowserUserAgentGrep . " GOT: " . $RtbBid->bid_request_device_ua; } continue; } } /* * Check browser cookie for string detection not supported by OpenRTB 2.1 */ /* * Check banner for PMP Enable */ if ($AdCampaignBannerRestrictions->PmpEnable !== null && $RtbBid->bid_request_imp_pmp !== null && $RtbBid->bid_request_imp_pmp != $AdCampaignBannerRestrictions->PmpEnable) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check banner for PMP Enable :: EXPECTED: " . $AdCampaignBannerRestrictions->PmpEnable . " GOT: " . $RtbBid->bid_request_imp_pmp; } continue; } /* * Check banner for https:// secure */ if ($AdCampaignBannerRestrictions->Secure !== null && $RtbBid->bid_request_secure !== null && $RtbBid->bid_request_secure != $AdCampaignBannerRestrictions->Secure) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check banner for https:// secure :: EXPECTED: " . $AdCampaignBannerRestrictions->Secure . " GOT: " . $RtbBid->bid_request_secure; } continue; } /* * Check user for Coppa opt out status */ if ($AdCampaignBannerRestrictions->Optout !== null && $RtbBid->bid_request_regs_coppa !== null && $RtbBid->bid_request_regs_coppa != $AdCampaignBannerRestrictions->Optout) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check user for Coppa opt out status :: EXPECTED: " . $AdCampaignBannerRestrictions->Optout . " GOT: " . $RtbBid->bid_request_regs_coppa; } continue; } /* * Check banner for it being in the right vertical */ if ($AdCampaignBannerRestrictions->Vertical !== null && $RtbBid->bid_request_site_publisher_cat !== null) { $has_vertical = false; $vertical_list = explode(",", $AdCampaignBannerRestrictions->Vertical); foreach ($vertical_list as $vertical_id) { if ($RtbBid->bid_request_site_publisher_cat == $vertical_id) { $has_vertical = true; break; } } if ($has_vertical === false) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check banner for it being in the right vertical :: EXPECTED: " . $AdCampaignBannerRestrictions->Vertical . " GOT: " . $RtbBid->bid_request_site_publisher_cat; } continue; } } /* * Check banner geography */ if ($RtbBid->bid_request_geo !== null) { if ($AdCampaignBannerRestrictions->GeoCountry !== null && isset($RtbBid->bid_request_geo["country"])) { $has_country = false; $country = strtolower($RtbBid->bid_request_geo["country"]); $geo_country_list = explode(",", $AdCampaignBannerRestrictions->GeoCountry); foreach ($geo_country_list as $geo_country) { if (strtolower($geo_country) == $country) { $has_country = true; break; } } if ($has_country === false) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check banner geography : Country :: EXPECTED: " . strtolower($AdCampaignBannerRestrictions->GeoCountry) . " GOT: " . $country; } continue; } else { /* * STATE CHECK */ if ($geo_info === null && $AdCampaignBannerRestrictions->GeoState !== null && !isset($RtbBid->bid_request_geo["state"])) { if ($maxmind === null) { $maxmind = new \geoip\maxmind(); } $geo_info = $maxmind->get_geo_code($RtbBid->bid_request_device_ip); if ($geo_info !== null) { $RtbBid->bid_request_geo["state"] = $geo_info["state"]; $RtbBid->bid_request_geo["city"] = $geo_info["city"]; } } if ($AdCampaignBannerRestrictions->GeoState !== null && isset($RtbBid->bid_request_geo["state"])) { if (!isset($RtbBid->bid_request_geo["state"]) && $geo_info === null) { $geo_info = $maxmind->get_geo_code($this->bid_request_device_ip); $this->bid_request_geo["state"] = $geo_info["state"]; } $has_state = false; $state = strtolower($RtbBid->bid_request_geo["state"]); $geo_state_list = explode(",", $AdCampaignBannerRestrictions->GeoState); foreach ($geo_state_list as $geo_state) { if (strtolower($geo_state) == $state) { $has_state = true; break; } } if ($has_state === false) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check banner geography : State :: EXPECTED: " . strtolower($AdCampaignBannerRestrictions->GeoState) . " GOT: " . $state; } continue; } else { /* * CITY CHECK */ if ($geo_info === null && $AdCampaignBannerRestrictions->GeoCity !== null && !isset($RtbBid->bid_request_geo["city"])) { if ($maxmind === null) { $maxmind = new \geoip\maxmind(); } $geo_info = $maxmind->get_geo_code($RtbBid->bid_request_device_ip); $RtbBid->bid_request_geo["state"] = $geo_info["state"]; $RtbBid->bid_request_geo["city"] = $geo_info["city"]; } if ($AdCampaignBannerRestrictions->GeoCity !== null && isset($RtbBid->bid_request_geo["city"])) { $has_city = false; $city = strtolower($RtbBid->bid_request_geo["city"]); $geo_city_list = explode(",", $AdCampaignBannerRestrictions->GeoCity); foreach ($geo_city_list as $geo_city) { if (strtolower($geo_city) == $city) { $has_city = true; break; } } if ($has_city === false) { if (\rtbbuyv22\RtbBuyV22Logger::get_instance()->setting_log === true) { \rtbbuyv22\RtbBuyV22Logger::get_instance()->log[] = "Failed: " . "Check banner geography : City :: EXPECTED: " . strtolower($AdCampaignBannerRestrictions->GeoCity) . " GOT: " . $city; } continue; } } } } } } } } /* * PASSED ALL THE BUSINESS RULES, ADD TO THE RESULTS */ $AdCampaignBannerFactory->incrementAdCampaignBannerBidsCounterCached($RtbBid->config, $RtbBid->rtb_seat_id, $AdCampaignBanner->AdCampaignBannerID); /* * Adjust the bid rate according to the markup */ $mark_down = floatval($AdCampaignBanner->BidAmount) * floatval($markup_rate); $adusted_amount = floatval($AdCampaignBanner->BidAmount) - floatval($mark_down); $AdCampaignBanner->BidAmount = sprintf("%1.4f", $adusted_amount); $AdCampaignBanner_Match_List[] = $AdCampaignBanner; } } return $AdCampaignBanner_Match_List; }