diff -Nur smeserver-dhcpmanager-1.5-old/root/etc/e-smith/web/functions/dhcpd smeserver-dhcpmanager-1.5/root/etc/e-smith/web/functions/dhcpd --- smeserver-dhcpmanager-1.5-old/root/etc/e-smith/web/functions/dhcpd 2014-01-13 23:06:55.000000000 +0100 +++ smeserver-dhcpmanager-1.5/root/etc/e-smith/web/functions/dhcpd 2014-01-13 23:07:32.000000000 +0100 @@ -6,7 +6,7 @@ # navigation : 6000 6900 # # Copyright (c) 2003 Thierry Quaak thierry@quaak.net -# +# 2014 Stephane de Labrusse stephdl@de-labrusse.fr #---------------------------------------------------------------------- ###Set NameSpace of Panel @@ -37,8 +37,12 @@ sub Message ($$); sub Global_WinPopup ($); sub Perform_Message ($); -sub Table_IP ($); +sub Table_IP ($$); sub Scan_Local_Network ($); +sub Del_all_Lease ($); +sub Perform_del_all_Lease ($); +sub Save_checkip ($); + ### Clear PATH and related environment variables so that calls to ### external programs do not cause results to be tainted. See ### "perlsec" manual page for details. @@ -75,7 +79,7 @@ my $q = new CGI; if (! grep (/^state$/, $q->param)){ Main_Display($q, '');} elsif ($q->param ('state') eq "main_display"){Main_Display ($q,'');} -elsif ($q->param ('state') eq "Refresh"){Table_IP ($q);} +elsif ($q->param ('state') eq "Refresh"){Table_IP ($q, '');} elsif ($q->param ('state') eq "main_save"){Main_Save ($q);} elsif ($q->param ('state') eq "del_lease"){Del_Lease ($q);} elsif ($q->param ('state') eq "perform_del_lease"){Perform_Del_Lease ($q);} @@ -84,9 +88,11 @@ elsif ($q->param ('state') eq "Global WinPopup"){Global_WinPopup ($q);} elsif ($q->param ('state') eq "message"){Message ($q,'');} elsif ($q->param ('state') eq "perform_message"){Perform_Message ($q);} -elsif ($q->param ('state') eq "Connected IP"){Table_IP ($q);} +elsif ($q->param ('state') eq "Connected IP"){Table_IP ($q,'');} elsif ($q->param ('state') eq "Scan your Network"){Scan_Local_Network ($q);} - +elsif ($q->param ('state') eq "Remove all entries"){Del_all_Lease ($q);} +elsif ($q->param ('state') eq "Remove all dhcp leases"){Perform_del_all_Lease ($q);} +elsif ($q->param ('state') eq 'Save/Restart'){Save_checkip ($q);} else{esmith::cgi::genStateError ($q, \%conf);} exit (0); @@ -127,30 +133,30 @@ #print $q->h3 ('Managing DHCP clients...'); print $q->table ({border => 0, cellspacing => 0, cellpadding => 4}, - esmith::cgi::genWidgetRow ($q, "Always check status of computers in the panel \"Connected IP\" (No is much faster, need Save/Restart) ", + esmith::cgi::genWidgetRow ($q, "Always check status of computers in the panel \"Connected IP\" (No is much faster. Use Save/Restart below to activate your changes) ", $q->popup_menu (-name => 'dhcp_check', -values => ['disabled', 'enabled'], -default => $sme_conf{'check'}, -labels => \%check)) ); - # Go to see table connected ip + #see table connected ip -> Table_ip #print $q->p ; print $q->table ({border => 0, cellspacing => 0, cellpadding => 4}, esmith::cgi::genTextRow ($q, - $q->p ('You may want to see all connected computer to the dhcpd server ?'))); + $q->p ('Show all devices connected to the dhcp server :'))); print $q->Tr (esmith::cgi::genButtonRow ($q,$q->submit (-name => 'state',-value => 'Connected IP'))); - # Go to scan the local network + # scan the local network with nmap #print $q->p ; print $q->table ({border => 0, cellspacing => 0, cellpadding => 4}, esmith::cgi::genTextRow ($q, - $q->p ('You may want to scan your network to know how many hosts are up ?'))); + $q->p ('Scan your network to show active devices :'))); print $q->Tr (esmith::cgi::genButtonRow ($q,$q->submit (-name => 'state',-value => 'Scan your Network'))); #Global Winpopup print $q->table ({border => 0, cellspacing => 0, cellpadding => 4}, esmith::cgi::genTextRow ($q, - $q->p ('You may want to send a global WinPopup to all connected computer compatible with Net send protocol ?'))); + $q->p ('Send a global WinPopup with Net send protocol to all connected devices using a compatible client'))); print $q->Tr (esmith::cgi::genButtonRow ($q,$q->submit (-name => 'state',-value => 'Global WinPopup'))); print $q->hidden (-name => 'liste_connected', -override => 1, -default => "@liste_connected"); @@ -284,8 +290,8 @@ my $dhcpd_dns2server = $q->param ('dhcp_dns2server'); my $dhcpd_gatewaycustom = $q->param ('dhcp_gatewaycustom'); my $dhcpd_gateway = $q->param ('dhcp_gateway'); + ###Update SME configuration dbase - ##Create object to spammassassin dbase my $dbh_sme = esmith::ConfigDB->open('/home/e-smith/db/configuration'); ##Initiate get method --> create record object @@ -418,21 +424,9 @@ # - 4 expand templates # changed to new sme standard signal-event - #system ("/sbin/e-smith/expand-template", "/etc/dhcpd.conf", "") == 0 ; - - ###Rebuild spamassassin hooks into procmail and restart deamon - #system ("/etc/e-smith/events/actions/restart-dhcpd") == 0 - #or die ("Error occurred while restarting dhcpd.\n"); - #system ("/etc/init.d/dhcpd","restart") == 0 system ("/sbin/e-smith/signal-event","conf-dhcpmanager") == 0 or die ("Error occurred while restarting dhcpd.\n"); - ###Display processed message - esmith::cgi::genHeaderNonCacheable ($q, \%conf, 'DHCPd Settings'); - print $q->h3('Operation status report...'); - print $q->p("Successfully saved settings.... DHCPd restarted !\n"); - print $q->p("Click Here to return to" . - " main DHCPd panel.\n"); - esmith::cgi::genFooter ($q); + Main_Display($q, "Successfully saved settings" ); exit; } @@ -510,21 +504,17 @@ close(OUTFILE); # changed to new sme standard signal-event - ###Rebuild spamassassin hooks into procmail and restart deamon - #system ("/etc/e-smith/events/actions/restart-dhcpd") == 0 - #or die ("Error occurred while restarting dhcpd.\n"); - #system ("/etc/init.d/dhcpd","restart") == 0 - #or die ("Error occurred while restarting dhcpd.\n"); - system ("/sbin/e-smith/signal-event","conf-dhcpmanager") == 0 + system ("/sbin/e-smith/signal-event","conf-dhcpmanager") == 0 or die ("Error occurred while restarting dhcpd.\n"); ###Return action message - Main_Display($q, "Successfully deleted $name at $ip in dhcpd.leases. " ); + #Main_Display($q, "Successfully deleted $name at $ip in dhcpd.leases. " ); + Table_IP($q, "Successfully deleted $name at $ip in dhcpd.leases. " ); exit; } #=============================================================================== -#SUBROUTINE: procedure qui supprime un bail dans le dhcpd.leases +#SUBROUTINE: procedure qui valide les parametres de l'host eteint #=============================================================================== sub Wake_Up ($){ ###Pull CGI object from parameters array @@ -574,9 +564,9 @@ #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 - Main_Display($q, "Successfully request to wake up $name at $mac . The computer may take time to wake up. " ); + #Main_Display($q, "Successfully request to wake up $name at $mac . The computer may take time to wake up. " ); + Table_IP($q, "Successfully request to wake up $name at $mac . The computer may take time to wake up. "); exit; } @@ -635,7 +625,8 @@ $work_line =~ s/^;//; $work_line =~ s/"//g; $work_line =~ s/;$//; - push(@liste_computer,$work_line) ; + push(@liste_computer,$work_line) ; + @liste_computer= sort(@liste_computer); } } close(FILE); @@ -692,12 +683,13 @@ foreach (@liste_connected){ system ("/etc/e-smith/events/actions/send-message","$_","$message2send") ; } - Main_Display($q, "Successfully sent message popup to @liste_connected. Warning, there is no garanty that the popup will appear on the remote computer. " ); + #Main_Display($q, "Successfully sent message popup to @liste_connected. Warning, there is no garanty that the popup will appear on the remote computer. " ); + Table_IP($q, "Successfully sent message popup to @liste_connected. Warning, there is no garanty that the popup will appear on the remote computer. " ); exit; } #=============================================================================== -#SUBROUTINE: +#SUBROUTINE: Win Popup for all connected hosts #=============================================================================== sub Global_WinPopup($){ @@ -708,9 +700,9 @@ } #=============================================================================== -#SUBROUTINE: Perform Table_IP of dhcp server +#SUBROUTINE: Create Table_IP of dhcp server #=============================================================================== -sub Table_IP ($) { +sub Table_IP ($$) { ###Pull cgi object from parameters array my $q = shift; my @computer; @@ -739,32 +731,39 @@ print $q->p (''); print $q->startform (-method => 'POST', -action => $q->url (-absolute => 1)); - #print $q->hr; - #print $q->h3 ('Managing DHCP clients...'); - + print $q->table ({border => 0, cellspacing => 0, cellpadding => 4}, - esmith::cgi::genWidgetRow ($q, "Always check status of connected IP in the manager (No is much faster, need Save/Restart) ", + esmith::cgi::genWidgetRow ($q, "Always check status of computers in the panel (No is much faster. Use Save/Restart below to activate your changes) ", $q->popup_menu (-name => 'dhcp_check', -values => ['disabled', 'enabled'], -default => $sme_conf{'check'}, -labels => \%check)) ); + + ##save checkip ('Saving modification and restart the daemon...') and go to sub Save_checkip :) + #print $q->h3 ('Saving modification and restart the daemon...'); + print $q->table ({border => 0, cellspacing => 0, cellpadding => 4}, + esmith::cgi::genTextRow ($q, + $q->p ('After changing the check IP setting above, you must save and' . + ' restart dhcpd.'))); + + print $q->Tr (esmith::cgi::genButtonRow ($q, + $q->submit (-name => 'state', -value => 'Save/Restart'))); + # Refresh Liste #print $q->p ; print $q->table ({border => 0, cellspacing => 0, cellpadding => 4}, esmith::cgi::genTextRow ($q, - $q->p ('You may want to refresh this list ?'))); + $q->p ('You may want to refresh this list ?'))) ; print $q->Tr (esmith::cgi::genButtonRow ($q,$q->submit (-name => 'state',-value => 'Refresh'))); #print $q->hr; - #print $q->h3 ('Saving modification and restart the daemon...'); print $q->table ({border => 0, cellspacing => 0, cellpadding => 4}, esmith::cgi::genTextRow ($q, - $q->p ('After changing the check setting above, you must save and' . - ' restart dhcpd.'))); + $q->p ('You may want to clean all dhcp leases below ?'))) ; + print $q->Tr (esmith::cgi::genButtonRow ($q,$q->submit (-name => 'state',-value => 'Remove all entries'))); + - print $q->Tr (esmith::cgi::genButtonRow ($q, - $q->submit (-name => 'action', -value => 'Save/Restart'))); - print $q->hidden (-name => 'state', -override => 1, -default => 'main_save'); + print $q->p("Click Here to return to" . " main DHCPd panel.\n"); @@ -774,13 +773,15 @@ print $q->table ({border => 1, cellspacing => 1, cellpadding => 4,nowarp => 1}); print $q->Tr (esmith::cgi::genSmallCell ($q, $q->p ( '