/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     if (!DebugHelpers::shouldSiteBeLive()) {
         $this->info('Not running because site should not be live at the moment.');
         return;
     }
     $this->info('Sending ping command to any dvr bridge service servers that are being used.');
     // go though all dvrLiveStreamUris, get their dvr bridge service url, and send ping to it
     $dvrLiveStreamUriModels = DvrLiveStreamUri::with("liveStreamUri", "mediaItemLiveStream")->get();
     foreach ($dvrLiveStreamUriModels as $a) {
         $liveStreamUriModel = $a->liveStreamUri;
         $mediaItemLiveStream = $a->mediaItemLiveStream;
         $url = $liveStreamUriModel->uri;
         $this->info("Sending ping command to dvr bridge service at url \"" . $url . "\".");
         $responseInfo = MediaItemLiveStream::makeDvrBridgeServiceRequest($url, "PING", intval($a->id));
         if ($responseInfo["statusCode"] !== 200) {
             // error occurred. Remove dvrLiveStreamUri as something's wrong with it.
             $a->delete();
             $this->info("Error occurred/response returned from ping command to dvr bridge service at url \"" . $url . "\". Removing dvr link.");
         } else {
             $this->info("Sent ping command to dvr bridge service at url \"" . $url . "\".");
         }
     }
     $this->info("Finished.");
 }
 protected function setContent($content, $cssPageId, $title = NULL, $statusCode = 200)
 {
     $view = View::make("layouts.embed.master");
     $view->version = !is_null(DebugHelpers::getVersion()) ? DebugHelpers::getVersion() : "[Unknown]";
     $view->baseUrl = URL::to("/");
     $view->cssPageId = $cssPageId;
     $view->title = !is_null($title) ? $title : "LA1:TV";
     $view->description = "";
     $view->content = $content;
     $view->allowRobots = false;
     $view->cssBootstrap = asset("assets/css/bootstrap/embed.css");
     $view->requireJsBootstrap = asset("assets/scripts/bootstrap/embed.js");
     $view->supportEmail = Config::get("contactEmails.development");
     $view->pageData = array("baseUrl" => URL::to("/"), "cookieDomain" => Config::get("cookies.domain"), "cookieSecure" => Config::get("ssl.enabled"), "assetsBaseUrl" => asset(""), "logUri" => Config::get("custom.log_uri"), "debugId" => DebugHelpers::getDebugId(), "sessionId" => Session::getId(), "csrfToken" => Csrf::getToken(), "loggedIn" => Facebook::isLoggedIn(), "gaEnabled" => Config::get("googleAnalytics.enabled"), "notificationServiceUrl" => Config::get("notificationService.url"), "env" => App::environment(), "version" => DebugHelpers::getVersion(), "degradedService" => Config::get("degradedService.enabled"));
     $contentSecurityPolicyDomains = MediaItemLiveStream::getCachedLiveStreamDomains();
     $response = new MyResponse($view, $statusCode);
     // disable csp for main site because causing too many issues with live streams (and clappr uses unsafe evals etc)
     $response->enableContentSecurityPolicy(false);
     //$response->setContentSecurityPolicyDomains($contentSecurityPolicyDomains);
     $this->layout = $response;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     LiveStream::truncate();
     MediaItem::truncate();
     MediaItemComment::truncate();
     MediaItemLike::truncate();
     MediaItemLiveStream::truncate();
     MediaItemVideo::truncate();
     Permission::truncate();
     PermissionGroup::truncate();
     QualityDefinition::truncate();
     LiveStreamUri::truncate();
     Playlist::truncate();
     Show::truncate();
     SiteUser::truncate();
     User::truncate();
     VideoFile::truncate();
     DB::table("media_item_to_playlist")->truncate();
     DB::table("permission_to_group")->truncate();
     DB::table("user_to_group")->truncate();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     $this->command->info('Tables truncated!');
 }
 public function postRemoveDvrRecording($mediaItemLiveStreamId)
 {
     Auth::getUser()->hasPermissionOr401(Config::get("permissions.mediaItems"), 1);
     $resp = array("success" => false);
     $mediaItemLiveStreamId = intval($mediaItemLiveStreamId, 10);
     $mediaItemLiveStream = MediaItemLiveStream::find($mediaItemLiveStreamId);
     if (!is_null($mediaItemLiveStream)) {
         $mediaItemLiveStream->removeDvrs();
         $resp["success"] = true;
     }
     return Response::json($resp);
 }
 protected function setContent($content, $navPage, $cssPageId, $openGraphProperties = array(), $title = NULL, $statusCode = 200, $twitterProperties = null, $sideBannersImageUrl = null, $sideBannersFillImageUrl = null)
 {
     $description = Config::get("custom.site_description");
     $registerPushNotificationEndpointUrl = Config::get("pushNotifications.enabled") ? URL::route("ajax-registerPushNotificationEndpoint") : null;
     $view = View::make("layouts.home.master");
     $view->version = !is_null(DebugHelpers::getVersion()) ? DebugHelpers::getVersion() : "[Unknown]";
     $view->baseUrl = URL::to("/");
     $view->currentNavPage = $navPage;
     $view->cssPageId = $cssPageId;
     $view->title = "LA1:TV";
     if (!is_null($title)) {
         $view->title .= ": " . $title;
     }
     $view->description = $description;
     $view->content = $content;
     $view->allowRobots = true;
     $view->manifestUri = URL::route('manifest');
     $view->cssBootstrap = asset("assets/css/bootstrap/home.css");
     $view->requireJsBootstrap = asset("assets/scripts/bootstrap/home.js");
     $view->loggedIn = Facebook::isLoggedIn();
     $view->sideBannersImageUrl = $sideBannersImageUrl;
     $view->sideBannersFillImageUrl = $sideBannersFillImageUrl;
     $view->sideBannersOn = !is_null($sideBannersImageUrl) || !is_null($sideBannersFillImageUrl);
     $view->supportEmail = Config::get("contactEmails.development");
     $view->pageData = array("baseUrl" => URL::to("/"), "cookieDomain" => Config::get("cookies.domain"), "cookieSecure" => Config::get("ssl.enabled"), "assetsBaseUrl" => asset(""), "serviceWorkerUrl" => URL::route("home-service-worker"), "logUri" => Config::get("custom.log_uri"), "debugId" => DebugHelpers::getDebugId(), "sessionId" => Session::getId(), "csrfToken" => Csrf::getToken(), "loggedIn" => Facebook::isLoggedIn(), "gaEnabled" => Config::get("googleAnalytics.enabled"), "notificationServiceUrl" => Config::get("notificationService.url"), "registerPushNotificationEndpointUrl" => $registerPushNotificationEndpointUrl, "promoAjaxUri" => Config::get("custom.live_shows_uri"), "env" => App::environment(), "version" => DebugHelpers::getVersion(), "degradedService" => Config::get("degradedService.enabled"));
     $facebookAppId = Config::get("facebook.appId");
     $defaultOpenGraphProperties = array();
     if (!is_null($facebookAppId)) {
         $defaultOpenGraphProperties[] = array("name" => "fb:app_id", "content" => $facebookAppId);
     }
     $defaultOpenGraphProperties[] = array("name" => "og:title", "content" => "LA1:TV");
     $defaultOpenGraphProperties[] = array("name" => "og:url", "content" => Request::url());
     $defaultOpenGraphProperties[] = array("name" => "og:locale", "content" => "en_GB");
     $defaultOpenGraphProperties[] = array("name" => "og:site_name", "content" => "LA1:TV");
     $defaultOpenGraphProperties[] = array("name" => "og:description", "content" => $description);
     $defaultOpenGraphProperties[] = array("name" => "og:image", "content" => Config::get("custom.open_graph_logo_uri"));
     $finalOpenGraphProperties = $this->mergeProperties($defaultOpenGraphProperties, $openGraphProperties);
     $finalTwitterProperties = array();
     if (!is_null($twitterProperties)) {
         $defaultTwitterProperties = array(array("name" => "card", "content" => "summary"), array("name" => "site", "content" => "@LA1TV"), array("name" => "description", "content" => str_limit($description, 197, "...")), array("name" => "image", "content" => Config::get("custom.twitter_card_logo_uri")));
         $finalTwitterProperties = $this->mergeProperties($defaultTwitterProperties, $twitterProperties);
     }
     $view->openGraphProperties = $finalOpenGraphProperties;
     $view->twitterProperties = $finalTwitterProperties;
     $view->searchEnabled = Config::get("search.enabled");
     $view->searchQueryAjaxUri = Config::get("custom.search_query_uri");
     $view->loginUri = URLHelpers::generateLoginUrl();
     $view->homeUri = Config::get("custom.base_url");
     $view->guideUri = Config::get("custom.base_url") . "/guide";
     $view->blogUri = Config::get("custom.blog_url");
     $view->contactUri = Config::get("custom.base_url") . "/contact";
     $view->accountUri = Config::get("custom.base_url") . "/account";
     $view->adminUri = Config::get("custom.base_url") . "/admin";
     // recent shows in dropdown
     $shows = Show::getCachedActiveShows();
     $view->showsDropdown = array();
     foreach ($shows as $a) {
         $view->showsDropdown[] = array("uri" => Config::get("custom.base_url") . "/show/" . $a->id, "text" => $a->name);
     }
     $view->showsUri = Config::get("custom.base_url") . "/shows";
     // recent playlists dropdown
     $playlists = Playlist::getCachedActivePlaylists(false);
     $view->playlistsDropdown = array();
     foreach ($playlists as $a) {
         $view->playlistsDropdown[] = array("uri" => Config::get("custom.base_url") . "/playlist/" . $a->id, "text" => $a->name);
     }
     $view->playlistsUri = Config::get("custom.base_url") . "/playlists";
     $liveStreams = LiveStream::getCachedSiteLiveStreams();
     $view->liveStreamsDropdown = array();
     foreach ($liveStreams as $a) {
         $view->liveStreamsDropdown[] = array("uri" => Config::get("custom.base_url") . "/livestream/" . $a->id, "text" => $a->name);
     }
     $contentSecurityPolicyDomains = MediaItemLiveStream::getCachedLiveStreamDomains();
     $response = new MyResponse($view, $statusCode);
     // disable csp for main site because causing too many issues with live streams (and clappr uses unsafe evals etc)
     $response->enableContentSecurityPolicy(false);
     //$response->setContentSecurityPolicyDomains($contentSecurityPolicyDomains);
     $this->layout = $response;
 }