09-01-2019, 12:03 PM
(02-06-2019, 05:17 PM)TheOldPresbyope Wrote: As you surmise, the basic machinery is there.
Like vol.sh, you could create a /var/www/playitagainsam.sh script with appropriate options and invoke it via http://moode/command?cmd=playitagainsam.sh with appropriate parameters. (See Tim's recent reply to another poster http://moodeaudio.org/forum/showthread.p...98#pid7698)
You'll likely have to reinstall the script after a moOde update.
Just in case anyone needs this in the future - in v6 custom scripts can't be called via the URL like the above. You need to modify /var/www/command/index.php to include another elsif section to match the name of your script file.
My version below:
PHP Code:
<?php
/**
* moOde audio player (C) 2014 Tim Curtis
* http://moodeaudio.org
*
* tsunamp player ui (C) 2013 Andrea Coiutti & Simone De Gregori
* http://www.tsunamp.com
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* 2019-08-08 TC moOde 6.0.0
*
*/
require_once dirname(__FILE__) . '/../inc/playerlib.php';
playerSession('open', '' ,'');
session_write_close();
if (isset($_GET['cmd']) && empty($_GET['cmd'])) {
echo 'Command missing';
}
// SH or PHP commands
elseif (stripos($_GET['cmd'], '.sh') !== false || stripos($_GET['cmd'], '.php') !== false) {
// check for valid chrs
if (preg_match('/^[A-Za-z0-9 _.-]+$/', $_GET['cmd'])) {
// reject directory traversal ../
if (substr_count($_GET['cmd'], '.') > 1) {
echo 'Invalid string';
}
// check for valid commands
elseif (stripos($_GET['cmd'], 'vol.sh') !== false) {
$result = sysCmd('/var/www/' . $_GET['cmd']);
echo $result[0];
}
elseif (stripos($_GET['cmd'], 'playitagainsam.sh') !== false) {
$result = sysCmd('/var/www/' . $_GET['cmd']);
echo $result[0];
}
else {
echo 'Unknown command';
}
}
else {
echo 'Invalid string';
}
}
// MPD commands
else {
if (false === ($sock = openMpdSock('localhost', 6600))) {
$msg = 'command/index: Connection to MPD failed';
workerLog($msg);
exit($msg . "\n");
}
else {
sendMpdCmd($sock, $_GET['cmd']);
$result = readMpdResp($sock);
closeMpdSock($sock);
//echo $result;
}
}