diff --git a/htdocs/ajax.loadControls.php b/htdocs/ajax.loadControls.php
deleted file mode 100755
index 74243910e..000000000
--- a/htdocs/ajax.loadControls.php
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
-
'>
-
-
-
-
'.$lang['globalOff'].'';
- } elseif ($playerStatus['single'] == "1") {
- print '
'.$lang['globalTrack'].'';
- } else {
- print '
'.$lang['globalList'].'';
- }
- if (array_key_exists('state', $playerStatus)) {
- print '
';
- }
-?>
-
-
-
-
-*/
-?>
-
-
";
-} else {
- print "
";
-}
-?>
-
-
'>
-
'>
-
-
\ No newline at end of file
diff --git a/htdocs/ajax.loadCover.php b/htdocs/ajax.loadCover.php
deleted file mode 100755
index 738714dad..000000000
--- a/htdocs/ajax.loadCover.php
+++ /dev/null
@@ -1,52 +0,0 @@
-';
- print "
";
- print '';
-} elseif (file_exists($Audio_Folders_Path.'/'.$Latest_Folder_Played.'/spotify.txt')) {
- print '
';
- print " ";
- print ' ';
-} else {
- print '
';
- print " ";
- print ' ';
-}
-?>
diff --git a/htdocs/ajax.loadPlaylist.php b/htdocs/ajax.loadPlaylist.php
deleted file mode 100755
index 656ac35f6..000000000
--- a/htdocs/ajax.loadPlaylist.php
+++ /dev/null
@@ -1,89 +0,0 @@
-';
-$i=0;
-foreach($plFile[1] AS $file) {
- print '
-
-
-
-
- ';
- if(trim($plTitle['1'][$i]) != "") {
- print '
- '.$plTitle['1'][$i].' ';
- } else {
- print '
- '.basename($file).' ';
- }
- print '
- '.str_replace(";", " and ", $plArtist['1'][$i]).' ';
- if (empty($plAlbum['1'][$i]) != true) {
- print "".$plAlbum['1'][$i];
- if (empty($plDate['1'][$i]) != true) {
- print " (".$plDate['1'][$i].")";
- }
- print " ";
- }
- print '
-
- ';
- // Livestreams and podcasts have no time length, check to suppress badge
- if ( $plTime['1'][$i] > 0 && $plTime['1'][$i] < 3600 ) {
- print ''.date("i:s",$plTime['1'][$i]).' ';
- } elseif ( $plTime['1'][$i] > 0 ) {
- print ''.gmdate("H:i:s",$plTime['1'][$i]).' ';
- }
- print'
-
-
- ';
- $i++;
-}
-print '';
-/*
-$i=0;
-foreach($plFile[1] AS $file) {
- print '
-
-
-
-
';
- if(trim($plTitle['1'][$i]) != "") {
- print '
- '.$plTitle['1'][$i].' ';
- } else {
- print '
- '.basename($file).' ';
- }
- print '
- '.str_replace(";", " and ", $plArtist['1'][$i]).' ';
- if (empty($plAlbum['1'][$i]) != true) {
- print "".$plAlbum['1'][$i];
- if (empty($plDate['1'][$i]) != true) {
- print " (".$plDate['1'][$i].")";
- }
- print " ";
- }
- print '
-
-
';
- // Livestreams and podcasts have no time length, check to suppress badge
- if ( $plTime['1'][$i] > 0 && $plTime['1'][$i] < 3600 ) {
- print ''.date("i:s",$plTime['1'][$i]).' ';
- } elseif ( $plTime['1'][$i] > 0 ) {
- print ''.gmdate("H:i:s",$plTime['1'][$i]).' ';
- }
- print'
-
-
-
- ';
- $i++;
-}
-*/
-?>
\ No newline at end of file
diff --git a/htdocs/ajax.loadTime.php b/htdocs/ajax.loadTime.php
deleted file mode 100755
index e72ff78ae..000000000
--- a/htdocs/ajax.loadTime.php
+++ /dev/null
@@ -1,18 +0,0 @@
-';
-if ( $plTime['1'][$playerStatus['pos']] < 3600 ) {
- print date("i:s",$playerStatus['elapsed']);
- // Livestream and podcasts have no time length, show only elapsed time
- if ( $plTime['1'][$playerStatus['pos']] > 0 ) {
- print ' / '.date("i:s",$plTime['1'][$playerStatus['pos']]);
- }
-} else {
- print date("H:i:s",$playerStatus['elapsed']);
- // Livestream and podcasts have no time length, show only elapsed time
- if ( $plTime['1'][$playerStatus['pos']] > 0 ) {
- print ' / '.gmdate("H:i:s",$plTime['1'][$playerStatus['pos']]);
- }
-}
-print '';
-?>
\ No newline at end of file
diff --git a/htdocs/ajax.loadVolume.php b/htdocs/ajax.loadVolume.php
deleted file mode 100755
index b5ace5d26..000000000
--- a/htdocs/ajax.loadVolume.php
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
diff --git a/htdocs/api/common.php b/htdocs/api/common.php
new file mode 100644
index 000000000..7562c58b2
--- /dev/null
+++ b/htdocs/api/common.php
@@ -0,0 +1,29 @@
+
diff --git a/htdocs/api/cover.php b/htdocs/api/cover.php
new file mode 100644
index 000000000..c9bdbd113
--- /dev/null
+++ b/htdocs/api/cover.php
@@ -0,0 +1,30 @@
+
diff --git a/htdocs/api/latest.php b/htdocs/api/latest.php
new file mode 100644
index 000000000..1f949fa50
--- /dev/null
+++ b/htdocs/api/latest.php
@@ -0,0 +1,13 @@
+
diff --git a/htdocs/api/player.php b/htdocs/api/player.php
new file mode 100644
index 000000000..407822cce
--- /dev/null
+++ b/htdocs/api/player.php
@@ -0,0 +1,81 @@
+
diff --git a/htdocs/api/playlist.php b/htdocs/api/playlist.php
new file mode 100644
index 000000000..d39155e30
--- /dev/null
+++ b/htdocs/api/playlist.php
@@ -0,0 +1,69 @@
+= 2) {
+ $key = substr(trim($exploded[0]), 0, -1);
+ $value = $exploded[1];
+ if ($key === 'file') {
+ // next track
+ if ($index != -1) {
+ $result[$index] = $currentEntry;
+ }
+ $index++;
+ $currentEntry = array();
+ }
+ $currentEntry[$key] = $value;
+ }
+ }
+ header('Content-Type: application/json');
+ echo json_encode($result);
+}
+
+function handlePut() {
+ $body = file_get_contents('php://input');
+ $json = json_decode(trim($body), TRUE);
+ if (validateRequest($json)) {
+ $playlist = $json['playlist'];
+ if($json['recursive'] === "true") {
+ execScript("rfid_trigger_play.sh -d={$playlist} -v=\"recursive\"");
+ } else {
+ execScript("rfid_trigger_play.sh -d={$playlist}");
+ }
+ }
+}
+
+function validateRequest($json) {
+ if ($json['playlist'] == null) {
+ http_response_code(400);
+ echo "playlist attribute missing";
+ return false;
+ } else if ($json['recursive'] == null) {
+ http_response_code(400);
+ echo "recursive attribute missing";
+ return false;
+ }
+ return true;
+}
+
+?>
diff --git a/htdocs/api/playlist/resume.php b/htdocs/api/playlist/resume.php
new file mode 100644
index 000000000..d5c0b2a10
--- /dev/null
+++ b/htdocs/api/playlist/resume.php
@@ -0,0 +1,37 @@
+
diff --git a/htdocs/api/playlist/shuffle.php b/htdocs/api/playlist/shuffle.php
new file mode 100644
index 000000000..a21049130
--- /dev/null
+++ b/htdocs/api/playlist/shuffle.php
@@ -0,0 +1,37 @@
+
diff --git a/htdocs/api/playlist/single.php b/htdocs/api/playlist/single.php
new file mode 100644
index 000000000..52e6b2393
--- /dev/null
+++ b/htdocs/api/playlist/single.php
@@ -0,0 +1,37 @@
+
diff --git a/htdocs/api/playlist/song.php b/htdocs/api/playlist/song.php
new file mode 100644
index 000000000..00a2a644e
--- /dev/null
+++ b/htdocs/api/playlist/song.php
@@ -0,0 +1,19 @@
+
diff --git a/htdocs/api/volume.php b/htdocs/api/volume.php
new file mode 100644
index 000000000..5e97bb6f3
--- /dev/null
+++ b/htdocs/api/volume.php
@@ -0,0 +1,23 @@
+
diff --git a/htdocs/func.php b/htdocs/func.php
index b13f46f0e..6c4f5096c 100755
--- a/htdocs/func.php
+++ b/htdocs/func.php
@@ -20,15 +20,15 @@ function html_bootstrap3_createHeader($lang="en",$title="Welcome",$url_absolute=
-
+
".$title."
-
+
-
+
@@ -37,21 +37,21 @@ function html_bootstrap3_createHeader($lang="en",$title="Welcome",$url_absolute=
-
+
-
-
+
+
-
+
@@ -149,7 +149,7 @@ function html_bootstrap3_createHeader($lang="en",$title="Welcome",$url_absolute=
color: #999!important;
}
.btn-panel-big {
- font-size: 3em!important;
+ font-size: 3em!important;
margin-right: 0.1em;
}
.btn-panel-col {
@@ -173,13 +173,13 @@ function html_bootstrap3_createHeader($lang="en",$title="Welcome",$url_absolute=
margin-right: 1em
}
-
+
\n";
}
function arrayPregDiff($a, $p) {
- # added function to use regular expressions to remove multiple files
- # e.g. all of the same file type from the array forming the later playlist.
+ # added function to use regular expressions to remove multiple files
+ # e.g. all of the same file type from the array forming the later playlist.
# Idea originates from http://php.net/manual/en/function.array-diff.php#117219
foreach ($a as $key => $value) {
if (preg_match($p, $value)) {
@@ -235,7 +235,7 @@ function dir_list_recursively($rootdir = "") {
* Get directory tree recursively.
* The dir path will end without '/'.
*/
-
+
$iter = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($rootdir, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST,
@@ -246,7 +246,7 @@ function dir_list_recursively($rootdir = "") {
foreach ($iter as $path => $dir) {
if ($dir->isDir()) {
$paths[] = $path;
- }
+ }
}
return $paths;
@@ -260,9 +260,9 @@ function index_folders_print($item, $key)
global $debugcol;
/**/
// get files from array
- foreach($contentTree as $tempkey => $values) {
- $allFiles = $values['files'];
- }
+ foreach($contentTree as $tempkey => $values) {
+ $allFiles = $values['files'];
+ }
//print_r($contentTree);//???
// get mp3 files from files list
$filesMp3 = array();
@@ -272,6 +272,7 @@ function index_folders_print($item, $key)
$filesMp3[] = $allFile;
}
}
+ $playlist = urlencode($contentTree[$key]['path_rel']);
/**/
//print "
\nkey:".$key." id:".$contentTree[$key]['id']." path_rel:".$contentTree[$key]['path_rel']; print_r($contentTree); print " "; //???
//print "
\nfiles:"; print_r($files); print " "; //???
@@ -285,7 +286,7 @@ function index_folders_print($item, $key)
$panelStyle = "panel-default";
}
/*
- if(file_exists($contentTree[$key]['path_abs'].'/cover.jpg')) {
+ if(file_exists($contentTree[$key]['path_abs'].'/cover.jpg')) {
print '
';
} else {
print '
';
@@ -309,11 +310,11 @@ function index_folders_print($item, $key)
*/
if($contentTree[$key]['count_files'] > 0) {
print "
-
";
+
";
}
if($contentTree[$key]['count_subdirs'] > 0) {
print "
-
";
+
";
}
if (!in_array($contentTree[$key]['path_abs']."/livestream.txt", $contentTree[$key]['files']) && !in_array($contentTree[$key]['path_abs']."/spotify.txt", $contentTree[$key]['files']) && !in_array($contentTree[$key]['path_abs']."/podcast.txt", $contentTree[$key]['files']) ) {
print "
@@ -339,11 +340,11 @@ function index_folders_print($item, $key)
} elseif (in_array($contentTree[$key]['path_abs']."/livestream.txt", $contentTree[$key]['files'])) {
print "
";
print $contentTree[$key]['basename'];
-
+
} elseif (in_array($contentTree[$key]['path_abs']."/podcast.txt", $contentTree[$key]['files'])) {
print "
";
print $contentTree[$key]['basename'];
-
+
} else {
print $contentTree[$key]['basename'];
}
@@ -360,8 +361,8 @@ function index_folders_print($item, $key)
// do not show any if there is a live stream in the folder
if (!in_array($contentTree[$key]['path_abs']."/livestream.txt", $contentTree[$key]['files']) ) {
$foundResume = "OFF";
- if(
- file_exists($contentTree[$key]['path_abs']."/folder.conf")
+ if(
+ file_exists($contentTree[$key]['path_abs']."/folder.conf")
&& strpos(file_get_contents($contentTree[$key]['path_abs']."/folder.conf"),'RESUME="ON"') !== false
) {
$foundResume = "ON";
@@ -369,27 +370,27 @@ function index_folders_print($item, $key)
}
if( $foundResume == "OFF" ) {
// do stuff
- print "
".$lang['globalResume'].": ".$lang['globalOff']." ";
+ print "
".$lang['globalResume'].": ".$lang['globalOff']." ";
} elseif($foundResume == "ON") {
- print "
".$lang['globalResume'].": ".$lang['globalOn']." ";
+ print "
".$lang['globalResume'].": ".$lang['globalOn']." ";
}
}
-
+
// SHUFFLE BUTTON
// do not show any if there is a live stream in the folder
if (!in_array($contentTree[$key]['path_abs']."/livestream.txt", $contentTree[$key]['files']) ) {
$foundShuffle = "OFF";
- if(
- file_exists($contentTree[$key]['path_abs']."/folder.conf")
+ if(
+ file_exists($contentTree[$key]['path_abs']."/folder.conf")
&& strpos(file_get_contents($contentTree[$key]['path_abs']."/folder.conf"),'SHUFFLE="ON"') !== false
) {
$foundShuffle = "ON";
}
if( $foundShuffle == "OFF" ) {
// do stuff
- print "
".$lang['globalShuffle'].": ".$lang['globalOff']." ";
+ print "
".$lang['globalShuffle'].": ".$lang['globalOff']." ";
} elseif($foundShuffle == "ON") {
- print "
".$lang['globalShuffle'].": ".$lang['globalOn']." ";
+ print "
".$lang['globalShuffle'].": ".$lang['globalOn']." ";
}
}
@@ -397,30 +398,31 @@ function index_folders_print($item, $key)
// do not show any if there is a live stream in the folder
if (!in_array($contentTree[$key]['path_abs']."/livestream.txt", $contentTree[$key]['files']) ) {
$foundSinglePlay = "OFF";
- if(
- file_exists($contentTree[$key]['path_abs']."/folder.conf")
+ if(
+ file_exists($contentTree[$key]['path_abs']."/folder.conf")
&& strpos(file_get_contents($contentTree[$key]['path_abs']."/folder.conf"),'SINGLE="ON"') !== false
) {
$foundSinglePlay = "ON";
}
if( $foundSinglePlay == "OFF" ) {
// do stuff
- print "
".$lang['globalSingle'].": ".$lang['globalOff']." ";
+
+ print "
".$lang['globalSingle'].": ".$lang['globalOff']." ";
} elseif($foundSinglePlay == "ON") {
- print "
".$lang['globalSingle'].": ".$lang['globalOn']." ";
+ print "
".$lang['globalSingle'].": ".$lang['globalOn']." ";
}
}
// RSS link
if (count($filesMp3) > 0) {
print "
";
- print "Podcast RSS ";
+ print "Podcast RSS ";
print " ";
- }
+ }
print "
";
}
-
+
// get all IDs that match this folder
$IDchips = ""; // print later
@@ -441,9 +443,9 @@ function index_folders_print($item, $key)
";
//print $contentTree[$key]['id']; //???
-
+
printPlaylistHtml($contentTree[$key]['files']);
-
+
if(is_array($item)) {
array_walk($item, 'index_folders_print');
}
@@ -451,53 +453,53 @@ function index_folders_print($item, $key)
";
-
+
}
-function getSubDirectories( $path = '.', $level = 0, $showfiles = 0 ){
+function getSubDirectories( $path = '.', $level = 0, $showfiles = 0 ){
$return = array();
- // Directories to ignore when listing output. Many hosts
- // will deny PHP access to the cgi-bin.
- $ignore = array( '.', '..', '.git', '.github' );
+ // Directories to ignore when listing output. Many hosts
+ // will deny PHP access to the cgi-bin.
+ $ignore = array( '.', '..', '.git', '.github' );
- // Open the directory to the handle $dh
+ // Open the directory to the handle $dh
$dh = @opendir($path);
-
- while( false !== ( $file = readdir( $dh ) ) ){
- // Loop through the directory
-
- if( !in_array( $file, $ignore ) ){
- // Check that this file is not to be ignored
-
- //$spaces = str_repeat( ' ', ( $level * 4 ) );
- // Just to add spacing to the list, to better
- // show the directory tree.
-
- if(is_dir("$path/$file") ){
- // Its a directory, so we need to keep reading down...
+
+ while( false !== ( $file = readdir( $dh ) ) ){
+ // Loop through the directory
+
+ if( !in_array( $file, $ignore ) ){
+ // Check that this file is not to be ignored
+
+ //$spaces = str_repeat( ' ', ( $level * 4 ) );
+ // Just to add spacing to the list, to better
+ // show the directory tree.
+
+ if(is_dir("$path/$file") ){
+ // Its a directory, so we need to keep reading down...
$return[$path."/".$file] = getSubDirectories("$path/$file",($level+1));
-
- } elseif($showfiles == "1") {
+
+ } elseif($showfiles == "1") {
//$return[$path."/".$file]['files'] = $file;
- }
- }
- }
+ }
+ }
+ }
+
+ closedir( $dh );
- closedir( $dh );
-
uksort($return, 'strnatcasecmp');
return $return;
}
function printPlaylistHtml($files)
-{
+{
global $lang;
$counter = 1;
-
-/*
+
+/*
print "
-