if (isset($params["callback"])) { $originalJsonCallback = $params["callback"]; $params["callback"] = "63kfn61Ikx90Nw"; //just a unique random string } $fullUrl = $apiUrl . http_build_query($params); if ($config["isNoCache"]) { removeCacheForUrl($fullUrl); } $result = file_get_contents_with_cache($fullUrl, true); if (isset($originalJsonCallback)) { $resultJson = json_decode(preg_replace('/.+?({.+}).+/', "\$1", $result), true); } else { $resultJson = json_decode($result, true); } //if response has errors or has no response if (!empty($resultJson["error"]) || empty($resultJson["response"])) { removeCacheForUrl($fullUrl); } else { logSuccessQuery($_GET["q"]); } if (isset($originalJsonCallback)) { //replacing callback string back $result = str_replace($params["callback"], $originalJsonCallback, $result); } if (isset($_REQUEST["noCount"])) { $result = preg_replace('/\\{\\"response\\"\\:\\[([0-9]{1,20}),\\{/', '{"response":[{', $result); $result = preg_replace('/\\{\\"response\\"\\:\\[([0-9]{1,20})\\]\\}/', '{"response":[]}', $result); } //hehe https://datmusic.xyz/stream/YGexC:AEYtr die($result);
/** * Download file with given name to given path * @param $url url to download * @param $path output filepath * @return true if success, else you know what */ function downloadFile($url, $path) { $fp = fopen($path, 'wb'); $ch = curl_init($url); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_exec($ch); fclose($fp); if (curl_errno($ch) > 0) { global $audioGetUrl; removeCacheForUrl($audioGetUrl); notFound(); return false; } curl_close($ch); fclose($fp); return true; }