public function rentVideo() { $video_id = (int) $_REQUEST['video_id']; $price = $_REQUEST['price']; $user = User::getInstance(Stb::getInstance()->id); $response = array(); try { $package = $user->getPackageByVideoId($video_id); if (empty($package)) { throw new Exception(_('Server error')); } if ($price === '0') { $oss_result = true; } else { $oss_result = $user->subscribeToPackage($package['id']); } $response['result'] = $oss_result; $response['rent_duration'] = $package['rent_duration']; $response['package_id'] = $package['id']; $rent_session_id = $user->rentVideo($video_id, $price); $response['rent_info'] = Mysql::getInstance()->from('video_rent')->where(array('id' => $rent_session_id))->get()->first(); $response['rent_info']['expires_in'] = User::humanDateDiff($response['rent_info']['rent_end_date'], $response['rent_info']['rent_date']); } catch (OssDeny $e) { $response['message'] = $e->getMessage(); Stb::logOssError($e); } catch (OssException $e) { $response['message'] = _('This operation is temporarily unavailable.'); Stb::logOssError($e); } catch (Exception $e) { $response['message'] = $e->getMessage(); Stb::logOssError($e); } return $response; }
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 __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 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(); } }
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 __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; }
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 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; }
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']; }
/** * Return link for program * * @return array */ public function createLink() { $res = array('id' => 0, 'cmd' => '', 'storage_id' => '', 'load' => '0', 'error' => ''); preg_match("/\\/media\\/(\\d+).mpg/", $_REQUEST['cmd'], $tmp_arr); $program_id = $tmp_arr[1]; $program = Epg::getById($program_id); try { $task = $this->getLessLoadedTaskByChId($program['ch_id']); } catch (StorageSessionLimitException $e) { $res['error'] = 'limit'; $res['storage_name'] = $e->getStorageName(); return $res; } $overlap = Config::getSafe('tv_archive_playback_overlap', 0) * 60; $overlap_start = Config::getSafe('tv_archive_playback_overlap_start', 0) * 60; $tz = new DateTimeZone(Stb::$server_timezone); $date = new DateTime(date('r', strtotime($program['time']))); $date->setTimeZone($tz); if ($overlap_start) { $date->sub(new DateInterval('PT' . $overlap_start . 'S')); } $date_now = new DateTime('now', new DateTimeZone(Stb::$server_timezone)); $date_to = new DateTime(date('r', strtotime($program['time_to']))); $date_to->setTimeZone($tz); $dst_diff = $date->format('Z') - $date_now->format('Z'); $storage = Master::getStorageByName($task['storage_name']); if (!$storage['flussonic_dvr'] && !$storage['wowza_dvr']) { if ($dst_diff > 0) { $date->add(new DateInterval('PT' . $dst_diff . 'S')); $date_to->add(new DateInterval('PT' . $dst_diff . 'S')); } elseif ($dst_diff < 0) { $dst_diff *= -1; $date->sub(new DateInterval('PT' . $dst_diff . 'S')); $date_to->sub(new DateInterval('PT' . $dst_diff . 'S')); } } $start_timestamp = $date->getTimestamp(); $stop_timestamp = $date_to->getTimestamp() + $overlap; $channel = Itv::getChannelById($program['ch_id']); $filename = $date->format("Ymd-H"); if ($channel['wowza_dvr']) { $filename .= '.mp4'; } else { $filename .= '.mpg'; } $res['storage_id'] = $storage['id']; $position = date("i", $start_timestamp) * 60 + date("s", $start_timestamp); if ($storage['flussonic_dvr']) { if (preg_match("/:\\/\\/([^\\/]*)\\/([^\\/]*).*(mpegts|m3u8)\$/", $channel['mc_cmd'], $match)) { if ($match[3] == 'mpegts') { $res['cmd'] = 'http://' . $storage['storage_ip'] . '/' . $match[2] . '/archive/' . $start_timestamp . '/' . ($stop_timestamp - $start_timestamp) . '/mpegts'; } else { $res['cmd'] = preg_replace('/:\\/\\/([^\\/]*)/', '://' . $storage['storage_ip'], $channel['mc_cmd']); $res['cmd'] = preg_replace('/\\.m3u8/', '-' . $start_timestamp . '-' . ($stop_timestamp - $start_timestamp) . '.m3u8', $res['cmd']); } $res['cmd'] .= '?ch_id=' . $program['ch_id'] . '&token=' . $this->createTemporaryToken($this->stb->id) . '&start=' . $position . '&duration=' . ($stop_timestamp - $start_timestamp) . '&osd_title=' . urlencode($channel['name'] . ' — ' . $program['name']) . '&real_id=' . $program['real_id']; $res['download_cmd'] = 'http://' . $storage['storage_ip'] . '/' . $match[2] . '/archive-' . $start_timestamp . '-' . ($stop_timestamp - $start_timestamp) . '.ts'; } else { $res['error'] = 'link_fault'; } } elseif ($storage['wowza_dvr']) { if (preg_match("/:\\/\\/([^\\/]*)\\/.*\\.m3u8/", $channel['mc_cmd'], $match)) { $res['cmd'] = preg_replace('/:\\/\\/([^\\/]*)/', '://' . $storage['storage_ip'], $channel['mc_cmd']); $res['cmd'] = preg_replace('/\\.m3u8.*/', '.m3u8?DVR&wowzadvrplayliststart=' . gmdate("YmdHis", $start_timestamp) . '&wowzadvrplaylistduration=' . ($stop_timestamp - $start_timestamp) * 1000, $res['cmd']) . '&ch_id=' . $program['ch_id'] . '&token=' . $this->createTemporaryToken("1") . '&start=' . $position . '&duration=' . ($stop_timestamp - $start_timestamp) . '&osd_title=' . urlencode($channel['name'] . ' — ' . $program['name']) . '&real_id=' . $program['real_id']; $res['download_cmd'] = false; } else { $res['error'] = 'link_fault'; } } else { $res['cmd'] = Config::getSafe('tv_archive_player_solution', 'ffmpeg') . ' http://' . $storage['storage_ip'] . ':' . $storage['apache_port'] . '/stalker_portal/storage/get.php?filename=' . $filename . '&ch_id=' . $program['ch_id'] . '&token=' . $this->createTemporaryToken(true) . '&start=' . $position . '&duration=' . ($stop_timestamp - $start_timestamp) . '&osd_title=' . urlencode($channel['name'] . ' — ' . $program['name']) . '&real_id=' . $program['real_id']; if (!empty($_REQUEST['download'])) { $downloads = new Downloads(); $res['download_cmd'] = $downloads->createDownloadLink('tv_archive', $program_id, Stb::getInstance()->id); } else { $res['download_cmd'] = false; } } $res['to_file'] = date("Ymd-H", $start_timestamp) . '_' . System::transliterate($channel['name'] . '_' . $program['name']) . '.mpg'; var_dump($res); return $res; }
public function checkUserAuth($username, $password, $mac = null, $serial_number = null, OAuthRequest $request) { sleep(1); // anti brute-force delay $user = null; if ($username) { $user = \User::getByLogin($username); } elseif (!$password && $mac) { if ($serial_number) { $_REQUEST['serial_number'] = $serial_number; } if ($request->getVersion()) { $_REQUEST['version'] = $request->getVersion(); } if ($request->getDeviceId2()) { $_REQUEST['device_id2'] = $request->getDeviceId2(); $_REQUEST['signature'] = $request->getSignature(); } // init user as STB \Stb::getInstance()->getProfile(); $user = \User::getByMac(\Stb::getInstance()->mac); } if (!$user) { $user = \User::authorizeFromOss($username, $password, $mac); } if (!$user) { return false; } $possible_user = $user->getProfile(); if (strlen($possible_user['password']) == 32 && md5(md5($password) . $possible_user['id']) == $possible_user['password'] || strlen($possible_user['password']) < 32 && $password == $possible_user['password']) { if (\Config::getSafe('oauth_force_mac_check', false) && \Config::getSafe('oauth_force_serial_number_check', false)) { if ($mac == $possible_user['mac'] && ($serial_number == $possible_user['serial_number'] || $possible_user['serial_number'] == '')) { $verified_user = $possible_user; } } else { if (\Config::getSafe('oauth_force_mac_check', false)) { if ($mac == $possible_user['mac']) { $verified_user = $possible_user; } } else { if (\Config::getSafe('oauth_force_serial_number_check', false)) { if ($serial_number == $possible_user['serial_number'] || $possible_user['serial_number'] == '') { $verified_user = $possible_user; } } else { $verified_user = $possible_user; } } } } if (!empty($verified_user)) { $user->setSerialNumber($serial_number); $user->updateUserInfoFromOSS(); if (\Config::getSafe('bind_stb_auth_and_oauth', true)) { // invalidate stb access_token $user->resetAccessToken(); } } $user->updateIp(); return !empty($verified_user); }
public static function logOssError(Exception $e) { $logger = new Logger(); $logger->setPrefix("oss_"); $date = new DateTime('now', new DateTimeZone(Config::get('default_timezone'))); $logger->error(sprintf("[%s] %s\nMessage:%s\nTrace:[%s]\n-------\n", $date->format('r'), Stb::getInstance()->mac, $e->getMessage(), $e->getTraceAsString())); }
public function getOrderedList() { $fav = $this->getFav(); $ls = Stb::getInstance()->getParam('ls'); if ($ls) { $ids_on_ls = Mysql::getInstance()->from('users')->where(array('ls' => $ls))->get()->all('id'); } else { $ids_on_ls = array($this->stb->id); } $user = User::getInstance($this->stb->id); $all_users_video_ids = $user->getServicesByType('video'); $result = $this->getData(); if (@$_REQUEST['sortby']) { $sortby = $_REQUEST['sortby']; if ($sortby == 'name' || $sortby == 'purchased') { $result = $result->orderby('video.name'); } elseif ($sortby == 'added') { $result = $result->orderby('video.added', 'DESC'); } elseif ($sortby == 'top') { $result->select('(count_first_0_5+count_second_0_5) as top')->orderby('top', 'DESC'); } elseif ($sortby == 'last_ended') { $result = $result->orderby('vclub_not_ended.added', 'DESC'); } elseif ($sortby == 'rating') { $result = $result->orderby('video.rating_kinopoisk', 'DESC'); } } else { $result = $result->orderby('video.name'); } if (!empty($_REQUEST['sortby']) && $_REQUEST['sortby'] == 'purchased' && Config::get('enable_tariff_plans')) { $rented_video = $user->getAllRentedVideo(); $rented_video_ids = array_keys($rented_video); $result = $result->in('video.id', $rented_video_ids); } if (@$_REQUEST['fav']) { $result = $result->in('video.id', $fav); } if (@$_REQUEST['hd']) { $result = $result->where(array('hd' => 1)); } if (Config::get('enable_tariff_plans') && $all_users_video_ids != 'all') { $result = $result->in('video.id', $all_users_video_ids); } if (@$_REQUEST['not_ended']) { $result = $result->from('vclub_not_ended')->select('vclub_not_ended.series as cur_series, vclub_not_ended.end_time as position')->where('video.id=vclub_not_ended.video_id', 'AND ', null, -1)->in('vclub_not_ended.uid', $ids_on_ls); } $this->setResponseData($result); return $this->getResponse('prepareData'); }
public static function getClonesIPAddress() { $cache = Cache::getInstance(); $mac = Stb::getInstance()->mac; if (empty($mac)) { return false; } $history = Cache::getInstance()->get($mac); if ($history === false) { $history = array(); } else { $history = json_decode($history, true); if ($history === null) { $history = array(); } } $history[] = Stb::getInstance()->ip; $result = $cache->set($mac, json_encode($history), array(), 10); //var_dump($history); if (count($history) > 1) { return $history; } return false; }
} $mac = Cache::getInstance()->get($_GET['key']); if (!$mac || $mac != $_GET['mac']) { return false; } $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 {
public function __construct() { $this->db = Mysql::getInstance(); $this->stb = Stb::getInstance(); }
/** * @deprecated */ public function setLocale($language) { $this->language = $language; Stb::getInstance()->initLocale($this->language); }
public function __construct() { $this->db = Mysql::getInstance(); $this->stb = Stb::getInstance(); $this->page = @intval($_REQUEST['p']); }
public static function getNotEnded() { $raw = Mysql::getInstance()->from('vclub_not_ended')->where(array('uid' => Stb::getInstance()->id))->get()->all(); $not_ended = array(); foreach ($raw as $video) { $not_ended[$video['video_id']] = $video; } return $not_ended; }
public function getCities($country_id, $search = '') { $result = array(); if (empty($search)) { $cities = Mysql::getInstance()->from('cities')->where(array('country_id' => $country_id))->orderby('name_en')->get()->all(); foreach ($cities as $city) { $selected = Stb::getInstance()->city_id == $city['id'] ? 1 : 0; $city_name = $city['name_en']; $result[] = array('label' => $city_name, 'value' => $city['id'], 'timezone' => $city['timezone'], 'selected' => $selected); } } else { $cities = Mysql::getInstance()->select('id, name_en')->from('cities')->where(array('country_id' => $country_id))->like(array('name' => iconv('windows-1251', 'utf-8', $search) . '%', 'name_en' => $search . '%'), 'OR ')->limit(3)->get()->all(); $result = array(); foreach ($cities as $city) { $result[] = array('label' => $city['name_en'], 'value' => $city['id']); } } return $result; }
public function getSimpleDataTable() { $ch_id = intval($_REQUEST['ch_id']); $date = $_REQUEST['date']; $page = intval($_REQUEST['p']); $default_page = false; $page_items = 10; $from = $date . ' 00:00:00'; $to = $date . ' 23:59:59'; //$epg = $this->getEpgForChannelsOnPeriod(array($ch_id), $from, $to); $program = Mysql::getInstance()->from('epg')->select('epg.*, UNIX_TIMESTAMP(epg.time) as start_timestamp, UNIX_TIMESTAMP(epg.time_to) as stop_timestamp, TIME_FORMAT(epg.time,"' . _('%H:%i') . '") as t_time, TIME_FORMAT(epg.time_to,"' . _('%H:%i') . '") as t_time_to')->where(array('epg.ch_id' => $ch_id, 'epg.time>=' => $from, 'epg.time<=' => $to))->orderby('epg.time')->get()->all(); $total_items = count($program); $ch_idx = Mysql::getInstance()->from('epg')->count()->where(array('epg.ch_id' => $ch_id, 'epg.time>=' => $from, 'epg.time<' => date(Mysql::DATETIME_FORMAT)))->get()->counter(); //var_dump($ch_idx, date('Y-m-d')); if ($page == 0) { $default_page = true; $page = ceil($ch_idx / $page_items); if ($page == 0) { $page = 1; } if ($date != date('Y-m-d')) { $page = 1; $default_page = false; } } $program = array_slice($program, ($page - 1) * $page_items, $page_items); $now = time(); $recorder = new StreamRecorder(); $user_rec_ids = $recorder->getDeferredRecordIdsForUser(Stb::getInstance()->id); $tv_archive = new TvArchive(); $archived_recs = $tv_archive->getAllTasksAssoc(); $reminder = new TvReminder(); $reminders = $reminder->getAllActiveForMac(Stb::getInstance()->mac); //var_dump($reminders); for ($i = 0; $i < count($program); $i++) { if ($program[$i]['stop_timestamp'] < $now) { $program[$i]['open'] = 0; } else { $program[$i]['open'] = 1; } /*if ($program[$i]['start_timestamp'] < $now){ $program[$i]['mark_memo'] = null; }*/ //var_dump($reminders); if (array_key_exists($program[$i]['real_id'], $reminders)) { $program[$i]['mark_memo'] = 1; } else { $program[$i]['mark_memo'] = 0; } //if (in_array($program[$i]['id'], $user_rec_ids)){ if (array_key_exists($program[$i]['real_id'], $user_rec_ids)) { $program[$i]['mark_rec'] = 1; $program[$i]['rec_id'] = $user_rec_ids[$program[$i]['real_id']]; } else { $program[$i]['mark_rec'] = 0; } if (array_key_exists($program[$i]['ch_id'], $archived_recs)) { if ($program[$i]['start_timestamp'] > time() - $archived_recs[$program[$i]['ch_id']]['parts_number'] * 3600 && $program[$i]['stop_timestamp'] < time()) { $program[$i]['mark_archive'] = 1; } else { $program[$i]['mark_archive'] = 0; } } else { $program[$i]['mark_archive'] = 0; } } if ($default_page) { $cur_page = $page; $selected_item = $ch_idx - ($page - 1) * $page_items; } else { $cur_page = 0; $selected_item = 0; } return array('cur_page' => $cur_page, 'selected_item' => $selected_item, 'total_items' => $total_items, 'max_page_items' => $page_items, 'data' => $program); }
public function getRawAllUserChannels($uid = null) { if ($uid) { if (Config::getSafe('enable_tariff_plans', false)) { $user = User::getInstance(Stb::getInstance()->id); $user_channels = $user->getServicesByType('radio'); if ($user_channels == 'all') { return Mysql::getInstance()->from('radio')->where(array('status' => 1))->orderby('number'); } else { return Mysql::getInstance()->from('radio')->where(array('status' => 1))->in('id', $user_channels)->orderby('number'); } } } return Mysql::getInstance()->from('radio')->where(array('status' => 1))->orderby('number'); }
public function __construct() { $this->manager = Stb::getInstance(); $this->allowed_fields = array_fill_keys(array('mac', 'ls', 'login', 'status', 'online', 'additional_services_on', 'ip', 'version', 'expire_billing_date', 'account_balance', 'last_active'), true); }
public function setAdEndedTime() { $ad_id = (int) $_REQUEST['ad_id']; $end_time = (int) $_REQUEST['end_time']; $total_time = (int) $_REQUEST['total_time']; $ended = (int) $_REQUEST['ended']; $ad = $this->getById($ad_id); if (empty($ad)) { return false; } return Mysql::getInstance()->insert('vclub_ads_log', array('title' => $ad['title'], 'vclub_ad_id' => $ad_id, 'uid' => Stb::getInstance()->id, 'watched_percent' => $total_time == 0 ? 0 : ceil(100 * $end_time / $total_time), 'watched_time' => $end_time, 'watch_complete' => $ended, 'added' => 'NOW()'))->insert_id(); }
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; }
<?php $start_time = microtime(1); // no cache header("Expires: Thu, 01 Jan 1970 00:00:00 GMT"); header("Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT"); header("Pragma: no-cache"); header("Cache-Control: no-store, no-cache, must-revalidate"); require_once "common.php"; set_error_handler(array($debug = Debug::getInstance(), 'parsePHPError')); $response = new AjaxBackend(); Stb::getInstance(); $loader = new DataLoader($_REQUEST['type'], $_REQUEST['action']); $response->setBody($loader->getResult()); echo "generated in: " . round(microtime(1) - $start_time, 3) . "s; query counter: " . Mysql::get_num_queries() . "; cache hits: " . Mysql::get_cache_hits() . "; cache miss: " . Mysql::get_cache_misses() . "; " . $debug->getErrorStr(); $response->send();