//Start session
if (isset($_GET["PHPSESID"])) {
    session_id($_GET["PHPSESID"]);
}
session_start();
//Filter user action and redirect to scrap function
if (isset($_GET["search"])) {
    $type = $_GET["search"];
    $pageTitle = base64_decode($_GET["title"]);
    fetchSearch($type, $pageTitle);
} else {
    if (isset($_GET["letter"])) {
        $type = base64_decode($_GET["type"]);
        $letter = $_GET["letter"];
        $pageTitle = base64_decode($_GET["title"]);
        fetchCategoryItems($type, $letter, $pageTitle);
    } else {
        if (isset($_GET["type"])) {
            $type = base64_decode($_GET["type"]);
            $pageTitle = base64_decode($_GET["title"]);
            if ($type == "nov") {
                fetchCategoryNewest();
            } else {
                if ($type == "pop") {
                    fetchCategoryPopular();
                } else {
                    if ($type == "est") {
                        fetchCategoryFirstRun();
                    } else {
                        if ($type == "doc") {
                            fetchCategoryFirstRun();
    $type = $_GET["search"];
    $pageTitle = base64_decode($_GET["title"]);
    fetchSearch($type, $pageTitle);
} else {
    if (isset($_GET["item"])) {
        $item = base64_decode($_GET["item"]);
        $title = base64_decode($_GET["title"]);
        fetchMovie($item, $title);
    } else {
        if (isset($_GET["host"])) {
            $host = base64_decode($_GET["host"]);
            $link = base64_decode($_GET["link"]);
            $title = base64_decode($_GET["title"]);
            fetchLink($title, $host, $link);
        } else {
            fetchCategoryItems("");
        }
    }
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/**
 * Get category movies and pages.
 */
function fetchCategoryItems($title)
{
    $template = new Anime44MoviesTemplate();
    $template->setLetter($letter);
    //If page equal "x" goto page number list, in other case process actual category page
    if (isset($_GET["page"]) && $_GET["page"] == "x") {
        $maxPages = $_GET["pages"];