@ 2014-01-23T11:35:33Z <?php
require_once 'Services/Soundcloud.php';
/*
* function to get via cUrl
* From lastRSS 0.9.1 by Vojtech Semecky, webmaster @ webdot . cz
* See http://lastrss.webdot.cz/
*/
function curlGet($URL) {
$ch = curl_init();
$timeout = 3;
curl_setopt( $ch , CURLOPT_URL , $URL );
curl_setopt( $ch , CURLOPT_RETURNTRANSFER , 1 );
curl_setopt( $ch , CURLOPT_CONNECTTIMEOUT , $timeout );
/* if you want to force to ipv6, uncomment the following line */
//curl_setopt( $ch , CURLOPT_IPRESOLVE , 'CURLOPT_IPRESOLVE_V6');
$tmp = curl_exec( $ch );
curl_close( $ch );
return $tmp;
}
/*
* function to use cUrl to get the headers of the file
*/
function get_location($url) {
$my_ch = curl_init();
curl_setopt($my_ch, CURLOPT_URL,$url);
curl_setopt($my_ch, CURLOPT_HEADER, true);
curl_setopt($my_ch, CURLOPT_NOBODY, true);
curl_setopt($my_ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($my_ch, CURLOPT_TIMEOUT, 10);
$r = curl_exec($my_ch);
foreach(explode("\n", $r) as $header) {
if(strpos($header, 'Location: ') === 0) {
return trim(substr($header,10));
}
}
return '';
}
function get_size($url) {
$my_ch = curl_init();
curl_setopt($my_ch, CURLOPT_URL,$url);
curl_setopt($my_ch, CURLOPT_HEADER, true);
curl_setopt($my_ch, CURLOPT_NOBODY, true);
curl_setopt($my_ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($my_ch, CURLOPT_TIMEOUT, 10);
$r = curl_exec($my_ch);
foreach(explode("\n", $r) as $header) {
if(strpos($header, 'Content-Length:') === 0) {
return trim(substr($header,16));
}
}
return '';
}
function get_description($url) {
$fullpage = curlGet($url);
$dom = new DOMDocument();
@$dom->loadHTML($fullpage);
$xpath = new DOMXPath($dom);
$tags = $xpath->query('//div[@class="info-description-body"]');
foreach ($tags as $tag) {
$my_description .= (trim($tag->nodeValue));
}
return utf8_decode($my_description);
}
// create a client object with your app credentials
$client = new Services_Soundcloud(
'6813c5d125013568ef986b73e4ba265c', '2eb6f212de6f4963c3873f8afdf517e9');
// a permalink to a track
$track_url = 'http://soundcloud.com/forss/voca-nomen-tuum';
if($_GET['url']){
$track_url = $_GET['url'];
}
$url='http://api.soundcloud.com/resolve.json?url='.$track_url.'&client_id=6813c5d125013568ef986b73e4ba265c';
$headers=get_headers($url,1);
$location=$headers['Location'];
// resolve track URL into track resource
//$track = json_decode($client->get('resolve', array('url' => $track_url)));
/* now that we have the track id, we can get a list of comments, for example
foreach (json_decode($client->get('tracks/' . $track->id . 'comments')) as $c)
print 'Someone said: ' . $c->body . ' at ' . $c->timestamp . "\n";
try {
$track = $soundcloud->download($track->id);
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
exit($e->getMessage());
}
file_put_contents("files/download.mp3",$track);
echo "<a href='files/download.mp3'>download</a>";*/
function modify_url($mod, $url = FALSE){
// If $url wasn't passed in, use the current url
if($url == FALSE){
$scheme = $_SERVER['SERVER_PORT'] == 80 ? 'http' : 'https';
$url = $scheme.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
// Parse the url into pieces
$url_array = parse_url($url);
// The original URL had a query string, modify it.
if(!empty($url_array['query'])){
parse_str($url_array['query'], $query_array);
foreach ($mod as $key => $value) {
if(!empty($query_array[$key])){
$query_array[$key] = $value;
}
}
}
// The original URL didn't have a query string, add it.
else{
$query_array = $mod;
}
return $url_array['scheme'].'://'.$url_array['host'].'/'.$url_array['path'].'?'.http_build_query($query_array);
}
$location = modify_url(array('client_id' => '6813c5d125013568ef986b73e4ba265c'), $location);
$location=str_replace("//tracks","/tracks",$location);
$loginUrl = $location;
$agent= 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$loginUrl);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
$result=curl_exec($ch);
curl_close($ch);
//var_dump($result);
$json = file_get_contents($location);
$obj = json_decode($json, true);
if(!$_GET['d']){
echo $location;
echo "<br/>";
echo $obj['id'];
} else {
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: public');
header('Content-type: application/force-download');
header('Content-Disposition: attachment; filename='.basename($obj["stream"]).";" );
header("Content-Transfer-Encoding: binary");
readfile("$obj['stream']");
}
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 5.4.24 0.006 0.041 12.47 5.4.23 0.006 0.047 12.47 5.4.22 0.005 0.042 12.47 5.4.21 0.007 0.038 12.46 5.4.20 0.008 0.043 12.46 5.4.19 0.007 0.042 12.46 5.4.18 0.008 0.058 12.46 5.4.17 0.009 0.045 12.47 5.4.16 0.011 0.047 12.47 5.4.15 0.011 0.041 12.46 5.4.14 0.009 0.041 12.15 5.4.13 0.007 0.042 12.13 5.4.12 0.009 0.042 12.10 5.4.11 0.005 0.043 12.10 5.4.10 0.009 0.041 12.09 5.4.9 0.005 0.039 12.10 5.4.8 0.006 0.043 12.09 5.4.7 0.004 0.039 12.09 5.4.6 0.007 0.035 12.10 5.4.5 0.007 0.036 12.09 5.4.4 0.007 0.038 12.08 5.4.3 0.004 0.040 12.07 5.4.2 0.006 0.038 12.07 5.4.1 0.007 0.037 12.08 5.4.0 0.007 0.043 11.57 5.3.28 0.008 0.045 12.72 5.3.27 0.009 0.045 12.73 5.3.26 0.004 0.042 12.73 5.3.25 0.009 0.039 12.73 5.3.24 0.010 0.045 12.73 5.3.23 0.005 0.043 12.72 5.3.22 0.004 0.040 12.69 5.3.21 0.006 0.044 12.69 5.3.20 0.005 0.046 12.69 5.3.19 0.008 0.045 12.69 5.3.18 0.007 0.038 12.69 5.3.17 0.007 0.043 12.69 5.3.16 0.008 0.042 12.69 5.3.15 0.005 0.038 12.69 5.3.14 0.004 0.039 12.68 5.3.13 0.008 0.040 12.67 5.3.12 0.006 0.049 12.67 5.3.11 0.004 0.041 12.67 5.3.10 0.005 0.038 12.15 5.3.9 0.005 0.038 12.13 5.3.8 0.005 0.037 12.12 5.3.7 0.009 0.036 12.12 5.3.6 0.009 0.043 12.11 5.3.5 0.005 0.042 12.05 5.3.4 0.007 0.041 12.05 5.3.3 0.005 0.037 12.02 5.3.2 0.004 0.038 11.79 5.3.1 0.005 0.036 11.76 5.3.0 0.006 0.038 11.75
preferences:dark mode live preview
139.94 ms | 1394 KiB | 7 Q