예제 #1
0
 /**
  *
  * @return JSON encoded data for AJAX call
  */
 public function editlinkedbannerAction()
 {
     $id = intval($this->params()->fromRoute('id', 0));
     $height = $this->getRequest()->getQuery('height');
     $width = $this->getRequest()->getQuery('width');
     if ($height == null || $width == null) {
         $data = array('success' => false, 'linked_ad_zones' => "", 'complete_zone_list' => array());
         return $this->getResponse()->setContent(json_encode($data));
     }
     $initialized = $this->initialize();
     if ($initialized !== true) {
         return $initialized;
     }
     if (!$this->is_admin) {
         $data = array('success' => false, 'linked_ad_zones' => "", 'complete_zone_list' => array());
         return $this->getResponse()->setContent(json_encode($data));
     }
     // verify
     $linked_ad_banners = array();
     $PublisherAdZoneFactory = \_factory\PublisherAdZone::get_instance();
     if ($id) {
         $params = array("PublisherAdZoneID" => $id);
         $PublisherAdZone = $PublisherAdZoneFactory->get_row_object($params);
         if ($PublisherAdZone == null || $PublisherAdZone->AdOwnerID != $this->PublisherInfoID) {
             $error_message = "An invalid Ad Zone ID was provided.";
             $data = array('success' => false, 'error' => $error_message, 'linked_ad_zones' => "", 'complete_zone_list' => array());
             return $this->getResponse()->setContent(json_encode($data));
         }
         $LinkedBannerToAdZoneFactory = \_factory\LinkedBannerToAdZone::get_instance();
         $params = array();
         $params["PublisherAdZoneID"] = $id;
         $linked_ad_banners = $LinkedBannerToAdZoneFactory->get($params);
     }
     $params = array();
     $params["Height"] = $height;
     $params["Width"] = $width;
     $params["Active"] = 1;
     // $params["UserID"] 	= $this->EffectiveID;
     $AdCampaignBannerFactory = \_factory\AdCampaignBanner::get_instance();
     $AdCampaignBannerList = $AdCampaignBannerFactory->get($params);
     if ($AdCampaignBannerList === null) {
         $AdCampaignBannerList = array();
     }
     $complete_banner_list = array();
     foreach ($AdCampaignBannerList as $AdCampaignBanner) {
         $complete_banner_list[] = array("banner_id" => $AdCampaignBanner->AdCampaignBannerID, "ad_name" => $AdCampaignBanner->Name);
     }
     $linked_banner_list = array();
     foreach ($linked_ad_banners as $linked_ad_banner) {
         $linked_banner_list[] = $linked_ad_banner->AdCampaignBannerID;
     }
     $data = array('success' => count($AdCampaignBannerList) > 0, 'linked_ad_banners' => implode(',', $linked_banner_list), 'complete_banner_list' => $complete_banner_list);
     return $this->getResponse()->setContent(json_encode($data));
 }
예제 #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
 /**
  *
  * @return JSON encoded data for AJAX call
  */
 public function editlinkedzoneAction()
 {
     $id = $this->getEvent()->getRouteMatch()->getParam('param1');
     $height = $this->getRequest()->getQuery('height');
     $width = $this->getRequest()->getQuery('width');
     $is_preview = $this->getRequest()->getQuery('is_preview');
     if ($height == null || $width == null) {
         $data = array('success' => false, 'linked_ad_zones' => "", 'complete_zone_list' => array());
         return $this->getResponse()->setContent(json_encode($data));
     }
     $initialized = $this->initialize();
     if ($initialized !== true) {
         return $initialized;
     }
     if (!$this->is_admin) {
         $data = array('success' => false, 'linked_ad_zones' => "", 'complete_zone_list' => array());
         return $this->getResponse()->setContent(json_encode($data));
     }
     // verify
     if ($is_preview == "true") {
         $is_preview = \transformation\TransformPreview::doesPreviewBannerExist($id, $this->auth);
     }
     $banner_preview_id = "";
     $linked_ad_zones = array();
     if ($id != null) {
         if ($is_preview === true) {
             // ACL PREVIEW PERMISSIONS CHECK
             transformation\CheckPermissions::checkEditPermissionAdCampaignBannerPreview($id, $this->auth, $this->config_handle);
             $AdCampaignBannerPreviewFactory = \_factory\AdCampaignBannerPreview::get_instance();
             $params = array();
             $params["Active"] = 1;
             $params["AdCampaignBannerPreviewID"] = $id;
             $banner_preview_id = $id;
             $AdCampaignBanner = $AdCampaignBannerPreviewFactory->get_row($params);
             $LinkedBannerToAdZonePreviewFactory = \_factory\LinkedBannerToAdZonePreview::get_instance();
             $params = array();
             $params["AdCampaignBannerPreviewID"] = $id;
             $linked_ad_zones = $LinkedBannerToAdZonePreviewFactory->get($params);
         } else {
             // ACL PERMISSIONS CHECK
             transformation\CheckPermissions::checkEditPermissionAdCampaignBanner($id, $this->auth, $this->config_handle);
             $AdCampaignBannerFactory = \_factory\AdCampaignBanner::get_instance();
             $params = array();
             $params["Active"] = 1;
             $params["AdCampaignBannerID"] = $id;
             $AdCampaignBanner = $AdCampaignBannerFactory->get_row($params);
             $LinkedBannerToAdZoneFactory = \_factory\LinkedBannerToAdZone::get_instance();
             $params = array();
             $params["AdCampaignBannerID"] = $id;
             $linked_ad_zones = $LinkedBannerToAdZoneFactory->get($params);
         }
     }
     $params = array();
     $params["Height"] = $height;
     $params["Width"] = $width;
     // $params["AdOwnerID"] = \transformation\UserToPublisher::user_id_to_publisher_info_id($this->auth->getEffectiveUserID());
     $PublisherAdZoneFactory = \_factory\PublisherAdZone::get_instance();
     $PublisherAdZoneList = $PublisherAdZoneFactory->get($params);
     if ($PublisherAdZoneList === null) {
         $PublisherAdZoneList = array();
     }
     $complete_zone_list = array();
     foreach ($PublisherAdZoneList as $PublisherAdZone) {
         $complete_zone_list[] = array("zone_id" => $PublisherAdZone->PublisherAdZoneID, "ad_name" => $PublisherAdZone->AdName);
     }
     $linked_zone_list = array();
     foreach ($linked_ad_zones as $linked_ad_zone) {
         $linked_zone_list[] = $linked_ad_zone->PublisherAdZoneID;
     }
     $data = array('success' => count($PublisherAdZoneList) > 0, 'linked_ad_zones' => implode(',', $linked_zone_list), 'complete_zone_list' => $complete_zone_list);
     return $this->getResponse()->setContent(json_encode($data));
 }
