function show() { //所有频道信息 $sql = "select id,logo,name from " . DB_PREFIX . "channel ORDER BY order_id DESC"; $ch = $this->db->query($sql); $channel_info = array(); while ($row = $this->db->fetch_array($ch)) { if (empty($channel_info)) { $channel_info['default'] = $row; } $imgss = hg_get_images($row['logo'], UPLOAD_URL . CHANNEL_IMG_DIR, $this->settings['channel_img_size']); foreach ($imgss as $key => $value) { $row[$key] = $value; } $channel_info[$row['id']] = $row; } $this->addItem_withkey('channel_info', $channel_info); $dates = $this->input['dates'] ? urldecode($this->input['dates']) : date("Y-m-d"); $this->addItem_withkey('date', $dates); if (!$this->input['channel_id']) { $sql = "SELECT id FROM " . DB_PREFIX . "channel WHERE 1 ORDER BY order_id DESC LIMIT 1"; $f = $this->db->query_first($sql); if (!empty($f)) { $this->input['channel_id'] = $f['id']; } else { $this->errorOutput('未传入频道ID'); } } $sql = "SELECT * FROM " . DB_PREFIX . "topic WHERE channel_id=" . $this->input['channel_id'] . " and dates='" . $dates . "' ORDER BY start_time ASC "; $q = $this->db->query($sql); $topic = array(); $last_end = ''; $start = strtotime($dates . " 00:00:00"); $end = strtotime($dates . " 23:59:59"); $com_time = 0; while ($row = $this->db->fetch_array($q)) { if (!$com_time && $row['start_time'] > $start) { $topic[] = $this->getInfo($start, $row['start_time'], $dates); } if ($com_time && $com_time != $row['start_time']) { $topic[] = $this->getInfo($com_time, $row['start_time'], $dates); } $com_time = $row['end_time']; $row['start'] = date("H:i:s", $row['start_time']); $row['end'] = date("H:i:s", $row['end_time']); $topic[] = $row; } if ($com_time && $com_time < $end) { $topic[] = $this->getInfo($com_time, $end, $dates); } if (empty($topic)) { $topic[] = $this->getInfo($start, strtotime($dates . " 08:00:00"), $dates, 1); $topic[] = $this->getInfo(strtotime($dates . " 08:00:00"), $end, $dates); } $this->addItem_withkey('topic', $topic); $this->output(); }
public function show() { $channel_id = $this->input['channel_id']; if (!$channel_id) { $this->errorOutput('未传入频道ID'); } $suffix = 'live.m3u8'; if ($this->input['source']) { $cond = ' AND open_ts=1'; if ($this->input['source'] == 2) { $suffix = 'live.mp4'; } } $sql = "select * from " . DB_PREFIX . "channel where id=" . $channel_id . $cond; $channel_info = $this->db->query_first($sql); $imgsize = $this->input['imgsize'] ? $this->input['imgsize'] : '450x341'; $info = array(); if (is_array($channel_info)) { $info['id'] = $channel_info['id']; $info['channel']['name'] = $channel_info['name']; $info['channel']['drm'] = $channel_info['drm']; $logo = hg_get_images($channel_info['logo'], UPLOAD_URL . CHANNEL_IMG_DIR, $this->settings['channel_img_size']); $info['channel']['logo'] = $logo['img']; $info['channel']['snap'] = MMS_CONTROL_LIST_PREVIEWIMG_URL . $channel_info['ch_id'] . '/' . $channel_info['main_stream_name'] . '/' . TIMENOW * 1000 . '/' . $imgsize . '.png'; $info['channel']['m3u8'] = isset($this->input['_config']) ? $this->config[$info['id']] : hg_get_stream_url($this->settings['tvie']['stream_server'], array('channel' => $channel_info['code'], 'stream_name' => $channel_info['main_stream_name']), 'channels', 'http://', 'm3u8:'); $sql = "SELECT id,theme,start_time FROM " . DB_PREFIX . 'program WHERE channel_id =' . $channel_id . ' '; $sql .= ' AND start_time >= ' . TIMENOW . ' LIMIT 2'; $programq = $this->db->query($sql); $program = array(); while ($r = $this->db->fetch_array($programq)) { $program[$r['start_time']] = $r['theme']; } ksort($program); $p = array(); foreach ($program as $theme) { $p[] = $theme; } $info['channel']['cur_program'] = $p[0] ? $p[0] : '精彩节目'; $info['channel']['next_program'] = $p[1] ? $p[1] : '精彩节目'; //$info['ad'][] = array(); $sql = "select * from " . DB_PREFIX . "channel_stream where channel_id=" . $channel_id; $main_stream = $this->db->query($sql); $streams = array(); while ($r = $this->db->fetch_array($main_stream)) { /* if ($r['bitrate']) { $streams[$r['bitrate']] = array( 'url' => hg_get_stream_url($this->settings['tvie']['stream_server'], array('channel' => $channel_info['code'], 'stream_name' => $r['out_stream_name'])), 'bit' => $r['bitrate'] ); } else { */ $streams[] = array('url' => hg_get_stream_url($this->settings['tvie']['stream_server'], array('channel' => $channel_info['code'], 'stream_name' => $r['out_stream_name'])), 'bit' => $r['bitrate']); /* } */ } if ($streams) { krsort($streams); foreach ($streams as $key => $value) { $info['stream'][] = $value; } } } $this->addItem($info); $this->output(); }
/** * 获取其他选项 * @name getOtherOption * @access public * @author lijiaying * @category hogesoft * @copyright hogesoft * @param $vote_question_id int 投票ID * @param $offset int 查询起始数 * @param $count int 查询长度 * @return $info array 用户填写选项信息 */ public function getOtherOption() { $id = $this->input['vote_question_id']; $sql = "SELECT * FROM " . DB_PREFIX . "vote_question WHERE id=" . $id; $row = $this->db->query_first($sql); $this->setXmlNode('vote_question', 'info'); if (is_array($row) && $row) { $row['create_time'] = date('Y-m-d H:i:s', $row['create_time']); $row['update_time'] = date('Y-m-d H:i:s', $row['update_time']); $row['question_img'] = hg_get_images($row['pictures'], UPLOAD_URL . QUESTION_IMG_DIR, $this->settings['question_img_size']); $sql = "SELECT * FROM " . DB_PREFIX . "question_option WHERE vote_question_id IN(" . $id . ") ORDER BY id ASC"; $q = $this->db->query($sql); $row['option_title'] = $row['other_option_title'] = array(); while ($r = $this->db->fetch_array($q)) { if (!$r['is_other']) { $r['option_img'] = hg_get_images($r['pictures'], UPLOAD_URL . OPTION_IMG_DIR, $this->settings['option_img_size']); $row['option_title'][] = $r; } else { $row['other_option_title'][] = $r; } } if ($row['option_title']) { $row['vote_total'] = ""; foreach ($row['option_title'] as $vv) { $row['vote_total'] = $vv['single_total'] + $row['vote_total']; } } if ($row['other_option_title']) { $row['other_vote_total'] = ""; foreach ($row['other_option_title'] as $vv) { $row['other_vote_total'] = $vv['single_total'] + $row['other_vote_total']; } } $row['other_option_num'] = count($row['other_option_title']); $row['question_total'] = $row['vote_total'] + $row['other_vote_total']; //hg_pre($row); $this->addItem($row); $this->output(); } }
function show() { $this->channel_id = intval($this->input['channel_id']); $play_time = $this->input['play_time'] ? $this->input['play_time'] : 0; //是当前要播放的时间,我不想改了 if (!$this->channel_id) { $this->errorOutput(OBJECT_NULL); } $sql = "select * from " . DB_PREFIX . "channel where id=" . $this->channel_id; $channel_info = $this->db->query_first($sql); $info = array(); if (!$channel_info) { $this->errorOutput(OBJECT_NULL); } $channel_info['logo'] = hg_get_images($channel_info['logo'], UPLOAD_URL . CHANNEL_IMG_DIR, $this->settings['channel_img_size']); $channel_info['m3u8'] = isset($this->input['_config']) && $this->config[$this->channel_id] ? $this->config[$this->channel_id] . 'live.m3u8' : hg_get_stream_url($this->settings['tvie']['stream_server'], array('channel' => $channel_info['code'], 'stream_name' => $channel_info['main_stream_name'], 'backtime' => 'Backtime'), 'channels', 'http://', 'm3u8:'); if (!isset($this->input['zone'])) { $dates = urldecode($this->input['dates']) ? urldecode($this->input['dates']) : date("Y-m-d", time()); if ($play_time) { $dates = date("Y-m-d", $play_time); } } else { $zone = intval($this->input['zone']); if ($zone) { $dates = date('Y-m-d', strtotime($zone . ' day')); } else { $dates = date('Y-m-d'); } } $this->play_time = $play_time; $sql = "select id,channel_id,start_time,toff,theme,subtopic,type_id,dates,weeks,describes from " . DB_PREFIX . "program where channel_id=" . $this->channel_id . " AND dates='" . $dates . "' ORDER BY start_time ASC "; $q = $this->db->query($sql); $this->m = 0; $program_plan = $this->getPlan($dates); $program = array(); $start = strtotime($dates . " 00:00:00"); $end = strtotime($dates . " 23:59:59"); $com_time = 0; while ($row = $this->db->fetch_array($q)) { $start_time = $row['start_time']; $end_time = $row['start_time'] + $row['toff']; $display = $lave_time = $now_play = $zhi_play = 0; if (!$com_time && $start_time > $start) { $plan = $this->verify_plan($program_plan, $start, $start_time); if ($plan) { foreach ($plan as $k => $v) { $program[] = $v; } } else { $program[] = $this->getInfo($start, $start_time, $dates); } } if ($com_time && $com_time > $start_time) { $plan = $this->verify_plan($program_plan, $com_time, $start_time); if ($plan) { foreach ($plan as $k => $v) { $program[] = $v; } } else { $program[] = $this->getInfo($com_time, $start_time, $dates); } } if ($start_time < TIMENOW) { $display = 1; } if ($start_time < TIMENOW && $end_time > TIMENOW) { $zhi_play = 1; $lave_time = $end_time - TIMENOW; if (!$this->m && !$play_time) { $now_play = $this->m = 1; } } if ($play_time && $start_time <= $play_time && $end_time > $play_time) { $now_play = 1; $lave_time = 0; } $row['start'] = date("H:i", $start_time); $row['end'] = date("H:i", $end_time); $row['zhi_play'] = $zhi_play; $row['now_play'] = $now_play; $row['display'] = $display; $row['lave_time'] = $lave_time; if (!$row['theme']) { $row['theme'] = '精彩节目'; } $row['stime'] = date("H:i", $start_time); $com_time = $end_time; $program[] = $row; } if ($com_time && $com_time < $end) { $plan = $this->verify_plan($program_plan, $com_time, $end); if ($plan) { foreach ($plan as $k => $v) { $program[] = $v; } } else { $program[] = $this->getInfo($com_time, $end, $dates); } } if (empty($program)) { $this->m = 0; $program = $this->copy_program($start, $end); } /* include(CUR_CONF_PATH . 'lib/program_screen.class.php'); $this->screen = new programScreen(); $cond = " AND channel_id=" . $this->channel_id . " AND date='" . $dates . "'"; $screen = $this->screen->show($cond); if(!empty($program) && !empty($screen)) //处理屏蔽节目 { foreach($program as $k => $v) { if(!$v['new']) { $start_time = $v['start_time']; $end_time = $v['start_time'] + $v['toff']; foreach($screen as $key => $value) { if($value['start_time'] == $start_time && ($value['start_time']+$value['toff']) == $end_time) { $program[$k]['screen_id'] = $value['id']; return false; } else { if($value['start_time'] >= $start_time && $value['start_time'] < $end_time) { $program[$k]['screen_id'] = $value['id']; } if($value['start_time'] < $start_time) { if(($value['start_time']+$value['toff']) > $start_time) { $program[$k]['screen_id'] = $value['id']; } } } } } } } */ foreach ($program as $key => $value) { if ($value['start_time'] < TIMENOW - $channel_info['save_time'] * 3600) { $value['display'] = 0; } $value['channel_name'] = $channel_info['name']; $value['channel_logo'] = $channel_info['logo']; $value['channel_id'] = $channel_info['id']; $value['m3u8'] = isset($this->input['_config']) && $this->config[$this->channel_id] ? $this->config[$this->channel_id] . $value['start_time'] . '000,' . $value['toff'] . '000.m3u8' : str_replace('Backtime', $value['start_time'] . '000,' . ($value['start_time'] + $value['toff']) . '000.m3u8', $channel_info['m3u8']); $this->addItem($value); } $this->output(); }