Add thumbnails to the ucenter home video

Source: Internet
Author: User
Tags preg

Note: modify and update at http://www.discuz.net/thread-1465174-1-1.html#, and add 56.com. Can download the latest version, http://pan.baidu.com/netdisk/singlepublic here? FID = 156737_3291021664

Plugin description

Function:

Displays videos shared from video sites such as Youku, Tudou, ku6, mofile, and 56 with thumbnails.

 

Environment Support:

The space must support the file_get_contents function. This function is valid when allow_url_fopen is enabled by default.

How to enable allow_url_fopen:

Set allow_url_fopen in the PHP. ini file as follows: (most spaces are enabled)

Allow_url_fopen = on

 

 

Installation instructions

1. files to be modified

Source/cp_mirror.php

Source/script_common.js (this file needs to be modified to support potato videos)

Template/your own style directory/space_feed_li.htm (by default, this file is under the default style directory)

Template/your own style directory/space_javas_li.htm (by default, this file is in the default style directory, that is, the default folder)

2. Added files

Image/movie_icon.png (the playback button displayed on the video thumbnail)

Image/noimg.gif (the display icon when no video thumbnail is displayed)

3. Installation Steps

3.1 open cp_cmd.php (408 rows by default)

If (preg_match ("/(youku.com | Youtube.com | 5show.com | ku6.com | sohu.com | mofile.com | sina.com.cn) $/I", $ parselink ['host'], $ hosts )){

$ Flashvar = getflash ($ link, $ hosts [1]);

If (! Empty ($ flashvar )){

$ Arr ['title _ template'] = cplang ('share _ video ');

$ Type = 'video ';

$ Arr ['body _ data'] ['flashvar'] = $ flashvar;

$ Arr ['body _ data'] ['host'] = $ hosts [1];

}

}

Replace the above Code with the following code

If (preg_match ("/(youku.com | Youtube.com | 56.com | ku6.com | sohu.com | mofile.com | sina.com.cn | tudou.com) $/I", $ parselink ['host'], $ hosts )) {

$ Flashvar = getflash ($ link, $ hosts [1]);

If (! Empty ($ flashvar )){

$ Flashimg = getflashimg ($ flashvar, $ hosts [1]);

$ Arr ['title _ template'] = cplang ('share _ video ');

$ Type = 'video ';

$ Arr ['body _ data'] ['flashvar'] = $ flashvar;

$ Arr ['body _ data'] ['host'] = $ hosts [1];

If (! Empty ($ flashimg )){

$ Arr ['image'] = $ flashimg;

}

}

}

3.2 search for function getflash ($ link, $ host) (the default value is 490 rows)

