From 3db9bd83148e64fbd88507e960bd1223d857bc7b Mon Sep 17 00:00:00 2001 From: Micz Flor Date: Mon, 8 Oct 2018 23:33:09 +0200 Subject: [PATCH 01/36] file upload with folder creation #237 --- htdocs/manageFilesFolders.php | 57 +++++++++++++++++++++++------------ scripts/rfid_trigger_play.sh | 2 +- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/htdocs/manageFilesFolders.php b/htdocs/manageFilesFolders.php index 922343f50..3032cbad5 100755 --- a/htdocs/manageFilesFolders.php +++ b/htdocs/manageFilesFolders.php @@ -11,7 +11,6 @@ /* NO CHANGES BENEATH THIS LINE ***********/ - /******************************************* * URLPARAMETERS *******************************************/ @@ -70,7 +69,8 @@ * confusing. Later I discovery the problem was in the POST_MAX_SIZE been 3m, so it happen * that not only MAX_UPLOAD_SIZE is responsible and that is why I'd like to know there is no * error message that shows the cause. - */ + */ + $uFiles = getFiles(); //print "
"; print_r($uFiles); print "
"; //??? // are there any files? @@ -82,34 +82,53 @@ if (count($uFiles['ufile']) == 0) { // if 0 there are no files $messageWarning .= "

No files were uploaded.

"; - } elseif ( - // see if we have a folder selected that exists + } + /* + * let's start building the path to move the files to + * as a relative path. + */ + if( isset($post['folder']) && $post['folder'] != "" && file_exists($post['folder']) && is_dir($post['folder']) ) { - // yes, a folder was selected - $messageAction .= "Will move files to folder: '" . $post['folder'] . "'"; + // add the existing folder to the path $moveFolder = $post['folder']; - } elseif ( - // if not, see if we have a new folder to create + } else { + $moveFolder = $Audio_Folders_Path; + } + /* + * see if we need to create a new folder + */ + if ( + // did we get a new folder to create? isset($post['folderNew']) && $post['folderNew'] != "" - && !file_exists($Audio_Folders_Path . "/" . $post['folderNew']) ) { - // yes, valid new folder - $messageAction .= "Will create new folder and move files to: '" . $post['folderNew'] . "'"; - // create folder - $exec = 'mkdir "' . $Audio_Folders_Path . '/' . $post['folderNew'] . '"; chown -R pi:www-data "' . $Audio_Folders_Path . "/" . $post['folderNew'] . '"; chmod 775 "' . $Audio_Folders_Path . "/" . $post['folderNew'] . '"'; - exec($exec); - $moveFolder = $Audio_Folders_Path . "/" . $post['folderNew']; - } else { - $messageWarning .= $lang['manageFilesFoldersErrorNewFolder']; + // add the new folder to the relative folder path + $moveFolder = $moveFolder . "/" . $post['folderNew']; + // hang on, does that folder exist already? + if(!file_exists($Audio_Folders_Path . "/" . $moveFolder)) { + // no, so create the folder + $exec = 'mkdir "' . $moveFolder . '"; chown -R pi:www-data "' . $moveFolder . '"; chmod 775 "' . $moveFolder . '"'; + exec($exec); + $messageAction .= "Will create new folder and move files to: '" . $moveFolder . "'"; + } else { + // folder exists already :( + $messageWarning .= $lang['manageFilesFoldersErrorNewFolderExists'] . "(".$moveFolder.")"; + } + } + /* + * see if any valid folder has been chosen + */ + if($moveFolder == $Audio_Folders_Path) { + $messageWarning .= $lang['manageFilesFoldersErrorNoNewFolder']; } - // if neither: error message + + // if no error message if ($messageWarning == "") { - // else: move files to folder + // move files to folder foreach ($uFiles['ufile'] as $key => $values) { $targetName = $moveFolder . '/' . $values['name']; $exec = 'mv "' . $values['tmp_name'] . '" "' . $targetName . '"; sudo chown -R pi:www-data "' . $targetName . '"; chmod 775 "' . $targetName . '"'; diff --git a/scripts/rfid_trigger_play.sh b/scripts/rfid_trigger_play.sh index f42828cac..110592a2b 100755 --- a/scripts/rfid_trigger_play.sh +++ b/scripts/rfid_trigger_play.sh @@ -27,7 +27,7 @@ ############################################################# # $DEBUG true|false -DEBUG=true +DEBUG=false # Set the date and time of now NOW=`date +%Y-%m-%d.%H:%M:%S` From c2aaae4b638ae390d801fc4a7a39fba7b00b8d2d Mon Sep 17 00:00:00 2001 From: Micz Flor Date: Mon, 8 Oct 2018 23:47:16 +0200 Subject: [PATCH 02/36] file upload with folder creation #237 --- htdocs/lang/lang-en.php | 6 ++++-- htdocs/manageFilesFolders.php | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/lang/lang-en.php b/htdocs/lang/lang-en.php index 9c3664983..6fe5b86a3 100755 --- a/htdocs/lang/lang-en.php +++ b/htdocs/lang/lang-en.php @@ -158,16 +158,18 @@ $lang['manageFilesFoldersTitle'] = "Folders & Files"; $lang['manageFilesFoldersUploadFilesLabel'] = "Select files from your drive"; $lang['manageFilesFoldersUploadLegend'] = "Upload files"; -$lang['manageFilesFoldersUploadLabel'] = "Select folder or create new"; -$lang['manageFilesFoldersUploadFolderHelp'] = "Name for the audio folder that will contain the uploaded files."; +$lang['manageFilesFoldersUploadLabel'] = "Select and/or create new folder"; +$lang['manageFilesFoldersUploadFolderHelp'] = "If you select AND name a new folder, the new folder will be created inside the selected folder."; $lang['manageFilesFoldersNewFolderTitle'] = "Create new folder"; $lang['manageFilesFoldersNewFolderPositionLegend'] = "Folder position"; $lang['manageFilesFoldersNewFolderPositionDefault'] = "The new folder will be on the root level or inside (choose below)"; $lang['manageFilesFoldersErrorNewFolderName'] = "

