public function show_opration() { if (!$this->input['id']) { $this->errorOutput(NOID); } //查询出顶级类别供下面没有分类的时候用 $sql = "SELECT * FROM " . DB_PREFIX . "vod_media_node WHERE fid = 0"; $q = $this->db->query($sql); $top_sorts = array(); while ($r = $this->db->fetch_array($q)) { $top_sorts[$r['id']] = $r; } $sql = "SELECT f.*,s.name AS sort_name FROM " . DB_PREFIX . "vodinfo as f left join " . DB_PREFIX . "vod_media_node as s on f.vod_sort_id = s.id WHERE f.id = '" . intval($this->input['id']) . "'"; $return = $this->db->query_first($sql); if (!$return) { $this->errorOutput('视频不存在或已被删除'); } if ($return['isfile']) { $return['start'] = 0; } $return['format_duration'] = hg_timeFormatChinese($return['duration']); //时长 $return['trans_use_time'] = hg_timeFormatChinese($return['trans_use_time']); //转码所用时间 $return['is_forcecode'] = $return['is_forcecode'] ? '是' : '否'; $return['is_water_marked'] = $return['is_water_marked'] ? '是' : '否'; $return['bitrate'] = $return['bitrate'] . 'kbps'; //码流 $return['resolution'] = $return['width'] . '*' . $return['height']; //分辨率 $return['vod_leixing_name'] = $top_sorts[$return['vod_leixing']]['name']; $return['totalsize'] = hg_fetch_number_format($return['totalsize'], 1); $return['isfile'] = $return['isfile'] ? '是' : '否'; $return['frame_rate'] = number_format($return['frame_rate'], 3) . 'fps'; $audio_status = check_str('L', 'R', $return['audio_channels']); switch ($audio_status) { case 0: $return['audio_channels'] = '无'; break; case 1: $return['audio_channels'] = '右'; break; case 2: $return['audio_channels'] = '左'; break; case 3: $return['audio_channels'] = '左右'; break; default: $return['audio_channels'] = '无'; break; } if ($return['collects']) { $return['collects'] = unserialize($return['collects']); } //记录页面的所处的类型与类别 if ($this->input['frame_type']) { $return['frame_type'] = intval($this->input['frame_type']); } else { $return['frame_type'] = ''; } if ($this->input['frame_sort']) { $return['frame_sort'] = intval($this->input['frame_sort']); } else { $return['frame_sort'] = ''; } $return['download'] = $this->settings['App_mediaserver']['protocol'] . $this->settings['App_mediaserver']['host'] . '/' . $this->settings['App_mediaserver']['dir'] . 'admin/download.php'; $return['video_url'] = $return['hostwork'] . '/' . $return['video_path'] . MAINFEST_F4M; $return['video_m3u8'] = $return['hostwork'] . '/' . $return['video_path'] . str_replace('.mp4', '.m3u8', $return['video_filename']); $return['snapUrl'] = $this->settings['App_mediaserver']['protocol'] . $this->settings['App_mediaserver']['host'] . '/' . $this->settings['App_mediaserver']['dir'] . 'admin/snap.php'; $return['display_technical'] = $this->settings['technical_swdl']['host']; switch ($return['technical_status']) { case -1: $return['technical_status'] = '技审失败'; break; case 1: $return['technical_status'] = '技术审核'; break; case 2: $return['technical_status'] = '正在技审中'; break; case 3: $return['technical_status'] = '技审成功'; break; default: $return['technical_status'] = '技术审核'; break; } $this->addItem($return); $this->output(); }
public function recommend() { if ($this->mNeedCheckIn && !$this->prms['update']) { $this->errorOutput(NO_OPRATION_PRIVILEGE); } if (!$this->input['id']) { $this->errorOutput(NOID); } $sql = "SELECT * FROM " . DB_PREFIX . "webvod WHERE program_id IN( " . $this->input['id'] . ")"; $qs = $this->db->query($sql); while ($vod_result = $this->db->fetch_array($qs)) { $vod_result['column_id'] = unserialize($vod_result['column_id']); if (is_array($vod_result['column_id']) && $vod_result['column_id']) { $column_id = array(); foreach ($vod_result['column_id'] as $k => $v) { $column_id[] = $k; } $column_id = implode(',', $column_id); $vod_result['column_id'] = $column_id; } if ($vod_result['duration']) { $vod_result['video_duration'] = hg_timeFormatChinese($vod_result['duration'] * 1000); //时长 } else { $vod_result['video_duration'] = '无'; } $vod_result['time'] = TIMENOW; if ($vod_result['status'] == 2) { $vod_result['pubstatus'] = 1; } else { $vod_result['pubstatus'] = 0; } if ($this->input['indexpic']) { $sql = "SELECT * FROM " . DB_PREFIX . "webvodpic WHERE id = " . $this->input['indexpic']; $index = $this->db->query_first($sql); require_once ROOT_PATH . 'lib/class/material.class.php'; $this->ma = new material(); $materials = $this->ma->localMaterial($index['url'], $this->input['id']); if ($materials) { $arr = array('host' => $materials[0]['host'], 'dir' => $materials[0]['dir'], 'filepath' => $materials[0]['filepath'], 'filename' => $materials[0]['filename']); $indexpic = serialize($arr); } $sql_ = "UPDATE " . DB_PREFIX . "webvodpic SET is_now = 1,indexpic = '" . addslashes($indexpic) . "' WHERE program_id = " . $this->input['id'] . " AND id = " . $this->input['indexpic']; $this->db->query($sql_); } $vod_result['pub_time'] = $vod_result['pub_time'] ? date("Y-m-d H:i", $vod_result['pub_time']) : date("Y-m-d H:i", TIMENOW); $this->addItem($vod_result); } $this->output(); }
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(); }
public function detail() { ##### $this->verify_content_prms(array('_action' => 'show')); ##### if (!$this->input['id']) { $this->errorOutput(NOID); } $is_fast_edit = array(); $sql = "SELECT * FROM " . DB_PREFIX . "vod_mark_video WHERE original_id IN (" . $this->input['id'] . ")"; $q = $this->db->query($sql); while ($row = $this->db->fetch_array($q)) { $is_fast_edit[$row['original_id']][$row['id']] = $row; } $sql = "SELECT v.*,vm.name AS vod_sort_name FROM " . DB_PREFIX . "vodinfo v LEFT JOIN " . DB_PREFIX . "vod_media_node vm ON v.vod_sort_id = vm.id WHERE v.id IN( " . $this->input['id'] . ")"; $qs = $this->db->query($sql); while ($vod_result = $this->db->fetch_array($qs)) { if (!$vod_result['vod_sort_name']) { $vod_result['vod_sort_name'] = $this->settings['video_upload_type'][$vod_result['vod_leixing']]; } if ($vod_result['isfile']) { $vod_result['start'] = 0; } $vod_result['title'] = trim($vod_result['title']); $vod_result['comment'] = trim($vod_result['comment']); $vod_result['subtitle'] = trim($vod_result['subtitle']); $vod_result['keywords'] = trim($vod_result['keywords']); $vod_result['author'] = trim($vod_result['author']); $vod_result['column_id'] = unserialize($vod_result['column_id']); $vod_result['column_url'] = unserialize($vod_result['column_url']); $pub_column = array(); if (is_array($vod_result['column_id']) && $vod_result['column_id']) { $column_id = array(); foreach ($vod_result['column_id'] as $k => $v) { $column_id[] = $k; $pub_column[] = array("column_id" => $k, "column_name" => $v, 'pub_id' => intval($vod_result['column_url'][$k])); } $column_id = implode(',', $column_id); $vod_result['column_id'] = $column_id; } $vod_result['pub_column'] = $pub_column; $vod_result['pub_time'] = $vod_result['pub_time'] ? date("Y-m-d H:i", $vod_result['pub_time']) : ''; $img_arr = unserialize($vod_result['img_info']); if ($img_arr['filename'] == '<') { $img_arr = ''; } $vod_result['img_info'] = $img_arr; $vod_result['img'] = $img_arr['host'] . $img_arr['dir'] . $img_arr['filepath'] . $img_arr['filename']; $vod_result['source_img'] = $vod_result['img']; if ($vod_result['is_link']) { $vod_result['video_url'] = $vod_result['hostwork'] . '/' . $vod_result['video_path']; } else { $vod_result['video_url'] = $vod_result['hostwork'] . '/' . $vod_result['video_path'] . MAINFEST_F4M; } $vod_result['video_m3u8'] = $vod_result['hostwork'] . '/' . $vod_result['video_path'] . str_replace('.mp4', '.m3u8', $vod_result['video_filename']); $vod_result['snapUrl'] = $this->settings['App_mediaserver']['protocol'] . $this->settings['App_mediaserver']['host'] . '/' . $this->settings['App_mediaserver']['dir'] . 'admin/snap.php'; if ($vod_result['totalsize']) { $vod_result['video_totalsize'] = hg_fetch_number_format($vod_result['totalsize'], 1); } else { $vod_result['video_totalsize'] = '无'; } if ($vod_result['duration']) { $vod_result['video_duration'] = hg_timeFormatChinese($vod_result['duration']); //时长 } else { $vod_result['video_duration'] = '无'; } $vod_result['format_duration'] = hg_timeFormatChinese($vod_result['duration']); //时长 $vod_result['resolution'] = $vod_result['width'] . '*' . $vod_result['height']; //分辨率 $vod_result['frame_rate'] = number_format($vod_result['frame_rate'], 3) . 'fps'; $audio_status = check_str('L', 'R', $vod_result['audio_channels']); switch ($audio_status) { case 0: $vod_result['video_audio_channels'] = '无'; break; case 1: $vod_result['video_audio_channels'] = '右'; break; case 2: $vod_result['video_audio_channels'] = '左'; break; case 3: $vod_result['video_audio_channels'] = '左右'; break; default: $vod_result['video_audio_channels'] = '无'; break; } $vod_result['video_resolution'] = $vod_result['width'] . '*' . $vod_result['height']; //分辨率 $vod_result['snap_img'] = ''; //$this->get_video_imgs($vod_result['id'],$vod_result['duration']); if (isset($is_fast_edit[$vod_result['id']]) && !empty($is_fast_edit[$vod_result['id']])) { $vod_result['is_fast_edit'] = 0; } else { $vod_result['is_fast_edit'] = 1; } if ($vod_result['status'] == 2) { $vod_result['pubstatus'] = 1; } else { $vod_result['pubstatus'] = 0; } if ($vod_result['catalog']) { $vod_result['catalog'] = unserialize($vod_result['catalog']); } $this->addItem($vod_result); } $this->output(); }