function he_wall_youtube_video_upload($new_action_id, $video_url, $video_privacy_level) { global $setting, $user, $url; if (!$user->level_info['level_youtube_allow']) { return array('result' => 0, 'message' => SE_Language::get(690706078)); } $video = new se_video($user->user_info['user_id'], 0); $total_videos = $video->video_total(); if ($total_videos >= $user->level_info['level_video_maxnum']) { return array('result' => 0, 'message' => SE_Language::get(5500201)); } // GET PRIVACY SETTINGS $level_video_privacy = unserialize($user->level_info['level_video_privacy']); rsort($level_video_privacy); $level_video_comments = unserialize($user->level_info['level_video_comments']); rsort($level_video_comments); $video->video_info = array('video_title' => '', 'video_desc' => '', 'video_search' => true, 'video_privacy' => $video_privacy_level, 'video_comments' => $level_video_comments[0]); $video_code = extract_youtube_code($video_url); $video_info_json = @file_get_contents("http://gdata.youtube.com/feeds/api/videos/{$video_code}?alt=json"); if ($video_info_json === false) { return array('result' => 0, 'message' => SE_Language::get(690706074)); } $video_info = $video_info_json ? json_decode($video_info_json, true) : array(); $video_title = isset($video_info['entry']['title']['$t']) ? $video_info['entry']['title']['$t'] : ''; $video_description = isset($video_info['entry']['content']['$t']) ? $video_info['entry']['content']['$t'] : ''; $video_duration = isset($video_info['entry']['media$group']['yt$duration']['seconds']) ? $video_info['entry']['media$group']['yt$duration']['seconds'] : ''; $video_thumb = isset($video_info['entry']['media$group']['media$thumbnail'][3]) ? $video_info['entry']['media$group']['media$thumbnail'][3] : ''; $video_thumb_src = $video_thumb['url']; $thumb_dimensions = array($video_thumb['width'], $video_thumb['height']); $video_thumb_dimensions = array($setting['setting_video_thumb_width'], $setting['setting_video_thumb_height']); $video_id = he_wall::add_youtube_video($video_code, censor(str_replace(array("\r", "\n"), "<br>", $video_title)), censor(str_replace(array("\r", "\n"), "<br>", $video_description)), true, $video_privacy_level, $level_video_comments[0]); he_wall::add_video_action_link($user->user_info['user_id'], $new_action_id, $video_id); $video_directory = $video->video_dir($user->user_info['user_id'], true); $destination = $video_directory . $video_id . '_thumb.jpg'; $video_result = he_wall_update_video_thumb($video_thumb_src, $destination, $thumb_dimensions, $video_thumb_dimensions); $video_result['result'] = 1; $video_result['title'] = $video_title; $video_result['description'] = $video_description; $video_result['media_src'] = $url->url_base . substr($destination, 2); $video_result['video_url'] = $url->url_base . 'wall_action.php?id=' . $new_action_id; $video_result['video_length'] = he_wall_format_duration($video_duration); $width = $setting['setting_he_wall_video_player_width']; $height = $setting['setting_he_wall_video_player_height']; $video_result['player'] = '<object width="' . $width . '" height="' . $height . '"><param name="wmode" value="transparent"></param><param name="movie" value="http://www.youtube.com/v/' . $video_code . '&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed wmode="transparent" src="http://www.youtube.com/v/' . $video_code . '&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' . $width . '" height="' . $height . '"></embed></object>'; return $video_result; }