public function dispatch()
 {
     $connection = ConnectionFactory::getDataConnection();
     $bookmarks = $connection->getBookmarks();
     $template = new BookmarksTemplate($bookmarks, "Bookmarks");
     $template->showTemplate();
 }
 /**
  * Retrieve favourite sites and fill data in template.
  */
 private function parseFavouriteSites($template)
 {
     try {
         $connection = ConnectionFactory::getDataConnection();
         $favourites = $connection->getWebsiteFavourites();
         foreach ($favourites as $id => $favourite) {
             $name = $favourite->getName();
             $link = SERVER_HOST_AND_PATH . "php/scraper" . $favourite->getLink();
             switch ($favourite->getType()) {
                 case "movie":
                     $template->setFavouriteMovieWebsite(array($name, $link));
                     break;
                 case "serie":
                     $template->setFavouriteSerieWebsite(array($name, $link));
                     break;
                 case "documentary":
                     $template->setFavouriteDocumentaryWebsite(array($name, $link));
                     break;
                 case "anime":
                     $template->setFavouriteAnimeWebsite(array($name, $link));
                     break;
             }
         }
     } catch (Exception $e) {
         //Ignored exception
     }
 }
 public function dispatch()
 {
     $connection = ConnectionFactory::getDataConnection();
     $scrapers = $connection->getScrapers();
     if ($scrapers) {
         $template = new WebsitesTemplate($scrapers, "..:: Xtreamer Video on Demand ::....:: xVoD ::..");
         //Check for type filter
         if (isset($_GET["type"])) {
             $template->setShowType($_GET["type"]);
         }
         $template->showTemplate();
     } else {
     }
 }
 public function dispatch()
 {
     if (isset($_GET["data"])) {
         //Save
         $bookmarkId = $_GET["data"];
         $connection = ConnectionFactory::getDataConnection();
         if ($connection->deleteBookmark($bookmarkId)) {
             echo "OK";
         } else {
             echo "ERROR";
         }
     } else {
         echo "ERROR";
     }
 }
 public function dispatch()
 {
     $subaction = $_GET["subaction"];
     switch ($subaction) {
         case ViewFavouritePageAction::SUBACTION_FAVOURITE_DELETE:
             //--------------------------------
             if (isset($_GET["id"])) {
                 $connection = ConnectionFactory::getDataConnection();
                 $connection->deleteBookmark($_GET["id"]);
             }
             break;
     }
     //Show default template
     $template = new FavouriteWebTemplate();
     $connection = ConnectionFactory::getDataConnection();
     $bookmarks = $connection->getBookmarks();
     $template->setFavourites($bookmarks);
     $template->show();
 }
 public function dispatch()
 {
     if (isset($_GET["id"])) {
         //Save
         $websiteId = $_GET["id"];
         $connection = ConnectionFactory::getDataConnection();
         $website = $connection->getScraperById($websiteId);
         if ($website) {
             $type = $website->getType();
             if ($website->getType() == "mixed") {
                 $type = "movie";
             }
             var_dump($website);
             $connection->addWebsiteFavourite($website->getId(), $type, $website->getName(), $website->getLink());
             echo "OK";
         } else {
             echo "ERROR";
         }
     } else {
         echo "ERROR";
     }
 }
 public function dispatch()
 {
     if (isset($_GET["data"])) {
         //Save
         $data = explode("-", $_GET["data"]);
         $title = base64_decode($data[0]);
         $link = base64_decode($data[1]);
         $link = substr($link, strpos($link, "xVoD") + 5);
         $image = base64_decode($data[2]);
         if ($title && $link) {
             $connection = ConnectionFactory::getDataConnection();
             if ($connection->getBookmarkByLink($link) == null) {
                 $connection->addBookmark($title, $description, $link, $image);
             }
             echo "OK";
         } else {
             echo "ERROR";
         }
     } else {
         echo "ERROR";
     }
 }
<?php

$oldDB = "data/db/xvod.sqlite3.db";
$newDB = "data/db/xvod.sqlite3.new.db";
$configFile = "config/config.php";
if (file_exists($oldDB) && file_exists($newDB)) {
    //Get connection
    $connection = ConnectionFactory::getDataConnection();
    //Get user bookmarks
    $bookmarks = $connection->getBookmarks();
    //Delete old db and change new one
    rename($oldDB, "data/db/xvod.sqlite3.old.db");
    rename($newDB, $oldDB);
    //Connection to new database
    $connection = ConnectionFactory::getDataConnection();
    foreach ($bookmarks as $id => $bookmark) {
        $connection->addBookmark($bookmark->getName(), $bookmark->getDescription(), $bookmark->getLink(), $bookmark->getImage());
    }
    //Set updated
    $lines = file($configFile);
    $out = "";
    foreach ($lines as $line) {
        if (strpos($line, "UPDATE_DB")) {
            $change = strstr($line, "true") ? true : false;
            $line = str_replace($change ? "true" : "false", !$change ? "true" : "false", $line);
        }
        $out .= $line;
    }
    $f = fopen($configFile, "w");
    fwrite($f, $out);
    fclose($f);
    /**
     * Generate rss page config header.
     */
    private function showHeader()
    {
        //Set change types
        switch ($this->showType) {
            case "all":
                $nextType = "movie";
                $previousType = "mixed";
                break;
            case "movie":
                $nextType = "serie";
                $previousType = "all";
                break;
            case "serie":
                $nextType = "documentary";
                $previousType = "movie";
                break;
            case "documentary":
                $nextType = "anime";
                $previousType = "serie";
                break;
            case "anime":
                $nextType = "mixed";
                $previousType = "documentary";
                break;
            case "mixed":
                $nextType = "all";
                $previousType = "anime";
                break;
        }
        ?>

<mediaDisplay name="photoView"
              rowCount="7" columnCount="3" drawItemText="no" showHeader="no" showDefaultInfo="no"
              menuBorderColor="0:0:0" sideColorBottom="-1:-1:-1" sideColorTop="-1:-1:-1"
              itemOffsetXPC="14" itemOffsetYPC="22.9" itemWidthPC="26" itemHeightPC="3.8"
              sliding="no" backgroundColor="-1:-1:-1" itemBorderColor="-1:-1:-1" imageBorderPC="0"
              idleImageXPC="90" idleImageYPC="5" idleImageWidthPC="5" idleImageHeightPC="8">
                          <?php 
        xVoDLoader();
        ?>
    <!-- IMAGE PUZZLE -->
    <image redraw="yes" offsetXPC="43.9" offsetYPC="71.6" widthPC="56.1" heightPC="6" backgroundColor="-1:-1:-1" >
                <?php 
        echo XTREAMER_IMAGE_PATH;
        ?>
background/websites_title.jpg
    </image>

    <!-- SELECTED ITEM LOGO -->
    <image redraw="yes" offsetXPC="1" offsetYPC="22.9" widthPC="10" heightPC="13" >
        <script>
            getItemInfo("thumbnailover");
        </script>
    </image>

    <!-- SELECTED WEBSITE ICON CONTENT TYPE -->
    <image redraw="yes" offsetXPC="47" offsetYPC="71.68" widthPC="3.8" heightPC="6" backgroundColor="-1:-1:-1" >
        <script>
            getItemInfo("image");
        </script>
    </image>
    <!-- SELECTED WEBSITE DESCRIPTION -->
    <text redraw="yes" backgroundColor="0:0:0" foregroundColor="0:154:205"
          offsetXPC="14.6" offsetYPC="59" widthPC="80" heightPC="7.6" fontSize="12" lines="2">
        <script>
            getItemInfo("description");
        </script>
    </text>
    <!-- SELECTED WEBSITE BOTTOM BAR TITLE -->
    <text redraw="yes" backgroundColor="-1:-1:-1" foregroundColor="0:0:0"
          offsetXPC="50" offsetYPC="67.4" widthPC="50" heightPC="14" fontSize="20" lines="1">
        <script>
            getItemInfo("subtitle");
        </script>
    </text>
    <!-- LOGO ICON HISTORY -->
    <image redraw="no" offsetXPC="5" offsetYPC="11.5" widthPC="2.25" heightPC="4" backgroundColor="-1:-1:-1" >
                <?php 
        echo XTREAMER_IMAGE_PATH;
        ?>
background/pgup_btn.png
    </image>

    <image redraw="no" offsetXPC="10" offsetYPC="11" widthPC="2.75" heightPC="5" backgroundColor="-1:-1:-1" >
                <?php 
        echo XTREAMER_IMAGE_PATH;
        ?>
img/all.png
    </image>
    <text redraw="no" backgroundColor="-1:-1:-1"
          foregroundColor="<?php 
        echo $this->showType == "all" ? "255:102:19" : "230:230:255";
        ?>
"
          offsetXPC="13" offsetYPC="11" widthPC="9" heightPC="5" fontSize="10" lines="1">
                      <?php 
        echo resourceString("header_menu_all") . "\n";
        ?>
    </text>

    <image redraw="no" offsetXPC="22" offsetYPC="11" widthPC="2.75" heightPC="5" backgroundColor="-1:-1:-1" >
                <?php 
        echo XTREAMER_IMAGE_PATH;
        ?>
img/movie.png
    </image>
    <text redraw="no" backgroundColor="-1:-1:-1"
          foregroundColor="<?php 
        echo $this->showType == "movie" ? "255:102:19" : "230:230:255";
        ?>
"
          offsetXPC="25" offsetYPC="11" widthPC="10" heightPC="5" fontSize="10" lines="1">
                      <?php 
        echo resourceString("header_menu_movies") . "\n";
        ?>
    </text>

    <image redraw="no" offsetXPC="35" offsetYPC="11" widthPC="2.75" heightPC="5" backgroundColor="-1:-1:-1" >
                <?php 
        echo XTREAMER_IMAGE_PATH;
        ?>
img/serie.png
    </image>
    <text redraw="no" backgroundColor="-1:-1:-1"
          foregroundColor="<?php 
        echo $this->showType == "serie" ? "255:102:19" : "230:230:255";
        ?>
"
          offsetXPC="38" offsetYPC="11" widthPC="9" heightPC="5" fontSize="10" lines="1">
                      <?php 
        echo resourceString("header_menu_series") . "\n";
        ?>
    </text>

    <image redraw="no" offsetXPC="47" offsetYPC="11" widthPC="2.75" heightPC="5" backgroundColor="-1:-1:-1" >
                <?php 
        echo XTREAMER_IMAGE_PATH;
        ?>
img/documentary.png
    </image>
    <text redraw="no" backgroundColor="-1:-1:-1"
          foregroundColor="<?php 
        echo $this->showType == "documentary" ? "255:102:19" : "230:230:255";
        ?>
"
          offsetXPC="50" offsetYPC="11" widthPC="12" heightPC="5" fontSize="10" lines="1">
                      <?php 
        echo resourceString("header_menu_documentaries") . "\n";
        ?>
    </text>

    <image redraw="no" offsetXPC="62" offsetYPC="11" widthPC="2.75" heightPC="5" backgroundColor="-1:-1:-1" >
                <?php 
        echo XTREAMER_IMAGE_PATH;
        ?>
img/anime.png
    </image>
    <text redraw="no" backgroundColor="-1:-1:-1"
          foregroundColor="<?php 
        echo $this->showType == "anime" ? "255:102:19" : "230:230:255";
        ?>
"
          offsetXPC="65" offsetYPC="11" widthPC="10" heightPC="5" fontSize="10" lines="1">
                      <?php 
        echo resourceString("header_menu_anime") . "\n";
        ?>
    </text>

    <image redraw="no" offsetXPC="75" offsetYPC="11" widthPC="2.75" heightPC="5" backgroundColor="-1:-1:-1" >
                <?php 
        echo XTREAMER_IMAGE_PATH;
        ?>
img/mixed.png
    </image>
    <text redraw="no" backgroundColor="-1:-1:-1"
          foregroundColor="<?php 
        echo $this->showType == "mixed" ? "255:102:19" : "230:230:255";
        ?>
"
          offsetXPC="78" offsetYPC="11" widthPC="10" heightPC="5" fontSize="10" lines="1">
                      <?php 
        echo resourceString("header_menu_mixed") . "\n";
        ?>
    </text>

    <image redraw="no" offsetXPC="92.5" offsetYPC="11.5" widthPC="2.25" heightPC="4" backgroundColor="-1:-1:-1" >
                <?php 
        echo XTREAMER_IMAGE_PATH;
        ?>
background/pgdn_btn.png
    </image>

    <!-- HEADER BUTTON TITLES -->
    <text redraw="no" backgroundColor="-1:-1:-1" foregroundColor="255:255:255"
          offsetXPC="5.95" offsetYPC="2.6" widthPC="12" heightPC="2.4" fontSize="12" lines="1">
                      <?php 
        echo resourceString("header_menu_home") . "\n";
        ?>
    </text>
    <text redraw="no" backgroundColor="-1:-1:-1" foregroundColor="255:255:255"
          offsetXPC="20" offsetYPC="2.6" widthPC="30" heightPC="2.4" fontSize="12" lines="1">
                      <?php 
        echo resourceString("header_menu_websites_mark_favourite") . "\n";
        ?>
    </text>

    <itemDisplay>
        <text redraw="yes" offsetXPC="1" offsetYPC="1" widthPC="98" heightPC="98">
            <backgroundColor>
                <script>
                    focusidx = getFocusItemIndex();
                    if ( focusidx == getItemInfo(-1,"itemid") ){
                        "255:192:192";
                    }else{
                        "32:32:32";
                    }
                </script>
            </backgroundColor>
        </text>
        <text redraw="yes" offsetXPC="1" offsetYPC="1" widthPC="1" heightPC="6" backgroundColor="0:0:0">
        </text>
        <text redraw="yes" offsetXPC="98" offsetYPC="1" widthPC="1" heightPC="6" backgroundColor="0:0:0">
        </text>
        <text redraw="yes" offsetXPC="1" offsetYPC="93" widthPC="1" heightPC="6" backgroundColor="0:0:0">
        </text>
        <text redraw="yes" offsetXPC="98" offsetYPC="93" widthPC="1" heightPC="6" backgroundColor="0:0:0">
        </text>
        <text redraw="yes" offsetXPC="36" offsetYPC="0" widthPC="60" heightPC="100" fontSize="12" lines="1"
              backgroundColor="-1:-1:-1" foregroundColor="255:255:255">
            <script>
                getItemInfo(-1,"title");
            </script>
            <foregroundColor>
                <script>
                    if ( focusidx == getItemInfo(-1,"itemid") ){
                        "0:0:0";
                    }else{
                        "255:255:255";
                    }
                </script>
            </foregroundColor>
        </text>
        <!-- ITEM FAVOURITE ICON -->
                <?php 
        $connection = ConnectionFactory::getDataConnection();
        $websites = $connection->getWebsiteFavourites();
        foreach ($websites as $id => $favourite) {
            switch ($favourite->getType()) {
                case "movie":
                    $movie = $id;
                    break;
                case "serie":
                    $serie = $id;
                    break;
                case "documentary":
                    $documentary = $id;
                    break;
                case "anime":
                    $anime = $id;
                    break;
            }
        }
        $condition = '( getItemInfo(-1,"scraperid") == "' . $movie . '" ) || ' . '( getItemInfo(-1,"scraperid") == "' . $serie . '" ) || ' . '( getItemInfo(-1,"scraperid") == "' . $documentary . '" ) || ' . '( getItemInfo(-1,"scraperid") == "' . $anime . '" )';
        ?>
        <image redraw="no" offsetXPC="2" offsetYPC="4" widthPC="8" heightPC="92">
            <script>
                if( <?php 
        echo $condition;
        ?>
 )
                "<?php 
        echo XTREAMER_IMAGE_PATH;
        ?>
img/star.png";
                else
                    "";
            </script>
        </image>
        <!-- ITEM CONTENT TYPE ICON -->
        <image redraw="no" offsetXPC="12" offsetYPC="0" widthPC="10" heightPC="100">
            <script>
                getItemInfo(-1,"image");
            </script>
        </image>
        <!-- ITEM CONTENT LANGUAGE FLAG ICON -->
        <text redraw="no" offsetXPC="24" offsetYPC="2" widthPC="10" heightPC="96" fontSize="12">
            <script>
                getItemInfo(-1,"scraperlanguage");
            </script>
            <foregroundColor>
                <script>
                    if ( focusidx == getItemInfo(-1,"itemid") ){
                        "0:0:0";
                    }else{
                        "255:255:255";
                    }
                </script>
            </foregroundColor>
            <backgroundColor>
                <script>
                    if ( focusidx == getItemInfo(-1,"itemid") ){
                        "192:192:255";
                    }else{
                        "64:64:255";
                    }
                </script>
            </backgroundColor>
        </text>
    </itemDisplay>

    <onUserInput>
        <script>
            userInput = currentUserInput();
            if( userInput == "one" ){
                showIdle();
                result = getURL("<?php 
        echo SERVER_HOST_AND_PATH . "php/index.php?action=" . SaveFavouriteWebsiteAction::getActionName() . URL_AMP . "id=";
        ?>
" + getItemInfo("scraperid"));
                jumpToLink("websitesPageLink");
                redrawDisplay();
            }
            if(userInput == "zero"){
                showIdle();
                jumpToLink("homePageLink");
                redrawDisplay();
            }
            if(userInput == "pageup"){
                showIdle();
                changeType = "<?php 
        echo $previousType;
        ?>
";
                jumpToLink("websitesChangeTypeLink");
                redrawDisplay();
            }
            if(userInput == "pagedown"){
                showIdle();
                changeType = "<?php 
        echo $nextType;
        ?>
";
                jumpToLink("websitesChangeTypeLink");
                redrawDisplay();
            }
        </script>
    </onUserInput>

    <backgroundDisplay>
        <image offsetXPC="0" offsetYPC="0" widthPC="100" heightPC="100">
                    <?php 
        echo XTREAMER_IMAGE_PATH;
        ?>
background/websites.jpg
        </image>
    </backgroundDisplay>

</mediaDisplay>

<websitesPageLink>
    <link>
            <?php 
        echo SERVER_HOST_AND_PATH . "php/index.php?action=" . ViewWebsitesPageAction::getActionName();
        ?>
    </link>
</websitesPageLink>

<websitesChangeTypeLink>
    <link>
    <script>
        "<?php 
        echo SERVER_HOST_AND_PATH . "php/index.php?action=" . ViewWebsitesPageAction::getActionName() . URL_AMP . "type=";
        ?>
" + changeType;
    </script>
    </link>
</websitesChangeTypeLink>

<homePageLink>
    <link>
            <?php 
        echo SERVER_HOST_AND_PATH . "php/index.php";
        ?>
    </link>
</homePageLink>

        <?php 
    }
 /**
  * Get scrapers marked as favourites to show it on first xVoD screen.
  * @return array Scrapers mark as favourites.
  */
 private function getFavouriteScrapers($forceLoad)
 {
     if (!$forceLoad && isset($_SESSION["webScrapersFavourites"])) {
         $favourites = unserialize($_SESSION["webScrapersFavourites"]);
     } else {
         $connection = ConnectionFactory::getDataConnection();
         $favourites = $connection->getWebsiteFavourites();
         $_SESSION["webScrapersFavourites"] = serialize($favourites);
     }
     return $favourites;
 }