function show() { include_once ROOT_PATH . 'api/lib/video.class.php'; $this->mVideo = new video(); $mInfo = $this->mUser->verify_credentials(); $mInfo['id'] = $mInfo['id'] ? $mInfo['id'] : 0; $count = intval($this->input['count'] ? $this->input['count'] : 0); $page = intval($this->input['page'] ? $this->input['page'] : 0); $end = ""; $offset = $page * $count; if ($count) { $end = " LIMIT " . $offset . "," . $count; } $condition = $this->input['condition'] ? ' AND username LIKE "%' . urldecode($this->input['condition']) . '%" ' : ''; $sql = "SELECT COUNT(*) AS nums FROM " . DB_PREFIX . "user WHERE 1 " . $condition; $r = $this->db->query_first($sql); $total_nums = $r['nums']; $sql = "SELECT id, username,avatar,register_time,email,ip,collect_count,comment_count \r\n\t\tFROM " . DB_PREFIX . "user\r\n\t\tWHERE 1 " . $condition . "\t\t\r\n\t\tORDER BY collect_count DESC ,register_time DESC " . $end; $id = ""; $space = " "; $query = $this->db->query($sql); 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['larger_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']); } $id .= $space . $array['id']; $space = ','; $info[] = $array; } $program = $this->getPrgramByUserid($id); if ($info) { $sta_id = ""; $space = ""; foreach ($info as $key => $value) { $info[$key]['program'] = hg_check_time($program[$value['id']]); if (is_array($program[$value['id']])) { $info[$key]['sta_id'] = $program[$value['id']][0]['sta_id']; } else { $info[$key]['sta_id'] = 0; } $sta_id .= $space . $info[$key]['sta_id']; $space = ","; } if ($sta_id) { $re = $this->mVideo->get_concern_relevance($mInfo['id'], $sta_id); foreach ($info as $key => $value) { $info[$key]['relation'] = $re[$value['sta_id']]['relation']; $info[$key]['concern_id'] = $re[$value['sta_id']]['id']; } } } $info[] = $total_nums; $this->setXmlNode('user', 'info'); $this->addItem($info); $this->output(); }
/** * 根据条件来查询多个节目单信息 * @return $info 节目单信息 */ function shows() { $mInfo = $this->mUser->verify_credentials(); $sta_id = $this->input['sta_id'] ? urldecode($this->input['sta_id']) : 0; $program_id = $this->input['program_id'] ? urldecode($this->input['program_id']) : 0; $user_id = $this->input['user_id'] ? urldecode($this->input['user_id']) : 0; $cond = " 1 "; if ($user_id) { $cond .= " AND user_id IN(" . $user_id . ")"; } if ($sta_id) { $cond .= " AND sta_id IN(" . $sta_id . ")"; } if ($program_id) { $cond .= " AND id IN (" . $program_id . ")"; } if (!$user_id && !$sta_id && !$program_id) { $this->errorOutput(OBJECT_NULL); } $sql = "SELECT * FROM " . DB_PREFIX . "network_programme WHERE " . $cond . " ORDER BY order_id DESC"; $query = $this->db->query($sql); $video_id = ""; $space = " "; while ($array = $this->db->fetch_array($query)) { $program[] = $array; $video_id .= $space . $array['video_id']; $space = ","; } $program = hg_check_time($program); if ($video_id) { $sql = "SELECT * FROM " . DB_PREFIX . "video WHERE id IN(" . $video_id . ")"; $query = $this->db->query($sql); while ($array = $this->db->fetch_array($query)) { if ($array['images']) { $array = hg_video_image($array['id'], $array); } $video[$array['id']] = $array; } } $re = $this->mVideo->get_collect_relevance($mInfo['id'], $video_id, 0); foreach ($program as $key => $value) { if ($video_id) { $program[$key]['video'] = $video[$value['video_id']]; } $program[$key]['video']['relation'] = $re[$value['video_id']]['relation']; $program[$key]['video']['collect_id'] = $re[$value['video_id']]['id']; } $this->setXmlNode('user', 'info'); $this->addItem($program); $this->output(); }