コード例 #1
0
 public function dispatch()
 {
     //Check for session path
     if (!isset($_SESSION["playlistActualPath"])) {
         $_SESSION["playlistActualPath"] = $this->basepath;
     }
     //
     $subaction = $_GET["subaction"];
     switch ($subaction) {
         case ViewPlaylistPageAction::SUBACTION_PLAYLIST_DELETE:
             //---------------------------
             $path = base64_decode($_GET["path"]);
             $this->deletePlaylist($path);
             //Refresh
             $items = $this->getFolderPlaylist($_SESSION["playlistActualPath"]);
             $template = new PlaylistFolderTemplate($this->convertRssPathTitle($_SESSION["playlistActualPath"]));
             $template->setItems($items);
             break;
         case ViewPlaylistPageAction::SUBACTION_PLAYLIST_OPEN:
             //----------------------------
             $path = $_SESSION["playlistActualPath"] . "/" . base64_decode($_GET["playlist"]);
             $template = new PlaylistTemplate("..:: xVoD ::..:: Playlist Playlist View ::..");
             try {
                 $playlist = $this->openPlaylist($path);
                 $_SESSION["loadedPlaylist"] = serialize($playlist);
                 $template->setPlaylist($playlist);
                 $template->setTitle($playlist->getName() != null ? $playlist->getName() . ' (' . $playlist->getFilename() . ')' : $playlist->getFilename());
             } catch (Exception $e) {
                 $template->setDescription($e->getMessage());
             }
             break;
         case ViewPlaylistPageAction::SUBACTION_PLAYLIST_FOLDER_OPEN:
             //-----------------------
             $selectedFolder = base64_decode($_GET['folder']);
             //Check for base path or return folder
             if ($_SESSION["playlistActualPath"] == $this->basepath && $selectedFolder == "..") {
                 $path = $this->basepath;
             } else {
                 if ($selectedFolder == "..") {
                     $path = $_SESSION["playlistActualPath"];
                     $path = substr($path, 0, strrpos($path, "/"));
                 } else {
                     $path = $_SESSION["playlistActualPath"];
                     $path = $path . "/" . $selectedFolder;
                 }
             }
             //Load folder playlist file list
             $_SESSION["playlistActualPath"] = $path;
             $items = $this->getFolderPlaylist($path);
             $template = new PlaylistFolderTemplate($this->convertRssPathTitle($path));
             $template->setItems($items);
             $template->setBaseFolder($path);
             break;
         case ViewPlaylistPageAction::SUBACTION_PLAYLIST_LINK:
             //-------------------------------
             $playlist = unserialize($_SESSION["loadedPlaylist"]);
             $key = base64_decode($_GET["link"]);
             $playlistLink = $playlist->getPlaylistLink($key);
             $template = new PlaylistLinkTemplate($playlistLink->getTitle() != null ? $playlistLink->getTitle() : $playlistLink->getFilename());
             $template->setPlaylistLink($playlistLink);
             break;
         default:
             //-----------------------------------------------------------------------------
             $items = $this->getFolderPlaylist($_SESSION["playlistActualPath"]);
             $template = new PlaylistFolderTemplate($this->convertRssPathTitle($_SESSION["playlistActualPath"]));
             $template->setItems($items);
             $template->setBaseFolder($_SESSION["playlistActualPath"]);
             break;
     }
     $template->showTemplate();
 }
