Get XML

<?php

header("Content-Type: application/xml; charset=utf-8");

$string = $_GET['L'];

$mode=$_GET['M'];

function grab_link($url,$type)

{

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,$url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_HEADER, $type);

$result = curl_exec($ch);

curl_close($ch);

return $result;

}

if(isset($string))

$url= grab_link('http://www.nhaccuatui.com/l/'.$string,1);

if(isset($mode))

$url= grab_link('http://www.nhaccuatui.com/m/'.$mode,1);

preg_match("#file=(.*?)Cache-Control: private#is",$url,$xml);

$xml = trim ($xml[1]);

$data = grab_link($xml,0);

$song = explode('<track>',$data);

$xml = '<playlist version="1" xmlns="http://xspf.org/ns/0/"><trackList>';

for($i=0;$i<count($song);$i++)

{

if(preg_match('#<title>(.*?)<\/title>(.*?)<creator>(.*?)<\/creator>(.*?)<location>(.*?)<\/location>#is',$song[$i],$name))

$xml .= '<track><title>'.htmlspecialchars($name[1]).'</title>'.

'<creator>'.htmlspecialchars($name[3]).'</creator>'.

'<location>'.$name[5].'</location>'.

'<info>'.$name[5].'</info>'.

'<image></image></track>';

}

$xml .='</trackList></playlist>';

echo $xml;

?>

Bạn đang đọc truyện trên: AzTruyen.Top

Tags: