示例#1
0
 function delete_user_uploads($user_id)
 {
     if (!$user_id) {
         return false;
     }
     $dirname = './uploads_wall/';
     // delete photos
     $photo_upload = new he_upload($user_id, 'wall_photo');
     $photo_uploads = $photo_upload->get_user_uploads();
     foreach ($photo_uploads as $upload) {
         $filename = $upload['uploads_filename'];
         $filename_arr = explode('.', $filename);
         $filename_thumb = $filename_arr[0] . '_thumb.' . $filename_arr[1];
         @unlink($dirname . $filename);
         @unlink($dirname . $filename_thumb);
     }
     $photo_upload->delete_user_uploads();
     // delete music
     $music_upload = new he_upload($user_id, 'wall_music');
     $music_uploads = $music_upload->get_user_uploads();
     foreach ($music_uploads as $upload) {
         $filename = $upload['uploads_filename'];
         @unlink($dirname . $filename);
     }
     $music_upload->delete_user_uploads();
     // delete video thumb
     $video_upload = new he_upload($user_id, 'wall_video');
     $video_uploads = $video_upload->get_user_uploads();
     foreach ($video_uploads as $upload) {
         $filename = $upload['uploads_filename'];
         @unlink($dirname . $filename);
     }
     $video_upload->delete_user_uploads();
 }
function he_wall_youtube_video_custom_upload($new_action_id, $video_url, $pages_id = 0)
{
    global $setting, $user, $url;
    $video_query = parse_url($video_url);
    if (!isset($video_query['query']) || !$video_query['query']) {
        return array('result' => 0, 'message' => SE_Language::get(690706074));
    }
    $video_vars = array();
    parse_str($video_query['query'], $video_vars);
    if (!isset($video_vars['v']) || !$video_vars['v']) {
        return array('result' => 0, 'message' => SE_Language::get(690706074));
    }
    $video_code = $video_vars['v'];
    $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] : '';
    $instance_id = $pages_id ? $pages_id : $new_action_id;
    $instance_type = $pages_id ? 'pages_video' : 'wall_video';
    $upload_dir = $pages_id ? './uploads_pages/' : './uploads_wall/';
    $he_upload = new he_upload($user->user_info['user_id'], $instance_type);
    $upload_id = $he_upload->new_upload($instance_id);
    $file_name = "{$he_upload->instance_type}_{$upload_id}.jpg";
    $file_path = $upload_dir . $file_name;
    $video_thumb_src = $video_thumb['url'];
    $thumb_dimensions = array($video_thumb['width'], $video_thumb['height']);
    $video_result = he_wall_update_video_thumb($video_thumb_src, $file_path, $thumb_dimensions);
    $he_upload->save_upload($upload_id, $file_name);
    $video_result['result'] = 1;
    $video_result['title'] = $video_title;
    $video_result['description'] = strip_tags($video_description);
    $video_result['media_src'] = $url->url_base . substr($file_path, 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);
    if ($pages_id) {
        $pages_video = new he_pages_video($pages_id, $user->user_info['user_id']);
        $video_result['video_id'] = $pages_video->video_add($video_code, 'youtube', $video_title, $video_result['description'], $file_name, $video_result['video_length']);
    }
    $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;
}