コード例 #2
0
 public function dispatch()
 {
     //Check for session path
     if (!isset($_SESSION["webPlaylistActualPath"])) {
         $_SESSION["webPlaylistActualPath"] = $this->basepath;
     }
     //
     $subaction = $_GET["subaction"];
     switch ($subaction) {
         case ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_DELETE:
             //------------------------------------------------
             if (isset($_GET["path"])) {
                 $path = base64_decode($_GET["path"]);
                 $message = $this->deletePlaylist($_SESSION["webPlaylistActualPath"] . "/" . $path);
             }
             $template = $this->createDefaultTemplateFolderExplorer();
             $template->setMessage($message);
             break;
         case ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_OPEN:
             //-------------------------------------------------
             $path = $_SESSION["webPlaylistActualPath"] . "/" . base64_decode($_GET["playlist"]);
             $template = new PlaylistWebTemplate("..:: xVoD ::..:: Playlist Playlist View ::..");
             try {
                 $playlist = $this->openPlaylist($path);
                 $_SESSION["webLoadedPlaylist"] = serialize($playlist);
                 $template->setPlaylist($playlist);
                 $template->setTitle($playlist->getName() != null ? $playlist->getName() . ' (' . $playlist->getFilename() . ')' : $playlist->getFilename());
             } catch (Exception $e) {
                 $template->setDescription($e->getMessage());
             }
             break;
         case ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_FOLDER_OPEN:
             //--------------------------------------------
             $selectedFolder = base64_decode($_GET['folder']);
             //Check for base path or return folder
             if ($_SESSION["webPlaylistActualPath"] == $this->basepath && $selectedFolder == "..") {
                 $path = $this->basepath;
             } else {
                 if ($selectedFolder == "..") {
                     $path = $_SESSION["webPlaylistActualPath"];
                     $path = substr($path, 0, strrpos($path, "/"));
                 } else {
                     $path = $_SESSION["webPlaylistActualPath"];
                     $path = $path . "/" . $selectedFolder;
                 }
             }
             //Load folder playlist file list
             $_SESSION["webPlaylistActualPath"] = $path;
             $items = $this->getFolderPlaylist($path);
             $template = new PlaylistExploreWebTemplate($this->convertRssPathTitle($path));
             $template->setItems($items);
             $template->setBaseFolder($path);
             break;
         case ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_LINK:
             //-----------------------------------------------------
             $playlist = unserialize($_SESSION["webLoadedPlaylist"]);
             $key = base64_decode($_GET["link"]);
             $playlistLink = $playlist->getPlaylistLink($key);
             $template = new PlaylistLinkWebTemplate($playlistLink->getTitle());
             $template->setPlaylistLink($playlistLink);
             $template->setPlaylist($playlist);
             break;
         case ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_LINK_ADD:
             //-------------------------------------------------
             $template = new PlaylistLinkAddWebTemplate();
             $template->setPlaylist(unserialize($_SESSION["webLoadedPlaylist"]));
             break;
         case ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_LINK_SAVE:
             //------------------------------------------------
             $playlist = unserialize($_SESSION["webLoadedPlaylist"]);
             //Create playlist link and recover data
             $playlistLink = new PlaylistLink();
             $playlistLink->setKey(uniqid());
             $playlistLink->setTitle(utf8_encode(html_entity_decode($_GET["title"])));
             $playlistLink->setDescription(utf8_encode(html_entity_decode($_GET["description"])));
             $playlistLink->setLanguage(utf8_encode(html_entity_decode($_GET["language"])));
             $playlistLink->setThumbnail(utf8_encode(html_entity_decode($_GET["thumbnail"])));
             $playlistLink->setType(utf8_encode(html_entity_decode($_GET["type"])));
             $playlistLink->setFormat(utf8_encode(html_entity_decode($_GET["format"])));
             //Set link or ids
             if ($_GET["type"] == "HTTP") {
                 $playlistLink->setLink($_GET["link"]);
                 $playlist->addPlaylistLink($playlistLink);
             } else {
                 if ($_GET["type"] == "MV" || $_GET["type"] == "MU") {
                     $ids = split(" ", $_GET["link"]);
                     $order = 0;
                     foreach ($ids as $id) {
                         $playlistLink->addId($order, $id);
                         ++$order;
                     }
                 }
             }
             //Save playlist
             $playlist->addPlaylistLink($playlistLink);
             $this->savePlaylist($playlist->getPath() . "/" . $playlist->getFilename(), $playlist);
             $_SESSION["webLoadedPlaylist"] = serialize($playlist);
             //
             $template = new PlaylistLinkAddWebTemplate();
             $template->setPlaylist($playlist);
             break;
         case ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_LINK_DELETE:
             //----------------------------------------------
             $playlist = unserialize($_SESSION["webLoadedPlaylist"]);
             $playlist->deletePlaylistLink(base64_decode($_GET["link"]));
             $this->savePlaylist($playlist->getPath() . "/" . $playlist->getFilename(), $playlist);
             $_SESSION["webLoadedPlaylist"] = serialize($playlist);
             $template = new PlaylistWebTemplate("..:: xVoD ::..:: Playlist Playlist View ::..");
             $template->setTitle($playlist->getName() != null ? $playlist->getName() . ' (' . $playlist->getFilename() . ')' : $playlist->getFilename());
             $template->setPlaylist($playlist);
             break;
         case ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_ADD:
             //------------------------------------------------------
             $template = new PlaylistAddWebTemplate();
             $template->setBasepath($_SESSION["webPlaylistActualPath"]);
             break;
         case ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_ADD_SAVE:
             //-------------------------------------------------
             $playlist = new Playlist();
             $playlist->setName($_GET["name"]);
             $playlist->setDescription($_GET["description"]);
             $playlist->setPath($_GET["path"]);
             $playlist->setFilename($_GET["filename"]);
             $this->savePlaylist($playlist->getPath() . "/" . $playlist->getFilename() . ".xpls", $playlist);
             $template = $this->createDefaultTemplateFolderExplorer();
             break;
         case ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_SAVE:
             //------------------------------------------------------
             $playlist = unserialize($_SESSION["webLoadedPlaylist"]);
             $key = base64_decode($_GET["link"]);
             $playlistLink = $playlist->getPlaylistLink($key);
             $template = new PlaylistLinkTemplate($playlistLink->getTitle() != null ? $playlistLink->getTitle() : $playlistLink->getFilename());
             $template->setPlaylistLink($playlistLink);
             break;
         case ViewPlaylistWebPageAction::SUBACTION_FOLDER_DELETE:
             //-------------------------------------------------------
             if (isset($_GET["folder"])) {
                 $folderName = base64_decode($_GET["folder"]);
                 $this->deleteFolder($_SESSION["webPlaylistActualPath"] . "/" . $folderName);
             }
             $template = $this->createDefaultTemplateFolderExplorer();
             break;
         case ViewPlaylistWebPageAction::SUBACTION_FOLDER_ADD:
             //-----------------------------------------------------------
             if (isset($_GET["folder"])) {
                 $folderName = $_GET["folder"];
                 $message = $this->createFolder($_SESSION["webPlaylistActualPath"] . "/" . $folderName);
             }
             $template = $this->createDefaultTemplateFolderExplorer();
             $template->setMessage($message);
             break;
         case ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_DOWNLOAD:
             //----------------------------------------------------
             if (isset($_GET["download"])) {
                 $folderName = base64_decode($_GET["download"]);
                 $this->downloadFile($_SESSION["webPlaylistActualPath"], $folderName);
             }
             break;
         case ViewPlaylistWebPageAction::SUBACTION_FOLDER_DOWNLOAD:
             if (isset($_GET["download"])) {
                 $folderName = base64_decode($_GET["download"]);
                 $this->downloadFolder($_SESSION["webPlaylistActualPath"], $folderName);
             }
             break;
         case ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_UPLOAD:
             //-------------------------------------------------------
             $template = new PlaylistUploadWebTemplate();
             $template->setBasePath(strstr($_SESSION["webPlaylistActualPath"], "xVoD"));
             break;
         case ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_UPLOAD_SAVE:
             //--------------------------------------------------
             $message = array();
             //Save http file
             if (isset($_POST["uploadFileWeb"]) && $_POST["uploadFileWeb"] != "http://") {
                 try {
                     $content = @file_get_contents($_POST["uploadFileWeb"]);
                     if (strpos($content, "</playlist>")) {
                         $file = $_SESSION["webPlaylistActualPath"] . "/" . $_POST["uploadFileWebName"] . ".xpls";
                         $fp = fopen($file, 'w');
                         fwrite($fp, utf8_encode($content));
                         fclose($fp);
                         array_push($message, "File '" . $_POST["uploadFileWebName"] . ".xpls has been saved correctly.");
                     } else {
                         array_push($message, "File '" . $_POST["uploadFileWebName"] . ".xpls has been saved correctly.");
                     }
                 } catch (Exception $e) {
                     array_push($message, "An error has occurred: " . $e->getMessage() . ".");
                 }
             }
             //Save upload file
             if (isset($_FILES['uploadFile'])) {
                 $fileName = $_FILES['uploadFile']['name'];
                 $fileExtension = $_FILES['uploadFile']['type'];
                 $fileSize = $_FILES['uploadFile']['size'];
                 if (strpos($fileName, "xpls")) {
                     if (move_uploaded_file($_FILES['uploadFile']['tmp_name'], $_SESSION["webPlaylistActualPath"] . "/" . $fileName)) {
                         array_push($message, "File '" . $fileName . " with size " . $fileSize . " has been saved correctly.");
                     } else {
                         array_push($message, "An error has occurred saving file!!");
                     }
                 } else {
                     array_push($message, "Only files with XPLS extension be accepted.");
                 }
             }
             //Return to explorer or show upload view another time
             if (isset($_POST["returnExplorer"]) && $_POST["returnExplorer"] == "ON") {
                 $template = $this->createDefaultTemplateFolderExplorer();
                 if ($message && count($message) > 0) {
                     $temp = "";
                     foreach ($message as $value) {
                         $temp .= "<br/>" . $value;
                     }
                     $template->setMessage($temp);
                 }
             } else {
                 $template = new PlaylistUploadWebTemplate();
                 $template->setMessage($message);
                 $template->setBasePath($_SESSION["webPlaylistActualPath"]);
             }
             break;
         default:
             //---------------------------------------------------------------------------------------------------------
             $template = $this->createDefaultTemplateFolderExplorer();
             break;
     }
     //
     if ($template) {
         $template->show();
     }
 }