I can’t back up the link

Asked

Viewed 44 times

0

The site Openload and Streamanho works perfectly, more of this site can not backup link. Somebody help me solve this problem please?

<?php
require "config.php";

error_reporting(0);
ini_set('display_errors', 0);

if (isset($_GET["id"])) {
    $id = $_GET["id"];

    $query = $db->prepare("SELECT * FROM videos WHERE uuid = :id");
    $query->execute(array("id" => $id));
    $video = $query->fetch(PDO::FETCH_ASSOC);

    if ($video) {
        if (isVideoRemoved($video['link'])) {
            if (!isNullOrEmptyString($video["backup_link"])) {
                if (!isVideoRemoved($video["backup_link"])) {
                    $query = $db->prepare("UPDATE videos SET link = :link, backup_link = '',status = 1 WHERE uuid = :id");
                    $update = $query->execute(array("link" => $video["backup_link"], "id" => $id));
                    if ($update) {
                        addVideoBackup($id, $video["backup_link"], $verystreamLogin, $verystreamKey);
                        redirect($video["backup_link"]);
                    }
                } else {
                    $query = $db->prepare("UPDATE videos SET status = 0 WHERE uuid = :id");
                    $update = $query->execute(array("id" => $id));
                    die("KAYNAK SORUNLU, DİĞER KAYNAKLARI DENEYİNİZ");
                }
            } else {
                $query = $db->prepare("UPDATE videos SET status = 0 WHERE uuid = :id");
                $update = $query->execute(array("id" => $id));
                die("KAYNAK SORUNLU, DİĞER KAYNAKLARI DENEYİNİZ");
            }
        } else {
            if (isNullOrEmptyString($video["backup_link"])) {
                addVideoBackup($id, $video["link"], $verystreamLogin, $verystreamKey);
            }
            $query = $db->prepare("UPDATE videos SET status = 1 WHERE uuid = :id");
            $update = $query->execute(array("id" => $id));
            redirect($video['link']);
        }
    } else {
        die("KAYNAK SORUNLU, DİĞER KAYNAKLARI DENEYİNİZ");
    }
} else {
    die("KAYNAK SORUNLU, DİĞER KAYNAKLARI DENEYİNİZ");
}

function addVideoBackup($id, $url, $login, $key)
{
    global $db;
    $uploadId = addVideoRemoteDownloadReq($url, $login, $key);
    if ($uploadId) {
        $newLink = checkVideoRemoteDownloadReq($uploadId, $login, $key);
        if ($newLink && !isNullOrEmptyString($newLink)) {
            $newLink = str_replace("verystream.com", "verystream.com", $newLink);
            $newLink = str_replace("/e/", "/e/", $newLink);

            $query = $db->prepare("UPDATE videos SET backup_link = :link, status = 1 WHERE uuid = :id");
            $update = $query->execute(array("link" => $newLink, "id" => $id));
            if ($update)
                return $newLink;
        }
    }
    return false;
}

function checkVideoRemoteDownloadReq($videoId, $login, $key)
{
    $resp = request("https://api.verystream.com/remotedl/status?login=$login&key=$key&id=$videoId");
    $respArray = json_decode($resp, true);
    if ($respArray["status"] == 200) {
        if ($respArray["result"][$videoId]["status"] == "finished")
            return $respArray["result"][$videoId]["url"];
    }
    return false;
}

function addVideoRemoteDownloadReq($url, $login, $key)
{
    $resp = request("https://api.verystream.com/remotedl/add?login=$login&key=$key&url=$url");
    $respArray = json_decode($resp, true);
    if ($respArray["status"] == 200) {
        return $respArray["result"]["id"];
    }
    return false;
}

function isVideoRemoved($url)
{
    $html = request($url);
    if (strpos($html, 'File blocked! Much sorry!') !== false) {
        return true;
    } else {
        return false;
    }
}

function isNullOrEmptyString($question)
{
    return (!isset($question) || trim($question) === '');
}

