initial commit of file from CVS for smeserver-dhcpmanager on Sat Sep 7 19:51:44 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 19:51:44 +10:00
parent c74767858a
commit f510f789c6
49 changed files with 12045 additions and 2 deletions

View File

@@ -0,0 +1,704 @@
package SrvMngr::Controller::Dhcpd;
#----------------------------------------------------------------------
# heading : Network
# description : DHCP manager
# navigation : 6000 550
#
# name : dhcpd, method : get, url : /dhcpd, ctlact : Dhcpd#main
# name : dhcpd1, method : get, url : /dhcpd1, ctlact : Dhcpd#do_leases
# name : dhcpd2, method : get, url : /dhcpd2, ctlact : Dhcpd#do_winpopup
# name : dhcpd3, method : get, url : /dhcpd3, ctlact : Dhcpd#do_scan
# name : dhcpd4, method : get, url : /dhcpd4, ctlact : Dhcpd#do_delete_all_leases
# name : dhcpd5, method : post, url : /dhcpd5, ctlact : Dhcpd#do_update_config
# name : dhcpd6, method : get, url : /dhcpd6, ctlact : Dhcpd#do_delete_one_lease
# name : dhcpd7, method : get, url : /dhcpd7, ctlact : Dhcpd#do_refresh_leases
# name : dhcpd8, method : get, url : /dhcpd8, ctlact : Dhcpd#do_winpopup
# name : dhcpd9, method : get, url : /dhcpd9, ctlact : Dhcpd#do_wol
# name : dhcpd10, method : post, url : /dhcpd10, ctlact : Dhcpd#do_update_check
#
# routes : end
#
#
# Documentation: https://wiki.koozali.org/Dhcpmanager
#
use strict;
use warnings;
use Mojo::Base 'Mojolicious::Controller';
use constant FALSE => 0;
use constant TRUE => 1;
use Locale::gettext;
use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session);
use Data::Dumper;
use esmith::util;
use esmith::HostsDB;
use esmith::AccountsDB;
use Net::Ping;
use esmith::util::network qw(:all);
use Socket qw( inet_aton );
#our $adb = esmith::AccountsDB->open() or die("Unable to open accounts DB");
my %dhcp_data = ();
sub main {
#
# Initial page - full summary of parameters etc
# Initial para from the Wiki.
#
my $c = shift;
%dhcp_data = ();
do_display($c);
}
sub do_display {
#
# Front parameters page
#
my $c = shift;
$c->app->log->info( $c->log_req );
my $title = $c->l("dhcpd_DHCP manager");
my $modul = '';
my $trt = "SETTINGS";
our $db = esmith::ConfigDB->open() or die("Unable to open Configuration DB");
our %sme_conf = $db->get('dhcpd')->props;
our %smb_conf = $db->get('smb')->props;
$dhcp_data{trt} = $trt;
$dhcp_data{"status"} = [[$c->l('dhcpd_ENABLED'),'enabled'],
[$c->l('dhcpd_DISABLED'),'disabled']
];
$dhcp_data{"check"} = [[$c->l('dhcpd_ENABLED'),'enabled'],
[$c->l('dhcpd_DISABLED'),'disabled']
];
if (! $sme_conf{'winscustom'} ) {
$sme_conf{'winscustom'} = 'disabled' ;
}
if (! $sme_conf{'dnscustom'} ) {
$sme_conf{'dnscustom'} = 'disabled' ;
}
if ( ! $sme_conf{'leasetime'} )
{ $sme_conf{'leasetime'} = "86400" ;
}
if (! $sme_conf{'gatewaycustom'} ) {
$sme_conf{'gatewaycustom'} = 'disabled' ;
}
# Accumulate parameters for Configuration DB
$dhcp_data{'params'} = \%sme_conf;
$dhcp_data{'smbparams'} = \%smb_conf;
$c->stash( title => $title,
modul => $modul,
dhcp_data => \%dhcp_data
);
#die("here");
$c->render( template => 'dhcpd' );
}
sub do_leases {
#
# Show a table of the leases
#
my $c = shift;
my $title = $c->l("dhcpd_MANAGING_DHCP_CLIENT");
my $modul = '';
my $trt = "LEASES";
$dhcp_data{"check"} = [[$c->l('dhcpd_ENABLED'),'enabled'],
[$c->l('dhcpd_DISABLED'),'disabled']
];
$dhcp_data{trt} = $trt;
$dhcp_data{"first"} = '';
my @leases = get_leases_in_array($c);
$c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data, leases=> \@leases );
$c->render( template => 'dhcpd' );
}
sub do_winpopup {
#
# call to win pop up
#
my $c = shift;
my $title = $c->l("dhcpd_GLOBAL_WINPOPUP");
my $modul = '';
my $trt = "WINPOPUP";
$dhcp_data{trt} = $trt;
$dhcp_data{"first"} = '';
#..... get winpopup details
$c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data );
$c->render( template => 'dhcpd' );
}
sub do_scan {
#
# call to show scan results
#
my $c = shift;
my $title = $c->l("dhcpd_SCANNING_NETWORK_TITLE");
my $modul = '';
my $trt = "SCAN";
$dhcp_data{trt} = $trt;
$dhcp_data{"first"} = '';
# ..... get scan results into stash for passing to html template
my $dhcp_scanresults = get_scan_results($c);
$c->stash( title => $title, modul => $modul, "dhcp_data" => \%dhcp_data, "scanresults" => $dhcp_scanresults);
$c->render( template => 'dhcpd' );
}
sub do_update_config {
#
# Update config dhcp parameters
# called through form submit.
#
my $c = shift;
# Input results are in $c->param(<fieldname>).
# If parameters do not validate, then return error message.
# else write into config DB, and...
# signal-event and ...return ok
$dhcp_data{"success"} ="";
my $ret = Main_Save($c);
if ($ret eq 'ok') {
$dhcp_data{"success"}="dhcpd_SUCCESSFULLY_SAVED_SETTINGS";
} else {
$dhcp_data{"error"}=$ret;
}
do_display($c);
return;
}
sub do_update_check {
#Just update the check parameter
my $c = shift;
my $dhcpd_check = $c->param ('dhcp_check');
###Update SME configuration dbase
my $dbh_sme = esmith::ConfigDB->open('/home/e-smith/db/configuration');
##Initiate get method --> create record object
my $sme_record = $dbh_sme->get('dhcpd');
$sme_record->set_prop('check' , $dhcpd_check);
$dhcp_data{"success"}="dhcpd_SUCCESSFULLY_SAVED_SETTINGS";
do_display($c);
return;
}
sub Main_Save ($){
##Pull CGI object from parameters array
my $q = shift;
###Build Hash of config parameters to update from cgi submit
my $dhcpd_status = $q->param ('dhcp_enable');
my $dhcpd_winscustom = $q->param ('dhcp_winscustom');
my $dhcpd_check = $q->param ('dhcp_check');
my $dhcpd_start = $q->param ('dhcp_start');
my $dhcpd_end = $q->param ('dhcp_end');
my $dhcpd_winsserver = $q->param ('dhcp_winsserver');
my $dhcpd_leasetime = $q->param ('dhcp_leasetime');
my $dhcpd_dnscustom = $q->param ('dhcp_dnscustom');
my $dhcpd_dns1server = $q->param ('dhcp_dns1server');
my $dhcpd_dns2server = $q->param ('dhcp_dns2server');
my $dhcpd_dns3server = $q->param ('dhcp_dns3server');
my $dhcpd_gatewaycustom = $q->param ('dhcp_gatewaycustom');
my $dhcpd_gateway = $q->param ('dhcp_gateway');
###Update SME configuration dbase
my $dbh_sme = esmith::ConfigDB->open('/home/e-smith/db/configuration');
##Initiate get method --> create record object
my $sme_record = $dbh_sme->get('dhcpd');
#get localip of server
my $local_ip = $dbh_sme->get_value('LocalIP');
##Set status of service
$sme_record->set_prop('status', $dhcpd_status);
$sme_record->set_prop('check' , $dhcpd_check);
$sme_record->set_prop('winscustom', $dhcpd_winscustom);
$sme_record->set_prop('leasetime' , $dhcpd_leasetime);
$sme_record->set_prop('dnscustom' , $dhcpd_dnscustom);
$sme_record->set_prop('gatewaycustom' , $dhcpd_gatewaycustom);
#checkip to the dhcpserver, perform the save in DB configuration or display an error if value != of a valid ip or if dhcp_start is greater than dhcp_end
if ($dhcpd_status eq "enabled")
{
if ( isValidIP ($dhcpd_start) && isValidIP ($dhcpd_end))
{
#check if $dhcpd_start is greater than $dhcpd_end and if yes, display an error message.
if (inet_aton($dhcpd_start) ge inet_aton($dhcpd_end))
{
return $q->l('dhcpd_DHCP_START_GREATER_DHCP_END_ERRORS') . ' (' . $dhcpd_start . '/' . $dhcpd_end .')';
}
elsif ( ( (inet_aton($dhcpd_start) le inet_aton($local_ip) ) && ( inet_aton($dhcpd_end)) ge inet_aton($local_ip) ) )
{
#display an error if the range of dhcp server include the ip of the server address
return $q->l('dhcpd_DHCP_RANGE_MUST_NOT_INCLUDE_SERVER_IP') . ' (' . $local_ip . ')';
}
else
{
#set value
my $dhcpd_start = cleanIP($dhcpd_start);
my $dhcpd_end = cleanIP($dhcpd_end);
$sme_record->set_prop('end', $dhcpd_end);
$sme_record->set_prop('start', $dhcpd_start);
}
}
#if $dhcpd_start or $dhcpd_end are not valid ip then display an error
else
{
return $q->l('dhcpd_DHCP_RANGE_WITH_BAD_IP') . ' (' . $dhcpd_start . '/' . $dhcpd_end .')';
}
}
#checkip to the winserver perform the save in DB configuration or display an error if value != of a valid ip
if ($dhcpd_winscustom eq "enabled")
{
if ( isValidIP ($dhcpd_winsserver) )
{
#set value
my $dhcpd_winsserver = cleanIP($dhcpd_winsserver);
$dbh_sme->set_prop('smb','WINSServer', $dhcpd_winsserver);
}
else
{
#if $dhcpd_winsserver is not valid ip then display an error
return $q->l('dhcpd_WINSSERVER_BAD_IP') . ' (' . $dhcpd_winsserver .')';
}
}
elsif ($dhcpd_winscustom eq "disabled")
{
my $delws = $dbh_sme->get('smb');
$delws->delete_prop('WINSServer');
}
#checkip to the dnsserver custom, perform the save in DB configuration or display an error if value != of a valid ip
if ($dhcpd_dnscustom eq "enabled")
{
#check if $dhcpd_dns1server and ( $dhcpd_dns2server are valid ip or $dhcpd_dns2server = null )
if ( isValidIP ($dhcpd_dns1server) && (isValidIP($dhcpd_dns2server) || ( $dhcpd_dns2server eq "") ) && (isValidIP($dhcpd_dns3server) || ( $dhcpd_dns3server eq "") ) )
{
#set value
my $dhcpd_dns1server = cleanIP($dhcpd_dns1server);
$sme_record->set_prop('dns1server' , $dhcpd_dns1server);
my $dhcpd_dns2server = cleanIP($dhcpd_dns2server);
$sme_record->set_prop('dns2server' , $dhcpd_dns2server);
my $dhcpd_dns3server = cleanIP($dhcpd_dns3server);
$sme_record->set_prop('dns3server' , $dhcpd_dns3server);
}
else
{
##if $dhcpd_dns1server or $dhcpd_dns2server or $dhcpd_dns3server are not valid ip then display an error
return $q->l('dhcpd_DNS_SERVER_WITH_BAD_IP') . ' (' . $dhcpd_dns1server . '/' . $dhcpd_dns2server . '/' . $dhcpd_dns3server .')';
}
}
#checkip to the gateway_custom perform the save in DB configuration or display an error if value != of a valid ip
if ($dhcpd_gatewaycustom eq "enabled")
{
if ( isValidIP ($dhcpd_gateway) )
{
#set value
my $dhcpd_gateway = cleanIP($dhcpd_gateway);
$sme_record->set_prop('gateway' , $dhcpd_gateway);
}
else
{
#if $dhcpd_gateway is not valid ip then display an error
return $q->l('dhcpd_GATEWAY_BAD_IP') . ' (' . $dhcpd_gateway .')';
}
}
# - 4 expand templates
# changed to new sme standard signal-event
system ("/sbin/e-smith/signal-event","workgroup-update") == 0
or die "Error while saving settings: $!";
return 'ok';
exit;
}
sub do_delete_all_leases {
#
# Delete all the specified lease
# Called from button at top of leases list panel
#
my $c = shift;
my $ret = delete_all_leases($c);
if ($ret == 'ok') {
$dhcp_data{"success"}="dhcpd_SUCCESSFULLY_SAVED_SETTINGS";
do_leases($c);
}
else {$dhcp_data{"error"}=$ret;}
return ;
}
sub do_delete_one_lease {
#
# Delete the specified lease
# Called from link in table of leases
#
my $c = shift;
# Lease in $c->param("lease")
# Validate - if not return error message
# delete it
# If deletion not ok return message
# else return "ok"
my $ret = delete_one_lease($c);
if ($ret == 'ok') {
$dhcp_data{"success"}="dhcpd_SUCCESSFULLY_SAVED_SETTINGS";
do_leases($c);
}
else {$dhcp_data{"error"}=$ret;}
return ;
}
sub get_scan_results {
my $c = shift;
#...do it
return Scan_Local_Network($c);
}
sub update_config {
my $c = shift;
#...do it
return "ok";
}
sub delete_one_lease {
my $c = shift;
Perform_Del_Lease($c);
return "ok";
}
sub delete_all_leases {
my $c = shift;
Perform_del_all_Lease($c);
return "ok";
}
sub get_leases_in_array {
my $c = shift;
my @leases = Load_leases($c);
# ...do it
return @leases;
}
sub Perform_del_all_Lease ($){
system ('/bin/echo "" > /var/lib/dhcpd/dhcpd.leases') ==0
or die "Error while removing all leases: $!";
system ("/sbin/e-smith/signal-event","workgroup-update") == 0
or die "Error while saving settings: $!";
return 'ok';
exit;
}
#===============================================================================
#SUBROUTINE: Perform delete lease
#===============================================================================
sub Perform_Del_Lease($){
###Pull CGI object from parameters array
my $c = shift;
#my $fred = 1/0;
###Pull entry to delete
my $ip = $c->param('ip');
my $name = $c->param('name');
my $name_in_file = '/var/lib/dhcpd/dhcpd.leases' ;
my $name_tmp_file = '/var/lib/dhcpd/dhcpd.leases.tmp' ;
my $name_out_file = '/var/lib/dhcpd/dhcpd.leases~' ;
my $del_current = "0" ;
open(INFILE,"<$name_in_file") || die "Read Error $name_in_file, Read: $!";
open(OUTFILE,">$name_tmp_file") || die "Write error $name_in_file, Write: $!";
while (<INFILE>) {
if ( "$_" =~ /lease $ip/ ) {
$del_current = "1" ;
}
if ( $del_current == "0" ) { print OUTFILE "$_" ; }
if ( "$_" =~ /}/ ) {
$del_current = "0" ;
}
}
rename ($name_tmp_file,$name_in_file) ;
system ("/bin/cp","-f","$name_in_file","$name_out_file") ;
close(INFILE);
close(OUTFILE);
# changed to new sme standard signal-event
system ("/sbin/e-smith/signal-event","workgroup-update") == 0
or die "Error while saving settings: $!";
###Return action message
return $c->l('SUCCESSFULLY_DELETED_THE_CLIENT') . ' (' . $name . '/' . $ip .')';
}
#===============================================================================
#SUBROUTINE: Scan The Local Network
#===============================================================================
sub dec2bin {
my $str = unpack("B32", pack("N", shift));
return $str;
}
sub netmask2cidr {
my ($mask, $network) = @_;
my @octet = split (/\./, $mask);
my @bits;
my $binmask;
my $binoct;
my $bitcount=0;
foreach (@octet) {
$binoct = dec2bin($_);
$binmask = $binmask . substr $binoct, -8;
}
# let's count the 1s
@bits = split (//,$binmask);
foreach (@bits) {
if ($_ eq "1") {
$bitcount++;
}
}
my $cidr = $network . "/" . $bitcount;
return $cidr;
}
sub get_mac_address {
# From the leases file
my ($ip, $file) = @_;
open(my $fh, '<', $file) or die "Could not open file '$file' $!";
my $mac_address = undef;
my $lease_block;
while(my $line = <$fh>) {
if($line =~ /lease $ip {/ .. $line =~ /}/) {
$lease_block .= $line;
if($line =~ /}/) {
if($lease_block =~ /hardware ethernet (\S+);/) {
$mac_address = $1;
last;
} else {
$lease_block = '';
}
}
}
}
close $fh;
return $mac_address;
}
sub trim { my $s = shift; $s =~ s/^\s+|\s+$//g; return $s };
sub get_mac_address_by_ping {
my ($ip) = trim(@_);
# Ping the IP to ensure it's in the ARP table
my $ping_result = `ping -c 1 -W 1 $ip`;
#return $ping_result;
if($ping_result =~ m/1 packets transmitted, 1 received/) {
# Fetch the ARP table and find the line with the IP address
my $mac_result = `nmap -PR -sn $ip`;
#return "*$arp_result *$ip*";
# If found, return the MAC address
#if ($arp_result =~ m/.*at ((?:[0-9a-f]{2}\:){5}[0-9a-f]{2})/) {
if ($mac_result =~ /MAC Address: (..:..:..:..:..:..) /) {
return $1;
} else { return "mac not in nmap result";}
} else { return "no ping";}
return undef;
}
sub Scan_Local_Network ($) {
my $nmap_sme = esmith::ConfigDB->open('/home/e-smith/db/configuration');
my $mask = $nmap_sme->get_value('LocalNetmask');
my $network = $nmap_sme->get_prop('InternalInterface','Network');
#we start to calculate the method to find the cidr (we want to use network/cidr with nmap)
my $cidr = netmask2cidr($mask, $network);
#ok go to use nmap with nmap -T4 -sP network/cidr
my @nmap_output= `/usr/bin/nmap --script smb-os-discovery.nse -p U:137,T:139 $cidr|
/bin/grep -Ev "MAC|NetBIOS|OS CPE"| /bin/grep -E "scan|done|Computer|OS"|
/bin/sed -e 's/Nmap scan/-- Scan/g'|/bin/sed -e 's/done/Done/g'|
/bin/sed -e 's/Nmap//g'|/bin/sed -e 's/|/ /g'`;
my @extracted_output;
my $leasefile = "/var/lib/dhcpd/dhcpd.leases";
foreach my $line (@nmap_output) {
if ($line =~ m/Scan report for ([\w\.-]+) \(([\d\.\:]+)\)/) {
my $ip = $2;
my $mac = get_mac_address($ip,$leasefile);
if (!$mac){
$mac = get_mac_address_by_ping($ip);
}
# if (!$mac) {$mac = "unknown";}
my %pair = ('Network' => $1, 'ip' => $ip, 'mac' => $mac); # $1 => PC Name, $2 => IP Address
push @extracted_output, \%pair;
}
}
return \@extracted_output;
}
#=========================================================================
# Procedure qui charge le dhcpd.conf
# retourne un tableau contenant les informations
#=========================================================================
sub Load_leases ($){
my $q = shift;
#Definition de variable
use vars qw/
@detail $work_line $header /;
my $name_file = '/var/lib/dhcpd/dhcpd.leases' ;
our @liste_computer = '' ;
our $db = esmith::ConfigDB->open() or die("Unable to open Configuration DB");
our %sme_conf = $db->get('dhcpd')->props;
#Ouverture du fichier en lecture seule
open(FILE,"<$name_file") || die "Read error $name_file, Error: $!" ;
#Parcours du fichier dhcpd.leases
while (<FILE>) {
# suppression des commentaires
if ($_ =~ /^#/) { next; }
#spurresion des lignes vides
if ($_ =~ /^$/) { next; }
#supression de la ligne uid de windows
if ($_ =~ /uid/) { next; }
#supression de la ligne tstp de XP
if ($_ =~ /tstp/) { next; }
#supression de la ligne "binding state active"
if ($_ =~ /binding/) { next; }
#supression de la ligne "next binding state"
if ($_ =~ /next/) { next; }
#suprresion des commentaire et des ;
$_ =~ s/\s#.*$//;
$_ =~ s/(;|{) *$//;
#supression des espace en debut de lignes
$_ =~ s/^ *\s//;
#Suppression des retours chariot en fin de lignes.
chomp $_ ;
#Chargement d'un tableau avec le contenu de la ligne.
(@detail) = split(/ /, $_) ;
#initialisation d'un nouveau poste connect<63>
if ($_ =~ /lease/) {
$work_line = "" ;
}
$header = shift(@detail);
$work_line = $work_line . ";" . join(" ",@detail) ;
if ($header =~ /}/) {
$work_line =~ s/ /;/g;
$work_line =~ s/^;//;
$work_line =~ s/"//g;
$work_line =~ s/;$//;
#we want the last entry is the first element of the array
unshift(@liste_computer,$work_line) ;
}
}
close(FILE);
# Now check if up and extract details
my @mac = ();
my @count = ();
my @results = ();
my @liste_connected = ();
foreach (@liste_computer){
my @computer = split(/;/, $_) ;
#we want to sort elements the array by mac address
$computer[11] = uc($computer[11]) ;
push @mac, ($computer[11]);
my @count;
push @count , (grep /$computer[11]/ , @mac);
next if (scalar @count > 1);
#we start the table if it is a valid IP
if ( $computer[0] ) {
$computer[12] = uc($computer[12]) ;
my $datedeb = $computer[2] . "-" . $computer[3] ;
my $datefin = $computer[5] . "-" . $computer[6] ;
my $status = 'dhcpd_NOT_CHECKED';
#my $status = '<a href=/smanager/dhcpd1'."?state=wake_up&MAC=" . $computer[11] . "&name=" . $computer[12].">".$q->l('dhcpd_NOT_CHECKED')."</a>";
if ( $sme_conf{'check'} =~ /enabled/ ) {
use Net::Ping;
my($ping_obj) = Net::Ping->new("icmp");
# formatage des dates
$computer[3] = substr($computer[3],0,5);
$computer[6] = substr($computer[6],0,5);
if ($ping_obj->ping("$computer[0]")) {
push(@liste_connected,$computer[12]) ;
$status = 'dhcpd_ACTIVE_DEVICE';
#alimentation de la liste des connect<63>
}
else { $status = 'dhcpd_WAKE_UP_ACTION';}
#else { $status = '<a href=/smanager/dhcpd1'."?state=wake_up&MAC=" . $computer[11] . "&name=" . $computer[12].">".$q->l('dhcpd_WAKE_UP_ACTION')."</a>";
}
my %ipdetails = (ip=>$computer[0],name=>$computer[12],wol=>$status,start=>$datedeb,end=>$datefin,mac=>$computer[11]);
push(@results,\%ipdetails);
}
else {
push(@liste_connected,$computer[12]) ;
}
}
return @results;
}
sub winpopup{
my $c = shift;
# Message in $c->param("winpopupmsg")
# .... do it
return TRUE;
}
sub do_wol{
my $c = shift;
my $retVal = Perform_Wake_Up($c);
if ($retVal) {$dhcp_data{"success"} = $retVal;}
do_leases($c);
return TRUE;
}
#===============================================================================
#SUBROUTINE: Perform wake UP
#===============================================================================
sub Perform_Wake_Up($){
###Pull CGI object from parameters array
my $q = shift;
###Get Mac Adress
my $mac = uc($q->param('mac'));
my $name = uc($q->param('name'));
#Send Wake Up to the station
#Old version obsolete since 1.5.0 - system ("/usr/bin/wol","$mac") ;
system ("/sbin/ether-wake","$mac") ;
###Return action message
return 'dhcpd_SUCCESSFULLY_CLIENT_WOL_REQUEST';
}
1;

View File

@@ -0,0 +1,91 @@
'dhcpd_ACTION' => 'Action',
'dhcpd_ACTIVE_DEVICE' => 'Active Device',
'dhcpd_ALL_OF_THEM' => 'All of them',
'dhcpd_CHECK_CLIENT_STATUS' => 'Always check the status of computers (Disabled is much faster)',
'dhcpd_CLEAN_ALL_DHCPLEASES' => 'You may want to clean the dhcpd.leases',
'dhcpd_CLICK_HERE_TO_MAIN_PANEL' => 'Return to the main panel',
'dhcpd_CONNECTED_IP' => 'Show DHCP Clients',
'dhcpd_CUSTOM_DNS_STATUS' => 'Custom DNS',
'dhcpd_CUSTOM_DNS_TITLE' => 'Enable custom DNS servers.',
'dhcpd_CUSTOM_GATEWAY_ADDRESS' => 'Gateway address',
'dhcpd_CUSTOM_GATEWAY_STATUS' => 'Custom gateway',
'dhcpd_CUSTOM_GATEWAY_TITLE' => 'Enable a custom gateway address.',
'dhcpd_CUSTOM_LEASETIME' => 'Custom lease time',
'dhcpd_CUSTOM_LEASETIME_TITLE' => 'Set the lease time (default is 86400 seconds).',
'dhcpd_CUSTOM_WINSERVER_ADDRESS' => 'WINS Server address',
'dhcpd_CUSTOM_WINSERVER_STATUS' => 'WINS Server',
'dhcpd_CUSTOM_WINSERVER_TITLE' => 'Enable a WINS Server.',
'dhcpd_DHCPD_SETTING_ERRORS' => 'DHCPd Settings ERRORS',
'dhcpd_DHCPD_SETTINGS_TITLE' => 'DHCP server settings',
'dhcpd_DHCPD_TITLE' => 'DHCP Manager',
'dhcpd_DHCP_END' => 'DHCP End',
'dhcpd_DHCP manager' => 'DHCP Manager',
'dhcpd_DHCP_RANGE_MUST_NOT_INCLUDE_SERVER_IP' =>'Incorrect range of IPs, the range of IP address allocation must not include the server address, Update unsuccessfull',
'dhcpd_DHCP_RANGE_WITH_BAD_IP' => 'Incorrect IP in the DHCP range, Update unsuccessfull',
'dhcpd_DHCP_START' => 'DHCP Start',
'dhcpd_DHCP_START_GREATER_DHCP_END_ERRORS' =>'Incorrect range of IPs, the DHCP Start is greater than the DHCP End , Update unsuccessfull',
'dhcpd_DISABLED' => 'Disabled',
'dhcpd_DNS_SERVER_WITH_BAD_IP' => 'Incorrect IP for DNS servers, Update unsuccessfull',
'dhcpd_DO_YOU_WANT_TO_SENT' => 'Do you want to send this message to',
'dhcpd_ENABLED' => 'Enabled',
'dhcpd_END_DATE' => 'End Date',
'dhcpd_ERROR_WHILE_REMOVING_ALL_LEASES' => 'Error while removing all dhcpd Leases',
'dhcpd_ERROR_WHILE_SAVING_SETTINGS' => 'Error while saving settings',
'dhcpd_GATEWAY_BAD_IP' => 'Incorrect IP for Gateway, Update unsuccessfull',
'dhcpd_GLOBAL_WINPOPUP' => 'Send Global Netsend WinPopup',
'dhcpd_GLOBAL_WINPOPUP_TITLE' => 'Send a global WinPopup with the Net send protocol',
'dhcpd_IP' => 'Ip Address',
'dhcpd_MAC_ADDRESS' => 'MAC Address',
'dhcpd_MANAGING_DHCP_CLIENT' => 'Managing DHCP clients',
'dhcpd_NETWORK_NAME' => 'Network Name',
'dhcpd_NETWORK_VALUES_FOUND' => 'Please wait .... Your subnet and your netmask appear to be :',
'dhcpd_NO_CONNECTED_COMPUTERS' => 'There are no connected computers',
'dhcpd_NOT_CHECKED' => 'Not Checked...',
'dhcpd_PRIMARY_DNS_ADDRESS' => 'Primary DNS',
'dhcpd_REFRESH_CONNECTED_IP_LIST' => 'You may want to refresh this list ?',
'dhcpd_REFRESH' => 'Refresh the list',
'dhcpd_REMOVE_ACTION' => 'Remove...',
'dhcpd_REMOVE_A_DHCP_LEASE_ACTION' => 'You are about to remove a client from the dhcpd.leases file.',
'dhcpd_REMOVE_A_DHCP_LEASE' => 'Remove a DHCP lease',
'dhcpd_ARE_YOU_SURE' => 'are you sure ?',
'dhcpd_REMOVE_A_DHCP_LEASE_TITLE' => 'Removing a DHCP Lease',
'dhcpd_REMOVE_ALL_LEASES_ACTION' => 'Remove all dhcpd leases',
'dhcpd_REMOVE_ALL_LEASES' => 'Remove all leases',
'dhcpd_REMOVE_DHCP_LEASE_TITLE' => 'Removing all DHCP Lease',
'dhcpd_REMOVE_DHCP_LEASE_WARNING' => 'Remove all entries in dhcpd.leases may cause issues',
'dhcpd_REMOVE' => 'Remove',
'dhcpd_SAVE/RESTART' => 'Save/Restart',
'dhcpd_SAVE_TITLE' => 'After changing settings above, you must save and restart dhcpd.',
'dhcpd_SCANNING_NETWORK_TITLE' => 'Scanning your network, the time needed depends of your subnet mask',
'dhcpd_SCAN_YOUR_NETWORK' => 'Scan your network',
'dhcpd_SCAN_YOUR_NETWORK_TITLE' => 'Scan your network to show active devices :',
'dhcpd_SECONDARY_DNS_ADDRESS' => 'Secondary DNS',
'dhcpd_SENDING_A_WINPOPUP' => 'Sending a WinPopup',
'dhcpd_SENDING_A_WINPOPUP_TO' => 'You are about to send a WinPopup to ',
'dhcpd_SEND_WINPOPUP_TO' => 'Send a WinPopup to',
'dhcpd_SHOW_CONNECTED_IP_TITLE' => 'Show all devices connected to the dhcpd server :',
'dhcpd_START_DATE' => 'Start Date',
'dhcpd_STATUS_CLICK_FOR_WOL' => 'Status - click for WOL',
'dhcpd_STATUS_DHCP_SERVER' => 'State of DHCPD',
'dhcpd_STATUS_REPORT' => 'Operation status report :',
'dhcpd_SUCCESSFULLY_CLIENT_WOL_REQUEST' =>'Successfull request to wake up the client. The computer may take time to wake up.',
'dhcpd_SUCCESSFULLY_DELETED_THE_CLIENT' => 'Successfully deleted the client in dhcpd.leases : ',
'dhcpd_SUCCESSFULLY_REMOVED_ALL_LEASES' => 'Successfully deleted all leases.',
'dhcpd_SUCCESSFULLY_SAVED_SETTINGS' => 'Successfully saved settings',
'dhcpd_SUCCESSFULLY_SENT_MESSAGE' => 'Successfully sent message popup to',
'dhcpd_TERTIARY_DNS_ADDRESS' => 'Tertiary DNS',
'dhcpd_WAKE_UP_ACTION' => '<font color="red">Wake-Up...</font>',
'dhcpd_WAKE_UP' => 'Wake UP',
'dhcpd_WAKING_A_REMOTE_COMPUTER_ACTION' => 'Are you sure you want to wake on lan the client : ',
'dhcpd_WAKING_A_REMOTE_COMPUTER_TITLE' => 'Waking Up a remote computer',
'dhcpd_WAKING_A_REMOTE_COMPUTER' => 'You are about to wake up a remote computer.',
'dhcpd_WARNING_NO_WINPOPUP_GARANTY' =>'Warning, there is no guarantee that the popup will appear on the remote computer.',
'dhcpd_WINPOPUP_ACTION' => 'WinPopup...',
'dhcpd_WINSSERVER_BAD_IP' => 'Incorrect IP for WINS Server, Update unsuccessfull',
'dhcpd_WRITE_YOUR_MESSAGE' => 'Write your message here',
'dhcpd_YOUR_MESSAGE' => 'Your message',
'dhcpd_REMOVE_DHCP_LEASE_WARNING2' => 'The lease file is a log-structured file - whenever a lease changes, the
contents of that lease are written to the end of the file. This means that it is entirely possible for there to be two
or more declarations of the same lease in the lease file at the same
time. In that case, the instance of that particular lease that
appears last in the file is the one that is in effect.',

View File

@@ -0,0 +1,109 @@
package SrvMngr::I18N::Modules::Dhcpd::en;
use strict;
use warnings;
use utf8;
use Mojo::Base 'SrvMngr::I18N';
use SrvMngr::I18N::Modules::General::en;
my %lexicon = (
'dhcpd_ACTION' => 'Action',
'dhcpd_ACTIVE_DEVICE' => 'Active Device',
'dhcpd_ALL_OF_THEM' => 'All of them',
'dhcpd_CHECK_CLIENT_STATUS' => 'Always check the status of computers (Disabled is much faster)',
'dhcpd_CLEAN_ALL_DHCPLEASES' => 'You may want to clean the dhcpd.leases',
'dhcpd_CLICK_HERE_TO_MAIN_PANEL' => 'Return to the main panel',
'dhcpd_CONNECTED_IP' => 'Show DHCP Clients',
'dhcpd_CUSTOM_DNS_STATUS' => 'Custom DNS',
'dhcpd_CUSTOM_DNS_TITLE' => 'Enable custom DNS servers.',
'dhcpd_CUSTOM_GATEWAY_ADDRESS' => 'Gateway address',
'dhcpd_CUSTOM_GATEWAY_STATUS' => 'Custom gateway',
'dhcpd_CUSTOM_GATEWAY_TITLE' => 'Enable a custom gateway address.',
'dhcpd_CUSTOM_LEASETIME' => 'Custom lease time',
'dhcpd_CUSTOM_LEASETIME_TITLE' => 'Set the lease time (default is 86400 seconds).',
'dhcpd_CUSTOM_WINSERVER_ADDRESS' => 'WINS Server address',
'dhcpd_CUSTOM_WINSERVER_STATUS' => 'WINS Server',
'dhcpd_CUSTOM_WINSERVER_TITLE' => 'Enable a WINS Server.',
'dhcpd_DHCPD_SETTING_ERRORS' => 'DHCPd Settings ERRORS',
'dhcpd_DHCPD_SETTINGS_TITLE' => 'DHCP server settings',
'dhcpd_DHCPD_TITLE' => 'DHCP Manager',
'dhcpd_DHCP_END' => 'DHCP End',
'dhcpd_DHCP manager' => 'DHCP Manager',
'dhcpd_DHCP_RANGE_MUST_NOT_INCLUDE_SERVER_IP' =>'Incorrect range of IPs, the range of IP address allocation must not include the server address, Update unsuccessfull',
'dhcpd_DHCP_RANGE_WITH_BAD_IP' => 'Incorrect IP in the DHCP range, Update unsuccessfull',
'dhcpd_DHCP_START' => 'DHCP Start',
'dhcpd_DHCP_START_GREATER_DHCP_END_ERRORS' =>'Incorrect range of IPs, the DHCP Start is greater than the DHCP End , Update unsuccessfull',
'dhcpd_DISABLED' => 'Disabled',
'dhcpd_DNS_SERVER_WITH_BAD_IP' => 'Incorrect IP for DNS servers, Update unsuccessfull',
'dhcpd_DO_YOU_WANT_TO_SENT' => 'Do you want to send this message to',
'dhcpd_ENABLED' => 'Enabled',
'dhcpd_END_DATE' => 'End Date',
'dhcpd_ERROR_WHILE_REMOVING_ALL_LEASES' => 'Error while removing all dhcpd Leases',
'dhcpd_ERROR_WHILE_SAVING_SETTINGS' => 'Error while saving settings',
'dhcpd_GATEWAY_BAD_IP' => 'Incorrect IP for Gateway, Update unsuccessfull',
'dhcpd_GLOBAL_WINPOPUP' => 'Send Global Netsend WinPopup',
'dhcpd_GLOBAL_WINPOPUP_TITLE' => 'Send a global WinPopup with the Net send protocol',
'dhcpd_IP' => 'Ip Address',
'dhcpd_MAC_ADDRESS' => 'MAC Address',
'dhcpd_MANAGING_DHCP_CLIENT' => 'Managing DHCP clients',
'dhcpd_NETWORK_NAME' => 'Network Name',
'dhcpd_NETWORK_VALUES_FOUND' => 'Please wait .... Your subnet and your netmask appear to be :',
'dhcpd_NO_CONNECTED_COMPUTERS' => 'There are no connected computers',
'dhcpd_NOT_CHECKED' => 'Not Checked...',
'dhcpd_PRIMARY_DNS_ADDRESS' => 'Primary DNS',
'dhcpd_REFRESH_CONNECTED_IP_LIST' => 'You may want to refresh this list ?',
'dhcpd_REFRESH' => 'Refresh the list',
'dhcpd_REMOVE_ACTION' => 'Remove...',
'dhcpd_REMOVE_A_DHCP_LEASE_ACTION' => 'You are about to remove a client from the dhcpd.leases file.',
'dhcpd_REMOVE_A_DHCP_LEASE' => 'Remove a DHCP lease',
'dhcpd_ARE_YOU_SURE' => 'are you sure ?',
'dhcpd_REMOVE_A_DHCP_LEASE_TITLE' => 'Removing a DHCP Lease',
'dhcpd_REMOVE_ALL_LEASES_ACTION' => 'Remove all dhcpd leases',
'dhcpd_REMOVE_ALL_LEASES' => 'Remove all leases',
'dhcpd_REMOVE_DHCP_LEASE_TITLE' => 'Removing all DHCP Lease',
'dhcpd_REMOVE_DHCP_LEASE_WARNING' => 'Remove all entries in dhcpd.leases may cause issues',
'dhcpd_REMOVE' => 'Remove',
'dhcpd_SAVE/RESTART' => 'Save/Restart',
'dhcpd_SAVE_TITLE' => 'After changing settings above, you must save and restart dhcpd.',
'dhcpd_SCANNING_NETWORK_TITLE' => 'Scanning your network, the time needed depends on your subnet mask',
'dhcpd_SCAN_YOUR_NETWORK' => 'Scan your network',
'dhcpd_SCAN_YOUR_NETWORK_TITLE' => 'Scan your network to show active devices :',
'dhcpd_SECONDARY_DNS_ADDRESS' => 'Secondary DNS',
'dhcpd_SENDING_A_WINPOPUP' => 'Sending a WinPopup',
'dhcpd_SENDING_A_WINPOPUP_TO' => 'You are about to send a WinPopup to ',
'dhcpd_SEND_WINPOPUP_TO' => 'Send a WinPopup to',
'dhcpd_SHOW_CONNECTED_IP_TITLE' => 'Show all devices connected to the dhcpd server :',
'dhcpd_START_DATE' => 'Start Date',
'dhcpd_STATUS_CLICK_FOR_WOL' => 'Status - click for WOL',
'dhcpd_STATUS_DHCP_SERVER' => 'State of DHCPD',
'dhcpd_STATUS_REPORT' => 'Operation status report :',
'dhcpd_SUCCESSFULLY_CLIENT_WOL_REQUEST' =>'Successfull request to wake up the client. The computer may take time to wake up.',
'dhcpd_SUCCESSFULLY_DELETED_THE_CLIENT' => 'Successfully deleted the client in dhcpd.leases : ',
'dhcpd_SUCCESSFULLY_REMOVED_ALL_LEASES' => 'Successfully deleted all leases.',
'dhcpd_SUCCESSFULLY_SAVED_SETTINGS' => 'Successfully saved settings',
'dhcpd_SUCCESSFULLY_SENT_MESSAGE' => 'Successfully sent message popup to',
'dhcpd_TERTIARY_DNS_ADDRESS' => 'Tertiary DNS',
'dhcpd_WAKE_UP_ACTION' => '<font color="red">Wake-Up...</font>',
'dhcpd_WAKE_UP' => 'Wake UP',
'dhcpd_WAKING_A_REMOTE_COMPUTER_ACTION' => 'Are you sure you want to wake on lan the client : ',
'dhcpd_WAKING_A_REMOTE_COMPUTER_TITLE' => 'Waking Up a remote computer',
'dhcpd_WAKING_A_REMOTE_COMPUTER' => 'You are about to wake up a remote computer.',
'dhcpd_WARNING_NO_WINPOPUP_GARANTY' =>'Warning, there is no guarantee that the popup will appear on the remote computer.',
'dhcpd_WINPOPUP_ACTION' => 'WinPopup...',
'dhcpd_WINSSERVER_BAD_IP' => 'Incorrect IP for WINS Server, Update unsuccessfull',
'dhcpd_WRITE_YOUR_MESSAGE' => 'Write your message here',
'dhcpd_YOUR_MESSAGE' => 'Your message',
'dhcpd_REMOVE_DHCP_LEASE_WARNING2' => 'The lease file is a log-structured file - whenever a lease changes, the
contents of that lease are written to the end of the file. This means that it is entirely possible for there to be two
or more declarations of the same lease in the lease file at the same
time. In that case, the instance of that particular lease that
appears last in the file is the one that is in effect.',
);
our %Lexicon = (
%{ SrvMngr::I18N::Modules::General::en::Lexicon },
%lexicon
);
1;

View File

@@ -0,0 +1,219 @@
% layout 'default', title => "Sme server 2 - DHCP Manager", share_dir => './';
% content_for 'module' => begin
<div id="module" class="module dhcpman-panel">
% if ($config->{debug} == 1) {
<p>
%= dumper $c->current_route
</p>
% }
<h1><%=$title%></h1>
%= $modul
%if ($dhcp_data->{first}) {
<br><p>
%=$c->render_to_string(inline =>$c->l($dhcp_data->{first}))
</p>
%} elsif ($dhcp_data->{success}) {
<div class='sme-border'>
<h2> Operation Status Report - success</h2><p>
<font color=green>
%= $c->l($dhcp_data->{success});
</font>
</p>
</div>
%} elsif ($dhcp_data->{error}) {
<div class='sme-error'>
<h2> Operation Status Report - error</h2><p>
<font color=red>
%= $c->l($dhcp_data->{error});
</font>
</p>
</div>
%} elsif ($dhcp_data->{error}) {
<div class='sme-warning'>
<h2> Operation Status Report - warning</h2><p>
<font color=orange>
%= $c->l($dhcp_data->{error});
</font>
</p>
</div>
%}
% if ($dhcp_data->{trt} eq 'LEASES') {
%= include 'partials/_dhcpd_leases'
%} elsif ($dhcp_data->{trt} eq 'SCAN') {
%= include 'partials/_dhcpd_scan'
%} else { #PARAMS
% my $ip_regex = '^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$';
<table>
<tr>
<td>
%= button_to $c->l('dhcpd_CONNECTED_IP') => '/dhcpd1', onclick=>"showSpinnerLeases()", id=>"scanLeases"
<button class ="btn btn-primary spinnerButtonOverlay" type = "submit" id="load" style="display:none">
Scanning <!--%= $c->l('dhcpd_CONNECTED_IP')-->
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
</button>
</td><td>
%= button_to $c->l('dhcpd_SCAN_YOUR_NETWORK') => '/dhcpd3', onclick=>"showSpinnerNetwork()", id=>"scanNetwork"
<button class ="btn btn-primary spinnerButtonOverlay" type = "submit" id="loadingNetwork" style="display:none">
Scanning <!--%= $c->l('dhcpd_CONNECTED_IP')-->
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
</button>
</td>
</tr>
</table>
<hr />
<h2>
%= $c->l("dhcpd_DHCPD_SETTINGS_TITLE")
</h2>
% my $btn = l('dhcpd_SAVE/RESTART');
%= form_for '/dhcpd5' => (method => 'POST') => begin
<span class=label>
%=l 'dhcpd_CHECK_CLIENT_STATUS'
</span><span class=data>
% param dhcp_check=>$dhcp_data->{"params"}->{"check"};
%=select_field dhcp_check=>$dhcp_data->{"check"}
</span><br>
<br />
<span class=label>
%=l 'dhcpd_STATUS_DHCP_SERVER'
</span><span class=data>
% param dhcp_enable=>$dhcp_data->{"params"}->{"status"};
%=select_field dhcp_enable=>$dhcp_data->{"status"}
</span><br>
<span class=label>
%=l 'dhcpd_DHCP_START'
</span><span class=data>
% param dhcp_start=>$dhcp_data->{"params"}->{"start"};
%=text_field 'dhcp_start',minlength=>'7',maxlength=>"15",size=>"15",placeholder=>"nnn.nnn.nnn.nnn", pattern=>"$ip_regex"
</span><br>
<span class=label>
%=l 'dhcpd_DHCP_END'
</span><span class=data>
% param dhcp_end=>$dhcp_data->{"params"}->{"end"};
%=text_field 'dhcp_end',minlength=>'7',maxlength=>"15",size=>"15",placeholder=>"nnn.nnn.nnn.nnn", pattern=>"$ip_regex"
</span><br><br />
%= $c->l("dhcpd_CUSTOM_WINSERVER_TITLE");
<br />
<span class=label>
%=l 'dhcpd_CUSTOM_WINSERVER_STATUS'
</span><span class=data>
% param dhcp_winscustom=>$dhcp_data->{"params"}->{"winscustom"};
%=select_field dhcp_winscustom=>$dhcp_data->{"status"}
</span><br>
<span class=label>
%=l 'dhcpd_CUSTOM_WINSERVER_ADDRESS'
</span><span class=data>
% param dhcp_winsserver=>$dhcp_data->{"smbparams"}->{"WINSServer"};
%=text_field 'dhcp_winsserver' ,minlength=>'7',maxlength=>"15",size=>"15",placeholder=>"nnn.nnn.nnn.nnn", pattern=>"$ip_regex"
</span><br><br />
%= $c->l("dhcpd_CUSTOM_DNS_TITLE");
<br />
<span class=label>
%=l 'dhcpd_CUSTOM_DNS_STATUS'
</span><span class=data>
% param dhcp_dnscustom=>$dhcp_data->{"params"}->{"dnscustom"};
%=select_field dhcp_dnscustom=>$dhcp_data->{"status"}
</span><br>
<span class=label>
%=l 'dhcpd_PRIMARY_DNS_ADDRESS'
</span><span class=data>
% param dhcp_dns1server=>$dhcp_data->{"params"}->{"dns1server"};
%=text_field 'dhcp_dns1server' ,minlength=>'7',maxlength=>"15",size=>"15",placeholder=>"nnn.nnn.nnn.nnn", pattern=>"$ip_regex"
</span><br>
<span class=label>
%=l 'dhcpd_SECONDARY_DNS_ADDRESS'
</span><span class=data>
% param dhcp_dns2server=>$dhcp_data->{"params"}->{"dns2server"};
%=text_field 'dhcp_dns2server' ,minlength=>'7',maxlength=>"15",size=>"15",placeholder=>"nnn.nnn.nnn.nnn", pattern=>"$ip_regex"
</span><br>
<span class=label>
%=l 'dhcpd_TERTIARY_DNS_ADDRESS'
</span><span class=data>
% param dhcp_dns3server=>$dhcp_data->{"params"}->{"dns3server"};
%=text_field 'dhcp_dns3server' ,minlength=>'7',maxlength=>"15",size=>"15",placeholder=>"nnn.nnn.nnn.nnn", pattern=>"$ip_regex"
</span><br>
%= $c->l("dhcpd_CUSTOM_GATEWAY_TITLE");
<br />
<span class=label>
%=l 'dhcpd_CUSTOM_GATEWAY_STATUS'
</span><span class=data>
% param dhcp_gatewaycustom=>$dhcp_data->{"params"}->{"gatewaycustom"};
%=select_field dhcp_gatewaycustom=>$dhcp_data->{"status"}
</span><br>
<span class=label>
%=l 'dhcpd_CUSTOM_GATEWAY_ADDRESS'
</span><span class=data>
% param dhcp_gateway=>$dhcp_data->{"params"}->{"gateway"};
%=text_field 'dhcp_gateway' ,minlength=>'7',maxlength=>"15",size=>"15",placeholder=>"nnn.nnn.nnn.nnn", pattern=>"$ip_regex"
</span><br><br />
%= $c->l("dhcpd_CUSTOM_LEASETIME_TITLE");
<br />
<span class=label>
%=l 'dhcpd_CUSTOM_LEASETIME'
</span><span class=data>
% param dhcp_leasetime=>$dhcp_data->{"params"}->{"leasetime"};
%=number_field 'dhcp_leasetime'
</span><br><br />
%= submit_button "$btn", class => 'action'
% end
%}
</div>
%= javascript begin
if (document.getElementById("load")){document.getElementById("load").style.display="none";}
if (document.getElementById("loadingNetwork")){document.getElementById("loadingNetwork").style.display="none";}
function showSpinnerLeases(){
document.getElementById("scanLeases").style.display="none";
document.getElementById("load").style.display="inline";
}
function showSpinnerNetwork(){
document.getElementById("scanNetwork").style.display="none";
document.getElementById("loadingNetwork").style.display="inline";
}
%end
%= stylesheet begin
.spinnerButtonOverlay,
.spinnerButtonOverlay:hover,
.spinnerButtonOverlay:any-link ,
.spinnerButtonOverlay:focus ,
.spinnerButtonOverlay:active {
appearance: auto;
user-select: none;
align-items: flex-start;
cursor: default;
box-sizing: border-box;
background-color: #efefef;
color: black;
padding: 1px 6px;
border-width: 2px;
border-style: outset;
border-color: darkgrey;
border-image: initial;
}
%end
%end
1;

View File

@@ -0,0 +1,113 @@
<div id='dhcpd-leases'>
<table><tr><td>
%= button_to $c->l('dhcpd_REFRESH') => '/dhcpd1', onclick=>"showSpinnerLeases()", id=>"scanLeases"
<button class ="btn btn-primary spinnerButtonOverlay" type = "submit" id="load" style="display:true">
Scanning <!--%= $c->l('dhcpd_CONNECTED_IP')-->
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
</button>
</td><td>
%= button_to $c->l('dhcpd_REMOVE_ALL_LEASES') => '/dhcpd4'
</td>
</tr>
</table>
% my $btn = l('dhcpd_SAVE/RESTART');
%= form_for '/dhcpd10' => (method => 'POST') => begin
<span class=label>
%=l 'dhcpd_CHECK_CLIENT_STATUS'
</span><span class=data>
% param dhcp_check=>$dhcp_data->{"params"}->{"check"};
%=select_field dhcp_check=>$dhcp_data->{"check"}
</span><br>
<br />
%= $c->l("dhcpd_SAVE_TITLE");
<br />
%= submit_button "$btn", class => 'action'
% end
<br>
<table class="sme-border TableSort"><thead>
<tr>
<th class='sme-border'>
%=l 'dhcpd_IP'
</th>
<th class='sme-border'>
%=l 'dhcpd_NETWORK_NAME'
</th>
<th class='sme-border'>
%=l 'dhcpd_STATUS_CLICK_FOR_WOL'
</th>
<th class='sme-border'>
%=l('dhcpd_START_DATE',"")
</th>
<th class='sme-border'>
%=l 'dhcpd_END_DATE'
</th>
<th class='sme-border'>
%=l 'dhcpd_MAC_ADDRESS'
</th>
<th class='sme-border' colspan=2>
%=l 'dhcpd_ACTION'
</th>
</tr>
</thead>
<tbody>
% foreach my $ip (@$leases) {
<tr>
%= t td => (class => 'sme-border') => $ip->{ip}
%= t td => (class => 'sme-border') => $ip->{name}
<td class='sme-border'>
% if ($ip->{wol} =~ /ACTIVE/) {
<center><%==l $ip->{wol}%></center>
%} else {
<a href="/smanager/dhcpd9??state=wake_up&MAC=<%= $ip->{mac}%>&name=<%= $ip->{name}%>" onclick="Wol_confirm(event,'<%=$c->l('dhcpd_WAKING_A_REMOTE_COMPUTER')%>',this);"><center><%==l $ip->{wol}%></center></a>
%}
</td>
%= t td => (class => 'sme-border') => $ip->{start}
%= t td => (class => 'sme-border') => $ip->{end}
%= t td => (class => 'sme-border') => $ip->{mac}
<td class = 'sme-border'>
<a href="/smanager/dhcpd6?trt=DEL&ip=<%= $ip->{ip}%>&name=<%= $ip->{name}%>" onclick="Remove_lease_confirm(event,'<%=$c->l('dhcpd_REMOVE_A_DHCP_LEASE_ACTION')%>',this);"><center><%=l 'dhcpd_REMOVE'%></center></a>
</td>
</tr>
%}
</tbody>
</table>
%= hidden_field "hiddenmsg"=>"", id=>"hiddenmsg"
<br />
%= button_to $c->l('dhcpd_CLICK_HERE_TO_MAIN_PANEL') => '/dhcpd'
%= javascript begin
function Wol_confirm(event,msg,current){
const getMAC = /.*MAC\=(.*)\&name.*/;
var MAC = current.href.match(getMAC)[1];
if (confirm(msg+": MAC: "+MAC))
{ return true;}
else {event.preventDefault();return false;}
}
function Winpop_confirm(event,msg,current){
const getIP = /.*ip\=(.*)/;
var IP = ": IP: "+current.href.match(getIP)[1];
msg = msg.replace("$",IP);
var retVal = prompt(msg);
if (retVal) {
//Write it away in a hidden field
$hidden = document.getElementById("hiddenMsg");
$hidden.value = retVal;
return true;
} else {event.preventDefault();return false;}
}
function Remove_lease_confirm(event,msg,current){
const getIP = /.*ip\=(.*)/;
var IP = current.href.match(getIP)[1];
if (confirm(msg+" IP: "+IP))
{ return true;}
else {event.preventDefault();return false;}
}
%end
</div>

View File

@@ -0,0 +1,63 @@
<div id='dhcpd-scan'>
<table><tr><td>
%= button_to $c->l('dhcpd_REFRESH') => '/dhcpd3', onclick=>"showSpinnerNetwork1()", id=>"scanNetwork1"
<button class ="btn btn-primary spinnerButtonOverlay" type = "submit" id="loadingNetwork1" style="display:true">
Scanning <!--%= $c->l('dhcpd_CONNECTED_IP')-->
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
</button>
</td>
</tr>
</table>
<table class="sme-border TableSort"><thead>
<tr>
<th class='sme-border'>
%=l 'dhcpd_NETWORK_NAME'
</th>
<th class='sme-border'>
%=l 'dhcpd_IP'
</th>
<th class='sme-border'>
%=l 'dhcpd_MAC_ADDRESS'
</th>
</tr>
</thead>
<tbody>
% foreach my $ip (@$scanresults) {
<tr>
%= t td => (class => 'sme-border') => $ip->{Network}
%= t td => (class => 'sme-border') => $ip->{ip}
%= t td => (class => 'sme-border') => $ip->{mac}
</tr>
%}
</tbody>
</table>
%= hidden_field "hiddenmsg"=>"", id=>"hiddenmsg"
<br />
%= button_to $c->l('dhcpd_CLICK_HERE_TO_MAIN_PANEL') => '/dhcpd'
%= javascript begin
function Wol_confirm(event,msg,current){
const getMAC = /.*MAC\=(.*)\&name.*/;
var MAC = current.href.match(getMAC)[1];
if (confirm(msg+": MAC: "+MAC))
{ return true;}
else {event.preventDefault();return false;}
}
%end
</div>
%= javascript begin
document.getElementById("loadingNetwork1").style.display="none";
function showSpinnerNetwork1(){
document.getElementById("scanNetwork1").style.display="none";
document.getElementById("loadingNetwork1").style.display="inline";
}
%end