. * */ $_POST=$_GET; //debug OCP\JSON::checkAppEnabled('media'); require_once(OC::$APPSROOT . '/apps/media/lib_collection.php'); $user=isset($_POST['user'])?$_POST['user']:''; $pass=isset($_POST['pass'])?$_POST['pass']:''; if(OCP\User::checkPassword($user,$pass)){ OC_Util::setupFS($user); OC_MEDIA_COLLECTION::$uid=$user; }else{ exit; } if(isset($_POST['play']) and $_POST['play']=='true'){ if(!isset($_POST['song'])){ exit; } $song=OC_MEDIA_COLLECTION::getSong($_POST['song']); $ftype=OC_Filesystem::getMimeType( $song['song_path'] ); header('Content-Type:'.$ftype); OCP\Response::disableCaching(); header('Content-Length: '.OC_Filesystem::filesize($song['song_path'])); OC_Filesystem::readfile($song['song_path']); } $artist=isset($_POST['artist'])?'%'.$_POST['artist'].'%':''; $album=isset($_POST['album'])?'%'.$_POST['album'].'%':''; $song=isset($_POST['song'])?$_POST['song']:''; $artist=OC_MEDIA_COLLECTION::getArtistId($artist); $album=OC_MEDIA_COLLECTION::getAlbumId($album,$artist); $songs=OC_MEDIA_COLLECTION::getSongs($artist,$album,$song); $baseUrl=$baseuri; $results=array(); foreach($songs as $song) { $results[] = (Object) array( 'artist' => OC_MEDIA_COLLECTION::getArtistName($song['song_artist']), 'album' => OC_MEDIA_COLLECTION::getAlbumName($song['song_album']), 'track' => $song['song_name'], 'source' => 'ownCloud', 'mimetype' => OC_Filesystem::getMimeType($song['song_path']), 'extension' => substr($song['song_path'],strrpos($song['song_path'],'.')), 'url' => $baseUrl.'?play=true&song='.$song['song_id'], 'bitrate' => round($song['song_id']/$song['song_length'],0), 'duration' => round($song['song_length'],0), 'size' => $song['song_size'], 'score' => (float)1.0 ); } OCP\JSON::encodedPrint($results);