public function application_list_json()
 {
     if ($no_auth = $this->checkAuth()) {
         return $no_auth;
     }
     $response = array('data' => array(), 'recordsTotal' => 0, 'recordsFiltered' => 0);
     try {
         $apps_list = new \AppsManager();
         $response['data'] = $apps_list->getList();
     } catch (\Exception $e) {
         $response['error'] = $error = $this->setLocalization('Failed to get the list of applications');
     }
     $response['recordsTotal'] = $response['recordsFiltered'] = count($response['data']);
     $response["draw"] = !empty($this->data['draw']) ? $this->data['draw'] : 1;
     $error = '';
     if ($this->isAjax) {
         $response = $this->generateAjaxResponse($response);
         return new Response(json_encode($response), empty($error) ? 200 : 500);
     } else {
         return $response;
     }
 }
 public static function getServices()
 {
     $apps = new AppsManager();
     $external_apps = $apps->getList(true);
     $installed_apps = array_values(array_filter($external_apps, function ($app) {
         return $app['installed'] == 1 && $app['status'] == 1 && !empty($app['alias']);
     }));
     $external_apps_list = array_map(function ($app) {
         return array('id' => 'external_' . $app['alias'], 'name' => $app['alias'], 'external' => 1);
     }, $installed_apps);
     $modules = Config::getSafe('disabled_modules', array());
     sort($modules);
     $idx = array_search('ivi', $modules);
     if ($idx !== false) {
         array_splice($modules, $idx, 1);
     }
     $modules = array_map(function ($module) {
         return array('id' => $module, 'name' => $module);
     }, $modules);
     $modules = array_merge($modules, $external_apps_list);
     return $modules;
 }
Example #3
0
 public function getModules()
 {
     $template = $this->getUserPortalTheme();
     $apps = new AppsManager();
     $external_apps = $apps->getList(true);
     $installed_apps = array_values(array_filter($external_apps, function ($app) {
         return $app['installed'] == 1 && $app['status'] == 1 && !empty($app['alias']);
     }));
     $installed_apps = array_map(function ($app) {
         return 'external_' . $app['alias'];
     }, $installed_apps);
     // change order order according to the package
     if (Config::get('enable_tariff_plans')) {
         $user = User::getInstance(Stb::getInstance()->id);
         $user_enabled_modules = $user->getServicesByType('module');
         if ($user_enabled_modules === null) {
             $user_enabled_modules = array();
         }
         if (Config::getSafe('enable_modules_order_by_package', false)) {
             $static_modules = array_diff(Config::get('all_modules'), $user_enabled_modules);
             $all_modules = array_merge($static_modules, $user_enabled_modules);
         } else {
             $flipped_installed_apps = array_flip($installed_apps);
             $installed_apps = array_values(array_filter($user_enabled_modules, function ($module) use($flipped_installed_apps) {
                 return isset($flipped_installed_apps[$module]);
             }));
             $all_modules = array_merge(Config::get('all_modules'), $installed_apps);
         }
     } else {
         $all_modules = array_merge(Config::get('all_modules'), $installed_apps);
     }
     $result = array('all_modules' => $all_modules, 'switchable_modules' => Config::get('disabled_modules'), 'disabled_modules' => $this->getDisabledModules(), 'restricted_modules' => $this->getRestrictedModules(), 'template' => $template);
     if (Config::getSafe('enable_supermodule', false)) {
         $key = md5($this->mac . time() . uniqid());
         $cache = Cache::getInstance();
         $cache->set($key, $this->mac, 0, 60);
         $result['supermodule'] = Config::getSafe('portal_url', '/stalker_portal/') . 'server/api/supermodule.php' . '?key=' . $key . '&mac=' . $this->mac . '&uid=' . $this->id . '&type=';
     }
     return $result;
 }
<?php

include "./common.php";
if (empty($_GET['uid'])) {
    exit;
}
$file = file_get_contents('../../new/launcher/profile.json');
$profile = json_decode($file, true);
$apps = new AppsManager();
$external_apps = $apps->getList(true);
$installed_apps = array_values(array_filter($external_apps, function ($app) {
    return $app['installed'] == 1 && $app['status'] == 1 && !empty($app['alias']);
}));
$installed_apps_names = array_map(function ($app) {
    return 'external_' . $app['alias'];
}, $installed_apps);
$all_modules = array_merge(Config::get('all_modules'), $installed_apps_names);
$disabled_modules = Stb::getDisabledModulesByUid((int) $_GET['uid']);
$user = Stb::getById((int) $_GET['uid']);
// if user is off - return empty menu
if ($user['status'] == 1) {
    $profile['menu'] = array();
    echo json_encode($profile);
    exit;
}
$profile['apiDomain'] = $profile['stalkerAuthDomain'] = 'http' . (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . Config::getSafe('portal_url', '/stalker_portal/') . 'api/api_v2.php?_resource=';
$profile['authDomain'] = 'http' . (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . Config::getSafe('portal_url', '/stalker_portal/') . 'auth/token/';
$profile['pingTimeout'] = Config::getSafe('watchdog_timeout', 120) * 1000;
$available_modules = array_diff($all_modules, $disabled_modules);
$available_modules[] = 'portal settings';
$module_to_app_map = array('vclub' => 'video club', 'audioclub' => 'audio club', 'media_browser' => 'explorer', 'weather.day' => 'weather', 'ex' => 'ex.ua', 'game.lines' => 'lines', 'game.memory' => 'memory', 'game.sudoku' => 'sudoku', 'internet' => 'browser', 'game.2048' => '2048');