function redirect($url, $statusCode = 303)
{
    header('Location: ' . $url, true, $statusCode);
    die();
}

1 answer

0

<?php
require "config.php";

error_reporting(0);
ini_set('display_errors', 0);

if (isset($_GET["id"])) {
    $id = $_GET["id"];

    $query = $db->prepare("SELECT * FROM videos WHERE uuid = :id");
    $query->execute(array("id" => $id));
    $video = $query->fetch(PDO::FETCH_ASSOC);

    if ($video) {
        if (isVideoRemoved($video['link'])) {
            if (!isNullOrEmptyString($video["backup_link"])) {
                if (!isVideoRemoved($video["backup_link"])) {
                    $query = $db->prepare("UPDATE videos SET link = :link, backup_link = '',status = 1 WHERE uuid = :id");
                    $update = $query->execute(array("link" => $video["backup_link"], "id" => $id));
                    if ($update) {
                        addVideoBackup($id, $video["backup_link"], $verystreamLogin, $verystreamKey);
                        redirect($video["backup_link"]);
                    }
                } else {
                    $query = $db->prepare("UPDATE videos SET status = 0 WHERE uuid = :id");
                    $update = $query->execute(array("id" => $id));
                    die("KAYNAK SORUNLU, DİĞER KAYNAKLARI DENEYİNİZ");
                }
            } else {
                $query = $db->prepare("UPDATE videos SET status = 0 WHERE uuid = :id");
                $update = $query->execute(array("id" => $id));
                die("KAYNAK SORUNLU, DİĞER KAYNAKLARI DENEYİNİZ");
            }
        } else {
            if (isNullOrEmptyString($video["backup_link"])) {
                addVideoBackup($id, $video["link"], $verystreamLogin, $verystreamKey);
            }
            $query = $db->prepare("UPDATE videos SET status = 1 WHERE uuid = :id");
            $update = $query->execute(array("id" => $id));
            redirect($video['link']);
        }
    } else {
        die("KAYNAK SORUNLU, DİĞER KAYNAKLARI DENEYİNİZ");
    }
} else {
    die("KAYNAK SORUNLU, DİĞER KAYNAKLARI DENEYİNİZ");
}

function addVideoBackup($id, $url, $login, $key)
{
    global $db;
    $uploadId = addVideoRemoteDownloadReq($url, $login, $key);
    if ($uploadId) {
        $newLink = checkVideoRemoteDownloadReq($uploadId, $login, $key);
        if ($newLink && !isNullOrEmptyString($newLink)) {
            $newLink = str_replace("verystream.com", "verystream.com", $newLink);
            $newLink = str_replace("/e/", "/e/", $newLink);

            $query = $db->prepare("UPDATE videos SET backup_link = :link, status = 1 WHERE uuid = :id");
            $update = $query->execute(array("link" => $newLink, "id" => $id));
            if ($update)
                return $newLink;
        }
    }
    return false;
}

function checkVideoRemoteDownloadReq($videoId, $login, $key)
{
    $resp = request("https://api.verystream.com/remotedl/status?login=$login&key=$key&id=$videoId");
    $respArray = json_decode($resp, true);
    if ($respArray["status"] == 200) {
        if ($respArray["result"][$videoId]["status"] == "finished")
            return $respArray["result"][$videoId]["url"];
    }
    return false;
}

function addVideoRemoteDownloadReq($url, $login, $key)
{
    $resp = request("https://api.verystream.com/remotedl/add?login=$login&key=$key&url=$url");
    $respArray = json_decode($resp, true);
    if ($respArray["status"] == 200) {
        return $respArray["result"]["id"];
    }
    return false;
}



function isVideoRemoved($url)
{
    $html = request($url);
    if (strpos($html, 'File blocked! Much sorry!') !== false) {
        return true;
    } else {
        return false;
    }
}

function isNullOrEmptyString($question)
{
    return (!isset($question) || trim($question) === '');
}

function redirect($url, $statusCode = 303)
{
    header('Location: ' . $url, true, $statusCode);
    die();
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.