Exemplo n.º 1
0
 /**
  * 显示录播节目单
  */
 function show()
 {
     #####节点权限认证需要将节点数据放在nodes=>标志=>节点id=>节点所有父级节点
     $nodes = array();
     if (intval($this->input['channel_id']) > 0) {
         $nodes['nodes'][intval($this->input['channel_id'])] = intval($this->input['channel_id']);
         $this->verify_content_prms($nodes);
     }
     #####
     $condition = $this->get_condition();
     if ($this->user['group_type'] > MAX_ADMIN_TYPE) {
         if ($this->user['prms']['app_prms'][APP_UNIQUEID]['nodes']) {
             $condition .= " AND channel_id IN (" . implode(',', $this->user['prms']['app_prms'][APP_UNIQUEID]['nodes']) . ")";
         } else {
             $this->errorOutput(NO_PRIVILEGE);
         }
     }
     $offset = $this->input['offset'] ? $this->input['offset'] : 0;
     $count = $this->input['count'] ? intval($this->input['count']) : 20;
     $data_limit = " LIMIT " . $offset . " , " . $count;
     $info = $this->obj->show($condition, $data_limit, trim($this->input['dates']));
     if (!empty($info)) {
         include_once ROOT_PATH . 'lib/class/program.class.php';
         $program_plan = new program();
         foreach ($info as $key => $value) {
             $spa = '';
             $start_time = strtotime($value['dates'] . " " . $value['start_time']);
             $end_time = strtotime($value['dates'] . " " . $value['start_time']) + $value['toff'];
             $value['title'] = $value['title'] ? $value['title'] : (trim($program_plan->get_program_plan($value['channel_id'], $start_time, $end_time)) ? $program_plan->get_program_plan($value['channel_id'], $start_time, $end_time) : '精彩节目');
             $value['source'] = $value['program_id'] ? '节目单' : ($value['plan_id'] ? '节目单计划' : '计划收录');
             //hg_pre($value);
             $this->addItem($value);
         }
         $this->output();
     }
 }
Exemplo n.º 2
0
 /**
  * 显示录播节目单
  */
 function show()
 {
     $sql = "SELECT * FROM " . DB_PREFIX . "server_config WHERE 1 AND state=1";
     $q = $this->db->query($sql);
     $server_config = array();
     while ($row = $this->db->fetch_array($q)) {
         $server_config[$row['id']] = $row;
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "program_record WHERE is_record=0 and start_time < " . (strtotime(date('Y-m-d', TIMENOW)) + 86399);
     $record_info = $channel_info = $item_info = array();
     $q = $this->db->query($sql);
     while ($row = $this->db->fetch_array($q)) {
         $channel_info[$row['channel_id']] = $row['channel_id'];
         $item_info[$row['item']] = $row['item'];
         $record_info[] = $row;
     }
     if (empty($record_info)) {
         return '';
     }
     $channel = array();
     if (!empty($channel_info)) {
         $channel_ids = implode(',', $channel_info);
         include_once ROOT_PATH . 'lib/class/live.class.php';
         $newLive = new live();
         $channel_tmp = $newLive->getChannelInfoById(array('id' => $channel_ids, 'is_stream' => 1, 'live' => 1, 'is_sys' => -1, 'fetch_live' => 1));
         foreach ($channel_tmp as $k => $v) {
             $channel[$v['id']] = $v;
         }
         if (empty($channel)) {
             return '';
         }
     }
     if (!empty($item_info)) {
         include_once ROOT_PATH . 'lib/class/livmedia.class.php';
         $livmedia = new livmedia();
         $item_info = $livmedia->getAutoItem();
     }
     include_once ROOT_PATH . 'lib/class/program.class.php';
     $program_plan = new program();
     foreach ($record_info as $k => $row) {
         if (empty($server_config[$row['server_id']])) {
             continue;
         }
         $check_server = $this->checkServer($server_config[$row['server_id']]['host'] . ':' . $server_config[$row['server_id']]['port'] . $server_config[$row['server_id']]['dir']);
         if (!$check_server) {
             continue;
         }
         $channel_tmp = $channel[$row['channel_id']];
         $row['code'] = $channel_tmp['code'];
         $row['name'] = $channel_tmp['name'];
         $row['is_audio'] = $channel_tmp['is_audio'];
         $row['save_time'] = $channel_tmp['time_shift'];
         $row['main_stream_name'] = $channel_tmp['main_stream_name'];
         $row['stream_state'] = $channel_tmp['status'];
         $row['record_time'] = $channel_tmp['record_time'];
         $row['stream_id'] = $channel_tmp['stream_id'];
         $row['sort_name'] = $row['item'] > 0 ? $item_info[$row['item']]['name'] : '';
         $return = array();
         if (!$row['channel_id']) {
             continue;
         }
         $ret = $log_data = array();
         $ret['id'] = $log_data['id'] = $row['id'];
         $ret['channel_id'] = $log_data['channel_id'] = $row['channel_id'];
         $ret['name'] = rawurlencode($row['name']);
         $ret['startTime'] = date('YmdHis', $row['start_time'] + $row['record_time'] - 1);
         $row['toff'] = $row['toff'] + 2;
         $program = $row['title'] ? $row['title'] : trim($program_plan->get_program_plan($ret['channel_id'], $ret['starttime'], $ret['endtime']));
         $ret['title'] = base64_encode(json_encode(trim($program ? $program : '精彩节目')));
         $log_data['title'] = rawurlencode(trim($program ? $program : '精彩节目'));
         $log_data['start_time'] = $row['start_time'];
         $log_data['toff'] = $row['toff'];
         $log_data['week_day'] = $row['week_day'];
         $log_data['item'] = $row['item'];
         $log_data['columnid'] = $row['columnid'];
         $log_data['column_name'] = $row['column_name'];
         $log_data['ip'] = $row['ip'];
         if (empty($channel_tmp['record_stream'])) {
             continue;
         }
         $ret['stream'] = $channel_tmp['record_uri'] ? $channel_tmp['record_uri'] : $channel_tmp['record_stream'][0]['output_url_rtmp'];
         $callback = $this->settings['App_program_record']['protocol'] . $this->settings['App_program_record']['host'] . '/' . $this->settings['App_program_record']['dir'] . 'admin/record_callback.php';
         $ret['vod_sort_id'] = $row['item'];
         $ret['week_flag'] = $row['week_day'] ? 1 : 0;
         $ret['column_id'] = $row['columnid'] ? $row['columnid'] : 0;
         $ret['audit_auto'] = $row['audit_auto'] ? 2 : 0;
         $ret['exit_status'] = $row['audit_auto'];
         $ret['save_time'] = $row['save_time'];
         //$ret['delay_time'] = $row['live_delay'] * 60;
         //$ret['source'] = $row['channel_id'];
         $ret['is_allow'] = $row['is_mark'];
         $ret['is_audio'] = $row['is_audio'];
         $ret['extend'] = base64_encode(json_encode(array('_user_id' => $row['user_id'], '_user_name' => $row['user_name'], 'org_id' => $row['org_id'], 'force_codec' => $row['force_codec'], 'source' => $row['name'], 'callback_extra' => $row['callback_extra'])));
         if (!$row['stream_state']) {
             $ret = array('errortext' => '视频流未开启!');
             $str = 'ID-' . $row['id'] . ($ret['errortext'] ? $ret['errortext'] : '录制成功');
             $this->tips($str, TIMENOW);
         } else {
             switch ($row['is_record']) {
                 case 0:
                     //录制未进行提交
                     $this->curl = new curl($server_config[$row['server_id']]['host'] . ':' . $server_config[$row['server_id']]['port'], $server_config[$row['server_id']]['dir']);
                     $this->curl->setSubmitType('get');
                     $this->curl->initPostData();
                     $this->curl->addRequestData('action', 'INSERT');
                     $this->curl->addRequestData('url', $ret['stream']);
                     $this->curl->addRequestData('callback', $callback);
                     //urlencode
                     //$this->curl->addRequestData('startTime', $ret['starttime']-1);
                     $this->curl->addRequestData('duration', $row['toff']);
                     $this->curl->addRequestData('uploadFile', '0');
                     $this->curl->addRequestData('app', 'live');
                     $this->curl->addRequestData('streamname', $channel_tmp['code'] . '_' . $channel_tmp['main_stream_name']);
                     $this->curl->addRequestData('html', 1);
                     $this->curl->addRequestData('appid', $this->input['appid']);
                     $this->curl->addRequestData('appkey', $this->input['appkey']);
                     foreach ($ret as $k => $v) {
                         $this->curl->addRequestData($k, $v);
                     }
                     $ret = array();
                     $record_xml = $this->curl->request('');
                     $record_array = xml2Array($record_xml);
                     if (is_array($record_array)) {
                         $ret['id'] = $record_array['record']['id'] ? $record_array['record']['id'] : 0;
                         if (!$record_array['result']) {
                             $ret['errortext'] = '录制超时,重复提交';
                             //报错
                             $ret['isError'] = 1;
                             $ret['id'] = -1;
                         } else {
                             $ret['errortext'] = '等待录制';
                             $ret['isError'] = 0;
                         }
                     } else {
                         $ret['id'] = 0;
                         $ret['errortext'] = '录制失败,无内容!';
                         $ret['isError'] = 1;
                     }
                     $is_record = $ret['id'] ? 1 : 0;
                     $conid = $this->add_queue($row['id']);
                     if (!$ret['isError']) {
                         $sql_update = "UPDATE " . DB_PREFIX . "program_record SET is_out=0,conid=" . $conid . ",is_record=" . $is_record . " WHERE id=" . $row['id'];
                         $this->db->query($sql_update);
                         $log_data['text'] = $ret['errortext'];
                         $log_data['state'] = $ret['isError'] ? 2 : 0;
                         $log_id = $this->record->addLogs($log_data);
                         $this->update_queue($conid, $log_id);
                     } else {
                         $week_day = unserialize($row['week_day']);
                         $select_curl = new curl($server_config[$row['server_id']]['host'] . ':' . $server_config[$row['server_id']]['port'], $server_config[$row['server_id']]['dir']);
                         $select_curl->setSubmitType('get');
                         $select_curl->initPostData();
                         $select_curl->addRequestData('action', 'SELECT');
                         $select_curl->addRequestData('id', $row['id']);
                         $select_record = $this->curl->request('');
                         $select_array = xml2Array($select_record);
                         if (is_array($select_array)) {
                             if (!$select_array['result']) {
                                 if (is_array($week_day) && $week_day) {
                                     $week_now = date('N', $row['start_time']);
                                     $new_arr = array_flip($week_day);
                                     if (count($week_day) > $new_arr[$week_now] + 1) {
                                         $ks = $new_arr[$week_now] + 1;
                                     } else {
                                         $ks = 0;
                                     }
                                     $week_day = array_flip($new_arr);
                                     $next_week = $week_day[$ks] - $week_now > 0 ? $week_day[$ks] - $week_now : $week_day[$ks] - $week_now + 7;
                                     $start_time = $row['start_time'] + $next_week * 86400;
                                     $sql_update = "UPDATE " . DB_PREFIX . "program_record SET conid=0,is_record=0,start_time=" . $start_time . " WHERE id=" . $row['id'];
                                     $this->db->query($sql_update);
                                 } else {
                                     $sql_update = "UPDATE " . DB_PREFIX . "program_record SET is_out=1,conid=0,is_record=1 WHERE id=" . $row['id'];
                                     $this->db->query($sql_update);
                                 }
                             } else {
                             }
                         }
                         $log_data['text'] = $ret['errortext'];
                         $log_data['state'] = 2;
                         $log_id = $this->record->addLogs($log_data);
                         $this->update_queue($conid, $log_id);
                     }
                     $str = 'ID-' . $row['id'] . ($ret['errortext'] ? $ret['errortext'] : '录制成功');
                     $this->tips($str, TIMENOW);
                     break;
                 case 1:
                     //正在录制,录制超时,只处理周期性的录制超时
                     if ($row['start_time'] + $row['toff'] < TIMENOW - 120) {
                         $week_day = unserialize($row['week_day']);
                         if (is_array($week_day) && $week_day) {
                             $week_now = date('N', $row['start_time']);
                             $new_arr = array_flip($week_day);
                             if (count($week_day) > $new_arr[$week_now] + 1) {
                                 $ks = $new_arr[$week_now] + 1;
                             } else {
                                 $ks = 0;
                             }
                             $week_day = array_flip($new_arr);
                             $next_week = $week_day[$ks] - $week_now > 0 ? $week_day[$ks] - $week_now : $week_day[$ks] - $week_now + 7;
                             $start_time = $row['start_time'] + $next_week * 86400;
                             $sql_update = "UPDATE " . DB_PREFIX . "program_record SET conid=0,is_record=0,start_time=" . $start_time . " WHERE id=" . $row['id'];
                             $this->db->query($sql_update);
                             $str = 'ID-' . $row['id'] . '录制超时处理成功';
                             $this->tips($str, TIMENOW);
                         }
                     }
                     break;
             }
         }
     }
 }
Exemplo n.º 3
0
 public function detail($condition = '')
 {
     $sql = "SELECT p.* FROM " . DB_PREFIX . "program_record p " . $condition;
     $row = $this->db->query_first($sql);
     if (is_array($row) && $row) {
         include_once ROOT_PATH . 'lib/class/program.class.php';
         $program_plan = new program();
         include_once ROOT_PATH . 'lib/class/live.class.php';
         $newLive = new live();
         $channel = $newLive->getChannelById($row['channel_id']);
         $channel = $channel[0];
         $row['create_time'] = date('Y-m-d H:i:s', $row['create_time']);
         $row['update_time'] = date('Y-m-d H:i:s', $row['update_time']);
         $row['end_time'] = date('Y-m-d H:i:s', $row['start_time'] + $row['toff']);
         $row['start_time'] = date('Y-m-d H:i:s', $row['start_time']);
         $row['week_day'] = $row['week_day'] ? unserialize($row['week_day']) : array();
         $start_time = strtotime($row['dates'] . " " . $row['start_time']);
         $end_time = strtotime($row['dates'] . " " . $row['start_time']) + $row['toff'];
         $row['title'] = $row['title'] ? $row['title'] : (trim($program_plan->get_program_plan($row['channel_id'], $start_time, $end_time)) ? trim($program_plan->get_program_plan($row['channel_id'], $start_time, $end_time)) : '精彩节目');
         $mins = floor($row['toff'] / 60);
         $sen = $row['toff'] - $mins * 60;
         $row['toff_decode'] = ($mins ? $mins . "'" : '') . ($sen ? $sen . "''" : '');
         $row['channel_name'] = $channel['name'];
         return $row;
     }
 }
Exemplo n.º 4
0
 function show()
 {
     //$id = '126,106,100,127,217,111,134,139,119';
     $id = $this->input['id'];
     $condition = '';
     if ($id) {
         $condition .= ' pr.id IN(' . $this->input['id'] . ')';
         $day = intval($this->input['day']);
     } else {
         $condition .= "is_record=1 and (pr.start_time) > " . strtotime(date('Y-m-d', TIMENOW)) . " and (pr.start_time+pr.toff) < " . TIMENOW;
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "program_record pr WHERE " . $condition;
     $record_info = $channel_info = array();
     $q = $this->db->query($sql);
     while ($row = $this->db->fetch_array($q)) {
         $channel_info[$row['channel_id']] = $row['channel_id'];
         $record_info[] = $row;
     }
     if (!empty($channel_info)) {
         $channel_ids = implode(',', $channel_info);
         include_once ROOT_PATH . 'lib/class/live.class.php';
         $newLive = new live();
         $channel_tmp = $newLive->getChannelById($channel_ids);
         foreach ($channel_tmp as $k => $v) {
             $channel[$v['id']] = $v;
         }
     }
     include_once ROOT_PATH . 'lib/class/program.class.php';
     $program_plan = new program();
     $info = array();
     foreach ($record_info as $k => $row) {
         $channel_tmp = $channel[$row['channel_id']];
         $row['name'] = $channel_tmp['name'];
         $row['save_time'] = $channel_tmp['save_time'];
         $row['record_time'] = $channel_tmp['record_time'];
         $program = $row['title'] ? $row['title'] : trim($program_plan->get_program_plan($row['channel_id'], $row['starttime'], $row['endtime']));
         if ($id) {
             $row['start_time'] = $row['start_time'] - $day * 86400;
         }
         $start_time = date('YmdHis', $row['start_time'] + $row['record_time'] - 1);
         /*
         $data = array(
         	'start_time' => $start_time,
         	'id' =>  $row['id'],
         	'duration' => $row['toff'],
         	'exit_status' => 1,
         	'save_time' => $row['save_time'],
         	'source' => $row['channel_id'],
         	'is_allow' => $row['is_mark'],
         	'vod_sort_id' => $row['item'],
         	'week_flag' => $row['week_day'] ? 1 : 0,
         	'column_id' => $row['columnid'],
         	'audit_auto' => $row['audit_auto'] ? 2 : 0,
         	'title' => base64_encode(json_encode(trim($program ? $program : '精彩节目'))),
         	'name' => $row['name'],
         	'channel_id' => $row['channel_id'],
         	'file_path' => substr($start_time,0,4) . '/' . substr($start_time,4,2). '/' . substr($start_time,6,2). '/' . substr($start_time,8,2). '/' . substr($start_time,10,2). '/' . substr($start_time,12,2) . '/' . $row['id'] . '.mp4',
         	'extend' => base64_encode(json_encode(array('user_id' => $row['user_id'],'user_name' => $row['user_name'],'org_id' => $row['org_id'],'force_codec'=>$row['force_codec']))),
         	'update_state' => 1,
         );
         */
         $data = array('id' => $row['id'], 'is_time_shift' => $row['time_shift'] ? 1 : 0, 'title' => $program ? $program : '精彩节目', 'filepath' => substr($start_time, 0, 4) . '/' . substr($start_time, 4, 2) . '/' . substr($start_time, 6, 2) . '/' . substr($start_time, 8, 2) . '/' . substr($start_time, 10, 2) . '/' . substr($start_time, 12, 2) . '/' . $row['id'] . '.flv', 'source' => $row['name'], 'is_mark' => $row['is_mark'], 'vod_sort_id' => $row['item'], 'audit_auto' => $row['audit_auto'] ? 2 : 0, 'column_id' => $row['columnid'], 'channel_id' => $row['channel_id'], 'vod_leixing' => 3, 'start' => '0', 'end' => $row['toff'] * 1000, 'starttime' => $start_time, 'create_time' => -1, 'appid' => $this->input['appid'], 'appkey' => $this->input['appkey'], 'user_id' => $row['user_id'], 'user_name' => $row['user_name'], 'org_id' => $row['org_id'], 'force_codec' => $row['force_codec']);
         hg_pre($data);
         exit;
         $info[] = $data;
         if ($this->input['debug']) {
             hg_pre($data);
             exit;
         }
         foreach ($data as $k => $v) {
             $curl->addRequestData($k, $v);
         }
         $ret = $curl->request('create.php');
         /*	
         			$this->curl->setSubmitType('post');
         			$this->curl->initPostData();
         			$this->curl->addRequestData('a','callBack');
         			$this->curl->addRequestData('appkey',$this->input['appkey']);
         			$this->curl->addRequestData('appid',$this->input['appid']);
         			$this->curl->addRequestData('data',json_encode($data));
         			$this->curl->addRequestData('html',1);
         			$ret = $this->curl->request('record_callback.php');
         			hg_pre($ret);
         */
     }
     //hg_pre($info);
 }