public function unsubscribeFromPackage($ext_package_id) { if (!Config::exist('on_unsubscribe_hook_url')) { return true; } return $this->onSubscriptionHookResult('on_unsubscribe_hook_url', $ext_package_id); }
private function getConnectionForRead() { if (!Config::exist('read_mysql_host')) { $this->links['read'] = $this->getConnectionForWrite(); } elseif (!isset($this->links['read'])) { $this->links['read'] = $this->getConnection(Config::get('read_mysql_host'), Config::getSafe('read_mysql_port', 3306), Config::get('read_mysql_user'), Config::get('read_mysql_pass'), Config::get('read_db_name')); } return $this->links['read']; }
public function __construct() { if (Config::exist('http_proxy')) { $this->context_params['http']['proxy'] = Config::get('http_proxy'); $this->context_params['http']['request_fulluri'] = true; if (Config::exist('http_proxy_login') && Config::exist('http_proxy_password')) { $this->context_params['http']['header'] = "Proxy-Authorization: Basic " . base64_encode(Config::get('http_proxy_login') . ":" . Config::get('http_proxy_password')) . "\r\n"; } } $this->cache_table = strtolower(get_called_class()) . '_cache'; }
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 static function setChannelLinkStatus($link_id, $status) { if (strpos($link_id, 's') === 0) { // stream balanser monitoring $balanser_link_id = substr($link_id, 1); Mysql::getInstance()->update('ch_link_on_streamer', array('monitoring_status' => $status), array('id' => $balanser_link_id)); $balanser_link = Mysql::getInstance()->from('ch_link_on_streamer')->where(array('id' => $balanser_link_id))->get()->first(); if (empty($balanser_link)) { return false; } $link = Mysql::getInstance()->from('ch_links')->where(array('id' => $balanser_link['link_id']))->get()->first(); if (empty($link)) { return false; } if ($status == 0) { $other_good_balanser_links = Mysql::getInstance()->from('ch_link_on_streamer')->where(array('link_id' => $link['id'], 'id!=' => $balanser_link_id, 'monitoring_status' => 1))->get()->all(); if (empty($other_good_balanser_links)) { Mysql::getInstance()->update('ch_links', array('status' => $status), array('id' => $link['id'])); } } else { Mysql::getInstance()->update('ch_links', array('status' => $status), array('id' => $link['id'])); } $ch_id = $link['ch_id']; } else { Mysql::getInstance()->update('ch_links', array('status' => $status), array('id' => $link_id)); $ch_id = (int) Mysql::getInstance()->from('ch_links')->where(array('id' => $link_id))->get()->first('ch_id'); } $channel = Mysql::getInstance()->from('itv')->where(array('id' => $ch_id))->get()->first(); if (empty($channel)) { return false; } $good_links = Mysql::getInstance()->from('ch_links')->where(array('ch_id' => $ch_id, 'status' => 1))->get()->all(); if (!empty($good_links) && $channel['monitoring_status'] == 0) { Mysql::getInstance()->update('itv', array('monitoring_status' => 1), array('id' => $ch_id)); if (Config::exist('administrator_email')) { $message = sprintf(_("Channel %s set to active because at least one of its URLs became available."), $channel['number'] . ' ' . $channel['name']); mail(Config::get('administrator_email'), 'Channels monitoring report: channel enabled', $message, "Content-type: text/html; charset=UTF-8\r\n"); } } else { if (empty($good_links) && $channel['monitoring_status'] == 1) { Mysql::getInstance()->update('itv', array('monitoring_status' => 0), array('id' => $ch_id)); if (Config::exist('administrator_email')) { $message = sprintf(_('Channel %s set to inactive because all its URLs are not available.'), $channel['number'] . ' ' . $channel['name']); mail(Config::get('administrator_email'), 'Channels monitoring report: channel disabled', $message, "Content-type: text/html; charset=UTF-8\r\n"); } } } return Mysql::getInstance()->update('itv', array('monitoring_status_updated' => 'NOW()'), array('id' => $ch_id))->result(); }
public static function getInfoById($id) { $movie_info = array('kinopoisk_id' => $id); $movie_url = 'http://www.kinopoisk.ru/film/' . $id . '/'; $movie_info['kinopoisk_url'] = $movie_url; $movie_info['cover'] = 'http://st.kinopoisk.ru/images/film/' . $id . '.jpg'; $cover_big_url = 'http://st.kinopoisk.ru/images/film_big/' . $id . '.jpg'; $big_cover_headers = get_headers($cover_big_url, 1); if ($big_cover_headers !== false) { if (strpos($big_cover_headers[0], '302') !== false && !empty($big_cover_headers['Location'])) { $movie_info['cover_big'] = $big_cover_headers['Location']; } else { $movie_info['cover_big'] = $cover_big_url; } } $ch = curl_init(); $curl_options = array(CURLOPT_URL => $movie_url, CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => array('Connection: keep-alive', 'Cache-Control: no-cache', 'Pragma: no-cache', 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.9 Safari/536.5', 'Accept: text/css,*/*;q=0.1', 'Accept-Encoding: deflate,sdch', 'Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4', 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.3')); if (Config::exist('http_proxy')) { $curl_options[CURLOPT_PROXY] = str_replace('tcp://', '', Config::get('http_proxy')); if (Config::exist('http_proxy_login') && Config::exist('http_proxy_password')) { $curl_options[CURLOPT_PROXYUSERPWD] = Config::get('http_proxy_login') . ":" . Config::get('http_proxy_password'); } } curl_setopt_array($ch, $curl_options); $page = curl_exec($ch); curl_close($ch); //var_dump($page); libxml_use_internal_errors(true); $dom = new DomDocument(); $dom->loadHTML($page); libxml_use_internal_errors(false); $xpath = new DomXPath($dom); // Translated name $node_list = $xpath->query('//*[@id="headerFilm"]/h1'); if ($node_list !== false && $node_list->length != 0) { $movie_info['name'] = self::getNodeText($node_list->item(0)); } if (empty($movie_info['name'])) { throw new KinopoiskException("Movie name in '" . $movie_url . "' not found", $page); } // Original name $node_list = $xpath->query(".//*[@id='headerFilm']/span"); if ($node_list !== false && $node_list->length != 0) { $movie_info['o_name'] = self::getNodeText($node_list->item(0)); } if (empty($movie_info['o_name'])) { $movie_info['o_name'] = $movie_info['name']; } // Year $node_list = $xpath->query('//*[@id="infoTable"]/table/tr[1]/td[2]/div/a'); if ($node_list !== false && $node_list->length != 0) { $movie_info['year'] = self::getNodeText($node_list->item(0)); } // Country $node_list = $xpath->query('//*[@id="infoTable"]/table/tr[2]/td[2]/div'); if ($node_list !== false && $node_list->length != 0) { $movie_info['country'] = self::getNodeText($node_list->item(0)); } // Duration $node_list = $xpath->query('//*[@id="runtime"]'); if ($node_list !== false && $node_list->length != 0) { $movie_info['duration'] = (int) self::getNodeText($node_list->item(0)); } // Director $node_list = $xpath->query('//*[@id="infoTable"]/table/tr[4]/td[2]/a'); if ($node_list !== false && $node_list->length != 0) { $movie_info['director'] = self::getNodeText($node_list->item(0)); } // Actors $node_list = $xpath->query('//*[@id="actorList"]/ul[1]/li'); if ($node_list !== false && $node_list->length != 0) { $actors = array(); foreach ($node_list as $node) { $actors[] = self::getNodeText($node); } if ($actors[count($actors) - 1] == '...') { unset($actors[count($actors) - 1]); } $movie_info['actors'] = implode(", ", $actors); } // Description //$node_list = $xpath->query('//*[@id="syn"]/tr[1]/td/table/tr[1]/td'); $node_list = $xpath->query('//div[@itemprop="description"]'); if ($node_list !== false && $node_list->length != 0) { $movie_info['description'] = self::getNodeText($node_list->item(0)); } // Age limit $node_list = $xpath->query('//div[contains(@class, "ageLimit")]'); if ($node_list !== false && $node_list->length != 0) { $class = $node_list->item(0)->attributes->getNamedItem('class')->nodeValue; $movie_info['age'] = substr($class, strrpos($class, 'age') + 3); if ($movie_info['age']) { $movie_info['age'] .= '+'; } } // Rating MPAA $node_list = $xpath->query('//td[contains(@class, "rate_")]'); if ($node_list !== false && $node_list->length != 0) { $class = $node_list->item(0)->attributes->getNamedItem('class')->nodeValue; $movie_info['rating_mpaa'] = strtoupper(substr($class, 5)); if ($movie_info['rating_mpaa'] == 'PG13') { $movie_info['rating_mpaa'] = 'PG-13'; } elseif ($movie_info['rating_mpaa'] == 'NC17') { $movie_info['rating_mpaa'] = 'NC-17'; } } // Kinopoisk rating $node_list = $xpath->query('//*[@id="block_rating"]/div[1]/div[1]/a/span[1]'); if ($node_list !== false && $node_list->length != 0) { $movie_info['rating_kinopoisk'] = self::getNodeText($node_list->item(0)); } // Kinopoisk rating count $node_list = $xpath->query('//*[@id="block_rating"]/div[1]/div[1]/a/span[2]'); if ($node_list !== false && $node_list->length != 0) { $movie_info['rating_count_kinopoisk'] = self::getNodeText($node_list->item(0)); } // IMDB rating $node_list = $xpath->query('//*[@id="block_rating"]/div[1]/div[2]'); if ($node_list !== false && $node_list->length != 0) { $imdb_raw = self::getNodeText($node_list->item(0)); if (preg_match("/IMDb: (.*) \\((.*)\\)/", $imdb_raw, $match)) { $movie_info['rating_imdb'] = $match[1]; $movie_info['rating_count_imdb'] = $match[2]; } } return $movie_info; }
public static function getInfoByName($orig_name) { if (empty($orig_name)) { return false; } $ch = curl_init(); if ($ch === false) { throw new KinopoiskException("Curl initialization error", curl_error($ch)); } $orig_name = iconv("utf-8", "windows-1251", $orig_name); $orig_name = urlencode($orig_name); $search_url = 'http://www.kinopoisk.ru/index.php?level=7&from=forma&result=adv&m_act[from]=forma&m_act[what]=content&m_act[find]=' . $orig_name . '&m_act[content_find]=film,serial&first=yes'; $curl_options = array(CURLOPT_URL => $search_url, CURLOPT_HEADER => 1, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => array('Connection: keep-alive', 'Cache-Control: no-cache', 'Pragma: no-cache', 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.9 Safari/536.5', 'Accept: text/css,*/*;q=0.1', 'Accept-Encoding: gzip,deflate,sdch', 'Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4', 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.3')); if (Config::exist('http_proxy')) { $curl_options[CURLOPT_PROXY] = str_replace('tcp://', '', Config::get('http_proxy')); if (Config::exist('http_proxy_login') && Config::exist('http_proxy_password')) { $curl_options[CURLOPT_PROXYUSERPWD] = Config::get('http_proxy_login') . ":" . Config::get('http_proxy_password'); } } curl_setopt_array($ch, $curl_options); $response = curl_exec($ch); curl_close($ch); if ($response === false) { throw new KinopoiskException("Curl exec failure", curl_error($ch)); } if (preg_match("/Location: ([^\\s]*)/", $response, $match)) { $location = $match[1]; } if (empty($location)) { throw new KinopoiskException("Empty location header", $response); } if (strpos($location, 'http') === 0) { throw new KinopoiskException("Wrong location header. Location: ('" . $location . "')", $response); } if (preg_match("/\\/([\\d]*)\\/\$/", $location, $match)) { $movie_id = $match[1]; } else { throw new KinopoiskException("Location does not contain movie id. Location: ('" . $location . "')", $response); } return self::getInfoById($movie_id); }
public static function getInfoByName($orig_name) { if (empty($orig_name)) { return false; } $ch = curl_init(); if ($ch === false) { throw new tmdbException("Curl initialization error", curl_error($ch)); } $orig_name = iconv("utf-8", "windows-1251", $orig_name); $orig_name = urlencode($orig_name); $lang = self::getLanguage(); $search_url = 'http://api.themoviedb.org/3/search/movie?query=' . $orig_name . '&api_key=' . Config::get('tmdb_api_key') . "&language={$lang}&include_image_language={$lang}"; $curl_options = array(CURLOPT_URL => $search_url, CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => array('Connection: keep-alive', 'Cache-Control: no-cache', 'Pragma: no-cache', 'Accept: application/json')); if (Config::exist('http_proxy')) { $curl_options[CURLOPT_PROXY] = str_replace('tcp://', '', Config::get('http_proxy')); if (Config::exist('http_proxy_login') && Config::exist('http_proxy_password')) { $curl_options[CURLOPT_PROXYUSERPWD] = Config::get('http_proxy_login') . ":" . Config::get('http_proxy_password'); } } curl_setopt_array($ch, $curl_options); $response = curl_exec($ch); curl_close($ch); if ($response === false) { throw new tmdbException("Curl exec failure", curl_error($ch)); } $results = json_decode($response, true); if ((!array_key_exists('status_code', $results) || $results['status_code'] == 1) && !empty($results['results'])) { $movie_id = $results['results'][0]['id']; return self::getInfoById($movie_id); } return $results; }
/** * Main claim method. * * @param string $media_type */ protected function setClaimGlobal($media_type) { $id = intval($_REQUEST['id']); $type = $_REQUEST['real_type']; $this->db->insert('media_claims_log', array('media_type' => $media_type, 'media_id' => $id, 'type' => $type, 'uid' => $this->stb->id, 'added' => 'NOW()')); $total_media_claims = $this->db->from('media_claims')->where(array('media_type' => $media_type, 'media_id' => $id))->get()->first(); $sound_counter = 0; $video_counter = 0; $no_epg_counter = 0; $wrong_epg_counter = 0; if ($type == 'video') { $video_counter++; } else { if ($type == 'sound') { $sound_counter++; } else { if ($type == 'no_epg') { $no_epg_counter++; } else { if ($type == 'wrong_epg') { $wrong_epg_counter++; } } } } if (!empty($total_media_claims)) { $this->db->update('media_claims', array('sound_counter' => $total_media_claims['sound_counter'] + $sound_counter, 'video_counter' => $total_media_claims['video_counter'] + $video_counter, 'no_epg' => $total_media_claims['no_epg'] + $no_epg_counter, 'wrong_epg' => $total_media_claims['wrong_epg'] + $wrong_epg_counter), array('media_type' => $media_type, 'media_id' => $id)); } else { $this->db->insert('media_claims', array('sound_counter' => $sound_counter, 'video_counter' => $video_counter, 'no_epg' => $no_epg_counter, 'wrong_epg' => $wrong_epg_counter, 'media_type' => $media_type, 'media_id' => $id)); } $total_daily_claims = $this->db->from('daily_media_claims')->where(array('date' => 'CURDATE()'))->get()->first(); $media_name = 'undefined'; if ($media_type == 'itv') { $media = Itv::getById($id); if (!empty($media['name'])) { $media_name = $media['name']; } } elseif ($media_type == 'vclub') { $media = Video::getById($id); if (!empty($media['name'])) { $media_name = $media['name']; } } elseif ($media_type == 'karaoke') { $media = Karaoke::getById($id); if (!empty($media['name'])) { $media_name = $media['name']; } } if (Config::exist('administrator_email')) { $message = sprintf(_("New claim on %s - %s (%s, id: %s). From %s"), $media_type, $type, $media_name, $id, $this->stb->mac); mail(Config::get('administrator_email'), 'New claim on ' . $media_type . ' - ' . $type, $message, "Content-type: text/html; charset=UTF-8\r\n"); } if (!empty($total_daily_claims)) { return $this->db->update('daily_media_claims', array($media_type . '_sound' => $total_daily_claims[$media_type . '_sound'] + $sound_counter, $media_type . '_video' => $total_daily_claims[$media_type . '_video'] + $video_counter, 'no_epg' => $total_daily_claims['no_epg'] + $no_epg_counter, 'wrong_epg' => $total_daily_claims['wrong_epg'] + $wrong_epg_counter), array('date' => 'CURDATE()'))->result(); } else { return $this->db->insert('daily_media_claims', array($media_type . '_sound' => $sound_counter, $media_type . '_video' => $video_counter, 'no_epg' => $no_epg_counter, 'wrong_epg' => $wrong_epg_counter, 'date' => 'CURDATE()'))->insert_id(); } }
public static function setChannelLinkStatus($link_id, $status) { if (empty($link_id) || !is_numeric($link_id)) { return false; } $channel = Mysql::getInstance()->from('radio')->where(array('id' => $link_id))->get()->first(); if (empty($channel)) { return false; } if ((int) $status != (int) $channel['monitoring_status']) { if ((int) $status == 0) { if (Config::exist('administrator_email')) { $message = sprintf(_("Radio-channel %s set to active because its URL became available."), $channel['number'] . ' ' . $channel['name']); mail(Config::get('administrator_email'), 'Radio-channels monitoring report: channel enabled', $message, "Content-type: text/html; charset=UTF-8\r\n"); } } else { if (Config::exist('administrator_email')) { $message = sprintf(_('Radio-channel %s set to inactive because its URL are not available.'), $channel['number'] . ' ' . $channel['name']); mail(Config::get('administrator_email'), 'Radio-channels monitoring report: channel disabled', $message, "Content-type: text/html; charset=UTF-8\r\n"); } } Mysql::getInstance()->update('radio', array('monitoring_status' => $status), array('id' => $link_id))->result(); } return Mysql::getInstance()->update('radio', array('monitoring_status_updated' => 'NOW()'), array('id' => $link_id))->result(); }
<?php $page = 'testimonios'; $page2 = 'nav-testimonios'; require "template/header.php"; ?> <div class="container"> <div class="row"> <?php require "template/nav_testimonios.php"; ?> <?php if (Utils::checkPost("add")) { if (Config::exist("bgtestimonios")) { $edit = array("value" => File::upload("background")); $confirm = Config::edit($edit, array("name", "=", "bgtestimonios")); } else { $new = array("name" => "bgtestimonios", "value" => File::upload("background")); $confirm = Config::add($new); } } ?> <div class="grid col-9"> <div class="row"> <form action="" method="post" enctype="multipart/form-data" > <p><?php if (isset($confirm) && $confirm > 0) { echo "Modificación exitosa"; }
public static function create($data) { if (!empty($data['mac'])) { $user = Stb::getUidByMacs($data['mac']); if (!empty($user)) { throw new ErrorException('Stb already exists'); } } $data['created'] = 'NOW()'; if (Config::exist('default_stb_status') && !isset($data['status'])) { $data['status'] = intval(!Config::get('default_stb_status')); } try { OssWrapper::getWrapper()->registerSTB(Stb::getInstance()->mac, isset($_REQUEST['sn']) ? $_REQUEST['sn'] : '', isset($_REQUEST['stb_type']) ? $_REQUEST['stb_type'] : ''); } catch (OssException $e) { self::logOssError($e); } $data['serial_number'] = isset($_REQUEST['sn']) ? $_REQUEST['sn'] : ''; $user_id = Mysql::getInstance()->insert('users', $data)->insert_id(); if ($user_id && !empty($data['password'])) { $update_data = array('password' => md5(md5($data['password']) . $user_id)); if (empty($data['login'])) { $update_data['login'] = $user_id; } Mysql::getInstance()->update('users', $update_data, array('id' => $user_id)); } self::$just_created = true; return $user_id; }
/** * Trying to create a link of media file in stb home directory * * @param int $media_id * @param int $series_num * @param bool $from_cache * @param string $forced_storage * @return array contains path to media or error */ public function play($media_id, $series_num = 0, $from_cache = true, $forced_storage = "") { $this->initMedia($media_id); $res = array('id' => 0, 'cmd' => '', 'storage_id' => '', 'load' => '', 'error' => ''); if (!empty($this->rtsp_url)) { $res['id'] = $this->media_id; $res['cmd'] = $this->rtsp_url; return $res; } if (!empty($forced_storage)) { $from_cache = false; } $good_storages = $this->getAllGoodStoragesForMedia($this->media_id, !$from_cache); if (!empty($forced_storage)) { if (array_key_exists($forced_storage, $good_storages)) { $good_storages = array($forced_storage => $good_storages[$forced_storage]); } else { $good_storages = array(); } } $default_error = 'nothing_to_play'; foreach ($good_storages as $name => $storage) { if ($storage['load'] < 1) { if ($series_num > 0) { $file = $storage['series_file'][array_search($series_num, $storage['series'])]; } else { $file = $storage['first_media']; } preg_match("/([\\S\\s]+)\\.([\\S]+)\$/", $file, $arr); $ext = $arr[2]; //var_dump($this->storages[$name]); if ($this->storages[$name]['external'] == 0) { try { //$this->clients[$name]->createLink($this->stb->mac, $this->media_name, $file, $this->media_id, (($this->media_protocol == 'http') ? 'http_' : '') . $this->media_type); $this->clients[$name]->resource($this->media_type)->create(array('media_name' => $this->getMediaPath($file), 'media_id' => $this->media_id, 'proto' => $this->media_protocol)); } catch (Exception $exception) { $default_error = 'link_fault'; $this->parseException($exception); if ($exception instanceof RESTClientException && !$exception instanceof RESTClientRemoteError) { $storage = new Storage(array('name' => $name)); $storage->markAsFailed($exception->getMessage()); continue; } if ($this->from_cache) { return $this->play($media_id, $series_num, false); } else { continue; } } if ($this->media_protocol == 'http' || $this->media_type == 'remote_pvr') { if (Config::exist('nfs_proxy')) { $base_path = 'http://' . Config::get('nfs_proxy') . '/media/' . $name . '/' . RESTClient::$from . '/'; } elseif (!empty($this->storages[$name]['wowza_server'])) { $base_path = 'http://' . $this->storages[$name]['storage_ip'] . ':' . $this->storages[$name]['wowza_port'] . '/' . $this->storages[$name]['wowza_app'] . '/_definst_/mp4:' . $this->getMediaPath($file) . '/'; } else { $base_path = 'http://' . $this->storages[$name]['storage_ip'] . '/media/' . $name . '/' . RESTClient::$from . '/'; } } else { $base_path = '/media/' . $name . '/'; } if (strpos($base_path, 'http://') !== false) { $res['cmd'] = 'ffmpeg '; } else { $res['cmd'] = 'auto '; } if (empty($this->storages[$name]['wowza_server'])) { $res['cmd'] .= $base_path . $this->media_id . '.' . $ext; // nginx secure link $secret = Config::get('nginx_secure_link_secret'); if (preg_match('/http(s)?:\\/\\/([^\\/]+)\\/(.+)$/', $res['cmd'], $match)) { $uri = '/' . $match[3]; } else { $uri = ''; } $remote_addr = $this->stb->ip; $expire = time() + Config::getSafe('vclub_nginx_tmp_link_ttl', 7200); $hash = base64_encode(md5($secret . $uri . $remote_addr . $expire, true)); $hash = strtr($hash, '+/', '-_'); $hash = str_replace('=', '', $hash); $res['cmd'] .= '?st=' . $hash . '&e=' . $expire; } else { $res['cmd'] .= $base_path . 'playlist.m3u8?token=' . $this->createTemporaryLink("1"); } $file_info = array_filter($storage['files'], function ($info) use($file) { return $info['name'] == $file; }); $file_info = array_values($file_info); if (!empty($file_info) && !empty($file_info[0]['subtitles'])) { $ip = $this->stb->ip; $res['subtitles'] = array_map(function ($subtitle) use($base_path, $file, $ip) { $file_base = substr($file, 0, strrpos($file, '.')); $lang = substr($subtitle, strlen($file_base), strrpos($subtitle, '.') - strlen($file_base)); if ($lang && ($lang[0] == '_' || $lang[0] == '.')) { $lang = substr($lang, 1); } $file = $base_path . $subtitle; // nginx secure link $secret = Config::get('nginx_secure_link_secret'); if (preg_match('/http(s)?:\\/\\/([^\\/]+)\\/(.+)$/', $file, $match)) { $uri = '/' . $match[3]; } else { $uri = ''; } $remote_addr = $ip; $expire = time() + Config::getSafe('vclub_nginx_tmp_link_ttl', 7200); $hash = base64_encode(md5($secret . $uri . $remote_addr . $expire, true)); $hash = strtr($hash, '+/', '-_'); $hash = str_replace('=', '', $hash); return array('file' => $file . '?st=' . $hash . '&e=' . $expire, 'lang' => $lang); }, $file_info[0]['subtitles']); } } else { $redirect_url = '/media/' . $this->getMediaPath($file); $link_result = $this->createTemporaryLink($redirect_url); var_dump($redirect_url, $link_result); if (!$link_result) { $default_error = 'link_fault'; if ($this->from_cache) { return $this->play($media_id, $series_num, false); } else { continue; } } else { $res['cmd'] = 'ffmpeg http://' . $this->storages[$name]['storage_ip'] . '/get/' . $link_result; $res['external'] = 1; } } //$res['cmd'] = 'auto /media/'.$name.'/'.$this->media_id.'.'.$ext; $res['id'] = $this->media_id; $res['load'] = $storage['load']; $res['storage_id'] = $this->storages[$name]['id']; $res['from_cache'] = $this->from_cache; return $res; } else { $this->incrementStorageDeny($name); $res['error'] = 'limit'; return $res; } } if ($this->from_cache) { return $this->play($media_id, $series_num, false); } else { $res['error'] = $default_error; 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) { $_COOKIE['mac'] = $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) { $request->setUsername($user->getLogin()); } } if (\Config::exist('auth_url') && strpos(\Config::get('auth_url'), 'auth_every_load') && empty($username) && empty($password)) { return false; } if (!$user || !empty($username) && !empty($password) && \Config::getSafe('oss_url', '')) { $user = \User::authorizeFromOss($username, $password, $mac); } if (!$user) { return false; } $possible_user = $user->getProfile(); if (!$password && $mac) { $request->setUsername($user->getLogin()); } if (!$password && $mac || \Config::exist('auth_url') && $username && $password) { $verified_user = $possible_user; } elseif (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); }
if (!defined("PATH_SEPARATOR")) { define("PATH_SEPARATOR", getenv("COMSPEC") ? ";" : ":"); } define('PROJECT_PATH', dirname(__FILE__)); ini_set("include_path", ini_get("include_path") . PATH_SEPARATOR . PROJECT_PATH); /*function __autoload($class_name) { $class = PROJECT_PATH.'/lib/'.strtolower($class_name).'.class.php'; if (!file_exists($class)){ throw new Exception('Class file for "'.$class_name.'" not found'); } require $class; }*/ require "lib/splclassloader.class.php"; $classLoader = new SplClassLoader(null, PROJECT_PATH . DIRECTORY_SEPARATOR . 'lib'); $classLoader->setFileExtension('.class.php'); $classLoader->setExcludeNs('Stalker\\Lib'); $classLoader->register(); if (Config::exist('default_timezone')) { date_default_timezone_set(Config::get('default_timezone')); } if (Config::exist('http_proxy')) { $default_context = array('http' => array('proxy' => Config::get('http_proxy'), 'request_fulluri' => true)); if (Config::exist('http_proxy_login') && Config::exist('http_proxy_password')) { $default_context['http']['header'] = "Proxy-Authorization: Basic " . base64_encode(Config::get('http_proxy_login') . ":" . Config::get('http_proxy_password')) . "\r\n"; } stream_context_set_default($default_context); libxml_set_streams_context(stream_context_create($default_context)); }