'yes'));
}else
echo json_encode(array('err'=>'Invalid remote url'));
exit();
}
//error_reporting(E_ALL); /**/
/**
* Call back function of cURL handlers
* when it downloads a file, it works with php >= 5.3.0
* @param $download_size total file size of the file
* @param $downloaded total file size that has been downloaded
* @param $upload_size total file size that has to be uploaded
* @param $uploadsed total file size that is uploaded
*
* Writes the log in file
*/
if(!isCurlInstalled())
{
exit(json_encode(array("error"=>"Sorry, we do not support remote upload")));
}
//checking if user is logged in or not
if(!userid())
exit(json_encode(array('error'=>'You are not logged in')));
if(isset($_POST['youtube']))
{
$youtube_url = $_POST['file'];
$filename = $_POST['file_name'];
$ParseUrl = parse_url($youtube_url);
parse_str($ParseUrl['query'], $youtube_url_prop);
$YouTubeId = isset($youtube_url_prop['v']) ? $youtube_url_prop['v'] : '';
if(!$YouTubeId)
{
exit(json_encode(array("error"=>"Invalid youtube url")));
}
//for devolpment
$youtube_content = file_get_contents('http://gdata.youtube.com/feeds/api/videos/'.$YouTubeId.'?v=2&alt=jsonc');
$content = json_decode($youtube_content);
//$content = xml2array('http://gdata.youtube.com/feeds/api/videos/'.$YouTubeId);
$content = $content->data;
/* $match_arr =
array
(
"title"=>"//",
"description"=>"//",
"tags" =>"//",
"embed_code" => "//",
"duration" => "/([0-9\:]+)<\/span>/"
);
$vid_array = array();
foreach($match_arr as $title=> $match)
{
preg_match($match,$content,$matches);
$vid_array[$title] = $matches[1];
}*/
$vid_array['title'] = $content->title;
$vid_array['description'] = $content->description;
$vid_array['tags'] = $content->title;
$vid_array['duration'] = $content->duration;
$vid_array['thumbs'] =
array('http://i3.ytimg.com/vi/'.$YouTubeId.'/1.jpg','http://i3.ytimg.com/vi/'.
$YouTubeId.'/2.jpg','http://i3.ytimg.com/vi/'.$YouTubeId.'/3.jpg',
'big'=>'http://i3.ytimg.com/vi/'.$YouTubeId.'/0.jpg');
$vid_array['embed_code'] = '