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 __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 update(RESTRequest $request) { $stb_list = $request->getConvertedIdentifiers(); if (empty($stb_list)) { throw new RESTCommandException('Empty stb list'); } /*if (count($stb_list) != 1){ throw new RESTCommandException('Only one identifier allowed'); }*/ $uids = $stb_list; $data = $request->getPut(); if (empty($data)) { throw new RESTCommandException('HTTP PUT data is empty'); } if (!key_exists('disabled', $data) && !key_exists('restricted', $data)) { throw new RESTCommandException('Update data is empty'); } if (key_exists('disabled', $data)) { foreach ($uids as $uid) { Stb::setDisabledModulesByUid($uid, $data['disabled']); } } if (key_exists('restricted', $data)) { foreach ($uids as $uid) { Stb::setRestrictedModulesByUid($uid, $data['restricted']); } } return array('disabled' => Stb::getDisabledModulesByUid($uids[0]), 'restricted' => Stb::getRestrictedModulesByUid($uids[0])); }
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 static function getSubscriptionChannelsIds($uid) { $mac = Mysql::getInstance()->from('users')->where(array('id' => (int) $uid))->get()->first('mac'); if (empty($mac)) { return array(); } if (Stb::getInstance()->isModerator()) { return Mysql::getInstance()->from('itv')->where(array('base_ch' => 0))->get()->all('id'); } if (self::$itv_subscription === false) { self::$itv_subscription = Mysql::getInstance()->from('itv_subscription')->where(array('uid' => $uid))->get()->first(); } if (empty(self::$itv_subscription)) { return array(); } $sub_ch = self::$itv_subscription['sub_ch']; if (empty($sub_ch)) { return array(); } $sub_ch_arr = unserialize(System::base64_decode($sub_ch)); if (!is_array($sub_ch_arr)) { return array(); } return $sub_ch_arr; }
public function update(RESTRequest $request) { $put = $request->getPut(); if (empty($put)) { throw new RESTCommandException('HTTP PUT data is empty'); } $allowed_to_update_fields = array_fill_keys(array('sub_ch', 'additional_services_on'), true); $data = array_intersect_key($put, $allowed_to_update_fields); $stb_data = array_intersect_key($put, array('additional_services_on' => true)); if (empty($data)) { throw new RESTCommandException('Update data is empty'); } unset($data['additional_services_on']); if (!empty($stb_data)) { //$stb = Stb::getInstance(); //$stb->setParam('additional_services_on', intval($stb_data['additional_services_on'])); $uids = $request->getConvertedIdentifiers(); foreach ($uids as $uid) { Stb::setAdditionServicesById($uid, intval($stb_data['additional_services_on'])); } } //var_dump($stb_data); if (!empty($data)) { $list = ItvSubscription::updateByUids($request->getConvertedIdentifiers(), $data); if (empty($list)) { return false; } } return $this->formatList(ItvSubscription::getByUids($request->getConvertedIdentifiers())); }
protected function getUsersIdsFromIdentifiers($identifiers) { if (!empty($identifiers[0]) && strlen($identifiers[0]) >= 12 && strpos($identifiers[0], ":")) { return Stb::getUidByMacs($identifiers); } else { return Stb::getUidByLogin($identifiers); } }
public function getConvertedIdentifiers() { if (self::$use_mac_identifiers || !empty($this->identifiers[0]) && strlen($this->identifiers[0]) >= 12) { //var_dump($this->identifiers); return Stb::getUidByMacs($this->identifiers); } else { return Stb::getUidByLs($this->identifiers); } }
public function __construct() { $this->db = Mysql::getInstance(); $this->stb = Stb::getInstance(); $this->storages = $this->getAllActiveStorages(); $this->moderator_storages = $this->getModeratorStorages(); $this->clients = $this->getClients(); $this->cache_expire_h = Config::get('master_cache_expire'); $this->stb_storages = $this->getStoragesForStb(); }
public function update(RESTApiRequest $request, $parent_id) { $allowed_for_update = array_fill_keys(array("parent_password"), true); $data = $request->getData(); if (empty($data)) { throw new RESTBadRequest("Update data is empty"); } $data = array_intersect_key($data, $allowed_for_update); if (empty($data)) { throw new RESTBadRequest("Update data is empty"); } return \Stb::updateById($parent_id, $data); }
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 static function writePackageSubscribeLog($user_id, $package_id, $set_state) { $data = array('user_id' => $user_id, 'set_state' => $set_state, 'package_id' => $package_id); if (!empty(Stb::getInstance()->id) && (empty($_SERVER['TARGET']) || $_SERVER['TARGET'] !== 'API' && $_SERVER['TARGET'] !== 'ADM')) { $data['initiator_id'] = Stb::getInstance()->id; $data['initiator'] = 'user'; } else { $data['initiator_id'] = Admin::getInstance()->getId(); if (!empty($data['initiator_id'])) { $data['initiator'] = 'admin'; } } Mysql::getInstance()->insert('package_subscribe_log', $data); }
public function save() { $downloads = @$_REQUEST['downloads']; if (empty($downloads)) { $downloads = '""'; } $downloads = System::base64_encode($downloads); $record = Mysql::getInstance()->from('user_downloads')->where(array('uid' => Stb::getInstance()->id))->get()->first(); if (empty($record)) { return Mysql::getInstance()->insert('user_downloads', array('downloads' => $downloads, 'uid' => Stb::getInstance()->id))->insert_id(); } else { return Mysql::getInstance()->update('user_downloads', array('downloads' => $downloads), array('uid' => Stb::getInstance()->id))->result(); } }
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"); } }
protected function postParse($weather) { if (!empty($weather['date'])) { if (strlen($weather['date']) == 10 && !empty($weather['hour'])) { $weather['date'] = $weather['date'] . ' ' . $weather['hour'] . ':00:00'; } $target_timezone = Mysql::getInstance()->from('cities')->where(array('id' => Stb::getInstance()->city_id))->get()->first('timezone'); if (!$target_timezone) { $target_timezone = Stb::getInstance()->getTimezone(); } $date = new DateTime($weather['date'], new DateTimeZone('Europe/Kiev')); $date->setTimeZone(new DateTimeZone($target_timezone)); $weather['date_orig'] = $weather['date']; $weather['date'] = $date->format('Y-m-d H:i:s'); $weather['hour'] = $date->format('G'); $weather['pict'] = $this->getPicture($weather); } return $weather; }
public function update(RESTApiRequest $request, $parent_id) { $allowed_for_update = array_fill_keys(array("parent_password", "theme"), true); $data = $request->getData(); if (empty($data)) { throw new RESTBadRequest("Update data is empty"); } $data = array_intersect_key($data, $allowed_for_update); if (empty($data)) { throw new RESTBadRequest("Update data is empty"); } if (!empty($data['theme'])) { $themes = \Middleware::getThemes(); if (!isset($themes[$data['theme']])) { throw new RESTBadRequest("Theme '" . $data['theme'] . "' is not supported"); } } return \Stb::updateById($parent_id, $data); }
public function __construct() { $this->db = Mysql::getInstance(); $this->stb = Stb::getInstance(); $this->response['max_page_items'] = self::max_page_items; /// TRANSLATORS: Letters of the alphabet. If the letter is missing - leave "."; $this->abc = array_filter(array('*', _('ABC_1l'), _('ABC_2l'), _('ABC_3l'), _('ABC_4l'), _('ABC_5l'), _('ABC_6l'), _('ABC_7l'), _('ABC_8l'), _('ABC_9l'), _('ABC_10l'), _('ABC_11l'), _('ABC_12l'), _('ABC_13l'), _('ABC_14l'), _('ABC_15l'), _('ABC_16l'), _('ABC_17l'), _('ABC_18l'), _('ABC_19l'), _('ABC_20l'), _('ABC_21l'), _('ABC_22l'), _('ABC_23l'), _('ABC_24l'), _('ABC_25l'), _('ABC_26l'), _('ABC_27l'), _('ABC_28l'), _('ABC_29l'), _('ABC_30l'), _('ABC_31l'), _('ABC_32l'), _('ABC_33l')), function ($e) { return $e != '.'; }); $this->months = array(_('january'), _('february'), _('march'), _('april'), _('may'), _('june'), _('july'), _('august'), _('september'), _('october'), _('november'), _('december')); $this->all_title = _('All'); $this->no_ch_info = _('[No channel info]'); $this->page = @intval($_REQUEST['p']); if ($this->page == 0) { $this->load_last_page = true; } if ($this->page > 0) { $this->page--; } }
public function getEvents() { $just_started = isset($_REQUEST['init']) ? (int) $_REQUEST['init'] : 0; if (isset($_REQUEST['init']) && Config::getSafe('log_mac_clones', false) && $just_started == 0 && Stb::getInstance()->getParam('just_started') == 0) { $clone_ip = Middleware::getClonesIPAddress($this->stb->mac); if ($clone_ip) { Stb::logDoubleMAC($clone_ip); } } if ($this->stb->getParam('ip') != $this->stb->ip) { $user = User::getInstance($this->stb->id); $user->getInfoFromOSS(); } $this->db->update('users', array('keep_alive' => 'NOW()', 'ip' => $this->stb->ip, 'now_playing_type' => intval($_REQUEST['cur_play_type']), 'just_started' => $just_started, 'last_watchdog' => 'NOW()'), array('mac' => $this->stb->mac)); $events = Event::getAllNotEndedEvents($this->stb->id); $messages = count($events); $res['data'] = array(); $res['data']['msgs'] = $messages; if ($messages > 0) { if ($events[0]['sended'] == 0) { Event::setSended($events[0]['id']); if ($events[0]['need_confirm'] == 0) { Event::setEnded($events[0]['id']); } } if ($events[0]['id'] != @$_GET['data']['event_active_id']) { $res['data']['id'] = $events[0]['id']; $res['data']['event'] = $events[0]['event']; $res['data']['need_confirm'] = $events[0]['need_confirm']; $res['data']['msg'] = $events[0]['msg']; $res['data']['reboot_after_ok'] = $events[0]['reboot_after_ok']; $res['data']['auto_hide_timeout'] = $events[0]['auto_hide_timeout']; $res['data']['param1'] = $events[0]['param1']; if (Config::getSafe('display_send_time_in_message', false)) { $res['data']['send_time'] = $events[0]['addtime']; } } } $res['data']['additional_services_on'] = Config::getSafe('enable_tariff_plans', false) ? '1' : $this->stb->additional_services_on; return $res; }
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); }
private function getLinkByRecId($rec_id) { $item = self::getById($rec_id); $master = new StreamRecorder(); try { $res = $master->play($rec_id, 0, false, $item['storage_name']); } catch (Exception $e) { trigger_error($e->getMessage()); } $res['local'] = 0; if (!empty($res['cmd'])) { preg_match("/\\.(\\w*)\$/", $res['cmd'], $ext_arr); $res['to_file'] = System::transliterate($item['id'] . '_' . Itv::getChannelNameById($item['ch_id']) . '_' . $item['program']); $res['to_file'] .= '.' . $ext_arr[1]; } if (!empty($_REQUEST['download'])) { $downloads = new Downloads(); $res['cmd'] = $downloads->createDownloadLink('pvr', $rec_id, Stb::getInstance()->id); } return $res; }
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; }
public function getUserPackages() { $user = User::getInstance(Stb::getInstance()->id); $packages = $user->getPackages(); $page = intval($_GET['p']); if ($page == 0) { $page = 1; } $sliced_packages = array_slice($packages, ($page - 1) * 14, 14); //var_dump($packages); $sliced_packages = array_map(function ($package) { $package['optional'] = (bool) $package['optional']; if ($package['subscribed']) { $package['subscribed_str'] = _('Subscribed'); } else { $package['not_subscribed_str'] = _('Not subscribed'); } return $package; }, $sliced_packages); $data = array('total_items' => count($packages), 'max_page_items' => 14, 'selected_item' => 0, 'cur_page' => 0, 'data' => $sliced_packages); return $data; }
public function create(RESTRequest $request) { $data = $request->getData(); if (empty($data)) { throw new RESTCommandException('HTTP POST data is empty'); } $allowed_to_update_fields = array_fill_keys(array('mac', 'login', 'password', 'status', 'additional_services_on', 'ls', 'end_date', 'account_balance'), true); $data = array_intersect_key($data, $allowed_to_update_fields); if (empty($data)) { throw new RESTCommandException('Insert data is empty'); } if (isset($data['end_date'])) { $data['expire_billing_date'] = $data['end_date']; unset($data['end_date']); } if (!empty($data['mac'])) { $mac = Middleware::normalizeMac($data['mac']); if (!$mac) { throw new RESTCommandException('Not valid mac address'); } $data['mac'] = $mac; } if (empty($data['mac']) && (empty($data['login']) || empty($data['password']))) { throw new RESTCommandException('Login and password required'); } try { $uid = Stb::create($data); } catch (Exception $e) { throw new RESTCommandException($e->getMessage()); } $stb_list = $this->manager->getByUids(array($uid)); $stb_list = $this->formatList($stb_list); if (count($stb_list) == 1) { return $stb_list[0]; } return $stb_list; }
private function onSubscriptionHookResult($config_param, $ext_package_id) { if (Config::get($config_param) == '') { return false; } $url = Config::get($config_param) . '?mac=' . Stb::getInstance()->mac . '&tariff_id=' . User::getInstance(Stb::getInstance()->id)->getExternalTariffId() . '&package_id=' . $ext_package_id; var_dump($url); $data = file_get_contents($url); if (!$data) { throw new OssFault('Server error, no data'); } $data = json_decode($data, true); if (empty($data)) { throw new OssFault('Server error, wrong format'); } var_dump($data); if ($data['status'] != 'OK' && !empty($data['error'])) { throw new OssDeny($data['error']); } if ($data['status'] != 'OK' || empty($data['results'])) { throw new OssError('Server error or empty results'); } return $data['results']; }
public function getDvbChannels() { $stb_type = Stb::getInstance()->getParam('stb_type'); if ($stb_type != 'MAG270' && $stb_type != 'MAG275') { return array(); } if ($this->dvb_channels !== null) { return $this->dvb_channels; } if (!in_array('dvb', stb::getAvailableModulesByUid($this->stb->id))) { $this->dvb_channels = array(); return $this->dvb_channels; } $dvb_channels = Mysql::getInstance()->from('dvb_channels')->where(array('uid' => $this->stb->id))->get()->first('channels'); if (empty($dvb_channels)) { $this->dvb_channels = array(); return $this->dvb_channels; } $dvb_channels = json_decode($dvb_channels, true); if (!$dvb_channels) { $this->dvb_channels = array(); return $this->dvb_channels; } $ch_number = (int) $this->getChannels(true)->orderby('number', 'desc')->get()->first('number'); $this->dvb_channels = array_map(function ($channel) use(&$ch_number) { $ch_number++; $channel['type'] = 'dvb'; $channel['cmd'] = 'dvb dvb://' . $channel['id']; $channel['cmds'] = array($channel['cmd']); $channel['name'] = $channel['name'] . ' (DVB)'; $channel['status'] = 1; $channel['number'] = (string) $ch_number; $channel['dvb_id'] = $channel['id']; $channel['id'] = (int) str_replace(array('T', 'C', '_'), '', $channel['id']); $channel['scrambled'] = $channel['scrambled'] == 'true' ? 1 : 0; $channel['tv_genre_id'] = 'dvb'; unset($channel['isRadio']); unset($channel['symrate']); unset($channel['channel_number']); return $channel; }, $dvb_channels); return $this->dvb_channels; }
function get_user_status($id) { $stb = Stb::getById($id); return $stb['status']; }