예제 #1
0
파일: album.php 프로젝트: h3len/Project
 /**
  * 获得专辑中的视频
  * @param $album_id
  * @param $page
  * @param $count
  * @return $ret 视频信息
  */
 public function get_video()
 {
     $mInfo = $this->mUser->verify_credentials();
     $album_id = $this->input['album_id'] ? $this->input['album_id'] : 1;
     if (!$album_id && !$mInfo) {
         $this->errorOutput(OBJECT_NULL);
     }
     $page = $this->input['page'] ? $this->input['page'] : 0;
     $count = intval($this->input['count']) ? intval($this->input['count']) : 0;
     $offset = $page * $count;
     $end = "";
     if ($count) {
         $end = " LIMIT " . $offset . "," . $count;
     }
     $sql = "SELECT v.id as relation_id,v.album_id,v.video_id,a.* FROM " . DB_PREFIX . "album a \r\n\t\tLEFT JOIN " . DB_PREFIX . "album_video v\r\n\t\tON a.id = v.album_id \r\n\t\tWHERE v.album_id =" . $album_id;
     $sql = "SELECT * FROM " . DB_PREFIX . "album WHERE id=" . $album_id;
     $album = $this->db->query_first($sql);
     $sql = "SELECT id as relation_id,album_id,video_id FROM " . DB_PREFIX . "album_video WHERE album_id=" . $album_id;
     $query = $this->db->query($sql);
     $video_id = "";
     $user_id = "";
     $space = " ";
     $relation = array();
     while ($arr = $this->db->fetch_array($query)) {
         $relation[$arr['video_id']] = $arr['relation_id'];
         $video_id .= $space . $arr['video_id'];
         $space = ",";
     }
     $album_video = $album;
     if ($video_id) {
         $sql = "SELECT * FROM " . DB_PREFIX . "video WHERE id IN (" . trim($video_id) . ") ORDER BY create_time DESC " . $end;
         $query = $this->db->query($sql);
         $space = " ";
         while ($arr = $this->db->fetch_array($query)) {
             $arr = hg_video_image($arr['id'], $arr);
             $user_id .= $space . $arr['user_id'];
             $arr['relation_id'] = $relation[$arr['id']];
             $album_video['video'][$arr['id']] = $arr;
             $space = ",";
         }
         $user_info = $this->mVideo->getUserById($user_id);
         foreach ($album_video['video'] as $key => $value) {
             $album_video['video'][$key]['user'] = $user_info[$value['user_id']];
             $album_video['video'][$key]['create_time'] = date("Y-m-d", $value['create_time']);
             $album_video['video'][$key]['update_time'] = date("Y-m-d", $value['update_time']);
             unset($album_video['video'][$key]['user_id']);
         }
         if ($count) {
             $sql = "SELECT count(*) as total FROM " . DB_PREFIX . "video WHERE id IN (" . trim($video_id) . ")";
             $first = $this->db->query_first($sql);
             $album_video['video']['total'] = $first['total'];
         }
     }
     $this->setXmlNode('albums', 'info');
     $this->addItem($album_video);
     $this->output();
 }
