Класс
<?php class videoThumb { var $config; 'imagesPath' => PATH. '/images/' ,'imagesUrl' => '/images/video/' ,'emptyImage' => '/images/video/nopic.jpg' ),$config); } } /* * Return error message from lexicon array * @param string $msg Array key * @return string Message * */ function lexicon($msg = '') { 'video_err_ns' => 'Вы забыли указать ссылку на видео.' ,'video_err_nf' => 'Не могу найти видео, может - неверная ссылка?' ); return @$array[$msg]; } /* * Check and format video link, then fire download of preview image * @param string $video Remote url on video hosting * @return array $array Array with formatted video link and preview url * */ function process($video = '') { $video = 'http://' . $video; } // YouTube if (preg_match('/[http|https]+:\/\/(?:www\.|)youtube\.com\/watch\?(?:.*)?v=([a-zA-Z0-9_\-]+)/i', $video, $matches) || preg_match('/[http|https]+:\/\/(?:www\.|)youtube\.com\/embed\/([a-zA-Z0-9_\-]+)/i', $video, $matches) || preg_match('/[http|https]+:\/\/(?:www\.|)youtu\.be\/([a-zA-Z0-9_\-]+)/i', $video, $matches)) { $video = 'http://www.youtube.com/embed/'.$matches[1]; $image = 'http://img.youtube.com/vi/'.$matches[1].'/0.jpg'; 'video' => $video ,'image' => $this->getRemoteImage($image) ); } // Vimeo else if (preg_match('/[http|https]+:\/\/(?:www\.|)vimeo\.com\/([a-zA-Z0-9_\-]+)(&.+)?/i', $video, $matches) || preg_match('/[http|https]+:\/\/player\.vimeo\.com\/video\/([a-zA-Z0-9_\-]+)(&.+)?/i', $video, $matches)) { $video = 'http://player.vimeo.com/video/'.$matches[1]; $image = ''; $image = $xml->video->thumbnail_large ? (string) $xml->video->thumbnail_large: (string) $xml->video->thumbnail_medium; $image = $this->getRemoteImage($image); } 'video' => $video ,'image' => $image ); } // ruTube else if (preg_match('/[http|https]+:\/\/(?:www\.|)rutube\.ru\/video\/embed\/([a-zA-Z0-9_\-]+)/i', $video, $matches) || preg_match('/[http|https]+:\/\/(?:www\.|)rutube\.ru\/tracks\/([a-zA-Z0-9_\-]+)(&.+)?/i', $video, $matches)) { $video = 'http://rutube.ru/video/embed/'.$matches[1]; $image = ''; if ($xml = simplexml_load_file("http://rutube.ru/cgi-bin/xmlapi.cgi?rt_mode=movie&rt_movie_id=".$matches[1]."&utf=1")) { $image = (string) $xml->movie->thumbnailLink; $image = $this->getRemoteImage($image); } 'video' => $video ,'image' => $image ); } else if (preg_match('/[http|https]+:\/\/(?:www\.|)rutube\.ru\/video\/([a-zA-Z0-9_\-]+)\//i', $video, $matches)) { $html = $this->Curl($matches[0]); return $this->process($html); } // No matches else { } return $array; } /* * Download ans save image from remote service * @param string $url Remote url * @return string $image Url to image or false * */ function getRemoteImage($url = '') { $image = ''; $response = $this->Curl($url); $image = $this->config['imagesUrl'] . $filename; } } return $image; } /* * Method for loading remote url * @param string $url Remote url * @return mixed $data Results of an request * */ function Curl($url = '') { return $data; } }