<?php
function retext($text){
$marTViet=array(" ","à","á","ạ","ả","ã","â","ầ","ấ","ậ ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"," è","é","ẹ","ẻ","ẽ","ê","ề","ế","ệ", "ể","ễ","ì","í","ị","ỉ","ĩ","ò","ó"," ọ","ỏ","õ","ô","ồ","ố","ộ","ổ","ỗ" ,"ơ","ờ","ớ","ợ","ở","ỡ","ù","ú","ụ ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"," ","ý","ỵ","ỷ","ỹ","đ","À","Á","Ạ"," ","Ã","Â","Ầ","Ấ","Ậ","Ẩ","Ẫ","Ă"," Ằ","Ắ","Ặ","Ẳ","Ẵ","È","É","Ẹ","Ẻ" ,"Ẽ","Ê","Ề","Ế","Ệ","Ể","Ễ","Ì","Í ","Ị","Ỉ","Ĩ","Ò","Ó","Ọ","Ỏ","Õ","Ô" ,"Ồ","Ố","Ộ","Ổ","Ỗ","Ơ","Ờ","Ớ"," ","Ở","Ỡ","Ù","Ú","Ụ","Ủ","Ũ","Ư"," ","Ứ","Ự","Ử","Ữ","Ỳ","Ý","Ỵ","Ỷ" ,"Ỹ","Đ");
$marKoDau=array("%20","a","a","a","a","a","a","a", "a","a","a","a","a","a","a","a","a","a","e","e","e ","e","e","e","e","e","e","e","e","i","i","i","i", "i","o","o","o","o","o","o","o","o","o","o","o","o ","o","o","o","o","o","u","u","u","u","u","u","u", "u","u","u","u","y","y","y","y","y","d","A","A","A ","A","A","A","A","A","A","A","A","A","A","A","A", "A","A","E","E","E","E","E","E","E","E","E","E","E ","I","I","I","I","I","O","O","O","O","O","O","O", "O","O","O","O","O","O","O","O","O","O","U","U","U ","U","U","U","U","U","U","U","U","Y","Y","Y","Y", "Y","D");
return str_replace($marTViet,$marKoDau,$text);}
function LayCode($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch,CURLOPT_USERAGENT,"Windows-Media-Player/10.00.00.xxxx");
return curl_exec($ch);
}
function get_zing($id){
$mp3=explode('.',$id);$id=$mp3[1];
$get="http://mp3.zing.vn/play/?pid=".$id."||4";
$data=file_get_contents($get);
$link=explode("</source>",$data);$link=explode("<source>",$link[0]);
$link=str_replace('stream','dl',$link[1]);
$name=explode(" ]]></title>",$data);$name=explode("<title><![CDATA[ ",$name[0]);
$name=retext($name[1]).".mp3";
return "$link?filename=$name";
}
function get_id($id){
$mp3=explode('.',$id);$id=$mp3[1];
return $id;
}
$k=retext($_POST["timkiem"]);
$k=str_replace(" ","+",$k);
$source=LayCode("http://mp3.zing.vn/mp3/search/do.1.html?q=$k");
$s1 = explode('leftInfo',$source);
$s1 = $s1[1];
$s1=strpos($source,"leftInfo",$s1);
$s1=strpos($source,"<a href=\"/mp3/nghe-bai-hat/",$s1)+strlen("<a href=\"/mp3/nghe-bai-hat/");
$s2=strpos($source,"\"",$s1);
$Ma=substr($source,$s1,$s2-$s1);
$s1=strpos($source,">",$s2)+1;
$s2=strpos($source,"<",$s1);
$Ten=substr($source,$s1,$s2-$s1);
$s1=strpos($source,"<a",$s2);
$s1=strpos($source,"\">",$s1)+2;
$s2=strpos($source,"<",$s1);
$CaSi=substr($source,$s1,$s2-$s1);
$s1=strpos($source,"typeMusic",$s2);
$s1=strpos($source,"</span>",$s1)+strlen("</span>");
$s2=strpos($source,"<",$s1);
$ChatLuong=substr($source,$s1,$s2-$s1);
$luotnghe=explode('Lượt nghe: ',$ChatLuong);
$s1=$s2;
?>
<html><head>
<title>Nghe nhạc Online</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
body {
font: .8em Verdana, Arial, Sans-Serif;
text-align: center;
color: #333;
background-color: #fff;
margin-top: 5em;
}
h1 {
font-size: 2em;
padding: 0;
margin: 0;
}
h4 {
font-size: 1em;
font-weight: bold;
}
form {
width: 38em;
background-color: #eee;
border: 1px solid #ccc;
margin-left: auto;
margin-right: auto;
padding: 1em;
}
fieldset {
border: 0;
margin: 0;
padding: 0;
}
a {
color: #09c;
text-decoration: none;
font-weight: bold;
}
a:visited {
color: #07a;
}
a:hover {
color: #c30;
}
.error, .success {
font-size: 1.2em;
font-weight: bold;
}
.error {
color: #ff0000;
}
.success {
color: #000;
}
.box {
padding: 3px;
color: #000000;
font-size: 12px;
font-family: Verdana;
font-weight: bold;
border: 2px dotted red;
</style>
</head><body>
<form id="form1" name="form1" method="post" action="">
<fieldset>
<label for="endipi000">Nhập tên ca khúc <b>không dấu</b>.<br> Nên nhập thêm tên ca sỹ để kết quả được chính xác hơn<br> Ví dụ: <b>Muốn Nghe bài hát Lạnh Của khổng tú quỳnh Bạn Hãy điền là : lanh khong tu quynh và ấn Play</b></label>
<label>
<input name="timkiem" id="endipi000" style="width: 80%;" type="text">
</label>
<label>
<input name="chay" id="chay" value="Play" type="submit">
</label>
</fieldset>
</form>
<?php
if($_POST){
echo '<form>
<marquee width="300">Bạn đang nghe ca khúc <b><font color="red">'.$Ten.'</font></b> do ca sỹ <b><font color="red">'.$CaSi.'</font></b> trình bày. Chúc bạn nghe nhạc vui vẻ!</marquee><br>
<embed src="http://static.mp3.zing.vn/skins/gentle/flash/mp3player.swf?xmlURL=http://mp3.zing.vn/play/?pid='.get_id($Ma).'||4&songID=0&_mp3=&autoplay=tr ue&wmode=transparent" quality="high" wmode="transparent" type="application/x-shockwave-flash" width="430" height="34">
<a href="'.get_zing($Ma).'">DownLoad</a>
</form>';
}
?>
</body></html>