/**
  * Store a newly created resource in storage.
  * @param itemid <=== What?
  * @param itemtype
  * @param userid
  * @param string key
  * @return Response
  */
 public function store()
 {
     $itemid = Input::get('itemid');
     $itemtype = Input::get('itemtype');
     $userid = Input::get('userid');
     $usercomment = Input::get('comment');
     $key = Input::get('key');
     $retVal = array('status' => 'ERR', 'msg' => 'Invalid Session');
     try {
         $user = \Member::where('session_key', '=', $key)->exists();
         if (!$user) {
             return Response::json($retVal);
         }
         $media = \Media::where('_id', '=', $itemid)->exists();
         //var_dump($media);
         if (!$media) {
             $retVal = array('status' => 'ERR', 'msg' => 'Invalid item.');
             return Response::json($retVal);
         }
         $comment = new \Comments();
         $comment->itemid = $itemid;
         $comment->itemtype = $itemtype;
         $comment->userid = $userid;
         $comment->comment = $usercomment;
         $comment->save();
         $retVal = array('status' => 'OK');
         return Response::json($retVal);
     } catch (ModelNotFoundException $e) {
     }
 }
 public function getEditmedias($id, $module_id)
 {
     $medias = Media::where('category_id', $id)->orderBy('name')->get();
     $memberships = Membership::orderBy('rank')->get();
     $modMediaMembership = array();
     foreach (ModuleMediaMembership::where('module_id', $module_id)->get() as $mmm) {
         $modMediaMembership[$mmm->media_id][$mmm->membership_id] = true;
     }
     return \View::make('redminportal::modules/medias')->with('medias', $medias)->with('memberships', $memberships)->with('modMediaMembership', $modMediaMembership);
 }
Beispiel #3
0
 public function getCoverAttribute()
 {
     $cover = Media::where('id', $this->attributes['cover_id'])->get(array('url', 'extension'))->first();
     if (!empty($cover->url)) {
         $response = $cover->url . "_cover." . $cover->extension;
     } else {
         $response = "themes/vdomax1.1/images/default-cover.png";
     }
     return $this->attributes['cover'] = $response;
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     $media = \Media::where('status', 'approved')->orderBy('createdDate', 'desc')->get();
     for ($i = 0; $i < count($media); $i++) {
         $media[$i]->mongoid = $media[$i]->_id;
         $media[$i]->token = $media[$i]->_token;
         unset($media[$i]->_id);
         unset($media[$i]->_token);
         unset($media[$i]->thumbnail_url);
         unset($media[$i]->large_url);
         unset($media[$i]->medium_url);
         unset($media[$i]->full_url);
         unset($media[$i]->delete_type);
         unset($media[$i]->delete_url);
         unset($media[$i]->filename);
         unset($media[$i]->filesize);
         unset($media[$i]->temp_dir);
         unset($media[$i]->filetype);
         unset($media[$i]->is_image);
         unset($media[$i]->is_audio);
         unset($media[$i]->is_video);
         unset($media[$i]->fileurl);
         unset($media[$i]->file_id);
         unset($media[$i]->caption);
         // non file related
         unset($media[$i]->lyric);
         unset($media[$i]->files);
         $dm = $media[$i]->defaultmedias;
         unset($dm['delete_type']);
         unset($dm['delete_url']);
         unset($dm['temp_dir']);
         $media[$i]->defaultmedias = $dm;
         foreach ($dm as $k => $v) {
             $name = 'media' . str_replace(' ', '', ucwords(str_replace('_', ' ', $k)));
             $media[$i]->{$name} = $v;
         }
         unset($media[$i]->defaultmedias);
         $dp = $media[$i]->defaultpictures;
         unset($dp['delete_type']);
         unset($dp['delete_url']);
         unset($dp['temp_dir']);
         foreach ($dp as $k => $v) {
             $name = 'picture' . str_replace(' ', '', ucwords(str_replace('_', ' ', $k)));
             $media[$i]->{$name} = $v;
         }
         unset($media[$i]->defaultpictures);
         $media[$i]->createdDate = date('Y-m-d H:i:s', $media[$i]->createdDate->sec);
         $media[$i]->lastUpdate = date('Y-m-d H:i:s', $media[$i]->lastUpdate->sec);
     }
     return $media;
 }
Beispiel #5
0
 public function getMedia()
 {
     $response = Media::where('active', '=', '1');
     if (Input::get('offset')) {
         $reponse = $response->skip(Input::get('offset'));
     }
     if (Input::get('filter') && Input::get('order')) {
         $response = $response->orderBy(Input::get('filter'), Input::get('order'));
     } else {
         $response = $response->orderBy('created_at', 'desc');
     }
     if (Input::get('limit')) {
         $response = $response->take(Input::get('limit'));
     } else {
         $response = $response->take($this->default_limit);
     }
     return Response::json($response->get(), 200);
 }
Beispiel #6
0
 public function home()
 {
     try {
         $settings = Setting::first();
         if ($settings) {
             $search = Input::get('search');
             if (isset($search)) {
                 $media = Media::where('active', '=', 1)->where('title', 'LIKE', '%' . $search . '%')->orderBy('created_at', 'desc')->paginate(Config::get('site.num_results_per_page'));
             } else {
                 $media = Media::with('media_likes', 'comments')->where('active', '=', 1)->orderBy('created_at', 'desc')->paginate(Config::get('site.num_results_per_page'));
             }
             $data = array('media' => $media, 'search' => $search);
             return View::make('home', $data);
         } else {
             throw new Exception('settings not set, first install the script');
         }
     } catch (Exception $e) {
         return Redirect::to('install');
     }
 }
Beispiel #7
0
 public function delete($user_id = NULL)
 {
     $user = $this->prepare_user($user_id);
     if ($this->ion_auth->is_admin($user_id)) {
         $url = 'manage_admins';
     } elseif ($this->ion_auth->is_manager($user_id)) {
         $url = 'manage_accounts';
     } else {
         $url = 'admin_users';
     }
     if ($this->ion_auth->is_collaborator($user_id)) {
         $this->c_user->delete($user);
     }
     $user_deleted = $this->ion_auth->delete_user($user->id);
     if (!$user_deleted) {
         $this->addFlash(lang('delete_error', [$this->ion_auth->errors()]));
         redirect('admin/admin_users');
     }
     $sender = $this->get('core.mail.sender');
     $sender->sendUserDeleteMail(array('user' => $user));
     $access_token = new Access_token();
     $access_token->where('user_id', $user->id)->get()->delete_all();
     $directory_user = new Directory_User();
     $directory_user->where('user_id', $user->id)->get()->delete_all();
     $facebook_fanpage = new Facebook_Fanpage();
     $facebook_fanpage->where('user_id', $user->id)->get()->delete_all();
     $keyword = new Keyword();
     $keyword->where('user_id', $user->id)->get();
     foreach ($keyword as $k) {
         $keyword_rank = new Keyword_rank();
         $keyword_rank->where('keyword_id', $k->id)->get()->delete_all();
     }
     $keyword->delete_all();
     $media = new Media();
     $media->where('user_id', $user->id)->get()->delete_all();
     $post = new Post();
     $post->where('user_id', $user->id)->get();
     foreach ($post as $p) {
         $post_social = new Post_social();
         $post_social->where('post_id', $p->id)->get()->delete_all();
     }
     $post->delete_all();
     $review = new Review();
     $review->where('user_id', $user->id)->get()->delete_all();
     $reviews_notification = new Reviews_notification();
     $reviews_notification->where('user_id', $user->id)->get()->delete_all();
     $rss_feeds_users = new Rss_feeds_users();
     $rss_feeds_users->where('user_id', $user->id)->get()->delete_all();
     $social_post = new Social_post();
     $social_post->where('user_id', $user->id)->get()->delete_all();
     $social_value = new Social_value();
     $social_value->where('user_id', $user->id)->get()->delete_all();
     $user_additional = new User_additional();
     $user_additional->where('user_id', $user->id)->get()->delete_all();
     $user_feed = new User_feed();
     $user_feed->where('user_id', $user->id)->get()->delete_all();
     $user_timezone = new User_timezone();
     $user_timezone->where('user_id', $user->id)->get()->delete_all();
     $this->addFlash(lang('delete_success'), 'success');
     redirect('admin/' . $url);
 }
