Example #1
0
 public function __construct()
 {
     $this->_table_prefix = '#__' . TABLE_PREFIX . '_';
     $this->_db = JFactory::getDbo();
     statistic::reshop_visitors();
     statistic::reshop_pageview();
 }
Example #2
0
 /**
  * 创建频道 (当tvie为open时开始创建,创建顺序:延时层-->切播层-->输出层-->本地)
  * @name create
  * @access public
  * @author lijiaying
  * @category hogesoft
  * @copyright hogesoft
  * @param $name string 频道名称
  * @param $code string 台号
  * @param $code_2 string 台号(修改用)
  * @param $logo string 台标
  * @param $stream_id int 信号ID
  * @param $delay_id int 延时层ID
  * @param $chg_id int 切播层ID
  * @param $ch_id int 输出层ID
  * @param $save_time int 回看时间(小时)
  * @param $live_delay int 延时时间 (分钟)
  * @param $is_live tinyint 是否播控 (1-是 0-否)
  * @param $stream_name string 流名称	not null
  * @param $main_stream_name string 主信号名称
  * @param $beibo string 备播信号  (暂最多支持2个)
  * @param $uri_in_num tinyint 输入流数目
  * @param $uri_out_num tinyint 输出流数目
  * @param $level tinyint 频道层数
  * @param $open_ts tinyint 是否支持手机流 (1-是 0-否)
  * @param $record_time int 自动收录节目时间偏差设置 (±30秒 大于30秒就等于30秒,小于-30秒就等于-30秒)
  * @param $audio_only tinyint 记录是否是音频 (1-是 0-否 )
  * @param $create_time int 创建时间
  * @param $update_time int 更新时间
  * @param $ip string 创建者ip
  * @param $channel_id int 频道ID
  * @param $delay_stream_id int 延时层流ID
  * @param $chg_stream_id int 切播层流ID
  * @param $out_stream_id int 输出层流ID
  * @param $stream_name string 流名称
  * @param $out_stream_name string 输出流名称
  * @param $is_main tinyint 是否主流 (1-是 0-否)
  * @param $bitrate int 码流
  * @param $flag_stream 标识(单流改为多流)
  * @param $drm tyinint 防盗链设置 (1-启用  0-关闭)	
  * @param $logo_info array logo素材信息
  * @return $ret['id'] int 频道ID
  * @include tvie_api.php
  */
 public function create()
 {
     $name = urldecode($this->input['name']);
     if (!$name) {
         $this->errorOutput('频道名称不能为空!');
     }
     $code = urldecode($this->input['code']);
     if (!$code) {
         $this->errorOutput('台号不能为空!');
     }
     $stream_id = $this->input['stream_id'] ? intval($this->input['stream_id']) : 0;
     $save_time = $this->input['save_time'] ? intval($this->input['save_time']) : 0;
     //回看时间
     $live_delay = $this->input['live_delay'] ? intval($this->input['live_delay']) : 0;
     //延时时间
     $is_live = intval($this->input['is_live']);
     //是否播控    1表示有播控  0表示无播控
     $drm = intval($this->input['drm']);
     //防盗链设置
     $stream_name = $this->input['stream_name'];
     if (!$stream_name) {
         $this->errorOutput('至少为频道选择一条流');
     }
     $main_stream_name = $this->input['main_stream_name'];
     if ($this->input['beibo']) {
         if ($is_live && count($this->input['beibo']) > 2) {
             $this->errorOutput('最多两个备播信号,请重新选择!');
         }
         foreach ($this->input['beibo'] as $value) {
             $beibo_key_value = explode('#', urldecode($value));
             $beibo[$beibo_key_value[0]] = $beibo_key_value[1];
         }
         $beibo = serialize($beibo);
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "stream WHERE id=" . $stream_id;
     $streams = $this->db->query_first($sql);
     if (!$streams) {
         $this->errorOutput('所选信号不存在,请重新选择');
     }
     $other_info = unserialize($streams['other_info']);
     if (!$other_info) {
         $this->errorOutput('所选信号没有信号流');
     }
     $stream_name_arr = array();
     foreach ($other_info as $v) {
         $stream_name_arr[$v['name']] = $v;
     }
     $stream_info = array();
     foreach ($stream_name as $n) {
         if ($stream_name_arr[$n]) {
             $stream_info[] = $stream_name_arr[$n];
         }
     }
     if (!$stream_info) {
         $this->errorOutput('所选流不存在或已被删除');
     }
     //输入流的数目
     $uri_in_num = count($stream_name);
     //层数目
     if ($uri_in_num > 1) {
         $level = 1;
     } else {
         if (!$is_live) {
             $level = 1;
         } elseif (!$live_delay) {
             $level = 2;
         } else {
             $level = 3;
         }
     }
     //选择流与选择信号流的差集
     $diff_stream_name = array_diff($stream_name_arr, $stream_name);
     //开启tvie
     if ($this->settings['tvie']['open']) {
         include CUR_CONF_PATH . 'lib/tvie_api.php';
         $delay_tvie = new TVie_api($this->settings['tvie']['up_stream_server']);
         $delay_type = 'normal_virtual';
         $chg_tvie = $delay_tvie;
         $out_tvie = new TVie_api($this->settings['tvie']['stream_server']);
         $first_stream = $stream_info[0];
         //获取主信号流
         unset($stream_info[0]);
         $delay_stream_uri = hg_get_stream_url($this->settings['tvie']['up_stream_server'], array('channel' => $streams['ch_name'], 'stream_name' => $first_stream['name']), 'channels', 'tvie://');
         if (is_array($first_stream['backstore'])) {
             $backstore = implode(',', $first_stream['backstore']);
         } else {
             $backstore = $first_stream['backstore'];
         }
         //32创建延时层
         $delay_channel = $delay_tvie->create_channel('delay_' . $code, $name, $streams['server_id'], 1, $live_delay, $delay_type, $first_stream['name'], $first_stream['recover_cache'], $first_stream['source_name'], $delay_stream_uri, $first_stream['bitrate'], $first_stream['drm'], $first_stream['wait_relay'], $backstore);
         $delay_channel_id = $delay_channel['channel_id'];
         if (!$delay_channel_id) {
             $this->errorOutput('频道创建失败,原因:' . serialize($delay_channel) . $delay_channel['message'] . $delay_channel['errors']);
         }
         $ret_delay_channel_info = $delay_tvie->get_channel_by_id($delay_channel_id);
         $ret_delay_stream_info = $ret_delay_channel_info['channel']['streams'];
         $first_delay_stream_id = $ret_delay_stream_info[0]['id'];
         //延时层创建流
         $stream_ids = array('delay_stream_id' => array($first_stream['name'] => $first_delay_stream_id));
         if ($stream_info) {
             foreach ($stream_info as $key => $value) {
                 $delay_uri = hg_get_stream_url($this->settings['tvie']['up_stream_server'], array('channel' => $streams['ch_name'], 'stream_name' => $value['name']), 'channels', 'tvie://');
                 if (is_array($value['backstore'])) {
                     $backstore = implode(',', $value['backstore']);
                 } else {
                     $backstore = $value['backstore'];
                 }
                 $ret_delay_stream = $delay_tvie->create_channel_stream($value['name'], $value['recover_cache'], $value['source_name'], $delay_uri, $value['drm'], $backstore, $value['wait_relay'], 0, $value['bitrate'], $delay_channel_id);
                 if ($ret_delay_stream['stream_id']) {
                     $stream_ids['delay_stream_id'][$value['name']] = $ret_delay_stream['stream_id'];
                 }
             }
         }
         //创建切播层
         $chg_type = 'normal_virtual';
         if (!$live_delay) {
             //没有延时,上游流地址直接是信号流地址
             $chg_stream_uri = hg_get_stream_url($this->settings['tvie']['up_stream_server'], array('channel' => $streams['ch_name'], 'stream_name' => $first_stream['name']));
         } else {
             //有延时,上游流地址延迟层流地址
             $chg_stream_uri = hg_get_stream_url($this->settings['tvie']['up_stream_server'], array('channel' => 'delay_' . $code, 'stream_name' => $first_stream['name']));
         }
         if (is_array($first_stream['backstore'])) {
             $backstore = implode(',', $first_stream['backstore']);
         } else {
             $backstore = $first_stream['backstore'];
         }
         //32创建切播层
         $chg_channel = $chg_tvie->create_channel('chg_' . $code, $name, $streams['server_id'], 0, 0, $chg_type, $first_stream['name'], $first_stream['recover_cache'], $first_stream['source_name'], $chg_stream_uri, $first_stream['bitrate'], $first_stream['drm'], $first_stream['wait_relay'], $backstore);
         $chg_channel_id = $chg_channel['channel_id'];
         if (!$chg_channel_id) {
             $delay_tvie->delete_channel($delay_channel_id);
             $this->errorOutput('频道创建失败,原因:' . $chg_channel['message'] . $chg_channel['errors']);
         }
         $ret_chg_channel_info = $chg_tvie->get_channel_by_id($chg_channel_id);
         $ret_chg_stream_info = $ret_chg_channel_info['channel']['streams'];
         $first_chg_stream_id = $ret_chg_stream_info[0]['id'];
         $stream_ids['chg_stream_id'][$first_stream['name']] = $first_chg_stream_id;
         //创建切播层流
         $chg_url = array();
         foreach ($stream_info as $key => $value) {
             if (!$live_delay) {
                 //没有延时,上游流地址直接是信号流地址
                 $chg_uri = hg_get_stream_url($this->settings['tvie']['up_stream_server'], array('channel' => $streams['ch_name'], 'stream_name' => $value['name']), 'channels', 'tvie://');
                 $chg_uri_http = hg_get_stream_url($this->settings['tvie']['up_stream_server'], array('channel' => $streams['ch_name'], 'stream_name' => $value['name']));
             } else {
                 //有延迟,上游流地址是延迟层流地址
                 $chg_uri = hg_get_stream_url($this->settings['tvie']['up_stream_server'], array('channel' => 'delay_' . $code, 'stream_name' => $value['name']), 'channels', 'tvie://');
                 $chg_uri_http = hg_get_stream_url($this->settings['tvie']['up_stream_server'], array('channel' => 'delay_' . $code, 'stream_name' => $value['name']));
             }
             $chg_url['tvie'][] = $chg_uri;
             $chg_url['http'][] = $chg_uri_http;
             if (is_array($value['backstore'])) {
                 $backstore = implode(',', $value['backstore']);
             } else {
                 $backstore = $value['backstore'];
             }
             $ret_chg_stream = $chg_tvie->create_channel_stream($value['name'], $value['recover_cache'], $value['source_name'], $chg_uri_http, $value['drm'], $backstore, $value['wait_relay'], 0, $value['bitrate'], $chg_channel_id);
             if ($ret_chg_stream['stream_id']) {
                 $stream_ids['chg_stream_id'][$value['name']] = $ret_chg_stream['stream_id'];
             }
         }
         //32延时层或者切播层创建成功后,再向21创建输出层
         $out_type = 'normal_virtual';
         if (!$is_live) {
             //无切播层,直接信号流地址
             $out_stream_uri = hg_get_stream_url($this->settings['tvie']['up_stream_server'], array('channel' => $streams['ch_name'], 'stream_name' => $first_stream['name']), 'channels', 'tvie://');
         } else {
             //有切播层,切播层流地址
             $out_stream_uri = hg_get_stream_url($this->settings['tvie']['up_stream_server'], array('channel' => 'chg_' . $code, 'stream_name' => $first_stream['name']), 'channels', 'tvie://');
         }
         if ($this->input['open_ts']) {
             $first_stream['backstore'] = array(0 => 'flv', 1 => 'ts');
         }
         if (is_array($first_stream['backstore'])) {
             $backstore = implode(',', $first_stream['backstore']);
         } else {
             $backstore = $first_stream['backstore'];
         }
         $out_live_delay = $live_delay;
         if ($level != 1) {
             $out_live_delay = 0;
         } else {
             if (!$save_time) {
                 $save_time = 1;
             }
         }
         //创建频道
         $out_channel = $out_tvie->create_channel($code, $name, $streams['server_id'], $save_time, $out_live_delay, $out_type, $first_stream['name'], $first_stream['recover_cache'], $first_stream['source_name'], $out_stream_uri, $first_stream['bitrate'], $drm, $first_stream['wait_relay'], $backstore);
         $out_channel_id = $out_channel['channel_id'];
         //返回频道id
         if (!$out_channel_id) {
             //删除切播层、延时层
             $delay_tvie->delete_channel($delay_channel_id);
             $chg_tvie->delete_channel($chg_channel_id);
             $this->errorOutput('频道创建失败,原因:' . $out_channel['message'] . $out_channel['errors']);
         }
         $ret_out_channel_info = $out_tvie->get_channel_by_id($out_channel_id);
         $ret_out_stream_info = $ret_out_channel_info['channel']['streams'];
         $first_out_stream_id = $ret_out_stream_info[0]['id'];
         $stream_ids['out_stream_id'][$first_stream['name']] = $first_out_stream_id;
         //创建输出层流
         foreach ($stream_info as $key => $value) {
             if (!$is_live) {
                 //无切播层,直接信号流地址
                 $out_uri = hg_get_stream_url($this->settings['tvie']['up_stream_server'], array('channel' => $streams['ch_name'], 'stream_name' => $value['name']), 'channels', 'tvie://');
             } else {
                 //有切播层,切播层流地址
                 $out_uri = hg_get_stream_url($this->settings['tvie']['up_stream_server'], array('channel' => 'chg_' . $code, 'stream_name' => $value['name']), 'channels', 'tvie://');
             }
             if ($this->input['open_ts']) {
                 $value['backstore'] = array(0 => 'flv', 1 => 'ts');
             }
             if (is_array($value['backstore'])) {
                 $backstore = implode(',', $value['backstore']);
             } else {
                 $backstore = $value['backstore'];
             }
             $ret_out_stream = $out_tvie->create_channel_stream($value['name'], $value['recover_cache'], $value['source_name'], $out_uri, $drm, $backstore, $value['wait_relay'], 0, $value['bitrate'], $out_channel_id);
             if ($ret_out_stream['stream_id']) {
                 $stream_ids['out_stream_id'][$value['name']] = $ret_out_stream['stream_id'];
             }
         }
     }
     //录制节目时间偏差设置
     if ($this->input['record_time'] >= 0) {
         if ($this->input['record_time'] > 30) {
             $record_time = 30;
         } else {
             $record_time = $this->input['record_time'];
         }
     } else {
         if ($this->input['record_time'] < -30) {
             $record_time = -30;
         } else {
             $record_time = $this->input['record_time'];
         }
     }
     $info = array('user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name'], 'code' => $code, 'code_2' => $code, 'name' => $name, 'delay_id' => $delay_channel_id, 'chg_id' => $chg_channel_id, 'ch_id' => $out_channel_id, 'is_live' => $is_live, 'drm' => $drm, 'open_ts' => $this->input['open_ts'], 'uri_in_num' => $uri_in_num, 'uri_out_num' => $uri_out_num, 'save_time' => $save_time ? $save_time : 0, 'live_delay' => $live_delay ? $live_delay : 0, 'stream_display_name' => $streams['s_name'], 'stream_mark' => $streams['ch_name'], 'level' => $level, 'beibo' => $beibo, 'stream_id' => $stream_id, 'main_stream_name' => $main_stream_name[0], 'stream_info_all' => serialize($stream_name), 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip(), 'record_time' => $record_time, 'audio_only' => $first_stream['audio_only']);
     $createsql = "INSERT INTO " . DB_PREFIX . "channel SET ";
     $space = "";
     foreach ($info as $key => $value) {
         $createsql .= $space . $key . "=" . "'" . $value . "'";
         $space = ",";
     }
     $ret = array();
     $this->db->query($createsql);
     $ret['id'] = $this->db->insert_id();
     //插入排序id
     //插入工作量统计
     $statistic = new statistic();
     $statistics_data = array('content_id' => $ret['id'], 'contentfather_id' => '', 'type' => 'insert', 'user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name'], 'app_uniqueid' => APP_UNIQUEID, 'module_uniqueid' => MODULE_UNIQUEID, 'before_data' => '', 'last_data' => $name, 'num' => 1);
     $statistic->insert_record($statistics_data);
     if ($_FILES['files']['tmp_name']) {
         include_once ROOT_PATH . 'lib/class/material.class.php';
         $this->mMaterial = new material();
         $file['Filedata'] = $_FILES['files'];
         $material = $this->mMaterial->addMaterial($file, $ret['id'], intval($this->input['mmid']), 'img4');
         $logo_info['id'] = $material['id'];
         $logo_info['type'] = $material['type'];
         $logo_info['server_mark'] = $material['server_mark'];
         $logo_info['filepath'] = $material['filepath'];
         $logo_info['name'] = $material['name'];
         $logo_info['filename'] = $material['filename'];
         $logo_info['url'] = $material['url'];
     }
     $sql = "UPDATE " . DB_PREFIX . "channel SET order_id = " . $ret['id'] . ", logo_info = '" . serialize($logo_info) . "' WHERE id=" . $ret['id'];
     $this->db->query($sql);
     //流信息
     $stream_info[] = $first_stream;
     $i = 0;
     $stream_num = count($stream_info) - 1;
     foreach ($stream_info as $k => $v) {
         $main_stream_info = array('channel_id' => $ret['id'], 'stream_id' => $stream_id, 'delay_stream_id' => $stream_ids['delay_stream_id'][$v['name']], 'chg_stream_id' => $stream_ids['chg_stream_id'][$v['name']], 'out_stream_id' => $stream_ids['out_stream_id'][$v['name']], 'stream_name' => $v['name'], 'out_stream_name' => $v['name'], 'is_main' => $main_stream_name[0] == $v['name'] ? 1 : 0, 'bitrate' => $v['bitrate'], 'flag_stream' => '', 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip());
         $cresql = "INSERT INTO " . DB_PREFIX . "channel_stream SET ";
         $space = "";
         foreach ($main_stream_info as $key => $value) {
             $cresql .= $space . $key . "=" . "'" . $value . "'";
             $space = ",";
         }
         $this->db->query($cresql);
         $i++;
     }
     $this->setXmlNode('channel', 'info');
     $this->addItem($ret['id']);
     $this->output();
 }
