freenet-router |
Subversion Repositories: |
Compare with Previous - Blame - Download
<?php
namespace FreenetRouter\Models\System;
use FreenetRouter\Libraries\ConfigEntryManagers\AdminEmailManager;
use FreenetRouter\Libraries\ConfigEntryManagers\DomainManager;
use FreenetRouter\Libraries\ConfigEntryManagers\HostnameManager;
use FreenetRouter\Libraries\ConfigEntryManagers\InternalIPv4PoolManager;
use FreenetRouter\Libraries\ConfigEntryManagers\MailServerManager;
use FreenetRouter\Libraries\ConfigEntryManagers\PrimaryDnsManager;
use FreenetRouter\Libraries\ConfigEntryManagers\SecondaryDnsManager;
use FreenetRouter\Libraries\ConfigEntryManagers\WritableManager;
use FreenetRouter\Libraries\ServiceManagers\AccountingServiceManager;
use FreenetRouter\Libraries\ServiceManagers\DHCPServerManager;
use FreenetRouter\Libraries\ServiceManagers\SSHServerManager;
use FreenetRouter\Libraries\ServiceManagers\WebServerManager;
use Phem\Core\Collection;
use Phem\Core\Object;
/**
* @author Jakub PetrĹžĂlka <kubapet@lbcfree.net>
*/
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;
}
}