if ($_SESSION['w_lock'] != 1 && $_SESSION['w_queue'] == '') { // start / respawn session session_start(); $_SESSION['w_jobID'] = wrk_jobID(); $_SESSION['w_queue'] = 'backup'; $_SESSION['w_active'] = 1; playerSession('unlock'); // wait worker response loop while (1) { sleep(2); session_start(); if (isset($_SESSION[$_SESSION['w_jobID']])) { // set UI notify $_SESSION['notify']['title'] = 'BACKUP'; $_SESSION['notify']['msg'] = 'backup complete.'; pushFile($_SESSION[$_SESSION['w_jobID']]); unset($_SESSION[$_SESSION['w_jobID']]); break; } session_write_close(); } } else { session_start(); $_SESSION['notify']['title'] = 'Job Failed'; $_SESSION['notify']['msg'] = 'background worker is busy.'; } // unlock session file playerSession('unlock'); break; case 'updatempdDB': if ($_SESSION['w_lock'] != 1 && $_SESSION['w_queue'] == '') {
} 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'); $template->hostname = $redis->get('hostname'); $template->ntpserver = $redis->get('ntpserver'); $template->timezone = $redis->get('timezone'); $template->orionprofile = $redis->get('orionprofile'); $template->airplay = $redis->hGetAll('airplay'); $template->dlna = $redis->hGetAll('dlna'); $template->udevil = $redis->get('udevil');