Example #3
0
 public function pushStat()
 {
     if (!isset($_SESSION['old_logged_in_value'])) {
         $_SESSION['old_logged_in_value'] = false;
     }
     if (defined("DB_DRIVER") && DB_DRIVER == "xml") {
         return;
     }
     if (!$this->enabled || $this->isStatCollected) {
         return false;
     }
     if (defined("STAT_DISABLE")) {
         if (STAT_DISABLE) {
             return false;
         }
     }
     $this->isStatCollected = true;
     $element_id = cmsController::getInstance()->getCurrentElementId();
     if ($element = umiHierarchy::getInstance()->getElement($element_id)) {
         $tags = $element->getValue("tags");
     } else {
         return false;
     }
     $stat = new statistic();
     $stat->setReferer(getServer('HTTP_REFERER'));
     $stat->setUri(getServer('REQUEST_URI'));
     $stat->setServerName(getServer('HTTP_HOST') ? getServer('HTTP_HOST') : getServer('SERVER_NAME'));
     $stat->setRemoteAddr(getServer('REMOTE_ADDR'));
     if ($users_inst = cmsController::getInstance()->getModule("users")) {
         if ($users_inst->is_auth() != $_SESSION['old_logged_in_value']) {
             $stat->doLogin();
         }
         $_SESSION['old_logged_in_value'] = $users_inst->is_auth();
     }
     if (is_array($tags)) {
         foreach ($tags as $tag) {
             $stat->event($tag);
         }
     }
     $stat->run();
 }
