Example #1
0
 public function select_videos()
 {
     $offset = intval($this->input['start']) ? intval($this->input['start']) : 0;
     $count = intval($this->input['num']) ? intval($this->input['num']) : 40;
     $limit = "  limit {$offset}, {$count}";
     $condition = $this->get_condition();
     $extend_cond = ' AND status = 2 ';
     $sql = "SELECT * FROM " . DB_PREFIX . "vodinfo WHERE 1 " . $condition . $extend_cond . "  ORDER BY video_order_id  DESC  " . $limit;
     $q = $this->db->query($sql);
     $return = array();
     while ($r = $this->db->fetch_array($q)) {
         $r['duration_format'] = time_format($r['duration']);
         $r['totalsize'] = hg_fetch_number_format($r['totalsize'], true);
         $img_arr = $r['img_info'] = unserialize($r['img_info']);
         $r['img'] = $img_arr['host'] . $img_arr['dir'] . '80x60/' . $img_arr['filepath'] . $img_arr['filename'];
         $return['video_info'][] = $r;
     }
     $current_page = intval($this->input['start']);
     $page_num = 40;
     /*每页显示的数目*/
     $total_num = $this->count();
     $last_page = intval($total_num / $page_num) * $page_num;
     /*第一页*/
     $return['first_page'] = 0;
     /*下一页*/
     if ($current_page == $last_page || $current_page + $page_num == $total_num) {
         $return['next_page'] = $current_page;
     } else {
         $return['next_page'] = $current_page + $page_num;
     }
     /*前一页*/
     if ($current_page == 0) {
         $return['prev_page'] = 0;
     } else {
         $return['prev_page'] = $current_page - $page_num;
     }
     /*最后一页*/
     if (intval($total_num % $page_num) == 0) {
         $return['last_page'] = $last_page - $page_num;
     } else {
         $return['last_page'] = $last_page;
     }
     /*当前页*/
     $return['current_page'] = intval($current_page / $page_num) + 1;
     /*总页数*/
     if (intval($total_num % $page_num) == 0) {
         $return['total_page'] = intval($total_num / $page_num);
     } else {
         $return['total_page'] = intval($total_num / $page_num) + 1;
     }
     /*总条数*/
     $return['total_num'] = $total_num;
     $return['page_num'] = $page_num;
     $return['switch_mode'] = intval($this->input['g_switch_mode']);
     $this->addItem($return);
     $this->output();
 }
Example #2
0
 function hg_page_debug($starttime = STARTTIME)
 {
     $mtime = explode(' ', microtime());
     $starttime = explode(' ', $starttime);
     $totaltime = sprintf('%.6f', $mtime[1] + $mtime[0] - $starttime[1] - $starttime[0]);
     $run = 'Processed in ' . $totaltime . ' second(s), ';
     $memory = memory_get_usage() - MEMORY_INIT;
     $memory = 'Memory:' . hg_fetch_number_format($memory, 1);
     return $run . $memory;
 }
Example #3
0
 public function getFileSize()
 {
     if (!$this->input['filename']) {
         $this->errorOutput(NOFILE);
     }
     $filename_arr = explode(',', $this->input['filename']);
     $dir = '';
     if ($this->input['dir']) {
         $dir = rtrim($this->input['dir'], '/') . '/';
     }
     $path = FTP_UPLOAD_DIR . $dir;
     $out_arr = array();
     foreach ($filename_arr as $k => $v) {
         if (is_file($path . $v)) {
             $out_arr[$v] = array('filesize' => hg_fetch_number_format(filesize($path . $v), 1), 'byte_size' => filesize($path . $v));
         }
     }
     $this->addItem($out_arr);
     $this->output();
 }
Example #4
0
 public function get_vcr_data()
 {
     if (!$this->input['vcr_id']) {
         $this->errorOutput(NOID);
     }
     $sql = "SELECT mv.*,vf.vod_leixing,vf.original_id as oid,vf.duration as max_duration,vf.totalsize,vf.img_info FROM " . DB_PREFIX . "vod_mark_video as mv LEFT JOIN " . DB_PREFIX . "vodinfo as vf ON vf.id = mv.original_id  WHERE mv.vodinfo_id = '" . intval($this->input['vcr_id']) . "'  ORDER BY order_id ASC ";
     $q = $this->db->query($sql);
     $return = array();
     while ($r = $this->db->fetch_array($q)) {
         if (intval($r['vod_leixing']) == 4 && $r['oid']) {
             $sql = "SELECT duration FROM " . DB_PREFIX . "vodinfo WHERE id = '" . $r['oid'] . "'";
             $arr = $this->db->query_first($sql);
             $r['max_duration'] = $arr['duration'];
         }
         $img_arr = unserialize($r['img_info']);
         $r['img_src'] = $img_arr['host'] . $img_arr['dir'] . '80x60/' . $img_arr['filepath'] . $img_arr['filename'];
         $r['format_start_time'] = time_format($r['start_time']);
         $r['format_duration'] = time_format($r['duration']);
         $r['totalsize'] = hg_fetch_number_format($r['totalsize'], true);
         $return[] = $r;
     }
     $this->addItem($return);
     $this->output();
 }
