Beispiel #1
0
 public function channelList()
 {
     if (!class_exists('live')) {
         include CUR_CONF_PATH . 'lib/class/live.class.php';
     }
     $objNewLive = new live();
     $channel = $objNewLive->getChannel();
     $this->addItem($channel);
     $this->output();
 }
Beispiel #2
0
 public function copy_day()
 {
     $channel_id = $this->input['channel_id'];
     if (!$channel_id) {
         $this->errorOutput("未传入频道ID");
     }
     include_once ROOT_PATH . 'lib/class/live.class.php';
     $newLive = new live();
     $channel = $newLive->getChannelById($channel_id, -1);
     $channel = $channel[0];
     if (!$channel['id']) {
         $this->errorOutput('该频道已经不存在!');
     }
     #####节点权限认证需要将节点数据放在nodes=>标志=>节点id=>节点所有父级节点
     $nodes = array();
     $nodes['_action'] = 'manage';
     $nodes['nodes'][$channel_id] = $channel_id;
     $this->verify_content_prms($nodes);
     #####节点权限认证需要将节点数据放在nodes=>标志=>节点id=>节点所有父级节点
     $dates = rawurldecode($this->input['dates']);
     //源日期
     if (!$dates) {
         $this->errorOutput("未传入更新日期");
     }
     $copy_dates = rawurldecode($this->input['copy_dates']);
     if (!$copy_dates) {
         $this->errorOutput("未传入更新日期");
     }
     $diff = strtotime($copy_dates) - strtotime($dates);
     //相差时间
     $sql = "DELETE FROM  " . DB_PREFIX . "program WHERE channel_id=" . $channel_id . " AND dates='" . $copy_dates . "'";
     $this->db->query($sql);
     $sql = "INSERT  INTO  " . DB_PREFIX . "program (channel_id,start_time, toff, theme, subtopic, type_id, dates, weeks, describes, create_time, update_time, ip, is_show) SELECT channel_id,start_time+" . $diff . ", toff, theme, subtopic, type_id, '" . $copy_dates . "', " . date('N', strtotime($copy_dates)) . ", describes, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), ip, is_show FROM " . DB_PREFIX . "program ";
     $sql .= "WHERE dates='" . $dates . "' AND channel_id=" . $channel_id;
     $this->db->query($sql);
     $tip = array('ret' => 1);
     $this->addItem($tip);
     $this->output();
 }