Example #4
0
 public function update()
 {
     if (!$this->input['id']) {
         $this->errorOutput(NOID);
     }
     $id = intval($this->input['id']);
     $new_column_ids = $this->input['column_id'];
     //查询修改视频之前已经发布到的栏目
     $sql = "select * from " . DB_PREFIX . "vodinfo where id = " . $id;
     $q = $this->db->query_first($sql);
     $pre_data = $q;
     $q['column_id'] = unserialize($q['column_id']);
     $ori_column_id = array();
     if (is_array($q['column_id'])) {
         $ori_column_id = array_keys($q['column_id']);
     }
     $column_id = $this->publish_column->get_columnname_by_ids('id,name', $this->input['column_id']);
     $column_id = serialize($column_id);
     $this->input['column_id'] = $column_id;
     /*         * *******************************权限控制*************************************** */
     if ($this->user['group_type'] > MAX_ADMIN_TYPE) {
         if ($this->input['vod_sort_id']) {
             $sql = 'SELECT id, parents FROM ' . DB_PREFIX . 'vod_media_node WHERE id IN(' . $this->input['vod_sort_id'] . ')';
             $query = $this->db->query($sql);
             while ($row = $this->db->fetch_array($query)) {
                 $data['nodes'][$row['id']] = $row['parents'];
             }
         }
         $data['id'] = $id;
         $data['user_id'] = $q['user_id'];
         $data['org_id'] = $q['org_id'];
         $data['column_id'] = $new_column_ids;
         $data['published_column_id'] = implode(',', $ori_column_id);
         $this->verify_content_prms($data);
         $this->check_weight_prms(intval($this->input['weight']), $pre_data['weight']);
     }
     /*         * *******************************权限控制*************************************** */
     $this->change_pic_server();
     //图片处理
     $info = array('copyright', 'author', 'comment', 'title', 'subtitle', 'keywords', 'vod_sort_id', 'source', 'column_id', 'weight', 'tcolor', 'isbold', 'isitalic', 'template_sign', 'iscomment', 'is_praise', 'hostwork', 'video_path', 'click_count');
     $update_info = array();
     //用于存放更新之后的信息,用于版本控制
     $fields = ' SET  ';
     foreach ($info as $k => $v) {
         if (!isset($this->input[$v])) {
             continue;
         }
         if (in_array($v, array('title', 'comment', 'subtitle', 'keywords', 'author', 'template_sign', 'iscomment', 'is_praise', 'hostwork', 'video_path', 'click_count'))) {
             $this->input[$v] = trim($this->input[$v]);
         }
         $fields .= $v . ' = \'' . $this->input[$v] . '\',';
     }
     $fields = trim($fields, ',');
     $updatesql = "UPDATE " . DB_PREFIX . 'vodinfo ' . $fields . '  WHERE  id = ' . $id;
     //更新编目
     $this->catalog('update', $id, 'vodinfo', $q['catalog']);
     $this->db->query($updatesql);
     if ($this->db->affected_rows()) {
         $append_update_data = array('update_time' => TIMENOW);
         $sql = " UPDATE " . DB_PREFIX . "vodinfo SET ";
         foreach ($append_update_data as $k => $v) {
             $sql .= " {$k} = '{$v}',";
         }
         $sql = trim($sql, ',');
         $sql .= " WHERE id = '" . $id . "'";
         $this->db->query($sql);
     } else {
         $this->addItem('success');
         $this->output();
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "vodinfo  WHERE id =" . $id;
     $info = $this->db->query_first($sql);
     /*************************此处是为了解决vod_sort_id 编程栏目的id这个bug暂时不清楚为什么会有这种情况的***/
     if ($info['vod_sort_id']) {
         $_sql = "SELECT * FROM " . DB_PREFIX . "vod_media_node WHERE id = '" . $info['vod_sort_id'] . "'";
         if (!$this->db->query_first($_sql)) {
             $_sql = "UPDATE " . DB_PREFIX . "vodinfo SET vod_sort_id = '" . $info['vod_leixing'] . "' WHERE id = '" . $id . "'";
             $this->db->query($_sql);
             $info['vod_sort_id'] = $info['vod_leixing'];
         }
     }
     /******************************************************************************************/
     $this->addLogs('更新视频', $pre_data, $info, $info['title']);
     $this->index_search($info, 'update');
     //插入工作量统计
     $statistic = new statistic();
     $statistics_data = array('content_id' => $id, 'contentfather_id' => '', 'type' => 'update', 'user_id' => $info['user_id'], 'user_name' => $info['addperson'], 'before_data' => '', 'last_data' => $info['title'], 'num' => 1);
     $statistic->insert_record($statistics_data);
     $sql = "SELECT * FROM " . DB_PREFIX . "vodinfo  WHERE id =" . $id;
     $info = $this->db->query_first($sql);
     $update_data = serialize($info);
     //将更改的信息进行串行化
     $info['format_duration'] = hg_timeFormatChinese($info['duration']);
     //时长
     $info['resolution'] = $info['width'] . '*' . $info['height'];
     //分辨率
     $info['vod_leixing'] = $this->settings['video_upload_type'][$info['vod_leixing']];
     $info['totalsize'] = hg_fetch_number_format($info['totalsize'], 1);
     $audio_status = check_str('L', 'R', $info['audio_channels']);
     switch ($audio_status) {
         case 0:
             $info['audio_channels'] = '无';
             break;
         case 1:
             $info['audio_channels'] = '右';
             break;
         case 2:
             $info['audio_channels'] = '左';
             break;
         case 3:
             $info['audio_channels'] = '左右';
             break;
         default:
             $info['audio_channels'] = '无';
             break;
     }
     //发布系统
     $sql = "SELECT * FROM " . DB_PREFIX . "vodinfo WHERE id = " . intval($this->input['id']);
     $ret = $this->db->query_first($sql);
     //更改视频后发布的栏目
     $ret['column_id'] = unserialize($ret['column_id']);
     $new_column_id = array();
     if (is_array($ret['column_id'])) {
         $new_column_id = array_keys($ret['column_id']);
     }
     //记录发布库栏目分发表
     $this->update_pub_column(intval($this->input['id']), implode(',', $new_column_id));
     //记录发布库栏目分发表
     if (intval($ret['status']) == 2) {
         if (!empty($ret['expand_id'])) {
             $del_column = array_diff($ori_column_id, $new_column_id);
             if (!empty($del_column)) {
                 publish_insert_query($ret, 'delete', $del_column);
             }
             $add_column = array_diff($new_column_id, $ori_column_id);
             if (!empty($add_column)) {
                 publish_insert_query($ret, 'insert', $add_column);
             }
             $same_column = array_intersect($ori_column_id, $new_column_id);
             if (!empty($same_column)) {
                 publish_insert_query($ret, 'update', $same_column);
             }
         } else {
             if ($new_column_id) {
                 $op = "insert";
                 publish_insert_query($ret, $op);
             }
         }
     } else {
         if (!empty($ret['expand_id'])) {
             $op = "delete";
             publish_insert_query($ret, $op);
         }
     }
     /* 返回数据 */
     $sql = " SELECT * FROM " . DB_PREFIX . "vod_media_node WHERE id = '" . $info['vod_sort_id'] . "'";
     $sort_arr = $this->db->query_first($sql);
     if ($sort_arr['id']) {
         $info['vod_sort_id'] = $sort_arr['name'];
         $info['vod_sort_color'] = $sort_arr['color'];
     } else {
         $info['vod_sort_id'] = $this->settings['video_upload_type'][$info['vod_leixing']];
         $info['vod_sort_color'] = $this->settings['video_upload_type_attr'][$info['vod_leixing']];
     }
     $collects = unserialize($info['collects']);
     if ($collects) {
         $info['collects'] = $collects;
     } else {
         $info['collects'] = '';
     }
     $img_arr = $info['img_info'] = unserialize($info['img_info']);
     $info['img'] = $img_arr['host'] . $img_arr['dir'] . '80x60/' . $img_arr['filepath'] . $img_arr['filename'];
     $rgb = $info['bitrate'] / 100;
     if ($rgb < 10) {
         $info['bitrate_color'] = $this->settings['bitrate_color'][$rgb];
     } else {
         $info['bitrate_color'] = $this->settings['bitrate_color'][9];
     }
     if ($info['starttime']) {
         $info['starttime'] = '(' . date('Y-m-d', $r['starttime']) . ')';
     } else {
         $info['starttime'] = '';
     }
     $info['duration'] = time_format($info['duration']);
     $info['status_display'] = intval($info['status']);
     $info['status'] = $this->settings['video_upload_status'][$info['status']];
     $info['create_time'] = date('Y-m-d H:i', $info['create_time']);
     $info['update_time'] = date('Y-m-d H:i', $info['update_time']);
     $info['pub'] = unserialize($info['column_id']);
     $info['pub_url'] = unserialize($info['column_url']);
     $info['row_id'] = $info['id'];
     $this->addItem($info);
     $this->output();
 }
Example #5
0
 /**
  * 删除频道 (频道及其所属频道 节目单 , 节目单计划 , 串联单 , 串联单计划 , 自动收录, 屏蔽节目, 信号流信息)
  * 删除顺序:延时层-->切播层-->输出层-->本地 	(只有每一步成功后在进行下一步删除)
  * @name delete
  * @access public
  * @author lijiaying
  * @category hogesoft
  * @copyright hogesoft
  * @param $id int 频道id
  * @return $ret['id'] int 删除频道的ID 
  * @include tvie_api.php
  */
 function delete()
 {
     $id = urldecode($this->input['id']);
     if (!$id) {
         $this->errorOutput('该频道不存在或已被删除');
     }
     $sql = "SELECT user_id,user_name,delay_id,chg_id,ch_id FROM " . DB_PREFIX . "channel WHERE id IN(" . $id . ")";
     $q = $this->db->query($sql);
     $ch_id_all = $delay_id_all = $chg_id_all = array();
     while ($row = $this->db->fetch_array($q)) {
         $ch_id_all[] = $row['ch_id'];
         $delay_id_all[] = $row['delay_id'];
         $chg_id_all[] = $row['chg_id'];
         $ch_user_id[] = $row['user_id'];
         $ch_user_name[] = $row['user_name'];
     }
     if ($this->settings['tvie']['open']) {
         include CUR_CONF_PATH . 'lib/tvie_api.php';
         $tvie_api = new TVie_api($this->settings['tvie']['stream_server']);
         $virtual_api = new TVie_api($this->settings['tvie']['up_stream_server']);
         if ($delay_id_all) {
             foreach ($delay_id_all as $delay_id) {
                 //32延时层
                 $delay_channel_info = $virtual_api->get_channel_by_id($delay_id);
                 //查询的频道信息
                 $delay_stream_info = $delay_channel_info['channel']['streams'];
                 if (!$delay_id) {
                     $this->errorOutput('删除失败请重试');
                 }
                 /*	foreach($delay_stream_info as $key => $value)
                 			{
                 				$ret = $virtual_api->delete_stream($value['id']);			//删除流信息
                 			}
                 			*/
                 if ($delay_id) {
                     $ret_delay = $virtual_api->delete_channel($delay_id);
                     //删除频道
                 }
             }
         }
         if ($chg_id_all && $ret_delay['message'] == 'Handled') {
             foreach ($chg_id_all as $chg_id) {
                 //32切播层
                 $chg_channel_info = $virtual_api->get_channel_by_id($chg_id);
                 //查询的频道信息
                 $chg_stream_info = $chg_channel_info['channel']['streams'];
                 if (!$chg_id) {
                     $this->errorOutput('删除失败请重试');
                 }
                 /*foreach($chg_stream_info as $key => $value)
                 		{
                 			$ret = $virtual_api->delete_stream($value['id']);			//删除流信息
                 		}*/
                 if ($chg_id) {
                     $ret_chg = $virtual_api->delete_channel($chg_id);
                     //删除频道
                 }
             }
         }
         if ($ch_id_all && $ret_chg['message'] == 'Handled') {
             foreach ($ch_id_all as $ch_id) {
                 //21输出层
                 $channel_info = $tvie_api->get_channel_by_id($ch_id);
                 //查询的频道信息
                 $stream_info = $channel_info['channel']['streams'];
                 if (!$ch_id) {
                     $this->errorOutput('删除失败请重试');
                 }
                 /*foreach($stream_info as $key => $value)
                 		{
                 			$ret = $tvie_api->delete_stream($value['id']);			//删除流信息
                 		}*/
                 if ($ch_id) {
                     $ret_out = $tvie_api->delete_channel($ch_id);
                     //删除频道
                 }
             }
         }
     }
     if ($ret_out['message'] == 'Handled') {
         //删除节目单
         $sql = "DELETE FROM " . DB_PREFIX . "program WHERE channel_id IN (" . $id . ")";
         $this->db->query($sql);
         //删除自动收录
         $sql = "DELETE FROM " . DB_PREFIX . "program_record WHERE channel_id IN (" . $id . ")";
         $this->db->query($sql);
         //删除屏蔽节目
         $sql = "DELETE FROM " . DB_PREFIX . "program_screen WHERE channel_id IN (" . $id . ")";
         $this->db->query($sql);
         //删除频道
         $sql = "DELETE FROM " . DB_PREFIX . "channel WHERE id IN (" . $id . ")";
         $this->db->query($sql);
         //插入工作量统计
         $statistic = new statistic();
         $statistics_data = array('content_id' => $id, 'contentfather_id' => '', 'type' => 'delete', 'user_id' => implode(',', $ch_user_id), 'user_name' => implode(',', $ch_user_name), 'app_uniqueid' => APP_UNIQUEID, 'module_uniqueid' => MODULE_UNIQUEID, 'before_data' => '', 'last_data' => '', 'num' => 1);
         $statistic->insert_record($statistics_data);
         //删除信号流信息
         $sql = "DELETE FROM " . DB_PREFIX . "channel_stream WHERE channel_id IN (" . $id . ")";
         $this->db->query($sql);
         //删除串联单
         $sql = "DELETE FROM " . DB_PREFIX . "channel_chg_plan WHERE channel_id IN (" . $id . ")";
         $this->db->query($sql);
         $programPlanSql = "SELECT id FROM " . DB_PREFIX . "program_plan WHERE channel_id IN (" . $id . ")";
         $q = $this->db->query($programPlanSql);
         $program_plan_id = array();
         while ($row = $this->db->fetch_array($q)) {
             $program_plan_id[] = $row['id'];
         }
         //删除节目单周数
         if (is_array($program_plan_id) && $program_plan_id) {
             foreach ($program_plan_id as $v) {
                 $sql = "DELETE FROM " . DB_PREFIX . "program_plan_relation WHERE plan_id IN (" . $v . ")";
                 $this->db->query($sql);
             }
         }
         //删除节目单计划
         $sql = "DELETE FROM " . DB_PREFIX . "program_plan WHERE channel_id IN (" . $id . ")";
         $this->db->query($sql);
         $changePlanSql = "SELECT id FROM " . DB_PREFIX . "change_plan WHERE channel_id IN (" . $id . ")";
         $q = $this->db->query($changePlanSql);
         $plan_id = array();
         while ($row = $this->db->fetch_array($q)) {
             $plan_id[] = $row['id'];
         }
         //删除串联单周数
         if (is_array($plan_id) && $plan_id) {
             foreach ($plan_id as $v) {
                 $sql = "DELETE FROM " . DB_PREFIX . "change_plan_relation WHERE plan_id IN (" . $v . ")";
                 $this->db->query($sql);
             }
         }
         //删除串联单计划
         $sql = "DELETE FROM " . DB_PREFIX . "change_plan WHERE channel_id IN (" . $id . ")";
         $this->db->query($sql);
     }
     $ret['id'] = $id;
     $this->addItem($ret['id']);
     $this->output();
 }
Example #6
0
 public function addStatistics($statistics_data)
 {
     @(include_once ROOT_PATH . 'lib/class/statistic.class.php');
     if (class_exists('statistic')) {
         $statistic = new statistic();
         $statistic->insert_record($statistics_data);
     }
 }
Example #7
0
 public function fast_edit()
 {
     if (!$this->input['id']) {
         $this->errorOutput(NOID);
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "vodinfo WHERE id = '" . intval($this->input['id']) . "'";
     $arr = $this->db->query_first($sql);
     //快速编辑之前视频的状态
     $ori_status = $arr['status'];
     //查询视频快速编辑之前已经发布到的栏目
     $arr['column_id'] = unserialize($arr['column_id']);
     $ori_column_id = array();
     if (is_array($arr['column_id'])) {
         $ori_column_id = array_keys($arr['column_id']);
     }
     $column_id = $this->publish_column->get_columnname_by_ids('id,name', $this->input['column_id']);
     $column_id = serialize($column_id);
     $sql = " UPDATE " . DB_PREFIX . "vodinfo SET ";
     $data = array('title' => $this->input['title'] ? $this->input['title'] : $arr['title'], 'subtitle' => $this->input['subtitle'] ? $this->input['subtitle'] : $arr['subtitle'], 'comment' => $this->input['comment'] ? $this->input['comment'] : $arr['comment'], 'keywords' => $this->input['keywords'] ? $this->input['keywords'] : $arr['keywords'], 'author' => $this->input['author'] ? $this->input['author'] : $arr['author'], 'source' => $this->input['mark_source_id'] ? $this->input['mark_source_id'] : $arr['source'], 'vod_sort_id' => intval($this->input['mark_sort_id']) ? intval($this->input['mark_sort_id']) : $arr['vod_sort_id'], 'isfile' => 0, 'column_id' => addslashes($column_id));
     foreach ($data as $k => $v) {
         $sql .= " {$k} = '{$v}',";
     }
     $sql = trim($sql, ',');
     $sql .= " WHERE id = '" . intval($this->input['id']) . "'";
     $this->db->query($sql);
     $this->change_mark_pic(intval($this->input['id']));
     $original_id_arr = $this->input['original_id'];
     $start_time_arr = $this->input['start_time'];
     $duration_arr = $this->input['duration'];
     $this->request_create_physics(intval($this->input['id']), $original_id_arr, $start_time_arr, $duration_arr, 'transcode_fast_edit', $arr['status']);
     //返回数据
     $sql_r = "SELECT * FROM " . DB_PREFIX . "vodinfo WHERE id = '" . intval($this->input['id']) . "'";
     $ret = $this->db->query_first($sql_r);
     //快编视频后发布的栏目
     $ret['column_id'] = unserialize($ret['column_id']);
     $new_column_id = array();
     if (is_array($ret['column_id'])) {
         $new_column_id = array_keys($ret['column_id']);
     }
     if ($ori_status == 2) {
         if (!empty($ret['expand_id'])) {
             $del_column = array_diff($ori_column_id, $new_column_id);
             if (!empty($del_column)) {
                 publish_insert_query($ret, 'delete', $del_column);
             }
             $add_column = array_diff($new_column_id, $ori_column_id);
             if (!empty($add_column)) {
                 publish_insert_query($ret, 'insert', $add_column);
             }
             $same_column = array_intersect($ori_column_id, $new_column_id);
             if (!empty($same_column)) {
                 publish_insert_query($ret, 'update', $same_column);
             }
         } else {
             if ($new_column_id) {
                 $op = "insert";
                 publish_insert_query($ret, $op);
             }
         }
     } else {
         if (!empty($ret['expand_id'])) {
             $op = "delete";
             publish_insert_query($ret, $op);
         }
     }
     $this->index_search($ret, 'update');
     //插入工作量统计
     $statistic = new statistic();
     $statistics_data = array('content_id' => intval($this->input['id']), 'contentfather_id' => '', 'type' => 'update', 'user_id' => $ret['user_id'], 'user_name' => $ret['addperson'], 'before_data' => '', 'last_data' => $this->input['title'], 'num' => 1);
     $statistic->insert_record($statistics_data);
     $this->addItem($ret);
     $this->output();
 }