Exemple #1
0
 /**
  * 
  * @return Ambigous <\Zend\View\Model\ViewModel, \Zend\View\Model\ViewModel>
  */
 public function deleteexclusiveinclusionAction()
 {
     $error_msg = null;
     $success = true;
     $id = $this->getEvent()->getRouteMatch()->getParam('param1');
     if ($id == null) {
         //die("Invalid DomainExclusiveInclusion ID");
         $error_msg = "Invalid DomainExclusiveInclusion ID";
         $success = false;
         $data = array('success' => $success, 'data' => array('error_msg' => $error_msg));
         return $this->getResponse()->setContent(json_encode($data));
     }
     $initialized = $this->initialize();
     if ($initialized !== true) {
         return $initialized;
     }
     $is_preview = $this->getRequest()->getQuery('ispreview');
     $exclusiveinclusion_preview_id = null;
     $AdCampaignBannerDomainExclusiveInclusionPreviewFactory = \_factory\AdCampaignBannerDomainExclusiveInclusionPreview::get_instance();
     // verify
     if ($is_preview != "true") {
         $AdCampaignBannerDomainExclusiveInclusionFactory = \_factory\AdCampaignBannerDomainExclusiveInclusion::get_instance();
         $params = array();
         $params["AdCampaignBannerDomainExclusiveInclusionID"] = $id;
         $rtb_domain_exclusive_inclusion = $AdCampaignBannerDomainExclusiveInclusionFactory->get_row($params);
         if ($rtb_domain_exclusive_inclusion == null) {
             //die("Invalid AdCampaignBannerDomainExclusiveInclusion ID");
             $error_msg = "Invalid AdCampaignBannerDomainExclusiveInclusion ID";
             $success = false;
             $data = array('success' => $success, 'data' => array('error_msg' => $error_msg));
             return $this->getResponse()->setContent(json_encode($data));
         }
         $banner_id = $rtb_domain_exclusive_inclusion->AdCampaignBannerID;
         // ACL PERMISSIONS CHECK
         $response = transformation\CheckPermissions::checkEditPermissionAdCampaignBanner($banner_id, $this->auth, $this->config_handle);
         if (array_key_exists("error", $response) > 0) {
             $success = false;
             $data = array('success' => $success, 'data' => array('error_msg' => $response['error']));
             return $this->getResponse()->setContent(json_encode($data));
         }
         /*
          * THIS METHOD CHECKS IF THERE IS AN EXISTING PREVIEW MODE CAMPAIGN
          * IF NOT, IT CHECKS THE ACL PERMISSIONS ON THE PRODUCTION BANNER/CAMPAIGN REFERENCED
          * THEN IT CREATES A PREVIEW VERSION OF THE AD CAMPAIGN
          */
         $update_data = array('type' => 'AdCampaignBannerDomainExclusiveInclusionID', 'id' => $id);
         $return_val = \transformation\TransformPreview::previewCheckBannerID($banner_id, $this->auth, $update_data);
         if ($return_val !== null && array_key_exists("error", $return_val)) {
             $success = false;
             $data = array('success' => $success, 'data' => array('error_msg' => $return_val['error']));
             return $this->getResponse()->setContent(json_encode($data));
         }
         if ($return_val !== null) {
             $banner_preview_id = $return_val["AdCampaignBannerPreviewID"];
             $exclusiveinclusion_preview_id = $return_val["AdCampaignBannerDomainExclusiveInclusionPreviewID"];
         }
     } else {
         $params = array();
         $params["AdCampaignBannerDomainExclusiveInclusionPreviewID"] = $id;
         $rtb_domain_exclusive_inclusion_preview = $AdCampaignBannerDomainExclusiveInclusionPreviewFactory->get_row($params);
         if ($rtb_domain_exclusive_inclusion_preview == null) {
             //die("Invalid AdCampaignBannerDomainExclusiveInclusionPreview ID");
             $error_msg = "Invalid AdCampaignBannerDomainExclusiveInclusionPreview ID";
             $success = false;
             $data = array('success' => $success, 'data' => array('error_msg' => $error_msg));
             return $this->getResponse()->setContent(json_encode($data));
         }
         $banner_preview_id = $rtb_domain_exclusive_inclusion_preview->AdCampaignBannerPreviewID;
         $exclusiveinclusion_preview_id = $rtb_domain_exclusive_inclusion_preview->AdCampaignBannerDomainExclusiveInclusionPreviewID;
         // ACL PREVIEW PERMISSIONS CHECK
         $response = transformation\CheckPermissions::checkEditPermissionAdCampaignBannerPreview($banner_preview_id, $this->auth, $this->config_handle);
         if (array_key_exists("error", $response) > 0) {
             $success = false;
             $data = array('success' => $success, 'data' => array('error_msg' => $response['error']));
             return $this->getResponse()->setContent(json_encode($data));
         }
     }
     $AdCampaignBannerDomainExclusiveInclusionPreviewFactory->deleteAdCampaignBannerDomainExclusiveInclusionPreview($exclusiveinclusion_preview_id);
     $data = array('success' => $success, 'data' => array('error_msg' => $error_msg));
     return $this->getResponse()->setContent(json_encode($data));
 }
Exemple #2
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 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;
 }
 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;
 }
Exemple #5
0
 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;
 }