Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1822

Přidáno uživatelem Michal Kliment před téměř 12 roky(ů)

Upravy:

- #312 - Generovani zaznamu DHCP serveru (Mikrotik)

Zobrazit rozdíly:

freenetis/branches/1.1/application/models/device.php
'comment' => '{name}'
), 'stdClass', FALSE);
$mac_addresses = array();
// find all hosts in subnets
foreach ($ip_address->subnet->ip_addresses as $dhcp_ip_address)
{
......
else
$mac = $dhcp_ip_address->iface->mac;
$dhcp_server->hosts[] = arr::to_object(array
(
'id' => $dhcp_ip_address->id,
'server' => $dhcp_server->name,
'ip_address' => $dhcp_ip_address->ip_address,
'mac' => $mac,
'device_name' => $dhcp_ip_address->iface->device->name,
'device_type' => $dhcp_ip_address->iface->device->type,
'member_id' => $dhcp_ip_address->iface->device->user->member->id,
'member_name' => $dhcp_ip_address->iface->device->user->member->name,
'member_type' => $dhcp_ip_address->iface->device->user->member->type,
'comment' => 'ID {member_id} - {member_name} - {device_name}'
), 'stdClass', FALSE);
// mac has to bee valid and unique
if (valid::mac_address($mac) && !in_array($mac, $mac_addresses))
{
$mac_addresses[] = $mac;
$dhcp_server->hosts[] = arr::to_object(array
(
'id' => $dhcp_ip_address->id,
'server' => $dhcp_server->name,
'ip_address' => $dhcp_ip_address->ip_address,
'mac' => $mac,
'device_name' => $dhcp_ip_address->iface->device->name,
'device_type' => $dhcp_ip_address->iface->device->type,
'member_id' => $dhcp_ip_address->iface->device->user->member->id,
'member_name' => $dhcp_ip_address->iface->device->user->member->name,
'member_type' => $dhcp_ip_address->iface->device->user->member->type,
'comment' => 'ID {member_id} - {member_name} - {device_name}'
), 'stdClass', FALSE);
}
else
{
/**
* @todo Log error
*/
}
}
$dhcp_servers[] = $dhcp_server;
freenetis/branches/1.1/application/controllers/devices.php
'debian-etc-dhcp-dhcpd' => 'Debian /etc/dhcp/dhcpd.conf',
'debian-etc-network-interfaces' => 'Debian /etc/network/interfaces',
'mikrotik-all' => 'Mikrotik',
'mikrotik-ip-dhcp-server' => 'Mikrotik /ip dhcp-server',
'mikrotik-ip-dhcp-server-lease' => 'Mikrotik /ip dhcp-server lease',
);
......
$view = new View('device_export_templates/'.$format);
$view->result = $device_export;
$view->dns_servers = explode("\n", Settings::get('dns_servers'));
$view->dns_servers = array_map('trim', explode("\n", Settings::get('dns_servers')));
$view->render(TRUE);
}
// form to choose format and output
freenetis/branches/1.1/application/libraries/snmp/Linux_Snmp.php
// parse result
$matches = array();
if (preg_match('/STRING: "(.*)"/', $row, $matches) > 0)
if (preg_match('/STRING: "?(.*)"?/', $row, $matches) > 0)
{
return text::starts_with($matches[1], 'Linux');
}
freenetis/branches/1.1/application/libraries/snmp/Mikrotik_Snmp.php
// parse result
$matches = array();
if (preg_match('/STRING: "(.*)"/', $row, $matches) > 0)
if (preg_match('/STRING: "?(.*)"?/', $row, $matches) > 0)
{
return text::starts_with($matches[1], 'RouterOS');
}
freenetis/branches/1.1/application/views/device_export_templates/mikrotik-ip-dhcp-server.php
/ip pool
remove [find]
<?php foreach ($result->dhcp_servers as $dhcp_server): ?>
add name="<?php echo text::cs_utf2ascii($dhcp_server->name) ?>" ranges=<?php echo $dhcp_server->range_start ?>-<?php echo $dhcp_server->range_end ?>
<?php endforeach ?>
/ip dhcp-server
remove [find]
<?php foreach ($result->dhcp_servers as $dhcp_server): ?>
add name="<?php echo text::cs_utf2ascii($dhcp_server->name) ?>" address-pool="<?php echo text::cs_utf2ascii($dhcp_server->name) ?>" authoritative=after-2sec-delay bootp-support=static disabled=no interface="<?php echo $dhcp_server->interface ?>" lease-time=3d
<?php endforeach ?>
/ip dhcp-server network
remove [find]
<?php foreach ($result->dhcp_servers as $dhcp_server): ?>
add address=<?php echo $dhcp_server->cidr ?> dhcp-option="" dns-server=<?php echo implode(',', $dns_servers) ?> gateway=<?php echo $dhcp_server->gateway ?> ntp-server="" wins-server="" comment="<?php echo text::cs_utf2ascii(text::object_format($dhcp_server, $dhcp_server->comment)) ?>"
<?php endforeach ?>
/ip dhcp-server lease
remove [find]
<?php foreach ($result->dhcp_servers as $dhcp_server): ?>
<?php foreach ($dhcp_server->hosts as $host): ?>
add address=<?php echo $host->ip_address ?> disabled=no mac-address=<?php echo $host->mac ?> server="<?php echo $host->server ?>" comment="<?php echo text::cs_utf2ascii(text::object_format($host, $host->comment)) ?>"
<?php endforeach ?>
<?php endforeach ?>
freenetis/branches/1.1/application/views/device_export_templates/mikrotik-ip-dhcp-server-lease.php
/ip dhcp-server lease
remove [find]
<?php foreach ($result->dhcp_servers as $dhcp_server): ?>
remove [find name="<?php echo $dhcp_server->name ?>"]
<?php foreach ($dhcp_server->hosts as $host): ?>
add address=<?php echo $host->ip_address ?> disabled=no mac-address=<?php echo $host->mac ?> server="<?php echo $host->server ?>" comment="<?php echo text::cs_utf2ascii(text::object_format($host, $host->comment)) ?>"
<?php endforeach ?>

Také k dispozici: Unified diff