Хак видео Rutube в DLE


Часто кино-сайты используют видеоролики с известных видеохостингов, как Рутубе или Ютубе. В дле достаточно вставить код ссылки Youtube, чтобы получить на странице готовый плеер и видеоролик для его демонстрации. Но с Rutube так не получится, чтобы любой пользователь на сайт мог добавлять ролики с Рутуб, вам поможет хак видео Rutube в DLE. Хак для dle нужен, чтобы вставить видео с Rutube на сайты под управлением CMS: DLE

Вам нужно дует сделать всего две вставки
Установка:

1.0 Открыть engine/classes/parse.class.php

найти

	AND $source['host'] != "gametrailers.com") return "[media=".$url."]";


заменить на

	AND $source['host'] != "gametrailers.com" AND $source['host'] != "rutube.ru") return "[media=" . $url . "]";


1.1 Найти

		if ($source['host'] == "youtube.com" OR $source['host'] == "youtu.be") {


заменить на

		if ($source['host'] == "rutube.ru") {

	        if (!function_exists('EmbedUrl')) {
				function EmbedUrl($source) {
                	$return = false;
					
					$timeout = stream_context_create( array ( 'http' => array( 'timeout' => 1 ) ) );

                	preg_match('#rutube.ru/video/([a-z0-9]+)/#', $source, $matches);//

                	if(isset($matches[1])) {
			        	$answer = file_get_contents("http://rutube.ru/api/video/" . $matches[1] . "?format=json", 0, $timeout);
                    	$params = json_decode($answer);
					
                    	/*
                    	 * $params->html возвращает готовый HTML IFRAME-код.
                    	 * Разбор из нее URL видео
                    	 */
                    	preg_match('#src="(.+?)"#', $params->html, $matches);
                    	if(isset($matches[1])) {
				        	return $matches[1];
                    	}
                	}

                	return $return;
            	}
			}
		
			$video_linc = getEmbedUrl("http://rutube.ru" . $source['path']);
			$video_link = $source['path'];
			
			if ( count($get_size) == 2 ) $decode_url = $width . "x" . $height . ", http://rutube.ru" . $video_link;
			else $decode_url = "http://rutube.ru" . $video_link;

			return '<!--dle_media_begin:' . $decode_url . '--><iframe width="' . $width . '" height="' . $height . '" src="' . $video_linc . '" frameborder="0" allowfullscreen></iframe><!--dle_media_end-->';

		} else
if ($source['host'] == "youtube.com" OR $source['host'] == "youtu.be") {


Готово!
Пример вставляемого кода:
[media=http://rutube.ru/video/12a5decd5cd3f6558ee04cf7f8c21609/]

Скачать хаки для dle у нас и другие.
Автор: vitnet
Версия DataLife Engine: 9.x - 10.x
Demo: Link хак видео с Rutube в DLE скачать текстовый файл в архиве

Hak-video-s-Rutube-v-DLE.rar [1,02 Kb] (cкачиваний: 99)
  • 80

Комментарии 4

vseprosto от 21 января 2014 14:03
а в файл parse.class.php
в переменную $allowed_domains дописать домен рутуба не судьба?

и тогда прямо в новости ставим фрейм рутуба без всяких медиа и прочих

и не надо никаких хаков

Или через дополнительное поое добавлять
hahol2030 от 21 января 2014 12:45
Версия 10.1 и теперь пишет
( $word_arr[5] == 2 AND !$this->safe_mode ) $allow_find = false; if ( $allow_find ) { if( $word_arr[3] ) { $find_text = "#(^|\b|\s|\
)" . preg_quote( $word_arr[1], "#" ) . "(\b|\s|!|\?|\.|,|$)#".$register; if( $word_arr[2] == "" ) $replace_text = "\\1"; else $replace_text = "\\1" . $word_arr[2] . "\\2"; } else { $find_text = "#(" . preg_quote( $word_arr[1], "#" ) . ")#".$register; if( $word_arr[2] == "" ) $replace_text = ""; else $replace_text = "" . $word_arr[2] . ""; } if ( $word_arr[6] ) { if ( preg_match($find_text, $source) ) { $this->not_allowed_text = true; return $source; } } else { $find[] = $find_text; $replace[] = $replace_text; } } } if( !count( $find ) ) return $source; $source = preg_split( '((>)|(<))', $source, - 1, PREG_SPLIT_DELIM_CAPTURE ); $count = count( $source ); for($i = 0; $i < $count; $i ++) { if( $source[$i] == "<" or $source[$i] == "[" ) { $i ++; continue; } if( $source[$i] != "" ) $source[$i] = preg_replace( $find, $replace, $source[$i] ); } $source = join( "", $source ); } else { $source = preg_replace( "#(.+?)#", "\\1", $source ); } return $source; } } ?>
dle9.com от 21 января 2014 12:27
Цитата: hahol2030
Странно все сделал как написано но пишет ошибку при добавление фильмы



Fatal error: Call to undefined function getembedurl() in /home/----/public_html/ваш-сайт.ru/engine/classes/parse.class.php on line 714

Как можно исправить ?

Версии движка ?
в конце код был слитно написан
elseif

должно так
else 
if

проверьте исправлено
hahol2030 от 21 января 2014 11:40
Странно все сделал как написано но пишет ошибку при добавление фильмы



Fatal error: Call to undefined function getembedurl() in /home/----/public_html/ваш-сайт.ru/engine/classes/parse.class.php on line 714

Как можно исправить ?
Добавить комментарий

Оставить комментарий

    • bowtiesmilelaughingblushsmileyrelaxedsmirk
      heart_eyeskissing_heartkissing_closed_eyesflushedrelievedsatisfiedgrin
      winkstuck_out_tongue_winking_eyestuck_out_tongue_closed_eyesgrinningkissingstuck_out_tonguesleeping
      worriedfrowninganguishedopen_mouthgrimacingconfusedhushed
      expressionlessunamusedsweat_smilesweatdisappointed_relievedwearypensive
      disappointedconfoundedfearfulcold_sweatperseverecrysob
      joyastonishedscreamtired_faceangryragetriumph
      sleepyyummasksunglassesdizzy_faceimpsmiling_imp
      neutral_faceno_mouthinnocent