Add a config parameter for the home folder of the web server user

This commit is contained in:
Junior 2019-07-02 09:17:04 -04:00
parent 127b8b32f4
commit c63ddd8e3e
6 changed files with 28 additions and 13 deletions

View File

@ -1,3 +1,10 @@
# HomeAudio
A PHP and PERL based "jukebox style" home audio system for Linux.
## Installation
* The **homeaudio.ini** file from the **/scripts/** folder needs to be edited and saved in **/etc/**. Make sure it is ONLY readable by the web server user.
* The [getID3](https://github.com/JamesHeinrich/getID3) project needs to be added somewhere in a folder included by PHP.
* The **tables.sql** file needs to be imported into the database referenced in the **homeaudio.ini** file.
* The **art/** folder needs to be writable by the web server user.

View File

@ -28,7 +28,7 @@ $query = "SELECT songid FROM " . RECENTSTABLE . " ORDER BY timeplayed DESC limit
$sth = $globaldbh->prepare($query);
$sth->execute();
$data['volume'] = getSystemVolume();
system("HOME=/home/web && scripts/homeaudio_togglemute.pl -show", $retval);
system("HOME=" . WEBUSERHOMEDIR . " && scripts/homeaudio_togglemute.pl -show", $retval);
$data['muted'] = ($retval == 0) ? false : true;
$data['songplaying'] = "";
$data['songlist'] = "";

View File

@ -1,9 +1,9 @@
<?php
if ( isset($_REQUEST['show']) && ($_REQUEST['show'] == 'show') ) {
system("HOME=/home/web && scripts/homeaudio_togglemute.pl -show", $retval);
system("HOME=" . WEBUSERHOMEDIR . " && scripts/homeaudio_togglemute.pl -show", $retval);
} else {
system("HOME=/home/web && scripts/homeaudio_togglemute.pl", $retval);
system("HOME=" . WEBUSERHOMEDIR . " && scripts/homeaudio_togglemute.pl", $retval);
}
$data = array();

View File

@ -1,13 +1,14 @@
<?php
// Database configuration
define('DBHOST', 'localhost');
define('DBUSER', 'root');
define('DBPASS', '');
define('DBNAME', 'musicnew');
define('ENABLELEDBUTTONS', false);
// How many songs to queue into the jukebox when "Surpise Me" is clicked
define('SONGSPERSURPRISE', 10);
// How many songs to return when searching
define('SEARCHLIMIT', 50);
// LOCALNETWORK can be a partial (for a subnet) or a full IP address.
@ -16,6 +17,18 @@ define('SEARCHLIMIT', 50);
define('LOCALNETWORK', '192.168.1.');
define('RESTRICTQUEUES', false);
// The min and max volumes used for system audio. This will likely
// require a bit of tweaking for each system and amplifier configuration.
define('MAXVOLUME', 28);
define('MINVOLUME', 0);
// Home directory for the user that runs the web server process.
// Modern Linux systems typically use PulseAudio which needs files
// from a user's home directory to properly control audio settings.
// This may require changing the shell and/or login permissions for
// the user that runs the web server process. Your mileage may vary.
define('WEBUSERHOMEDIR', '/home/web');
/* ---------------------- Below here be dragons ---------------------- */
define('ALBUMSTABLE', 'albums');
@ -25,8 +38,3 @@ define('RECENTSTABLE', 'recently');
define('SONGSTABLE', 'songs');
define('QUEUECONTENTSTABLE', 'queuecontents');
define('SETTINGSTABLE', 'settings');
define('MAXVOLUME', 28);
define('MINVOLUME', 0);
?>

View File

@ -8,7 +8,7 @@ function setSystemVolume($newvol = null) {
global $globaldbh;
if ( is_null($newvol) ) return false;
system("HOME=/home/web && /usr/bin/amixer -q sset Master " . $newvol);
system("HOME=" . WEBUSERHOMEDIR . " && /usr/bin/amixer -q sset Master " . $newvol);
$query = "UPDATE " . SETTINGSTABLE . " SET value=:value WHERE parameter='CURVOLUME'";
$fields = array();
$fields[':value'] = $newvol;

View File

@ -6,7 +6,7 @@ require 'functions.php';
echo "<pre>";
//$curvol = getSystemVolume();
$curvol = shell_exec("HOME=/home/web && amixer sget Master");
$curvol = shell_exec("HOME=" . WEBUSERHOMEDIR . " && amixer sget Master");
echo "Current Volume: '", $curvol, "'\n";