Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP5 Decoder for ionCube Encoder)
- *
- * @ Version : 3.0.8.0
- * @ Author : DeZender
- * @ Release on : 25.09.2017
- * @ Official site : http://DeZender.Net
- *
- */
- namespace Stalker\Lib\Core;
- class Advertising
- {
- const PLATFORM_STB = 1;
- const PLATFORM_LAUNCHER = 2;
- const PLATFORM_ANDROID = 3;
- const PLATFORM_IOS = 4;
- const PLATFORM_SMARTTV = 5;
- private $tracking_id = '';
- public static function registration($full_name, $email, $phone, $region, $num_users, $website, $additional_request = false)
- {
- $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']));
- $token = '2678e15e93679addf985e07a9a52b4';
- $hc = new HipChat( $token );
- return $hc->message_room( 3180997, 'Stalker', $msg );
- }
- public static function getSupportedCountries()
- {
- $content = file_get_contents( 'http://download.middleware-stalker.com/verta.json' );
- if (!($content)) {
- return null;
- }
- $content = json_decode( $content, true );
- if (!($content)) {
- return null;
- }
- return (isset( $content['countries'] ) && is_array( $content['countries'] ) ? $content['countries'] : array( ));
- }
- public static function getUserPlatformCode(User $user)
- {
- $client_type = strtolower( $user->getProfileParam( 'client_type' ) );
- if ($client_type == 'stb') {
- return self::PLATFORM_LAUNCHER;
- }
- if (strpos( $client_type, 'android' ) !== false) {
- return self::PLATFORM_ANDROID;
- }
- if ($client_type == 'ios') {
- return self::PLATFORM_IOS;
- }
- if ($client_type == 'smarttv') {
- return self::PLATFORM_SMARTTV;
- }
- return self::PLATFORM_STB;
- }
- public static function getUserPlatformByPlaceCode($place_code)
- {
- if ((200 < $place_code) && ($place_code < 300)) {
- return self::PLATFORM_LAUNCHER;
- }
- if ((300 < $place_code) && ($place_code < 400)) {
- return self::PLATFORM_ANDROID;
- }
- if ((400 < $place_code) && ($place_code < 500)) {
- return self::PLATFORM_IOS;
- }
- if ((500 < $place_code) && ($place_code < 600)) {
- return self::PLATFORM_SMARTTV;
- }
- return self::PLATFORM_STB;
- }
- /**
- * @param $user_id
- * @param $platform integer see this class PLATFORM_* constants
- * @return array|null
- */
- public static function getConfig($user_id, $platform = 1)
- {
- $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(
- 'ext_adv_campaigns.status' => 1,
- 'ext_adv_campaigns_position.position_code>' => $platform * 100,
- 'ext_adv_campaigns_position.position_code<=' => ($platform * 100) + 99
- ) )->groupby( 'ext_adv_campaigns.id' )->get( )->all( );
- if (empty( $campaigns )) {
- return null;
- }
- $config = array( );
- foreach ($campaigns as $campaign) {
- $places = Mysql::getInstance( )->from( 'ext_adv_campaigns_position' )->where( array(
- 'campaigns_id' => $campaign['id'],
- 'ext_adv_campaigns_position.position_code>' => $platform * 100,
- 'ext_adv_campaigns_position.position_code<=' => ($platform * 100) + 99
- ) )->orderby( 'position_code' )->get( )->all( );
- $place_to_blocks_map = array( );
- foreach ($places as $place) {
- $place_to_blocks_map[(int) $place['position_code']] = (int) $place['blocks'];
- }
- $config[] = array(
- 'id' => (int) $campaign['id'],
- 'places' => $place_to_blocks_map,
- 'source' => $campaign['source']
- );
- }
- return $config;
- }
- public function setTrackingId($tracking_id)
- {
- $this->tracking_id = $tracking_id;
- }
- /**
- * @param $user_id
- * @param $place
- * @return array|bool
- */
- public function getAds($user_id, $place)
- {
- $user = User::getInstance( $user_id );
- $options = $user->getServicesByType( 'option' );
- if ($options && (array_search( 'disable_ad', $options ) !== false)) {
- return false;
- }
- $platform = self::getUserPlatformByPlaceCode( $place );
- $campaigns = $this->getConfig( $user_id, $platform );
- if (empty( $campaigns )) {
- return false;
- }
- $ads = array( );
- $times = 0;
- $ad = $this->getAd( $user_id, $campaign, $place );
- ...........................................................................................
- .......................................................
- ..........................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement