public function get(RESTApiRequest $request, $parent_id) { $epg = \Epg::getById(intval($parent_id)); if (empty($epg)) { throw new RESTNotFound("Program not found"); } $channel = \Itv::getChannelById(intval($epg['ch_id'])); if (empty($channel)) { throw new RESTNotFound("Channel not found"); } if ($channel["enable_tv_archive"] != 1) { throw new RESTForbidden("This channel does not have tv archive"); } try { $archive = new \TvArchive(); $url = $archive->getUrlByProgramId(intval($epg['id'])); } catch (\StorageSessionLimitException $e) { throw new RESTTemporaryUnavailable("Session limit"); } catch (\Exception $e) { throw new RESTServerError("Failed to obtain url"); } return $url; }
private function getStorages($id = FALSE) { $return = array('storage_names' => array(), 'wowza_storage_names' => array(), 'flussonic_storage_names' => array()); foreach ($this->db->getStorages() as $key => $value) { if ($value['flussonic_dvr'] && !$value['wowza_dvr']) { $return['flussonic_storage_names'][$value['storage_name']] = $value['storage_name']; } elseif (!$value['flussonic_dvr'] && $value['wowza_dvr']) { $return['wowza_storage_names'][$value['storage_name']] = $value['storage_name']; } else { $return['storage_names'][$value['storage_name']] = $value['storage_name']; } } if ($id !== FALSE) { $tasks = $id == FALSE ? array() : \TvArchive::getTasksByChannelId($id); if (!empty($tasks)) { $return = array_map(function ($row) use($tasks) { $names = array_filter(array_map(function ($task_row) use($row) { if (in_array($task_row['storage_name'], $row)) { return $task_row['storage_name']; } }, $tasks)); return array_combine(array_values($names), $names); }, $return); } else { $return = array('storage_names' => array(), 'wowza_storage_names' => array(), 'flussonic_storage_names' => array()); } } return $return; }
} } else { foreach ($links_on_server as $streamer_id) { Mysql::getInstance()->insert('ch_link_on_streamer', array('link_id' => $link_id, 'streamer_id' => $streamer_id)); } } } } } if ($enable_tv_archive) { if (!empty($_POST['flussonic_dvr'])) { $archive = new FlussonicTvArchive(); } elseif (!empty($_POST['wowza_dvr'])) { $archive = new WowzaTvArchive(); } else { $archive = new TvArchive(); } $archive->createTasks($ch_id, $storage_names); } if ($allow_pvr) { RemotePvr::setAllowedStoragesForChannel($ch_id, $pvr_storage_names); } if (!empty($_FILES['logo']['name'])) { if ($logo = handle_upload_logo($_FILES['logo'], $ch_id)) { Mysql::getInstance()->update('itv', array('logo' => $logo), array('id' => $ch_id)); } else { $error = _('Error: could not save logo') . ' <a href="#form">#</a>'; } } if (empty($error)) { header("Location: add_itv.php?edit=1&id=" . intval(@$_GET['id']) . "#form");
public function __construct() { parent::__construct(); }
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); }
<?php include "./common.php"; $result = TvArchive::checkTemporaryTimeShiftToken($_GET['key']); if (!$result) { $result = '/404/'; } $result = preg_replace("/([^\\/]+)\$/", $_GET['file'], $result); header("X-Accel-Redirect: " . $result);
<?php include "./common.php"; $response = array('result' => TvArchive::checkTemporaryToken($_GET['token'])); echo json_encode($response);
<?php include "./common.php"; if (empty($_GET['lid'])) { header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); exit; } $link = Mysql::getInstance()->from('download_links')->where(array('link_hash' => $_GET['lid']))->get()->first(); if (empty($link)) { header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); exit; } $user = User::getInstance((int) $link['uid']); ob_start(); if ($link['type'] == 'tv_archive') { $tv_archive = new TvArchive(); try { $url = $tv_archive->getUrlByProgramId($link['media_id']); } catch (\Exception $e) { header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); exit; } if ($url) { header("Location: " . $url); ob_end_clean(); exit; } } elseif ($link['type'] == 'vclub') { $video = Vod::getInstance(); try { $url = $video->getUrlByVideoId($link['media_id'], (int) $link['param1']);