/** * Store a newly created post in storage. * * @return Response */ public function postAnswer($question_id) { $validate = Validator::make(Input::all(), Answer::$rules); if ($validate->passes()) { //get file from input $audio = Input::file('audio'); //get file's temporary path in server $file_temporary_path = $audio->getPathname(); //create MP3 Object $audio_file = new MP3($file_temporary_path); $duration = $audio_file->getDuration(); #Do same thing in 1 line: #$duration = with(new MP3($audio->getPathname()))->getDuration(); //check if audio is less than/equal to 120 Seconds, then save it! if ($duration <= 120) { //seconds $name = time() . '-' . $audio->getClientOriginalName(); //Move file from temporary folder to PUBLIC folder. //PUBLIC folder because we want user have access to this file later. $avatar = $audio->move(public_path() . '/answers/', $name); $answer = new Answer(); $answer->title = Input::get('title'); $answer->info = Input::get('info'); $answer->audio = $name; if (Auth::check()) { $answer->user_id = Auth::id(); } else { $answer->user_id = 0; } $answer->save(); } return Redirect::action('AnswerController@index'); } return Redirect::back()->withErrors($validate)->withInput(); }
public function download() { $url = Input::get('url'); $mp3 = MP3::whereUrl($url)->first(); if ($mp3) { $mp3->count += 1; $mp3->save(); $count = MP3::sum('count'); $response = ['success' => true, 'link' => $mp3->link, 'count' => $count, 'title' => $mp3->title]; return $response; } if (!empty($url)) { $meta = Keeng::getMeta($url); // return $meta; if ($meta) { $mp3 = new MP3(); $mp3->title = $meta['title']; $mp3->url = $url; $mp3->link = $meta['link']; $mp3->count = 1; $mp3->save(); $count = MP3::sum('count'); $response = ['success' => true, 'url' => $url, 'link' => $meta['link'], 'count' => $count, 'title' => $meta['title']]; return $response; } return ['success' => false]; } }
public function get_mp4() { $mp4 = MP4::remember(120)->latest()->paginate(30); $mp4_count = MP3::remember(120)->count(); $title = 'Administrayon Videyo (' . $mp4_count . ')'; return View::make('admin.mp4.index')->withTitle($title)->withMp4s($mp4)->withmp4Count($mp4_count); }
public function getIndex() { $mp3s = MP3::remember(120)->latest()->published()->take(3)->get(); $mp4s = MP4::remember(120)->latest()->take(3)->get(); $data = ['mp3s', 'mp4s']; return View::make('home', compact($data)); }
private function searchMP3($query) { $mp3results = MP3::published()->search($query)->orderBy('play', 'desc')->orderBy('download', 'desc')->take(20)->get(['id', 'name', 'play', 'download', 'image', 'price']); $mp3results->each(function ($mp3) { $mp3->icon = 'music'; $mp3->type = 'mp3'; }); return $mp3results; }
public function searchMP3($query) { $mp3s = MP3::where('name', 'like', '%' . $query . '%')->paginate(20, ['id', 'name', 'play', 'download', 'image']); $mp3s->each(function ($mp3) { $mp3->icon = 'music'; $mp3->type = 'mp3'; }); $data = ['mp3s' => $mp3s, 'query' => $query, 'title' => $query]; return View::make('search.mp3')->with($data); }
private function getRSS($type) { $key = $type . '_rss_feed_'; if (Cache::has($key)) { return Cache::get($key); } if ($type == 'mp3') { $objs = MP3::published()->latest()->take(10)->get(); $hash = 'Mizik'; } elseif ($type == 'mp4') { $objs = MP4::latest()->take(10)->get(); $hash = 'Videyo'; } $rss = $this->buildRssData($objs, $type, $hash); $rss = Response::make($rss)->header('Content-type', 'application/rss+xml'); Cache::put($key, $rss, 30); return $rss; }
$count = 0; $arr = explode('/', $newdir); $name = $arr[count($arr) - 1]; $output = "[playlist]\n"; $output .= "NumberOfEntries="; $output .= count($contents) - 1 . "\n"; $output .= "Version=2\n\n"; if ($_GET['shuffle']) { for ($x = 0; $x < 4; $x++) { shuffle($contents); } } foreach ($contents as $entry) { // Ignore files < 300k (usually ads) if (filesize($newdir . "/" . $entry) > 307200) { $mp3 = new MP3($newdir . "/" . $entry); $mp3->get_info(); $output .= "File{$count}=http://{$serverurl}/{$browserdir}/mp3/?file=" . urlencode($newdir . "/" . $entry) . "\n"; $title = explode(".", $entry); $title = $title[0]; $output .= "Title{$count}={$title}\n"; $output .= "Length{$count}="; $output .= $mp3->info["length"]; $output .= "\n\n"; } $count += 1; } } elseif ($_GET['server']) { $server = $_GET['server']; $name = $_GET['name']; $output = "[playlist]\n";
@endforeach </ul> @endif </div> </div> <div class="col-sm-4"> <div class="list-group"> <li class="list-group-item bg-black"> <h4>Popular Videos</h4> </li> <?php $mp3s = MP3::orderBy('id', 'desc')->take(5)->get(); ?> @if ( $mp3s && count( $mp3s ) > 0 ) @foreach( $mp3s as $mp3 ) <strong> <a class="list-group-item" href="/mp3/{{ $mp3->id }}"> {{ $mp3->name }} </a> </strong> @endforeach @endif
public function postBuy($id) { $code = Input::get('code'); if (Auth::check()) { $mp3 = MP3::find($id); $user = Auth::user(); if ($user->id == $mp3->user_id) { return Redirect::back()->withMessage(Config::get('site.message.cant-buy')); } $bought = MP3Sold::whereUserId($user->id)->whereMp3Id($mp3->id)->first(); if ($bought) { return Redirect::to('/user/my-bought-mp3s')->withMessage(Config::get('site.message.bought-already')); } if ($code == $mp3->code) { $sold = new MP3Sold(); $sold->user_id = $user->id; $sold->mp3_id = $mp3->id; $sold->save(); $mp3->buy_count += 1; $mp3->save(); return Redirect::to("/user/my-bought-mp3s")->withMessage(Config::get('site.message.bought-success')); } else { return Redirect::back()->withMessage(Config::get('site.message.bought-failed')); } } return Redirect::to('/login')->withMessage(Config::get('site.message.login')); }
public function boughtMP3s() { $user = Auth::user(); $mp3count = $user->mp3s()->count(); $mp4count = $user->mp4s()->count(); $mp3playcount = $user->mp3s()->sum('play'); $mp3downloadcount = $user->mp3s()->sum('download'); $mp4downloadcount = $user->mp4s()->sum('download'); $mp3ViewsCount = $user->mp3s()->sum('views'); $mp4ViewsCount = $user->mp4s()->sum('views'); $firstname = TKPM::firstName($user->name); $bought_mp3s = $user->bought()->get(['mp3_id']); $mp3s = []; $mp3_ids = []; foreach ($bought_mp3s as $bought_mp3) { $mp3_ids[] = $bought_mp3->mp3_id; } if ($mp3_ids) { $mp3s = MP3::find($mp3_ids)->reverse(); } $bought_mp3s_count = $bought_mp3s->count(); $title = "Ou achte {$bought_mp3s_count} mizik"; return View::make('user.bought-mp3')->with('title', $title)->with('mp3s', $mp3s)->with('first_name', $firstname)->with('mp3count', $mp3count)->with('mp4count', $mp4count)->with('mp3playcount', $mp3playcount)->with('mp3downloadcount', $mp3downloadcount)->with('mp4downloadcount', $mp4downloadcount)->with('mp3ViewsCount', $mp3ViewsCount)->with('mp4ViewsCount', $mp4ViewsCount)->with('user', $user)->withBoughtCount($bought_mp3s_count); }