예제 #4
0
 public static function cloneAdCampaignIntoAdCampaignPreview($ad_campaign_id, $auth, $update_data)
 {
     $return_val = array();
     if ($ad_campaign_id === null) {
         return null;
     }
     $AdCampaignFactory = \_factory\AdCampaign::get_instance();
     $params = array();
     $params["AdCampaignID"] = $ad_campaign_id;
     $params["UserID"] = $auth->getEffectiveUserID();
     $params["Active"] = 1;
     $AdCampaign = $AdCampaignFactory->get_row($params);
     if ($AdCampaign == null) {
         //die("Invalid AdCampaign ID");
         $params["error"] = "Invalid AdCampaign ID";
         return $params;
     }
     /*
      * Clone AdCampaign into AdCampaignPreview
      */
     $AdCampaignPreviewFactory = \_factory\AdCampaignPreview::get_instance();
     $AdCampaignPreview = new \model\AdCampaignPreview();
     $AdCampaignPreview->AdCampaignID = $AdCampaign->AdCampaignID;
     $AdCampaignPreview->UserID = $AdCampaign->UserID;
     $AdCampaignPreview->Name = $AdCampaign->Name;
     $AdCampaignPreview->StartDate = $AdCampaign->StartDate;
     $AdCampaignPreview->EndDate = $AdCampaign->EndDate;
     $AdCampaignPreview->Customer = $AdCampaign->Customer;
     $AdCampaignPreview->CustomerID = $AdCampaign->CustomerID;
     $AdCampaignPreview->ImpressionsCounter = 0;
     $AdCampaignPreview->MaxImpressions = $AdCampaign->MaxImpressions;
     $AdCampaignPreview->CurrentSpend = 0;
     $AdCampaignPreview->MaxSpend = $AdCampaign->MaxSpend;
     $AdCampaignPreview->Active = 1;
     $AdCampaignPreview->DateCreated = date("Y-m-d H:i:s");
     $AdCampaignPreview->DateUpdated = date("Y-m-d H:i:s");
     $AdCampaignPreview->ChangeWentLive = 0;
     $AdCampaignPreviewID = $AdCampaignPreviewFactory->saveAdCampaignPreview($AdCampaignPreview);
     if ($update_data['type'] == 'AdCampaignID') {
         $return_val = array('AdCampaignPreviewID' => $AdCampaignPreviewID);
     }
     $AdCampaignBannerFactory = \_factory\AdCampaignBanner::get_instance();
     $params = array();
     $params["AdCampaignID"] = $AdCampaign->AdCampaignID;
     $params["Active"] = 1;
     $AdCampaignBannerList = $AdCampaignBannerFactory->get($params);
     $AdCampaignBannerPreviewFactory = \_factory\AdCampaignBannerPreview::get_instance();
     $AdCampaignBannerRestrictionsFactory = \_factory\AdCampaignBannerRestrictions::get_instance();
     $AdCampaignBannerRestrictionsPreviewFactory = \_factory\AdCampaignBannerRestrictionsPreview::get_instance();
     $LinkedBannerToAdZoneFactory = \_factory\LinkedBannerToAdZone::get_instance();
     $LinkedBannerToAdZonePreviewFactory = \_factory\LinkedBannerToAdZonePreview::get_instance();
     $AdCampaignBannerDomainExclusionFactory = \_factory\AdCampaignBannerDomainExclusion::get_instance();
     $AdCampaignBannerDomainExclusionPreviewFactory = \_factory\AdCampaignBannerDomainExclusionPreview::get_instance();
     $AdCampaignBannerDomainExclusiveInclusionFactory = \_factory\AdCampaignBannerDomainExclusiveInclusion::get_instance();
     $AdCampaignBannerDomainExclusiveInclusionPreviewFactory = \_factory\AdCampaignBannerDomainExclusiveInclusionPreview::get_instance();
     foreach ($AdCampaignBannerList as $AdCampaignBanner) {
         $banner_id = $AdCampaignBanner->AdCampaignBannerID;
         $BannerPreview = new \model\AdCampaignBannerPreview();
         $BannerPreview->AdCampaignPreviewID = $AdCampaignPreviewID;
         $BannerPreview->AdCampaignBannerID = $AdCampaignBanner->AdCampaignBannerID;
         $BannerPreview->UserID = $AdCampaignBanner->UserID;
         $BannerPreview->Name = $AdCampaignBanner->Name;
         $BannerPreview->StartDate = $AdCampaignBanner->StartDate;
         $BannerPreview->EndDate = $AdCampaignBanner->EndDate;
         $BannerPreview->AdCampaignTypeID = $AdCampaignBanner->AdCampaignTypeID;
         $BannerPreview->IsMobile = $AdCampaignBanner->IsMobile;
         $BannerPreview->IABSize = $AdCampaignBanner->IABSize;
         $BannerPreview->Height = $AdCampaignBanner->Height;
         $BannerPreview->Width = $AdCampaignBanner->Width;
         $BannerPreview->Weight = $AdCampaignBanner->Weight;
         $BannerPreview->BidAmount = $AdCampaignBanner->BidAmount;
         $BannerPreview->AdTag = $AdCampaignBanner->AdTag;
         $BannerPreview->DeliveryType = $AdCampaignBanner->DeliveryType;
         $BannerPreview->LandingPageTLD = $AdCampaignBanner->LandingPageTLD;
         $BannerPreview->ImpressionsCounter = $AdCampaignBanner->ImpressionsCounter;
         $BannerPreview->BidsCounter = $AdCampaignBanner->BidsCounter;
         $BannerPreview->CurrentSpend = $AdCampaignBanner->CurrentSpend;
         $BannerPreview->Active = $AdCampaignBanner->Active;
         $BannerPreview->DateCreated = date("Y-m-d H:i:s");
         $BannerPreview->DateUpdated = date("Y-m-d H:i:s");
         $BannerPreview->ChangeWentLive = 0;
         $AdCampaignBannerPreviewID = $AdCampaignBannerPreviewFactory->saveAdCampaignBannerPreview($BannerPreview);
         if ($update_data['type'] == 'AdCampaignBannerID' && $update_data['id'] == $banner_id) {
             $return_val = array('AdCampaignBannerPreviewID' => $AdCampaignBannerPreviewID, 'AdCampaignPreviewID' => $AdCampaignPreviewID);
         }
         /*
          * BANNER RESTRICTIONS
          */
         $params = array();
         $params["AdCampaignBannerID"] = $banner_id;
         $AdCampaignBannerRestrictions = $AdCampaignBannerRestrictionsFactory->get_row($params);
         // may not be present
         if ($AdCampaignBannerRestrictions != null) {
             $BannerRestrictionsPreview = new \model\AdCampaignBannerRestrictionsPreview();
             $BannerRestrictionsPreview->AdCampaignBannerPreviewID = $AdCampaignBannerPreviewID;
             $BannerRestrictionsPreview->GeoCountry = $AdCampaignBannerRestrictions->GeoCountry;
             $BannerRestrictionsPreview->GeoState = $AdCampaignBannerRestrictions->GeoState;
             $BannerRestrictionsPreview->GeoCity = $AdCampaignBannerRestrictions->GeoCity;
             $BannerRestrictionsPreview->AdTagType = $AdCampaignBannerRestrictions->AdTagType;
             $BannerRestrictionsPreview->AdPositionMinLeft = $AdCampaignBannerRestrictions->AdPositionMinLeft;
             $BannerRestrictionsPreview->AdPositionMaxLeft = $AdCampaignBannerRestrictions->AdPositionMaxLeft;
             $BannerRestrictionsPreview->AdPositionMinTop = $AdCampaignBannerRestrictions->AdPositionMinTop;
             $BannerRestrictionsPreview->AdPositionMaxTop = $AdCampaignBannerRestrictions->AdPositionMaxTop;
             $BannerRestrictionsPreview->FoldPos = $AdCampaignBannerRestrictions->FoldPos;
             $BannerRestrictionsPreview->Freq = $AdCampaignBannerRestrictions->Freq;
             $BannerRestrictionsPreview->Timezone = $AdCampaignBannerRestrictions->Timezone;
             $BannerRestrictionsPreview->InIframe = $AdCampaignBannerRestrictions->InIframe;
             $BannerRestrictionsPreview->InMultipleNestedIframes = $AdCampaignBannerRestrictions->InMultipleNestedIframes;
             $BannerRestrictionsPreview->MinScreenResolutionWidth = $AdCampaignBannerRestrictions->MinScreenResolutionWidth;
             $BannerRestrictionsPreview->MaxScreenResolutionWidth = $AdCampaignBannerRestrictions->MaxScreenResolutionWidth;
             $BannerRestrictionsPreview->MinScreenResolutionHeight = $AdCampaignBannerRestrictions->MinScreenResolutionHeight;
             $BannerRestrictionsPreview->MaxScreenResolutionHeight = $AdCampaignBannerRestrictions->MaxScreenResolutionHeight;
             $BannerRestrictionsPreview->HttpLanguage = $AdCampaignBannerRestrictions->HttpLanguage;
             $BannerRestrictionsPreview->BrowserUserAgentGrep = $AdCampaignBannerRestrictions->BrowserUserAgentGrep;
             $BannerRestrictionsPreview->CookieGrep = $AdCampaignBannerRestrictions->CookieGrep;
             $BannerRestrictionsPreview->PmpEnable = $AdCampaignBannerRestrictions->PmpEnable;
             $BannerRestrictionsPreview->Secure = $AdCampaignBannerRestrictions->Secure;
             $BannerRestrictionsPreview->Optout = $AdCampaignBannerRestrictions->Optout;
             $BannerRestrictionsPreview->Vertical = $AdCampaignBannerRestrictions->Vertical;
             $BannerRestrictionsPreview->DateCreated = date("Y-m-d H:i:s");
             $BannerRestrictionsPreview->DateUpdated = date("Y-m-d H:i:s");
             $AdCampaignBannerRestrictionsPreviewID = $AdCampaignBannerRestrictionsPreviewFactory->saveAdCampaignBannerRestrictionsPreview($BannerRestrictionsPreview);
             if ($update_data['type'] == 'AdCampaignBannerRestrictionsID' && $update_data['id'] == $AdCampaignBannerRestrictions->AdCampaignBannerRestrictionsID) {
                 $return_val = array('AdCampaignBannerRestrictionsPreviewID' => $AdCampaignBannerRestrictionsPreviewID, 'AdCampaignBannerPreviewID' => $AdCampaignBannerPreviewID, 'AdCampaignPreviewID' => $AdCampaignPreviewID);
             }
         }
         /*
          * LINKED BANNER TO AD ZONE
          */
         $params = array();
         $params["AdCampaignBannerID"] = $banner_id;
         $LinkedBannerToAdZoneList = $LinkedBannerToAdZoneFactory->get($params);
         foreach ($LinkedBannerToAdZoneList as $LinkedBannerToAdZone) {
             $LinkedBannerToAdZonePreview = new \model\LinkedBannerToAdZonePreview();
             $LinkedBannerToAdZonePreview->AdCampaignBannerPreviewID = $AdCampaignBannerPreviewID;
             $LinkedBannerToAdZonePreview->PublisherAdZoneID = $LinkedBannerToAdZone->PublisherAdZoneID;
             $LinkedBannerToAdZonePreview->Weight = $LinkedBannerToAdZone->Weight;
             $LinkedBannerToAdZonePreview->DateCreated = date("Y-m-d H:i:s");
             $LinkedBannerToAdZonePreview->DateUpdated = date("Y-m-d H:i:s");
             $LinkedBannerToAdZonePreviewFactory->saveLinkedBannerToAdZonePreview($LinkedBannerToAdZonePreview);
         }
         /*
          * DOMAIN EXCLUSIONS
          */
         $params = array();
         $params["AdCampaignBannerID"] = $banner_id;
         $AdCampaignBannerDomainExclusionList = $AdCampaignBannerDomainExclusionFactory->get($params);
         foreach ($AdCampaignBannerDomainExclusionList as $AdCampaignBannerDomainExclusion) {
             $BannerDomainExclusionPreview = new \model\AdCampaignBannerDomainExclusionPreview();
             $BannerDomainExclusionPreview->AdCampaignBannerPreviewID = $AdCampaignBannerPreviewID;
             $BannerDomainExclusionPreview->ExclusionType = $AdCampaignBannerDomainExclusion->ExclusionType;
             $BannerDomainExclusionPreview->DomainName = $AdCampaignBannerDomainExclusion->DomainName;
             $BannerDomainExclusionPreview->DateCreated = date("Y-m-d H:i:s");
             $BannerDomainExclusionPreview->DateUpdated = date("Y-m-d H:i:s");
             $AdCampaignBannerDomainExclusionPreviewID = $AdCampaignBannerDomainExclusionPreviewFactory->saveAdCampaignBannerDomainExclusionPreview($BannerDomainExclusionPreview);
             if ($update_data['type'] == 'AdCampaignBannerDomainExclusionID' && $update_data['id'] == $AdCampaignBannerDomainExclusion->AdCampaignBannerDomainExclusionID) {
                 $return_val = array('AdCampaignBannerDomainExclusionPreviewID' => $AdCampaignBannerDomainExclusionPreviewID, 'AdCampaignBannerPreviewID' => $AdCampaignBannerPreviewID, 'AdCampaignPreviewID' => $AdCampaignPreviewID);
             }
         }
         /*
          * DOMAIN EXCLUSIVE INCLUSIONS
          */
         $params = array();
         $params["AdCampaignBannerID"] = $banner_id;
         $AdCampaignBannerDomainExclusiveInclusionList = $AdCampaignBannerDomainExclusiveInclusionFactory->get($params);
         foreach ($AdCampaignBannerDomainExclusiveInclusionList as $AdCampaignBannerDomainExclusiveInclusion) {
             $BannerDomainExclusiveInclusionPreview = new \model\AdCampaignBannerDomainExclusiveInclusionPreview();
             $BannerDomainExclusiveInclusionPreview->AdCampaignBannerPreviewID = $AdCampaignBannerPreviewID;
             $BannerDomainExclusiveInclusionPreview->InclusionType = $AdCampaignBannerDomainExclusiveInclusion->InclusionType;
             $BannerDomainExclusiveInclusionPreview->DomainName = $AdCampaignBannerDomainExclusiveInclusion->DomainName;
             $BannerDomainExclusiveInclusionPreview->DateCreated = date("Y-m-d H:i:s");
             $BannerDomainExclusiveInclusionPreview->DateUpdated = date("Y-m-d H:i:s");
             $AdCampaignBannerDomainExclusiveInclusionPreviewID = $AdCampaignBannerDomainExclusiveInclusionPreviewFactory->saveAdCampaignBannerDomainExclusiveInclusionPreview($BannerDomainExclusiveInclusionPreview);
             if ($update_data['type'] == 'AdCampaignBannerDomainExclusiveInclusionID' && $update_data['id'] == $AdCampaignBannerDomainExclusiveInclusion->AdCampaignBannerDomainExclusiveInclusionID) {
                 $return_val = array('AdCampaignBannerDomainExclusiveInclusionPreviewID' => $AdCampaignBannerDomainExclusiveInclusionPreviewID, 'AdCampaignBannerPreviewID' => $AdCampaignBannerPreviewID, 'AdCampaignPreviewID' => $AdCampaignPreviewID);
             }
         }
     }
     return $return_val;
 }
 public function deleteLinkedBannerToAdZoneByPublisherAdZoneID($publisher_ad_zone_id)
 {
     /*
      * First go through each banner and make sure that 
      * each one no longer is selected for contract
      */
     $AdCampaignBannerFactory = \_factory\AdCampaignBanner::get_instance();
     $LinkedBannerToAdZoneFactory = \_factory\LinkedBannerToAdZone::get_instance();
     $params = array();
     $params["PublisherAdZoneID"] = $publisher_ad_zone_id;
     $LinkedBannerToAdZoneList = $LinkedBannerToAdZoneFactory->get($params);
     if ($LinkedBannerToAdZoneList != null) {
         foreach ($LinkedBannerToAdZoneList as $LinkedBannerToAdZone) {
             $params = array();
             $params["AdCampaignBannerID"] = $LinkedBannerToAdZone->AdCampaignBannerID;
             $LinkedBannerToAdZoneByAdCampaignBannerList = $LinkedBannerToAdZoneFactory->get($params);
             if (count($LinkedBannerToAdZoneByAdCampaignBannerList) <= 1) {
                 $AdCampaignBannerFactory->updateAdCampaignBannerAdCampaignType($LinkedBannerToAdZone->AdCampaignBannerID, AD_TYPE_ANY_REMNANT);
             }
         }
     }
     $this->delete(array('PublisherAdZoneID' => $publisher_ad_zone_id));
 }
 public static function cloneAdCampaignIntoAdCampaignPreview($ad_campaign_id, $auth, $config, $mail_transport, $update_data)
 {
     $return_val = array();
     if ($ad_campaign_id === null) {
         return null;
     }
     $AdCampaignFactory = \_factory\AdCampaign::get_instance();
     $params = array();
     $params["AdCampaignID"] = $ad_campaign_id;
     $params["UserID"] = $auth->getEffectiveUserID();
     $params["Active"] = 1;
     $AdCampaign = $AdCampaignFactory->get_row($params);
     if ($AdCampaign == null) {
         //die("Invalid AdCampaign ID");
         $params["error"] = "Invalid AdCampaign ID";
         return $params;
     }
     /*
      * Clone AdCampaign into AdCampaignPreview
      */
     $AdCampaignPreviewFactory = \_factory\AdCampaignPreview::get_instance();
     $AdCampaignPreview = new \model\AdCampaignPreview();
     $AdCampaignPreview->AdCampaignID = $AdCampaign->AdCampaignID;
     $AdCampaignPreview->UserID = $AdCampaign->UserID;
     $AdCampaignPreview->Name = $AdCampaign->Name;
     $AdCampaignPreview->StartDate = $AdCampaign->StartDate;
     $AdCampaignPreview->EndDate = $AdCampaign->EndDate;
     $AdCampaignPreview->Customer = $AdCampaign->Customer;
     $AdCampaignPreview->CustomerID = $AdCampaign->CustomerID;
     $AdCampaignPreview->ImpressionsCounter = 0;
     $AdCampaignPreview->MaxImpressions = $AdCampaign->MaxImpressions;
     $AdCampaignPreview->CurrentSpend = 0;
     $AdCampaignPreview->MaxSpend = $AdCampaign->MaxSpend;
     $AdCampaignPreview->Active = 1;
     $AdCampaignPreview->DateCreated = date("Y-m-d H:i:s");
     $AdCampaignPreview->DateUpdated = date("Y-m-d H:i:s");
     $AdCampaignPreview->ChangeWentLive = 0;
     $AdCampaignPreviewID = $AdCampaignPreviewFactory->saveAdCampaignPreview($AdCampaignPreview);
     if ($update_data['type'] == 'AdCampaignID') {
         $return_val = array('AdCampaignPreviewID' => $AdCampaignPreviewID);
     }
     $AdCampaignBannerFactory = \_factory\AdCampaignBanner::get_instance();
     $params = array();
     $params["AdCampaignID"] = $AdCampaign->AdCampaignID;
     $params["Active"] = 1;
     $AdCampaignBannerList = $AdCampaignBannerFactory->get($params);
     $AdCampaignBannerPreviewFactory = \_factory\AdCampaignBannerPreview::get_instance();
     $AdCampaignBannerRestrictionsFactory = \_factory\AdCampaignBannerRestrictions::get_instance();
     $AdCampaignBannerRestrictionsPreviewFactory = \_factory\AdCampaignBannerRestrictionsPreview::get_instance();
     $AdCampaignVideoRestrictionsFactory = \_factory\AdCampaignVideoRestrictions::get_instance();
     $AdCampaignVideoRestrictionsPreviewFactory = \_factory\AdCampaignVideoRestrictionsPreview::get_instance();
     $LinkedBannerToAdZoneFactory = \_factory\LinkedBannerToAdZone::get_instance();
     $LinkedBannerToAdZonePreviewFactory = \_factory\LinkedBannerToAdZonePreview::get_instance();
     $AdCampaignBannerDomainExclusionFactory = \_factory\AdCampaignBannerDomainExclusion::get_instance();
     $AdCampaignBannerDomainExclusionPreviewFactory = \_factory\AdCampaignBannerDomainExclusionPreview::get_instance();
     $AdCampaignBannerDomainExclusiveInclusionFactory = \_factory\AdCampaignBannerDomainExclusiveInclusion::get_instance();
     $AdCampaignBannerDomainExclusiveInclusionPreviewFactory = \_factory\AdCampaignBannerDomainExclusiveInclusionPreview::get_instance();
     foreach ($AdCampaignBannerList as $AdCampaignBanner) {
         $banner_id = $AdCampaignBanner->AdCampaignBannerID;
         $BannerPreview = new \model\AdCampaignBannerPreview();
         $BannerPreview->AdCampaignPreviewID = $AdCampaignPreviewID;
         $BannerPreview->AdCampaignBannerID = $AdCampaignBanner->AdCampaignBannerID;
         $BannerPreview->UserID = $AdCampaignBanner->UserID;
         $BannerPreview->Name = $AdCampaignBanner->Name;
         $BannerPreview->ImpressionType = $AdCampaignBanner->ImpressionType;
         $BannerPreview->StartDate = $AdCampaignBanner->StartDate;
         $BannerPreview->EndDate = $AdCampaignBanner->EndDate;
         $BannerPreview->AdCampaignTypeID = $AdCampaignBanner->AdCampaignTypeID;
         $BannerPreview->IsMobile = $AdCampaignBanner->IsMobile;
         $BannerPreview->IABSize = $AdCampaignBanner->IABSize;
         $BannerPreview->Height = $AdCampaignBanner->Height;
         $BannerPreview->Width = $AdCampaignBanner->Width;
         $BannerPreview->Weight = $AdCampaignBanner->Weight;
         $BannerPreview->BidAmount = $AdCampaignBanner->BidAmount;
         $BannerPreview->AdTag = $AdCampaignBanner->AdTag;
         $BannerPreview->DeliveryType = $AdCampaignBanner->DeliveryType;
         $BannerPreview->LandingPageTLD = $AdCampaignBanner->LandingPageTLD;
         $BannerPreview->ImpressionsCounter = $AdCampaignBanner->ImpressionsCounter;
         $BannerPreview->BidsCounter = $AdCampaignBanner->BidsCounter;
         $BannerPreview->CurrentSpend = $AdCampaignBanner->CurrentSpend;
         $BannerPreview->Active = $AdCampaignBanner->Active;
         $BannerPreview->DateCreated = date("Y-m-d H:i:s");
         $BannerPreview->DateUpdated = date("Y-m-d H:i:s");
         $BannerPreview->ChangeWentLive = 0;
         $AdCampaignBannerPreviewID = $AdCampaignBannerPreviewFactory->saveAdCampaignBannerPreview($BannerPreview);
         if ($update_data['type'] == 'AdCampaignBannerID' && $update_data['id'] == $banner_id) {
             $return_val = array('AdCampaignBannerPreviewID' => $AdCampaignBannerPreviewID, 'AdCampaignPreviewID' => $AdCampaignPreviewID);
         }
         if ($BannerPreview->ImpressionType == 'video') {
             /*
              * VIDEO RESTRICTIONS
              */
             $params = array();
             $params["AdCampaignBannerID"] = $banner_id;
             $AdCampaignVideoRestrictions = $AdCampaignVideoRestrictionsFactory->get_row($params);
             if ($AdCampaignVideoRestrictions != null) {
                 $VideoRestrictionsPreview = new \model\AdCampaignVideoRestrictionsPreview();
                 $VideoRestrictionsPreview->AdCampaignBannerPreviewID = $AdCampaignBannerPreviewID;
                 $VideoRestrictionsPreview->GeoCountry = $AdCampaignVideoRestrictions->GeoCountry;
                 $VideoRestrictionsPreview->GeoState = $AdCampaignVideoRestrictions->GeoState;
                 $VideoRestrictionsPreview->GeoCity = $AdCampaignVideoRestrictions->GeoCity;
                 $VideoRestrictionsPreview->MimesCommaSeparated = $AdCampaignVideoRestrictions->MimesCommaSeparated;
                 $VideoRestrictionsPreview->MinDuration = $AdCampaignVideoRestrictions->MinDuration;
                 $VideoRestrictionsPreview->MaxDuration = $AdCampaignVideoRestrictions->MaxDuration;
                 $VideoRestrictionsPreview->ApisSupportedCommaSeparated = $AdCampaignVideoRestrictions->ApisSupportedCommaSeparated;
                 $VideoRestrictionsPreview->ProtocolsCommaSeparated = $AdCampaignVideoRestrictions->ProtocolsCommaSeparated;
                 $VideoRestrictionsPreview->DeliveryCommaSeparated = $AdCampaignVideoRestrictions->DeliveryCommaSeparated;
                 $VideoRestrictionsPreview->PlaybackCommaSeparated = $AdCampaignVideoRestrictions->PlaybackCommaSeparated;
                 $VideoRestrictionsPreview->StartDelay = $AdCampaignVideoRestrictions->StartDelay;
                 $VideoRestrictionsPreview->Linearity = $AdCampaignVideoRestrictions->Linearity;
                 $VideoRestrictionsPreview->FoldPos = $AdCampaignVideoRestrictions->FoldPos;
                 $VideoRestrictionsPreview->MinHeight = $AdCampaignVideoRestrictions->MinHeight;
                 $VideoRestrictionsPreview->MinWidth = $AdCampaignVideoRestrictions->MinWidth;
                 $VideoRestrictionsPreview->PmpEnable = $AdCampaignVideoRestrictions->PmpEnable;
                 $VideoRestrictionsPreview->Secure = $AdCampaignVideoRestrictions->Secure;
                 $VideoRestrictionsPreview->Optout = $AdCampaignVideoRestrictions->Optout;
                 $VideoRestrictionsPreview->Vertical = $AdCampaignVideoRestrictions->Vertical;
                 $VideoRestrictionsPreview->DateCreated = date("Y-m-d H:i:s");
                 $VideoRestrictionsPreview->DateUpdated = date("Y-m-d H:i:s");
                 $AdCampaignVideoRestrictionsPreviewID = $AdCampaignVideoRestrictionsPreviewFactory->saveAdCampaignVideoRestrictionsPreview($VideoRestrictionsPreview);
                 if ($update_data['type'] == 'AdCampaignVideoRestrictionsID' && $update_data['id'] == $AdCampaignVideoRestrictions->AdCampaignVideoRestrictionsID) {
                     $return_val = array('AdCampaignVideoRestrictionsPreviewID' => $AdCampaignVideoRestrictionsPreviewID, 'AdCampaignBannerPreviewID' => $AdCampaignBannerPreviewID, 'AdCampaignPreviewID' => $AdCampaignPreviewID);
                 }
             }
         } else {
             /*
              * BANNER RESTRICTIONS
              */
             $params = array();
             $params["AdCampaignBannerID"] = $banner_id;
             $AdCampaignBannerRestrictions = $AdCampaignBannerRestrictionsFactory->get_row($params);
             // may not be present
             if ($AdCampaignBannerRestrictions != null) {
                 $BannerRestrictionsPreview = new \model\AdCampaignBannerRestrictionsPreview();
                 $BannerRestrictionsPreview->AdCampaignBannerPreviewID = $AdCampaignBannerPreviewID;
                 $BannerRestrictionsPreview->GeoCountry = $AdCampaignBannerRestrictions->GeoCountry;
                 $BannerRestrictionsPreview->GeoState = $AdCampaignBannerRestrictions->GeoState;
                 $BannerRestrictionsPreview->GeoCity = $AdCampaignBannerRestrictions->GeoCity;
                 $BannerRestrictionsPreview->AdTagType = $AdCampaignBannerRestrictions->AdTagType;
                 $BannerRestrictionsPreview->AdPositionMinLeft = $AdCampaignBannerRestrictions->AdPositionMinLeft;
                 $BannerRestrictionsPreview->AdPositionMaxLeft = $AdCampaignBannerRestrictions->AdPositionMaxLeft;
                 $BannerRestrictionsPreview->AdPositionMinTop = $AdCampaignBannerRestrictions->AdPositionMinTop;
                 $BannerRestrictionsPreview->AdPositionMaxTop = $AdCampaignBannerRestrictions->AdPositionMaxTop;
                 $BannerRestrictionsPreview->FoldPos = $AdCampaignBannerRestrictions->FoldPos;
                 $BannerRestrictionsPreview->Freq = $AdCampaignBannerRestrictions->Freq;
                 $BannerRestrictionsPreview->Timezone = $AdCampaignBannerRestrictions->Timezone;
                 $BannerRestrictionsPreview->InIframe = $AdCampaignBannerRestrictions->InIframe;
                 $BannerRestrictionsPreview->InMultipleNestedIframes = $AdCampaignBannerRestrictions->InMultipleNestedIframes;
                 $BannerRestrictionsPreview->MinScreenResolutionWidth = $AdCampaignBannerRestrictions->MinScreenResolutionWidth;
                 $BannerRestrictionsPreview->MaxScreenResolutionWidth = $AdCampaignBannerRestrictions->MaxScreenResolutionWidth;
                 $BannerRestrictionsPreview->MinScreenResolutionHeight = $AdCampaignBannerRestrictions->MinScreenResolutionHeight;
                 $BannerRestrictionsPreview->MaxScreenResolutionHeight = $AdCampaignBannerRestrictions->MaxScreenResolutionHeight;
                 $BannerRestrictionsPreview->HttpLanguage = $AdCampaignBannerRestrictions->HttpLanguage;
                 $BannerRestrictionsPreview->BrowserUserAgentGrep = $AdCampaignBannerRestrictions->BrowserUserAgentGrep;
                 $BannerRestrictionsPreview->CookieGrep = $AdCampaignBannerRestrictions->CookieGrep;
                 $BannerRestrictionsPreview->PmpEnable = $AdCampaignBannerRestrictions->PmpEnable;
                 $BannerRestrictionsPreview->Secure = $AdCampaignBannerRestrictions->Secure;
                 $BannerRestrictionsPreview->Optout = $AdCampaignBannerRestrictions->Optout;
                 $BannerRestrictionsPreview->Vertical = $AdCampaignBannerRestrictions->Vertical;
                 $BannerRestrictionsPreview->DateCreated = date("Y-m-d H:i:s");
                 $BannerRestrictionsPreview->DateUpdated = date("Y-m-d H:i:s");
                 $AdCampaignBannerRestrictionsPreviewID = $AdCampaignBannerRestrictionsPreviewFactory->saveAdCampaignBannerRestrictionsPreview($BannerRestrictionsPreview);
                 if ($update_data['type'] == 'AdCampaignBannerRestrictionsID' && $update_data['id'] == $AdCampaignBannerRestrictions->AdCampaignBannerRestrictionsID) {
                     $return_val = array('AdCampaignBannerRestrictionsPreviewID' => $AdCampaignBannerRestrictionsPreviewID, 'AdCampaignBannerPreviewID' => $AdCampaignBannerPreviewID, 'AdCampaignPreviewID' => $AdCampaignPreviewID);
                 }
             }
         }
         /*
          * LINKED BANNER TO AD ZONE
          */
         $params = array();
         $params["AdCampaignBannerID"] = $banner_id;
         $LinkedBannerToAdZoneList = $LinkedBannerToAdZoneFactory->get($params);
         foreach ($LinkedBannerToAdZoneList as $LinkedBannerToAdZone) {
             $LinkedBannerToAdZonePreview = new \model\LinkedBannerToAdZonePreview();
             $LinkedBannerToAdZonePreview->AdCampaignBannerPreviewID = $AdCampaignBannerPreviewID;
             $LinkedBannerToAdZonePreview->PublisherAdZoneID = $LinkedBannerToAdZone->PublisherAdZoneID;
             $LinkedBannerToAdZonePreview->Weight = $LinkedBannerToAdZone->Weight;
             $LinkedBannerToAdZonePreview->DateCreated = date("Y-m-d H:i:s");
             $LinkedBannerToAdZonePreview->DateUpdated = date("Y-m-d H:i:s");
             $LinkedBannerToAdZonePreviewFactory->saveLinkedBannerToAdZonePreview($LinkedBannerToAdZonePreview);
         }
         /*
          * DOMAIN EXCLUSIONS
          */
         $params = array();
         $params["AdCampaignBannerID"] = $banner_id;
         $AdCampaignBannerDomainExclusionList = $AdCampaignBannerDomainExclusionFactory->get($params);
         foreach ($AdCampaignBannerDomainExclusionList as $AdCampaignBannerDomainExclusion) {
             $BannerDomainExclusionPreview = new \model\AdCampaignBannerDomainExclusionPreview();
             $BannerDomainExclusionPreview->AdCampaignBannerPreviewID = $AdCampaignBannerPreviewID;
             $BannerDomainExclusionPreview->ExclusionType = $AdCampaignBannerDomainExclusion->ExclusionType;
             $BannerDomainExclusionPreview->DomainName = $AdCampaignBannerDomainExclusion->DomainName;
             $BannerDomainExclusionPreview->DateCreated = date("Y-m-d H:i:s");
             $BannerDomainExclusionPreview->DateUpdated = date("Y-m-d H:i:s");
             $AdCampaignBannerDomainExclusionPreviewID = $AdCampaignBannerDomainExclusionPreviewFactory->saveAdCampaignBannerDomainExclusionPreview($BannerDomainExclusionPreview);
             if ($update_data['type'] == 'AdCampaignBannerDomainExclusionID' && $update_data['id'] == $AdCampaignBannerDomainExclusion->AdCampaignBannerDomainExclusionID) {
                 $return_val = array('AdCampaignBannerDomainExclusionPreviewID' => $AdCampaignBannerDomainExclusionPreviewID, 'AdCampaignBannerPreviewID' => $AdCampaignBannerPreviewID, 'AdCampaignPreviewID' => $AdCampaignPreviewID);
             }
         }
         /*
          * DOMAIN EXCLUSIVE INCLUSIONS
          */
         $params = array();
         $params["AdCampaignBannerID"] = $banner_id;
         $AdCampaignBannerDomainExclusiveInclusionList = $AdCampaignBannerDomainExclusiveInclusionFactory->get($params);
         foreach ($AdCampaignBannerDomainExclusiveInclusionList as $AdCampaignBannerDomainExclusiveInclusion) {
             $BannerDomainExclusiveInclusionPreview = new \model\AdCampaignBannerDomainExclusiveInclusionPreview();
             $BannerDomainExclusiveInclusionPreview->AdCampaignBannerPreviewID = $AdCampaignBannerPreviewID;
             $BannerDomainExclusiveInclusionPreview->InclusionType = $AdCampaignBannerDomainExclusiveInclusion->InclusionType;
             $BannerDomainExclusiveInclusionPreview->DomainName = $AdCampaignBannerDomainExclusiveInclusion->DomainName;
             $BannerDomainExclusiveInclusionPreview->DateCreated = date("Y-m-d H:i:s");
             $BannerDomainExclusiveInclusionPreview->DateUpdated = date("Y-m-d H:i:s");
             $AdCampaignBannerDomainExclusiveInclusionPreviewID = $AdCampaignBannerDomainExclusiveInclusionPreviewFactory->saveAdCampaignBannerDomainExclusiveInclusionPreview($BannerDomainExclusiveInclusionPreview);
             if ($update_data['type'] == 'AdCampaignBannerDomainExclusiveInclusionID' && $update_data['id'] == $AdCampaignBannerDomainExclusiveInclusion->AdCampaignBannerDomainExclusiveInclusionID) {
                 $return_val = array('AdCampaignBannerDomainExclusiveInclusionPreviewID' => $AdCampaignBannerDomainExclusiveInclusionPreviewID, 'AdCampaignBannerPreviewID' => $AdCampaignBannerPreviewID, 'AdCampaignPreviewID' => $AdCampaignPreviewID);
             }
         }
     }
     if (!$auth->getIsAdmin() && $config['mail']['subscribe']['campaigns'] === true) {
         // if this ad campaign was not created/edited by the admin, then send out a notification email
         $message = '<b>NginAd Demand Customer Campaign Edited by ' . $auth->getUserName() . '.</b><br /><br />';
         $message = $message . '<table border="0" width="10%">';
         $message = $message . '<tr><td><b>AdCampaignID: </b></td><td>' . $AdCampaign->AdCampaignID . '</td></tr>';
         $message = $message . '<tr><td><b>UserID: </b></td><td>' . $AdCampaign->UserID . '</td></tr>';
         $message = $message . '<tr><td><b>Name: </b></td><td>' . $AdCampaign->Name . '</td></tr>';
         $message = $message . '<tr><td><b>StartDate: </b></td><td>' . $AdCampaign->StartDate . '</td></tr>';
         $message = $message . '<tr><td><b>EndDate: </b></td><td>' . $AdCampaign->EndDate . '</td></tr>';
         $message = $message . '<tr><td><b>Customer: </b></td><td>' . $AdCampaign->Customer . '</td></tr>';
         $message = $message . '<tr><td><b>CustomerID: </b></td><td>' . $AdCampaign->CustomerID . '</td></tr>';
         $message = $message . '<tr><td><b>MaxImpressions: </b></td><td>' . $AdCampaign->MaxImpressions . '</td></tr>';
         $message = $message . '<tr><td><b>MaxSpend: </b></td><td>' . $AdCampaign->MaxSpend . '</td></tr>';
         $message = $message . '</table>';
         $subject = "NginAd Demand Customer Campaign Edited by " . $auth->getUserName();
         $text = new Mime\Part($message);
         $text->type = Mime\Mime::TYPE_HTML;
         $text->charset = 'utf-8';
         $mimeMessage = new Mime\Message();
         $mimeMessage->setParts(array($text));
         $zf_message = new Message();
         $zf_message->addTo($config['mail']['admin-email']['email'], $config['mail']['admin-email']['name'])->addFrom($config['mail']['reply-to']['email'], $config['mail']['reply-to']['name'])->setSubject($subject)->setBody($mimeMessage);
         $mail_transport->send($zf_message);
     }
     return $return_val;
 }
 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;
 }