Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 46 lines (41 sloc) 1.7 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
<?php
session_start();

$UID = getYoutubeId($_POST['UID']);

function getYoutubeId($youtube) {
    $url = parse_url($youtube);
    if($url['host'] !== 'youtube.com' &&
             $url['host'] !== 'www.youtube.com'&&
             $url['host'] !== 'youtu.be'&&
             $url['host'] !== 'www.youtu.be')
        return false;
    $youtube = preg_replace('~
# Match non-linked youtube URL in the wild. (Rev:20111012)
https?:// # Required scheme. Either http or https.
(?:[0-9A-Z-]+\.)? # Optional subdomain.
(?: # Group host alternatives.
youtu\.be/ # Either youtu.be,
| youtube\.com # or youtube.com followed by
\S* # Allow anything up to VIDEO_ID,
[^\w\-\s] # but char before ID is non-ID char.
) # End host alternatives.
([\w\-]{11}) # $1: VIDEO_ID is exactly 11 chars.
(?=[^\w\-]|$) # Assert next char is non-ID or EOS.
(?! # Assert URL is not pre-linked.
[?=&+%\w]* # Allow URL (query) remainder.
(?: # Group pre-linked alternatives.
[\'"][^<>]*> # Either inside a start tag,
| </a> # or inside <a> element text contents.
) # End recognized pre-linked alts.
) # End negative lookahead assertion.
[?=&+%\w]* # Consume any URL (query) remainder.
~ix',
        '$1',
        $youtube);
    $youtube = substr($youtube, 0, 11);
    return $youtube;
}

$download = "youtube-dl -f 18 " . $UID;

exec($download);
$string = 'rm /var/www/Giftest/*.gif';
exec($string);

?>
Something went wrong with that request. Please try again.