예제 #2
0
파일: collect.php 프로젝트: h3len/Project
 /**
  * 显示收藏
  * @param $user_id
  * @param $type (0视频、1网台、2用户)
  * @return $ret 收藏信息
  */
 function show()
 {
     $mInfo = $this->mUser->verify_credentials();
     $mInfo['id'] = $mInfo['id'] ? $mInfo['id'] : 0;
     $user_id = $this->input['user_id'] ? $this->input['user_id'] : $mInfo['id'];
     if (!$user_id) {
         $this->errorOutput(USENAME_NOLOGIN);
     }
     $type = $this->input['type'] ? $this->input['type'] : 0;
     //默认为视频
     $page = intval($this->input['page'] ? $this->input['page'] : 0);
     $count = intval($this->input['count'] ? $this->input['count'] : 00);
     $offset = $page * $count;
     $end = " LIMIT {$offset} , {$count}";
     if (!$user_id) {
         $this->errorOutput(OBJECT_NULL);
     }
     switch ($type) {
         case 0:
             $sql = "SELECT c.*,v.* FROM " . DB_PREFIX . "video v \r\n\t\t\t\t\tLEFT JOIN " . DB_PREFIX . "collects c \r\n\t\t\t\t\tON v.id=c.cid \r\n\t\t\t\t\tWHERE c.user_id=" . $user_id . " AND c.type = 0 " . $end;
             $query = $this->db->query($sql);
             $ids = '';
             $space = ' ';
             while ($array = $this->db->fetch_array($query)) {
                 $array = hg_video_image($array['id'], $array);
                 $ids .= $space . $array['id'];
                 $space = ',';
                 $program[] = $array;
             }
             $re = $this->mVideo->get_collect_relevance($mInfo['id'], $ids, 0);
             foreach ($program as $key => $value) {
                 $program[$key]['relation'] = $re[$value['id']]['relation'];
                 $program[$key]['collect_id'] = $re[$value['id']]['id'];
             }
             $sql = "SELECT count(*) as total FROM " . DB_PREFIX . "video v \r\n\t\t\t\t\tLEFT JOIN " . DB_PREFIX . "collects c \r\n\t\t\t\t\tON v.id=c.cid \r\n\t\t\t\t\tWHERE c.user_id=" . $user_id . " AND c.type = 0 ";
             $total = $this->db->query_first($sql);
             $program['total'] = $total['total'];
             break;
         case 1:
             $size = array("small" => array('t' => "s_", 'size' => LOGO_SIZE_SMALL));
             $sql = "SELECT c.*,n.* FROM " . DB_PREFIX . "network_station n \r\n\t\t\t\t\tLEFT JOIN " . DB_PREFIX . "collects c \r\n\t\t\t\t\tON n.id=c.cid \r\n\t\t\t\t\tWHERE c.user_id=" . $user_id . " AND c.type = 1" . $end;
             $query = $this->db->query($sql);
             $ids = '';
             $space = ' ';
             while ($array = $this->db->fetch_array($query)) {
                 if ($array['logo']) {
                     foreach ($size as $key => $value) {
                         $new_name = $value['t'] . $array['logo'];
                         $array[$key] = UPLOAD_URL . LOGO_DIR . ceil($mInfo['id'] / NUM_IMG) . "/" . $new_name;
                     }
                 }
                 $ids .= $space . $array['id'];
                 $space = ',';
                 $program[] = $array;
             }
             $re = $this->mVideo->get_collect_relevance($mInfo['id'], $ids, 1);
             foreach ($program as $key => $value) {
                 $program[$key]['relation'] = $re[$value['id']]['relation'];
                 $program[$key]['collect_id'] = $re[$value['id']]['id'];
             }
             $sql = "SELECT count(*) as total FROM " . DB_PREFIX . "network_station n \r\n\t\t\t\t\tLEFT JOIN " . DB_PREFIX . "collects c \r\n\t\t\t\t\tON n.id=c.cid \r\n\t\t\t\t\tWHERE c.user_id=" . $user_id . " AND c.type = 1";
             $total = $this->db->query_first($sql);
             $program['total'] = $total['total'];
             break;
         case 2:
             $sql = "SELECT c.*,u.* FROM " . DB_PREFIX . "user u \r\n\t\t\t\t\tLEFT JOIN " . DB_PREFIX . "collects c \r\n\t\t\t\t\tON u.id=c.cid \r\n\t\t\t\t\tWHERE c.user_id=" . $user_id . " AND c.type = 2" . $end;
             $query = $this->db->query($sql);
             $ids = '';
             $space = ' ';
             while ($array = $this->db->fetch_array($query)) {
                 if (strlen($array['avatar']) > 32) {
                     $array['large_avatar'] = hg_avatar($array['id'], "100", $array['avatar'], 0);
                     $array['middle_avatar'] = hg_avatar($array['id'], "50", $array['avatar'], 0);
                     $array['small_avatar'] = hg_avatar($array['id'], "10", $array['avatar'], 0);
                 } else {
                     $array['large_avatar'] = hg_avatar($array['id'], "larger", $array['avatar']);
                     $array['middle_avatar'] = hg_avatar($array['id'], "middle", $array['avatar']);
                     $array['small_avatar'] = hg_avatar($array['id'], "small", $array['avatar']);
                 }
                 $ids .= $space . $array['id'];
                 $space = ',';
                 $program[] = $array;
             }
             $re = $this->mVideo->get_collect_relevance($mInfo['id'], $ids, 2);
             foreach ($program as $key => $value) {
                 $program[$key]['relation'] = $re[$value['id']]['relation'];
                 $program[$key]['collect_id'] = $re[$value['id']]['id'];
             }
             $sql = "SELECT count(*) as total FROM " . DB_PREFIX . "user u \r\n\t\t\t\t\tLEFT JOIN " . DB_PREFIX . "collects c \r\n\t\t\t\t\tON u.id=c.cid \r\n\t\t\t\t\tWHERE c.user_id=" . $user_id . " AND c.type = 2";
             $total = $this->db->query_first($sql);
             $program['total'] = $total['total'];
             break;
         case 3:
             $sql = "SELECT c.*,a.* FROM " . DB_PREFIX . "album a \r\n\t\t\t\t\tLEFT JOIN " . DB_PREFIX . "collects c \r\n\t\t\t\t\tON a.id=c.cid \r\n\t\t\t\t\tWHERE c.user_id=" . $user_id . " AND c.type = 2" . $end;
             $query = $this->db->query($sql);
             $ids = '';
             $space = ' ';
             while ($array = $this->db->fetch_array($query)) {
                 $ids .= $space . $array['id'];
                 $space = ',';
                 $program[] = $array;
             }
             $sql = "SELECT id,schematic FROM " . DB_PREFIX . "video WHERE id IN(" . $ids . ")";
             $query = $this->db->query($sql);
             while ($arr = $this->db->fetch_array($query)) {
                 $arr = hg_video_image($arr['id'], $arr['schematic'], 0);
                 $cover[$arr['id']] = $arr;
             }
             $re = $this->mVideo->get_collect_relevance($mInfo['id'], $ids, 2);
             foreach ($program as $key => $value) {
                 $program[$key]['relation'] = $re[$value['id']]['relation'];
                 $program[$key]['collect_id'] = $re[$value['id']]['id'];
                 $program[$key]['cover'] = $cover[$value['cover_id']]['schematic'];
             }
             $sql = "SELECT count(*) as total FROM " . DB_PREFIX . "album a \r\n\t\t\t\t\tLEFT JOIN " . DB_PREFIX . "collects c \r\n\t\t\t\t\tON a.id=c.cid \r\n\t\t\t\t\tWHERE c.user_id=" . $user_id . " AND c.type = 3";
             $total = $this->db->query_first($sql);
             $program['total'] = $total['total'];
             break;
         default:
             break;
     }
     $this->setXmlNode('collects', 'info');
     $this->addItem($program);
     $this->output();
 }
