public function get(RESTApiRequest $request, $user_id) { $recorder = new \StreamRecorder(); $free = ceil($recorder->checkTotalUserRecordsLength($user_id) / 60); $total = \Config::getSafe('total_records_length', 600); return array('total' => $total, 'free' => $free); }
/** * @return WeatherProvider * @throws Exception */ private function getProvider() { $class = ucfirst(Config::getSafe('weather_provider', 'weatherco')); if (!class_exists($class)) { throw new Exception('Resource "' . $class . '" does not exist'); } return new $class(); }
public function __construct() { parent::__construct(); $this->appid = Config::getSafe('openweathermap_appid', ''); if ($this->appid) { $this->context_params['http']['header'] = 'x-api-key: ' . $this->appid; } }
private static function getProvider() { $class = ucfirst(Config::getSafe('vclub_info_provider', 'kinopoisk')); if (!class_exists($class)) { throw new Exception('Resource "' . $class . '" does not exist'); } return $class; }
public function getUserInfo(User $user) { if (!Config::exist('oss_url')) { return false; } if (Config::get('oss_url') == '') { return false; } $data = file_get_contents(Config::get('oss_url') . (strpos(Config::get('oss_url'), '?') > 0 ? '&' : '?') . 'mac=' . $user->getMac() . '&serial_number=' . $user->getSerialNumber() . '&type=' . $user->getStbType() . '&locale=' . $user->getLocale() . '&login='******'&portal=' . (empty($_SERVER['HTTP_HOST']) ? '' : $_SERVER['HTTP_HOST']) . '&verified=' . intval($user->isVerified()) . '&ip=' . $user->getIp()); return $this->parseResult($data, Config::getSafe('strict_oss_url_check', true)); }
public static function getServices() { $modules = Config::getSafe('disabled_modules', array()); sort($modules); $idx = array_search('ivi', $modules); if ($idx !== false) { array_splice($modules, $idx, 1); } return array_map(function ($module) { return array('id' => $module, 'name' => $module); }, $modules); }
function get_save_folder($id) { $dir_name = ceil($id / 100); $dir_path = realpath(PROJECT_PATH . '/../' . Config::getSafe('screenshots_path', 'screenshots/')) . '/' . $dir_name; //echo '$dir_path: '.$dir_path; if (!is_dir($dir_path)) { umask(0); if (!mkdir($dir_path, 0777)) { return -1; } else { return $dir_path; } } else { return $dir_path; } }
public function filterDocument($document) { if (empty($document)) { throw new RESTNotFound("Document not found"); } $document = array_intersect_key($document, $this->fields_map); $document['account'] = $document['ls']; unset($document['ls']); $document['logo'] = \Config::exist('portal_logo_url') ? \Config::get('portal_logo_url') : null; if (is_readable(realpath(PROJECT_PATH . '/../new/launcher/img/1080/bg.jpg'))) { $document['background'] = \Config::getSafe('portal_url', '/stalker_portal/') . 'new/launcher/img/1080/bg.jpg'; } else { $document['background'] = null; } return $document; }
public function send() { if (!empty($this->request) && strpos($this->request->getAccept(), 'text/channel-monitoring-id-url') !== false) { if (is_array($this->body['results'])) { $channels = array_filter($this->body['results'], function ($channel) { return $channel['enable_monitoring']; }); //$channels = $this->body['results']; if (preg_match("/items=(\\d+)-(\\d*)/", $this->request->getAccept(), $match)) { $start = $match[1]; $end = empty($match[2]) ? count($channels) : $match[2]; $channels = array_slice($channels, $start - 1, $end - $start + 1); //var_dump($start, $end, $channels); } elseif (preg_match("/part=(\\d+)\\/(\\d+)/", $this->request->getAccept(), $match)) { $length = count($channels); $start = round((intval($match[1]) - 1) * ($length / intval($match[2]))); $end = round(intval($match[1]) * ($length / intval($match[2]))); $channels = array_slice($channels, $start, $end - $start); //var_dump($length, $start, $end); } $body = array_reduce($channels, function ($prev, $curr) { return $prev . $curr['id'] . ' ' . $curr['url'] . (isset($curr['type']) ? ' ' . $curr['type'] : '') . ' ' . str_replace(' ', '_', $curr["ch_name"]) . ' ' . ((int) $curr["status"] == 1 ? "up" : "down") . "\n"; }, ''); header("Content-Type: text/plain"); echo $body; } return; } header("Content-Type: " . $this->content_type); $this->setOutput(); $response = json_encode($this->body); echo $response; ob_end_flush(); if (!Config::getSafe('enable_api_log', true)) { return; } $logger = new Logger(); $logger->setPrefix("api_"); // format: ip - login - [date] method "query" - "data" response_bytes; $logger->access(sprintf("%s - %s - [%s] %s \"%s\" - \"%s\" %d\n", empty($_SERVER['HTTP_X_REAL_IP']) ? $_SERVER['REMOTE_ADDR'] : $_SERVER['HTTP_X_REAL_IP'], @$_SERVER['PHP_AUTH_USER'], date("r"), $_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI'], empty($this->request) ? 'no resource' : http_build_query($this->request->getData()), strlen($response))); if (!empty($this->body['error'])) { // format: ip - login - [date] method "query" - "data": error message; $logger->error(sprintf("%s - %s - [%s] %s \"%s\" - \"%s\": %s\n", empty($_SERVER['HTTP_X_REAL_IP']) ? $_SERVER['REMOTE_ADDR'] : $_SERVER['HTTP_X_REAL_IP'], @$_SERVER['PHP_AUTH_USER'], date("r"), $_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI'], empty($this->request) ? 'no resource' : http_build_query($this->request->getData()), $this->body['error'])); } }
public function __construct($init_info = array()) { if (empty($init_info)) { return; } if (!empty($init_info['id'])) { $this->storage = $this->getById($init_info['id']); } else { if (!empty($init_info['name'])) { $this->storage = $this->getByName($init_info['name']); } } if (empty($this->storage)) { throw new ErrorException("Storage can not be initialized with values: " . var_export($init_info, true)); } $this->max_failures = Config::getSafe("max_storage_failures", 3); $this->stat_period = Config::getSafe("storage_stat_period", 300); return $this->storage; }
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 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; }
echo _('restart on OK'); ?> </span> <span style="display:none" id="text_channel"><input type="text" name="channel" id="channel" size="5" maxlength="3"> <?php echo _('channels'); ?> </span> </td> </tr> <tr> <td align="right"> TTL: </td> <td> <input type="text" name="ttl" id="ttl" value="<?php echo Config::getSafe('watchdog_timeout', 120) * 2; ?> ">, <?php echo _('s'); ?> </td> </tr> <tr id="msg_row" style="display:none"> <td align="right" valign="top"> MSG: </td> <td> <textarea name="msg" id="msg" rows="10" cols="50"></textarea><br/> <?php if (substr($locale, 0, 2) == 'ru') { ?>
</form> <?php if (Admin::isPageActionAllowed()) { ?> <table cellpadding="0" cellspacing="3" width="641"> <tr> <td class="other"> <table align="center" width="80%"> <?php if (Config::getSafe('enable_tariff_plans', false)) { ?> <?php if (Config::getSafe('enable_tv_subscription_for_tariff_plans', false)) { ?> <tr align="center"> <td><a href="subscribe.php?id=<?php echo $id; ?> "><?php echo _('TV subscription'); ?> </a> (<?php echo kop2grn(get_cost_sub_channels()); ?> )</td> </tr> <?php }
<?php /* */ include "./common.php"; $from_date = date("Y-m-d H:i:s", time() - 7 * 24 * 60 * 60); $from_id = Mysql::getInstance()->select('max(id) as max_id')->from('master_log')->where(array('added<' => $from_date))->get()->first('max_id'); if ($from_id) { Mysql::getInstance()->delete('master_log', array('id<' => $from_id)); if (Config::getSafe('use_optimize_table', true)) { Mysql::getInstance()->query('ALTER TABLE `master_log` DROP INDEX `added`'); Mysql::getInstance()->query('optimize table master_log'); Mysql::getInstance()->query('ALTER TABLE `master_log` ADD INDEX `added` (`added`)'); } } echo 1;
/** * Return link for current channel and current time * * NGINX config: * * location /tslink/ { * * rewrite ^/tslink/(.+)/archive/(\d+)/(.+) /stalker_portal/server/api/chk_tmp_timeshift_link.php?key=$1&file=$3 last; * * proxy_set_header Host 192.168.1.71; # <- portal ip * proxy_set_header X-Real-IP $remote_addr; * proxy_pass http://192.168.1.71:88/; # <- portal ip * } * * location /archive/ { * root /var/www/bb1; * internal; * } * * @return string */ public function getLinkForChannel() { $ch_id = intval($_REQUEST['ch_id']); $res = array('id' => 0, 'cmd' => '', 'storage_id' => '', 'load' => '0', 'error' => ''); try { $task = $this->getLessLoadedTaskByChId($ch_id); } catch (StorageSessionLimitException $e) { $res['error'] = 'limit'; $res['storage_name'] = $e->getStorageName(); return $res; } if (empty($task)) { $res['error'] = 'server_error'; return $res; } $storage = Master::getStorageByName($task['storage_name']); //$channel = Itv::getChannelById($ch_id); $tz = new DateTimeZone(Stb::$server_timezone); $date = new DateTime(date('r')); $date->setTimeZone($tz); $date_now = new DateTime('now', new DateTimeZone(Stb::$server_timezone)); $dst_diff = $date->format('Z') - $date_now->format('Z'); if (!$storage['flussonic_dvr'] && !$storage['wowza_dvr']) { if ($dst_diff > 0) { $date->add(new DateInterval('PT' . $dst_diff . 'S')); } elseif ($dst_diff < 0) { $dst_diff *= -1; $date->sub(new DateInterval('PT' . $dst_diff . 'S')); } } $position = intval($date->format("i")) * 60 + intval($date->format("s")); $channel = Itv::getChannelById($ch_id); $filename = $date->format("Ymd-H"); $filename .= '.mpg'; if ($channel['flussonic_dvr']) { if (preg_match("/:\\/\\/([^\\/]*)\\/([^\\/]*).*(mpegts|m3u8)\$/", $channel['mc_cmd'], $match)) { if ($match[3] == 'mpegts') { $res['cmd'] = 'http://' . $storage['storage_ip'] . '/' . $match[2] . '/archive/' . strtotime(date("Y-m-d H:00:00")) . '/3600/mpegts'; } else { $res['cmd'] = preg_replace('/:\\/\\/([^\\/]*)/', '://' . $storage['storage_ip'], $channel['mc_cmd']); $res['cmd'] = preg_replace('/\\.m3u8/', '-' . strtotime(date("Y-m-d H:00:00")) . '-3600' . '.m3u8', $res['cmd']); // todo: current hour? } $res['cmd'] .= '' . '?token=' . $this->createTemporaryToken($this->stb->id) . ' position:' . $position . ' media_len:' . (intval(date("H")) * 3600 + intval(date("i")) * 60 + intval(date("s"))); } else { $res['error'] = 'server_error'; } } elseif ($channel['wowza_dvr']) { if (preg_match("/:\\/\\/([^\\/]*)\\/.*\\.m3u8/", $channel['mc_cmd'], $match)) { $url = preg_replace('/:\\/\\/([^\\/]*)/', '://' . $storage['storage_ip'], $channel['mc_cmd']); $res['cmd'] = preg_replace('/\\.m3u8.*/', '.m3u8?DVR&wowzadvrplayliststart=' . gmdate("YmdH0000") . '&wowzadvrplaylistduration=3600000', $url) . '&token=' . $this->createTemporaryToken("1") . ' position:' . $position . ' media_len:' . (intval(date("H")) * 3600 + intval(date("i")) * 60 + intval(date("s"))); } else { $res['error'] = 'server_error'; } return $res; } else { if (Config::getSafe('enable_timeshift_tmp_link', false)) { $redirect_url = '/archive/' . $ch_id . '/' . $filename; $link_result = $this->createTemporaryTimeShiftToken($redirect_url); $res['cmd'] = 'ffmpeg http://' . $storage['storage_ip'] . '/tslink/' . $link_result . '/archive/' . $ch_id . '/' . $filename . ' position:' . $position . ' media_len:' . (intval(date("H")) * 3600 + intval(date("i")) * 60 + intval(date("s"))); } else { $res['cmd'] = 'ffmpeg http://' . $storage['storage_ip'] . '/archive/' . $ch_id . '/' . $filename . ' position:' . $position . ' media_len:' . (intval(date("H")) * 3600 + intval(date("i")) * 60 + intval(date("s"))); } } return $res; }
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 static function getAccessSchema(HTTPRequest $request) { $auth_header = $request->getAuthorization(); if (empty($auth_header) && $request->getParam('api_key') === null) { throw new AuthUnauthorized("Authorization required"); } if (strpos($auth_header, "MAC ") === 0 && \Config::getSafe('api_v2_access_type', 'bearer') == 'mac') { return new MACAccessType($request, new self()); } else { if (strpos($auth_header, "Bearer ") === 0 && \Config::getSafe('api_v2_access_type', 'bearer') == 'bearer') { return new BearerAccessType($request, new self()); } else { if ($request->getParam('api_key') !== null) { return new DeveloperAccessType($request, new self()); } else { throw new AuthBadRequest("Unsupported authentication type"); } } } }
} ?> </table> </span> </td> </tr> <tr> <td align="right"> <?php echo _('TV archive duration, h'); ?> : </td> <td> <input name="tv_archive_duration" id="tv_archive_duration" type="text" value="<?php echo isset($_GET['id']) ? @$tv_archive_duration : Config::getSafe('tv_archive_parts_number', 168); ?> "> </td> </tr> <tr> <td align="right" valign="top"> <?php echo _('Allow nPVR'); ?> : </td> <td> <input name="allow_pvr" id="allow_pvr" type="checkbox" value="1" <?php echo @$checked_allow_pvr; ?>
$response['result'] = vclubinfo::getInfoById($_GET['kinopoisk_id']); } } } } catch (KinopoiskException $e) { echo $e->getMessage(); $logger = new Logger(); $logger->setPrefix("vclubinfo_"); // format: [date] - error_message - [base64 encoded response]; $logger->error(sprintf("[%s] - %s - \"%s\"\n", date("r"), $e->getMessage(), base64_encode($e->getResponse()))); } } elseif ($_GET['get'] == 'tv_services') { $response['result'] = Itv::getServices(); } elseif ($_GET['get'] == 'video_services') { $response['result'] = Video::getServices(); } elseif ($_GET['get'] == 'radio_services') { $response['result'] = Radio::getServices(); } elseif ($_GET['get'] == 'module_services') { $response['result'] = Module::getServices(); } elseif ($_GET['get'] == 'option_services') { $option_services = Config::getSafe('option_services', array()); $response['result'] = array_map(function ($item) { return array('id' => $item, 'name' => $item); }, $option_services); } $output = ob_get_contents(); ob_end_clean(); if ($output) { $response['output'] = $output; } echo json_encode($response);
public function getCountries() { $result = array(); $countries = Mysql::getInstance()->from('countries')->orderby('name_en')->get()->all(); $this->country_id = !$this->city_id ? 0 : intval(Mysql::getInstance()->from('cities')->where(array('id' => $this->city_id))->get()->first('country_id')); $this->openweathermap_country_id = !$this->openweathermap_city_id ? 0 : intval(Mysql::getInstance()->from('all_cities')->where(array('id' => $this->openweathermap_city_id))->get()->first('country_id')); foreach ($countries as $country) { if (Config::getSafe('weather_provider', 'openweathermap') == 'openweathermap') { $selected = $this->openweathermap_country_id == $country['id'] ? 1 : 0; } else { $selected = $this->country_id == $country['id'] ? 1 : 0; } $result[] = array('label' => $country['name_en'], 'value' => $country['id'], 'selected' => $selected); } return $result; }
public function getCategories() { $categories = $this->db->select('id, category_name as title, category_alias as alias')->from("media_category")->get()->all(); array_unshift($categories, array('id' => '*', 'title' => $this->all_title, 'alias' => '*')); $categories = array_map(function ($item) { $item['title'] = _($item['title']); return $item; }, $categories); if (Config::getSafe('enable_coming_soon_section', false)) { $categories[] = array('id' => 'coming_soon', 'title' => _('coming soon'), 'alias' => 'coming_soon'); } return $categories; }
public function deleteApp($app_id, $version = null) { $app = Mysql::getInstance()->from('apps')->where(array('id' => $app_id))->get()->first(); if ($version === null) { $version = $app['current_version']; } $path = realpath(PROJECT_PATH . '/../../' . Config::getSafe('apps_path', 'stalker_apps/') . $app['alias'] . '/' . $version); if (is_dir($path)) { self::delTree($path); } return false; }
<? if (Config::getSafe('enable_video_high_quality_option', false)){ ?> <tr> <td align="right" valign="top"> <?php echo _('High quality'); ?> : </td> <td> <input name="high_quality" id="high_quality" type="checkbox" <? echo isset($checked_high_quality) ? $checked_high_quality : 'checked' ?> > </td> </tr> <?}?> <? if (Config::getSafe('enable_video_low_quality_option', false)){ ?> <tr> <td align="right" valign="top"> <?php echo _('Low quality'); ?> : </td> <td> <input name="low_quality" id="low_quality" type="checkbox" <? echo isset($checked_low_quality) ? $checked_low_quality : 'checked' ?> > </td> </tr> <?}?> <tr id="genre_1" style="background-color:#e0e0e0"> <td align="right" valign="top">
echo "<td class='list'><a href='events.php?mac=" . $arr['mac'] . "'>" . $arr['ip'] . "</a></td>\n"; echo "<td class='list'><a href='profile.php?id=" . $arr['id'] . "'>" . $arr['login'] . "</a></td>\n"; echo "<td class='list'>" . $arr['ls'] . "</td>\n"; echo "<td class='list'>" . $arr['fname'] . "</td>\n"; echo "<td class='list'>" . $arr['tariff_plan_name'] . "</td>\n"; echo "<td class='list'>" . (!$status && Config::getSafe('hide_media_info_for_offline_stb', false) ? '--' : get_cur_media($arr['now_playing_type'])) . "</td>\n"; echo "<td class='list'>" . (!$status && Config::getSafe('hide_media_info_for_offline_stb', false) ? '' : $now_playing_content) . "</td>\n"; echo "<td class='list'>" . get_last_time($arr['now_playing_start']) . "</td>\n"; echo "<td class='list'><b>" . ($status ? '<font color="Green">online</font>' : '<font color="Red">offline</font>') . "</b></td>\n"; echo "<td class='list' nowrap>"; if (Admin::isActionAllowed() && !Config::getSafe('deny_change_user_status', false)) { echo "<a href='users.php?id=" . $arr['id'] . "&search=" . @$_GET['search'] . "&action=cut_off'>" . get_user_color($arr['id']) . "</a>"; } else { echo "<b>" . get_user_color($arr['id']) . "</b>"; } if (Admin::isActionAllowed() && !Config::getSafe('deny_delete_user', false)) { echo " "; echo "<a href='#' onclick='if(confirm(\"" . _('Do you really want to delete this record?') . "\")){document.location=\"users.php?del=1&id=" . $arr['id'] . "&page=" . @$_GET['page'] . "&search=" . @$_GET['search'] . "\"}'>del</a>"; } echo "</td>\n"; echo "<td class='list'>" . $arr['last_change_status'] . "</td>\n"; echo "</tr>\n"; } echo "</table>\n"; echo "<table width='600' align='center' border=0>\n"; echo "<tr>\n"; echo "<td width='100%' align='center'>\n"; echo page_bar(); echo "</td>\n"; echo "</tr>\n"; echo "</table>\n";
<?php set_time_limit(0); ob_start(); include "../common.php"; if (!Config::getSafe('enable_m3u_file', false)) { header("HTTP/1.0 404 Not Found"); exit; } $channels = Mysql::getInstance()->from('itv')->where(array('status' => 1))->orderby('number')->get()->all(); $m3u_data = "#EXTM3U\n"; foreach ($channels as $channel) { $m3u_data .= "#EXTINF:0," . $channel['number'] . '. ' . $channel['name'] . "\n"; if (!empty($_GET['origin'])) { $m3u_data .= $channel['cmd'] . "\n"; } else { if (preg_match("/([^\\s]+:\\/\\/[^\\s]+)/", $channel['cmd'], $tmp)) { $cmd = $tmp[1]; } else { $cmd = ''; } $cmd = str_replace(array('rtp://', 'udp://'), array('rtp://@', 'udp://@'), $cmd); $m3u_data .= $cmd . "\n"; } } if (is_file(PROJECT_PATH . '/tv.m3u') && is_writable(PROJECT_PATH . '/tv.m3u') || is_writable(PROJECT_PATH)) { @file_put_contents(PROJECT_PATH . '/tv.m3u', $m3u_data); } header('Content-Type: audio/mpegurl'); header('Content-Disposition: attachment; filename="playlist.m3u"'); echo $m3u_data;
<?php session_start(); include "./common.php"; Admin::checkAuth(); $image_url = Config::getSafe('vclub_info_provider', 'kinopoisk') == 'kinopoisk' ? 'kinopoisk.ru/' : 'image.tmdb.org/'; if (strpos($_GET['url'], 'http://') === 0 && strpos($_GET['url'], $image_url)) { echo file_get_contents($_GET['url']); }
<?php require_once "../server/common.php"; if (!Config::getSafe('enable_api_v2', false)) { echo "API v2 not enabled"; exit; } use Stalker\Lib\RESTAPI\v2\RESTApiManager; use Stalker\Lib\OAuth\AuthAccessHandler; $server = new RESTApiManager(new AuthAccessHandler()); $server->handleRequest();
public static function getNginxSecureLink($cmd) { if (preg_match("/:\\/\\/([^\\/]+)\\/?(\\S*)/", $cmd, $match)) { $nginx_secure_link_order = Config::get('nginx_secure_link_order'); $nginx_secure_link_field = array('$secure_link_expires' => '', '$uri' => '', '$remote_addr' => '', '$secret' => ''); $path = '/' . $match[2]; $expire = time() + Config::getSafe('nginx_secure_link_ttl', 5); if (strpos($nginx_secure_link_order, '$secret') !== FALSE) { $nginx_secure_link_field['$secret'] = Config::get('nginx_secure_link_secret'); } if (strpos($nginx_secure_link_order, '$uri') !== FALSE) { $nginx_secure_link_field['$uri'] = str_replace('/playlist.m3u8', '', $path); } if (strpos($nginx_secure_link_order, '$secure_link_expires') !== FALSE) { $nginx_secure_link_field['$secure_link_expires'] = $expire; } if (strpos($nginx_secure_link_order, '$remote_addr') !== FALSE) { if (!empty($_SERVER['REMOTE_ADDR'])) { $nginx_secure_link_field['$remote_addr'] = $_SERVER['REMOTE_ADDR']; } else { throw new ItvLinkException('link_fault'); } } $hash = base64_encode(md5(strtr($nginx_secure_link_order, $nginx_secure_link_field), true)); $hash = strtr($hash, '+/', '-_'); $hash = str_replace('=', '', $hash); $new_path = $path . (strpos($cmd, '?') ? '&' : '?') . 'st=' . $hash . '&e=' . $expire; return str_replace($match[1] . $path, $match[1] . $new_path, $cmd); } else { throw new ItvLinkException('link_fault'); } }
protected function createTemporaryLink($val) { $key = md5($val . microtime(1) . uniqid()); $cache = Cache::getInstance(); $result = $cache->set($key, $val, 0, Config::getSafe('vclub_tmp_link_ttl', 5)); if ($result) { return $key; } else { return $result; } }