예제 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // make sure there is at least one file entry that other seeders can use
     if (File::where("in_use", "=", true)->count() === 0) {
         $file = new File(array("in_use" => true, "size" => rand(10, 9999)));
         $file->fileType()->associate(FileType::first());
         $file->uploadPoint()->associate(UploadPoint::first());
         $file->save();
     }
     $this->command->info('File record created.');
 }
예제 #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $destinationFile = File::first();
     $file = new VideoFile(array("width" => 1920, "height" => 1080));
     $file->qualityDefinition()->associate(QualityDefinition::find(1));
     $file->file()->associate($destinationFile);
     $file->save();
     $file = new VideoFile(array("width" => 1280, "height" => 720));
     $file->qualityDefinition()->associate(QualityDefinition::find(2));
     $file->file()->associate($destinationFile);
     $file->save();
     $file = new VideoFile(array("width" => 640, "height" => 480));
     $file->qualityDefinition()->associate(QualityDefinition::find(3));
     $file->file()->associate($destinationFile);
     $file->save();
     $file = new VideoFile(array("width" => 640, "height" => 360));
     $file->qualityDefinition()->associate(QualityDefinition::find(4));
     $file->file()->associate($destinationFile);
     $file->save();
     $file = new VideoFile(array("width" => 426, "height" => 240));
     $file->qualityDefinition()->associate(QualityDefinition::find(5));
     $file->file()->associate($destinationFile);
     $file->save();
     $this->command->info('Video files records created!');
 }
예제 #3
0
 public function postRemove()
 {
     Auth::loggedInOr403();
     if (Config::get("degradedService.enabled")) {
         return App::abort(503);
         // service unavailable
     }
     $resp = array("success" => false);
     if (FormHelpers::hasPost("id")) {
         $id = intval($_POST["id"], 10);
         $file = File::find($id);
         if (!is_null($file) && $file->isTemporaryFromCurrentSession()) {
             Upload::delete($file);
             $resp['success'] = true;
         }
     }
     return Response::json($resp);
 }
예제 #4
0
 public static function getFileInfo($fileId)
 {
     $info = array("name" => "", "size" => "", "processState" => "0", "processPercentage" => "", "processMsg" => "", "inUse" => false);
     if ($fileId === "") {
         return $info;
     }
     $file = File::find(intval($fileId, 10));
     if (!is_null($file)) {
         $info['name'] = $file->filename;
         $info['size'] = $file->size;
         $info['processState'] = $file->process_state;
         $info['processPercentage'] = !is_null($file->process_percentage) ? $file->process_percentage : "";
         $info['processMsg'] = !is_null($file->msg) ? $file->msg : "";
         $info['inUse'] = (bool) $file->in_use;
     }
     return $info;
 }
