public function __construct(array $nested_params, array $external_params) { parent::__construct($nested_params, $external_params); $this->document = new RESTApiTvChannelDocument($this, $external_params); $this->document->controllers->add(new RESTApiTvChannelLink($this->nested_params)); $this->document->controllers->add(new RESTApiTvChannelRecord($this->nested_params)); $this->controllers->add(new RESTApiTvChannelLast($this->nested_params)); $this->fields_map = array_fill_keys(array('id', "name", "number", "archive", "censored"), true); $this->manager = \Itv::getInstance(); if (!empty($this->nested_params['users.id'])) { $user_id = $this->nested_params['users.id']; $user = \Stb::getById($user_id); if (empty($user)) { throw new RESTNotFound("User not found"); } $this->user_id = $user['id']; $this->fav_channels = $this->manager->getFav($this->user_id); $this->user_channels = $this->manager->getAllUserChannelsIdsByUid($this->user_id); } if (!empty($this->nested_params['genre'])) { $genres = new \TvGenre(); $genre = $genres->getById($this->nested_params['genre'], true); if (empty($genre)) { throw new RESTNotFound("Genre not found"); } $this->genre_id = (int) $genre['id']; } }
public function get(RESTApiRequest $request, $params) { if (empty($this->params['users.id'])) { throw new RESTBadRequest("User required"); } if (is_array($params) && count($params) != 4) { throw new RESTBadRequest("Bad params"); } $user_id = $this->params['users.id']; $user = \Stb::getById($user_id); if (empty($user)) { throw new RESTNotFound("User not found"); } if (is_array($params)) { $karaoke_id = (int) $params[0]; } else { $karaoke_id = (int) $params; } $karaoke = \Karaoke::getInstance(); try { $url = $karaoke->getUrlByKaraokeId($karaoke_id); } catch (\Exception $e) { throw new RESTServerError("Failed to obtain url"); } if (preg_match("/(\\S+:\\/\\/\\S+)/", $url, $match)) { $url = $match[1]; } return $url; }
public function get(RESTApiRequest $request, $parent_id) { $rec_id = $parent_id; if (empty($this->params['users.id'])) { throw new RESTBadRequest("User required"); } $user_id = $this->params['users.id']; $user = \Stb::getById($user_id); if (empty($user)) { throw new RESTNotFound("User not found"); } $pvr = new \RemotePvr(); $recording = $pvr->getById($rec_id); if (empty($recording)) { throw new RESTNotFound("Recording not found"); } if ($recording['uid'] != $user_id) { throw new RESTNotFound("User don't have access to this recording"); } try { $url = $pvr->getUrlByRecId($rec_id); } catch (\Exception $e) { throw new RESTServerError("Failed to obtain url"); } if (preg_match("/(\\S+:\\/\\/\\S+)/", $url, $match)) { $url = $match[1]; } return $url; }
public function __construct(array $nested_params, array $external_params) { parent::__construct($nested_params, $external_params); $this->manager = \Radio::getInstance(); if (!empty($this->nested_params['users.id'])) { $user_id = $this->nested_params['users.id']; $user = \Stb::getById($user_id); if (empty($user)) { throw new RESTNotFound("User not found"); } $this->user_id = $user['id']; } }
public function __construct(array $nested_params, array $external_params) { parent::__construct($nested_params, $external_params); $this->document = new RESTApiVideoDocument($this, $this->external_params); $this->document->controllers->add(new RESTApiVideoLink($this->nested_params)); $this->document->controllers->add(new RESTApiVideoNotEnded($this->nested_params)); $this->fields_map = array_fill_keys(array('id', "name", "description", "director", "actors", "year", "censored", "added", "genres", "genres_ids", "cover", "hd"), true); $this->manager = new \Video(); if (!empty($this->nested_params['users.id'])) { $user_id = $this->nested_params['users.id']; $user = \Stb::getById($user_id); if (empty($user)) { throw new RESTNotFound("User nor found"); } $user_obj = \User::getInstance(); $this->favorites = $user_obj->getVideoFavorites(); $this->not_ended = $user_obj->getNotEndedVideo(); } if (!empty($this->nested_params['video.category']) && empty($this->nested_params['video.genre'])) { $category_id = $this->nested_params['video.category']; $genre = new \VideoGenre(); $genres = $genre->getByCategoryId($category_id, true); if (empty($genres)) { throw new RESTNotFound("Genres list is empty"); } $this->genres_ids = array_map(function ($genre) { return (int) $genre['_id']; }, $genres); } else { if (!empty($this->nested_params['video.genre']) && empty($this->nested_params['video.category'])) { $genre = new \VideoGenre(); $genres = $genre->getById($this->nested_params['video.genre'], true); if (empty($genres)) { throw new RESTNotFound("Genres list is empty"); } $genres = array_map(function ($genre) { return (int) $genre['id']; }, $genres); $this->genres_ids = $genres; } else { if (!empty($this->nested_params['video.genre']) && !empty($this->nested_params['video.category'])) { $genre = new \VideoGenre(); $genres = $genre->getByIdAndCategory($this->nested_params['video.genre'], $this->nested_params['video.category'], true); if (empty($genres)) { throw new RESTNotFound("Genres list is empty"); } $this->genres_ids = array($genres['id']); } } } }
public function create(RESTApiRequest $request, $parent_id) { if (empty($this->params['users.id'])) { throw new RESTBadRequest("User required"); } $user_id = $this->params['users.id']; $user = \Stb::getById($user_id); if (empty($user)) { throw new RESTNotFound("User not found"); } $itv = \Itv::getInstance(); $user_channels = $itv->getAllUserChannelsIdsByUid($user['id']); if (!in_array($parent_id, $user_channels)) { throw new RESTForbidden("User don't have access to this channel"); } $channel = \Itv::getById($parent_id); if (empty($channel)) { throw new RESTNotFound("Channel not found"); } if (!$channel['allow_pvr']) { throw new RESTForbidden("Channel does not support PVR"); } $now_time = time(); $start_time = (int) $request->getData('start_time'); $end_time = (int) $request->getData('end_time'); if ($start_time && $start_time < $now_time) { $start_time = $now_time; } if ($end_time) { if ($start_time && $end_time < $start_time || $end_time < $now_time) { throw new RESTNotAcceptable("Not acceptable time range"); } } $pvr = new \RemotePvr(); try { $rec_id = $pvr->startRecNowByChannelId($channel['id']); } catch (\nPVRException $e) { throw new RESTServerError($e->getMessage()); } if (!$rec_id) { return false; } if ($end_time) { sleep(1); // give some time to dumpstream to startup $recorder = new \StreamRecorder(); $recorder->stopDeferred($rec_id, ceil(($end_time - $now_time) / 60)); } $recording = $pvr->getById($rec_id); return array('id' => $recording['id'], 'name' => $recording['program'], 'start_time' => strtotime($recording['t_start']), 'end_time' => strtotime($recording['t_stop']), 'ch_id' => (int) $recording['ch_id'], 'ch_name' => $channel['name'], 'status' => $recording['started'] ? $recording['ended'] ? 2 : 1 : 0); }
public function create(RESTApiRequest $request, $parent_id) { if (empty($this->params['users.id'])) { throw new RESTBadRequest("User required"); } if (empty($this->params['ch_id'])) { throw new RESTBadRequest("Channel ID required"); } $user_id = (int) $this->params['users.id']; $ch_id = (int) $this->params['ch_id']; $program_id = (int) $parent_id; $user = \Stb::getById($user_id); if (empty($user)) { throw new RESTNotFound("User not found"); } $itv = \Itv::getInstance(); $user_channels = $itv->getAllUserChannelsIdsByUid($user['id']); if (!in_array($ch_id, $user_channels)) { throw new RESTForbidden("User don't have access to this channel"); } $channel = \Itv::getById($ch_id); if (empty($channel)) { throw new RESTNotFound("Channel not found"); } if (!$channel['allow_pvr']) { throw new RESTForbidden("Channel does not support PVR"); } $program = \Epg::getById($program_id); if (empty($program)) { throw new RESTNotFound("Program not found"); } if ($program['ch_id'] != $ch_id) { throw new RESTNotAcceptable("Channel of program mismatch"); } if (strtotime($program['time']) < time()) { throw new RESTNotAcceptable("Start time in past"); } $pvr = new \RemotePvr(); try { $rec_id = $pvr->startRecDeferredById($program['real_id']); } catch (\nPVRException $e) { throw new RESTServerError($e->getMessage()); } if (!$rec_id) { return false; } $recording = $pvr->getById($rec_id); return array('id' => $recording['id'], 'name' => $recording['program'], 'start_time' => strtotime($recording['t_start']), 'end_time' => strtotime($recording['t_stop']), 'ch_id' => (int) $recording['ch_id'], 'ch_name' => $channel['name'], 'status' => $recording['started'] ? $recording['ended'] ? 2 : 1 : 0); }
public function __construct(array $nested_params, array $external_params) { parent::__construct($nested_params, $external_params); $this->document = new RESTApiTvFavoriteDocument($this, $this->external_params); if (empty($this->nested_params['users.id'])) { throw new RESTBadRequest("User must be specified"); } $user_id = $this->nested_params['users.id']; $user = \Stb::getById($user_id); if (empty($user)) { throw new RESTNotFound("User not found"); } $this->user_id = $user['id']; $this->manager = \Itv::getInstance(); }
public function __construct(array $nested_params, array $external_params) { parent::__construct($nested_params, $external_params); $this->document = new RESTApiPvrDocument($this, $this->external_params); $this->document->controllers->add(new RESTApiPvrLink($this->nested_params)); $this->document->controllers->add(new RESTApiPvrStop($this->nested_params)); if (!empty($this->nested_params['users.id'])) { $user_id = $this->nested_params['users.id']; $user = \Stb::getById($user_id); if (empty($user)) { throw new RESTNotFound("User not found"); } $this->user_id = $user['id']; } else { throw new RESTNotAcceptable("User ID required"); } }
public function create(RESTApiRequest $request, $parent_id) { $rec_id = $parent_id; if (empty($this->params['users.id'])) { throw new RESTBadRequest("User required"); } $user_id = $this->params['users.id']; $user = \Stb::getById($user_id); if (empty($user)) { throw new RESTNotFound("User not found"); } $pvr = new \RemotePvr(); $recording = $pvr->getById($rec_id); if (empty($recording)) { throw new RESTNotFound("Recording not found"); } if ($recording['uid'] != $user_id) { throw new RESTNotFound("User don't have access to this recording"); } return $pvr->stopRecById($rec_id); }
public function get(RESTApiRequest $request, $parent_id) { if (empty($this->params['users.id'])) { throw new RESTBadRequest("User required"); } $user_id = $this->params['users.id']; $user = \Stb::getById($user_id); if (empty($user)) { throw new RESTNotFound("User not found"); } $itv = \Itv::getInstance(); $this->user_channels = $itv->getAllUserChannelsIdsByUid($user['id']); if (!in_array($parent_id, $this->user_channels)) { throw new RESTForbidden("User don't have access to this channel"); } $channel = \Itv::getById($parent_id); if (empty($channel)) { throw new RESTNotFound("Channel not found"); } $start = $request->getParam('start'); if ($start) { // todo: time shift! throw new RESTNotFound("Time shift in progress..."); } $urls = \Itv::getUrlsForChannel($channel['id']); if (!empty($urls)) { $link = $urls[0]['id']; } else { $link = null; } try { $url = $itv->getUrlByChannelId($parent_id, $link); } catch (\ItvChannelTemporaryUnavailable $e) { throw new RESTNotFound($e->getMessage()); } if (preg_match("/(\\S+:\\/\\/\\S+)/", $url, $match)) { $url = $match[1]; } return $url; }
function get_user_status($id) { $stb = Stb::getById($id); return $stb['status']; }
function additional_services_btn() { global $id; $stb = Stb::getById($id); $additional_services_on = $stb['additional_services_on']; if ($additional_services_on == 0) { $color = 'red'; $txt = _('Disabled'); $set = 1; } else { $color = 'green'; $txt = _('Enabled'); $set = 0; } return '<a href="profile.php?id=' . $id . '&set_services=' . $set . '" style="color:' . $color . '"><b>' . $txt . '</b></a>'; }
try { $url = $video->getUrlByVideoId($link['media_id'], (int) $link['param1']); } catch (\Exception $e) { header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); exit; } if (preg_match('/(\\S+:\\/\\/\\S+)/', $url, $match)) { $url = $match[1]; } if ($url) { header("Location: " . $url); ob_end_clean(); exit; } } elseif ($link['type'] == 'pvr') { $user = Stb::getById((int) $link['uid']); if (empty($user)) { header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); exit; } $pvr = new RemotePvr(); $recording = $pvr->getById($link['media_id']); if (empty($recording)) { header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); exit; } if ($recording['uid'] != $link['uid']) { header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); exit; } try {
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'); $available_modules = array_map(function ($module) use($module_to_app_map) { return isset($module_to_app_map[$module]) ? $module_to_app_map[$module] : $module; }, $available_modules);
public function get(RESTApiRequest $request, $parent_id) { $user = \Stb::getById($parent_id); /// sptintf format: 1-account_number, 2-full name, 3-login, 4-mac return sprintf(_('account_agreement_info'), $user['ls'], $user['fname'], $user['login'], $user['mac']); }
public function get(RESTApiRequest $request, $parent_id) { $user = \Stb::getById($parent_id); return $this->filter($user); }
function get_mac_by_id(){ $stb = Stb::getById((int) $_GET['id']); return $stb['mac']; }