diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm 1970-01-01 01:00:00.000000000 +0100 +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm 2022-03-08 11:20:00.000000000 +0000 @@ -0,0 +1,539 @@ +package SrvMngr::Controller::Dhcpd; + +#---------------------------------------------------------------------- +# heading : Configuration +# description : DHCP manager +# navigation : 2000 2500 +# +# 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 = "NETSCAN"; + $dhcp_data{trt} = $trt; + $dhcp_data{"first"} = ''; + # ..... get scan results into dhcp_data + dhcp_data{"scanresults"} = get_scan_results($c); + $c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data ); + $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(). + # 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_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 "results"; +} + + +sub update_config { + my $c = shift; + #...do it + return "ok"; +} + +sub delete_one_lease { + my $c = shift; + # ...do it + return "ok"; +} + +sub delete_all_leases { + my $c = shift; + # ...do it + return "ok"; +} + +sub get_leases_in_array { + my $c = shift; + my @leases = Load_leases($c); + # ...do it + return @leases; +} + +#========================================================================= +# 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 () { + # 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� + 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 = '".$q->l('dhcpd_NOT_CHECKED').""; + 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� + } + else { $status = 'dhcpd_WAKE_UP_ACTION';} + #else { $status = '".$q->l('dhcpd_WAKE_UP_ACTION').""; + } + 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; + + \ No newline at end of file diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/dhcpd_en.lex smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/dhcpd_en.lex --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/dhcpd_en.lex 1970-01-01 01:00:00.000000000 +0100 +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/dhcpd_en.lex 2022-02-04 11:51:00.000000000 +0000 @@ -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' => 'Wake-Up...', + '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.', diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep 1970-01-01 01:00:00.000000000 +0100 +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep 2022-03-09 11:51:00.000000000 +0000 @@ -0,0 +1,211 @@ +% layout 'default', title => "Sme server 2 - DHCP Manager", share_dir => './'; + +% content_for 'module' => begin + +
+ + % if ($config->{debug} == 1) { +

+ %= dumper $c->current_route +

+ % } + +

<%=$title%>

+ %= $modul + + %if ($dhcp_data->{first}) { +

+ %=$c->render_to_string(inline =>$c->l($dhcp_data->{first})) +

+ + %} elsif ($dhcp_data->{success}) { +
+

Operation Status Report - success

+ + %= $c->l($dhcp_data->{success}); + +

+
+ + %} elsif ($dhcp_data->{error}) { +
+

Operation Status Report - error

+ + %= $c->l($dhcp_data->{error}); + +

+
+ + %} elsif ($dhcp_data->{error}) { +
+

Operation Status Report - warning

+ + %= $c->l($dhcp_data->{error}); + +

+
+ + %} + + % if ($dhcp_data->{trt} eq 'LEASES') { + %= include 'partials/_dhcpd_leases' + %} elsif ($dhcp_data->{trt} eq 'WINPOPUP') { + %= include 'partials/_dhcpd_winpopup' + %} 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])$'; + +
+ %= button_to $c->l('dhcpd_CONNECTED_IP') => '/dhcpd1', onclick=>"showSpinner()", id=>"scanLeases" + + + %= button_to $c->l('dhcpd_SCAN_YOUR_NETWORK') => '/dhcpd3' + + %= button_to $c->l('dhcpd_GLOBAL_WINPOPUP') => '/dhcpd2' + +
+
+

+ %= $c->l("dhcpd_DHCPD_SETTINGS_TITLE") +

+ % my $btn = l('dhcpd_SAVE/RESTART'); + %= form_for '/dhcpd5' => (method => 'POST') => begin + + %=l 'dhcpd_CHECK_CLIENT_STATUS' + + % param dhcp_check=>$dhcp_data->{"params"}->{"check"}; + %=select_field dhcp_check=>$dhcp_data->{"check"} +
+
+ + %=l 'dhcpd_STATUS_DHCP_SERVER' + + % param dhcp_enable=>$dhcp_data->{"params"}->{"status"}; + %=select_field dhcp_enable=>$dhcp_data->{"status"} +
+ + + %=l 'dhcpd_DHCP_START' + + % 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" +
+ + + %=l 'dhcpd_DHCP_END' + + % 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" +