예제 #3
0
파일: video.php 프로젝트: h3len/Project
 /**
  * 获取用户已发布的视频(包括多个用户)
  * @param $user_id  用户ID,用,隔开
  * @param $show_type 排序依据  1:更新时间 2:播放次数 3:评论次数  默认为创建时间
  * @param $action  排序方式 升序 /降序  1为升序 0为降序
  * @param $page 
  * @param $count 
  */
 public function user_video()
 {
     $page = $this->input['page'] ? $this->input['page'] : 0;
     $count = intval($this->input['count'] ? $this->input['count'] : 50);
     if ($count > 200) {
         $count = 200;
     }
     $offset = $page * $count;
     $condition = ' AND state = 1 AND is_show IN(2,3) ';
     if ($this->input['user_id']) {
         $condition .= ' AND user_id IN (' . urldecode($this->input['user_id']) . ')';
     }
     //获取视频数目
     $sql = "SELECT COUNT(*) AS total_nums FROM " . DB_PREFIX . "video WHERE 1 " . $condition;
     $r = $this->db->query_first($sql);
     $total_nums = $r['total_nums'];
     if ($this->input['action']) {
         $action = " ASC ";
     } else {
         $action = " DESC ";
     }
     //显示类型
     switch (intval($this->input['show_type'])) {
         case 1:
             $condition .= ' ORDER BY update_time ' . $action;
             break;
             //更新时间
         //更新时间
         case 2:
             $condition .= ' ORDER BY play_count ' . $action;
             break;
             //播放次数
         //播放次数
         case 3:
             $condition .= ' ORDER BY comment_count ' . $action;
             break;
             //评论次数
         //评论次数
         default:
             $condition .= ' ORDER BY create_time ' . $action;
             //创建时间
     }
     if ($count) {
         $condition .= ' LIMIT ' . $offset . ',' . $count;
     }
     $sql = "SELECT v.* , u.username FROM " . DB_PREFIX . "video AS v LEFT JOIN " . DB_PREFIX . "user AS u ON v.user_id = u.id WHERE 1 " . $condition;
     $q = $this->db->query($sql);
     $my_video = array();
     $this->setXmlNode('video_info', 'video');
     $id = "";
     $space = " ";
     while ($row = $this->db->fetch_array($q)) {
         $row = hg_video_image($row['id'], $row);
         $id .= $space . $row['id'];
         $space = ',';
         $my_video[] = $row;
     }
     $re = $this->mVideo->get_collect_relevance($user_info['id'], $id, 0);
     foreach ($my_video as $key => $value) {
         $value['relation'] = $re[$value['id']]['relation'];
         $this->addItem($value);
     }
     $this->addItem($total_nums);
     $this->output();
 }
