Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1698

Přidáno uživatelem Michal Kliment před asi 12 roky(ů)

Commit rozdelenych veci na exportu zarizeni - potrebuju delat z domu.

Zobrazit rozdíly:

freenetis/branches/1.1/db_upgrades/upgrade_1.1.0~alpha2.php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreenetIS
* and it is released under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* Add DHCP flag to subnets
*
* @author Michal Kliment <kliment@freenetis.org>
*/
$upgrade_sql['1.1.0~alpha2'] = array
(
"ALTER TABLE `subnets` ADD `dhcp` BOOLEAN NOT NULL DEFAULT FALSE",
"ALTER TABLE `subnets` ADD `qos` BOOLEAN NOT NULL DEFAULT FALSE"
);
freenetis/branches/1.1/application/i18n/cs_CZ/help.php
'deduct_member_fees' => 'Zobrazí formulář, který nabídne měsíc a rok pro stržení členských příspěvků. Strhávání členských příspěvků není automatizované a je třeba ho provádět jednou měsíčně, nejlépe uprostřed měsíce od 16. dne hospodářem sdružení. Výsledkem bude, že pro daný měsíc všem členům podle jejich tarifu buden stržen členský příspěvek.',
'deduct_device_repayments' => 'Provede stržení splátek zařízení. Jedná se o zařízení, která si člen koupil od sdružení. Pokud ve vašem sdružení neprovádíte prodej zařízení na splátky, patrně tuto možnost nevyužijete.',
'device_admin_users_filter' => 'Umožnuje vyfiltrovat pouze zařízení určité uživatele. Ti jsou zapsané ve tvaru ID člena - jméno příjmení uživatele.',
'dns_servers' => 'Jedná se o DNS servery sdružení. Jednotlivé servery zapište na samostatný řádek.',
'engineer' => 'Technik, který provedl instalaci zařízení.',
'engineers' => 'Technici, kteří provedli instalaci, výměnu nebo opravu zařízení.',
'entrance_date' => 'Datum vstupu do sdružení. Se vstupem do sdružení je člen povinen platit členské příspěvky. V případě, že člen vstoupil do 15. dne v měsíci včetně, tak již tento měsíc se započítává k placení. Od 16. dne v měsíci se daný měsíc k placení nezapočítává.',
......
'set_whitelist_to_member' => 'Trvalá bílá listina je seznam takových IP adres, pro které neplatí přesměrování. Jde například o důležitou partnerskou instituci zapojenou do sítě, například městský úřad apod. Všechna systémová přesměrování tedy nemohou ve výchozím stavu obtěžovat počítače s IP adresou na bílé listině. Lze ovšem vytvořit takové zprávy, které budou ignorovat tuto listinu, např. informování o nadcházejícím výpadku. Pro dočasnou bílou listinu platí to samé, ale IP adresy v ní jsou po určeném čase z této listiny mazány. Např. uživatel byl přesměrován kvůli neplacení a chceme mu umožnit krátkodobý přístup na internet do internetového bankovnictví.',
'sms_enabled' => 'Určuje zda-li zasílání SMS zpráv ze systému do sítě tohoto operátora je povoleno.',
'ssh' => 'Klíč je použit pro přístup k zařízením, která spravuje tento uživatel.',
'subnet_dhcp' => 'Ukazatel, zda-li je na podsíti spuštěn DHCP server. Využívá se pro export zařízení.',
'subnet_owner' => 'IP adresy, jenž nejsou v systému, patřící do podsítě budou přiřazeni k tomuto členovi-vlastníkovi. Na tyto podsítě se tedy nevztahuje přesměrování Neznámé zařízení - neznámé IP adresy jsou přiřazeni k členovi.',
'subnet_qos' => 'Ukazatel, zda-li je na podsíti spuštěn QoS. Využívá se pro export zařízení.',
'subnet_used_ips' => 'Jedná se procentuální vyjádření využití IP adres v podsíti. Červené zbarvení značí docházející IP adresy, zelené pak nevyužitou podsít (zbytečně velká?).',
'syslog_ng_mysql_api' => 'Jedná se o jednoduché API pro načítání dat z syslog-ng daémona ukládajícího logy do MySQL databáze. Více infa <a href=http://dev.quimi.cz/projects/syslog-ng-mysql-api/wiki>zde</a>',
'syslog_ng_mysql_api_url' => 'URL adresa API pro zasílání požadavků, včetně jména a hesla ve tvaru http://URL?user=uživatel&password=heslo',
freenetis/branches/1.1/application/i18n/en_US/help.php
'deduct_member_fees' => 'Form appears, which offers a month and year to tear down the membership fee. Entrainment of membership fees is not automatic and must be carried out once a month, preferably in the middle of the 16th month of landlord associations. The result is that for a given month to all members according to their tariff driven demolished membership fee.',
'deduct_device_repayments' => 'Performs demolition equipment payments. It is a device that you bought from member associations. If your association do not carry on installment sale of equipment, probably will not use this option.',
'device_admin_users_filter' => 'Allows to filter out only certain user devices. They are written in the form of a member ID - name surname of user.',
'dns_servers' => 'It are dns servers of association. You should write each server to one line.',
'engineer' => 'Engineer, who has performed device installation.',
'engineers' => 'Engineers, who has performed installation, replacement or repair of device.',
'entrance_date' => 'Date of entry into the association. With the entry into the association is a member must pay membership dues. In the event that the member joined by 15 including the day of the month, and already this month is counted for payment. From 16 of the month is the month to pay not included.',
......
'set_whitelist_to_member' => 'Permanent white list is a list of such IP addresses for which it does not redirect. This is such an important partner institution involved in the network, such as municipal authorities, etc. Any diversion system is not in default bother computer with an IP address on the white list. But you can create a message that will ignore this list, such as informing of impending failure. For temporary whitelist does the same, but IP addresses in it after a specified time from the instrument clean. Eg. user was redirected due to non-payment and we want him to allow short-term Internet access to internet banking.',
'sms_enabled' => 'Specifies whether to send SMS messages from the system into a network of this operator is allowed.',
'ssh' => 'Key is used for accessing devices, which are administrated by this user.',
'subnet_dhcp' => 'Indicator whether there is a running dhcp server on this subnet. It is used for export of devices.',
'subnet_owner' => 'IP addresses, which are not in the system, belonging to a subnet will be assigned to the member-owner. These are therefore not subnet redirects Unknown device - unknown IP addresses are assigned to the member.',
'subnet_qos' => 'Indicator whether there is a running QoS on this subnet. It is used for export of devices.',
'subnet_used_ips' => 'This percentage of use of IP addresses in the subnet. Red coloration indicates incoming IP addresses, then the unused green subnet (too large?).',
'syslog_ng_mysql_api' => 'It is a simple API for loading of data from syslog-ng deamon which is storing logs into a MySQL database. More informations <a href=http://dev.quimi.cz/projects/syslog-ng-mysql-api/wiki>here</a>',
'syslog_ng_mysql_api_url' => 'URL address API for receiving of requests with loginnameand password http://URL?user=username&password=pass',
freenetis/branches/1.1/application/models/subnet.php
* @property string $network_address
* @property string $netmask
* @property integer $redirect
* @property integer $dhcp
* @property Subnets_owner_Model $subnets_owner
* @property ORM_Iterator $clouds
* @property ORM_Iterator $ip_addresses
......
FROM ip_addresses
WHERE subnet_id = s.id AND member_id IS NULL
)/((~inet_aton(s.netmask) & 0xffffffff)+1)*100,1),0) AS used,
m.id AS member_id, m.name AS member_name
m.id AS member_id, m.name AS member_name, dhcp, qos
FROM subnets s
LEFT JOIN subnets_owners so ON s.id = so.subnet_id
LEFT JOIN members m ON so.member_id = m.id
......
32-log2((~inet_aton(netmask) & 0xffffffff) + 1) AS subnet_range,
ip.ip_address, INET_NTOA(INET_ATON(ip.ip_address)+1) AS subnet_range_start,
INET_NTOA(INET_ATON(ip.ip_address)+(~inet_aton(netmask) & 0xffffffff)-2) AS subnet_range_end,
INET_NTOA(INET_ATON(ip.ip_address)+(~inet_aton(netmask) & 0xffffffff)-1) AS broadcast,
i.name AS iface
FROM ip_addresses ip
JOIN subnets s ON s.id = ip.subnet_id
freenetis/branches/1.1/application/models/ip_address.php
s.name AS subnet_name,
32-log2((~inet_aton(netmask) & 0xffffffff) + 1) AS subnet_range,
s.network_address AS subnet_network,
s.netmask AS subnet_netmask,
i.name AS iface_name
FROM ip_addresses ip
LEFT JOIN subnets s ON s.id = ip.subnet_id
......
SELECT ip.id, ip.id AS ip_address_id, ip.ip_address,
ip.gateway, d.name AS device_name, d.id AS device_id,
m.name AS member_name, m.id AS member_id, a.balance,
u.name AS user_name, u.surname AS user_surname, i.mac
u.name AS user_name, u.surname AS user_surname,
IFNULL(i.mac, pi.mac) AS mac
FROM ip_addresses ip
LEFT JOIN ifaces i ON ip.iface_id = i.id
LEFT JOIN ifaces_relationships ir ON ir.iface_id = i.id
LEFT JOIN ifaces pi ON ir.parent_iface_id = pi.id
LEFT JOIN devices d ON i.device_id = d.id
LEFT JOIN users u ON d.user_id = u.id
LEFT JOIN members m ON u.member_id = m.id
freenetis/branches/1.1/application/controllers/ifaces.php
->label('VLAN')
->options($vlan_ifaces)
->rules('required')
->style('width:200px');
->style('width:200px')
->add_button('vlans');
$vlan_form->dropdown('parent_iface_id')
->label('Parent interface')
freenetis/branches/1.1/application/controllers/subnets.php
->bool(arr::rbool())
->class('center');
$grid->order_callback_field('dhcp')
->label(__('DHCP'))
->callback('callback::boolean')
->class('center')
->help(help::hint('subnet_dhcp'));
$grid->order_callback_field('qos')
->label(__('QoS'))
->callback('callback::boolean')
->class('center')
->help(help::hint('subnet_qos'));
$grid->order_callback_field('used')
->label(__('Used'))
->callback('callback::used_field')
......
->options(arr::rbool())
->selected(0);
}
$form->dropdown('dhcp')
->label('DHCP server')
->help(help::hint('subnet_dhcp'))
->options(arr::rbool());
$form->dropdown('qos')
->label('QoS')
->help(help::hint('subnet_qos'))
->options(arr::rbool());
$form->dropdown('owner_id')
->label(__('Owner').' '.help::hint('subnet_owner'))
......
$subnet_model->network_address = $form_data['network_address'];
$subnet_model->netmask = $form_data['netmask'];
$subnet_model->OSPF_area_id = $form_data['OSPF_area_id'];
$subnet_model->dhcp = $form_data['dhcp'];
$subnet_model->qos = $form_data['qos'];
// redirect
if ($this->acl_check_new('Devices_Controller', 'redirect'))
......
->options(arr::rbool())
->selected($subnet_model->redirect);
}
$form->dropdown('dhcp')
->label('DHCP server')
->help(help::hint('subnet_dhcp'))
->options(arr::rbool())
->selected($subnet_model->dhcp);
$form->dropdown('qos')
->label('QoS')
->help(help::hint('subnet_qos'))
->options(arr::rbool())
->selected($subnet_model->qos);
$form->dropdown('owner_id')
->label(__('Owner').' '.help::hint('subnet_owner'))
......
$subnet_model->network_address = $form_data['network_address'];
$subnet_model->netmask = $form_data['netmask'];
$subnet_model->OSPF_area_id = $form_data['OSPF_area_id'];
$subnet_model->dhcp = $form_data['dhcp'];
$subnet_model->qos = $form_data['qos'];
if ($this->acl_check_edit('Devices_Controller', 'redirect'))
{
freenetis/branches/1.1/application/controllers/settings.php
->rules('valid_address_ranges')
->value(str_replace(",","\n", Settings::get('address_ranges')))
->class('autosize');
$this->form->textarea('dns_servers')
->help('dns_servers')
->rules('valid_address_ranges')
->value(str_replace(",","\n", Settings::get('dns_servers')))
->class('autosize');
$this->form->group('Module settings');
freenetis/branches/1.1/application/controllers/devices.php
if (!$device->id)
Controller::error(RECORD);
$result = array
(
'name' => $device->name,
'type' => $device->type,
'ifaces' => array
(
Iface_Model::TYPE_WIRELESS => array(),
Iface_Model::TYPE_ETHERNET => array(),
Iface_Model::TYPE_PORT => array(),
Iface_Model::TYPE_BRIDGE => array(),
Iface_Model::TYPE_VLAN => array(),
Iface_Model::TYPE_INTERNAL => array(),
Iface_Model::TYPE_VIRTUAL_AP => array()
),
'ip_addresses' => array(),
'gateways' => array()
);
foreach ($device->ifaces as $iface)
{
$result['ifaces'][$iface->type][$iface->name] = array
(
'mac' => $iface->mac,
'number' => $iface->number,
);
if ($iface->type == Iface_Model::TYPE_WIRELESS)
{
$result['ifaces'][$iface->type][$iface->name]['wireless'] = array
(
'mode' => $iface->wireless_mode,
'ssid' => $iface->link->wireless_ssid,
'norm' => $iface->link->wireless_norm,
'frequency' => $iface->link->wireless_norm,
'channel' => $iface->link->wireless_norm,
'channel_width' => $iface->link->wireless_norm,
'polarization' => $iface->link->wireless_norm,
'bitrate' => $iface->link->bitrate
);
if ($iface->wireless_mode == Iface_Model::WIRELESS_MODE_AP)
{
$result['ifaces'][$iface->type][$iface->name]['wireless']['clients'] = array();
foreach ($iface->link->ifaces as $link_iface)
{
if ($link_iface->id == $iface->id)
continue;
$result['ifaces'][$iface->type][$iface->name]['wireless']['clients'][] = array
(
'name' => $link_iface->name,
'mac' => $link_iface->mac,
'device_name' => $link_iface->device->name,
'device_type' => $link_iface->device->type,
'member_id' => $link_iface->device->user->member->id,
'member_name' => $link_iface->device->user->member->name,
'member_type' => $link_iface->device->user->member->type,
);
}
}
}
foreach ($iface->ip_addresses as $ip_address)
{
$result['ip_addresses'][] = array
(
'ip_address' => $ip_address->ip_address,
'iface' => $iface->name
);
}
}
debug::printr($result);
die();
// definition of models
$subnet_model = new Subnet_Model();
$ip_address_model = new Ip_address_Model();
......
$device_model = new Device_Model();
// definition of array for data
$device_ifaces = array
$device_ifaces = array
(
Iface_Model::TYPE_WIRELESS => array(),
Iface_Model::TYPE_ETHERNET => array(),
......
$device_wireless_iface_devices = array();
$device_ip_addresses = array();
$device_subnets = array();
$device_subnet_ip_addresses = array();
$device_gateways = array();
$devices_members = array();
$device_members = array();
$dhcp_subnets = array();
$dhcp_ip_addresses = array();
$qos_subnets = array();
$qos_ip_addresses = array();
// devices's interfaces
$ifaces = $iface_model->get_all_ifaces_of_device($device->id);
foreach ($ifaces as $iface)
{
$device_ifaces[$iface->type][] = $iface;
$device_ifaces[$iface->type][$iface->name] = $iface;
if ($iface->type == Iface_Model::TYPE_WIRELESS)
{
......
$gateway = $ip_address_model->get_gateway_of_subnet($subnet->id);
if ($gateway)
$device_gateways[] = $gateway->ip_address;
$device_gateways[$gateway->subnet_id] = $gateway->ip_address;
}
$device_subnets[$subnet->id] = $subnet;
// there is dhcp server on this subnet
if ($subnet->gateway && $subnet->dhcp)
$dhcp_subnets[$subnet->id] = $subnet;
// there is a qos on this subnet
if ($subnet->gateway && $subnet->qos)
$qos_subnets[$subnet->id] = $subnet;
$mac_addresses = array();
$dhcp_ip_addresses[$subnet->id] = array();
$ip_addresses = $ip_address_model->get_ip_addresses_of_subnet($subnet->id);
foreach ($ip_addresses as $ip_address)
{
......
{
$mac_addresses[] = $ip_address->mac;
$device_subnet_ip_addresses[$subnet->id][$ip_address->id] = $ip_address;
if (!isset($device_members[$ip_address->member_id]))
$device_members[$ip_address->member_id] = $ip_address->member_name;
if ($subnet->dhcp)
$dhcp_ip_addresses[$subnet->id][$ip_address->id] = $ip_address;
if ($subnet->qos)
$qos_ip_addresses[$subnet->id][$ip_address->member_id][] = $ip_address->ip_address;
}
}
}
......
$form->dropdown('format')
->options(array
(
'mikrotik' => 'Mikrotik'
'debian-etc-dhcp-dhcpd' => 'Debian /etc/dhcp/dhcpd.conf',
'debian-etc-network-interfaces' => 'Debian /etc/network/interfaces',
'mikrotik' => 'Mikrotik',
));
// subnets on which is dhcp server running
$form->dropdown('dhcp_subnets[]')
->label('Subnets with DHCP')
->options($subnets_options)
->selected($subnets_selected)
->size(20)
->multiple('multiple');
// subnets to QoS
$form->dropdown('qos_subnets[]')
->label('Subnets to QoS')
->options($subnets_options)
->selected($subnets_selected)
->size(20)
->multiple('multiple');
// IP addresses of DNS servers
$form->input('dns_servers')
->rules('required|valid_address_ranges');
// result format - text or file
$form->dropdown('download_as')
->options(array
......
{
$form_data = $form->as_array();
$dhcp_subnets = array();
$dhcp_ip_addresses = array();
if (is_array($form_data['dhcp_subnets']))
{
foreach ($form_data['dhcp_subnets'] as $subnet_id)
{
if (isset($device_subnets[$subnet_id]))
{
$dhcp_subnets[$subnet_id] = $device_subnets[$subnet_id];
$dhcp_ip_addresses[$subnet_id] = isset($device_subnet_ip_addresses[$subnet_id]) ? $device_subnet_ip_addresses[$subnet_id] : array();
}
}
}
$qos_ifaces = array();
$qos_subnets = array();
$qos_ip_addresses = array();
if (is_array($form_data['qos_subnets']))
{
foreach ($form_data['qos_subnets'] as $subnet_id)
{
if (isset($device_subnets[$subnet_id]))
{
$qos_subnets[$subnet_id] = $device_subnets[$subnet_id];
$qos_ip_addresses[$subnet_id] = array();
if (isset($device_subnet_ip_addresses[$subnet_id]))
{
foreach ($device_subnet_ip_addresses[$subnet_id] as $device_ip_address)
$qos_ip_addresses[$subnet_id][$device_ip_address->member_id][] = $device_ip_address->ip_address;
}
}
}
}
if ($form_data['download_as'] == 'file')
{
switch ($form_data["format"])
......
$view->device_ip_addresses = $device_ip_addresses;
$view->device_gateways = $device_gateways;
$view->device_wireless_iface_devices = $device_wireless_iface_devices;
$view->dns_servers = $form_data["dns_servers"];
$view->dns_servers = explode("\n", Settings::get('dns_servers'));
$view->render(TRUE);
}
else
freenetis/branches/1.1/application/views/subnets/show.php
<td><?php echo ($subnet->redirect == 1) ? __('Yes') : __('No') ?></td>
</tr>
<tr>
<th><?php echo __('DHCP server') ?> <?php echo help::hint('subnet_dhcp') ?></th>
<td><?php echo ($subnet->dhcp == 1) ? __('Yes') : __('No') ?></td>
</tr>
<tr>
<th><?php echo __('QoS') ?> <?php echo help::hint('subnet_qos') ?></th>
<td><?php echo ($subnet->qos == 1) ? __('Yes') : __('No') ?></td>
</tr>
<tr>
<th><?php echo __('Cloud') ?></th>
<td>
<?php
freenetis/branches/1.1/application/views/device_templates/mikrotik.php
add address=<?php echo $device_ip_address->ip_address ?>/<?php echo $device_ip_address->subnet_range ?> disabled=no interface="<?php echo $device_ip_address->iface_name !='' ? $device_ip_address->iface_name : $device_ip_address->vlan_iface_name ?>" network=<?php echo $device_ip_address->subnet_network ?>
<?php endforeach ?>
/ip dns
set allow-remote-requests=yes servers=<?php echo $dns_servers ?>
set allow-remote-requests=yes servers=<?php echo implode(", ",$dns_servers) ?>
/ip pool
<?php foreach ($dhcp_subnets as $dhcp_subnet): ?>
add name="<?php echo $dhcp_subnet->iface ?>" ranges=<?php echo $dhcp_subnet->subnet_range_start ?>-<?php echo $dhcp_subnet->subnet_range_end ?>
<?php endforeach ?>
/ip dhcp-server
<?php foreach ($dhcp_subnets as $dhcp_subnet): ?>
add address-pool="<?php $dhcp_subnet->iface ?>" authoritative=after-2sec-delay bootp-support=static disabled=no interface="<?php echo $dhcp_subnet->iface ?>" lease-time=3d name="<?php echo $dhcp_subnet->iface ?>"
add address-pool="<?php echo $dhcp_subnet->iface ?>" authoritative=after-2sec-delay bootp-support=static disabled=no interface="<?php echo $dhcp_subnet->iface ?>" lease-time=3d name="<?php echo $dhcp_subnet->iface ?>"
<?php endforeach ?>
/ip dhcp-server config
set store-leases-disk=5m
freenetis/branches/1.1/version.php
* The current version of FreenetIS.
* This value must be changed by developers in a new release of FreenetIS.
*/
define('FREENETIS_VERSION', '1.1.0~alpha1');
define('FREENETIS_VERSION', '1.1.0~alpha2');

Také k dispozici: Unified diff