No valid folder name given.

"; $lang['manageFilesFoldersErrorNewFolder'] = "

No folder selected nor a valid new folder specified.

"; +$lang['manageFilesFoldersErrorNoNewFolder'] = "

No folder selected nor a valid new folder specified.

"; $lang['manageFilesFoldersErrorNewFolderExists'] = "

A folder by that name already exists. Be original, type a new name.

"; $lang['manageFilesFoldersErrorNewFolderNotParent'] = "

The parent folder does not exist.

"; $lang['manageFilesFoldersSuccessNewFolder'] = "New folder created: "; +$lang['manageFilesFoldersSelectDefault'] = "Pull down to select a folder and/or create a new child folder below"; diff --git a/htdocs/manageFilesFolders.php b/htdocs/manageFilesFolders.php index 3032cbad5..aaf78ae62 100755 --- a/htdocs/manageFilesFolders.php +++ b/htdocs/manageFilesFolders.php @@ -122,7 +122,8 @@ /* * see if any valid folder has been chosen */ - if($moveFolder == $Audio_Folders_Path) { + print "if(".realpath($moveFolder)." == ".realpath($Audio_Folders_Path).") {"; + if(realpath($moveFolder) == realpath($Audio_Folders_Path)) { $messageWarning .= $lang['manageFilesFoldersErrorNoNewFolder']; } @@ -256,7 +257,7 @@
- Start custom scripts + Start custom scripts
@@ -201,19 +201,20 @@ $audiofolders = array_filter(glob($conf['scripts_abs'].'/userscripts/*'), 'is_file'); usort($audiofolders, 'strcasecmp'); + // check if we can preselect an audiofolder if NOT a foldername was posted -if(! isset($fpost['folder'])) { +/* if(! isset($fpost['folder'])) { if(array_key_exists($fpost['cardID'], $shortcuts)) { $fpost['folder'] = $shortcuts[$fpost['cardID']]; } } - +*/ // counter for ID of each folder $idcounter = 0; // go through all folders foreach($audiofolders as $audiofolder) { - + print "
+ @@ -254,8 +256,38 @@ +

+ +"; +print "Filename:".basename($audiofolder)."(Filerights:".$perms.")
"; +print "--------------------------------------------------------
"; +print nl2br(file_get_contents($conf['scripts_abs']."/userscripts/".basename($audiofolder))); +print "--------------------------------------------------------
"; +print ""; +} +?> +

+ From cf052c674de23395a252725496aa8a7f8edaa4c3 Mon Sep 17 00:00:00 2001 From: Felix Date: Wed, 10 Oct 2018 12:31:10 +0200 Subject: [PATCH 04/36] Fix: unable to delete Card ID If you press the "Remove Card ID" Button in cardEdit.php the "delete" is not in $post but in $_POST --- htdocs/inc.processCheckCardEditRegister.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/inc.processCheckCardEditRegister.php b/htdocs/inc.processCheckCardEditRegister.php index 13d361730..f7e93922c 100644 --- a/htdocs/inc.processCheckCardEditRegister.php +++ b/htdocs/inc.processCheckCardEditRegister.php @@ -9,7 +9,7 @@ $messageAction = ""; $messageSuccess = ""; -if($post['delete'] == "delete") { +if($_POST['delete'] == "delete") { $messageAction .= "

The card with the ID '".$post['cardID']." has been deleted. If you made a mistake, this is your chance to press 'Submit' to restore the card settings. Else: Go Home.

"; @@ -111,4 +111,4 @@ */ } } -?> \ No newline at end of file +?> From 662c32792093c6cd74517c192d3464feffd619d6 Mon Sep 17 00:00:00 2001 From: Micz Flor Date: Mon, 15 Oct 2018 10:39:09 +0200 Subject: [PATCH 05/36] gpio docs and delete card PHP --- docs/GPIO-BUTTONS.md | 23 +++++++++------------ docs/MANUAL.md | 7 +++++++ htdocs/inc.processCheckCardEditRegister.php | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/docs/GPIO-BUTTONS.md b/docs/GPIO-BUTTONS.md index 13fda67ff..ebde3cbdf 100644 --- a/docs/GPIO-BUTTONS.md +++ b/docs/GPIO-BUTTONS.md @@ -16,12 +16,8 @@ Many, many fellow jukebox tweakers have contacted me to push the envelope a bit further and add buttons to the jukebox. Buttons to change the volume and skip between tracks in a playlist. -Right now (12th Dec 2017) I still have to get my soldering iron -out of the shelf and try this myself. Until then, what I have done here -is compiling and editing howto mails and docs I got sent. -I would love to hear feedback and get pull requests to improve -this documentation. So if you are successful, give back to the project -by sharing your knowledge. +So this documentation is entirely community driven, I am only editing and asking for +confirmation that this works :) Enough said, here we go. @@ -52,13 +48,14 @@ On the above image you can also see the pin numbering, in this case containing b The script for the GPIO buttons we are using have been provided by Andreas aka [hailogugo](https://github.com/hailogugo). He also sent the picture above and has a working version of the GPIO button solution. Pin numbers and functionality in this example connect as such: -| Board | GPIO (BCM) | Function | -| --- | --- | --- | -| 15 | 22 | Volume up | -| 16 | 23 | Volume down | -| 11 | 17 | Next track | -| 13 | 27 | Previous track | -| 37 | 26 | Play/Pause | +* **Volume Down** GPIO19 (PIN35) and GND (PIN39) +* **Volume Up** GPIO16 (PIN36) and GND (PIN34) +* **Play/Pause/Halt (or how you call it)** GPIO21 (PIN40) and GND (PIN25) +* **Next** GPIO26 (PIN37) and GND (PIN30) +* **Previous** GPIO20 (PIN38) and GND (PIN20) +* **Shutdown (you need to hold button for 2 secs for shutdown)** GPIO3 (PIN5) and GND (PIN6) + +**!!! IMPORTANT Only when using the above listed pins for wiring you will be able to power-up the Raspberry PI from firmware halt. !!!** ### Circuit example(s) for the button wiring diff --git a/docs/MANUAL.md b/docs/MANUAL.md index 5d8a8bc0a..e8f7c8f25 100755 --- a/docs/MANUAL.md +++ b/docs/MANUAL.md @@ -556,6 +556,13 @@ $ sudo reboot ## Audio is not working +Before you file a ticket on github, please read this section and when you file it, please answer these questions: + +* what version are you on? Type in terminal `cat /home/pi/settings/version` +* what soundcard are you using? +* does your Raspberry Pi play any sound? +* did the audio work and then you connected a sound card and now it doesn't? + This might occur if you are using external sound cards like *pHat BEAT* or the like. I split this into two parts: a) sound did never work and b) sound worked once, now, with a new soundcard, it doesn't. **a) Audio never worked** diff --git a/htdocs/inc.processCheckCardEditRegister.php b/htdocs/inc.processCheckCardEditRegister.php index f7e93922c..9b9b167ea 100644 --- a/htdocs/inc.processCheckCardEditRegister.php +++ b/htdocs/inc.processCheckCardEditRegister.php @@ -9,7 +9,7 @@ $messageAction = ""; $messageSuccess = ""; -if($_POST['delete'] == "delete") { +if($post['delete'] == "delete") { $messageAction .= "

The card with the ID '".$post['cardID']." has been deleted. If you made a mistake, this is your chance to press 'Submit' to restore the card settings. Else: Go Home.

"; From fa60fff9875e9ef4c8c5bc9d9980dc72e067902f Mon Sep 17 00:00:00 2001 From: Maxwell <37151645+princemaxwell@users.noreply.github.com> Date: Tue, 16 Oct 2018 00:36:07 +0200 Subject: [PATCH 06/36] Update lang-en.php Adding and editing some textstrings for spotify integration. --- htdocs/lang/lang-en.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/lang/lang-en.php b/htdocs/lang/lang-en.php index 6fe5b86a3..ff333af08 100755 --- a/htdocs/lang/lang-en.php +++ b/htdocs/lang/lang-en.php @@ -16,6 +16,7 @@ $lang['globalCardIdPlaceholder'] = "e.g. '1234567890'"; $lang['globalCardIdHelp'] = "The ID is usually printed on the card or fob. A list of used IDs can be found on the home page."; $lang['globalRegisterCard'] = "Register new card ID"; +$lang['globalRegisterCardShort'] = "Card ID"; $lang['globalLastUsedCard'] = "Last used Chip ID"; $lang['globalClose'] = "Close"; $lang['globalPlay'] = "Play"; @@ -73,6 +74,8 @@ $lang['indexShowFiles'] = "Show files"; $lang['indexManageFilesChips'] = "Manage Files and Chips"; +$lang['Spotify'] = "Spotify"; + /* * Register & Edit Cards */ @@ -101,11 +104,11 @@ $lang['cardFormFolderLabel'] = "a) Link card to audio folder"; $lang['cardFormFolderSelectDefault'] = "None (pulldown to select a folder)"; $lang['cardFormStreamLabel'] = "b) ... or connect with Stream URL"; -$lang['cardFormStreamPlaceholder'] = "http(...).mp3 / .m3u / .ogg / ..."; -$lang['cardFormStreamHelp'] = "Add the URL for a podcast, web radio, stream or other online media"; -$lang['cardFormStreamTypeSelectDefault'] = "Select type of stream"; -$lang['cardFormStreamTypeHelp'] = "Select the type of URL / stream you are adding"; -$lang['cardFormStreamFolderPlaceholder'] = "e.g. 'Station Name'"; +$lang['cardFormStreamPlaceholder'] = "Spotify: spotify:(user:username:)album/track/playlist:### / Livestream: http(...).mp3 / .m3u / .ogg / ..."; +$lang['cardFormStreamHelp'] = "Add the URL for spotify, podcast, web radio, stream or other online media"; +$lang['cardFormStreamTypeSelectDefault'] = "Select type"; +$lang['cardFormStreamTypeHelp'] = "Select the type you are adding"; +$lang['cardFormStreamFolderPlaceholder'] = "e.g. 'Album/Playlist/Station Name'"; $lang['cardFormStreamFolderHelp'] = "Name for the audio folder that will contain the stream URL."; $lang['cardFormYTLegend'] = "YouTube"; $lang['cardFormYTLabel'] = "c) ... or download YouTube audio"; @@ -171,7 +174,4 @@ $lang['manageFilesFoldersSuccessNewFolder'] = "New folder created: "; $lang['manageFilesFoldersSelectDefault'] = "Pull down to select a folder and/or create a new child folder below"; - - ?> - From b988891380ebf9a5aff4d5ec39980758741cab09 Mon Sep 17 00:00:00 2001 From: Maxwell <37151645+princemaxwell@users.noreply.github.com> Date: Tue, 16 Oct 2018 00:38:07 +0200 Subject: [PATCH 07/36] Update inc.setVolume.php Change volume steps to 5 --- htdocs/inc.setVolume.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/inc.setVolume.php b/htdocs/inc.setVolume.php index ec8dd87f3..7dc9d09f3 100755 --- a/htdocs/inc.setVolume.php +++ b/htdocs/inc.setVolume.php @@ -35,7 +35,7 @@ print " limit"; } print ""; - $i = $i - 10; + $i = $i - 5; }; print "\n"; ?> From 06a10c25289d9bce01b40667bab27b2a3568aa99 Mon Sep 17 00:00:00 2001 From: Maxwell <37151645+princemaxwell@users.noreply.github.com> Date: Tue, 16 Oct 2018 00:39:25 +0200 Subject: [PATCH 08/36] Update inc.formCardEdit.php add spotify --- htdocs/inc.formCardEdit.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/inc.formCardEdit.php b/htdocs/inc.formCardEdit.php index 5ed01bee2..aa60a53fe 100755 --- a/htdocs/inc.formCardEdit.php +++ b/htdocs/inc.formCardEdit.php @@ -129,6 +129,7 @@