$_POST['mount']['options'] = "cache=none,ro"; } else { $_POST['mount']['options'] = "nfsvers=3,ro"; } } if ($_POST['action'] == 'add') { $jobID = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'sourcecfg', 'action' => 'add', 'args' => $_POST['mount'])); } if ($_POST['action'] == 'edit') { $jobID = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'sourcecfg', 'action' => 'edit', 'args' => $_POST['mount'])); } if ($_POST['action'] == 'delete') { $jobID = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'sourcecfg', 'action' => 'delete', 'args' => $_POST['mount'])); } if ($_POST['action'] == 'reset') { $jobID = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'sourcecfgman', 'action' => 'reset')); } } } waitSyWrk($redis, $jobID); $source = netMounts($redis, 'read'); if ($source !== true) { foreach ($source as $mp) { if (wrk_checkStrSysfile('/proc/mounts', '/mnt/MPD/NAS/' . $mp['name'])) { $mp['status'] = 1; } else { $mp['status'] = 0; } $mounts[] = $mp; } }
} // ----- RESET NET CONFIG ----- if ($_POST['syscmd'] === 'netconfreset') { $jobID[] = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'netcfg', 'action' => 'reset')); } // ----- RESET MPD CONFIG ----- if ($_POST['syscmd'] === 'mpdconfreset') { $jobID[] = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'mpdcfg', 'action' => 'reset')); } // ----- RESTART PHP-FPM ----- if ($_POST['syscmd'] === 'phprestart') { $jobID[] = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'phprestart')); } // ----- GIT PULL ----- if ($_POST['syscmd'] === 'gitpull') { $jobID[] = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'gitpull')); } // ----- RESTART WORKERS ----- if (isset($_POST['syscmd']['wrkrestart'])) { $jobID[] = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'wrkrestart', 'args' => $_POST['syscmd']['wrkrestart'])); } } } waitSyWrk($redis, $jobID); $template->debug = $redis->get('debug'); $template->playerid = $redis->get('playerid'); $template->opcache = $redis->get('opcache'); // debug // var_dump($template->dev); // var_dump($template->debug); // var_dump($template->opcache);
case 'editradio': if ($activePlayer === 'MPD') { // input array= $_POST['radio']['label'] $_POST['radio']['newlabel'] $_POST['radio']['url'] wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'webradio', 'action' => 'edit', 'args' => $_POST['radio'])); } break; case 'readradio': if ($activePlayer === 'MPD') { $name = parseFileStr(parseFileStr($_POST['filename'], '.', 1), '/'); echo json_encode(array('name' => $name, 'url' => $redis->hGet('webradios', $name))); } break; case 'deleteradio': if ($activePlayer === 'MPD') { // input array= $_POST['radio']['label'] wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'webradio', 'action' => 'delete', 'args' => $_POST['radio'])); } break; case 'test': $proxy = $redis->hGetall('proxy'); print_r($proxy); break; case 'albumadd': if ($activePlayer === 'MPD') { if (isset($_POST['path'])) { addAlbumToQueue($mpd, $_POST['path']); // send MPD response to UI ui_mpd_response($mpd, array('title' => 'Added to queue', 'text' => $_POST['path'])); } } break;
} else { $template->section = 'error'; $template->content = 'error'; // register current controller in SESSION $_SESSION['controller'] = 'error'; } // set devmode $template->dev = $devmode; // plates: render layout (if you want to output direct, set $tplfile = 0 into controller) if ($tplfile !== 0) { echo $template->render('default_lo'); } // close palyer backend connection if ($activePlayer === 'MPD') { // close MPD connection closeMpdSocket($mpd); } elseif ($activePlayer === 'Spotify') { // close SPOP connection closeSpopSocket($spop); } // notifications $notifications = $redis->hGetAll('notifications'); if (!empty($notifications) && $tplfile !== 0) { foreach ($notifications as $raw_notification) { wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'ui_notify', 'args' => $notifications, 'delay_us' => 450000)); } } // close Redis connection // $redis->close(); // close session session_write_close();
} else { $redis->get('cmediafix') == 0 || $redis->set('cmediafix', 0); } // ----- SYSTEM COMMANDS ----- if (isset($_POST['syscmd'])) { if ($_POST['syscmd'] === 'reboot') { $jobID[] = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'reboot')); } if ($_POST['syscmd'] === 'poweroff') { $jobID[] = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'poweroff')); } if ($_POST['syscmd'] === 'mpdrestart') { $jobID[] = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'mpdrestart')); } if ($_POST['syscmd'] === 'backup') { $jobID[] = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'backup')); } } } waitSyWrk($redis, $jobID); // push backup file if ($_POST['syscmd'] === 'backup') { pushFile($redis->hGet('w_msg', $jobID[0])); $redis->hDel('w_msg', $jobID[0]); } // collect system status $template->sysstate['kernel'] = file_get_contents('/proc/version'); $template->sysstate['time'] = implode('\\n', sysCmd('date')); $template->sysstate['uptime'] = date('d:H:i:s', strtok(file_get_contents('/proc/uptime'), ' ')); $template->sysstate['HWplatform'] = $redis->get('hwplatform') . " (" . $redis->get('hwplatformid') . ")"; $template->sysstate['playerID'] = $redis->get('playerid');
wrk_notify($redis, 'startjob', $notification, $jobID); } else { ui_notify('Spotify not enabled', 'Enable and configure it under the Settings screen'); } } elseif (isset($_GET['cmd']) && $_GET['cmd'] !== '') { // debug // runelog('MPD command: ',$_GET['cmd']); if ($_GET['cmd'] === 'renderui') { if ($activePlayer === 'MPD') { $socket = $mpd; } elseif ($activePlayer === 'Spotify') { $socket = $spop; } $response = ui_update($redis, $socket); } elseif ($_GET['cmd'] === 'wifiscan') { wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'wificfg', 'action' => 'scan')); echo 'wlan scan queued'; die; } else { if ($activePlayer === 'MPD') { sendMpdCommand($mpd, $_GET['cmd']); // debug // runelog('--- [command/index.php] --- CLOSE MPD SOCKET <<< (1) ---',''); if (!$response) { $response = readMpdResponse($mpd); } } elseif ($activePlayer === 'Spotify') { // MPD -> SPOP command conversion if ($_GET['cmd'] === 'pause') { $_GET['cmd'] = 'toggle'; }
* * RuneOS * copyright (C) 2013 - Carmelo San Giovanni (aka Um3ggh1U) & Simone De Gregori (aka Orion) * * RuneAudio website and logo * copyright (C) 2013 - ACX webdesign (Andrea Coiutti) * * 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 RuneAudio; see the file COPYING. If not, see * <http://www.gnu.org/licenses/gpl-3.0.txt>. * * file: app/debug_ctl.php * version: 1.3 * */ // ob_start(); // echo debug_data($redis); // $debugdata = ob_get_clean(); $jobID = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'debug')); waitSyWrk($redis, $jobID); $template->debug = $redis->get('debugdata');
if (isset($_POST)) { // switch audio output if (isset($_POST['ao'])) { $jobID = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'mpdcfg', 'action' => 'switchao', 'args' => $_POST['ao'])); } // reset MPD configuration if (isset($_POST['reset'])) { $jobID = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'mpdcfg', 'action' => 'reset')); } // update MPD configuration if (isset($_POST['conf'])) { $jobID = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'mpdcfg', 'action' => 'update', 'args' => $_POST['conf'])); } // manual MPD configuration if (isset($_POST['mpdconf'])) { $jobID = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'mpdcfgman', 'args' => $_POST['mpdconf'])); } } waitSyWrk($redis, $jobID); // check integrity of /etc/network/interfaces if (!hashCFG('check_mpd', $redis)) { $template->mpdconf = file_get_contents('/etc/mpd.conf'); // set manual config template $template->content = "mpd_manual"; } else { $template->conf = $redis->hGetAll('mpdconf'); $i2smodule = $redis->get('i2smodule'); // debug // echo $i2smodule."\n"; $acards = $redis->hGetAll('acards'); // debug
case 'edit': $jobID[] = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'wificfg', 'action' => 'edit', 'args' => $_POST['wifiprofile'])); break; case 'delete': $jobID[] = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'wificfg', 'action' => 'delete', 'args' => $_POST['wifiprofile'])); break; case 'disconnect': $jobID[] = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'wificfg', 'action' => 'disconnect', 'args' => $_POST['wifiprofile'])); break; } } // if (isset($_POST['wifidelete'])) { // $jobID[] = wrk_control($redis,'newjob', $data = array( 'wrkcmd' => 'wificfg', 'action' => 'delete', 'args' => $_POST['wifidelete'] )); // } if (isset($_POST['wpa_cli'])) { $jobID[] = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'wificfg', 'action' => 'wpa_cli', 'args' => $_POST['wpa_cli'])); } } waitSyWrk($redis, $jobID); $template->nics = wrk_netconfig($redis, 'getnics'); $template->wlan_autoconnect = $redis->Get('wlan_autoconnect'); if ($redis->hExists('wlan_profiles', urldecode($template->uri(4)))) { $template->stored = 1; } if (isset($template->action)) { // check if we are into interface details (ex. http://runeaudio/network/edit/eth0) if (isset($template->arg)) { // check if there is a stored profile for current nic $nic_stored_profile = json_decode($redis->Get($template->uri(3))); // runelog('nic stored profile: ',$nic_stored_profile); if (!empty($nic_stored_profile)) {