function wrk_sourcecfg($db, $queueargs) { $action = $queueargs['mount']['action']; unset($queueargs['mount']['action']); switch ($action) { case 'reset': $dbh = cfgdb_connect($db); $source = cfgdb_read('cfg_source', $dbh); foreach ($source as $mp) { sysCmd("umount -f \"/mnt/NAS/" . $mp['name'] . "\""); sysCmd("rmdir \"/mnt/NAS/" . $mp['name'] . "\""); } if (cfgdb_delete('cfg_source', $dbh)) { $return = 1; } else { $return = 0; } $dbh = null; break; case 'add': $dbh = cfgdb_connect($db); print_r($queueargs); unset($queueargs['mount']['id']); // format values string foreach ($queueargs['mount'] as $key => $value) { if ($key == 'error') { $values .= "'" . SQLite3::escapeString($value) . "'"; error_log(">>>>> values on line 1014 >>>>> " . $values, 0); } else { $values .= "'" . SQLite3::escapeString($value) . "',"; error_log(">>>>> values on line 1016 >>>>> " . $values, 0); } } error_log(">>>>> values on line 1019 >>>>> " . $values, 0); // write new entry cfgdb_write('cfg_source', $dbh, $values); $newmountID = $dbh->lastInsertId(); $dbh = null; if (wrk_sourcemount($db, 'mount', $newmountID)) { $return = 1; } else { $return = 0; } break; case 'edit': $dbh = cfgdb_connect($db); $mp = cfgdb_read('cfg_source', $dbh, '', $queueargs['mount']['id']); cfgdb_update('cfg_source', $dbh, '', $queueargs['mount']); sysCmd("umount -f \"/mnt/NAS/" . $mp[0]['name'] . "\""); if ($mp[0]['name'] != $queueargs['mount']['name']) { sysCmd("rmdir \"/mnt/NAS/" . $mp[0]['name'] . "\""); sysCmd("mkdir \"/mnt/NAS/" . $queueargs['mount']['name'] . "\""); } if (wrk_sourcemount($db, 'mount', $queueargs['mount']['id'])) { $return = 1; } else { $return = 0; } error_log(">>>>> wrk_sourcecfg(edit) exit status = >>>>> " . $return, 0); $dbh = null; break; case 'delete': $dbh = cfgdb_connect($db); $mp = cfgdb_read('cfg_source', $dbh, '', $queueargs['mount']['id']); sysCmd("umount -f \"/mnt/NAS/" . $mp[0]['name'] . "\""); sysCmd("rmdir \"/mnt/NAS/" . $mp[0]['name'] . "\""); if (cfgdb_delete('cfg_source', $dbh, $queueargs['mount']['id'])) { $return = 1; } else { $return = 0; } $dbh = null; break; } return $return; }
// check /etc/mpd.conf integrity hashCFG('check_mpd', $db); // check /etc/auto.nas integrity // hashCFG('check_source',$db); // unlock session files playerSession('unlock', $db, '', ''); // Cmediafix startup check if (isset($_SESSION['cmediafix']) && $_SESSION['cmediafix'] == 1) { $mpd = openMpdSocket('localhost', 6600); sendMpdCommand($mpd, 'cmediafix'); closeMpdSocket($mpd); } // Utilities to start with Volumio // Shairport for Airplay Capability //Retrieve Output Device $dbh = cfgdb_connect($db); $query_cfg = "SELECT param,value_player FROM cfg_mpd WHERE value_player!=''"; $mpdcfg = sdbquery($query_cfg, $dbh); $dbh = null; foreach ($mpdcfg as $cfg) { if ($cfg['param'] == 'audio_output_format' && $cfg['value_player'] == 'disabled') { $output .= ''; } else { if ($cfg['param'] == 'device') { $device = $cfg['value_player']; var_export($device); } else { $output .= $cfg['param'] . " \t\"" . $cfg['value_player'] . "\"\n"; } } }