Example #1
0
        if ($video[0] == $name) {
            return $video[1];
        }
    }
    return false;
}
//Determine if any of the YouTube links are valid
//Strip from url format 1: http://youtube.com/watch?v=xxx
if (preg_match("/^(?:http[s]?:\\/\\/)?(?:www\\.)?youtube.com\\/watch\\?(?=.*v=[a-zA-Z0-9_-]{11})(?:\\S+)?\$/", $video, $matches)) {
    $vid = substr($video, strpos($video, "v=") + 2, 11);
} else {
    if (preg_match("/^(?:http[s]?:\\/\\/)?(?:www\\.)?youtu.be\\/([a-zA-Z0-9_-]{11})(?:\\S+)?\$/", $video, $matches)) {
        $vid = substr($video, strpos($video, ".be") + 4, 11);
    } else {
        //Maybe they entered an exact title?
        $ttv = titleToVID($video);
        if ($ttv) {
            $vid = $ttv;
        }
    }
}
if (strlen($vid) != 11) {
    $_SESSION['pageerror'] = "Invalid URL: " . $video;
    header("Location: /admin/banned");
    exit;
}
//Already banned?
$sql = "SELECT * FROM `votes` WHERE `banned` = b'1' AND `vid`='{$vid}'";
$result = $con->query($sql);
if ($result->num_rows > 0) {
    $_SESSION['pageerror'] = "This video is already banned.";
Example #2
0
        }
    }
    return false;
}
//Determine if any of the YouTube links are valid
for ($i = 0; $i < $totalvotes; $i += 1) {
    $vid[$i] = "";
    //Strip from url format 1: http://youtube.com/watch?v=xxx
    if (preg_match("/^(?:http[s]?:\\/\\/)?(?:www\\.)?youtube.com\\/watch\\?(?=.*v=[a-zA-Z0-9_-]{11})(?:\\S+)?\$/", $url[$i], $matches)) {
        $vid[$i] = substr($url[$i], strpos($url[$i], "v=") + 2, 11);
    } else {
        if (preg_match("/^(?:http[s]?:\\/\\/)?(?:www\\.)?youtu.be\\/([a-zA-Z0-9_-]{11})(?:\\S+)?\$/", $url[$i], $matches)) {
            $vid[$i] = substr($url[$i], strpos($url[$i], ".be") + 4, 11);
        } else {
            //Maybe they entered an exact title?
            $ttv = titleToVID($url[$i]);
            if ($ttv) {
                $vid[$i] = $ttv;
            }
        }
    }
}
//Make sure all were valid links
for ($i = 0; $i < $totalvotes; $i += 1) {
    //Not a youtube?
    if (strlen($vid[$i]) != 11) {
        $_SESSION['pageerror'] = "Invalid URL: " . $url[$i];
        header("Location: /");
        exit;
    }
    //Duplicate link?