+ + %= $c->l("dhcpd_CUSTOM_WINSERVER_TITLE"); +
+ + + %=l 'dhcpd_CUSTOM_WINSERVER_STATUS' + + % param dhcp_winscustom=>$dhcp_data->{"params"}->{"winscustom"}; + %=select_field dhcp_winscustom=>$dhcp_data->{"status"} +
+ + + %=l 'dhcpd_CUSTOM_WINSERVER_ADDRESS' + + % 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" +

+ + %= $c->l("dhcpd_CUSTOM_DNS_TITLE"); +
+ + %=l 'dhcpd_CUSTOM_DNS_STATUS' + + % param dhcp_dnscustom=>$dhcp_data->{"params"}->{"dnscustom"}; + %=select_field dhcp_dnscustom=>$dhcp_data->{"status"} +
+ + + %=l 'dhcpd_PRIMARY_DNS_ADDRESS' + + % 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" +
+ + + %=l 'dhcpd_SECONDARY_DNS_ADDRESS' + + % 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" +
+ + + %=l 'dhcpd_TERTIARY_DNS_ADDRESS' + + % 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" +
+ + %= $c->l("dhcpd_CUSTOM_GATEWAY_TITLE"); +
+ + %=l 'dhcpd_CUSTOM_GATEWAY_STATUS' + + % param dhcp_gatewaycustom=>$dhcp_data->{"params"}->{"gatewaycustom"}; + %=select_field dhcp_gatewaycustom=>$dhcp_data->{"status"} +
+ + + %=l 'dhcpd_CUSTOM_GATEWAY_ADDRESS' + + % 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" +

+ %= $c->l("dhcpd_CUSTOM_LEASETIME_TITLE"); +
+ + %=l 'dhcpd_CUSTOM_LEASETIME' + + % param dhcp_leasetime=>$dhcp_data->{"params"}->{"leasetime"}; + %=number_field 'dhcp_leasetime' +

+ %= submit_button "$btn", class => 'action' + % end + %} + +
+ +%= javascript begin + document.getElementById("load").style.display="none"; + function showSpinner(){ + document.getElementById("scanLeases").style.display="none"; + document.getElementById("load").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 diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep 1970-01-01 01:00:00.000000000 +0100 +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep 2022-03-09 10:06:00.000000000 +0000 @@ -0,0 +1,113 @@ +
+ + +
+ %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd1', onclick=>"showSpinner()", id=>"scanLeases" + + + + %= button_to $c->l('dhcpd_REMOVE_ALL_LEASES') => '/dhcpd4' +
+
+ % my $btn = l('dhcpd_SAVE/RESTART'); + %= form_for '/dhcpd10' => (method => 'POST') => begin + + %=l 'dhcpd_CHECK_CLIENT_STATUS' + + % param dhcp_check=>$dhcp_data->{"params"}->{"check"}; + %=select_field dhcp_check=>$dhcp_data->{"check"} +
+
+ %= $c->l("dhcpd_SAVE_TITLE"); +
+ %= submit_button "$btn", class => 'action' + % end +
+ + + + + + + + + + + % foreach my $ip (@$leases) { + + %= t td => (class => 'sme-border') => $ip->{ip} + %= t td => (class => 'sme-border') => $ip->{name} + + %= t td => (class => 'sme-border') => $ip->{start} + %= t td => (class => 'sme-border') => $ip->{end} + %= t td => (class => 'sme-border') => $ip->{mac} + + + %} + +
+ %=l 'dhcpd_IP' + + %=l 'dhcpd_NETWORK_NAME' + + %=l 'dhcpd_STATUS_CLICK_FOR_WOL' + + %=l('dhcpd_START_DATE',"") + + %=l 'dhcpd_END_DATE' + + %=l 'dhcpd_MAC_ADDRESS' + + %=l 'dhcpd_ACTION' +
+ % if ($ip->{wol} =~ /ACTIVE/) { +
<%==l $ip->{wol}%>
+ %} else { +
<%==l $ip->{wol}%>
+ %} +
+
<%=l 'dhcpd_REMOVE'%>
+
+
<%=l 'dhcpd_WINPOPUP_ACTION'%>
+
+ %= hidden_field "hiddenmsg"=>"", id=>"hiddenmsg" +
+ %= 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 (prompt(msg+" IP: "+IP)) + { return true;} + else {event.preventDefault();return false;} + } + + %end + + +
\ No newline at end of file