The project is used for temporary writing. To be perfected:
Copy Code code as follows:
/*
* According to the user submitted (swf/html) address, access to Youku, potato SWF playback address
* */
Private Function _getswf ($url = ' ") {
if (Isset ($url) &&!empty ($url)) {
Preg_match_all ('/http:\/\/. *?) \. (.*?)? \.com\/(. *)/', $url, $types);
}else{
return false;
}
$type = $types [2][0];
$domain = $types [1][0];
$isswf = Strpos ($types [3][0], ' v.swf ') = = False? False:true;
$method = substr ($types [3][0],0,1);
Switch ($type) {
Case ' Youku ':
if ($domain = = ' Player ') {
$swf = $url;
}else if ($domain = = ' V ') {
Preg_match_all ('/http:\/\/v\.youku\.com\/v_show\/id_ (. *)? \.html/', $url, $url _array);
$swf = ' Http://player.youku.com/player.php/sid/'. Str_replace ('/', ', $url _array[1][0]). ' /v.swf ';
}else{
$swf = $url;
}
Break
Case ' Tudou ':
if ($isswf) {
$swf = $url;
}else{
$method = $method = = ' P '? ' V ': $method;
Preg_match_all ('/http:\/\/www.tudou\.com\/(. *)? \/(. *)?/', $url, $url _array);
$str _arr = explode ('/', $url _array[1][0]);
$count = count ($str _arr);
if ($count = = 1) {
$id = Explode ('. ', $url _array[2][0]) [0];
}else if ($count = = 2) {
$id = $str _arr[1];
}else if ($count = = 3) {
$id = $str _arr[2];
}
$swf = ' http://www.tudou.com/'. $method. ' /'. $id. ' /v.swf ';
}
Break
Default:
$swf = $url;
Break
}
return $swf;
}