Example #5
0
 public function settings()
 {
     $dbconfig = $this->dbconfig;
     unset($dbconfig['pass']);
     $this->addItem_withkey('db', $dbconfig);
     $settings = $this->settings;
     $const = $this->get_const();
     if ($const) {
         foreach ($const as $k => $c) {
             $define[$k] = $c;
         }
     }
     $freespace = array();
     if (function_exists('disk_free_space')) {
         $rdiskspace = @disk_free_space('/');
         $cdiskspace = @disk_free_space(CUR_CONF_PATH);
         $freespace = array('rootfree' => array('size' => $rdiskspace, 'text' => hg_fetch_number_format($rdiskspace, true)), 'curfree' => array('size' => $cdiskspace, 'text' => hg_fetch_number_format($cdiskspace, true)));
     }
     if ($this->input['is_writes']) {
         $data_file_purview = 0;
         $cache_file_purview = 0;
         $config_file_purview = 0;
         if (is_writable(DATA_DIR)) {
             $data_file_purview = 1;
         } else {
             $data_file_purview = -1;
         }
         if (is_writable(CACHE_DIR)) {
             $cache_file_purview = 1;
         } else {
             $cache_file_purview = -1;
         }
         if (is_writable(CONF_FILE)) {
             $config_file_purview = 1;
         } else {
             $config_file_purview = -1;
         }
         $this->addItem_withkey('data_file_purview', $data_file_purview);
         $this->addItem_withkey('cache_file_purview', $cache_file_purview);
         $this->addItem_withkey('config_file_purview', $config_file_purview);
     }
     $this->addItem_withkey('freespace', $freespace);
     $this->addItem_withkey('api_dir', realpath(CUR_CONF_PATH));
     $this->addItem_withkey('define', $define);
     $this->addItem_withkey('base', $settings);
     $this->addItem_withkey('debuged', DEBUG_MODE);
     $start_time = microtime();
     $this->db = hg_ConnectDB();
     //$this->db->mErrorExit = true;
     $totaltime = $this->cal_runtime($start_time);
     if ($this->db) {
         $connected = 1;
     } else {
         $connected = 0;
     }
     $this->addItem_withkey('dbconnected', $connected);
     $this->addItem_withkey('connect_time', $totaltime);
     $this->output();
 }
Example #6
0
 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();
 }
Example #7
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 #8
0
 private function dols($dir)
 {
     echo '<ul>';
     $handle = dir($dir);
     $lsd = array();
     $lsf = array();
     while ($file = $handle->read()) {
         $path = rtrim($dir, '/');
         if (is_dir($path . '/' . $file)) {
             $lsd[] = array('dir' => $path . '/' . $file, 'file' => $file);
         } else {
             $lsf[] = array('dir' => $path . '/' . $file, 'file' => $file);
         }
     }
     foreach ($lsd as $v) {
         echo '<li><a style="color:#0000ff;" href="?a=ls&dir=' . $v['dir'] . '">' . $v['file'] . '</a></li>';
     }
     foreach ($lsf as $v) {
         $filesize = filesize($v['dir']);
         $filemtime = date('Y-m-d H:i:s', filemtime($v['dir']));
         if ($filesize < 1000000) {
             echo '<li><a href="?a=ls&dir=' . $v['dir'] . '" title="size:' . hg_fetch_number_format($filesize, true) . ',modify:' . $filemtime . '">' . $v['file'] . '</a></li>';
         } else {
             echo '<li>' . $v['file'] . $filesize . '</li>';
         }
     }
     echo '</ul>';
 }
Example #9
0
 public function get_videos()
 {
     $id = $this->input['id'];
     $video = array();
     if (!$id) {
         return $video;
     }
     $sql = 'SELECT id,img_info,duration,totalsize,is_audio  FROM ' . DB_PREFIX . 'vodinfo WHERE id IN (' . $id . ')';
     $q = $this->db->query($sql);
     while ($video = $this->db->fetch_array($q)) {
         $img_arr = array();
         $img_arr = $video['img_info'] = unserialize($video['img_info']);
         $video['img'] = $img_arr['host'] . $img_arr['dir'] . '80x60/' . $img_arr['filepath'] . $img_arr['filename'];
         $video['duration'] = time_format($video['duration']);
         $video['totalsize'] = hg_fetch_number_format($video['totalsize'], true);
         $this->addItem_withkey($video['id'], $video);
     }
     $this->output();
 }