*/
class System extends Object
{
private static $instance;
private $overview;
private $services;
private $writeEnabled;
private $activeIPs;
private $totalThroughput;
/**
* @return System
*/
public static function getInstance()
{
if (self::$instance === null)
{
self::$instance = new self();
}
return self::$instance;
}
private function __construct()
{
$this->populateServices();
$this->populateOverviewEntries();
}
private function populateServices()
{
$this->services = new Collection();
$this->services->add(
new Service("APACHE", "web server", new WebServerManager()));
$this->services->add(
new Service("DHCP", "dhcp server", new DHCPServerManager()));
$this->services->add(
new Service("FIREWALL", "firewall", new WebServerManager()));
$this->services->add(
new Service("MACGUARD", "macguard", new WebServerManager()));
$this->services->add(
new Service("ACCOUNT", "tvorba grafů", new AccountingServiceManager()));
$this->services->add(
new Service("QUAGGA", "quagga", new WebServerManager()));
$this->services->add(
new Service("SNMP", "snmp", new WebServerManager()));
$this->services->add(
new Service("SSH", "ssh server", new SSHServerManager()));
}
private function populateOverviewEntries()
{
$this->overview = new Collection();
$this->overview->add(new ConfigEntry("HOSTNAME",
"název routeru", new HostnameManager()));
$this->overview->add(new ConfigEntry("PRIMARY_DNS",
"primární dns server", new PrimaryDnsManager()));
$this->overview->add(new ConfigEntry("SECONDARY_DNS",
"sekundární dns server", new SecondaryDnsManager()));
$this->overview->add(new ConfigEntry("DOMAIN",
"doména", new DomainManager()));
$this->overview->add(new ConfigEntry("INTERNAL_IP",
"vnitřní rozsahy sítě", new InternalIPv4PoolManager()));
$this->overview->add(new ConfigEntry("ADMIN_EMAIL",
"email správce", new AdminEmailManager()));
$this->overview->add(new ConfigEntry("MAIL_SERVER",
"mail server", new MailServerManager()));
}
public function getOverview()
{
return $this->overview;
}
public function getServices()
{
return $this->services;
}
public function getWriteEnabled()
{
if ($this->writeEnabled === null)
{
$this->writeEnabled = (new WritableManager())->getValue();
}
return $this->writeEnabled;
}
public function getActiveIPs()
{
return $this->activeIPs;
}
public function getTotalThroughput()
{
return $this->totalThroughput;
}
public function setOverview($overview)
{
$this->overview = $overview;
}
public function setServices($services)
{
$this->services = $services;
}
public function setWriteEnabled($writeEnabled)
{
$wm = new WritableManager();
$wm->setValue($writeEnabled);
$this->writeEnabled = $wm->getValue();
}
public function setActiveIPs($activeIPs)
{
$this->activeIPs = $activeIPs;
}
public function setTotalThroughput($totalThroughput)
{
$this->totalThroughput = $totalThroughput;
}
}