<?php
/**
 * Project:        M.VuiZ.Net
 * Author:         nampt.me <admin@vuiz.net>
 * Copyright:      © 2025 vuiz.net All rights reserved.
 */
error_reporting(0);
$link = isset($_POST['link']) ? htmlspecialchars(rawurldecode($_POST['link'])) : '';
$return = array();
if ($link && preg_match('#https?://#is',$link)){
	$api = getcontent('https://www.dlmixcloud.com/ajax.php', 'url='.$link);
	if(strlen($api) > 0){
		$api =json_decode($api,true);
		$thumb = htmlspecialchars($api['thumbnail']);
		$title = htmlspecialchars($api['title']);
		$author = htmlspecialchars($api['uploader']);
		$down = htmlspecialchars($api['url']);
		$return['success'] = '
		<link rel="stylesheet" type="text/css" href="/template/audioplayerengine/initaudioplayer-1.css">
		<div class="menu">
			<div style="margin:12px auto;">
				<div id="amazingaudioplayer-1" style="display:block;position:relative;width:100%;max-width:300px;height:300px;margin:0px auto 0px;">
					<ul class="amazingaudioplayer-audios" style="display:none;">
						<li data-artist="'.$author.'" data-title="'.$title.'" data-album="" data-info="" data-image="'.$thumb.'" data-duration="0">
							<div class="amazingaudioplayer-source" data-src="'.$down.'" data-type="audio/mpeg" />
						</li>
					</ul>
				</div>
			</div>
			<div style="text-align: center;">
				<a rel="noreferrer noopener" target="_blank" href="'.$down.'"><button type="button" class="btn btn-success"><i class="fa fa-cloud-download"></i> Download Now</button></a>
			</div>

		</div>

		<script src="/template/audioplayerengine/amazingaudioplayer.js"></script>
		<script src="/template/audioplayerengine/initaudioplayer-1.js"></script>';
	} else { 
		$return['error'] = 'Có lỗi xảy ra, vui lòng thử lại sau!'; 
	}
} else { 
	$return['error'] = 'Có lỗi xảy ra, vui lòng thử lại sau!'; 
}

echo json_encode($return, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE);

function getcontent($url,$post) {
	$ch = @curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	$head[] = "Connection: keep-alive";
	$head[] = "Keep-Alive: 300";
	$head[] = "Accept-Language: en-us,en;q=0.5";
	$head[] = "origin: https://www.dlmixcloud.com";
	$head[] = "referer: https://www.dlmixcloud.com";
	$head[] = "content-type: application/x-www-form-urlencoded; charset=UTF-8";
	$head[] = "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36";
	$head[] = "x-requested-with: XMLHttpRequest";
	curl_setopt($ch, CURLOPT_HTTPHEADER, $head);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($ch, CURLOPT_TIMEOUT, 60);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
	$nd = curl_exec($ch);
	curl_close($ch);
	return $nd;

}