Beispiel #3
0
 function uploads()
 {
     if (!$this->input['channel_id']) {
         $this->errorOutput('未传入频道ID');
     }
     $channel_id = intval($this->input['channel_id']);
     include_once ROOT_PATH . 'lib/class/live.class.php';
     $newLive = new live();
     $channel = $newLive->getChannelById($channel_id, -1);
     $channel = $channel[0];
     if (!$channel['id']) {
         $this->errorOutput('该频道已经不存在!');
     }
     #####节点权限认证需要将节点数据放在nodes=>标志=>节点id=>节点所有父级节点
     $nodes = array();
     $nodes['_action'] = 'manage';
     $nodes['nodes'][$channel_id] = $channel_id;
     $this->verify_content_prms($nodes);
     #####节点权限认证需要将节点数据放在nodes=>标志=>节点id=>节点所有父级节点
     /**/
     if ($_FILES) {
         if ($_FILES['program']['error'] != 0) {
             exit('文件上传出错');
         }
     } else {
         //$this->errorOutput();
     }
     $file = $_FILES['program'];
     //$file['name'] = $file['tmp_name'] = '../cache/20130424161051.txt';
     $type = substr($file['name'], strrpos($file['name'], '.') + 1);
     $programs = $this->file2array($file['tmp_name'], $type);
     foreach ($programs as $dates => $value) {
         foreach ($value as $v) {
             $timestamp = strtotime(str_replace(':', ':', $dates . ' ' . $v['start_time']));
             $r['start_time'] = $timestamp;
             //  $r['start'] = date("Y-m-d H:i:s",$r['start_time']);
             if ($v['toff']) {
                 //if()
                 $r['toff'] = strtotime($dates . ' ' . $v['toff']);
                 if ($r['toff'] <= $r['start_time']) {
                     $r['toff'] = strtotime(date("Y-m-d", strtotime($dates) + 86400) . ' ' . $v['toff']);
                 }
             } else {
                 $r['toff'] = 0;
             }
             $r['theme'] = $v['theme'];
             $r['subtopic'] = $v['subtopic'];
             $r['type_id'] = $v['type_id'];
             $r['weeks'] = date('W', strtotime($dates));
             $r['dates'] = $dates;
             $return[$dates][] = $r;
         }
     }
     $next_day = array();
     if (!empty($return)) {
         foreach ($return as $dat => $items) {
             if ($next_day[$dat]) {
                 if ($next_day[$dat]['toff'] > $items[0]['start_time']) {
                     $this->addItem($dat . '的跨天数据有误!');
                     $this->output();
                 } else {
                     array_unshift($return[$dat], $next_day[$dat]);
                     array_unshift($items, $next_day[$dat]);
                     unset($next_day[$dat]);
                 }
             }
             $last_end = 0;
             foreach ($items as $i => $v) {
                 if ($i == count($items) - 1) {
                     $tmp_start = strtotime($v['dates']) + 86399;
                     if ($return[$dat][$i]['toff']) {
                         if ($v['toff'] > $tmp_start) {
                             $tmp_time = $items[$i];
                             $tmp_time['start_time'] = strtotime($v['dates']) + 86400;
                             $tmp_time['dates'] = date("Y-m-d", strtotime($v['dates']) + 86400);
                             $next_day[date("Y-m-d", $v['toff'])] = $tmp_time;
                         }
                     }
                     $return[$dat][$i]['toff'] = $tmp_start - $v['start_time'];
                 } else {
                     $tmp_start = $items[$i + 1]['start_time'];
                     if ($return[$dat][$i]['toff']) {
                         $tmp_start = $v['toff'];
                     }
                     $return[$dat][$i]['toff'] = $items[$i + 1]['start_time'] - $v['start_time'];
                 }
                 $return[$dat][$i]['start'] = date("H:i:s", $v['start_time']);
                 $return[$dat][$i]['end'] = date("H:i:s", $v['start_time'] + $return[$dat][$i]['toff']);
                 if ($return[$dat][$i]['toff'] < 0 || $last_end && $last_end > $v['start_time']) {
                     //$this->errorOutput('时间线不正确,请检查确认后重新提交!');
                     $this->addItem('时间线不正确,请检查确认后重新提交!');
                     $this->output();
                 }
                 $last_end = $v['start_time'] + $return[$dat][$i]['toff'];
             }
         }
     }
     if (!empty($next_day)) {
         $i = 0;
         foreach ($next_day as $dat => $v) {
             $return[$dat][$i] = $v;
             $return[$dat][$i]['toff'] = $v['toff'] - $v['start_time'];
             $return[$dat][$i]['start'] = date("H:i:s", $v['start_time']);
             $return[$dat][$i]['end'] = date("H:i:s", $v['start_time'] + $return[$dat][$i]['toff']);
             $i++;
         }
     }
     $info = $return;
     if (!empty($info)) {
         $del_id = $space = "";
         foreach ($info as $key => $value) {
             $program_single = $this->getProgram($channel_id, $key);
             foreach ($value as $kk => $vv) {
                 $start = $vv['start_time'];
                 $end = $vv['start_time'] + $vv['toff'];
                 if (!empty($program_single)) {
                     foreach ($program_single as $k => $r) {
                         if ($start == $r['start_time'] && $end == $r['start_time'] + $r['toff']) {
                             //	unset($info[$key][$kk]);
                             $del_id .= $space . $r["id"];
                             $space = ",";
                         } else {
                             if ($r['start_time'] >= $start && $r['start_time'] < $end) {
                                 $del_id .= $space . $r["id"];
                                 $space = ",";
                             }
                             if ($r['start_time'] < $start) {
                                 if ($r['start_time'] + $r['toff'] > $start) {
                                     $del_id .= $space . $r["id"];
                                     $space = ",";
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($del_id) {
         $sql = "DELETE FROM " . DB_PREFIX . "program WHERE id IN(" . $del_id . ")";
         $this->db->query($sql);
     }
     //数据入库
     if (!empty($info)) {
         foreach ($info as $kk => $vv) {
             $sql = "INSERT INTO " . DB_PREFIX . "program(channel_id,start_time,toff,theme,subtopic,type_id,weeks,dates,create_time,update_time,ip,is_show,user_id,user_name,org_id,appid,appname) values";
             $space = $sql_extra = "";
             foreach ($vv as $k => $v) {
                 $sql_extra .= $space . "(" . $channel_id . "," . $v['start_time'] . "," . $v['toff'] . ",'" . $v['theme'] . "','" . $v['subtopic'] . "'," . ($v['type_id'] ? $v['type_id'] : 0) . "," . intval($v['weeks']) . ",'" . $v['dates'] . "'," . TIMENOW . "," . TIMENOW . ",'" . hg_getip() . "',1,'" . $this->user['user_id'] . "','" . $this->user['user_name'] . "','" . $this->user['org_id'] . "','" . $this->user['appid'] . "','" . $this->user['display_name'] . "')";
                 $space = ",";
             }
             if ($sql_extra) {
                 $sql .= $sql_extra;
                 $this->db->query($sql);
             }
         }
     }
     $this->addItem('success');
     $this->output();
 }
 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);
 }
Beispiel #5
0
 private function storage_data($video, $vod_config)
 {
     if ($video['column_id']) {
         $publish_column = new publishconfig();
         $column_id = $video['column_id'];
         $column_id = $publish_column->get_columnname_by_ids('id,name', $column_id);
         $column_id = serialize($column_id);
     }
     $channel_id = $video['channel_id'];
     if ($video['create_time'] != -1) {
         $create_time = strtotime($video['create_time']);
     }
     $pathinfo = pathinfo($video['filepath']);
     //如果不存在分类就默认其分类与类型相同
     $vod_leixing = $video['vod_leixing'] ? $video['vod_leixing'] : 1;
     if (!$video['vod_sort_id'] || intval($video['vod_sort_id']) == -1) {
         $video['vod_sort_id'] = $vod_leixing;
     }
     /************创建视频的权限控制**********/
     if ($this->user['group_type'] > MAX_ADMIN_TYPE) {
         $prms['_action'] = 'create';
         $prms['node'] = $video['vod_sort_id'];
         if (!$this->verify_self_prms($prms)) {
             $this->errorOutput('NO_PRIVILEGE');
             //$this->addItem(array('return' => 'fail'));
             //$this->output();
         }
     }
     foreach ($video as $k => $v) {
         if (is_string($v)) {
             $video[$k] = rawurldecode($v);
         }
     }
     $data = array('cur_clarity' => $vod_config['unique_id'], 'title' => $video['title'] ? $video['title'] : $this->dir_info['original'], 'source' => $video['source'], 'subtitle' => $video['subtitle'], 'keywords' => $video['keywords'], 'weight' => $video['weight'], 'comment' => $video['comment'], 'author' => $video['author'], 'vod_leixing' => $vod_leixing, 'bitrate' => $vod_config['video_bitrate'], 'vod_sort_id' => $video['vod_sort_id'], 'is_allow' => $video['is_mark'], 'starttime' => $video['starttime'] ? strtotime($video['starttime']) : '', 'hostwork' => defined("TARGET_VIDEO_DOMAIN") ? 'http://' . ltrim(TARGET_VIDEO_DOMAIN, 'http://') : $this->settings['videouploads']['protocol'] . $this->settings['videouploads']['host'], 'source_hostwork' => defined("SOURCE_VIDEO_DOMIAN") ? 'http://' . ltrim(SOURCE_VIDEO_DOMIAN, 'http://') : '', 'source_base_path' => UPLOAD_DIR, 'source_path' => rtrim($pathinfo['dirname'], '/') . '/', 'source_filename' => $pathinfo['basename'], 'video_base_path' => TARGET_DIR, 'video_path' => $this->dir_info['target_dir'], 'video_filename' => $this->dir_info['output_filename'] . '.' . $this->dir_info['output_format'], 'channel_id' => $channel_id, 'column_id' => $column_id, 'from_appid' => $this->user['appid'], 'from_appname' => $this->user['display_name'], 'user_id' => $video['_user_id'] ? $video['_user_id'] : ($this->input['user_id'] ? $this->input['user_id'] : $this->user['user_id']), 'addperson' => $video['_user_name'] ? $video['_user_name'] : ($this->input['user_name'] ? $this->input['user_name'] : $this->user['user_name']), 'org_id' => $this->input['org_id'] ? $this->input['org_id'] : $this->user['org_id'], 'create_time' => $create_time ? $create_time : TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip(), 'app_uniqueid' => $video['app_uniqueid'] ? $video['app_uniqueid'] : 'livmedia', 'mod_uniqueid' => $video['mod_uniqueid'] ? $video['mod_uniqueid'] : MOD_UNIQUEID, 'morebitrate_config_id' => $video['vod_config_id'], 'template_sign' => $video['template_sign']);
     if ($video['is_time_shift']) {
         $sql = "UPDATE " . DB_PREFIX . "vodinfo SET ";
     } else {
         $sql = " INSERT INTO " . DB_PREFIX . "vodinfo SET ";
     }
     foreach ($data as $k => $v) {
         $sql .= " {$k} = '{$v}',";
     }
     $sql = trim($sql, ',');
     if ($video['is_time_shift']) {
         $sql .= ' WHERE id = ' . $video['id'];
     }
     $this->db->query($sql);
     if ($video['is_time_shift']) {
         $vid = $video['id'];
     } else {
         $vid = $this->db->insert_id();
     }
     //记录发布库栏目分发表
     $this->update_pub_column($vid, $video['column_id']);
     //记录发布库栏目分发表
     if ($video['index_pic']) {
         $material = new material();
         $img_info = $material->localMaterial($video['index_pic'], $vid);
         $img_info = $img_info[0];
     } else {
         //获取一张截图,并且提交到图片服务器
         $img_info = getimage(UPLOAD_DIR . $video['filepath'], TARGET_DIR . $this->dir_info['target_dir'], $vid);
         if (!$img_info || !$img_info['filename']) {
             if ($this->settings['App_live'] && $channel_id) {
                 include_once ROOT_PATH . 'lib/class/live.class.php';
                 $live = new live();
                 $channelinfo = $live->getChannelById($channel_id, 1, 1);
                 if ($channelinfo && $channelinfo[0] && $channelinfo[0]['snap']) {
                     $img_info = $channelinfo[0]['snap'];
                 }
             }
         }
     }
     if ($img_info && is_array($img_info)) {
         $image_info = array('host' => $img_info['host'], 'dir' => $img_info['dir'], 'filepath' => $img_info['filepath'], 'filename' => $img_info['filename'], 'imgwidth' => $img_info['imgwidth'], 'imgheight' => $img_info['imgheight']);
     } else {
         $image_info = array();
     }
     $sql = " UPDATE " . DB_PREFIX . "vodinfo SET video_order_id = {$vid},img_info = '" . serialize($image_info) . "'  WHERE id = {$vid}";
     $this->db->query($sql);
     //存储vod_extend表
     if ($video['content_id']) {
         $extend_data = array('vodinfo_id' => $vid, 'content_id' => $video['content_id'], 'extend_data' => $video['extend_data']);
         $sql = " INSERT INTO " . DB_PREFIX . "vod_extend SET ";
         foreach ($extend_data as $k => $v) {
             $sql .= " {$k} = '{$v}',";
         }
         $sql = trim($sql, ',');
         $this->db->query($sql);
     }
     //加入日志
     $data['id'] = $vid;
     $this->addLogs('创建视频', '', $data, $data['title']);
     return array('vid' => $vid, 'img_info' => $image_info);
 }
<?php

// this script execute a simple livestatus query on table columns
// columns describe all of the others tables of livestatus
require_once "/var/www/frogx/api/live.php";
// live status query (each line is a row in the array)
$query = array("GET columns");
// create live object TCP with xinetd with default buffer size
$live = new live(array("host" => "localhost", "port" => "6557"));
// create live object with Unix Socket
//$live = new live(array("socket"=>"/opt/monitor/var/rw/live"),1024);
if (!$live) {
    die("Error while connecting");
} else {
    //execute the query
    $json = $live->execQuery($query);
    if ($live->responsecode != "200") {
        // error
        die($live->responsecode . " : " . $live->responsemessage);
    }
    $response = json_decode($json);
    echo "<table>";
    foreach ($response as $line) {
        // line
        echo "<tr>";
        // header
        foreach ($line as $col) {
            echo "<td style=\"border:1px solid black\">" . $col . "</td>";
        }
        echo "</tr>";
    }
Beispiel #7
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;
     }
 }
Beispiel #8
0
 public function getChannel()
 {
     include_once ROOT_PATH . 'lib/class/live.class.php';
     $newLive = new live();
     $channel = $newLive->getChannel();
     if (!empty($channel)) {
         foreach ($channel as $k => $v) {
             $this->addItem($v);
         }
         $this->output();
     }
 }
Beispiel #9
0
 public function buildBlocks()
 {
     $live = live::getInstance();
     $this->smarty = Core::smarty();
     $blocks = array();
     // Getting list of blocks
     $blocks_obj = new \Blocks\Block();
     $blocks_data = $blocks_obj->getList();
     foreach ($blocks_data as $block) {
         $template_file_name = $block['name'] . '.tpl';
         // Getting block's data
         $model = '\\' . $block['module'] . '\\Controller';
         $model = new $model();
         $action = $block['name'] . 'Block';
         if ($block_output = $model->{$action}()) {
             foreach ($block_output as $name => $data) {
                 $this->smarty->assign($name, $data);
             }
         }
         // Templating block's data
         $paths = array('custom/themes/' . $this->name . '/templates/' . $block['module'], 'system/themes/' . $this->name . '/templates/' . $block['module'], 'custom/modules/' . $block['module'] . '/templates', 'system/modules/' . $block['module'] . '/templates', 'custom/modules/' . $block['module'] . '/templates');
         $path = $live->findPath($paths, $template_file_name);
         if (!empty($path)) {
             $output = $this->smarty->fetch($path);
             if (empty($blocks[$block['region']])) {
                 $blocks[$block['region']] = $output;
             } else {
                 $blocks[$block['region']] .= $output;
             }
         }
     }
     return $blocks;
 }
Beispiel #10
0
<?php

/**
 * get overall hosts and services states (as known as tactical overview)
 * this introduce the concept of multisite. Each site is an entry in the array config["sites"]
 */
require_once "/var/www/frogx/conf/sites.inc.php";
require_once "/var/www/frogx/api/live.php";
$tac = new live($config["sites"], 1024);
// get global states
print_r(json_decode($tac->getOverallStates()));
// get performances
print_r(json_decode($tac->getPerformances()));
Beispiel #11
0
 public function delete()
 {
     $id = urldecode($this->input['id']);
     if (!$id) {
         $this->errorOutput(OBJECT_NULL);
     } else {
         $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 id IN (" . $id . ")";
         $q = $this->db->query($sql);
         include_once ROOT_PATH . 'lib/class/live.class.php';
         $newLive = new live();
         $info = array();
         $channel_id = array();
         while ($row = $this->db->fetch_array($q)) {
             $info[] = $row;
             $channel_id[$row['channel_id']] = $row['channel_id'];
         }
         $channel_node = $channel_parent_node = array();
         if ($channel_id) {
             $channel = $newLive->getChannelById(implode(',', $channel_id), -1);
             if (!empty($channel)) {
                 foreach ($channel as $k => $v) {
                     $tmp_data = $newLive->getFatherNodeByid($v['node_id']);
                     $channel_node[$v['id']] = $tmp_data[0];
                     $channel_parent_node[$v['id']] = $v['node_id'];
                 }
             }
         }
         include_once ROOT_PATH . 'lib/class/curl.class.php';
         $id_success = array();
         $delete_id = $space = "";
         $ret = array();
         foreach ($info as $k => $row) {
             $this->curl = new curl($server_config[$row['server_id']]['host'] . ':' . $server_config[$row['server_id']]['port'], $server_config[$row['server_id']]['dir']);
             #####整合数据进行权限
             $nodes = array();
             $nodes['nodes'][$row['channel_id']] = $row['channel_id'];
             //hg_pre($nodes);exit;
             $this->verify_content_prms($nodes);
             if ($this->user['group_type'] > MAX_ADMIN_TYPE) {
                 switch ($this->user['prms']['default_setting']['manage_other_data']) {
                     case 1:
                         //组织内,修改者和作者是否在同一组织
                         if ($this->user['org_id'] != $row['org_id']) {
                             $this->errorOutput(NO_PRIVILEGE);
                         }
                         break;
                     case 5:
                         //全部
                         break;
                     case 0:
                         //只能自己修改
                         if ($this->user['user_id'] != $row['user_id']) {
                             $this->errorOutput(NO_PRIVILEGE);
                         }
                         break;
                     default:
                         break;
                 }
             }
             #####整合数据进行权限结束
             if ($row['conid'] && $row['start_time'] > TIMENOW + 5) {
                 $sql = "SELECT * FROM " . DB_PREFIX . "program_queue WHERE id=" . $row['conid'];
                 $tmp_first = $this->db->query_first($sql);
                 if (!empty($tmp_first)) {
                     $this->curl->mPostContentType('string');
                     $this->curl->setSubmitType('get');
                     $this->curl->setReturnFormat('json');
                     $this->curl->initPostData();
                     if (!defined('IS_WOZA') || !IS_WOZA) {
                         $this->curl->addRequestData('action', 'DELETE');
                     } else {
                         $this->curl->addRequestData('action', 'delete');
                     }
                     $this->curl->addRequestData('id', $tmp_first['conid']);
                     $record_xml = $this->curl->request('');
                     $record_array = xml2Array($record_xml);
                     if ($record_array['result']) {
                         $id_success[] = $row['id'];
                     }
                 }
             }
             $delete_id .= $space . $row['id'];
             $space = ',';
             $ret[] = $row;
         }
         if ($delete_id) {
             $sql = "DELETE FROM " . DB_PREFIX . "program_record WHERE id IN (" . $delete_id . ")";
             $this->db->query($sql);
             $sql = "DELETE FROM " . DB_PREFIX . "program_record_relation WHERE record_id IN (" . $delete_id . ")";
             $this->db->query($sql);
             $sql = "DELETE FROM " . DB_PREFIX . "program_record_log WHERE record_id IN (" . $delete_id . ")";
             $this->db->query($sql);
             $sql = "DELETE FROM " . DB_PREFIX . "program_queue WHERE record_id IN (" . $delete_id . ")";
             $this->db->query($sql);
         }
         $this->addLogs('删除录制', $ret, '', '', '', '删除录制' . $delete_id);
     }
     $re = array();
     $id_array = explode(',', $id);
     $delid_array = explode(',', $delete_id);
     if (count($id_array) == count($delid_array)) {
         $re['info'] = '';
     } else {
         $re['info'] = '来自于节目单或者节目单计划的录制内容无法删除!';
     }
     $re['id'] = $delete_id;
     $this->setXmlNode('program_record', 'info');
     $this->addItem($re);
     $this->output();
 }
Beispiel #12
0
 public function getTimeshiftNew()
 {
     $channel_id = intval($this->input['channel_id'] ? $this->input['channel_id'] : '');
     if (empty($channel_id)) {
         $this->errorOutput('缺少频道ID');
     }
     include_once ROOT_PATH . 'lib/class/live.class.php';
     $newLive = new live();
     $channel = $newLive->getChannelById($channel_id);
     if (empty($channel)) {
         $this->errorOutput("此频道不存在或者已被删除!");
     }
     $channel = $channel[0];
     $channel_name = $channel['name'];
     $save_time = $channel['time_shift'];
     $start_time = strtotime(date("Y-m-d", TIMENOW - 3600 * $save_time) . " 00:00:00");
     $end_time = strtotime(date("Y-m-d", TIMENOW) . " 23:59:59") + 1;
     $condition = " AND channel_id=" . $channel_id . " AND  start_time>'" . $start_time . "' AND start_time<" . $end_time . "";
     $info = $this->obj->show($condition, $channel_id, $start_time, $end_time, $save_time);
     $this->addItem($info);
     $this->output();
 }
Beispiel #13
0
<?php

// this script send an external command to livestatus
$base = "/var/www/frogx";
include_once $base . "/api/live.php";
include_once $base . "/conf/commands.inc.php";
// command definition
$command = array("DISABLE_HOST_SVC_CHECKS", array("host_name" => "localhost"));
// this is a single site command call
// create live object with Unix Socket
$live = new live(array("socket" => "/opt/monitor/var/rw/live"), 1024);
//load authorised external command list
$live->getCommands($config["commands"]);
if (!$live) {
    die("Error while connecting");
} else {
    //execute the command
    if (!$live->sendExternalCommand($command)) {
        echo "[ERROR " . $live->responsecode . "] " . $live->responsemessage;
    } else {
        echo "[SUCCESS]";
    }
}
//
Beispiel #14
0
 public function delete($id)
 {
     if (empty($id)) {
         return false;
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "program_plan WHERE id=" . $id;
     $f = $this->db->query_first($sql);
     if ($f['id']) {
         if ($f['record_id']) {
             include_once ROOT_PATH . 'lib/class/live.class.php';
             $obj_live = new live();
             $obj_live->delete_record($f['record_id']);
         }
         $sql_ = "SELECT * FROM " . DB_PREFIX . "program_plan WHERE id = " . $id;
         $pre_data = $this->db->query_first($sql_);
         $sql = "DELETE FROM " . DB_PREFIX . "program_plan WHERE id=" . $id;
         $r = $this->db->query($sql);
         $sql = "DELETE FROM " . DB_PREFIX . "program_plan_relation WHERE plan_id=" . $id;
         $r = $this->db->query($sql);
         $this->addLogs('delete', $pre_data, '', '', '');
     }
     return $f['channel_id'];
 }
Beispiel #15
0
 public function load_time_shift()
 {
     $offset = $this->input['offset'] ? intval($this->input['offset']) : 0;
     $count = $this->input['count'] ? intval($this->input['count']) : 50;
     $cond = array('offset' => $offset, 'count' => $count, 'is_stream' => 0, 'fetch_live' => 1);
     $mLive = new live();
     $channel = $mLive->getChannelInfo($cond);
     $return['channel'] = $channel;
     $this->addItem($return);
     $this->output();
 }
Beispiel #16
0
<?php

/*
* test gvim
*/
class live
{
    public $work = 'php enginer';
    public $study = 'design mode';
    public function working()
    {
        echo "write code .\n";
    }
    public function learning()
    {
        echo "reading vim doc\n";
    }
}
$live = new live();
$live->working();
$live->learning();
Beispiel #17
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;
             }
         }
     }
 }
Beispiel #18
0
 function update_day()
 {
     if (!$this->input['channel_id']) {
         $this->errorOutput("未传入频道ID");
     }
     if (!$this->input['dates']) {
         $this->errorOutput("未传入更新日期");
     }
     /*
     $sql = "select r.start_time,r.end_time,r.channel_id,r.week_num,p.item from " . DB_PREFIX . "program_record p left join " . DB_PREFIX . "program_record_relation r on p.id = r.record_id where r.channel_id=" . $this->input['channel_id'] . " and r.week_num=".date('N',strtotime($this->input['dates']));
     		$q = $this->db->query($sql);
     				$record = array();
     		while($r = $this->db->fetch_array($q))
     		{
     			$record[] = $r['start_time'] . '-' . $r['end_time'] . '-' . $r['item'];
     		}
     */
     include_once ROOT_PATH . 'lib/class/live.class.php';
     $obj_live = new live();
     include_once ROOT_PATH . 'lib/class/curl.class.php';
     $this->curl = new curl($this->settings['mms']['record_server']['host'], $this->settings['mms']['record_server']['dir']);
     $arr = array('color' => $this->input['color'], 'checke' => $this->input['checke'], 'start_time' => $this->input['start_time'], 'theme' => $this->input['theme'], 'end_time' => $this->input['end_time'], 'item' => $this->input['item'], 'new' => $this->input['new'], 'plan' => $this->input['plan'], 'plan_source' => $this->input['plan_source'], 'program_source' => $this->input['program_source']);
     foreach ($arr as $key => $value) {
         if (empty($value)) {
             unset($arr[$key]);
         }
     }
     $dates = urldecode($this->input['dates']);
     if (empty($arr)) {
         $sql = "SELECT * FROM " . DB_PREFIX . "program WHERE channel_id = " . $this->input['channel_id'] . " and dates='" . $dates . "'";
         $q = $this->db->query($sql);
         $tmp_record_id = $tmp_space = '';
         while ($row = $this->db->fetch_array($q)) {
             if ($row['record_id']) {
                 $tmp_record_id .= $tmp_space . $row['record_id'];
                 $tmp_space = ',';
             }
         }
         if ($tmp_record_id) {
             $sql = "SELECT * FROM " . DB_PREFIX . "program_record WHERE id IN (" . $tmp_record_id . ")";
             $q = $this->db->query($sql);
             $tmp_record_id_plan = $tmp_record_id_program = 0;
             $space_plan = $space_program = '';
             while ($row = $this->db->fetch_array($q)) {
                 if ($row['plan_id']) {
                     $tmp_record_id_plan .= $space_plan . $row['id'];
                     $space_plan = ',';
                 } else {
                     $tmp_record_id_program .= $space_program . $row['id'];
                     $space_program = ',';
                 }
             }
             if ($tmp_record_id_program) {
                 $obj_live->delete_record($tmp_record_id_program);
             }
             if ($tmp_record_id_plan) {
                 $sql = "UPDATE " . DB_PREFIX . "program_record SET program_id=0 WHERE id IN(" . $tmp_record_id_plan . ")";
                 $this->db->query($sql);
             }
         }
         $sql = "DELETE FROM " . DB_PREFIX . "program WHERE channel_id = " . $this->input['channel_id'] . " and dates='" . $dates . "'";
         $this->db->query($sql);
         $program_plan = $this->getPlan($this->input['channel_id'], $dates);
         $program = array();
         $start = strtotime($dates . " 00:00:00");
         $end = strtotime($dates . " 23:59:59");
         if (empty($program_plan)) {
             $program[] = $this->getInfo($start, strtotime($dates . " 08:00:00"), $dates, $this->input['channel_id'], 1, 0);
             $program[] = $this->getInfo(strtotime($dates . " 08:00:00"), $end, $dates, $this->input['channel_id']);
         } else {
             $com_time = 0;
             foreach ($program_plan as $k => $v) {
                 if (!$com_time && $v['start_time'] > $start) {
                     $program[] = $this->getInfo($start, $v['start_time'], $dates, $this->input['channel_id']);
                 }
                 if ($com_time && $com_time != $v['start_time']) {
                     $program[] = $this->getInfo($com_time, $v['start_time'], $dates, $this->input['channel_id']);
                 }
                 $v['start'] = date("H:i", $v['start_time']);
                 $v['end'] = date("H:i", $v['start_time'] + $v['toff']);
                 if ($v['start_time'] <= TIMENOW) {
                     $v['outdate'] = 1;
                 } else {
                     $v['outdate'] = 0;
                 }
                 $com_time = $v['start_time'] + $v['toff'];
                 $program[] = $v;
             }
             if ($com_time && $com_time < $end) {
                 $program[] = $this->getInfo($com_time, $end, $dates, $this->input['channel_id']);
             }
         }
         //	file_put_contents('../cache/2.php',var_export($program,1));
         $this->addItem($program);
         $this->output();
     }
     $prev_end = 0;
     foreach ($arr['start_time'] as $k => $v) {
         $start_this = strtotime(urldecode($dates . " " . $v));
         $end_this = strtotime(urldecode($dates . " " . $arr['end_time'][$k]));
         if ($start_this >= $end_this) {
             $this->errorOutput($v . '~' . urldecode($arr['end_time'][$k]) . "的开始时间大于等于结束时间");
         }
         if ($prev_end && $prev_end > $start_this) {
             $this->errorOutput($start_this . "的上一个节目的时间有误");
         }
         $prev_end = $end_this;
     }
     $ids = $spa = '';
     foreach ($arr['color'] as $key => $value) {
         $pid = $key;
         if ($arr['checke'][$pid]) {
             $info = array('id' => $pid, 'color' => urldecode($value), 'start_time' => strtotime(urldecode($dates . " " . $arr['start_time'][$key])), 'theme' => rawurldecode($arr['theme'][$key]), 'toff' => strtotime(urldecode($dates . " " . $arr['end_time'][$key])) - strtotime(urldecode($dates . " " . $arr['start_time'][$key])), 'item' => intval($arr['item'][$key]), 'new' => urldecode($arr['new'][$key]), 'plan' => intval($arr['plan'][$key]), 'plan_source' => intval($arr['plan_source'][$key]), 'program_source' => intval($arr['program_source'][$key]));
             if ($info['new']) {
                 $creates = array('channel_id' => $this->input['channel_id'], 'start_time' => $info['start_time'], 'toff' => $info['toff'], 'theme' => rawurldecode($arr['theme'][$key]), 'type_id' => 1, 'weeks' => date("W", $info['start_time']), 'dates' => date("Y-m-d", $info['start_time']), 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip(), 'is_show' => 1);
                 $sql = "INSERT INTO " . DB_PREFIX . "program SET ";
                 $space = "";
                 foreach ($creates as $k => $v) {
                     $sql .= $space . $k . "=" . "'" . $v . "'";
                     $space = ",";
                 }
                 $this->db->query($sql);
                 $info['id'] = $this->db->insert_id();
                 $pid = $info['id'];
                 if ($info['item'] > 0) {
                     $record_create = array('title' => $info['theme'], 'channel_id' => $this->input['channel_id'], 'program_id' => $info['id'], 'start_time' => $info['start_time'], 'toff' => $info['toff'], 'item' => $info['item'], 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip());
                     if ($record_create['start_time'] < TIMENOW) {
                         $record_create['is_out'] = 1;
                     }
                     if ($info['plan']) {
                         $sql = "SELECT id FROM " . DB_PREFIX . "program_record WHERE plan_id=" . $info['plan'];
                         $tmp_plan_record = $this->db->query_first($sql);
                         if ($info['program_source'] == 2) {
                             $createsql = "INSERT INTO " . DB_PREFIX . "program_record SET ";
                             $space = "";
                             foreach ($record_create as $k => $v) {
                                 $createsql .= $space . $k . "=" . "'" . $v . "'";
                                 $space = ",";
                             }
                             $this->db->query($createsql);
                             $record_id = $this->db->insert_id();
                             $this->insert_relation($record_create['channel_id'], $record_id, $record_create['start_time'], $record_create['toff'], 0);
                             $sql = "UPDATE " . DB_PREFIX . "program SET record_id='" . $record_id . "' WHERE id=" . $info['id'];
                             $this->db->query($sql);
                         } else {
                             if (!empty($tmp_plan_record)) {
                                 $sql = "UPDATE " . DB_PREFIX . "program_record SET program_id=" . $info['id'] . " WHERE plan_id=" . $info['plan'];
                                 $this->db->query($sql);
                                 $sql = "UPDATE " . DB_PREFIX . "program SET record_id='" . $tmp_plan_record['id'] . "' WHERE id=" . $info['id'];
                                 $this->db->query($sql);
                             } else {
                             }
                         }
                     } else {
                         //不是计划,而且有录制,说明肯定创建单天录制
                         $createsql = "INSERT INTO " . DB_PREFIX . "program_record SET ";
                         $space = "";
                         foreach ($record_create as $k => $v) {
                             $createsql .= $space . $k . "=" . "'" . $v . "'";
                             $space = ",";
                         }
                         $this->db->query($createsql);
                         $record_id = $this->db->insert_id();
                         $this->insert_relation($record_create['channel_id'], $record_id, $record_create['start_time'], $record_create['toff'], 0);
                         $sql = "UPDATE " . DB_PREFIX . "program SET record_id='" . $record_id . "' WHERE id=" . $info['id'];
                         $this->db->query($sql);
                     }
                 }
             } else {
                 $sql = "UPDATE " . DB_PREFIX . "program SET color='" . $info['color'] . "',start_time=" . $info['start_time'] . ",theme='" . $info['theme'] . "',toff=" . $info['toff'] . " where id=" . $info['id'];
                 $this->db->query($sql);
                 if ($info['item'] > 0) {
                     $record_create = array('title' => $info['theme'], 'channel_id' => $this->input['channel_id'], 'program_id' => $info['id'], 'start_time' => $info['start_time'], 'toff' => $info['toff'], 'item' => $info['item'], 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip());
                     $sql = "SELECT * FROM " . DB_PREFIX . "program_record WHERE program_id=" . $info['id'];
                     $tmp_senc = $this->db->query_first($sql);
                     if (empty($tmp_senc)) {
                         $createsql = "INSERT INTO " . DB_PREFIX . "program_record SET ";
                         $space = "";
                         foreach ($record_create as $k => $v) {
                             $createsql .= $space . $k . "=" . "'" . $v . "'";
                             $space = ",";
                         }
                         $this->db->query($createsql);
                         $record_id = $this->db->insert_id();
                         $this->insert_relation($record_create['channel_id'], $record_id, $record_create['start_time'], $record_create['toff'], 0);
                         $sql = "UPDATE " . DB_PREFIX . "program SET record_id='" . $record_id . "' WHERE id=" . $info['id'];
                         $this->db->query($sql);
                     } else {
                         $record_update = array('title' => $info['theme'], 'start_time' => $info['start_time'], 'toff' => $info['toff'], 'item' => $info['item'], 'update_time' => TIMENOW);
                         $sql = "SELECT id,log_id,conid FROM " . DB_PREFIX . "program_queue WHERE id=" . $tmp_senc['conid'];
                         $sen = $this->db->query_first($sql);
                         if ($sen) {
                             $this->curl->mPostContentType('string');
                             $this->curl->setSubmitType('get');
                             $this->curl->setReturnFormat('json');
                             $this->curl->initPostData();
                             if (!defined('IS_WOZA') || !IS_WOZA) {
                                 $this->curl->addRequestData('action', 'DELETE');
                             } else {
                                 $this->curl->addRequestData('action', 'delete');
                             }
                             $this->curl->addRequestData('id', $sen['conid']);
                             $record_xml = $this->curl->request('');
                             $record_array = xml2Array($record_xml);
                             if ($record_array['result']) {
                                 $sql = "DELETE FROM " . DB_PREFIX . "program_record_log WHERE id IN (" . $sen['log_id'] . ")";
                                 $this->db->query($sql);
                                 $sql = "DELETE FROM " . DB_PREFIX . "program_queue WHERE id=" . $sen['id'];
                                 $this->db->query($sql);
                             }
                         }
                         if (empty($tmp_senc['week_day'])) {
                             if ($record_update['start_time'] <= TIMENOW) {
                                 //相当于重置录制
                                 $record_update['is_out'] = 1;
                             }
                             $updatesql = "UPDATE " . DB_PREFIX . "program_record SET ";
                             $space = "";
                             foreach ($record_update as $k => $v) {
                                 $updatesql .= $space . $k . "=" . "'" . $v . "'";
                                 $space = ",";
                             }
                             $updatesql .= " WHERE program_id=" . $info['id'];
                             $this->db->query($updatesql);
                         } else {
                             if ($record_update['start_time'] <= TIMENOW) {
                                 $week_now = date('N', TIMENOW);
                                 $week_num = unserialize($tmp_senc['week_day']);
                                 if (in_array($week_now, $week_num)) {
                                     $dates = date('Y-m-d', TIMENOW);
                                 }
                                 $i = 0;
                                 $next_day = $next_week_day = 0;
                                 foreach ($week_num as $k => $v) {
                                     if (!$i && $v > $week_now) {
                                         $next_day = $v;
                                         $i = 1;
                                     }
                                     if (!$k) {
                                         $next_week_day = $v;
                                     }
                                 }
                                 if (!$next_day) {
                                     $next_day = $next_week_day;
                                 }
                                 $next_week = $next_day - $week_now > 0 ? $next_day - $week_now : $next_day - $week_now + 7;
                                 $dates = date('Y-m-d', TIMENOW + $next_week * 86400);
                                 $record_update['start_time'] = strtotime($dates . ' ' . date('H:i:s', $tmp_senc['start_time']));
                             }
                             $updatesql = "UPDATE " . DB_PREFIX . "program_record SET ";
                             $space = "";
                             foreach ($record_update as $k => $v) {
                                 $updatesql .= $space . $k . "=" . "'" . $v . "'";
                                 $space = ",";
                             }
                             $updatesql .= " WHERE program_id=" . $info['id'];
                             $this->db->query($updatesql);
                         }
                     }
                 } else {
                     $sql = "SELECT * FROM " . DB_PREFIX . "program_record WHERE program_id=" . $info['id'];
                     $tmp_senc = $this->db->query_first($sql);
                     if (empty($tmp_senc)) {
                         //对录制不做任何操作
                     } else {
                         if ($tmp_senc['plan_id']) {
                             $sql = "UPDATE " . DB_PREFIX . "program_record SET program_id=0 WHERE id=" . $tmp_senc['id'];
                             $this->db->query($sql);
                         } else {
                             $obj_live->delete_record($tmp_senc['id']);
                         }
                         //原本的节目中的录制ID必须更新为0
                         $sql = "UPDATE " . DB_PREFIX . "program SET record_id=0 WHERE id=" . $info['id'];
                         $this->db->query($sql);
                     }
                 }
             }
         }
         $ids .= $spa . $pid;
         $spa = ',';
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "program WHERE channel_id = " . $this->input['channel_id'] . " AND id NOT IN(" . $ids . ") and dates='" . $dates . "'";
     $q = $this->db->query($sql);
     $tmp_record_id = $tmp_space = '';
     while ($row = $this->db->fetch_array($q)) {
         if ($row['record_id']) {
             $tmp_record_id .= $tmp_space . $row['record_id'];
             $tmp_space = ',';
         }
     }
     if ($tmp_record_id) {
         $sql = "SELECT * FROM " . DB_PREFIX . "program_record WHERE id IN (" . $tmp_record_id . ")";
         $q = $this->db->query($sql);
         $tmp_record_id_plan = $tmp_record_id_program = 0;
         $space_plan = $space_program = '';
         while ($row = $this->db->fetch_array($q)) {
             if ($row['plan_id']) {
                 $tmp_record_id_plan .= $space_plan . $row['id'];
                 $space_plan = ',';
             } else {
                 $tmp_record_id_program .= $space_program . $row['id'];
                 $space_program = ',';
             }
         }
         if ($tmp_record_id_program) {
             $obj_live->delete_record($tmp_record_id_program);
         }
         if ($tmp_record_id_plan) {
             $sql = "UPDATE " . DB_PREFIX . "program_record SET program_id=0 WHERE id IN(" . $tmp_record_id_plan . ")";
             $this->db->query($sql);
         }
     }
     $sql = "DELETE FROM " . DB_PREFIX . "program WHERE channel_id = " . $this->input['channel_id'] . " AND id NOT IN(" . $ids . ") and dates='" . $dates . "'";
     $this->db->query($sql);
     $program = $this->get_program($this->input['channel_id'], $dates);
     //	file_put_contents('../cache/1.php',var_export($program,1));
     $this->addItem($program);
     $this->output();
 }
Beispiel #19
0
 /**
  * 获取频道信息
  * Enter description here ...
  * @param string $channel_ids
  */
 public function get_live($channel_ids)
 {
     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));
     return $channel_tmp;
 }
Beispiel #20
0
 /**
  * 根据频道,按时段显示节目,包含节目计划以及没有节目时自动填充
  * @name show
  * @access public
  * @author repheal
  * @category hogesoft
  * @copyright hogesoft
  * @param $channel_id int 频道ID
  * @return $program array 节目内容,键为日期,必须产生键,保证输出数据的完整性
  */
 function show()
 {
     $condition = $this->get_condition();
     $channel_id = intval($this->input['channel_id']);
     if (empty($channel_id)) {
         $this->errorOutput("未传入频道ID");
     }
     include_once ROOT_PATH . 'lib/class/live.class.php';
     $obj_newLive = new live();
     $channel = $obj_newLive->getChannelById($channel_id, -1);
     if (!$channel) {
         $this->errorOutput("此频道不存在或者已被删除!");
     } else {
         if (count($channel) == 1) {
             $channel = $channel[0];
         }
     }
     $channel_name = $channel['name'];
     $save_time = $channel['time_shift'];
     $start_time = strtotime(date("Y-m-d", TIMENOW - 3600 * $save_time) . " 00:00:00");
     $end_time = strtotime(date("Y-m-d", TIMENOW) . " 23:59:59");
     $condition = " AND channel_id=" . $channel_id . " AND  start_time>'" . $start_time . "' AND start_time<" . $end_time . "";
     $info = $this->obj->show($condition, $channel_id, $start_time, $end_time, $save_time);
     $date_type = array('00:00~09:00' => array('start' => '00:00:00', 'end' => '08:59:59'), '09:00~13:00' => array('start' => '09:00:00', 'end' => '12:59:59'), '13:00~19:00' => array('start' => '13:00:00', 'end' => '18:59:59'), '19:00~24:00' => array('start' => '19:00:00', 'end' => '23:59:59'));
     //串联单时移
     $dates = urldecode($this->input['dates']);
     $today = date('Y-m-d');
     $stime = urldecode($this->input['stime']);
     if ($dates > $today) {
         $day_offset = (strtotime($dates) - strtotime($today)) / 86400;
     }
     $i = $day_offset;
     if (!empty($info)) {
         $tmp_info = $info;
         $info = array();
         foreach ($tmp_info as $k => $v) {
             $info[$v['dates']][] = $v;
         }
         $program = array();
         foreach ($info as $ks => $vs) {
             $day_program = array();
             $v['dates'] = '';
             foreach ($vs as $k => $v) {
                 if ($dates > $today) {
                     $_dates = date('Y-m-d', strtotime($today) + 86400 * $i);
                 }
                 $v['starttime'] = date("Y-m-d H:i:s", $v['start_time']);
                 $v['endtime'] = date("Y-m-d H:i:s", $v['start_time'] + $v['toff']);
                 $v['start'] = date("H:i", $v['start_time']);
                 $v['channel_name'] = $channel_name;
                 //补齐频道id
                 $v['channel_id'] = $v['channel_id'] ? $v['channel_id'] : $channel_id;
                 foreach ($date_type as $key => $value) {
                     $start = strtotime($v['dates'] . " " . $value['start']);
                     $end = strtotime($v['dates'] . " " . $value['end']);
                     if ($v['start_time'] >= $start && $v['start_time'] < $end) {
                         if ($dates > $today) {
                             $v['starttime'] = $_dates . ' ' . date('H:i:s', $v['start_time']);
                             $v['endtime'] = $_dates . ' ' . date('H:i:s', $v['start_time'] + $v['toff']);
                             $v['dates'] = $_dates;
                             $v['start_time'] = strtotime($v['starttime']);
                             $v['weeks'] = date('W', $v['start_time']);
                             if (strtotime($_dates . ' ' . $stime) < $v['start_time'] + $v['toff'] && $i == $day_offset) {
                                 $v['display'] = 0;
                             }
                         }
                         $day_program[$key][] = $v;
                     }
                 }
             }
             if ($day_program) {
                 $program[$v['dates']] = $day_program;
             }
             $i--;
         }
         $this->addItem($program);
         $this->output();
     } else {
         $this->addItem();
         $this->output();
     }
 }
Beispiel #21
0
 function delete()
 {
     if (!$this->input['id']) {
         $this->errorOutput("未传入对象ID");
     }
     $id = intval($this->input['id']);
     $sql = "SELECT * FROM " . DB_PREFIX . "program_plan WHERE id=" . $id;
     $f = $this->db->query_first($sql);
     $channel_id = $f['channel_id'];
     include_once ROOT_PATH . 'lib/class/live.class.php';
     $newLive = new live();
     $channel = $newLive->getChannelById($channel_id, -1);
     $channel = $channel[0];
     if (!$channel['id']) {
         $this->errorOutput('该频道已经不存在!');
     }
     #####节点权限认证需要将节点数据放在nodes=>标志=>节点id=>节点所有父级节点
     $nodes = array();
     $nodes['_action'] = 'manage';
     $nodes['nodes'][$channel['id']] = $channel['id'];
     $this->verify_content_prms($nodes);
     #####节点权限认证需要将节点数据放在nodes=>标志=>节点id=>节点所有父级节点
     $info = $this->obj->delete(intval($this->input['id']));
     if (!$info) {
         $this->errorOutput("删除失败!");
     }
     if ($info['id']) {
         $this->addLogs('删除节目计划', $f, '', '', '', $f['program_name'] . $f['id']);
     }
     $this->addItem(array('id' => $info));
     $this->output();
 }
Beispiel #22
0
 /**
  * 获取频道列表
  * Enter description here ...
  */
 public function get_channel()
 {
     include_once ROOT_PATH . 'lib/class/live.class.php';
     $newLive = new live();
     $data = $newLive->getChannel();
     if ($data) {
         foreach ($data as $k => $v) {
             $arr[$v['id']] = $v['name'];
         }
     }
     $this->addItem($arr);
     $this->output();
 }
Beispiel #23
0
 function show($condition, $channel_id, $start_time, $end_times, $save_time = 0, $tf_by_endtime = false)
 {
     $sql = "SELECT * FROM " . DB_PREFIX . "program WHERE 1 " . $condition . " ORDER BY dates DESC,start_time ASC";
     $q = $this->db->query($sql);
     $program = array();
     include_once ROOT_PATH . 'lib/class/live.class.php';
     $newLive = new live();
     $channel_info = $newLive->getChannelById($channel_id, -1);
     if ($tf_by_endtime) {
         $dates = date("Y-m-d", $end_times);
     } else {
         $dates = date("Y-m-d", TIMENOW);
     }
     $start = strtotime(date("Y-m-d", $start_time) . " 00:00:00");
     $end = strtotime(date("Y-m-d", $end_times) . " 23:59:59") + 1;
     $channel_info = $channel_info[0];
     $com_time = 0;
     while ($row = $this->db->fetch_array($q)) {
         $start_time = $row['start_time'];
         $end_time = $row['start_time'] + $row['toff'];
         $dates = date("Y-m-d", $start_time);
         $start = strtotime(date("Y-m-d", $start_time) . " 00:00:00");
         $end = strtotime(date("Y-m-d", $end_time) . " 23:59:59");
         $display = $lave_time = $now_play = $zhi_play = 0;
         if (!$com_time && $start_time > $start) {
             $program[] = $this->getInfo($start, $start_time, $dates, $channel_id);
         }
         $row['start'] = date("H:i", $start_time);
         $row['end'] = date("H:i", $end_time);
         $row['zhi_play'] = $zhi_play;
         $row['now_play'] = $now_play;
         $row['display'] = $display;
         $row['lave_time'] = $lave_time;
         $row['is_program'] = 1;
         if (!$row['theme']) {
             $row['theme'] = '精彩节目';
         }
         $row['stime'] = date("H:i", $start_time);
         $com_time = $end_time;
         $program[] = $row;
     }
     $all_program = $program_plan = $program_plan_tmp = $program_plan_keys = array();
     if ($save_time) {
         $day = ceil($save_time / 24);
         if ($day > 1) {
             for ($i = 0; $i < $day; $i++) {
                 $tmp_dates = date('Y-m-d', strtotime($dates . ' 23:59:59') - $i * 86400);
                 $tmp = $this->getPlan($channel_id, $tmp_dates);
                 $program_plan_tmp = array_merge($program_plan_tmp, $tmp);
             }
         }
     } else {
         $program_plan_tmp = $this->getPlan($channel_id, $dates);
     }
     //hg_pre($program_plan_tmp);exit;
     if (!empty($program_plan_tmp)) {
         foreach ($program_plan_tmp as $k => $v) {
             $program_plan[strtotime($v['dates'] . ' ' . date('H:i:s', $v['start_time']))] = $v;
             $program_plan[strtotime($v['dates'] . ' ' . date('H:i:s', $v['start_time']))]['start_time'] = strtotime($v['dates'] . ' ' . date('H:i:s', $v['start_time']));
         }
         $program_plan_keys = array_keys($program_plan);
     }
     if (empty($program)) {
         $program = $this->copy_program($start, $end, $channel_id);
         if (defined('PROGRAM_DEFAULT') && !PROGRAM_DEFAULT && !empty($program_plan_tmp)) {
             $program = $program_plan_tmp;
             $length_tmp = count($program);
             foreach ($program as $k => $v) {
                 if ($k < $length_tmp - 1) {
                     $program[$k]['toff'] = strtotime($program[$k + 1]['dates'] . ' ' . $program[$k + 1]['start']) - strtotime($program[$k]['dates'] . ' ' . $program[$k]['start']);
                 } else {
                     $program[$k]['toff'] = strtotime($program[$k]['dates'] . ' 23:59:59') - strtotime($program[$k]['dates'] . ' ' . $program[$k]['start']);
                 }
             }
         }
     }
     //hg_pre($program);exit;
     foreach ($program as $key => $value) {
         $value['channel_name'] = $channel_info['name'];
         $value['channel_logo'] = array('rectangle' => $channel_info['logo_rectangle'], 'square' => $channel_info['logo_square']);
         $value['channel_id'] = $channel_info['id'];
         $value['toff'] = isset($program[$key + 1]) ? $program[$key + 1]['start_time'] - $program[$key]['start_time'] : $end - $program[$key]['start_time'];
         $value['end'] = date("H:i", $program[$key]['start_time'] + $value['toff']);
         //频道接管
         $channel_info['starttime'] = $value['start_time'];
         $channel_info['toff'] = $value['toff'];
         $value['m3u8'] = $this->set_m3u8($channel_info);
         $new_unit_program = array();
         if ($program_plan_keys && 0) {
             foreach ($program_plan_keys as $k => $v) {
                 if ($v > $value['start_time'] && $v < $value['start_time'] + $value['toff']) {
                     if ($v == $value['start_time']) {
                         if ($value['is_program']) {
                             unset($program_plan[$v], $program_plan_keys[$k]);
                             //	continue;
                         } else {
                             $value['theme'] = $program_plan[$v]['theme'];
                             $value['is_plan'] = 1;
                             $value['end'] = date("H:i", $value['start_time'] + $value['toff']);
                             $channel_info['starttime'] = $value['start_time'];
                             $channel_info['toff'] = $value['toff'];
                             $value['m3u8'] = $this->set_m3u8($channel_info);
                             $all_program[date("Y-m-d", $value['start_time'])][$value['start']] = $value;
                             unset($program_plan[$v], $program_plan_keys[$k]);
                             //	continue;
                         }
                     } else {
                         $new_unit_program = $value;
                         //是被切的节目单的上班部分的节目
                         $new_unit_program['toff'] = $program_plan[$v]['start_time'] - $new_unit_program['start_time'];
                         $new_unit_program['start'] = date("H:i", $new_unit_program['start_time']);
                         $new_unit_program['end'] = date("H:i", $new_unit_program['start_time'] + $new_unit_program['toff']);
                         $channel_info['starttime'] = $new_unit_program['start_time'];
                         $channel_info['toff'] = $new_unit_program['toff'];
                         $new_unit_program['m3u8'] = $this->set_m3u8($channel_info);
                         $all_program[date("Y-m-d", $new_unit_program['start_time'])][$new_unit_program['start']] = $new_unit_program;
                         //被切的下半部分,即为节目计划
                         $value['theme'] = $program_plan[$v]['theme'];
                         $value['toff'] = $value['toff'] - $new_unit_program['toff'];
                         $value['start_time'] = $program_plan[$v]['start_time'];
                         $value['is_plan'] = 1;
                         $value['id'] = $program_plan[$v]['start_time'];
                         $value['start'] = date("H:i", $value['start_time']);
                         $value['end'] = date("H:i", $value['start_time'] + $value['toff']);
                         //频道接管
                         $channel_info['starttime'] = $value['start_time'];
                         $channel_info['toff'] = $value['toff'];
                         $value['m3u8'] = $this->set_m3u8($channel_info);
                         //
                         $all_program[date("Y-m-d", $value['start_time'])][$value['start']] = $value;
                         unset($program_plan[$v], $program_plan_keys[$k]);
                         //	continue;
                     }
                 } else {
                     $all_program[date("Y-m-d", $value['start_time'])][$value['start']] = $value;
                 }
             }
         } else {
             $all_program[date("Y-m-d", $value['start_time'])][$value['start']] = $value;
         }
     }
     //	hg_pre($all_program);exit;
     $start_range = $end_range = 0;
     if ($save_time && 0) {
         if ($tf_by_endtime) {
             $end_range = $end_times;
             $start_range = $end_times - 3600 * ($save_time + 24);
         } else {
             $end_range = TIMENOW;
             $start_range = TIMENOW - 3600 * $save_time;
         }
     }
     $tmp_all_program = array();
     foreach ($all_program as $key => $value) {
         foreach ($value as $k => $v) {
             if ($start_range && $end_range) {
                 if ($v['start_time'] >= $start_range && $v['start_time'] + $v['toff'] <= $end_range) {
                     $tmp_all_program[] = $v;
                 }
             } else {
                 $tmp_all_program[] = $v;
             }
         }
     }
     $all_program = $tmp_all_program;
     //	hg_pre($all_program);exit;
     //排序
     $tmp_program = $program = array();
     $length = count($all_program);
     for ($i = 0, $j = $length; $i < $j; $i++) {
         for ($k = $j - 1; $k > $i; $k--) {
             if ($all_program[$k]['start_time'] < $all_program[$k - 1]['start_time']) {
                 list($all_program[$k - 1], $all_program[$k]) = array($all_program[$k], $all_program[$k - 1]);
             }
         }
         if ($all_program[$i]['start_time'] < TIMENOW) {
             if ($all_program[$i]['start_time'] < TIMENOW - $channel_info['time_shift'] * 3600) {
                 $all_program[$i]['display'] = 0;
             } else {
                 $all_program[$i]['display'] = 1;
             }
         }
         if ($all_program[$i]['start_time'] < TIMENOW && $all_program[$i]['start_time'] + $all_program[$i]['toff'] > TIMENOW) {
             $all_program[$i]['zhi_play'] = $is_zhi = empty($is_zhi) ? 1 : 0;
             $all_program[$i]['lave_time'] = $all_program[$i]['start_time'] + $all_program[$i]['toff'] - TIMENOW;
             if (!$play_time) {
                 $all_program[$i]['now_play'] = 1;
             }
         }
         if ($play_time && $all_program[$i]['start_time'] <= $play_time && $all_program[$i]['start_time'] + $all_program[$i]['toff'] > $play_time) {
             $all_program[$i]['now_play'] = 1;
             $all_program[$i]['lave_time'] = 1;
         }
         $all_program[$i]['stime'] = $all_program[$i]['start'];
         $program[] = $all_program[$i];
     }
     // hg_pre($program);exit;
     return $program;
 }
Beispiel #24
0
 public function getChannel()
 {
     include_once ROOT_PATH . 'lib/class/live.class.php';
     $newLive = new live();
     $channel = $newLive->getChannel(-1, 1);
     if (!empty($channel)) {
         $all_node = array();
         if ($this->user['prms']['app_prms'][APP_UNIQUEID]['nodes']) {
             $all_node = $this->user['prms']['app_prms'][APP_UNIQUEID]['nodes'];
         }
         foreach ($channel as $k => $v) {
             if ($this->user['group_type'] > MAX_ADMIN_TYPE) {
                 if ($this->user['prms']['app_prms'][APP_UNIQUEID]['nodes'] && in_array($v['id'], $all_node)) {
                     $this->addItem($v);
                 }
             } else {
                 $this->addItem($v);
             }
         }
         $this->output();
     }
 }
Beispiel #25
0
 function create()
 {
     $channel_id = intval($this->input['channel_id'] ? $this->input['channel_id'] : 0);
     if (empty($channel_id)) {
         $this->errorOutput('请传入频道ID');
     }
     include_once ROOT_PATH . 'lib/class/live.class.php';
     $newLive = new live();
     $channel = $newLive->getChannelById($channel_id, -1);
     $channel = $channel[0];
     if (!$channel['id']) {
         $this->errorOutput('该频道已经不存在!');
     }
     $start_time = strtotime(trim(urldecode($this->input['dates'])) . ' ' . trim(urldecode($this->input['start_time'])));
     $end_time = strtotime(trim(urldecode($this->input['dates'])) . ' ' . trim(urldecode($this->input['end_time'])));
     $toff = $end_time - $start_time;
     if ($toff < 0) {
         $toff = $toff + 24 * 3600;
     }
     $is_record = 0;
     //判断录制状态
     $is_out = 0;
     //判断是否超时
     if (is_array($this->input['week_day']) && $this->input['week_day']) {
         $is_record = 0;
         if ($start_time > TIMENOW + 5) {
             $week_now = date('N', TIMENOW);
             $week_num = $this->input['week_day'];
             if (in_array($week_now, $week_num)) {
                 $dates = date('Y-m-d', TIMENOW);
             }
             $i = 0;
             $next_day = $next_week_day = 0;
             foreach ($week_num as $k => $v) {
                 if (!$i && $v > $week_now) {
                     $next_day = $v;
                     $i = 1;
                 }
                 if (!$k) {
                     $next_week_day = $v;
                 }
             }
             if (!$next_day) {
                 $next_day = $next_week_day;
             }
             $next_week = $next_day - $week_now > 0 ? $next_day - $week_now : $next_day - $week_now + 7;
             $dates = date('Y-m-d', TIMENOW + $next_week * 86400);
             $start_time = strtotime($dates . ' ' . trim(urldecode($this->input['start_time'])));
             $end_time = strtotime($dates . ' ' . trim(urldecode($this->input['end_time'])));
         }
         $week_day = serialize($this->input['week_day']);
     } else {
         //单天
         if ($start_time > TIMENOW) {
             $is_record = 0;
             $is_out = 0;
         } else {
             $is_record = 2;
             $is_out = 1;
         }
     }
     $sql = "SELECT channel_id, start_time, toff FROM " . DB_PREFIX . "program_record WHERE channel_id =" . $channel_id . " AND " . $start_time . "=start_time and " . $end_time . "=(start_time+toff) AND week_day='" . $week_day . "'";
     $f = $this->db->query_first($sql);
     if ($f['channel_id']) {
         $this->errorOutput('此段时间已经有节目被录制!');
     }
     $columnid = $this->input['column_id'] ? $this->input['column_id'] : '';
     $column_name = $this->input['column_name'] ? $this->input['column_name'] : '';
     $info = array('channel_id' => $channel_id, 'start_time' => $start_time, 'title' => $this->input['title'] ? $this->input['title'] : '', 'toff' => $toff, 'week_day' => $week_day ? $week_day : '', 'item' => intval($this->input['item']), 'columnid' => $columnid, 'column_name' => $column_name, 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'is_mark' => $this->input['is_mark'], 'ip' => hg_getip(), 'force_codec' => $this->input['force_codec'] ? 1 : 0, 'is_record' => $is_record, 'audit_auto' => $this->input['audit_auto'], 'is_out' => $is_out, 'user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name'], 'org_id' => $this->user['org_id'], 'appid' => $this->user['appid'], 'appname' => $this->user['display_name']);
     if (!$info['channel_id'] || !$info['start_time']) {
         $this->errorOutput(OBJECT_NULL);
     }
     if (empty($toff)) {
         $this->errorOutput('录制时长不能为零!');
     }
     $server = $this->_get_server();
     if (empty($server)) {
         $this->errorOutput('录制服务不存在or有误~');
     }
     $info['server_id'] = $server['id'];
     $ret = $this->obj->create($info);
     $info['id'] = $ret['id'];
     $this->setXmlNode('program_record', 'info');
     $this->addItem($ret);
     $this->output();
 }