Function getflash ($ link, $ host ){

$ Return = '';

If ('youku. com' = $ host ){

// Http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html

Preg_match_all ("/ID \ _ (\ W +) [=.]/", $ link, $ matches );

If (! Empty ($ matches [1] [0]) {

$ Return = $ matches [1] [0];

}

} Elseif ('ku6. com' = $ host ){

// Http://v.ku6.com/show/bjbJKPEex097wVtC.html

Preg_match_all ("// ([\ W \-] +) \. html/", $ link, $ matches );

If (1> preg_match ("/\/index _ ([\ W \-] +) \. html/", $ link )&&! Empty ($ matches [1] [0]) {

$ Return = $ matches [1] [0];

}

} Elseif ('youtube. com' = $ host ){

// Http://tw.youtube.com/watch? V = hwhhrcrdan0

Preg_match_all ("/V \ = ([\ W \-] +)/", $ link, $ matches );

If (! Empty ($ matches [1] [0]) {

$ Return = $ matches [1] [0];

}

} Elseif ('5show. com' = $ host ){

// Http://www.5show.com/show/show/160944.shtml

Preg_match_all ("// (\ D +) \. shtml/", $ link, $ matches );

If (! Empty ($ matches [1] [0]) {

$ Return = $ matches [1] [0];

}

} Elseif ('mofile. com' = $ host ){

// Http:// TV .mofile.com/PPU3NTYW/

Preg_match_all ("// \/(\ W +) \/* $/", $ link, $ matches );

If (! Empty ($ matches [1] [0]) {

$ Return = $ matches [1] [0];

}

} Elseif ('sina .com.cn '= $ host ){

// Http://you.video.sina.com.cn/ B /16776316-1338697621.html

Preg_match_all ("// (\ D +)-(\ D +) \. html/", $ link, $ matches );

If (! Empty ($ matches [1] [0]) {

$ Return = $ matches [1] [0];

}

} Elseif ('sohu. com' = $ host ){

// Http://v.blog.sohu.com/u/vw/1785928

Preg_match_all ("// \/(\ D +) \/* $/", $ link, $ matches );

If (! Empty ($ matches [1] [0]) {

$ Return = $ matches [1] [0];

}

}

Return $ return;

}

 

Replace the above Code with the following

 

/**

* Match the video sequence number.

*

* @ Param string $ link video link

* @ Param string $ host domain name

* @ Return string $ flvid the video sequence number.

*/

Function getflash ($ link, $ host ){

$ Flvid = $ preg = '';

If ('youku. com' = $ host ){

// Http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html

$ Preg = '/ID \ _ (\ W +) [=.]/';

} Elseif ('ku6. com' = $ host ){

// Http://v.ku6.com/show/bjbJKPEex097wVtC.html

$ Preg = '/show \/(. + ?) \. Html /';

} Elseif ('youtube. com' = $ host ){

// Http://tw.youtube.com/watch? V = hwhhrcrdan0

$ Preg = '/V \ = ([\ W \-] + )/';

} Elseif ('sina .com.cn '= $ host ){

// Http://video.sina.com.cn/v/ B /16776316-1338697621.html

$ Preg = '// (\ D +)-(\ D +) \. html /';

} Elseif ('sohu. com' = $ host ){

// Http://v.blog.sohu.com/u/vw/1785928

$ Preg = '// (\ D +) \/* $ /';

} Elseif ('tudou. com' = $ host ){

// Http://www.tudou.com/programs/view/oOrUqgezkOc/

$ Preg = '// ([\ W \-] +) \/* $ /';

} Elseif ('56. com' = $ host ){

// Http://www.56.com/w86/play_album-aid-9869018_vid-Njc4MTk1MTY.html

$ Preg = (strpos ($ link, 'play _ album ') = false )? '/HTTP: \/www.56.com \/\ s + \/([^ \/]+).html/I ':

'/HTTP: \/www.56.com \/\ s + \/play_album-aid-(\ D +) _ vid-(. + ?). Html/I ';

}

 

// Match the video sequence number

If ($ preg & preg_match ($ preg, $ link, $ matches ))

$ Flvid = $ matches [1];

Return $ flvid;

}

 

/**

* Get the video image address

*

* @ Param string $ flashvar video sequence number

* @ Param string $ host domain name address

* @ Return string $ imgurl video image address

*/

Function getflashimg ($ flashvar, $ host ){

// Image address, video address

$ Imgurl = $ url = '';

 

If ('tudou. com' = $ host ){

// Http://www.tudou.com/programs/view/oOrUqgezkOc/

$ Url = 'HTTP: // www.tudou.com/programs/view/'. $ flashvar;

$ Preg_img = "/PIC \ s \ = \ s '(. + ?) '\ S, lpic /";

} Elseif ('youku. com' = $ host ){

// 'HTTP: // v.youku.com/v_show/id_xmzkxnduzmdu2.html'

$ Url = 'HTTP: // v.youku.com/player/getplaylist/videoids/'.w.flashvar;

$ Preg_img = '/"logo": "(. + ?) "/';

} Elseif ('sina .com.cn '= $ host ){

// Http://video.sina.com.cn/v/ B /16776316-1338697621.html

$ Url = 'HTTP: // interface.video.sina.com.cn/interface/common/getvideoimage.php? Vid = '. $ flashvar;

$ Preg_img = '/imgurl \ = (. + ?) /U ';

} Elseif ('ku6. com' = $ host ){

// Http://v.ku6.com/show/dcTU2QX6sb5QXz-C_30CDA...html

$ Url = 'HTTP: // vo.ku6.com/fetchvideo4player/1/'.w.flashvar.'.html ';

$ Preg_img = '/\ "picpath \": \ "(. + ?) \ "/I ';

} Elseif ('sohu. com' = $ host ){

// Http://my. TV .sohu.com/u/vw/13706596

$ Url = 'HTTP: // v.blog.sohu.com/videinfo.jhtml? M = view & id = '. $ flashvar.' & outtype = 3 ';

$ Preg_img = '/"cuscoverurl": "(. + ?) "/';

} Elseif ('56. com' = $ host ){

// Http://www.56.com/w86/play_album-aid-9869018_vid-Njc4MTk1MTY.html

$ Url = 'HTTP: // vxml.56.com/json/'.str_replace ('v _ ', '', $ flashvar ).'/? Src = out ';

$ Preg_img = '/\ "IMG \": \ "(. + ?) \ "/I ';

}

 

// Obtain the image address

If ($ URL ){

$ Content = file_get_contents ($ URL );

 

If ($ content & preg_match ($ preg_img, $ content, $ matches ))

{

$ Imgurl = trim ($ matches [1]);

 

// Remove the backslash

If ('youku. com' = $ host)

$ Imgurl = stripslashes ($ imgurl );

Elseif ('ku6. com' = $ host)

$ Imgurl = str_replace (Array ('\ u003a', '\ u002e'), array (':', '.'), $ imgurl );

}

}

Return $ imgurl;

}

3.3

Open script_common.js (the default value is 342 rows)

In 'mofile. com': 'http: // TV .mofile.com/cn/xplayer.swf? V = flashvar ', add the following code below (potato, 56 supported)

'Tudou. com': 'http: // www.tudou.com/v/flashvar ',

'56. com': 'http: // player.56.com/v_flashvar.swf ',

3.4

Find hideobj. style. cursor = 'pointer ';

Add the following code below:

// Add

If ('music '! = Host & 'flash '! = Host ){

$ ('Icon _ id _ '+ upload ID). style. Display = 'none ';

$ ('Media _ id _ '+ upload ID). style. Display = 'none ';

}

// End

3.5

Find obj. style. Display = ''; (there are two places, under the first place)

Add the code below:

// Add

If ('music '! = Host & 'flash '! = Host ){

$ ('Icon _ id _ '+ upload ID). style. Display = '';

$ ('Media _ id _ '+ upload ID). style. Display = '';

}

// End

3.6

Open space_feed_li.htm

Search:

<! -- {If $ value ['image _ 1']} -->

To:

<! -- {If $ value ['image _ 1'] & empty ($ value ['body _ data'] ['flashvar '])} -->

Search: (IN 47 rows)

<Div class = "Media">

</Div>

To:

<Div class = "Media">

<Div class = "movie_app">

$ value [image_1] <! -- {Else} -->/image/noimg.gif <! -- {/If} --> "alt =" click to play "onclick =" javascript: showflash ('{$ value ['body _ data'] ['host']}', '{$ value ['body _ data'] ['flashvar']}', this, '{$ value ['feedid']}'); "style =" cursor: pointer; "/>

</Div>

</Div>

3.7

Open space_pai_li.htm

Search: (near 15 rows by default)

<! -- {If $ value ['image']} -->

To:

<! -- {If $ value ['image'] & 'video '! = $ Value ['type']} -->

Search: (near 22 rows by default)

<! -- {If 'video' = $ value ['type']} -->

<Div class = "Media">

</Div>

To:

<! -- {If 'video' = $ value ['type']} -->

<Div class = "Media">

<Div class = "movie_app">

$ value [Image] <! -- {Else} -->/image/noimg.gif <! -- {/If} --> "alt =" click to play "onclick =" javascript: showflash ('{$ value ['body _ data'] ['host']}', '{$ value ['body _ data'] ['flashvar']}', this, '{$ value ['sid']} '); "style =" cursor: pointer; "/>

</Div>

</Div>

3.8

Open default/style.css (this file needs to be modified when the play button is displayed on the thumbnail)

Add the following code at the end of the file:

/*************************************** * ****** Vedio_img ***/

. Movie_none {display: none; position: relative}

. Movie_app. movie_pic {width: 128px; Height: 96px ;}

* Html. movie_pic {width: expression (this. width> 120? 120: True); display: block}

 

. Media {display: block; position: relative; ZOOM: 1}

. Movie_app {}

. Movie_app IMG {margin-left: 5px; margin-top: 5px; max-width: 130px; max-Height: 96px ;}

* Html. movie_app IMG {width: expression (this. width> 200 & this. width/This. Height> 2? 200: True); Height: expression (this. Height> 100 & this. width/This. height <2? 200: True); display: block}

 

. Movie_app. movie_icon {

Width: 21px; Height: 21px; Background: None transparent scroll repeat 0% 0%; filter: alpha (opacity = 70); left: 55px; border-top-style: none! Important; bottom: 35px; border-right-style: none! Important; border-left-style: none! Important; position: absolute; border-bottom-style: none! Important; opacity: 0.9

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.