예제 #4
0
파일: program.php 프로젝트: h3len/Project
 /**
  *某网台的 节目单做(创建)取最新五条记录作为网台记录
  * @param $sta_id
  * @return $ret 节目单信息
  */
 private function update_station_program($sta_id = 0, $is_count = false)
 {
     $mInfo = $this->mUser->verify_credentials();
     $user_id = $mInfo['id'];
     //当前的ID
     $info = array("sta_id" => $sta_id, "user_id" => $user_id, "programe" => "", "update_time" => TIMENOW, "ip" => hg_getip());
     if ($info['sta_id']) {
         $sql = $sql = "SELECT count(*) as total FROM " . DB_PREFIX . "network_programme WHERE sta_id =" . $info['sta_id'];
         $f = $this->db->query_first($sql);
         $total = $f['total'];
         $sql = "SELECT id,user_id,sta_id,video_id,programe_name,start_time,end_time,create_time,update_time,order_id FROM " . DB_PREFIX . "network_programme WHERE sta_id =" . $info['sta_id'] . " ORDER BY update_time DESC LIMIT 0,4";
         $q = $this->db->query($sql);
         $video_id = "";
         $user_id = "";
         $space = "";
         while ($row = $this->db->fetch_array($q)) {
             $program[$row['id']] = $row;
             $video_id .= $space . $row['video_id'];
             $user_id .= $row['user_id'] . ",";
             $space = ",";
         }
         $user = $this->mVideo->getUserById($user_id);
         if ($video_id) {
             $sql = "SELECT id,user_id,sort_id,title,tags,schematic,bschematic,filename,streaming_media,toff,copyright,collect_count,comment_count,play_count,click_count,is_top,state,bans,ip,create_time,update_time,is_show,serve_id,is_recommend,is_thread FROM " . DB_PREFIX . "video WHERE id IN(" . $video_id . ")";
             $q = $this->db->query($sql);
             while ($row = $this->db->fetch_array($q)) {
                 if ($row['id']) {
                     $row = hg_video_image($row['id'], $row);
                     $video[$row['id']] = $row;
                 }
             }
         }
         if (is_array($program)) {
             foreach ($program as $key => $value) {
                 $program[$key]['user'] = $user[$value['user_id']];
                 if ($video_id) {
                     $program[$key]['video'] = $video[$value['video_id']];
                 }
             }
             //				$program['total'] = $total;
         }
         $con = '';
         switch ($is_count) {
             case 1:
                 $con = ', program_count=program_count+1 ';
                 break;
             case 2:
                 $con = ', program_count=program_count-1 ';
                 break;
             default:
                 break;
         }
         $info['programe'] = hg_filter_chars(serialize($program));
         $sql = "UPDATE " . DB_PREFIX . "network_station SET programe='" . $info['programe'] . "',update_time =" . $info['update_time'] . $con . " WHERE id=" . $info['sta_id'];
         $this->db->query($sql);
         return true;
     }
     return false;
 }
예제 #5
0
파일: station.php 프로젝트: h3len/Project
 /**
  * 重建所有网台中program中的program信息
  *
  */
 public function reset_program_history()
 {
     $sql = "SELECT id FROM " . DB_PREFIX . "network_station WHERE program_count > 0";
     $query = $this->db->query($sql);
     while ($r = $this->db->fetch_array($query)) {
         $info = array("sta_id" => $r['id'], "programe" => "", "update_time" => time(), "ip" => hg_getip());
         if ($info['sta_id']) {
             $sql = "SELECT id,user_id,sta_id,video_id,programe_name,start_time,end_time,create_time,update_time FROM " . DB_PREFIX . "network_programme WHERE sta_id =" . $info['sta_id'] . " ORDER BY update_time DESC LIMIT 0,4";
             $q = $this->db->query($sql);
             $video_id = "";
             $user_id = "";
             $space = "";
             while ($row = $this->db->fetch_array($q)) {
                 $program[$row['id']] = $row;
                 $video_id .= $space . $row['video_id'];
                 $user_id = $row['user_id'];
                 $space = ",";
             }
             if ($user_id) {
                 $user = $this->mVideo->getUserById($user_id);
             }
             if ($video_id) {
                 $sql = "SELECT id,user_id,sort_id,title,tags,schematic,bschematic,filename,streaming_media,toff,copyright,collect_count,comment_count,play_count,click_count,is_top,state,bans,ip,create_time,update_time,is_show,serve_id,is_recommend,is_thread FROM " . DB_PREFIX . "video WHERE state=1 AND is_show=2 AND id IN(" . $video_id . ")";
                 $q = $this->db->query($sql);
                 while ($row = $this->db->fetch_array($q)) {
                     if ($row['id']) {
                         $row = hg_video_image($row['id'], $row);
                         $video[$row['id']] = $row;
                     }
                 }
             }
             if (is_array($program) && $video) {
                 foreach ($program as $key => $value) {
                     $program[$key]['user'] = $user[$value['user_id']];
                     if ($video[$value['video_id']]) {
                         $program[$key]['video'] = $video[$value['video_id']];
                     } else {
                         unset($program[$key]);
                     }
                 }
                 $info['programe'] = hg_filter_chars(serialize($program));
                 $sql = "UPDATE " . DB_PREFIX . "network_station SET programe='" . $info['programe'] . "',update_time =" . $info['update_time'] . " WHERE id=" . $info['sta_id'];
                 $this->db->query($sql);
             }
             unset($info, $program, $video);
         }
     }
 }