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; }
public function getAppInfo($app_id) { $app = Mysql::getInstance()->from('apps')->where(array('id' => $app_id))->get()->first(); if (empty($app)) { return false; } $repo = new GitHub($app['url']); $info = $repo->getFileContent('package.json'); $app['name'] = isset($info['name']) ? $info['name'] : ''; $app['alias'] = empty($info['alias']) ? AppsManager::safeFilename($info['name']) : $info['alias']; $app['available_version'] = isset($info['version']) ? $info['version'] : ''; $app['description'] = isset($info['description']) ? $info['description'] : ''; $option_values = json_decode($app['options'], true); if (empty($option_values)) { $option_values = array(); } unset($app['options']); if ($app['current_version']) { $app['installed'] = is_dir(realpath(PROJECT_PATH . '/../../' . Config::getSafe('apps_path', 'stalker_apps/') . $app['alias'] . '/' . $app['current_version'])); } else { $app['installed'] = false; } $app['app_url'] = 'http' . (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . '/' . Config::getSafe('apps_path', 'stalker_apps/') . $app['alias'] . '/' . $app['current_version']; $releases = $repo->getReleases(50); if (is_array($releases)) { $releases = array_map(function ($release) use($app, $option_values) { $repo = new GitHub($app['url']); $repo->setRelease($release['tag_name']); $info = $repo->getFileContent('package.json'); $option_list = isset($info['options']) ? $info['options'] : array(); $option_list = array_map(function ($option) use($option_values) { if (isset($option_values[$option['name']])) { $option['value'] = $option_values[$option['name']]; } elseif (!isset($option['value'])) { $option['value'] = null; } if (isset($option['info'])) { $option['desc'] = $option['info']; } return $option; }, $option_list); return array('version' => $release['tag_name'], 'name' => $release['name'], 'published' => $release['published_at'], 'description' => $release['body'], 'installed' => is_dir(realpath(PROJECT_PATH . '/../../' . Config::getSafe('apps_path', 'stalker_apps/') . $app['alias'] . '/' . $release['tag_name'])), 'current' => $release['tag_name'] == $app['current_version'], 'options' => $option_list); }, $releases); } $app['versions'] = $releases; return $app; }
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');
public function application_version_delete() { if (!$this->isAjax || $this->method != 'POST' || empty($this->postData)) { $this->app->abort(404, $this->setLocalization('Page not found')); } if ($no_auth = $this->checkAuth()) { return $no_auth; } $response['action'] = 'manageList'; if (!empty($this->postData['id'])) { ignore_user_abort(true); set_time_limit(0); $app_db = $this->db->getApplication(array('id' => $this->postData['id'])); try { $apps = new \AppsManager(); $apps->deleteApp($this->postData['id'], $this->postData['version']); $response['error'] = $error = ''; if ($app_db[0]['current_version'] == $this->postData['version']) { $response['installed'] = 0; } } catch (\Exception $e) { $response['error'] = $error = $this->setLocalization('Error of uninstalling the application.'); $response['error'] .= ' ' . $this->setLocalization($e->getMessage()); } } else { $response['error'] = $error = $this->setLocalization('Application is undefined'); } $response = $this->generateAjaxResponse($response); return new Response(json_encode($response), empty($error) ? 200 : 500); }
<?php include "./common.php"; if (empty($_GET['name']) || empty($_GET['mac'])) { exit; } $alias = str_replace('external_', '', $_GET['name']); $app = Mysql::getInstance()->from('apps')->where(array('alias' => $alias))->get()->first(); if (empty($app) || $app['status'] == 0) { exit; } $apps = new AppsManager(); $app = $apps->getAppInfo($app['id']); if (!$app['installed']) { exit; } header('Content-Type: application/x-javascript'); $user_theme = Mysql::getInstance()->from('users')->where(array('mac' => $_GET['mac']))->get()->first('theme'); $user_theme = empty($user_theme) || !array_key_exists($user_theme, Middleware::getThemes()) ? Mysql::getInstance()->from('settings')->get()->first('default_template') : $user_theme; $icon = $app['app_url'] . '/img/{0}/' . $app['icons'] . '/' . ($user_theme == 'default' ? '2010' : '2014') . '.png'; ?> /** * Redirection to <?php echo $app['name']; ?> module. */ (function(){ main_menu.add('<?php echo $app['name'];
<?php include "./common.php"; set_time_limit(0); $apps = new AppsManager(); $apps->startAutoUpdate();