Revize 488
Přidáno uživatelem Michal Kliment před asi 15 roky(ů)
freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'member has been successfully updated' => 'Člen byl úspěšně upraven.',
|
||
'member id' => 'ID člena',
|
||
'member name' => 'Jméno člena (organizace)',
|
||
'member_name' => 'Jméno člena (organizace)',
|
||
'member_name' => 'Jméno člena (organizace)',
|
||
'member not found' => 'Člen nenalezen',
|
||
'members account' => 'Účet člena',
|
||
'members' => 'Členové',
|
||
'membership can be ended only to former member' => 'Členství může být ukončeno jen bývalému členovi.',
|
freenetis/trunk/kohana/application/controllers/ip_addresses.php | ||
---|---|---|
$this->form->dropdown('subnet_id')->label(url_lang::lang('texts.Select subnet name').':')
|
||
->options($arr_subnets)
|
||
->rules('required');
|
||
//->class('ajax')->onchange('ajax_get_subnet(this.value)');
|
||
//->class('ajax')->onchange('ajax_get_subnet(this.value)');
|
||
|
||
$this->form->checkbox('gateway')->label(url_lang::lang('texts.Gateway'))->checked(false);
|
||
|
||
/**
|
||
* Removed by dulik for SVN rev. 98 - does not work with JavaScript disabled
|
||
* @todo Proper Ajax should be implemented - see http://learn.kohanaphp.com/2008/06/17/jquery-and-kohana-unobtrusive-ajax/
|
||
... | ... | |
$ip->vlan_iface_id = $form_data['vlan_iface_id'];
|
||
$ip->ip_address = $form_data['ip_address'];
|
||
$ip->subnet_id = $form_data['subnet_id'];
|
||
$ip->gateway = $form_data['gateway'];
|
||
unset($form_data);
|
||
if ($ip->save())
|
||
{
|
||
... | ... | |
$this->form->dropdown('subnet_id')->label(url_lang::lang('texts.Select subnet name').':')
|
||
->options($arr_subnets)
|
||
->rules('required');
|
||
|
||
$this->form->checkbox('gateway')->label(url_lang::lang('texts.Gateway'))->checked(false);
|
||
|
||
$this->form->submit('submit')->value(url_lang::lang('texts.Save'));
|
||
special::required_forge_style($this->form, ' *', 'required');
|
||
... | ... | |
$ip->iface_id = $form_data['iface_id'];
|
||
$ip->ip_address = $form_data['ip_address'];
|
||
$ip->subnet_id = $form_data['subnet_id'];
|
||
|
||
$ip->gateway = $form_data['gateway'];
|
||
unset($form_data);
|
||
|
||
if ($ip->save())
|
||
... | ... | |
$this->form->dropdown('subnet_id')->label(url_lang::lang('texts.Select subnet name').':')
|
||
->options($arr_subnets)
|
||
->rules('required');
|
||
|
||
$this->form->checkbox('gateway')->label(url_lang::lang('texts.Gateway'))->checked(false);
|
||
|
||
$this->form->submit('submit')->value(url_lang::lang('texts.Save'));
|
||
special::required_forge_style($this->form, ' *', 'required');
|
||
... | ... | |
$ip->vlan_iface_id = $form_data['vlan_iface_id'];
|
||
$ip->ip_address = $form_data['ip_address'];
|
||
$ip->subnet_id = $form_data['subnet_id'];
|
||
$ip->gateway = $form_data['gateway'];
|
||
|
||
unset($form_data);
|
||
|
||
... | ... | |
$this->form->dropdown('subnet_id')->label(url_lang::lang('texts.Select subnet name').':')
|
||
->options($arr_subnets)->selected($ip_address->subnet_id)
|
||
->rules('required');
|
||
|
||
$this->form->checkbox('gateway')->label(url_lang::lang('texts.Gateway'))->checked($ip_address->gateway);
|
||
|
||
$this->form->submit('submit')->value(url_lang::lang('texts.Save'));
|
||
special::required_forge_style($this->form, ' *', 'required');
|
||
... | ... | |
$ip->ip_address = $form_data['ip_address'];
|
||
|
||
$ip->subnet_id = $form_data['subnet_id'];
|
||
|
||
$ip->gateway = $form_data['gateway'];
|
||
|
||
unset($form_data);
|
||
|
freenetis/trunk/kohana/application/controllers/devices.php | ||
---|---|---|
if ($this->acl_check_new(get_class($this),'devices'))
|
||
$grid->add_new_button(url_lang::base().'devices/add', url_lang::lang('texts.Add new device'));
|
||
if ($this->acl_check_new(get_class($this),'devices'))
|
||
$grid->add_new_button(url_lang::base().'devices/import_mikrotik_export', url_lang::lang('texts.Import from Mikrotik export'));
|
||
$grid->add_new_button(url_lang::base().'devices/import_dhcp_export_from_mikrotik', url_lang::lang('texts.Import DHCP export from Mikrotik'));
|
||
$grid->order_field('id')->label('ID')->class('center');
|
||
$grid->order_field('name')->label(url_lang::lang('texts.name'));
|
||
$grid->order_field('type')->label(url_lang::lang('texts.type'));
|
||
... | ... | |
url::redirect($linkback);
|
||
}
|
||
|
||
|
||
function import_mikrotik_export()
|
||
/**
|
||
* @author Michal Kliment
|
||
* Function to synchronize freenetis with mikrotik's routers
|
||
*/
|
||
function import_dhcp_export_from_mikrotik()
|
||
{
|
||
// if form is posted
|
||
|
||
... | ... | |
$parser = new Parser_Mikrotik();
|
||
$parser->header_end = '/ip dhcp-server lease';
|
||
$parser->set_callback(array(get_class($this),'synchronize_device'));
|
||
|
||
|
||
$parser->parse($filename);
|
||
die();
|
||
}
|
||
... | ... | |
$view->content = new View('devices_import');
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
|
||
/**
|
||
* @author Michal Kliment
|
||
* Function to get member_ID from comment
|
||
*/
|
||
function synchronize_device($device)
|
||
{
|
||
$member_id = Devices_Controller::get_ID_from_comment($device->comment);
|
||
... | ... | |
// ip adress already exists
|
||
if ($ip_address->id)
|
||
{
|
||
//mac address is different
|
||
// ckecks if ip address belongs to some iface
|
||
// if it doesn't creates new iface with device
|
||
if (!$ip_address->iface_id)
|
||
{
|
||
$device_model->clear();
|
||
$device_model->user_id = $user->id;
|
||
$device_model->address_point_id = $member->address_point_id;
|
||
$device_model->name = $user->login."_pc";
|
||
$device_model->type = $enum_type_model->get_type_id('pc');
|
||
$device_model->comment = 'Import';
|
||
$device_model->save();
|
||
|
||
$device_add ++;
|
||
|
||
$ip_address->vlan_iface_id = NULL;
|
||
$ip_address->iface = $iface_model->clear();
|
||
$ip_address->iface->device_id = $device_model->id;
|
||
}
|
||
|
||
//mac address is different
|
||
if ($device->mac_address != $ip_address->iface->mac)
|
||
{
|
||
$ip_address->iface->segment_id = $ip_address->subnet->segment_id;
|
||
$ip_address->iface->mac = $device->mac_address;
|
||
$ip_address->iface->save();
|
||
}
|
||
... | ... | |
}
|
||
// remote ip address belongs to some subnet
|
||
$subnet_id = count($arr_subnets) ? $arr_subnets[0]->id : NULL;
|
||
$subnet = new Subnet_Model($subnet_id);
|
||
$gateway = $ip_address_model->where(array('subnet_id' => $subnet_id, 'gateway' => 1))->find();
|
||
|
||
$segment_id = ($gateway && $gateway->id && $gateway->iface_id) ? $gateway->iface->segment_id : NULL;
|
||
|
||
$device_model->clear();
|
||
$device_model->user_id = $user->id;
|
||
$device_model->address_point_id = $member->address_point_id;
|
||
... | ... | |
|
||
$iface_model->clear();
|
||
$iface_model->device_id = $device_model->id;
|
||
$iface_model->segment_id = $subnet->segment_id;
|
||
$iface_model->segment_id = $segment_id;
|
||
$iface_model->mac = $device->mac_address;
|
||
$iface_model->name = $user->login."_pc";
|
||
$iface_model->save();
|
||
|
||
$ip_address_model->clear();
|
||
$ip_address_model->iface_id = $iface_model->id;
|
||
$ip_address_model->subnet_id = $subnet->id;
|
||
$ip_address_model->subnet_id = $subnet_id;
|
||
$ip_address_model->ip_address = $device->address;
|
||
$ip_address_model->save();
|
||
|
||
... | ... | |
}
|
||
else
|
||
{
|
||
echo "Clen nenalezen - (".$device->comment.")<br />";
|
||
echo url_lang::lang('texts.Member not found.').": ".$device->comment."<br />";
|
||
}
|
||
|
||
}
|
freenetis/trunk/kohana/application/libraries/Parser_Mikrotik.php | ||
---|---|---|
else
|
||
{
|
||
$str .= ' '. $segment;
|
||
if (strpos($segment,'"'))
|
||
if (strpos($segment,'"')!==false)
|
||
{
|
||
$segment = $str;
|
||
$str = '';
|
||
... | ... | |
}
|
||
else
|
||
{
|
||
if (strpos($segment,'"'))
|
||
{
|
||
$str = $segment;
|
||
}
|
||
else $str = '';
|
||
if ($str != '')
|
||
{
|
||
$str .= ' '.$segment;
|
||
if (strpos($segment,'"')!==false)
|
||
{
|
||
$segment = $str;
|
||
$str = '';
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (strpos($segment,'"')!==false)
|
||
{
|
||
$str = $segment;
|
||
}
|
||
else $str = '';
|
||
}
|
||
}
|
||
|
||
if ($str == '')
|
||
{
|
||
//echo "$segment<br />";
|
||
list($key,$value) = explode("=",$segment,2);
|
||
$key = $this->remove_dashes($key);
|
||
$result->$key = $this->remove_quotes($value);
|
Také k dispozici: Unified diff
Vyladeny chyby na skriptu pro synchronizaci Freenetisu s mikrotiky.