0 ; each of these integers indicates that the corresponding API version is supported by this instance //0 is a reserved value used to indicate that the requesting (CreRo or YP server) client cannot access this API, either that it is host-based blacklisted by the instance //or that the instance has an host-based whiteslist and that the requesting server is not listed in it $version=0; //manage all the black/whitelist stuff here //TODO //here we got all the caching stuff $cache=true; if (!file_exists('./crero-yp-api-cache')){ mkdir('./crero-yp-api-cache'); } else if (!is_dir('./crero-yp-api-cache')){ $cache=false; } if (!file_exists('./crero-yp-api-cache/.htaccess')||filectime('./crero-yp-api-cache/.htaccess')0) echo '1'; else echo '0'; break; case 'styles': // echo implode(" ", $labelgenres); //returns a list of styles for the label separated by spaces break; case 'streaming_albums': // if (false!==readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$serverapi, true, $YP_APIMisconfiguredDateOnHostingToleranceWindow)){ echo readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$serverapi, true); break; } $ret=file_get_contents($serverapi.'?listalbums='.urlencode(($_GET[$_GET['a']]))); if ($ret!==false){ $ret=html_entity_decode($ret); writeCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$serverapi, true, $ret); echo $ret; } break; case 'download_albums': // if (false!==readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$clewnapiurl, true, $YP_APIMisconfiguredDateOnHostingToleranceWindow)){ echo readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$clewnapiurl, true); break; } $ret = file_get_contents($clewnapiurl.'?listalbums='.urlencode(($_GET[$_GET['a']]))); if ($ret!==false){ $ret=html_entity_decode($ret); writeCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$clewnapiurl, true, $ret); echo $ret; } break; case 'list_artists': // echo file_get_contents('./d/artists.txt'); //return either a list of artists of the label, separated by "\n", or empty if likely to be a radio-only station autobuilding its radiobase with a huge catalog and not declaring specific artists break; case 'album_streaming': // if (false!==readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$serverapi, true, $YP_APIMisconfiguredDateOnHostingToleranceWindow)){ echo readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$serverapi, true); break; } $ret=file_get_contents($serverapi.'?gettracks='.urlencode(strval($_GET[$_GET['a']]))); if ($ret!==false){ writeCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$serverapi, true, $ret); echo $ret; } break; case 'album_download': // if (false!==readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$clewnapiurl, true, $YP_APIMisconfiguredDateOnHostingToleranceWindow)){ echo readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$clewnapiurl, true); break; } $ret = file_get_contents($clewnapiurl.'?gettracks='.urlencode(strval($_GET[$_GET['a']]))); if ($ret!==false){ writeCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$clewnapiurl, true, $ret); echo $ret; } break; case 'title_streaming': // if (false!==readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$serverapi, true, $YP_APIMisconfiguredDateOnHostingToleranceWindow)){ echo readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$serverapi, true); break; } $ret=file_get_contents($serverapi.'?gettitle='.urlencode(strval($_GET[$_GET['a']]))); if ($ret!==false){ $ret=html_entity_decode($ret); writeCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$serverapi, true, $ret); echo $ret; } break; case 'title_download': // if (false!==readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$clewnapiurl, true, $YP_APIMisconfiguredDateOnHostingToleranceWindow)){ echo readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$clewnapiurl, true); break; } $ret = file_get_contents($clewnapiurl.'?gettitle='.urlencode(strval($_GET[$_GET['a']]))); if ($ret!==false){ $ret=html_entity_decode($ret); writeCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$clewnapiurl, true, $ret); echo $ret; } break; case 'track_artist_streaming': // if (false!==readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$serverapi, true, $YP_APIMisconfiguredDateOnHostingToleranceWindow)){ echo readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$serverapi, true); break; } $ret=file_get_contents($serverapi.'?getartist='.urlencode(strval($_GET[$_GET['a']]))); if ($ret!==false){ $ret=html_entity_decode($ret); writeCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$serverapi, true, $ret); echo $ret; } break; case 'track_artist_download': // if (false!==readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$clewnapiurl, true, $YP_APIMisconfiguredDateOnHostingToleranceWindow)){ echo readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$clewnapiurl, true); break; } $ret = file_get_contents($clewnapiurl.'?getartist='.urlencode(strval($_GET[$_GET['a']]))); if ($ret!==false){ $ret=html_entity_decode($ret); writeCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$clewnapiurl, true, $ret); echo $ret; } break; case 'artist_info': if (false!==file_get_contents('./d/highlight-artist-list.txt')){ echo file_get_contents('./d/highlight-artist-list.txt'); //returns additionnal info for some artists of the label //first line ("\n" for each newline) is the artist name //second line is styles separated by spaces //third line is info, typically years active //fouth line is blank and reserved for future usage //fifth line is 2nd artist name //sixth line is 2nd artist styles //...and so on } break; case 'list_all_artists': if (false!==readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$clewnapiurl, true, $YP_APIMisconfiguredDateOnHostingToleranceWindow)){ echo readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$clewnapiurl, true); break; } $ret = file_get_contents($clewnapiurl.'?listartists=1'); if ($ret!==false){ $ret=html_entity_decode($ret); writeCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$clewnapiurl, true, $ret); echo $ret; } break; //Here should go the API V2 commands //(...) //Then the API V3 commands //(...) //And so on case 'list_albums_with_covers': $list_albums = ''; //Step 1 get streaming albums if (false!==readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$serverapi, true, $YP_APIMisconfiguredDateOnHostingToleranceWindow)){ $list_albums = readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$serverapi, true); } else { $ret=file_get_contents($serverapi.'?listalbums='.urlencode(($_GET[$_GET['a']]))); if ($ret!==false){ $ret=html_entity_decode($ret); writeCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$serverapi, true, $ret); $list_albums = $ret; } } $arr_alb_str = explode("\n", $list_albums); $arr_alb_str = array_diff($arr_alb_str, Array('')); $list_albums = ''; //Step 2 get d/l albums if (false!==readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$clewnapiurl, true, $YP_APIMisconfiguredDateOnHostingToleranceWindow)){ $list_albums = readCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$clewnapiurl, true); } else { $ret=file_get_contents($clewnapiurl.'?listalbums='.urlencode(($_GET[$_GET['a']]))); if ($ret!==false){ $ret=html_entity_decode($ret); writeCache($version, $_GET['a'], strval($_GET[$_GET['a']]),$clewnapiurl, true, $ret); $list_albums = $ret; } } $arr_alb_dl = explode ("\n", $list_albums); $arr_alb_dl = array_diff($arr_alb_dl, Array('')); $arr_alb = array_merge($arr_alb_str, $arr_alb_dl); $coversdat = file_get_contents('./d/covers.txt'); if ($coverdat === false){$coverdat=implode("\n\n", $arr_alb).'\n';} $arr_covers = explode ("\n", $coversdat); $albcov = Array(); for ($i=0;$i