<?php } ?> <?php } ?> <!-- YOUTUBE VIDEO --> <?php if (strpos($item->vid_url, 'youtube') > 0 || strpos($item->vid_url, 'youtu.be') > 0) { ?> <iframe title="YouTube video player" class="youtube-player" type="text/html" width="640" height="360" src="http://www.youtube.com/embed/<?php echo Youtubehelper::extractUTubeVidId($item->vid_url); ?> ?theme=light&rel=0" frameborder="0" allowFullScreen></iframe> <!-- VIMEO VIDEO --> <?php } elseif (strpos($item->vid_url, 'vimeo') > 0) { ?> <?php $vimeo_id = (int) substr(parse_url($item->vid_url, PHP_URL_PATH), 1); ?> <iframe src="//player.vimeo.com/video/<?php echo $vimeo_id;
/** * Store a newly created resource in storage. * * @return Response */ public function store() { if (!Auth::guest() && Auth::user()->active) { $input = Input::all(); $validation = Validator::make($input, Media::$rules); $valid_media = false; if (isset($input['pic_url']) && !empty($input['pic_url'])) { $valid_media = true; } else { if (isset($input['img_url']) && $input['img_url'] != '') { $valid_media = true; } else { if (isset($input['vid']) && $input['vid'] != '') { $valid_media = true; } } } if ($validation->passes() && $valid_media) { if (isset($input['pic'])) { if (isset($input['img_url']) && $input['img_url'] != '') { $input['pic_url'] = ImageHandler::uploadImage($input['img_url'], 'images', Helper::slugify($input['title']), 'url'); } else { if (isset($input['pic_url'])) { $input['pic_url'] = ImageHandler::uploadImage(Input::file('pic_url'), 'images'); } } $input['pic'] = 1; } unset($input['img_url']); if (isset($input['vid'])) { if (isset($input['vid_url'])) { unset($input['vid']); if (strpos($input['vid_url'], 'youtube') > 0 || strpos($input['vid_url'], 'youtu.be') > 0) { $video_id = Youtubehelper::extractUTubeVidId($input['vid_url']); if (isset($video_id[1])) { $img_url = 'http://img.youtube.com/vi/' . $video_id . '/0.jpg'; $input['pic_url'] = ImageHandler::uploadImage($img_url, 'images', true, Helper::slugify($input['title']), 'url'); } else { unset($input['vid_url']); } $input['vid'] = 1; } elseif (strpos($input['vid_url'], 'vimeo') > 0) { $vimeo_id = (int) substr(parse_url($input['vid_url'], PHP_URL_PATH), 1); $link = unserialize(file_get_contents("http://vimeo.com/api/v2/video/{$vimeo_id}.php")); $image = $link[0]['thumbnail_large']; $input['pic_url'] = ImageHandler::uploadImage($image, 'images', Helper::slugify($input['title']), 'url'); $input['vid'] = 1; } elseif (strpos($input['vid_url'], 'vine') > 0) { $video_id = explode('/v/', $input['vid_url']); $video_id = str_replace('/embed', '', $video_id[1]); $video_id = str_replace('/', '', $video_id); if (isset($video_id)) { ini_set('default_socket_timeout', 120); $vine = file_get_contents("http://vine.co/v/{$video_id}"); preg_match('/property="og:image" content="(.*?)"/', $vine, $matches); $image = $matches[1] ? $matches[1] : ''; $input['pic_url'] = ImageHandler::uploadImage($image, 'images', Helper::slugify($input['title']), 'url'); } else { unset($input['vid_url']); } $input['vid'] = 1; } } } $this->add_daily_media_points(); $setting = Setting::first(); if (!$setting->auto_approve_posts) { $input['active'] = 0; } if (isset($input['nsfw'])) { $input['nsfw'] = 1; } else { $input['nsfw'] = 0; } $input['title'] = htmlspecialchars(stripslashes($input['title'])); $input['slug'] = Helper::slugify($input['title']); if (isset($input['description'])) { $input['description'] = htmlspecialchars(stripslashes($input['description'])); } $slugexist = Media::where('slug', '=', $input['slug'])->first(); $increment = 1; while (isset($slugexist->id)) { $input['slug'] = $input['slug'] . '-' . $increment; $slugexist = Media::where('slug', '=', $input['slug'])->first(); $increment += 1; } $new_media = $this->media->create($input); return Redirect::to('media' . '/' . $new_media->slug)->with(array('note' => Lang::get('lang.upload_success'), 'note_type' => 'success')); } return Redirect::to('/upload')->with(array('note' => Lang::get('lang.error_uploading'), 'note_type' => 'error')); } else { return Redirect::to('/')->with(array('note' => Lang::get('lang.login_to_upload'), 'note_type' => 'error')); } }