SHARE
TWEET

Untitled

a guest Nov 11th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP5 Decoder for ionCube Encoder)
  6. *
  7. * @ Version         :   3.0.8.0
  8. * @ Author          :   DeZender
  9. * @ Release on      :   25.09.2017
  10. * @ Official site   :   http://DeZender.Net
  11. *
  12. */
  13.  
  14. namespace Stalker\Lib\Core;
  15.  
  16. class Advertising
  17. {
  18.     const PLATFORM_STB = 1;
  19.     const PLATFORM_LAUNCHER = 2;
  20.     const PLATFORM_ANDROID = 3;
  21.     const PLATFORM_IOS = 4;
  22.     const PLATFORM_SMARTTV = 5;
  23.  
  24.     private $tracking_id = '';
  25.  
  26.     public static function registration($full_name, $email, $phone, $region, $num_users, $website, $additional_request = false)
  27.     {
  28.         $msg = (($additional_request ? 'Additional ' : 'New')) . ' request<br>' . "\n" . 'Full Name: ' . $full_name . '<br>' . "\n" . 'Email: ' . $email . '<br>' . "\n" . 'Phone: ' . $phone . '<br>' . "\n" . 'Region: ' . $region . '<br>' . "\n" . 'Number of users: ' . $num_users . '<br>' . "\n" . 'Website: ' . $website . '<br>' . "\n" . 'IP: ' . ((!(empty( $_SERVER['HTTP_X_REAL_IP'] )) ? $_SERVER['HTTP_X_REAL_IP'] : $_SERVER['REMOTE_ADDR']));
  29.         $token = '2678e15e93679addf985e07a9a52b4';
  30.         $hc = new HipChat( $token );
  31.         return $hc->message_room( 3180997, 'Stalker', $msg );
  32.     }
  33.  
  34.     public static function getSupportedCountries()
  35.     {
  36.         $content = file_get_contents( 'http://download.middleware-stalker.com/verta.json' );
  37.  
  38.         if (!($content)) {
  39.             return null;
  40.         }
  41.  
  42.         $content = json_decode( $content, true );
  43.  
  44.         if (!($content)) {
  45.             return null;
  46.         }
  47.  
  48.         return (isset( $content['countries'] ) && is_array( $content['countries'] ) ? $content['countries'] : array(  ));
  49.     }
  50.  
  51.     public static function getUserPlatformCode(User $user)
  52.     {
  53.         $client_type = strtolower( $user->getProfileParam( 'client_type' ) );
  54.  
  55.         if ($client_type == 'stb') {
  56.             return self::PLATFORM_LAUNCHER;
  57.         }
  58.  
  59.         if (strpos( $client_type, 'android' ) !== false) {
  60.             return self::PLATFORM_ANDROID;
  61.         }
  62.  
  63.         if ($client_type == 'ios') {
  64.             return self::PLATFORM_IOS;
  65.         }
  66.  
  67.         if ($client_type == 'smarttv') {
  68.             return self::PLATFORM_SMARTTV;
  69.         }
  70.  
  71.         return self::PLATFORM_STB;
  72.     }
  73.  
  74.     public static function getUserPlatformByPlaceCode($place_code)
  75.     {
  76.         if ((200 < $place_code) && ($place_code < 300)) {
  77.             return self::PLATFORM_LAUNCHER;
  78.         }
  79.  
  80.         if ((300 < $place_code) && ($place_code < 400)) {
  81.             return self::PLATFORM_ANDROID;
  82.         }
  83.  
  84.         if ((400 < $place_code) && ($place_code < 500)) {
  85.             return self::PLATFORM_IOS;
  86.         }
  87.  
  88.         if ((500 < $place_code) && ($place_code < 600)) {
  89.             return self::PLATFORM_SMARTTV;
  90.         }
  91.  
  92.         return self::PLATFORM_STB;
  93.     }
  94.  
  95.     /**
  96.      * @param $user_id
  97.      * @param $platform integer see this class PLATFORM_* constants
  98.      * @return array|null
  99.      */
  100.     public static function getConfig($user_id, $platform = 1)
  101.     {
  102.         $campaigns = Mysql::getInstance(  )->from( 'ext_adv_campaigns_position' )->select( 'ext_adv_campaigns.id, ext_adv_sources.source as source' )->join( 'ext_adv_campaigns', 'ext_adv_campaigns_position.campaigns_id', 'ext_adv_campaigns.id', 'INNER' )->join( 'ext_adv_sources', 'ext_adv_campaigns.source', 'ext_adv_sources.id', 'INNER' )->where( array(
  103.             'ext_adv_campaigns.status'                   => 1,
  104.             'ext_adv_campaigns_position.position_code>'  => $platform * 100,
  105.             'ext_adv_campaigns_position.position_code<=' => ($platform * 100) + 99
  106.         ) )->groupby( 'ext_adv_campaigns.id' )->get(  )->all(  );
  107.  
  108.         if (empty( $campaigns )) {
  109.             return null;
  110.         }
  111.  
  112.         $config = array(  );
  113.  
  114.         foreach ($campaigns as $campaign) {
  115.             $places = Mysql::getInstance(  )->from( 'ext_adv_campaigns_position' )->where( array(
  116.                 'campaigns_id'                               => $campaign['id'],
  117.                 'ext_adv_campaigns_position.position_code>'  => $platform * 100,
  118.                 'ext_adv_campaigns_position.position_code<=' => ($platform * 100) + 99
  119.             ) )->orderby( 'position_code' )->get(  )->all(  );
  120.             $place_to_blocks_map = array(  );
  121.  
  122.             foreach ($places as $place) {
  123.                 $place_to_blocks_map[(int) $place['position_code']] = (int) $place['blocks'];
  124.             }
  125.  
  126.             $config[] = array(
  127.                 'id'     => (int) $campaign['id'],
  128.                 'places' => $place_to_blocks_map,
  129.                 'source' => $campaign['source']
  130.             );
  131.         }
  132.  
  133.         return $config;
  134.     }
  135.  
  136.     public function setTrackingId($tracking_id)
  137.     {
  138.         $this->tracking_id = $tracking_id;
  139.     }
  140.  
  141.     /**
  142.      * @param $user_id
  143.      * @param $place
  144.      * @return array|bool
  145.      */
  146.     public function getAds($user_id, $place)
  147.     {
  148.         $user = User::getInstance( $user_id );
  149.         $options = $user->getServicesByType( 'option' );
  150.         if ($options && (array_search( 'disable_ad', $options ) !== false)) {
  151.             return false;
  152.         }
  153.  
  154.         $platform = self::getUserPlatformByPlaceCode( $place );
  155.         $campaigns = $this->getConfig( $user_id, $platform );
  156.  
  157.         if (empty( $campaigns )) {
  158.             return false;
  159.         }
  160.  
  161.         $ads = array(  );
  162.  
  163.         $times = 0;
  164.  
  165.         $ad = $this->getAd( $user_id, $campaign, $place );
  166. ...........................................................................................
  167. .......................................................
  168. ..........................
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top