示例#1
0
    preg_match("/(\\S+)\\s(\\S+):\\/\\/(\\d+).(\\d+).(\\d+).(\\d+):(\\d+)/", $addr, $tmp_arr);
    $img_str = '/iptv/mpg/' . $tmp_arr[6] . '_' . $tmp_arr[7] . '.mpg';
    return $img_str;
}
$tv_archive = new TvArchive();
$storages = Mysql::getInstance()->from('storages')->where(array('status' => 1, 'for_records' => 1, 'wowza_server' => 0))->get()->all();
$stream_servers = StreamServer::getAll();
$selected_storages = $selected_pvr_storages = array();
if (!empty($_GET['id'])) {
    $tasks = TvArchive::getTasksByChannelId((int) $_GET['id']);
    if (!empty($tasks)) {
        $selected_storages = array_map(function ($storage) {
            return $storage['storage_name'];
        }, $tasks);
    }
    $selected_pvr_storages = array_keys(RemotePvr::getStoragesForChannel((int) $_GET['id']));
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">

body {
    font-family: Arial, Helvetica, sans-serif;
    font-weight: bold;
}
td {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    text-decoration: none;
 public function edit_channel()
 {
     if ($no_auth = $this->checkAuth()) {
         return $no_auth;
     }
     if ($this->method == 'GET' && (empty($this->data['id']) || !is_numeric($this->data['id']))) {
         return $this->app->redirect('add-channel');
     }
     $id = $this->method == 'POST' && !empty($this->postData['form']['id']) ? $this->postData['form']['id'] : $this->data['id'];
     $getAllGenres = $this->db->getAllGenres();
     $this->app['allGenres'] = $this->setLocalization($getAllGenres, 'title');
     $this->app['channelEdit'] = TRUE;
     $this->oneChannel = $this->db->getChannelById($id);
     $this->oneChannel = array_merge($this->oneChannel, $this->getStorages($id));
     $this->oneChannel['pvr_storage_names'] = array_keys(\RemotePvr::getStoragesForChannel($id));
     settype($this->oneChannel['enable_tv_archive'], 'boolean');
     settype($this->oneChannel['wowza_dvr'], 'boolean');
     settype($this->oneChannel['flussonic_dvr'], 'boolean');
     settype($this->oneChannel['allow_pvr'], 'boolean');
     settype($this->oneChannel['censored'], 'boolean');
     settype($this->oneChannel['allow_local_timeshift'], 'boolean');
     settype($this->oneChannel['allow_local_pvr'], 'boolean');
     settype($this->oneChannel['base_ch'], 'boolean');
     $this->oneChannel['logo'] = $this->getLogoUriById(FALSE, $this->oneChannel);
     $this->setChannelLinks();
     $this->app['streamServers'] = $this->streamServers;
     $this->app['error_local'] = array();
     $form = $this->buildForm($this->oneChannel);
     if ($this->saveChannelData($form)) {
         return $this->app->redirect('iptv-list');
     }
     $this->app['form'] = $form->createView();
     $this->app['breadcrumbs']->addItem("'{$this->oneChannel['name']}'");
     $this->app['editChannelName'] = $this->oneChannel['name'];
     return $this->app['twig']->render('TvChannels_add_channel.twig');
 }
 private function createFileRecord($user_rec_id)
 {
     $user_rec = Mysql::getInstance()->from('users_rec')->where(array('id' => $user_rec_id))->get()->first();
     if (empty($user_rec)) {
         throw new nPVRServerError();
     }
     $channel = Mysql::getInstance()->from('itv')->where(array('id' => $user_rec['ch_id']))->get()->first();
     if (empty($channel)) {
         throw new nPVRChannelNotFoundError();
     }
     $rec_file_id = Mysql::getInstance()->insert('rec_files', array('ch_id' => $user_rec['ch_id'], 't_start' => 'NOW()', 'atrack' => $user_rec['atrack'], 'vtrack' => $user_rec['vtrack']))->insert_id();
     $allowed_storages = array_keys(RemotePvr::getStoragesForChannel($user_rec['ch_id']));
     foreach ($this->storages as $name => $storage) {
         if (!in_array($name, $allowed_storages)) {
             continue;
         }
         if ($storage['load'] < 1) {
             try {
                 $file_name = $this->clients[$name]->resource('recorder')->create(array('url' => $channel['mc_cmd'], 'rec_id' => $rec_file_id, 'start_delay' => strtotime($user_rec['t_start']) - time(), 'duration' => $user_rec['length']));
             } catch (Exception $exception) {
                 try {
                     //stop recording just in case
                     $this->clients[$name]->resource('recorder')->ids($rec_file_id)->update();
                 } catch (Exception $exception) {
                     $this->parseException($exception);
                 }
                 $this->deleteUserRecord($user_rec_id);
                 $this->deleteFileRecord($rec_file_id);
                 $this->parseException($exception);
             }
         }
         if (!empty($file_name)) {
             break;
         }
     }
     if (empty($file_name)) {
         Mysql::getInstance()->update('users_rec', array('ended' => 1), array('id' => $user_rec_id));
         Mysql::getInstance()->update('rec_files', array('ended' => 1), array('id' => $rec_file_id));
         throw new nPVRServerError();
     }
     Mysql::getInstance()->update('rec_files', array('storage_name' => $name, 'file_name' => $file_name), array('id' => $rec_file_id));
     Mysql::getInstance()->update('users_rec', array('file_id' => $rec_file_id, 'started' => strtotime($user_rec['t_start']) - time() > 0 ? 0 : 1), array('id' => $user_rec_id));
     return $user_rec_id;
 }