Beispiel #8
0
    $data = array('media' => $media, 'categories' => Category::all(), 'pages' => Page::all(), 'settings' => Setting::first());
    return View::make('Theme::home', $data);
});
Route::get('popular/month', function () {
    $media = Media::where('active', '=', '1')->join('media_likes', 'media.id', '=', 'media_likes.media_id')->where('media_likes.created_at', '>=', date('Y-m-d H:i:s', strtotime('-1 month')))->groupBy('media_likes.media_id')->orderBy(DB::raw('COUNT(media_likes.id)'), 'DESC')->select('media.*')->paginate(30);
    $data = array('media' => $media, 'categories' => Category::all(), 'pages' => Page::all(), 'settings' => Setting::first());
    return View::make('Theme::home', $data);
});
Route::get('popular/year', function () {
    $media = Media::where('active', '=', '1')->join('media_likes', 'media.id', '=', 'media_likes.media_id')->where('media_likes.created_at', '>=', date('Y-m-d H:i:s', strtotime('-1 year')))->groupBy('media_likes.media_id')->orderBy(DB::raw('COUNT(media_likes.id)'), 'DESC')->select('media.*')->paginate(30);
    $data = array('media' => $media, 'categories' => Category::all(), 'pages' => Page::all(), 'settings' => Setting::first());
    return View::make('Theme::home', $data);
});
// ********* TAGS ROUTE ********** //
Route::get('tags/{tag}', function ($tag) {
    $media = Media::where('active', '=', 1)->where('tags', 'LIKE', $tag . ',%')->orWhere('tags', 'LIKE', '%,' . $tag . ',%')->orWhere('tags', 'LIKE', '%,' . $tag)->orWhere('tags', '=', $tag)->orderBy('created_at', 'desc')->paginate(Config::get('site.num_results_per_page'));
    $data = array('media' => $media, 'tag' => $tag, 'categories' => Category::all(), 'pages' => Page::all(), 'settings' => Setting::first());
    return View::make('Theme::home', $data);
});
// ********* CATEGORY ROUTE ********** //
Route::get('category/{category}', 'CategoriesController@index');
// ********** USER AUTHENTICATION ROUTES  ********** //
// LOGIN
Route::get('login', function () {
    $settings = Setting::first();
    $facebook = new Facebook(array('appId' => $settings->fb_key, 'secret' => $settings->fb_secret_key, 'cookie' => true, 'oauth' => true));
    $params = array('scope' => 'email', 'redirect_uri' => URL::to("auth/facebook"));
    $loginUrl = $facebook->getLoginUrl($params);
    $data = array('type' => 'login', 'settings' => $settings, 'facebook' => $loginUrl);
    return View::make('Theme::auth', $data);
});
Beispiel #9
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($slug)
 {
     $media = Media::with('media_likes', 'comments')->where('slug', '=', $slug)->first();
     if (isset($media)) {
         $view_increment = $this->handleViewCount($media->id);
         $next = Media::where('active', '=', 1)->where('created_at', '>', date("Y-m-d H:i:s", strtotime($media->created_at)))->first();
         $previous = Media::where('active', '=', 1)->where('created_at', '<', date("Y-m-d H:i:s", strtotime($media->created_at)))->orderBy('created_at', 'desc')->first();
         $media_next = Media::where('active', '=', 1)->where('created_at', '>=', date("Y-m-d H:i:s", strtotime($media->created_at)))->take(6)->get();
         $next_media_count = $media_next->count();
         if ($next_media_count < 6) {
             $get_prev_results = 6 - $next_media_count;
             $media_prev = Media::where('active', '=', 1)->where('created_at', '<', date("Y-m-d H:i:s", strtotime($media->created_at)))->orderBy('created_at', 'DESC')->take($get_prev_results)->get();
         } else {
             $media_prev = array();
         }
         $data = array('item' => $media, 'media_next' => $media_next, 'next' => $next, 'previous' => $previous, 'media_prev' => $media_prev, 'view_increment' => $view_increment, 'settings' => Setting::first(), 'categories' => Category::all(), 'pages' => Page::all(), 'single' => true);
         return View::make('Theme::media', $data);
     } else {
         return Redirect::to('/');
     }
 }
Beispiel #10
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($slug)
 {
     $media = $this->media->where('slug', '=', $slug)->first();
     if (isset($media)) {
         $view_increment = $this->handleViewCount($media->id);
         $next = Media::where('active', '=', 1)->where('created_at', '>', date("Y-m-d H:i:s", strtotime($media->created_at)))->first();
         $previous = Media::where('active', '=', 1)->where('created_at', '<', date("Y-m-d H:i:s", strtotime($media->created_at)))->orderBy('created_at', 'desc')->first();
         $media_next = Media::where('active', '=', 1)->where('created_at', '>=', date("Y-m-d H:i:s", strtotime($media->created_at)))->take(6)->get();
         $next_media_count = $media_next->count();
         if ($next_media_count < 6) {
             $get_prev_results = 6 - $next_media_count;
             $media_prev = Media::where('active', '=', 1)->where('created_at', '<', date("Y-m-d H:i:s", strtotime($media->created_at)))->orderBy('created_at', 'DESC')->take($get_prev_results)->get();
         } else {
             $media_prev = array();
         }
         $data = array('media' => $media, 'media_next' => $media_next, 'next' => $next, 'previous' => $previous, 'media_prev' => $media_prev, 'view' => 'single', 'view_increment' => $view_increment);
         return View::make('media.show', $data);
     } else {
         return Redirect::to('/');
     }
 }
 public function getDelete($id)
 {
     // Find the category using the user id
     $category = Category::find($id);
     // Find if there's any child
     $children = Category::where('category_id', $id)->count();
     if ($children > 0) {
         $errors = new \Illuminate\Support\MessageBag();
         $errors->add('deleteError', "The category '" . $category->name . "' cannot be deleted because it has " . $children . " children categories.");
         return \Redirect::to('/admin/categories')->withErrors($errors);
     }
     // Check in use by media
     $medias = Media::where('category_id', $id)->get();
     if (count($medias) > 0) {
         $errors = new \Illuminate\Support\MessageBag();
         $errors->add('deleteError', "The category '" . $category->name . "' cannot be deleted because it is in used.");
         return \Redirect::to('/admin/categories')->withErrors($errors);
     }
     // Delete all images first
     $category->deleteAllImages();
     // Delete the category
     $category->delete();
     return \Redirect::to('admin/categories');
 }
Beispiel #12
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $config = array('host' => 'http://77.247.178.109:9018', 'endpoint' => '/datasrpc/rpc', 'username' => 'datasrpc', 'password' => 'Q8EAxtApHzNmz6UKHBQX');
     $hash = $this->option('hash');
     $media = Media::where('hash', '=', $hash)->first();
     $transmission = new Vohof\Transmission($config);
     $getFiles = $transmission->get($media->hash, array('files'));
     $files = $getFiles["arguments"]["torrents"][0]["files"];
     if (!empty($files)) {
         $media->files()->delete();
         $media->folders()->delete();
         $ignore_first_folder = true;
         $id = 1;
         $paths = array();
         foreach ($files as $file) {
             $fd = parse_url($file["name"]);
             $path_parts = pathinfo($fd['path']);
             $dirs = explode("/", $path_parts['dirname']);
             for ($i = 0; $i <= count($dirs); $i++) {
                 if (isset($dirs[$i]) && $dirs[$i] != '.') {
                     $full_path = $this->fullpath($dirs, $i);
                     if (array_key_exists($full_path, $paths)) {
                     } else {
                         $paths[$full_path]["id"] = $id;
                         $paths[$full_path]["name"] = $dirs[$i];
                         $prev_path = $this->fullpath($dirs, $i - 1);
                         if (!isset($paths[$prev_path]["id"])) {
                             $pv_p = 0;
                         } else {
                             $pv_p = $paths[$prev_path]["id"];
                         }
                         $new_folder = new MediaFlag();
                         $new_folder->name = $dirs[$i];
                         $new_folder->folder_id = $id;
                         $new_folder->in = $pv_p;
                         $new_folder->media_id = $media->id;
                         $new_folder->save();
                         $id++;
                     }
                 } elseif (isset($dirs[$i]) && $dirs[$i] == '.') {
                     //echo $path_parts["basename"].' 0';
                     $new_file = new MediaLike();
                     $new_file->path = $file["name"];
                     $new_file->name = $path_parts["basename"];
                     $new_file->type = $this->getExt($new_file->path);
                     $new_file->in = 0;
                     $new_file->size = $file["length"];
                     $new_file->media_id = $media->id;
                     //$like->user_id = Auth::user()->id;
                     $new_file->save();
                     $ignore_first_folder = false;
                 } else {
                     if (isset($dirs[$i - 1]) && $dirs[$i - 1] != '.') {
                         $full_path = $this->fullpath($dirs, $i - 1);
                         //echo $path_parts["basename"].' '.$paths[$full_path]["id"];
                         $new_file = new MediaLike();
                         $new_file->path = $file["name"];
                         $new_file->name = $path_parts["basename"];
                         $new_file->type = $this->getExt($new_file->path);
                         $new_file->in = $paths[$full_path]["id"];
                         $new_file->size = $file["length"];
                         $new_file->media_id = $media->id;
                         //$like->user_id = Auth::user()->id;
                         $new_file->save();
                     }
                 }
             }
         }
         $media["ignore_first"] = $ignore_first_folder;
         $media->save();
     }
     $files_local = $media->files();
     if (!empty($files_local)) {
         $max_file_id = null;
         $max_file_size = 0;
         foreach ($files_local as $file) {
             if ($file->type == "vid" || $file->type == "vid-conv") {
                 if ($file->size > $max_file_size) {
                     $max_file_size = $file->size;
                     $max_file_id = $file->id;
                 }
             }
         }
         $media->max_file_id = $max_file_id;
         $media->save();
         foreach ($files_local as $file) {
             if ($file->type == "vid" || $file->type == "vid-conv") {
                 if ($file->id == $max_file_id) {
                     echo $this->makeThumbs($media->id, $file->id, '/home/mfs/Downloads/transmission/completed/done/' . $media->id . '/' . $file->path, 1);
                 } else {
                     echo $this->makeThumbs($media->id, $file->id, '/home/mfs/Downloads/transmission/completed/done/' . $media->id . '/' . $file->path, 13);
                 }
             }
         }
     }
 }
