Ejemplo n.º 1
0
 public function set_up_local_demand_ping_clients()
 {
     $request_id = "Not Given";
     try {
         /*
          * First treat this bid request JSON as if it came in 
          * from a regular remote buy side partner (SSP)
          */
         \buyloopbackpartner\LoopbackPartnerInit::init();
         $LoopbackPartnerBid = new \buyloopbackpartner\LoopbackPartnerBid($this->config, $this->config['buyside_rtb']['supply_partners']['BuyLoopbackPartner']['buyer_id']);
         $LoopbackPartnerBid->is_local_request = true;
         $validated = $LoopbackPartnerBid->parse_incoming_request($this->ping_request_list[self::LOOPBACK_PARTNER]);
         if ($validated === true) {
             $request_id = $LoopbackPartnerBid->RtbBidRequest->id;
             $LoopbackPartnerBid->process_business_logic();
             $LoopbackPartnerBid->convert_ads_to_bid_response();
             $LoopbackPartnerBid->build_outgoing_bid_response();
         }
         if ($LoopbackPartnerBid->had_bid_response == true) {
             if (\buyloopbackpartner\LoopbackPartnerLogger::get_instance()->setting_only_log_bids == true) {
                 \buyloopbackpartner\LoopbackPartnerLogger::get_instance()->output_log($this->config);
             }
             /*
              * Next hook up the bid responses from our local demand dashboard customers
              * to the publishers' RTB bid request manager
              */
             $sell_side_partners_dir = __DIR__ . '/../../../../SellSidePartners';
             require_once $sell_side_partners_dir . '/LoopbackPartner.php';
             $partner_class = new \LoopbackPartner();
             $RTBPinger = new RTBPinger($partner_class->partner_name, $partner_class->partner_id, $partner_class->partner_rtb_url, $LoopbackPartnerBid->bid_responses, $partner_class->rtb_connection_timeout_ms, $partner_class->rtb_timeout_ms, $partner_class->partner_quality_score, $partner_class->verify_ssl, false);
             $RTBPinger->is_loopback_pinger = true;
             $this->RTBLoopbackPing = $RTBPinger;
         }
     } catch (Exception $e) {
         \buyloopbackpartner\LoopbackPartnerLogger::get_instance()->log[] = "BID EXCEPTION: ID: " . $request_id . " MESSAGE: " . $e->getMessage();
     }
     if (\buyloopbackpartner\LoopbackPartnerLogger::get_instance()->setting_only_log_bids == false) {
         \buyloopbackpartner\LoopbackPartnerLogger::get_instance()->output_log($this->config);
     }
 }
 public function bidAction()
 {
     \buyloopbackpartner\LoopbackPartnerInit::init();
     $real_ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : "";
     foreach ($this->ban_ips as $ban_ip) {
         if (strpos($real_ip, $ban_ip) !== false) {
             $this->indexAction();
         }
     }
     $config = $this->getServiceLocator()->get('Config');
     $application_config = $this->getServiceLocator()->get('ApplicationConfig');
     $rtb_seat_id = isset($application_config['rtb_seat_id']) ? $application_config['rtb_seat_id'] : null;
     $response_seat_id = isset($application_config['response_seat_id']) ? $application_config['response_seat_id'] : null;
     $request_id = "Not Given";
     try {
         $LoopbackPartnerBid = new \buyloopbackpartner\LoopbackPartnerBid($config, $rtb_seat_id, $response_seat_id);
         $LoopbackPartnerBid->is_local_request = false;
         $validated = $LoopbackPartnerBid->parse_incoming_request();
         if ($validated === true) {
             $request_id = $LoopbackPartnerBid->RtbBidRequest->id;
             $LoopbackPartnerBid->process_business_logic();
         }
         $LoopbackPartnerBid->convert_ads_to_bid_response();
         $LoopbackPartnerBid->build_outgoing_bid_response();
         $LoopbackPartnerBid->send_bid_response();
         if ($LoopbackPartnerBid->had_bid_response == true || \buyloopbackpartner\LoopbackPartnerLogger::get_instance()->setting_only_log_bids == false) {
             \buyloopbackpartner\LoopbackPartnerLogger::get_instance()->output_log();
         }
     } catch (Exception $e) {
         \buyloopbackpartner\LoopbackPartnerLogger::get_instance()->log[] = "BID EXCEPTION: ID: " . $request_id . " MESSAGE: " . $e->getMessage();
         header("Content-type: application/json");
         echo '{"seatbid":[{"bid":[{"price":0}]}],"nbr":2}';
     }
     if (\buyloopbackpartner\LoopbackPartnerLogger::get_instance()->setting_only_log_bids == false) {
         \buyloopbackpartner\LoopbackPartnerLogger::get_instance()->output_log();
     }
     exit;
 }