client-side validation

This commit is contained in:
Roland Gruber 2011-10-20 16:43:42 +00:00
parent a6afeb530b
commit 48348bafba
2 changed files with 17 additions and 9 deletions

View File

@ -4,7 +4,7 @@ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2008 Thomas Manninger Copyright (C) 2008 Thomas Manninger
2008 - 2010 Roland Gruber 2008 - 2011 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -346,7 +346,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I
elseif (!check_ip($_POST['cn'],true)) { elseif (!check_ip($_POST['cn'],true)) {
$errors[] = $this->messages['cn'][2]; $errors[] = $this->messages['cn'][2];
} }
elseif (array_pop(explode(".", $_POST['cn']))!=0) { elseif (strrpos($_POST['cn'], '.0') != (strlen($_POST['cn']) - 2)) {
$errors[] = $this->messages['cn'][2]; $errors[] = $this->messages['cn'][2];
} }
else { else {
@ -523,9 +523,13 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I
// domain name // domain name
$return->addElement(new htmlTableExtendedInputField(_('Domain name'), 'domainname', $this->getDHCPOption('domain-name'), 'domainname'), true); $return->addElement(new htmlTableExtendedInputField(_('Domain name'), 'domainname', $this->getDHCPOption('domain-name'), 'domainname'), true);
// lease Time // lease Time
$return->addElement(new htmlTableExtendedInputField(_('Lease time'), 'lease_time', $this->getDefaultLeaseTime(), 'leasetime'), true); $leasetimeInput = new htmlTableExtendedInputField(_('Lease time'), 'lease_time', $this->getDefaultLeaseTime(), 'leasetime');
$leasetimeInput->setValidationRule(htmlElement::VALIDATE_NUMERIC);
$return->addElement($leasetimeInput, true);
// max lease time // max lease time
$return->addElement(new htmlTableExtendedInputField(_('Maximum lease time'), 'max_lease_time', $this->getMaxLeaseTime(), 'max_leasetime'), true); $max_leasetimeInput = new htmlTableExtendedInputField(_('Maximum lease time'), 'max_lease_time', $this->getMaxLeaseTime(), 'max_leasetime');
$max_leasetimeInput->setValidationRule(htmlElement::VALIDATE_NUMERIC);
$return->addElement($max_leasetimeInput, true);
// DNS // DNS
$return->addElement(new htmlTableExtendedInputField(_('DNS'), 'dns', $this->getDHCPOption('domain-name-servers'), 'dns'), true); $return->addElement(new htmlTableExtendedInputField(_('DNS'), 'dns', $this->getDHCPOption('domain-name-servers'), 'dns'), true);
// gateway // gateway

View File

@ -4,7 +4,7 @@ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2008 Thomas Manninger Copyright (C) 2008 Thomas Manninger
2008 - 2010 Roland Gruber 2008 - 2011 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -205,13 +205,17 @@ class fixed_ip extends baseModule {
if ($this->getAccountContainer()->dn_orig!=$_SESSION['config']->get_suffix('dhcp')) { if ($this->getAccountContainer()->dn_orig!=$_SESSION['config']->get_suffix('dhcp')) {
$entries = searchLDAP($this->getAccountContainer()->dn_orig, '(objectClass=dhcpHost)', array('cn', 'dhcphwaddress', 'dhcpstatements')); $entries = searchLDAP($this->getAccountContainer()->dn_orig, '(objectClass=dhcpHost)', array('cn', 'dhcphwaddress', 'dhcpstatements'));
for ($i=0; $i < sizeof($entries); $i++) { for ($i=0; $i < sizeof($entries); $i++) {
$dhcphwaddress = explode(" ", $entries[$i]['dhcphwaddress'][0]);
$dhcphwaddress = array_pop($dhcphwaddress);
$dhcpstatements = explode(" ", $entries[$i]['dhcpstatements'][0]);
$dhcpstatements = array_pop($dhcpstatements);
$this->fixed_ip[$i]['cn'] = $entries[$i]['cn'][0]; $this->fixed_ip[$i]['cn'] = $entries[$i]['cn'][0];
$this->fixed_ip[$i]['mac'] = array_pop(explode(" ", $entries[$i]['dhcphwaddress'][0])); $this->fixed_ip[$i]['mac'] = $dhcphwaddress;
$this->fixed_ip[$i]['ip'] = array_pop(explode(" ", $entries[$i]['dhcpstatements'][0])); $this->fixed_ip[$i]['ip'] = $dhcpstatements;
$this->orig_ips[$i]['cn'] = $entries[$i]['cn'][0]; $this->orig_ips[$i]['cn'] = $entries[$i]['cn'][0];
$this->orig_ips[$i]['mac'] = array_pop(explode(" ", $entries[$i]['dhcphwaddress'][0])); $this->orig_ips[$i]['mac'] = $dhcphwaddress;
$this->orig_ips[$i]['ip'] = array_pop(explode(" ", $entries[$i]['dhcpstatements'][0])); $this->orig_ips[$i]['ip'] = $dhcpstatements;
} }
} }
} }