Beispiel #13
0
 public function profile($username)
 {
     $user = User::where('username', '=', $username)->first();
     $medias = Media::where('user_id', '=', $user->id)->orderBy('created_at', 'desc')->paginate(Config::get('site.num_results_per_page'));
     $data = array('user' => $user, 'media' => $medias);
     return View::make('user.index', $data);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     $category = Category::find($id);
     $media = Media::where('category_id', '=', $id)->get();
     foreach ($media as $single_media) {
         $single_media->category_id = 1;
         $single_media->save();
     }
     $category->delete();
     return Redirect::to('admin?section=categories')->with(array('note' => Lang::get('lang.delete_success'), 'note_type' => 'success'));
 }
Beispiel #15
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $time_start = microtime(true);
     $media = Media::where('state', '!=', 'done')->where('state', '!=', 'failed')->where('state', '!=', 'max_pause')->where('state', '!=', 'process')->where('state', '!=', 'fail_free')->where('state', '!=', 'delete')->get();
     foreach ($media as $update) {
         try {
             if ($update->state === "put_pause") {
                 echo "start";
                 $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                 $myvars = 'mode=start&hash=' . $update->hash;
                 $ch = curl_init($url);
                 $username = '******';
                 $password = '******';
                 curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                 curl_setopt($ch, CURLOPT_POST, 1);
                 curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                 curl_setopt($ch, CURLOPT_HEADER, 0);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                 $response = curl_exec($ch);
                 $torrent_start = json_decode($response, true);
                 $update->state = "put_start";
                 $update->save();
             }
             $now = new DateTime();
             $now_stamp = $now->format('Y-m-d H:i:s');
             $diff = strtotime($now_stamp) - strtotime($update->featured_at);
             $diff_in_minss = $diff / 60;
             if ($diff_in_minss > 60 && $update->cat == 1 && $update->featured_at != "0000-00-00 00:00:00") {
                 $media_users = UserMedia::where('media_id', '=', $update->id)->get();
                 $del = true;
                 foreach ($media_users as $media_user) {
                     $user = User::where('id', '=', $media_user->user_id)->first();
                     if ($user->category_id == 1) {
                     } else {
                         $del = false;
                         $update->cat = $user->category_id;
                         $update->save();
                     }
                 }
                 if ($del) {
                     $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                     $input_xml = '<methodCall><methodName>system.multicall</methodName><params><param><value><array><data><value><struct><member><name>methodName</name><value><string>d.set_custom5</string></value></member><member><name>params</name><value><array><data><value><string>' . $update->hash . '</string></value><value><string>1</string></value></data></array></value></member></struct></value><value><struct><member><name>methodName</name><value><string>d.delete_tied</string></value></member><member><name>params</name><value><array><data><value><string>' . $update->hash . '</string></value></data></array></value></member></struct></value><value><struct><member><name>methodName</name><value><string>d.erase</string></value></member><member><name>params</name><value><array><data><value><string>' . $update->hash . '</string></value></data></array></value></member></struct></value></data></array></value></param></params></methodCall>';
                     $ch = curl_init($url);
                     $username = '******';
                     $password = '******';
                     curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                     curl_setopt($ch, CURLOPT_POST, 1);
                     curl_setopt($ch, CURLOPT_POSTFIELDS, $input_xml);
                     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                     curl_setopt($ch, CURLOPT_HEADER, 0);
                     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
                     curl_setopt($ch, CURLOPT_TIMEOUT, 4);
                     //timeout in seconds
                     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                     $response = curl_exec($ch);
                     $report = new UserFlag();
                     $report->type = 'check';
                     $report->media_id = $update->id;
                     $report->res = 'took more than an hour' . $response;
                     $report->save();
                     $update->state = 'fail_free';
                     $update->save();
                     $user_report = UserFlag::where('media_id', '=', $update->id)->where('type', '=', 'error')->first();
                     if (!isset($user_report->id)) {
                         $report = new UserFlag();
                         $report->type = 'error';
                         $report->media_id = $update->id;
                         $report->res = $response;
                         $report->save();
                     }
                 }
             } else {
                 $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                 $myvars = 'mode=list-get&hash=' . $update->hash;
                 $ch = curl_init($url);
                 $username = '******';
                 $password = '******';
                 curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                 curl_setopt($ch, CURLOPT_POST, 1);
                 curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                 curl_setopt($ch, CURLOPT_HEADER, 0);
                 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
                 curl_setopt($ch, CURLOPT_TIMEOUT, 4);
                 //timeout in seconds
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                 $response = curl_exec($ch);
                 $tor = json_decode($response, true);
                 if (count($tor != 0) && $tor != false) {
                     echo $tor[0];
                     echo "files begin";
                     if ($update->files()->count() == 0 && $update->file_try < 3 && $update->state == "downloading" || $update->files()->count() == 0 && $update->file_try == 3 && $update->state == "downloading" && $this->percent($tor[9], $tor[6]) > 0) {
                         echo "files";
                         if ($tor[3] != 0) {
                             if (strpos($update->title, '.meta') !== false) {
                                 echo "in";
                             } else {
                                 if (!empty($tor[26])) {
                                     $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                                     $myvars = 'mode=fls&hash=' . $tor[0];
                                     $ch = curl_init($url);
                                     $username = '******';
                                     $password = '******';
                                     curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                                     curl_setopt($ch, CURLOPT_POST, 1);
                                     curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                                     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                                     curl_setopt($ch, CURLOPT_HEADER, 0);
                                     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
                                     curl_setopt($ch, CURLOPT_TIMEOUT, 5);
                                     //timeout in seconds
                                     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                                     $response = curl_exec($ch);
                                     $torrent_files = json_decode($response, true);
                                     $files = $torrent_files;
                                     if (!empty($files)) {
                                         $ignore_first_folder = true;
                                         $id = 1;
                                         $paths = array();
                                         foreach ($files as $file) {
                                             if ($file[0] != $tor[0] . '.meta' && isset($file[0]) && !empty($file[0])) {
                                                 if ($tor[34] != 0) {
                                                     $fd = parse_url(basename(str_replace("#", "", $tor[26])) . '/' . str_replace("#", "", $file[0]));
                                                 } else {
                                                     $fd = parse_url(str_replace("#", "", $file[0]));
                                                 }
                                                 if (isset($fd['path'])) {
                                                     $path_parts = pathinfo($fd['path']);
                                                 } else {
                                                     $path_parts = pathinfo($file["name"]);
                                                 }
                                                 $dirs = explode("/", $path_parts['dirname']);
                                                 for ($i = 0; $i <= count($dirs); $i++) {
                                                     if (isset($dirs[$i]) && $dirs[$i] != '.') {
                                                         $full_path = $this->fullpath($dirs, $i);
                                                         if (array_key_exists($full_path, $paths)) {
                                                         } else {
                                                             $paths[$full_path]["id"] = $id;
                                                             $paths[$full_path]["name"] = $dirs[$i];
                                                             $prev_path = $this->fullpath($dirs, $i - 1);
                                                             if (!isset($paths[$prev_path]["id"])) {
                                                                 $pv_p = 0;
                                                             } else {
                                                                 $pv_p = $paths[$prev_path]["id"];
                                                             }
                                                             $new_folder = new MediaFlag();
                                                             $new_folder->name = $dirs[$i];
                                                             $new_folder->folder_id = $id;
                                                             $new_folder->in = $pv_p;
                                                             $new_folder->media_id = $update->id;
                                                             $new_folder->save();
                                                             $id++;
                                                         }
                                                     } elseif (isset($dirs[$i]) && $dirs[$i] == '.') {
                                                         //echo $path_parts["basename"].' 0';
                                                         $new_file = new MediaLike();
                                                         if ($tor[34] != 0) {
                                                             $new_file->path = basename(str_replace("#", "", $tor[26])) . '/' . str_replace("#", "", $file[0]);
                                                         } else {
                                                             $new_file->path = str_replace("#", "", $file[0]);
                                                         }
                                                         $new_file->name = $path_parts["basename"];
                                                         $new_file->type = $this->getExt($new_file->path);
                                                         $new_file->in = 0;
                                                         $new_file->size = $file[3];
                                                         $new_file->media_id = $update->id;
                                                         //$like->user_id = Auth::user()->id;
                                                         $new_file->save();
                                                         $ignore_first_folder = false;
                                                     } else {
                                                         if (isset($dirs[$i - 1]) && $dirs[$i - 1] != '.') {
                                                             $full_path = $this->fullpath($dirs, $i - 1);
                                                             //echo $path_parts["basename"].' '.$paths[$full_path]["id"];
                                                             $new_file = new MediaLike();
                                                             if ($tor[34] != 0) {
                                                                 $new_file->path = basename(str_replace("#", "", $tor[26])) . '/' . str_replace("#", "", $file[0]);
                                                             } else {
                                                                 $new_file->path = $file[0];
                                                             }
                                                             $new_file->type = $this->getExt($new_file->path);
                                                             $new_file->name = $path_parts["basename"];
                                                             $new_file->in = $paths[$full_path]["id"];
                                                             $new_file->size = $file[3];
                                                             $new_file->media_id = $update->id;
                                                             //$like->user_id = Auth::user()->id;
                                                             $new_file->save();
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                         $update["ignore_first"] = $ignore_first_folder;
                                         $update->save();
                                     }
                                     $update->file_try = $update->file_try + 1;
                                     $update->save();
                                 }
                             }
                         }
                     }
                     $info = $tor;
                     echo "max check begin";
                     $max_pause = false;
                     if (strpos($update->title, '.meta') !== false) {
                         echo "in";
                     } else {
                         if ($tor[5] != $update->hash . '.meta' && $info[29] != 0 && $info[6] != null && $info[6] != 0 && !empty($info[6]) && $update->max_check == 0) {
                             $max_pause = true;
                             $media_users = UserMedia::where('media_id', '=', $update->id)->get();
                             echo $info[6] . 'size';
                             foreach ($media_users as $media_user) {
                                 $user = User::where('id', '=', $media_user->user_id)->first();
                                 $user_cat = Category::where('id', '=', $user->category_id)->first();
                                 if ($info[6] > $user_cat->max_add) {
                                     $media_user->max_error = true;
                                     $media_user->save();
                                 } else {
                                     $max_pause = false;
                                 }
                             }
                             if ($max_pause) {
                                 $update->state = "max_pause";
                                 $update->save();
                                 $info["status"] = 7;
                                 $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                                 $input_xml = '<methodCall><methodName>system.multicall</methodName><params><param><value><array><data><value><struct><member><name>methodName</name><value><string>d.set_custom5</string></value></member><member><name>params</name><value><array><data><value><string>' . $update->hash . '</string></value><value><string>1</string></value></data></array></value></member></struct></value><value><struct><member><name>methodName</name><value><string>d.delete_tied</string></value></member><member><name>params</name><value><array><data><value><string>' . $update->hash . '</string></value></data></array></value></member></struct></value><value><struct><member><name>methodName</name><value><string>d.erase</string></value></member><member><name>params</name><value><array><data><value><string>' . $update->hash . '</string></value></data></array></value></member></struct></value></data></array></value></param></params></methodCall>';
                                 $ch = curl_init($url);
                                 $username = '******';
                                 $password = '******';
                                 curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                                 curl_setopt($ch, CURLOPT_POST, 1);
                                 curl_setopt($ch, CURLOPT_POSTFIELDS, $input_xml);
                                 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                                 curl_setopt($ch, CURLOPT_HEADER, 0);
                                 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
                                 curl_setopt($ch, CURLOPT_TIMEOUT, 4);
                                 //timeout in seconds
                                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                                 $response = curl_exec($ch);
                                 $report = new UserFlag();
                                 $report->type = 'check';
                                 $report->media_id = $update->id;
                                 $report->res = 'max pause' . $response;
                                 $report->save();
                             }
                             $update->max_check = 1;
                             $update->save();
                         }
                     }
                     echo "max check end";
                     if ($max_pause) {
                     } else {
                         $state = 'stop';
                         if ($info[1] != 0) {
                             $state = "downloading";
                             if ($info[4] == 0 || $info[29] == 0) {
                                 $state = "paused";
                             }
                         } elseif ($info[24] != 0) {
                             $state = "hashing";
                         } elseif ($info[2] != 0) {
                             $state = "checking";
                         }
                         if ($info[9] >= $info[6]) {
                             $state = "done";
                         }
                         if ($update->title != $info[5]) {
                             if ($info[5] == '') {
                                 $info[5] = 'no name field';
                             }
                             $update->title = $info[5];
                         }
                         if ($update->state == "put_start" && $state == 'stop') {
                             $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                             $myvars = 'mode=start&hash=' . $tor[0];
                             $ch = curl_init($url);
                             $username = '******';
                             $password = '******';
                             curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                             curl_setopt($ch, CURLOPT_POST, 1);
                             curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                             curl_setopt($ch, CURLOPT_HEADER, 0);
                             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                             $response = curl_exec($ch);
                             $torrent_start = json_decode($response, true);
                             $update->state = "downloading";
                             $update->status = 4;
                             $update->save();
                         } elseif ($update->state == "downloading" && $state == 'stop') {
                             $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                             $myvars = 'mode=start&hash=' . $tor[0];
                             $ch = curl_init($url);
                             $username = '******';
                             $password = '******';
                             curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                             curl_setopt($ch, CURLOPT_POST, 1);
                             curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                             curl_setopt($ch, CURLOPT_HEADER, 0);
                             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                             $response = curl_exec($ch);
                             $torrent_start = json_decode($response, true);
                         } elseif ($update->state == "downloading" && $state == 'paused') {
                             $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                             $myvars = 'mode=start&hash=' . $tor[0];
                             $ch = curl_init($url);
                             $username = '******';
                             $password = '******';
                             curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                             curl_setopt($ch, CURLOPT_POST, 1);
                             curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                             curl_setopt($ch, CURLOPT_HEADER, 0);
                             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                             $response = curl_exec($ch);
                             $torrent_start = json_decode($response, true);
                         }
                         if ($info[29] == 0 && $info[1] == 1 && $info[2] == 1) {
                             $state = 'hashing';
                         }
                         switch ($state) {
                             case "hashing":
                                 $update->state = "hashing";
                                 $update->save();
                                 break;
                             case "checking":
                                 $update->state = "check";
                                 $update->status = 2;
                                 $update->save();
                                 break;
                             case "paused":
                             case "downloading":
                                 $update->state = "downloading";
                                 $update->status = 4;
                                 $update->save();
                                 break;
                             case "done":
                                 if ($tor[5] == $update->hash . '.meta' || $update->title == $update->hash . '.meta') {
                                     $report = new UserFlag();
                                     $report->media_id = $update->id;
                                     $report->save();
                                 } else {
                                     $loc = '/home/mfs/Downloads/transmission/completed/' . $update->id;
                                     $url = 'http://s01.okaydrive.com/rt/plugins/datadir/action.php';
                                     $myvars = 'move_fastresume=0&move_datafiles=1&move_addpath=1&hash=' . $tor[0] . '&datadir=' . $loc;
                                     $ch = curl_init($url);
                                     $username = '******';
                                     $password = '******';
                                     curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                                     curl_setopt($ch, CURLOPT_POST, 1);
                                     curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                                     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                                     curl_setopt($ch, CURLOPT_HEADER, 0);
                                     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                                     $response = curl_exec($ch);
                                     $torrent_move = json_decode($response, true);
                                     $process = shell_exec('nohup php /opt/nginx/html/artisan sys:process --hash=' . $update->hash . ' > /dev/null 2>&1 & echo $!');
                                     $update->state = "process";
                                     $update->status = 5;
                                     $update->save();
                                     break;
                                 }
                         }
                         if ($update->state == "put_start" || $update->state == "put_pause" || strpos($update->title, '.meta') !== false || $update->featured_at != "0000-00-00 00:00:00") {
                             echo "in";
                         } else {
                             if ($update->state == "downloading") {
                                 $now = new DateTime();
                                 $now_stamp = $now->format('Y-m-d H:i:s');
                                 $update->featured_at = $now_stamp;
                                 $update->save();
                             }
                         }
                         if ($update->state == "hashing") {
                             $update->perc = $this->percent($info[25], $info[8]);
                         } else {
                             $update->perc = $this->percent($info[9], $info[6]);
                         }
                         $update->upsd = $info[13];
                         if ($info[13] == 0) {
                             $update->eta = $info[6] - $info[9];
                         } else {
                             $update->eta = ($info[6] - $info[9]) / $info[13];
                         }
                         $update->peersc = $info[18];
                         $update->peersa = $info[19];
                         $update->size = $info[6];
                         if ($update->title != $info[5]) {
                             if ($info[5] == '') {
                                 $info[5] = 'no name field';
                             }
                             $update->title = $info[5];
                         }
                         $update->save();
                     }
                     echo uniqid();
                 }
             }
         } catch (Exception $e) {
             echo 'Message: ' . $e->getMessage();
             $report = new UserFlag();
             $report->type = 'check-all-error';
             $report->media_id = $update->id;
             $report->res = $e->getMessage();
             $report->save();
         }
     }
     echo "end";
 }
Beispiel #16
0
 /**
  * Delete media item from database as 
  * well as filesystem.
  * 
  * @param  integer $id
  * @return boolean
  */
 public function destroy($id)
 {
     $img = $this->model->where('id', $id)->select('local')->first();
     $this->fs->delete(public_path($img->locale));
     return $this->model->destroy($id);
 }
Beispiel #17
0
    /**
     * Execute the console command.
     *
     * @return void
     */
    public function fire()
    {
        include_once "/opt/nginx/html/laravel/vendor/SmartImage.class.php";
        try {
            $hash = $this->option('hash');
            $media = Media::where('hash', '=', $hash)->first();
            if ($media->files()->count() == 0) {
                echo "files";
                $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                $myvars = 'mode=info&hash=' . $hash;
                $ch = curl_init($url);
                $username = '******';
                $password = '******';
                curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                $response = curl_exec($ch);
                $torrent_info = json_decode($response, true);
                $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                $myvars = 'mode=fls&hash=' . $hash;
                $ch = curl_init($url);
                $username = '******';
                $password = '******';
                curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                $response = curl_exec($ch);
                $torrent_files = json_decode($response, true);
                $files = $torrent_files;
                if (!empty($files)) {
                    echo "not empty";
                    echo count($files);
                    $ignore_first_folder = true;
                    $id = 1;
                    $paths = array();
                    foreach ($files as $file) {
                        if ($torrent_info[3] != 0) {
                            $fd = parse_url(basename(str_replace("#", "", $torrent_info[2])) . '/' . str_replace("#", "", $file[0]));
                        } else {
                            $fd = parse_url(str_replace("#", "", $file[0]));
                        }
                        $path_parts = pathinfo($fd['path']);
                        $dirs = explode("/", $path_parts['dirname']);
                        for ($i = 0; $i <= count($dirs); $i++) {
                            if (isset($dirs[$i]) && $dirs[$i] != '.') {
                                $full_path = $this->fullpath($dirs, $i);
                                if (array_key_exists($full_path, $paths)) {
                                } else {
                                    $paths[$full_path]["id"] = $id;
                                    $paths[$full_path]["name"] = $dirs[$i];
                                    $prev_path = $this->fullpath($dirs, $i - 1);
                                    if (!isset($paths[$prev_path]["id"])) {
                                        $pv_p = 0;
                                    } else {
                                        $pv_p = $paths[$prev_path]["id"];
                                    }
                                    $new_folder = new MediaFlag();
                                    $new_folder->name = $dirs[$i];
                                    $new_folder->folder_id = $id;
                                    $new_folder->in = $pv_p;
                                    $new_folder->media_id = $media->id;
                                    $new_folder->save();
                                    $id++;
                                }
                            } elseif (isset($dirs[$i]) && $dirs[$i] == '.') {
                                //echo $path_parts["basename"].' 0';
                                $new_file = new MediaLike();
                                if ($torrent_info[3] != 0) {
                                    $new_file->path = basename(str_replace("#", "", $torrent_info[2])) . '/' . str_replace("#", "", $file[0]);
                                } else {
                                    $new_file->path = str_replace("#", "", $file[0]);
                                }
                                $new_file->name = $path_parts["basename"];
                                $new_file->type = $this->getExt($new_file->path);
                                $new_file->in = 0;
                                $new_file->size = $file[3];
                                $new_file->media_id = $media->id;
                                //$like->user_id = Auth::user()->id;
                                $new_file->save();
                                $ignore_first_folder = false;
                            } else {
                                if (isset($dirs[$i - 1]) && $dirs[$i - 1] != '.') {
                                    $full_path = $this->fullpath($dirs, $i - 1);
                                    //echo $path_parts["basename"].' '.$paths[$full_path]["id"];
                                    $new_file = new MediaLike();
                                    if ($torrent_info[3] != 0) {
                                        $new_file->path = basename(str_replace("#", "", $torrent_info[2])) . '/' . str_replace("#", "", $file[0]);
                                    } else {
                                        $new_file->path = str_replace("#", "", $file[0]);
                                    }
                                    $new_file->type = $this->getExt($new_file->path);
                                    $new_file->name = $path_parts["basename"];
                                    $new_file->in = $paths[$full_path]["id"];
                                    $new_file->size = $file[3];
                                    $new_file->media_id = $media->id;
                                    //$like->user_id = Auth::user()->id;
                                    $new_file->save();
                                }
                            }
                        }
                    }
                    $media["ignore_first"] = $ignore_first_folder;
                    $media->save();
                }
            }
            $files_local = $media->getFiles();
            if (!empty($files_local)) {
                echo "pro";
                $media_id = $media->id;
                shell_exec('nohup php /opt/nginx/html/artisan check:files --media=' . $media_id . ' > /dev/null 2>&1 & echo $!');
                $max_file_id = null;
                $max_file_size = 0;
                foreach ($files_local as $file) {
                    if ($file->type == "vid" || $file->type == "vid-conv") {
                        if ($file->size > $max_file_size) {
                            $max_file_size = $file->size;
                            $max_file_id = $file->id;
                        }
                    }
                }
                $media->max_file_id = $max_file_id;
                $media->save();
                $fast = false;
                foreach ($files_local as $file) {
                    if ($file->type == "vid" || $file->type == "vid-conv") {
                        if ($file->type == "vid") {
                            $fast = $this->getFast($file->path);
                        }
                        if ($file->id == $max_file_id) {
                            $info = $this->makeThumbs($media->id, $file->id, $media->id . '/' . $file->path, $fast, 13);
                        } else {
                            $info = $this->makeThumbs($media->id, $file->id, $media->id . '/' . $file->path, $fast, 1);
                        }
                        if (!empty($info) && $info != null) {
                            $info_decode_all = json_decode($info, true);
                            $info_decode = $info_decode_all["data"];
                            $new_fileinfo = new FileInfo();
                            $new_fileinfo->file_id = $file->id;
                            $new_fileinfo->media_id = $media->id;
                            $new_fileinfo->video_duration = $info_decode["video_duration"];
                            $new_fileinfo->video_codec_name = $info_decode["video_codec_name"];
                            $new_fileinfo->video_width = $info_decode["video_width"];
                            $new_fileinfo->video_height = $info_decode["video_height"];
                            $new_fileinfo->video_height = $info_decode["video_height"];
                            $new_fileinfo->video_ratio = $info_decode["video_ratio"];
                            $new_fileinfo->video_fps = $info_decode["video_fps"];
                            $new_fileinfo->audio_codec_name = $info_decode["audio_codec_name"];
                            $new_fileinfo->audio_bit_rate = $info_decode["audio_bit_rate"];
                            $new_fileinfo->save();
                        }
                    } elseif ($file->type == "img") {
                        //$this->setimages($file->name ,$media->id . '/'. $file->path);
                        $file_path_thumb = '/opt/nginx/html/public/cache/thumbs/' . $file->id . '.jpg';
                        $full_path = '/home/mfs/Downloads/transmission/completed/' . $media->id . '/' . $file->path;
                        if (file_exists($file_path_thumb)) {
                            unlink($file_path_thumb);
                        }
                        try {
                            $img = new SmartImage($full_path);
                            $img->resize(130, 130, true);
                            $img->saveImage($file_path_thumb, 85);
                        } catch (Exception $e) {
                            $full_path = '/home/mfs/Downloads/transmission/image.png';
                            $img = new SmartImage($full_path);
                            $img->saveImage($file_path_thumb, 85);
                        }
                        //file_put_contents($file_path_thumb, $file_img_tmp);
                    }
                }
                sleep(10);
                $save_base_thumbs = "/opt/nginx/html/public/snaps/thumbs/";
                $save_base_big = "/opt/nginx/html/public/snaps/big/";
                foreach ($files_local as $file) {
                    if ($file->type == "vid" || $file->type == "vid-conv") {
                        $snap_big_path = $save_base_big . $media->id;
                        if (!file_exists($snap_big_path)) {
                            mkdir($snap_big_path, 0775, true);
                        }
                        $snap_big_path_full = $snap_big_path . '/' . $file->id;
                        if (!file_exists($snap_big_path_full)) {
                            mkdir($snap_big_path_full, 0775, true);
                        }
                        $snap_thumb_path = $save_base_thumbs . $media->id;
                        if (!file_exists($snap_thumb_path)) {
                            mkdir($snap_thumb_path, 0775, true);
                        }
                        $snap_thumb_path_full = $snap_thumb_path . '/' . $file->id;
                        if (!file_exists($snap_thumb_path_full)) {
                            mkdir($snap_thumb_path_full, 0775, true);
                        }
                        if ($media->max_file_id != $file->id) {
                            $file_get = '/opt/nginx/html/laravel/public/snaps/' . $media->id . '/' . $file->id . '/1.jpg';
                            $snap_big_path_full_file = $snap_big_path_full . '/1.jpg';
                            $snap_thumb_path_full_file = $snap_thumb_path_full . '/1.jpg';
                            if (file_exists($snap_big_path_full_file)) {
                            } else {
                                try {
                                    $file_img = file_get_contents($file_get);
                                    file_put_contents($snap_big_path_full_file, $file_img);
                                    $img = new SmartImage($snap_big_path_full_file);
                                    $img->resize(130, 130, true);
                                    $img->saveImage($snap_thumb_path_full_file, 85);
                                } catch (Exception $e) {
                                    $img = new SmartImage('/opt/nginx/html/app/commands/1.png');
                                    $img->resize(130, 130, true);
                                    $img->saveImage($snap_thumb_path_full_file, 85);
                                }
                            }
                        } elseif ($media->max_file_id == $file->id) {
                            $frames = 13;
                            for ($k = 1; $k < $frames; $k++) {
                                $snap_big_path_full_file = $snap_big_path_full . '/' . $k . '.jpg';
                                $snap_thumb_path_full_file = $snap_thumb_path_full . '/' . $k . '.jpg';
                                $file_get = '/opt/nginx/html/laravel/public/snaps/' . $media->id . '/' . $file->id . '/' . $k . '.jpg';
                                if (file_exists($snap_big_path_full_file)) {
                                } else {
                                    try {
                                        $file_img = file_get_contents($file_get);
                                        file_put_contents($snap_big_path_full_file, $file_img);
                                        $img = new SmartImage($snap_big_path_full_file);
                                        $img->resize(130, 130, true);
                                        $img->saveImage($snap_thumb_path_full_file, 85);
                                    } catch (Exception $e) {
                                        $img = new SmartImage('/opt/nginx/html/app/commands/1.png');
                                        $img->resize(130, 130, true);
                                        $img->saveImage($snap_thumb_path_full_file, 85);
                                    }
                                }
                            }
                        }
                    }
                }
                while (MediaLike::where('media_id', '=', $media->id)->where('cksum', '=', '')->count() != 0) {
                    sleep(1);
                }
                $media["state"] = 'done';
                $media->save();
                $media_users = $media->usersMedia();
                foreach ($media_users as $media_user) {
                    try {
                        $user_this = User::where('id', '=', $media_user->user_id)->first();
                        if (isset($user_this->email) && $user_this->ea) {
                            require_once '/opt/nginx/html/vendor/php-aws-ses-master/src/ses.php';
                            $ses = new SimpleEmailService('AKIAJNUKDR6WQV2PJLEA', 'Q0p4SCDdHK5QddvUICYj/xMfoAbcxa7buuRYTJyY');
                            $m = new SimpleEmailServiceMessage();
                            $m->addTo($user_this->email);
                            $m->setFrom('DATAS Support <*****@*****.**>');
                            $m->setSubject('Your files are ready to download.');
                            $html = '<table class="yiv7962433916container" align="center" cellspacing="0" border="0" cellpadding="0" width="580" bgcolor="#FFFFFF" style="width:580px;background-color:#FFF;border-top:1px solid #DDD;border-bottom:1px solid #DDD;" id="yui_3_13_0_1_1397466773730_2821">
												<tbody id="yui_3_13_0_1_1397466773730_2820"><tr id="yui_3_13_0_1_1397466773730_2819">
													<td class="yiv7962433916title" style="padding-top:34px;padding-left:39px;padding-right:39px;text-align:left;border-left-width:1px;border-left-style:solid;border-left-color:#DDD;border-right-width:1px;border-right-style:solid;border-right-color:#DDD;" id="yui_3_13_0_1_1397466773730_2818">
														<h2 style="font-family:Helvetica Neue, Arial, Helvetica, sans-serif;font-size:30px;color:#262626;font-weight:normal;margin-top:0;margin-bottom:13px;margin-right:0;margin-left:0;padding-top:0;padding-bottom:0;padding-right:0;padding-left:0;letter-spacing:0;" id="yui_3_13_0_1_1397466773730_2817">Your file is ready!</h2>
														<h3 style="font-family:Helvetica Neue, Arial, Helvetica, sans-serif;font-size:16px;color:#3e434a;font-weight:normal;margin-top:0;margin-bottom:19px;margin-right:0;margin-left:0;padding-top:0;padding-bottom:0;padding-right:0;padding-left:0;line-height:25px;" id="yui_3_13_0_1_1397466773730_2824">The file <b>' . $media->title . '</b> has been downloaded and ready to Play, Download, Convert or Stream.</h3>
													</td>
												</tr>
												<tr id="yui_3_13_0_1_1397466773730_2831">
													<td class="yiv7962433916cta" align="left" style="background-color:#F1FAFE;font-size:14px;color:#1f1f1f;border-top-width:1px;border-top-style:solid;border-top-color:#DAE3EA;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#DAE3EA;border-left-width:1px;border-left-style:solid;border-left-color:#DDD;border-right-width:1px;border-right-style:solid;border-right-color:#DDD;margin-top:0;margin-bottom:0;margin-right:0;margin-left:0;padding-top:20px;padding-bottom:20px;padding-right:39px;padding-left:39px;text-align:left;" id="yui_3_13_0_1_1397466773730_2830">
														<table cellspacing="0" border="0" cellpadding="0" width="500" align="left">
															<tbody><tr>
																<td width="24"></td>
																<td class="yiv7962433916link" align="left" style="font-family:Helvetica Neue, Arial, Helvetica, sans-serif;padding-left:9px;font-size:14px;"><strong><a rel="nofollow" style="color:#2b6cb5;font-family:Arial;font-size:12px;" target="_blank" href="https://okaydrive.com/torrent/' . $media_user->uni_id . '">Click here to go to your file</a></strong></td>
															</tr>
														</tbody></table>
													</td>
												</tr>
												<tr id="yui_3_13_0_1_1397466773730_2827">
													<td class="yiv7962433916footer" style="color:#797c80;font-size:12px;border-left-width:1px;border-left-style:solid;border-left-color:#DDD;border-right-width:1px;border-right-style:solid;border-right-color:#DDD;padding-top:23px;padding-left:39px;padding-right:13px;padding-bottom:23px;text-align:left;" id="yui_3_13_0_1_1397466773730_2826">
														<p style="font-family:Helvetica Neue, Arial, Helvetica, sans-serif;margin-top:0;margin-bottom:0;margin-right:0;margin-left:0;padding-top:0;padding-bottom:13px;padding-right:0;padding-left:0;line-height:20px;" id="yui_3_13_0_1_1397466773730_2832">
															You can login with <a rel="nofollow" style="font-weight:bold;text-decoration:none;color:inherit;cursor:default;">' . $user_this->username . '</a> at <a rel="nofollow" target="_blank" href="https://okaydrive.com" id="yui_3_13_0_1_1397466773730_2833">https://okaydrive.com</a>
														</p>
														<p style="font-family:Helvetica Neue, Arial, Helvetica, sans-serif;margin-top:0;margin-bottom:0;margin-right:0;margin-left:0;padding-top:0;padding-bottom:13px;padding-right:0;padding-left:0;line-height:20px;" id="yui_3_13_0_1_1397466773730_2825">Want some help with using our site? Simply reply to this email or email us - support@okaydrive.com. Email alerts are enabled by default, you may disable email alerts in your account settings.</p>
													</td>
												</tr>
												<tr>
											</tr></tbody></table>';
                            $m->setMessageFromString('', $html);
                            $ses->sendEmail($m);
                        }
                    } catch (Exception $e) {
                    }
                }
            }
        } catch (Exception $e) {
            file_put_contents('/home/mfs/l.log', $e);
        }
    }
Beispiel #18
0
<style type="text/css">
.gallery-sub-header{
	top:0px;
}
.main_home_container{
	padding-top:0px;
}
</style>

<?php 
$random = Media::where('active', '=', 1)->orderBy(DB::raw('RAND()'))->take(18)->get();
?>

<div id="random-bar">
	<div id="random-left"><i class="fa fa-angle-left"></i></div>
	<div id="random-right"><i class="fa fa-angle-right"></i></div>
	<div class="container random-container">
		<div id="random-slider">
			@foreach($random as $media)
				
					<?php 
$image = Config::get('site.uploads_dir') . '/images/' . $media->pic_url;
?>
					<div class="random-item" >
						<a class="random-img" href="{{ URL::to('media') . '/' . $media->slug }}" style="background-image:url('{{ $image }}'); display:block; min-height:100px; background-size:cover; background-position-y:center"></a>
					</div>
			@endforeach
		</div>
	</div>
</div>
 public function delete($user_id = NULL)
 {
     $user = $this->prepare_user($user_id);
     $ia = $this->ion_auth;
     if ($ia->is_collaborator($user_id) && $this->c_user->isManager($user_id)) {
         $this->c_user->delete(new User($user_id));
         $user_deleted = $this->ion_auth->delete_user($user->id);
         if (!$user_deleted) {
             $this->addFlash(lang('delete_error', [$this->ion_auth->errors()]));
             redirect('settings/collaboration');
         }
         $sender = $this->get('core.mail.sender');
         $sender->sendUserDeleteMail(array('user' => $user));
         $media = new Media();
         $media->where('user_id', $user->id)->get()->delete_all();
         $post = new Post();
         $post->where('user_id', $user->id)->get();
         foreach ($post as $p) {
             $post_social = new Post_social();
             $post_social->where('post_id', $p->id)->get()->delete_all();
         }
         $post->delete_all();
         $social_post = new Social_post();
         $social_post->where('user_id', $user->id)->get()->delete_all();
         $this->addFlash(lang('delete_success'), 'success');
     } else {
         $this->addFlash(lang('permission_error'));
     }
     redirect('settings/collaboration');
 }
Beispiel #20
0
 public static function getAlbumFirst($album_id)
 {
     $photos = Media::where('album_id', $album_id)->get(array('id', 'album_id', 'url', 'extension'))->first();
     return "imgd.php?src=" . $photos->url . "." . $photos->extension;
 }
Beispiel #21
0
 public function profile($username)
 {
     $user = User::where('username', '=', $username)->first();
     $medias = Media::where('user_id', '=', $user->id)->orderBy('created_at', 'desc')->paginate(Config::get('site.num_results_per_page'));
     $is_user_profile = false;
     if (!Auth::guest() && Auth::user()->id == $user->id) {
         $is_user_profile = true;
     }
     $user_points = DB::table('points')->where('user_id', '=', $user->id)->sum('points');
     $data = array('user' => $user, 'media' => $medias, 'settings' => Setting::first(), 'is_user_profile' => $is_user_profile, 'user_points' => $user_points);
     return View::make('Theme::user', $data);
 }
 public static function countgalery($id)
 {
     $data = Media::where('tipe', 'image')->where('album_id', $id)->count();
     return $data;
 }
Beispiel #23
0
        foreach ($userm as $mm) {
            $mm->delete();
        }
        $m->delete();
    }
});
Route::get('test4', function () {
    $media_users = UserMedia::where('media_id', '=', '11')->get();
    foreach ($media_users as $media_user) {
        $user = User::where('id', '=', $media_user->user_id)->first();
        $user_cat = Category::where('id', '=', $user->category_id)->first();
        echo $user_cat->max_add;
    }
});
Route::post('test9', function () {
    $update = Media::where('hash', '=', 'A88EF509425F827998A4FD84AF2D46E020F6510B')->first();
    $url = 'http://77.247.178.109/rt/plugins/httprpc/action.php';
    $myvars = 'mode=list-get&hash=' . $update->hash;
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
    curl_setopt($ch, CURLOPT_TIMEOUT, 4);
    //timeout in seconds
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($ch);
    $tor = json_decode($response, true);
    $url = 'http://77.247.178.109/rt/plugins/httprpc/action.php';
    $myvars = 'mode=fls&hash=A88EF509425F827998A4FD84AF2D46E020F6510B';
 public function uploadFile()
 {
     $requestsPerHour = 60;
     $key = sprintf('api:%s', Request::getClientIp());
     $get_data = DB::table('limit')->where('ip', $key)->first();
     if (isset($get_data->ip)) {
         $count = $get_data->count;
         $count++;
         DB::table('limit')->where('ip', $key)->update(array('count' => $count));
     } else {
         DB::table('limit')->insert(array('user_id' => Auth::user()->id, 'ip' => $key, 'count' => 0));
     }
     $count = UserMedia::where('user_id', '=', Auth::user()->id)->where('is_deleted', '=', '0')->where('cat', '=', '1')->count();
     //if($count >= 2 && Auth::user()->category_id == 1){
     //	$response = Response::json(array('result'=>false, 'location' => false,'error'=>'Free accounts are only allowed 2 torrents per account.' ));
     //	$response->header('Content-Type', 'application/json');
     //	return $response;
     //}
     $user_media = UserMedia::where('user_id', '=', Auth::user()->id)->where('is_deleted', '=', '0')->get();
     if (count($user_media) != 0) {
         $uma = array();
         foreach ($user_media as $um) {
             array_push($uma, $um->media_id);
         }
         $media_count = Media::whereIn('id', $uma)->where('state', '!=', 'done')->where('state', '!=', 'max_pause')->where('state', '!=', 'failed')->where('state', '!=', 'process')->where('state', '!=', 'stop')->count();
         if ($media_count >= 1 && Auth::user()->category_id == 1) {
             $response = Response::json(array('result' => false, 'location' => false, 'error' => 'Free accounts are only allowed 1 active torrent per account.'));
             $response->header('Content-Type', 'application/json');
             return $response;
         }
         if ($media_count >= 10) {
             $response = Response::json(array('result' => false, 'location' => false, 'error' => 'Your account is only allowed 10 active torrents.'));
             $response->header('Content-Type', 'application/json');
             return $response;
         }
     }
     if (Auth::user()->category_id == 1) {
         $status = true;
         $useage = Auth::user()->used_bytes;
         if ($useage > Auth::user()->avl_bytes) {
             $status = false;
         }
         if (Auth::user()->avl_bytes - $useage < 104857600) {
             $status = false;
         }
         date_default_timezone_set('Pacific/Auckland');
         $ip_date = date("Y-m-d");
         $ip_bytes = DataIp::where('ip', '=', $_SERVER['REMOTE_ADDR'])->where('date', '=', $ip_date)->sum('bytes');
         if (1073741824 - $ip_bytes < 104857600) {
             $status = false;
         }
         if (!$status) {
             $response = Response::json(array('result' => false, 'location' => false, 'error' => 'Low bandwidth left on your account. Upgrade your account to premium.'));
             $response->header('Content-Type', 'application/json');
             return $response;
         }
     }
     require '/opt/nginx/html/vendor/upload.php';
     $upload_directory = '/opt/nginx/html/public/cache/tmp';
     $allowed_extensions = array('torrent');
     $max_size = 1048576;
     $uploader = new FileUpload('file');
     $ext = $uploader->getExtension();
     if (empty($ext)) {
         $response = Response::json(array('result' => false, 'location' => false, 'error' => 'Invalid file type.'));
         $response->header('Content-Type', 'application/json');
         return $response;
     }
     $filename = uniqid(uniqid(), true) . '.' . $ext;
     $uploader->newFileName = $filename;
     $uploader->sizeLimit = $max_size;
     $result = $uploader->handleUpload($upload_directory, $allowed_extensions);
     $errors = $uploader->getErrorMsg();
     if (!empty($errors)) {
         $response = Response::json(array('result' => false, 'location' => false, 'error' => $uploader->getErrorMsg()));
         $response->header('Content-Type', 'application/json');
         return $response;
     }
     $file = $uploader->getSavedFile();
     $url = 'http://s01.okaydrive.com/rt/php/addtorrent2.php';
     $myvars = 'torrents_start_stopped=1&url=https://okaydrive.com/cache/tmp/' . $filename;
     $ch = curl_init($url);
     $username = '******';
     $password = '******';
     curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $response = curl_exec($ch);
     $json = json_decode($response, true);
     $uni_id = '';
     if ($json["result"] == "success") {
         $hash = $json["hash"];
         $mediaexist = Media::where('hash', '=', $hash)->first();
         if (isset($mediaexist->id)) {
             if ($mediaexist->state == 'done' || $mediaexist->state == 'failed') {
                 $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                 $myvars = 'mode=remove&hash=' . $mediaexist->hash;
                 $ch = curl_init($url);
                 $username = '******';
                 $password = '******';
                 curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                 curl_setopt($ch, CURLOPT_POST, 1);
                 curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                 curl_setopt($ch, CURLOPT_HEADER, 0);
                 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
                 curl_setopt($ch, CURLOPT_TIMEOUT, 4);
                 //timeout in seconds
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                 $response = curl_exec($ch);
                 $removed = json_decode($response, true);
             }
             $userHasMedia = UserMedia::where('user_id', '=', Auth::user()->id)->where('media_id', '=', $mediaexist->id)->first();
             if (!isset($userHasMedia->id)) {
                 if ($mediaexist->size > Auth::user()->category()->max_add) {
                     $response = Response::json(array('result' => false, 'location' => false, 'error' => 'Max torrent size allowed for Free accounts reached.'));
                     $response->header('Content-Type', 'application/json');
                     return $response;
                 }
                 if ($mediaexist->state == 'max_pause') {
                     $mediaexist->state = 'put_pause';
                     $mediaexist->save();
                 }
                 if ($mediaexist->state == 'fail_free' && $mediaexist->user_id != Auth::user()->user_id) {
                     $mediaexist->state = 'put_pause';
                     $mediaexist->save();
                 }
                 if ($mediaexist->state == 'delete') {
                     $mediaexist->state = 'put_pause';
                     $mediaexist->save();
                 }
                 $newMedia = new UserMedia();
                 $newMedia->user_id = Auth::user()->id;
                 $newMedia->cat = Auth::user()->category_id;
                 $newMedia->media_id = $mediaexist->id;
                 $newMedia->uni_id = uniqid(rand(), true);
                 $newMedia->save();
                 $uni_id = $newMedia->uni_id;
                 $res = 'cache';
             } else {
                 if ($mediaexist->state == 'max_pause') {
                     $mediaexist->state = 'put_pause';
                     $mediaexist->save();
                 }
                 if ($mediaexist->state == 'fail_free' && $mediaexist->user_id != Auth::user()->user_id) {
                     $mediaexist->state = 'put_pause';
                     $mediaexist->save();
                 }
                 if ($mediaexist->state == 'delete') {
                     $mediaexist->state = 'put_pause';
                     $mediaexist->save();
                 }
                 if ($userHasMedia->is_deleted) {
                     $userHasMedia->is_deleted = false;
                     $userHasMedia->save();
                 }
                 $uni_id = $userHasMedia->uni_id;
                 $res = 'has';
             }
         } else {
             sleep(4);
             $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
             $myvars = 'mode=info&hash=' . $hash;
             $ch = curl_init($url);
             $username = '******';
             $password = '******';
             curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
             curl_setopt($ch, CURLOPT_HEADER, 0);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             $response = curl_exec($ch);
             $torrent_info = json_decode($response, true);
             if (empty($torrent_info[0]) || !isset($torrent_info[0])) {
                 $torrent_info[0] = $hash;
             }
             $inputTorrent["hash"] = $hash;
             $inputTorrent["title"] = $torrent_info[0];
             $inputTorrent["state"] = 'put_pause';
             $inputTorrent["user_id"] = Auth::user()->id;
             $inputTorrent["source"] = 'https://okaydrive.com/cache/tmp/' . $filename;
             $inputTorrent["cat"] = Auth::user()->category_id;
             $new_media = $this->media->create($inputTorrent);
             $newMedia = new UserMedia();
             $newMedia->user_id = Auth::user()->id;
             $newMedia->cat = Auth::user()->category_id;
             $newMedia->media_id = $new_media->id;
             $newMedia->uni_id = uniqid(rand(), true);
             $newMedia->save();
             $uni_id = $newMedia->uni_id;
             sleep(1);
             $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
             $myvars = 'mode=fls&hash=' . $hash;
             $ch = curl_init($url);
             $username = '******';
             $password = '******';
             curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
             curl_setopt($ch, CURLOPT_HEADER, 0);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             $response = curl_exec($ch);
             $torrent_files = json_decode($response, true);
             $files = $torrent_files;
             $totalSize = $torrent_info[1];
             if (!empty($totalSize)) {
                 if ($totalSize > Auth::user()->category()->max_add) {
                     $newMedia->delete();
                     $new_media->delete();
                     $response = Response::json(array('result' => false, 'location' => false, 'error' => 'Max torrent size allowed for Free accounts reached.'));
                     $response->header('Content-Type', 'application/json');
                     return $response;
                 } else {
                     $new_media["size"] = $totalSize;
                 }
             }
             if (!empty($files) && !empty($torrent_info[2])) {
                 $ignore_first_folder = true;
                 $id = 1;
                 $paths = array();
                 foreach ($files as $file) {
                     if ($file[0] != $hash . '.meta') {
                         if ($torrent_info[3] != 0) {
                             $fd = parse_url(basename($torrent_info[2]) . '/' . $file[0]);
                         } else {
                             $fd = parse_url($file[0]);
                         }
                         $path_parts = pathinfo($fd['path']);
                         $dirs = explode("/", $path_parts['dirname']);
                         for ($i = 0; $i <= count($dirs); $i++) {
                             if (isset($dirs[$i]) && $dirs[$i] != '.') {
                                 $full_path = $this->fullpath($dirs, $i);
                                 if (array_key_exists($full_path, $paths)) {
                                 } else {
                                     $paths[$full_path]["id"] = $id;
                                     $paths[$full_path]["name"] = $dirs[$i];
                                     $prev_path = $this->fullpath($dirs, $i - 1);
                                     if (!isset($paths[$prev_path]["id"])) {
                                         $pv_p = 0;
                                     } else {
                                         $pv_p = $paths[$prev_path]["id"];
                                     }
                                     $new_folder = new MediaFlag();
                                     $new_folder->name = $dirs[$i];
                                     $new_folder->folder_id = $id;
                                     $new_folder->in = $pv_p;
                                     $new_folder->media_id = $new_media->id;
                                     $new_folder->save();
                                     $id++;
                                 }
                             } elseif (isset($dirs[$i]) && $dirs[$i] == '.') {
                                 //echo $path_parts["basename"].' 0';
                                 $new_file = new MediaLike();
                                 if ($torrent_info[3] != 0) {
                                     $new_file->path = basename($torrent_info[2]) . '/' . $file[0];
                                 } else {
                                     $new_file->path = $file[0];
                                 }
                                 $new_file->type = $this->getExt($new_file->path);
                                 $new_file->name = $path_parts["basename"];
                                 $new_file->in = 0;
                                 $new_file->size = $file[3];
                                 $new_file->media_id = $new_media->id;
                                 //$like->user_id = Auth::user()->id;
                                 $new_file->save();
                                 $ignore_first_folder = false;
                             } else {
                                 if (isset($dirs[$i - 1]) && $dirs[$i - 1] != '.') {
                                     $full_path = $this->fullpath($dirs, $i - 1);
                                     //echo $path_parts["basename"].' '.$paths[$full_path]["id"];
                                     $new_file = new MediaLike();
                                     if ($torrent_info[3] != 0) {
                                         $new_file->path = basename($torrent_info[2]) . '/' . $file[0];
                                     } else {
                                         $new_file->path = $file[0];
                                     }
                                     $new_file->type = $this->getExt($new_file->path);
                                     $new_file->name = $path_parts["basename"];
                                     $new_file->in = $paths[$full_path]["id"];
                                     $new_file->size = $file[3];
                                     $new_file->media_id = $new_media->id;
                                     //$like->user_id = Auth::user()->id;
                                     $new_file->save();
                                 }
                             }
                         }
                     }
                 }
                 $new_media["ignore_first"] = $ignore_first_folder;
             }
             $new_media->save();
             $res = 'added';
         }
     } else {
         $error = "Could not add the torrent, please check your input.";
     }
     //$new_media = $this->media->create($input);
     if (isset($error)) {
         $response = Response::json(array('result' => false, 'location' => false, 'error' => $error));
         $response->header('Content-Type', 'application/json');
         return $response;
     } else {
         $response = Response::json(array('result' => true, 'location' => '/torrent/' . $uni_id, 'torrent' => $res));
         $response->header('Content-Type', 'application/json');
         return $response;
     }
 }