Código PHP:
*/
// register shortcode
add_shortcode('devuelveflv', 'PHP_Devuelve_Flv');
// include PHP file
// Devuelve una cadena entre dos tags
function get_string_between($string, $start, $end){
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}
function PHP_Devuelve_Flv($params=array()) {
extract(shortcode_atts(array(
'urlorigen' => 'default'
), $params));
$ch = curl_init();
// $urlorigen-ejemplo: "http://www.xvideos.com/video259513/black_girl_with_perfect_big_boobs_training"
curl_setopt($ch, CURLOPT_URL, $urlorigen);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$urlflv = get_string_between($output, "flv_url=", "url_bigthumb");
if ($urlflv<>'') {
// The payment is valid
$urlflv=rawurldecode($urlflv);
//echo do_shortcode('[jsplayer src="' . $urlflv . '" width="510" height="400"]');
echo do_shortcode('[jsplayer src="' . $urlflv.'"]');
}
else {
// El video no está disponible
echo '<H2>Sorry, Video not available</H2>';
}
}