예제 #5
0
 public static function getFile($fileId)
 {
     // the file must be a render (ie have a source file) file to be valid. Then the security checks are performed on the source file.
     $relationsToLoad = array("sourceFile", "sourceFile.mediaItemWithBanner", "sourceFile.mediaItemWithBannerFill", "sourceFile.mediaItemWithCover", "sourceFile.mediaItemWithCoverArt", "sourceFile.playlistWithBanner", "sourceFile.playlistWithBannerFill", "sourceFile.playlistWithCover", "sourceFile.liveStreamWithCoverArt", "sourceFile.mediaItemVideoWithFile.mediaItem", "sourceFile.videoFileDashWithMediaPresentationDescription", "sourceFile.videoFileDashWithAudioChannel", "sourceFile.videoFileDashWithVideoChannel");
     $requestedFile = File::with($relationsToLoad)->finishedProcessing()->find($fileId);
     if (is_null($requestedFile)) {
         return null;
     }
     $fileType = $requestedFile->file_type;
     $fileTypeId = intval($fileType->id);
     $user = Auth::getUser();
     $hasMediaItemsPermission = false;
     $hasPlaylistsPermission = false;
     $hasLiveStreamsPermission = false;
     $hasMediaItemsEditPermission = false;
     $hasPlaylistsEditPermission = false;
     $hasLiveStreamsEditPermission = false;
     if (!is_null($user)) {
         $hasMediaItemsPermission = Auth::getUser()->hasPermission(Config::get("permissions.mediaItems"), 0);
         $hasPlaylistsPermission = Auth::getUser()->hasPermission(Config::get("permissions.playlists"), 0);
         $hasLiveStreamsPermission = Auth::getUser()->hasPermission(Config::get("permissions.liveStreams"), 0);
         $hasMediaItemsEditPermission = Auth::getUser()->hasPermission(Config::get("permissions.mediaItems"), 1);
         $hasPlaylistsEditPermission = Auth::getUser()->hasPermission(Config::get("permissions.playlists"), 1);
         $hasLiveStreamsEditPermission = Auth::getUser()->hasPermission(Config::get("permissions.liveStreams"), 1);
     }
     $accessAllowed = false;
     $sourceFile = $requestedFile->sourceFile;
     if (is_null($sourceFile)) {
         // this is a source file
         // if the user is logged into the cms and has the relevent edit permission
         // meaning they would have been able to upload the source file, then allow
         // them to download it.
         // side banner source images
         if ($fileTypeId === 1 && $hasMediaItemsEditPermission && !is_null($requestedFile->mediaItemWithBanner)) {
             $accessAllowed = true;
         } else {
             if ($fileTypeId === 1 && $hasPlaylistsEditPermission && !is_null($requestedFile->playlistWithBanner)) {
                 $accessAllowed = true;
             } else {
                 if ($fileTypeId === 2 && $hasMediaItemsEditPermission && !is_null($requestedFile->mediaItemWithCover)) {
                     $accessAllowed = true;
                 } else {
                     if ($fileTypeId === 2 && $hasPlaylistsEditPermission && !is_null($requestedFile->playlistWithCover)) {
                         $accessAllowed = true;
                     } else {
                         if ($fileTypeId === 3 && $hasMediaItemsEditPermission && !is_null($requestedFile->mediaItemVideoWithFile)) {
                             $accessAllowed = true;
                         } else {
                             if ($fileTypeId === 4 && $hasMediaItemsEditPermission && !is_null($requestedFile->mediaItemWithCoverArt)) {
                                 $accessAllowed = true;
                             } else {
                                 if ($fileTypeId === 4 && $hasPlaylistsEditPermission && !is_null($requestedFile->playlistWithCoverArt)) {
                                     $accessAllowed = true;
                                 } else {
                                     if ($fileTypeId === 4 && $hasLiveStreamsEditPermission && !is_null($requestedFile->liveStreamWithCoverArt)) {
                                         $accessAllowed = true;
                                     } else {
                                         if ($fileTypeId === 10 && $hasMediaItemsEditPermission && !is_null($requestedFile->mediaItemWithBannerFill)) {
                                             $accessAllowed = true;
                                         } else {
                                             if ($fileTypeId === 10 && $hasPlaylistsEditPermission && !is_null($requestedFile->playlistWithBannerFill)) {
                                                 $accessAllowed = true;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         // see if the file should be accessible
         if ($fileTypeId === 5 && !is_null($sourceFile->mediaItemWithBanner)) {
             if ($sourceFile->mediaItemWithBanner->getIsAccessible()) {
                 $accessAllowed = true;
             }
         } else {
             if ($fileTypeId === 11 && !is_null($sourceFile->mediaItemWithBannerFill)) {
                 if ($sourceFile->mediaItemWithBannerFill->getIsAccessible()) {
                     $accessAllowed = true;
                 }
             } else {
                 if ($fileTypeId === 6 && !is_null($sourceFile->mediaItemWithCover)) {
                     if ($sourceFile->mediaItemWithCover->getIsAccessible()) {
                         $accessAllowed = true;
                     }
                 } else {
                     if ($fileTypeId === 8 && !is_null($sourceFile->mediaItemWithCoverArt)) {
                         if ($sourceFile->mediaItemWithCoverArt->getIsAccessible()) {
                             $accessAllowed = true;
                         }
                     } else {
                         if (($fileTypeId === 7 || $fileTypeId === 9 || $fileTypeId === 12 || $fileTypeId === 13 || $fileTypeId === 15 || $fileTypeId === 16) && !is_null($sourceFile->mediaItemVideoWithFile)) {
                             if ($sourceFile->mediaItemVideoWithFile->mediaItem->getIsAccessible() && ($sourceFile->mediaItemVideoWithFile->getIsLive() || $hasMediaItemsPermission)) {
                                 $accessAllowed = true;
                             }
                         } else {
                             if ($fileTypeId === 5 && !is_null($sourceFile->playlistWithBanner)) {
                                 if ($sourceFile->playlistWithBanner->getIsAccessible() && ($sourceFile->playlistWithBanner->getIsAccessibleToPublic() || $hasPlaylistsPermission)) {
                                     $accessAllowed = true;
                                 }
                             } else {
                                 if ($fileTypeId === 11 && !is_null($sourceFile->playlistWithBannerFill)) {
                                     if ($sourceFile->playlistWithBannerFill->getIsAccessible() && ($sourceFile->playlistWithBannerFill->getIsAccessibleToPublic() || $hasPlaylistsPermission)) {
                                         $accessAllowed = true;
                                     }
                                 } else {
                                     if ($fileTypeId === 6 && !is_null($sourceFile->playlistWithCover)) {
                                         if ($sourceFile->playlistWithCover->getIsAccessible() && ($sourceFile->playlistWithCover->getIsAccessibleToPublic() || $hasPlaylistsPermission)) {
                                             $accessAllowed = true;
                                         }
                                     } else {
                                         if ($fileTypeId === 8 && !is_null($sourceFile->playlistWithCoverArt)) {
                                             if ($sourceFile->playlistWithCoverArt->getIsAccessible() && ($sourceFile->playlistWithCoverArt->getIsAccessibleToPublic() || $hasPlaylistsPermission)) {
                                                 $accessAllowed = true;
                                             }
                                         } else {
                                             if ($fileTypeId === 8 && !is_null($sourceFile->liveStreamWithCoverArt)) {
                                                 if ($sourceFile->liveStreamWithCoverArt->getShowAsLiveStream()) {
                                                     $accessAllowed = true;
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $accessAllowed ? $requestedFile : null;
 }