enabled[] = $this->name($file); } } foreach(scandir(base_path().self::SOURCE_FAIL2BAN_JAIL_DIRECTORY) as $file) { if (!in_array($file, self::IGNORE_FILES)) { $name = $this->name($file); $this->configuration[$name] = in_array($name, $this->enabled); } } // create menu $builder = $this->menu('Fail2ban'); foreach($this->configuration as $name => $single) { // create checkbox $checkbox = new CheckboxItem($name, function(CliMenu $menu) use ($name) { if ($this->configuration[$name] === true) { $this->call('fail2ban:disable', [ 'configuration' => $name ]); $menu->redraw(); $menu->confirm($name.' is disabled!')->display('OK!'); } else { $this->call('fail2ban:enable', [ 'configuration' => $name ]); $menu->redraw(); $menu->confirm($name.' is enabled!')->display('OK!'); } // getting new value $this->configuration[$name] = $menu->getSelectedItem()->getChecked(); $menu->redraw(); }); // set default value if ($this->configuration[$name]) { $checkbox->setChecked(true); } $builder->addMenuItem($checkbox); } // apperance $builder = StylesFactory::setMenuStyles($builder); $builder->addLineBreak('-'); $mainmenu = $builder->build(); $mainmenu->open(); } }