if (count($changes)) { if (!empty($_REQUEST['uid'])) { dbQuery("update Users set " . implode(", ", $changes) . " where Id = ?", array($_REQUEST['uid'])); } else { dbQuery("insert into Users set " . implode(", ", $changes)); } $refreshParent = true; if ($dbUser['Username'] == $user['Username']) { userLogin($dbUser['Username'], $dbUser['Password']); } } $view = 'none'; } elseif ($action == "state") { if (!empty($_REQUEST['runState'])) { //if ( $cookies ) session_write_close(); packageControl($_REQUEST['runState']); $refreshParent = true; } } elseif ($action == "save") { if (!empty($_REQUEST['runState']) || !empty($_REQUEST['newState'])) { $sql = "select Id,Function,Enabled from Monitors order by Id"; $definitions = array(); foreach (dbFetchAll($sql) as $monitor) { $definitions[] = $monitor['Id'] . ":" . $monitor['Function'] . ":" . $monitor['Enabled']; } $definition = join(',', $definitions); if ($_REQUEST['newState']) { $_REQUEST['runState'] = $_REQUEST['newState']; } dbQuery("replace into States set Name=?, Definition=?", array($_REQUEST['runState'], $definition)); }
</div> <div class="panel-body"> <div class="form-group"> <select id="state" class="form-control"> <option value="restart">Restart</option> <?php if ($status !== "Running") { ?> <option value="start">Start</option> <?php } elseif ($status !== "Stopped") { ?> <option value="stop">Stop</option> <?php } foreach ($states as $state) { $allstates[] = $state['Definition']; echo "<option value=\"{$state['Definition']}\">{$state['Name']}</option>"; } ?> </select> </div> <button id="zm-change-state" class="btn btn-primary">Change State</button> </div> </div> <?php } else { if (ctype_alnum($_REQUEST['newstate']) && in_array($_REQUEST['newstate'], $allstates)) { packageControl($_REQUEST['newstate']); } }