SMP-Config angepasst.. CGIs usw. wurden im Windoof-Format gespeichert... muss noch alles korrigiert werden...

git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@67 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
This commit is contained in:
ms
2006-02-21 20:38:06 +00:00
parent 7ac38dc927
commit ac1cfefab2
49 changed files with 42817 additions and 42814 deletions

View File

@@ -1,482 +1,482 @@
#!/usr/bin/perl
#
# IPCop CGI's - aliases.cgi
#
# This code is distributed under the terms of the GPL
#
# (c) Steve Bootes 2002/04/13 - Manage IP Aliases
#
# $Id: aliases.cgi,v 1.5.2.14 2006/01/13 20:14:48 eoberlander Exp $
# to fully troubleshot your code, uncomment diagnostics, Carp and cluck lines
#use diagnostics; # need to add the file /usr/lib/perl5/5.8.x/pods/perldiag.pod before to work
# next look at /var/log/httpd/error_log , http://www.perl.com/pub/a/2002/05/07/mod_perl.html may help
use warnings;
use strict;
#use Carp ();
#local $SIG{__WARN__} = \&Carp::cluck;
require 'CONFIG_ROOT/general-functions.pl'; # replace CONFIG_ROOT with /var/ipcop in case of manual install
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::colouryellow} );
@dummy = ( ${Header::table1colour} );
@dummy = ( ${Header::table2colour} );
undef (@dummy);
# Files used
my $setting = "${General::swroot}/ethernet/settings";
our $datafile = "${General::swroot}/ethernet/aliases";
our %settings=();
#Settings1
#Settings2 for editing the multi-line list
#Must not be saved !
$settings{'IP'} = '';
$settings{'ENABLED'} = 'off'; # Every check box must be set to off
$settings{'NAME'} = '';
my @nosaved=('IP','ENABLED','NAME'); # List here ALL setting2 fields. Mandatory
$settings{'ACTION'} = ''; # add/edit/remove
$settings{'KEY1'} = ''; # point record for ACTION
#Define each field that can be used to sort columns
my $sortstring='^IP|^NAME';
my $errormessage = '';
my $warnmessage = '';
&Header::showhttpheaders();
# Read needed Ipcop netsettings
my %netsettings=();
$netsettings{'SORT_ALIASES'} = 'NAME'; # default sort
&General::readhash($setting, \%netsettings);
#Get GUI values
&Header::getcgihash(\%settings);
# Load multiline data
our @current = ();
if (open(FILE, "$datafile")) {
@current = <FILE>;
close (FILE);
}
#
# Check Settings1 first because they are needed before working on @current
#
# Remove if no Setting1 needed
#
if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
#
#Validate static Settings1 here
#
unless ($errormessage) { # Everything is ok, save settings
#map (delete ($settings{$_}) ,(@nosaved,'ACTION','KEY1'));# Must never be saved
#&General::writehash($setting, \%settings); # Save good settings
#$settings{'ACTION'} = $Lang::tr{'save'}; # Recreate 'ACTION'
#map ($settings{$_}= '',(@nosaved,'KEY1')); # and reinit var to empty
# Rebuild configuration file if needed
&BuildConfiguration;
}
ERROR: # Leave the faulty field untouched
} else {
#&General::readhash($setting, \%settings); # Get saved settings and reset to good if needed
}
## Now manipulate the multi-line list with Settings2
# Basic actions are:
# toggle the check box
# add/update a new line
# begin editing a line
# remove a line
# Toggle enable/disable field. Field is in second position
if ($settings{'ACTION'} eq $Lang::tr{'toggle enable disable'}) {
#move out new line
chomp(@current[$settings{'KEY1'}]);
my @temp = split(/\,/,@current[$settings{'KEY1'}]);
$temp[1] = $temp[1] eq 'on' ? '' : 'on'; # Toggle the field
@current[$settings{'KEY1'}] = join (',',@temp)."\n";
$settings{'KEY1'} = ''; # End edit mode
&General::log($Lang::tr{'ip alias changed'});
#Save current
open(FILE, ">$datafile") or die 'Unable to open aliases file.';
print FILE @current;
close(FILE);
# Rebuild configuration file
&BuildConfiguration;
}
if ($settings{'ACTION'} eq $Lang::tr{'add'}) {
# Validate inputs
if (! &General::validip($settings{'IP'})) {$errormessage = "invalid ip"};
$settings{'NAME'} = &Header::cleanhtml($settings{'NAME'});
# Make sure we haven't duplicated an alias or RED
my $spacer='';
if ($settings{'IP'} eq $netsettings{'RED_ADDRESS'}) {
$errormessage = $Lang::tr{'duplicate ip'} . ' (RED)';
$spacer=" & ";
}
my $idx=0;
foreach my $line (@current) {
chomp ($line);
my @temp = split (/\,/, $line);
if ( ($settings{'KEY1'} eq '')||(($settings{'KEY1'} ne '') && ($settings{'KEY1'} != $idx))) { # update
if ($temp[0] eq $settings{'IP'}) {
$errormessage .= $spacer.$Lang::tr{'duplicate ip'};
$spacer=" & ";
}
if ($temp[2] eq $settings{'NAME'} && $temp[2] ne '') {
$errormessage .= $spacer.$Lang::tr{'duplicate name'};
$spacer=" & ";
}
}
$idx++;
}
unless ($errormessage) {
if ($settings{'KEY1'} eq '') { #add or edit ?
unshift (@current, "$settings{'IP'},$settings{'ENABLED'},$settings{'NAME'}\n");
&General::log($Lang::tr{'ip alias added'});
} else {
@current[$settings{'KEY1'}] = "$settings{'IP'},$settings{'ENABLED'},$settings{'NAME'}\n";
$settings{'KEY1'} = ''; # End edit mode
&General::log($Lang::tr{'ip alias changed'});
}
# Write changes to config file.
&SortDataFile; # sort newly added/modified entry
&BuildConfiguration; # then re-build conf which use new data
##
## if entering data line is repetitive, choose here to not erase fields between each addition
##
map ($settings{$_}='' ,@nosaved); # Clear fields
}
}
if ($settings{'ACTION'} eq $Lang::tr{'edit'}) {
#move out new line
my $line = @current[$settings{'KEY1'}]; # KEY1 is the index in current
chomp($line);
my @temp = split(/\,/, $line);
##
## move data fields to Setting2 for edition
##
$settings{'IP'}=$temp[0]; # Prepare the screen for editing
$settings{'ENABLED'}=$temp[1];
$settings{'NAME'}=$temp[2];
}
if ($settings{'ACTION'} eq $Lang::tr{'remove'}) {
splice (@current,$settings{'KEY1'},1); # Delete line
open(FILE, ">$datafile") or die 'Unable to open aliases file.';
print FILE @current;
close(FILE);
$settings{'KEY1'} = ''; # End remove mode
&General::log($Lang::tr{'ip alias removed'});
&BuildConfiguration; # then re-build conf which use new data
}
## Check if sorting is asked
# If same column clicked, reverse the sort.
if ($ENV{'QUERY_STRING'} =~ /$sortstring/ ) {
my $newsort=$ENV{'QUERY_STRING'};
my $actual=$netsettings{'SORT_ALIASES'};
#Reverse actual sort ?
if ($actual =~ $newsort) {
my $Rev='';
if ($actual !~ 'Rev') {
$Rev='Rev';
}
$newsort.=$Rev;
}
$netsettings{'SORT_ALIASES'}=$newsort;
&General::writehash($setting, \%netsettings);
&SortDataFile;
$settings{'ACTION'} = 'SORT'; # Recreate 'ACTION'
}
# Default initial value
if ($settings{'ACTION'} eq '' ) { # First launch from GUI
$settings{'ENABLED'} ='on';
}
&Header::openpage($Lang::tr{'external aliases configuration'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
my %checked =(); # Checkbox manipulations
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>";
&Header::closebox();
}
unless (( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ ) && ($netsettings{'RED_TYPE'} eq 'STATIC'))
{
&Header::openbox('100%', 'left', $Lang::tr{'capswarning'});
print <<END
<table width='100%'>
<tr>
<td width='100%' class='boldbase' align='center'><font color='${Header::colourred}'><b>$Lang::tr{'aliases not active'}</b></font></td>
</tr>
</table>
END
;
&Header::closebox();
}
#
# Second check box is for editing the list
#
$checked{'ENABLED'}{'on'} = ($settings{'ENABLED'} eq '') ? '' : "checked='checked'";
my $buttontext = $Lang::tr{'add'};
if ($settings{'KEY1'} ne '') {
$buttontext = $Lang::tr{'update'};
&Header::openbox('100%', 'left', $Lang::tr{'edit an existing alias'});
} else {
&Header::openbox('100%', 'left', $Lang::tr{'add new alias'});
}
#Edited line number (KEY1) passed until cleared by 'save' or 'remove' or 'new sort order'
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='KEY1' value='$settings{'KEY1'}' />
<table width='100%'>
<tr>
<td class='base'><font color='${Header::colourred}'>$Lang::tr{'name'}:&nbsp;<img src='/blob.gif' alt='*' /></font></td>
<td><input type='text' name='NAME' value='$settings{'NAME'}' size='32' /></td>
<td class='base' align='right'><font color='${Header::colourred}'>$Lang::tr{'alias ip'}:&nbsp;</font></td>
<td><input type='text' name='IP' value='$settings{'IP'}' size='16' /></td>
<td class='base' align='right'>$Lang::tr{'enabled'}&nbsp;</td>
<td><input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td>
</tr>
</table>
<hr />
<table width='100%'>
<tr>
<td class='base' width='50%'><img src='/blob.gif' align='top' alt='*' />&nbsp;$Lang::tr{'this field may be blank'}</td>
<td width='50%' align='center'><input type='hidden' name='ACTION' value='$Lang::tr{'add'}' /><input type='submit' name='SUBMIT' value='$buttontext' /></td>
</tr>
</table>
</form>
END
;
&Header::closebox();
#
# Third box shows the list, in columns
#
# Columns headers may content a link. In this case it must be named in $sortstring
#
&Header::openbox('100%', 'left', $Lang::tr{'current aliases'});
print <<END
<table width='100%'>
<tr>
<td width='50%' align='center'><a href='$ENV{'SCRIPT_NAME'}?NAME'><b>$Lang::tr{'name'}</b></a></td>
<td width='40%' align='center'><a href='$ENV{'SCRIPT_NAME'}?IP'><b>$Lang::tr{'alias ip'}</b></a></td>
<td width='10%' colspan='3' class='boldbase' align='center'><b>$Lang::tr{'action'}</b></td>
</tr>
END
;
#
# Print each line of @current list
#
# each data line is splitted into @temp.
#
my $key = 0;
foreach my $line (@current) {
chomp($line);
my @temp = split(/\,/,$line);
#Choose icon for checkbox
my $gif = '';
my $gdesc = '';
if ($temp[1] eq "on") {
$gif = 'on.gif';
$gdesc = $Lang::tr{'click to disable'};
} else {
$gif = 'off.gif';
$gdesc = $Lang::tr{'click to enable'};
}
#Colorize each line
if ($settings{'KEY1'} eq $key) {
print "<tr bgcolor='${Header::colouryellow}'>";
} elsif ($key % 2) {
print "<tr bgcolor='${Header::table2colour}'>";
} else {
print "<tr bgcolor='${Header::table1colour}'>";
}
print <<END
<td align='center'>$temp[2]</td>
<td align='center'>$temp[0]</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
<input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' alt='$gdesc' title='$gdesc' />
<input type='hidden' name='KEY1' value='$key' />
</form>
</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
<input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
<input type='hidden' name='KEY1' value='$key' />
</form>
</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
<input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' alt='$Lang::tr{'remove'}' title='$Lang::tr{'remove'}' />
<input type='hidden' name='KEY1' value='$key' />
</form>
</td>
</tr>
END
;
$key++;
}
print "</table>";
# If table contains entries, print 'Key to action icons'
if ($key) {
print <<END
<table>
<tr>
<td class='boldbase'>&nbsp;<b>$Lang::tr{'legend'}:&nbsp;</b></td>
<td><img src='/images/on.gif' alt='$Lang::tr{'click to disable'}' /></td>
<td class='base'>$Lang::tr{'click to disable'}</td>
<td>&nbsp;&nbsp;</td>
<td><img src='/images/off.gif' alt='$Lang::tr{'click to enable'}' /></td>
<td class='base'>$Lang::tr{'click to enable'}</td>
<td>&nbsp;&nbsp;</td>
<td><img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
<td class='base'>$Lang::tr{'edit'}</td>
<td>&nbsp;&nbsp;</td>
<td><img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
<td class='base'>$Lang::tr{'remove'}</td>
</tr>
</table>
END
;
}
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
## Ouf it's the end !
# Sort the "current" array according to choices
sub SortDataFile
{
our %entries = ();
# Sort pair of record received in $a $b special vars.
# When IP is specified use numeric sort else alpha.
# If sortname ends with 'Rev', do reverse sort.
#
sub fixedleasesort {
my $qs=''; # The sort field specified minus 'Rev'
if (rindex ($netsettings{'SORT_ALIASES'},'Rev') != -1) {
$qs=substr ($netsettings{'SORT_ALIASES'},0,length($netsettings{'SORT_ALIASES'})-3);
if ($qs eq 'IP') {
my @a = split(/\./,$entries{$a}->{$qs});
my @b = split(/\./,$entries{$b}->{$qs});
($b[0]<=>$a[0]) ||
($b[1]<=>$a[1]) ||
($b[2]<=>$a[2]) ||
($b[3]<=>$a[3]);
} else {
$entries{$b}->{$qs} cmp $entries{$a}->{$qs};
}
} else { #not reverse
$qs=$netsettings{'SORT_ALIASES'};
if ($qs eq 'IP') {
my @a = split(/\./,$entries{$a}->{$qs});
my @b = split(/\./,$entries{$b}->{$qs});
($a[0]<=>$b[0]) ||
($a[1]<=>$b[1]) ||
($a[2]<=>$b[2]) ||
($a[3]<=>$b[3]);
} else {
$entries{$a}->{$qs} cmp $entries{$b}->{$qs};
}
}
}
#Use an associative array (%entries)
my $key = 0;
foreach my $line (@current) {
chomp( $line); #remove newline because can be on field 5 or 6 (addition of REMARK)
my @temp = split (',',$line);
# Build a pair 'Field Name',value for each of the data dataline.
# Each SORTABLE field must have is pair.
# Other data fields (non sortable) can be grouped in one
# Exemple
# F1,F2,F3,F4,F5 only F1 F2 for sorting
# my @record = ('KEY',$key++,
# 'F1',$temp[0],
# 'F2',$temp[1],
# 'DATA',join(',',@temp[2..4]) ); #group remainning values, with separator (,)
# The KEY,key record permits doublons. If removed, then F1 becomes the key without doublon permitted.
my @record = ('KEY',$key++,'IP',$temp[0],'ENABLED',$temp[1],'NAME',$temp[2]);
my $record = {}; # create a reference to empty hash
%{$record} = @record; # populate that hash with @record
$entries{$record->{KEY}} = $record; # add this to a hash of hashes
}
open(FILE, ">$datafile") or die 'Unable to open aliases file.';
# Each field value is printed , with the newline ! Don't forget separator and order of them.
foreach my $entry (sort fixedleasesort keys %entries) {
print FILE "$entries{$entry}->{IP},$entries{$entry}->{ENABLED},$entries{$entry}->{NAME}\n";
}
close(FILE);
# Reload sorted @current
open (FILE, "$datafile");
@current = <FILE>;
close (FILE);
}
#
# Build the configuration file for application aliases
#
sub BuildConfiguration {
# Restart service associated with this
system '/usr/local/bin/setaliases';
}
#!/usr/bin/perl
#
# IPCop CGI's - aliases.cgi
#
# This code is distributed under the terms of the GPL
#
# (c) Steve Bootes 2002/04/13 - Manage IP Aliases
#
# $Id: aliases.cgi,v 1.5.2.14 2006/01/13 20:14:48 eoberlander Exp $
# to fully troubleshot your code, uncomment diagnostics, Carp and cluck lines
#use diagnostics; # need to add the file /usr/lib/perl5/5.8.x/pods/perldiag.pod before to work
# next look at /var/log/httpd/error_log , http://www.perl.com/pub/a/2002/05/07/mod_perl.html may help
use warnings;
use strict;
#use Carp ();
#local $SIG{__WARN__} = \&Carp::cluck;
require 'CONFIG_ROOT/general-functions.pl'; # replace CONFIG_ROOT with /var/ipcop in case of manual install
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::colouryellow} );
@dummy = ( ${Header::table1colour} );
@dummy = ( ${Header::table2colour} );
undef (@dummy);
# Files used
my $setting = "${General::swroot}/ethernet/settings";
our $datafile = "${General::swroot}/ethernet/aliases";
our %settings=();
#Settings1
#Settings2 for editing the multi-line list
#Must not be saved !
$settings{'IP'} = '';
$settings{'ENABLED'} = 'off'; # Every check box must be set to off
$settings{'NAME'} = '';
my @nosaved=('IP','ENABLED','NAME'); # List here ALL setting2 fields. Mandatory
$settings{'ACTION'} = ''; # add/edit/remove
$settings{'KEY1'} = ''; # point record for ACTION
#Define each field that can be used to sort columns
my $sortstring='^IP|^NAME';
my $errormessage = '';
my $warnmessage = '';
&Header::showhttpheaders();
# Read needed Ipcop netsettings
my %netsettings=();
$netsettings{'SORT_ALIASES'} = 'NAME'; # default sort
&General::readhash($setting, \%netsettings);
#Get GUI values
&Header::getcgihash(\%settings);
# Load multiline data
our @current = ();
if (open(FILE, "$datafile")) {
@current = <FILE>;
close (FILE);
}
#
# Check Settings1 first because they are needed before working on @current
#
# Remove if no Setting1 needed
#
if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
#
#Validate static Settings1 here
#
unless ($errormessage) { # Everything is ok, save settings
#map (delete ($settings{$_}) ,(@nosaved,'ACTION','KEY1'));# Must never be saved
#&General::writehash($setting, \%settings); # Save good settings
#$settings{'ACTION'} = $Lang::tr{'save'}; # Recreate 'ACTION'
#map ($settings{$_}= '',(@nosaved,'KEY1')); # and reinit var to empty
# Rebuild configuration file if needed
&BuildConfiguration;
}
ERROR: # Leave the faulty field untouched
} else {
#&General::readhash($setting, \%settings); # Get saved settings and reset to good if needed
}
## Now manipulate the multi-line list with Settings2
# Basic actions are:
# toggle the check box
# add/update a new line
# begin editing a line
# remove a line
# Toggle enable/disable field. Field is in second position
if ($settings{'ACTION'} eq $Lang::tr{'toggle enable disable'}) {
#move out new line
chomp(@current[$settings{'KEY1'}]);
my @temp = split(/\,/,@current[$settings{'KEY1'}]);
$temp[1] = $temp[1] eq 'on' ? '' : 'on'; # Toggle the field
@current[$settings{'KEY1'}] = join (',',@temp)."\n";
$settings{'KEY1'} = ''; # End edit mode
&General::log($Lang::tr{'ip alias changed'});
#Save current
open(FILE, ">$datafile") or die 'Unable to open aliases file.';
print FILE @current;
close(FILE);
# Rebuild configuration file
&BuildConfiguration;
}
if ($settings{'ACTION'} eq $Lang::tr{'add'}) {
# Validate inputs
if (! &General::validip($settings{'IP'})) {$errormessage = "invalid ip"};
$settings{'NAME'} = &Header::cleanhtml($settings{'NAME'});
# Make sure we haven't duplicated an alias or RED
my $spacer='';
if ($settings{'IP'} eq $netsettings{'RED_ADDRESS'}) {
$errormessage = $Lang::tr{'duplicate ip'} . ' (RED)';
$spacer=" & ";
}
my $idx=0;
foreach my $line (@current) {
chomp ($line);
my @temp = split (/\,/, $line);
if ( ($settings{'KEY1'} eq '')||(($settings{'KEY1'} ne '') && ($settings{'KEY1'} != $idx))) { # update
if ($temp[0] eq $settings{'IP'}) {
$errormessage .= $spacer.$Lang::tr{'duplicate ip'};
$spacer=" & ";
}
if ($temp[2] eq $settings{'NAME'} && $temp[2] ne '') {
$errormessage .= $spacer.$Lang::tr{'duplicate name'};
$spacer=" & ";
}
}
$idx++;
}
unless ($errormessage) {
if ($settings{'KEY1'} eq '') { #add or edit ?
unshift (@current, "$settings{'IP'},$settings{'ENABLED'},$settings{'NAME'}\n");
&General::log($Lang::tr{'ip alias added'});
} else {
@current[$settings{'KEY1'}] = "$settings{'IP'},$settings{'ENABLED'},$settings{'NAME'}\n";
$settings{'KEY1'} = ''; # End edit mode
&General::log($Lang::tr{'ip alias changed'});
}
# Write changes to config file.
&SortDataFile; # sort newly added/modified entry
&BuildConfiguration; # then re-build conf which use new data
##
## if entering data line is repetitive, choose here to not erase fields between each addition
##
map ($settings{$_}='' ,@nosaved); # Clear fields
}
}
if ($settings{'ACTION'} eq $Lang::tr{'edit'}) {
#move out new line
my $line = @current[$settings{'KEY1'}]; # KEY1 is the index in current
chomp($line);
my @temp = split(/\,/, $line);
##
## move data fields to Setting2 for edition
##
$settings{'IP'}=$temp[0]; # Prepare the screen for editing
$settings{'ENABLED'}=$temp[1];
$settings{'NAME'}=$temp[2];
}
if ($settings{'ACTION'} eq $Lang::tr{'remove'}) {
splice (@current,$settings{'KEY1'},1); # Delete line
open(FILE, ">$datafile") or die 'Unable to open aliases file.';
print FILE @current;
close(FILE);
$settings{'KEY1'} = ''; # End remove mode
&General::log($Lang::tr{'ip alias removed'});
&BuildConfiguration; # then re-build conf which use new data
}
## Check if sorting is asked
# If same column clicked, reverse the sort.
if ($ENV{'QUERY_STRING'} =~ /$sortstring/ ) {
my $newsort=$ENV{'QUERY_STRING'};
my $actual=$netsettings{'SORT_ALIASES'};
#Reverse actual sort ?
if ($actual =~ $newsort) {
my $Rev='';
if ($actual !~ 'Rev') {
$Rev='Rev';
}
$newsort.=$Rev;
}
$netsettings{'SORT_ALIASES'}=$newsort;
&General::writehash($setting, \%netsettings);
&SortDataFile;
$settings{'ACTION'} = 'SORT'; # Recreate 'ACTION'
}
# Default initial value
if ($settings{'ACTION'} eq '' ) { # First launch from GUI
$settings{'ENABLED'} ='on';
}
&Header::openpage($Lang::tr{'external aliases configuration'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
my %checked =(); # Checkbox manipulations
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>";
&Header::closebox();
}
unless (( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ ) && ($netsettings{'RED_TYPE'} eq 'STATIC'))
{
&Header::openbox('100%', 'left', $Lang::tr{'capswarning'});
print <<END
<table width='100%'>
<tr>
<td width='100%' class='boldbase' align='center'><font color='${Header::colourred}'><b>$Lang::tr{'aliases not active'}</b></font></td>
</tr>
</table>
END
;
&Header::closebox();
}
#
# Second check box is for editing the list
#
$checked{'ENABLED'}{'on'} = ($settings{'ENABLED'} eq '') ? '' : "checked='checked'";
my $buttontext = $Lang::tr{'add'};
if ($settings{'KEY1'} ne '') {
$buttontext = $Lang::tr{'update'};
&Header::openbox('100%', 'left', $Lang::tr{'edit an existing alias'});
} else {
&Header::openbox('100%', 'left', $Lang::tr{'add new alias'});
}
#Edited line number (KEY1) passed until cleared by 'save' or 'remove' or 'new sort order'
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='KEY1' value='$settings{'KEY1'}' />
<table width='100%'>
<tr>
<td class='base'><font color='${Header::colourred}'>$Lang::tr{'name'}:&nbsp;<img src='/blob.gif' alt='*' /></font></td>
<td><input type='text' name='NAME' value='$settings{'NAME'}' size='32' /></td>
<td class='base' align='right'><font color='${Header::colourred}'>$Lang::tr{'alias ip'}:&nbsp;</font></td>
<td><input type='text' name='IP' value='$settings{'IP'}' size='16' /></td>
<td class='base' align='right'>$Lang::tr{'enabled'}&nbsp;</td>
<td><input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td>
</tr>
</table>
<hr />
<table width='100%'>
<tr>
<td class='base' width='50%'><img src='/blob.gif' align='top' alt='*' />&nbsp;$Lang::tr{'this field may be blank'}</td>
<td width='50%' align='center'><input type='hidden' name='ACTION' value='$Lang::tr{'add'}' /><input type='submit' name='SUBMIT' value='$buttontext' /></td>
</tr>
</table>
</form>
END
;
&Header::closebox();
#
# Third box shows the list, in columns
#
# Columns headers may content a link. In this case it must be named in $sortstring
#
&Header::openbox('100%', 'left', $Lang::tr{'current aliases'});
print <<END
<table width='100%'>
<tr>
<td width='50%' align='center'><a href='$ENV{'SCRIPT_NAME'}?NAME'><b>$Lang::tr{'name'}</b></a></td>
<td width='40%' align='center'><a href='$ENV{'SCRIPT_NAME'}?IP'><b>$Lang::tr{'alias ip'}</b></a></td>
<td width='10%' colspan='3' class='boldbase' align='center'><b>$Lang::tr{'action'}</b></td>
</tr>
END
;
#
# Print each line of @current list
#
# each data line is splitted into @temp.
#
my $key = 0;
foreach my $line (@current) {
chomp($line);
my @temp = split(/\,/,$line);
#Choose icon for checkbox
my $gif = '';
my $gdesc = '';
if ($temp[1] eq "on") {
$gif = 'on.gif';
$gdesc = $Lang::tr{'click to disable'};
} else {
$gif = 'off.gif';
$gdesc = $Lang::tr{'click to enable'};
}
#Colorize each line
if ($settings{'KEY1'} eq $key) {
print "<tr bgcolor='${Header::colouryellow}'>";
} elsif ($key % 2) {
print "<tr bgcolor='${Header::table2colour}'>";
} else {
print "<tr bgcolor='${Header::table1colour}'>";
}
print <<END
<td align='center'>$temp[2]</td>
<td align='center'>$temp[0]</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
<input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' alt='$gdesc' title='$gdesc' />
<input type='hidden' name='KEY1' value='$key' />
</form>
</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
<input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
<input type='hidden' name='KEY1' value='$key' />
</form>
</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
<input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' alt='$Lang::tr{'remove'}' title='$Lang::tr{'remove'}' />
<input type='hidden' name='KEY1' value='$key' />
</form>
</td>
</tr>
END
;
$key++;
}
print "</table>";
# If table contains entries, print 'Key to action icons'
if ($key) {
print <<END
<table>
<tr>
<td class='boldbase'>&nbsp;<b>$Lang::tr{'legend'}:&nbsp;</b></td>
<td><img src='/images/on.gif' alt='$Lang::tr{'click to disable'}' /></td>
<td class='base'>$Lang::tr{'click to disable'}</td>
<td>&nbsp;&nbsp;</td>
<td><img src='/images/off.gif' alt='$Lang::tr{'click to enable'}' /></td>
<td class='base'>$Lang::tr{'click to enable'}</td>
<td>&nbsp;&nbsp;</td>
<td><img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
<td class='base'>$Lang::tr{'edit'}</td>
<td>&nbsp;&nbsp;</td>
<td><img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
<td class='base'>$Lang::tr{'remove'}</td>
</tr>
</table>
END
;
}
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
## Ouf it's the end !
# Sort the "current" array according to choices
sub SortDataFile
{
our %entries = ();
# Sort pair of record received in $a $b special vars.
# When IP is specified use numeric sort else alpha.
# If sortname ends with 'Rev', do reverse sort.
#
sub fixedleasesort {
my $qs=''; # The sort field specified minus 'Rev'
if (rindex ($netsettings{'SORT_ALIASES'},'Rev') != -1) {
$qs=substr ($netsettings{'SORT_ALIASES'},0,length($netsettings{'SORT_ALIASES'})-3);
if ($qs eq 'IP') {
my @a = split(/\./,$entries{$a}->{$qs});
my @b = split(/\./,$entries{$b}->{$qs});
($b[0]<=>$a[0]) ||
($b[1]<=>$a[1]) ||
($b[2]<=>$a[2]) ||
($b[3]<=>$a[3]);
} else {
$entries{$b}->{$qs} cmp $entries{$a}->{$qs};
}
} else { #not reverse
$qs=$netsettings{'SORT_ALIASES'};
if ($qs eq 'IP') {
my @a = split(/\./,$entries{$a}->{$qs});
my @b = split(/\./,$entries{$b}->{$qs});
($a[0]<=>$b[0]) ||
($a[1]<=>$b[1]) ||
($a[2]<=>$b[2]) ||
($a[3]<=>$b[3]);
} else {
$entries{$a}->{$qs} cmp $entries{$b}->{$qs};
}
}
}
#Use an associative array (%entries)
my $key = 0;
foreach my $line (@current) {
chomp( $line); #remove newline because can be on field 5 or 6 (addition of REMARK)
my @temp = split (',',$line);
# Build a pair 'Field Name',value for each of the data dataline.
# Each SORTABLE field must have is pair.
# Other data fields (non sortable) can be grouped in one
# Exemple
# F1,F2,F3,F4,F5 only F1 F2 for sorting
# my @record = ('KEY',$key++,
# 'F1',$temp[0],
# 'F2',$temp[1],
# 'DATA',join(',',@temp[2..4]) ); #group remainning values, with separator (,)
# The KEY,key record permits doublons. If removed, then F1 becomes the key without doublon permitted.
my @record = ('KEY',$key++,'IP',$temp[0],'ENABLED',$temp[1],'NAME',$temp[2]);
my $record = {}; # create a reference to empty hash
%{$record} = @record; # populate that hash with @record
$entries{$record->{KEY}} = $record; # add this to a hash of hashes
}
open(FILE, ">$datafile") or die 'Unable to open aliases file.';
# Each field value is printed , with the newline ! Don't forget separator and order of them.
foreach my $entry (sort fixedleasesort keys %entries) {
print FILE "$entries{$entry}->{IP},$entries{$entry}->{ENABLED},$entries{$entry}->{NAME}\n";
}
close(FILE);
# Reload sorted @current
open (FILE, "$datafile");
@current = <FILE>;
close (FILE);
}
#
# Build the configuration file for application aliases
#
sub BuildConfiguration {
# Restart service associated with this
system '/usr/local/bin/setaliases';
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,488 +1,488 @@
#!/usr/bin/perl
#
# IPCop CGI's - base.cgi
#
# This code is distributed under the terms of the GPL
#
# (c) place a name here
#
# $Id: base.cgi,v 1.1.2.10 2005/11/03 19:20:50 franck78 Exp $
#
#
# This file is a starting base for writting a new GUI screen using the three box model
# Box 1 : global settings for the application
# Box 2 : line editor for multiple data line
# Box 3 : the list of data line, with edit/remove buttons
#
# This example do the following
# Read global settings:
# a NAME and an interface (IT)
# Lines of data composed of:
# an ipaddress (IP), an enabled/disabled options (CB), a comment (CO)
#
#
# All you need to do is
# replace 'XY' with your app name
# define your global $settings{'var name'}
# define your strings
# write validation code for Settings1 and Settings2
# write HTML box Settings1 and Settings2
# adapt the sort function
# write the correct configuration file
#
#
# to fully troubleshot your code, uncomment diagnostics, Carp and cluck lines
# use diagnostics; # need to add the file /usr/lib/perl5/5.8.x/pods/perldiag.pod before to work
# next look at /var/log/httpd/error_log , http://www.perl.com/pub/a/2002/05/07/mod_perl.html may help
#use warnings;
use strict;
#use Carp ();
#local $SIG{__WARN__} = \&Carp::cluck;
require '/var/ipcop/general-functions.pl'; # Replace all occurences of </var/ipcop> with CONFIG_ROOT
# before updating cvs IPCop file.
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
# Files used
our $setting = "${General::swroot}/XY/settings"; # particular settings
my $datafile = "${General::swroot}/XY/data"; # repeted settings (multilines)
our $conffile = "${General::swroot}/XY/XY.conf"; # Config file for application XY
# strings to add to languages databases or in addon language file
$Lang::tr{'XY title'} = 'XY service';
$Lang::tr{'XY settings'} = 'XY setup';
$Lang::tr{'XY add data'} = 'add data';
$Lang::tr{'XY edit data'} = 'edit data';
$Lang::tr{'XY data'} = 'XY data';
# informationnal & log strings, no translation required
my $msg_added = 'XY added';
my $msg_modified = 'XY modified';
my $msg_deleted = 'XY removed';
my $msg_datafileerror = 'XY data file error';
our $msg_configfileerror = 'XY configuration file error';
my %settings=();
# Settings1
$settings{'NAME'} = ''; # a string field than must be 'GOOD' or 'good'
$settings{'IT'} = ''; # a 'choose' field for color interface
$settings{'TURBO'} = 'off'; # a checkbox field to enable something
# Settings2 for editing the multi-line list
# Must not be saved by writehash !
$settings{'IP'} = ''; # datalines are: IPaddress,enable,comment
$settings{'CB'} = 'off'; # Every check box must be set to off
$settings{'COMMENT'} = '';
my @nosaved=('IP','CB','COMMENT'); # List here ALL setting2 fields. Mandatory
$settings{'ACTION'} = ''; # add/edit/remove....
$settings{'KEY1'} = ''; # point record for ACTION
# Define each field that can be used to sort columns
my $sortstring='^IP|^COMMENT';
my $errormessage = '';
my $warnmessage = '';
&Header::showhttpheaders();
# Read needed Ipcop settings (exemple)
my %mainsettings=();
&General::readhash("${General::swroot}/main/settings", \%mainsettings);
# Get GUI values
&Header::getcgihash(\%settings);
# Load multiline data. Do it before use in save action
our $f = new Multilines (filename => $datafile,
fields => ['IP','CB','COMMENT'],
comment => 1
);
##
## SAVE Settings1
##
# Remove if no Settings1 needed
if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
#
#Validate static Settings1 here
#
if (($settings{"NAME"} ne "GOOD") &&
($settings{"NAME"} ne "good")) {
$errormessage = 'Enter good or GOOD in Name field';
}
unless ($errormessage) { # Everything is ok, save settings
map (delete ($settings{$_}) ,(@nosaved,'ACTION','KEY1'));# Must never be saved
&General::writehash($setting, \%settings); # Save good settings
$settings{'ACTION'} = $Lang::tr{'save'}; # Recreate 'ACTION'
map ($settings{$_}= '',(@nosaved,'KEY1')); # and reinit var to empty
# Rebuild configuration file if needed
&BuildConfiguration;
}
ERROR: # Leave the faulty field untouched
} else {
&General::readhash($setting, \%settings); # Get saved settings and reset to good if needed
}
##
## Now manipulate the multiline list with Settings2
##
# Basic actions are:
# toggle the check box
# add/update a new line
# begin editing a line
# remove a line
# $KEY1 contains the index of the line manipulated
##
## Toggle CB field.
##
if ($settings{'ACTION'} eq $Lang::tr{'toggle enable disable'}) {
$f->togglebyfields($settings{'KEY1'},'CB'); # toggle checkbox
$settings{'KEY1'} = ''; # End edit mode
&General::log($msg_modified);
# save changes
$f->savedata || die "$msg_datafileerror";
# Rebuild configuration file
&BuildConfiguration;
}
##
## ADD/UPDATE a line of configuration from Settings2
##
if ($settings{'ACTION'} eq $Lang::tr{'add'}) {
# Validate inputs
if (! &General::validip($settings{'IP'})) {$errormessage = "Specify an IP value !"};
if (! $settings{'COMMENT'} ) {$warnmessage = "no comment specified"};
unless ($errormessage) {
if ($settings{'KEY1'} eq '') { #add or edit ?
# insert new data line
$f->writedata(-1, $settings{'IP'},$settings{'CB'},$settings{'COMMENT'});
&General::log($msg_added);
} else {
# modify data line
$f->writedata($settings{'KEY1'}, $settings{'IP'},$settings{'CB'},$settings{'COMMENT'});
$settings{'KEY1'} = ''; # End edit mode
&General::log($msg_modified);
}
# save changes
$f->savedata || die "$msg_datafileerror";
# Rebuild configuration file
&BuildConfiguration;
# if entering data line is a repetitive task, choose here to not erase fields between each addition
map ($settings{$_}='' ,@nosaved);
}
}
##
## begin EDIT: move data fields to Settings2 controls
##
if ($settings{'ACTION'} eq $Lang::tr{'edit'}) {
$f->readdata ($settings{'KEY1'},
$settings{'IP'},
$settings{'CB'},
$settings{'COMMENT'});
}
##
## REMOVE: remove selected line
##
if ($settings{'ACTION'} eq $Lang::tr{'remove'}) {
$f->deleteline ($settings{'KEY1'});
$settings{'KEY1'} = ''; # End remove mode
&General::log($msg_deleted);
# save changes
$f->savedata || die "$msg_datafileerror";
# Rebuild configuration file
&BuildConfiguration;
}
##
## Check if sorting is asked
##
if ($ENV{'QUERY_STRING'} =~ /$sortstring/ ) {
my $newsort=$ENV{'QUERY_STRING'};
my $actual=$settings{'SORT_XY'};
# Reverse actual sort or choose new column ?
if ($actual =~ $newsort) {
$f->setsortorder ($newsort ,rindex($actual,'Rev'));
$newsort .= rindex($actual,'Rev')==-1 ? 'Rev' : '';
} else {
$f->setsortorder ($newsort ,1);
}
$f->savedata; # Synchronise file & display
$settings{'SORT_XY'} = $newsort;
map (delete ($settings{$_}) ,(@nosaved,'ACTION','KEY1')); # Must never be saved
&General::writehash($setting, \%settings);
$settings{'ACTION'} = 'SORT'; # Recreate an 'ACTION'
map ($settings{$_}= '',(@nosaved,,'KEY1')); # and reinit var to empty
}
##
## Remove if no Setting1 needed
##
if ($settings{'ACTION'} eq '' ) { # First launch from GUI
# Place here default value when nothing is initialized
}
&Header::openpage($Lang::tr{'XY title'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
my %checked =(); # Checkbox manipulations
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>";
&Header::closebox();
}
##
## First box Settings1. Remove if not needed
##
$warnmessage = "<font color=${Header::colourred}><b>$Lang::tr{'capswarning'}</b></font>: $warnmessage" if ($warnmessage);
&Header::openbox('100%', 'left', $Lang::tr{'XY settings'});
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>";
$checked{'IT'}{'RED'} = '';
$checked{'IT'}{'GREEN'} = '';
$checked{'IT'}{'ORANGE'} = '';
$checked{'IT'}{'BLUE'} = '';
$checked{'IT'}{$settings{'IT'}} = "checked='checked'";
$checked{'TURBO'} = ($settings{'TURBO'} eq 'on') ? "checked='checked'" : '';
print<<END
<table width='100%'>
<tr>
<td class='base'>Name:</td>
<td><input type='text' name='NAME' value='$settings{'NAME'}' /></td>
<td align='right'>INTERFACE</td>
<td align='right'>red<input type='radio' name='IT' value='RED' $checked{'IT'}{'RED'} /></td>
</tr><tr>
<td>Turbo:</td>
<td><input type='checkbox' name='TURBO' $checked{'TURBO'}' /></td>
<td></td>
<td align='right'>green<input type='radio' name='IT' value='GREEN' $checked{'IT'}{'GREEN'} /></td>
</tr><tr>
<td></td>
<td></td>
<td></td>
<td align='right'>blue<input type='radio' name='IT' value='BLUE' $checked{'IT'}{'BLUE'} /></td>
</tr><tr>
<td></td>
<td></td>
<td></td>
<td align='right'>orange<input type='radio' name='IT' value='ORANGE' $checked{'IT'}{'ORANGE'} /></td>
</tr>
</table>
<br />
END
;
print<<END
<table width='100%'>
<hr />
<tr>
<td class='base' width='25%'><img src='/blob.gif' align='top' alt='*' />&nbsp;$Lang::tr{'this field may be blank'}</td>
<td class='base' width='25%'>$warnmessage</td>
<td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
</tr>
</table>
</form>
END
;
&Header::closebox(); # end of Settings1
##
## Second box is for editing the an item of the list
##
$checked{'CB'} = ($settings{'CB'} eq 'on') ? "checked='checked'" : '';
my $buttontext = $Lang::tr{'add'};
if ($settings{'KEY1'} ne '') {
$buttontext = $Lang::tr{'update'};
&Header::openbox('100%', 'left', $Lang::tr{'XY edit data'});
} else {
&Header::openbox('100%', 'left', $Lang::tr{'XY add data'});
}
# Edited line number (KEY1) passed until cleared by 'save' or 'remove' or 'new sort order'
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='KEY1' value='$settings{'KEY1'}' />
<table width='100%'>
<tr>
<td class='base'>$Lang::tr{'ip address'}:</td>
<td><input type='text' name='IP' value='$settings{'IP'}' /></td>
<td class='base'>$Lang::tr{'enabled'}</td>
<td><input type='checkbox' name='CB' $checked{'CB'} /></td>
<td class='base'>$Lang::tr{'remark'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
<td><input type 'text' name='COMMENT' value='$settings{'COMMENT'}' /></td>
</tr>
</table>
<hr />
<table width='100%'>
<tr>
<td class='base' width='50%'><img src='/blob.gif' align='top' alt='*' />&nbsp;$Lang::tr{'this field may be blank'}</td>
<td width='50%' align='center'><input type='hidden' name='ACTION' value='$Lang::tr{'add'}' /><input type='submit' name='SUBMIT' value='$buttontext' /></td>
</tr>
</table>
</form>
END
;
&Header::closebox();
##
## Third box shows the list
##
# Columns headers may be a sort link. In this case it must be named in $sortstring
&Header::openbox('100%', 'left', $Lang::tr{'XY data'});
print <<END
<table width='100%'>
<tr>
<td width='20%' align='center'><a href='$ENV{'SCRIPT_NAME'}?IP'><b>$Lang::tr{'ip address'}</b></a></td>
<td width='70%' align='center'><a href='$ENV{'SCRIPT_NAME'}?COMMENT'><b>$Lang::tr{'remark'}</b></a></td>
<td width='10%' colspan='3' class='boldbase' align='center'><b>$Lang::tr{'action'}</b></td>
</tr>
END
;
##
## Print each line of @current list
##
my $key = 0;
$f->readreset; # beginning of data
for ($key=0; $key<$f->getnumberofline; $key++) {
my($cb,$comment,$ip) = $f->readbyfieldsseq($key,'CB','COMMENT','IP');
#Choose icon for checkbox
my $gif = '';
my $gdesc = '';
if ($cb eq "on") {
$gif = 'on.gif';
$gdesc = $Lang::tr{'click to disable'};
} else {
$gif = 'off.gif';
$gdesc = $Lang::tr{'click to enable'};
}
#Colorize each line
if ($settings{'KEY1'} eq $key) {
print "<tr bgcolor='${Header::colouryellow}'>";
} elsif ($key % 2) {
print "<tr bgcolor='${Header::table2colour}'>";
} else {
print "<tr bgcolor='${Header::table1colour}'>";
}
print <<END
<td align='center'>$ip</td>
<td align='center'>$comment</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
<input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' alt='$gdesc' title='$gdesc' />
<input type='hidden' name='KEY1' value='$key' />
</form>
</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
<input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
<input type='hidden' name='KEY1' value='$key' />
</form>
</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
<input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' alt='$Lang::tr{'remove'}' title='$Lang::tr{'remove'}' />
<input type='hidden' name='KEY1' value='$key' />
</form>
</td>
</tr>
END
;
} print "</table>";
# If table contains entries, print 'Key to action icons'
if ($key) {
print <<END
<table>
<tr>
<td class='boldbase'>&nbsp;<b>$Lang::tr{'legend'}:&nbsp;</b></td>
<td><img src='/images/on.gif' alt='$Lang::tr{'click to disable'}' /></td>
<td class='base'>$Lang::tr{'click to disable'}</td>
<td>&nbsp;&nbsp;</td>
<td><img src='/images/off.gif' alt='$Lang::tr{'click to enable'}' /></td>
<td class='base'>$Lang::tr{'click to enable'}</td>
<td>&nbsp;&nbsp;</td>
<td><img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
<td class='base'>$Lang::tr{'edit'}</td>
<td>&nbsp;&nbsp;</td>
<td><img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
<td class='base'>$Lang::tr{'remove'}</td>
</tr>
</table>
END
;
}
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
## Ouf it's the end !
##
## Build the configuration file for application XY
##
sub BuildConfiguration {
open(FILE, ">/$conffile") or die "$msg_configfileerror";
flock(FILE, 2);
#Global settings
print FILE "#\n# Configuration file for application XY\n#\n\n";
print FILE "# do not edit manually\n";
print FILE "# build for Ipcop:$mainsettings{'HOSTNAME'}\n\n\n";
print FILE "service=$settings{'NAME'}\n";
print FILE "activate-turbo\n" if $settings{'TURBO'} eq 'on';
print FILE "interface=$settings{'IT'}\n\n\n";
#write data line
{
my ($IP,$CB,$COMMENT);
$f->readreset;
while (defined ($f->readdataseq($IP,$CB,$COMMENT))) {
if ($CB eq "on") {
print FILE "$IP\t\t\t\t\t#$COMMENT\n";
} else {
print FILE "#DISABLED $IP\t\t\t\t#$COMMENT\n";
}
}
}
close FILE;
# Restart service
#system '/usr/local/bin/restartyourhelper';
}
#!/usr/bin/perl
#
# IPCop CGI's - base.cgi
#
# This code is distributed under the terms of the GPL
#
# (c) place a name here
#
# $Id: base.cgi,v 1.1.2.10 2005/11/03 19:20:50 franck78 Exp $
#
#
# This file is a starting base for writting a new GUI screen using the three box model
# Box 1 : global settings for the application
# Box 2 : line editor for multiple data line
# Box 3 : the list of data line, with edit/remove buttons
#
# This example do the following
# Read global settings:
# a NAME and an interface (IT)
# Lines of data composed of:
# an ipaddress (IP), an enabled/disabled options (CB), a comment (CO)
#
#
# All you need to do is
# replace 'XY' with your app name
# define your global $settings{'var name'}
# define your strings
# write validation code for Settings1 and Settings2
# write HTML box Settings1 and Settings2
# adapt the sort function
# write the correct configuration file
#
#
# to fully troubleshot your code, uncomment diagnostics, Carp and cluck lines
# use diagnostics; # need to add the file /usr/lib/perl5/5.8.x/pods/perldiag.pod before to work
# next look at /var/log/httpd/error_log , http://www.perl.com/pub/a/2002/05/07/mod_perl.html may help
#use warnings;
use strict;
#use Carp ();
#local $SIG{__WARN__} = \&Carp::cluck;
require '/var/ipcop/general-functions.pl'; # Replace all occurences of </var/ipcop> with CONFIG_ROOT
# before updating cvs IPCop file.
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
# Files used
our $setting = "${General::swroot}/XY/settings"; # particular settings
my $datafile = "${General::swroot}/XY/data"; # repeted settings (multilines)
our $conffile = "${General::swroot}/XY/XY.conf"; # Config file for application XY
# strings to add to languages databases or in addon language file
$Lang::tr{'XY title'} = 'XY service';
$Lang::tr{'XY settings'} = 'XY setup';
$Lang::tr{'XY add data'} = 'add data';
$Lang::tr{'XY edit data'} = 'edit data';
$Lang::tr{'XY data'} = 'XY data';
# informationnal & log strings, no translation required
my $msg_added = 'XY added';
my $msg_modified = 'XY modified';
my $msg_deleted = 'XY removed';
my $msg_datafileerror = 'XY data file error';
our $msg_configfileerror = 'XY configuration file error';
my %settings=();
# Settings1
$settings{'NAME'} = ''; # a string field than must be 'GOOD' or 'good'
$settings{'IT'} = ''; # a 'choose' field for color interface
$settings{'TURBO'} = 'off'; # a checkbox field to enable something
# Settings2 for editing the multi-line list
# Must not be saved by writehash !
$settings{'IP'} = ''; # datalines are: IPaddress,enable,comment
$settings{'CB'} = 'off'; # Every check box must be set to off
$settings{'COMMENT'} = '';
my @nosaved=('IP','CB','COMMENT'); # List here ALL setting2 fields. Mandatory
$settings{'ACTION'} = ''; # add/edit/remove....
$settings{'KEY1'} = ''; # point record for ACTION
# Define each field that can be used to sort columns
my $sortstring='^IP|^COMMENT';
my $errormessage = '';
my $warnmessage = '';
&Header::showhttpheaders();
# Read needed Ipcop settings (exemple)
my %mainsettings=();
&General::readhash("${General::swroot}/main/settings", \%mainsettings);
# Get GUI values
&Header::getcgihash(\%settings);
# Load multiline data. Do it before use in save action
our $f = new Multilines (filename => $datafile,
fields => ['IP','CB','COMMENT'],
comment => 1
);
##
## SAVE Settings1
##
# Remove if no Settings1 needed
if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
#
#Validate static Settings1 here
#
if (($settings{"NAME"} ne "GOOD") &&
($settings{"NAME"} ne "good")) {
$errormessage = 'Enter good or GOOD in Name field';
}
unless ($errormessage) { # Everything is ok, save settings
map (delete ($settings{$_}) ,(@nosaved,'ACTION','KEY1'));# Must never be saved
&General::writehash($setting, \%settings); # Save good settings
$settings{'ACTION'} = $Lang::tr{'save'}; # Recreate 'ACTION'
map ($settings{$_}= '',(@nosaved,'KEY1')); # and reinit var to empty
# Rebuild configuration file if needed
&BuildConfiguration;
}
ERROR: # Leave the faulty field untouched
} else {
&General::readhash($setting, \%settings); # Get saved settings and reset to good if needed
}
##
## Now manipulate the multiline list with Settings2
##
# Basic actions are:
# toggle the check box
# add/update a new line
# begin editing a line
# remove a line
# $KEY1 contains the index of the line manipulated
##
## Toggle CB field.
##
if ($settings{'ACTION'} eq $Lang::tr{'toggle enable disable'}) {
$f->togglebyfields($settings{'KEY1'},'CB'); # toggle checkbox
$settings{'KEY1'} = ''; # End edit mode
&General::log($msg_modified);
# save changes
$f->savedata || die "$msg_datafileerror";
# Rebuild configuration file
&BuildConfiguration;
}
##
## ADD/UPDATE a line of configuration from Settings2
##
if ($settings{'ACTION'} eq $Lang::tr{'add'}) {
# Validate inputs
if (! &General::validip($settings{'IP'})) {$errormessage = "Specify an IP value !"};
if (! $settings{'COMMENT'} ) {$warnmessage = "no comment specified"};
unless ($errormessage) {
if ($settings{'KEY1'} eq '') { #add or edit ?
# insert new data line
$f->writedata(-1, $settings{'IP'},$settings{'CB'},$settings{'COMMENT'});
&General::log($msg_added);
} else {
# modify data line
$f->writedata($settings{'KEY1'}, $settings{'IP'},$settings{'CB'},$settings{'COMMENT'});
$settings{'KEY1'} = ''; # End edit mode
&General::log($msg_modified);
}
# save changes
$f->savedata || die "$msg_datafileerror";
# Rebuild configuration file
&BuildConfiguration;
# if entering data line is a repetitive task, choose here to not erase fields between each addition
map ($settings{$_}='' ,@nosaved);
}
}
##
## begin EDIT: move data fields to Settings2 controls
##
if ($settings{'ACTION'} eq $Lang::tr{'edit'}) {
$f->readdata ($settings{'KEY1'},
$settings{'IP'},
$settings{'CB'},
$settings{'COMMENT'});
}
##
## REMOVE: remove selected line
##
if ($settings{'ACTION'} eq $Lang::tr{'remove'}) {
$f->deleteline ($settings{'KEY1'});
$settings{'KEY1'} = ''; # End remove mode
&General::log($msg_deleted);
# save changes
$f->savedata || die "$msg_datafileerror";
# Rebuild configuration file
&BuildConfiguration;
}
##
## Check if sorting is asked
##
if ($ENV{'QUERY_STRING'} =~ /$sortstring/ ) {
my $newsort=$ENV{'QUERY_STRING'};
my $actual=$settings{'SORT_XY'};
# Reverse actual sort or choose new column ?
if ($actual =~ $newsort) {
$f->setsortorder ($newsort ,rindex($actual,'Rev'));
$newsort .= rindex($actual,'Rev')==-1 ? 'Rev' : '';
} else {
$f->setsortorder ($newsort ,1);
}
$f->savedata; # Synchronise file & display
$settings{'SORT_XY'} = $newsort;
map (delete ($settings{$_}) ,(@nosaved,'ACTION','KEY1')); # Must never be saved
&General::writehash($setting, \%settings);
$settings{'ACTION'} = 'SORT'; # Recreate an 'ACTION'
map ($settings{$_}= '',(@nosaved,,'KEY1')); # and reinit var to empty
}
##
## Remove if no Setting1 needed
##
if ($settings{'ACTION'} eq '' ) { # First launch from GUI
# Place here default value when nothing is initialized
}
&Header::openpage($Lang::tr{'XY title'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
my %checked =(); # Checkbox manipulations
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>";
&Header::closebox();
}
##
## First box Settings1. Remove if not needed
##
$warnmessage = "<font color=${Header::colourred}><b>$Lang::tr{'capswarning'}</b></font>: $warnmessage" if ($warnmessage);
&Header::openbox('100%', 'left', $Lang::tr{'XY settings'});
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>";
$checked{'IT'}{'RED'} = '';
$checked{'IT'}{'GREEN'} = '';
$checked{'IT'}{'ORANGE'} = '';
$checked{'IT'}{'BLUE'} = '';
$checked{'IT'}{$settings{'IT'}} = "checked='checked'";
$checked{'TURBO'} = ($settings{'TURBO'} eq 'on') ? "checked='checked'" : '';
print<<END
<table width='100%'>
<tr>
<td class='base'>Name:</td>
<td><input type='text' name='NAME' value='$settings{'NAME'}' /></td>
<td align='right'>INTERFACE</td>
<td align='right'>red<input type='radio' name='IT' value='RED' $checked{'IT'}{'RED'} /></td>
</tr><tr>
<td>Turbo:</td>
<td><input type='checkbox' name='TURBO' $checked{'TURBO'}' /></td>
<td></td>
<td align='right'>green<input type='radio' name='IT' value='GREEN' $checked{'IT'}{'GREEN'} /></td>
</tr><tr>
<td></td>
<td></td>
<td></td>
<td align='right'>blue<input type='radio' name='IT' value='BLUE' $checked{'IT'}{'BLUE'} /></td>
</tr><tr>
<td></td>
<td></td>
<td></td>
<td align='right'>orange<input type='radio' name='IT' value='ORANGE' $checked{'IT'}{'ORANGE'} /></td>
</tr>
</table>
<br />
END
;
print<<END
<table width='100%'>
<hr />
<tr>
<td class='base' width='25%'><img src='/blob.gif' align='top' alt='*' />&nbsp;$Lang::tr{'this field may be blank'}</td>
<td class='base' width='25%'>$warnmessage</td>
<td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
</tr>
</table>
</form>
END
;
&Header::closebox(); # end of Settings1
##
## Second box is for editing the an item of the list
##
$checked{'CB'} = ($settings{'CB'} eq 'on') ? "checked='checked'" : '';
my $buttontext = $Lang::tr{'add'};
if ($settings{'KEY1'} ne '') {
$buttontext = $Lang::tr{'update'};
&Header::openbox('100%', 'left', $Lang::tr{'XY edit data'});
} else {
&Header::openbox('100%', 'left', $Lang::tr{'XY add data'});
}
# Edited line number (KEY1) passed until cleared by 'save' or 'remove' or 'new sort order'
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='KEY1' value='$settings{'KEY1'}' />
<table width='100%'>
<tr>
<td class='base'>$Lang::tr{'ip address'}:</td>
<td><input type='text' name='IP' value='$settings{'IP'}' /></td>
<td class='base'>$Lang::tr{'enabled'}</td>
<td><input type='checkbox' name='CB' $checked{'CB'} /></td>
<td class='base'>$Lang::tr{'remark'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
<td><input type 'text' name='COMMENT' value='$settings{'COMMENT'}' /></td>
</tr>
</table>
<hr />
<table width='100%'>
<tr>
<td class='base' width='50%'><img src='/blob.gif' align='top' alt='*' />&nbsp;$Lang::tr{'this field may be blank'}</td>
<td width='50%' align='center'><input type='hidden' name='ACTION' value='$Lang::tr{'add'}' /><input type='submit' name='SUBMIT' value='$buttontext' /></td>
</tr>
</table>
</form>
END
;
&Header::closebox();
##
## Third box shows the list
##
# Columns headers may be a sort link. In this case it must be named in $sortstring
&Header::openbox('100%', 'left', $Lang::tr{'XY data'});
print <<END
<table width='100%'>
<tr>
<td width='20%' align='center'><a href='$ENV{'SCRIPT_NAME'}?IP'><b>$Lang::tr{'ip address'}</b></a></td>
<td width='70%' align='center'><a href='$ENV{'SCRIPT_NAME'}?COMMENT'><b>$Lang::tr{'remark'}</b></a></td>
<td width='10%' colspan='3' class='boldbase' align='center'><b>$Lang::tr{'action'}</b></td>
</tr>
END
;
##
## Print each line of @current list
##
my $key = 0;
$f->readreset; # beginning of data
for ($key=0; $key<$f->getnumberofline; $key++) {
my($cb,$comment,$ip) = $f->readbyfieldsseq($key,'CB','COMMENT','IP');
#Choose icon for checkbox
my $gif = '';
my $gdesc = '';
if ($cb eq "on") {
$gif = 'on.gif';
$gdesc = $Lang::tr{'click to disable'};
} else {
$gif = 'off.gif';
$gdesc = $Lang::tr{'click to enable'};
}
#Colorize each line
if ($settings{'KEY1'} eq $key) {
print "<tr bgcolor='${Header::colouryellow}'>";
} elsif ($key % 2) {
print "<tr bgcolor='${Header::table2colour}'>";
} else {
print "<tr bgcolor='${Header::table1colour}'>";
}
print <<END
<td align='center'>$ip</td>
<td align='center'>$comment</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
<input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' alt='$gdesc' title='$gdesc' />
<input type='hidden' name='KEY1' value='$key' />
</form>
</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
<input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
<input type='hidden' name='KEY1' value='$key' />
</form>
</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
<input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' alt='$Lang::tr{'remove'}' title='$Lang::tr{'remove'}' />
<input type='hidden' name='KEY1' value='$key' />
</form>
</td>
</tr>
END
;
} print "</table>";
# If table contains entries, print 'Key to action icons'
if ($key) {
print <<END
<table>
<tr>
<td class='boldbase'>&nbsp;<b>$Lang::tr{'legend'}:&nbsp;</b></td>
<td><img src='/images/on.gif' alt='$Lang::tr{'click to disable'}' /></td>
<td class='base'>$Lang::tr{'click to disable'}</td>
<td>&nbsp;&nbsp;</td>
<td><img src='/images/off.gif' alt='$Lang::tr{'click to enable'}' /></td>
<td class='base'>$Lang::tr{'click to enable'}</td>
<td>&nbsp;&nbsp;</td>
<td><img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
<td class='base'>$Lang::tr{'edit'}</td>
<td>&nbsp;&nbsp;</td>
<td><img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
<td class='base'>$Lang::tr{'remove'}</td>
</tr>
</table>
END
;
}
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
## Ouf it's the end !
##
## Build the configuration file for application XY
##
sub BuildConfiguration {
open(FILE, ">/$conffile") or die "$msg_configfileerror";
flock(FILE, 2);
#Global settings
print FILE "#\n# Configuration file for application XY\n#\n\n";
print FILE "# do not edit manually\n";
print FILE "# build for Ipcop:$mainsettings{'HOSTNAME'}\n\n\n";
print FILE "service=$settings{'NAME'}\n";
print FILE "activate-turbo\n" if $settings{'TURBO'} eq 'on';
print FILE "interface=$settings{'IT'}\n\n\n";
#write data line
{
my ($IP,$CB,$COMMENT);
$f->readreset;
while (defined ($f->readdataseq($IP,$CB,$COMMENT))) {
if ($CB eq "on") {
print FILE "$IP\t\t\t\t\t#$COMMENT\n";
} else {
print FILE "#DISABLED $IP\t\t\t\t#$COMMENT\n";
}
}
}
close FILE;
# Restart service
#system '/usr/local/bin/restartyourhelper';
}

View File

@@ -1,123 +1,123 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: changepw.cgi,v 1.4.2.6 2005/03/07 21:28:03 eoberlander Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %cgiparams=();
my $errormessage='';
&Header::showhttpheaders();
$cgiparams{'ACTION_ADMIN'} = '';
$cgiparams{'ACTION_DIAL'} = '';
&Header::getcgihash(\%cgiparams);
if ($cgiparams{'ACTION_ADMIN'} eq $Lang::tr{'save'})
{
my $password1 = $cgiparams{'ADMIN_PASSWORD1'};
my $password2 = $cgiparams{'ADMIN_PASSWORD2'};
if ($password1 eq $password2)
{
if ($password1 =~ m/\s|\"/) {
$errormessage = $Lang::tr{'password contains illegal characters'};
}
elsif (length($password1) >= 6)
{
system('/usr/bin/htpasswd', '-m', '-b', "${General::swroot}/auth/users", 'admin', "${password1}");
&General::log($Lang::tr{'admin user password has been changed'});
}
else {
$errormessage = $Lang::tr{'passwords must be at least 6 characters in length'}; }
}
else {
$errormessage = $Lang::tr{'passwords do not match'}; }
}
if ($cgiparams{'ACTION_DIAL'} eq $Lang::tr{'save'})
{
my $password1 = $cgiparams{'DIAL_PASSWORD1'};
my $password2 = $cgiparams{'DIAL_PASSWORD2'};
if ($password1 eq $password2)
{
if($password1 =~ m/\s|\"/) {
$errormessage = $Lang::tr{'password contains illegal characters'};
}
elsif (length($password1) >= 6)
{
system('/usr/bin/htpasswd', '-b', "${General::swroot}/auth/users", 'dial', "${password1}");
&General::log($Lang::tr{'dial user password has been changed'});
}
else {
$errormessage = $Lang::tr{'passwords must be at least 6 characters in length'}; }
}
else {
$errormessage = $Lang::tr{'passwords do not match'}; }
}
&Header::openpage($Lang::tr{'change passwords'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<class name='base'>$errormessage\n";
print "&nbsp;</class>\n";
&Header::closebox();
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
&Header::openbox('100%', 'left', $Lang::tr{'administrator user password'});
print <<END
<table width='100%'>
<tr>
<td width='20%' class='base'>$Lang::tr{'username'}&nbsp;'admin'</td>
<td width='15%' class='base' align='right'>$Lang::tr{'password'}&nbsp;</td>
<td width='15%'><input type='password' name='ADMIN_PASSWORD1' size='10' /></td>
<td width='15%' class='base' align='right'>$Lang::tr{'again'} </td>
<td width='15%'><input type='password' name='ADMIN_PASSWORD2' size='10' /></td>
<td width='20%' align='center'><input type='submit' name='ACTION_ADMIN' value='$Lang::tr{'save'}' /></td>
</tr>
</table>
END
;
&Header::closebox();
&Header::openbox('100%', 'left', $Lang::tr{'dial user password'});
print <<END
<table width='100%'>
<tr>
<td width='20%' class='base'>$Lang::tr{'username'}&nbsp;'dial'</td>
<td width='15%' class='base' align='right'>$Lang::tr{'password'}&nbsp;</td>
<td width='15%'><input type='password' name='DIAL_PASSWORD1' size='10'/></td>
<td width='15%' class='base' align='right'>$Lang::tr{'again'}&nbsp;</td>
<td width='15%'><input type='password' name='DIAL_PASSWORD2' size='10' /></td>
<td width='20%' align='center'><input type='submit' name='ACTION_DIAL' value='$Lang::tr{'save'}' /></td>
</tr>
</table>
END
;
&Header::closebox();
print "</form>\n";
&Header::closebigbox();
&Header::closepage();
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: changepw.cgi,v 1.4.2.6 2005/03/07 21:28:03 eoberlander Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %cgiparams=();
my $errormessage='';
&Header::showhttpheaders();
$cgiparams{'ACTION_ADMIN'} = '';
$cgiparams{'ACTION_DIAL'} = '';
&Header::getcgihash(\%cgiparams);
if ($cgiparams{'ACTION_ADMIN'} eq $Lang::tr{'save'})
{
my $password1 = $cgiparams{'ADMIN_PASSWORD1'};
my $password2 = $cgiparams{'ADMIN_PASSWORD2'};
if ($password1 eq $password2)
{
if ($password1 =~ m/\s|\"/) {
$errormessage = $Lang::tr{'password contains illegal characters'};
}
elsif (length($password1) >= 6)
{
system('/usr/bin/htpasswd', '-m', '-b', "${General::swroot}/auth/users", 'admin', "${password1}");
&General::log($Lang::tr{'admin user password has been changed'});
}
else {
$errormessage = $Lang::tr{'passwords must be at least 6 characters in length'}; }
}
else {
$errormessage = $Lang::tr{'passwords do not match'}; }
}
if ($cgiparams{'ACTION_DIAL'} eq $Lang::tr{'save'})
{
my $password1 = $cgiparams{'DIAL_PASSWORD1'};
my $password2 = $cgiparams{'DIAL_PASSWORD2'};
if ($password1 eq $password2)
{
if($password1 =~ m/\s|\"/) {
$errormessage = $Lang::tr{'password contains illegal characters'};
}
elsif (length($password1) >= 6)
{
system('/usr/bin/htpasswd', '-b', "${General::swroot}/auth/users", 'dial', "${password1}");
&General::log($Lang::tr{'dial user password has been changed'});
}
else {
$errormessage = $Lang::tr{'passwords must be at least 6 characters in length'}; }
}
else {
$errormessage = $Lang::tr{'passwords do not match'}; }
}
&Header::openpage($Lang::tr{'change passwords'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<class name='base'>$errormessage\n";
print "&nbsp;</class>\n";
&Header::closebox();
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
&Header::openbox('100%', 'left', $Lang::tr{'administrator user password'});
print <<END
<table width='100%'>
<tr>
<td width='20%' class='base'>$Lang::tr{'username'}&nbsp;'admin'</td>
<td width='15%' class='base' align='right'>$Lang::tr{'password'}&nbsp;</td>
<td width='15%'><input type='password' name='ADMIN_PASSWORD1' size='10' /></td>
<td width='15%' class='base' align='right'>$Lang::tr{'again'} </td>
<td width='15%'><input type='password' name='ADMIN_PASSWORD2' size='10' /></td>
<td width='20%' align='center'><input type='submit' name='ACTION_ADMIN' value='$Lang::tr{'save'}' /></td>
</tr>
</table>
END
;
&Header::closebox();
&Header::openbox('100%', 'left', $Lang::tr{'dial user password'});
print <<END
<table width='100%'>
<tr>
<td width='20%' class='base'>$Lang::tr{'username'}&nbsp;'dial'</td>
<td width='15%' class='base' align='right'>$Lang::tr{'password'}&nbsp;</td>
<td width='15%'><input type='password' name='DIAL_PASSWORD1' size='10'/></td>
<td width='15%' class='base' align='right'>$Lang::tr{'again'}&nbsp;</td>
<td width='15%'><input type='password' name='DIAL_PASSWORD2' size='10' /></td>
<td width='20%' align='center'><input type='submit' name='ACTION_DIAL' value='$Lang::tr{'save'}' /></td>
</tr>
</table>
END
;
&Header::closebox();
print "</form>\n";
&Header::closebigbox();
&Header::closepage();

View File

@@ -1,329 +1,329 @@
#!/usr/bin/perl
#
# (c) 2001 Jack Beglinger <jackb_guppy@yahoo.com>
#
# (c) 2003 Dave Roberts <countzerouk@hotmail.com> - colour coded netfilter/iptables rewrite for 1.3
#
# $Id: connections.cgi,v 1.6.2.11 2005/02/24 07:44:35 gespinasse Exp $
#
# Setup GREEN, ORANGE, IPCOP, VPN CIDR networks, masklengths and colours only once
my @network=();
my @masklen=();
my @colour=();
use Net::IPv4Addr qw( :all );
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::table1colour} );
undef (@dummy);
# Read various files
my %netsettings=();
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
open (ACTIVE, "/proc/net/ip_conntrack") or die 'Unable to open ip_conntrack';
my @active = <ACTIVE>;
close (ACTIVE);
my @vpn = ('none');
open (ACTIVE, "/proc/net/ipsec_eroute") and @vpn = <ACTIVE>; close (ACTIVE);
my $aliasfile = "${General::swroot}/ethernet/aliases";
open(ALIASES, $aliasfile) or die 'Unable to open aliases file.';
my @aliases = <ALIASES>;
close(ALIASES);
# Add Green Firewall Interface
push(@network, $netsettings{'GREEN_ADDRESS'});
push(@masklen, "255.255.255.255" );
push(@colour, ${Header::colourfw} );
# Add Green Network to Array
push(@network, $netsettings{'GREEN_NETADDRESS'});
push(@masklen, $netsettings{'GREEN_NETMASK'} );
push(@colour, ${Header::colourgreen} );
# Add Green Routes to Array
my @routes = `/sbin/route -n | /bin/grep $netsettings{'GREEN_DEV'}`;
foreach my $route (@routes) {
chomp($route);
my @temp = split(/[\t ]+/, $route);
push(@network, $temp[0]);
push(@masklen, $temp[2]);
push(@colour, ${Header::colourgreen} );
}
# Add Firewall Localhost 127.0.0.1
push(@network, '127.0.0.1');
push(@masklen, '255.255.255.255' );
push(@colour, ${Header::colourfw} );
# Add Orange Network
if ($netsettings{'ORANGE_DEV'}) {
push(@network, $netsettings{'ORANGE_NETADDRESS'});
push(@masklen, $netsettings{'ORANGE_NETMASK'} );
push(@colour, ${Header::colourorange} );
# Add Orange Routes to Array
@routes = `/sbin/route -n | /bin/grep $netsettings{'ORANGE_DEV'}`;
foreach my $route (@routes) {
chomp($route);
my @temp = split(/[\t ]+/, $route);
push(@network, $temp[0]);
push(@masklen, $temp[2]);
push(@colour, ${Header::colourorange} );
}
}
# Add Blue Network
if ($netsettings{'BLUE_DEV'}) {
push(@network, $netsettings{'BLUE_NETADDRESS'});
push(@masklen, $netsettings{'BLUE_NETMASK'} );
push(@colour, ${Header::colourblue} );
# Add Blue Routes to Array
@routes = `/sbin/route -n | /bin/grep $netsettings{'BLUE_DEV'}`;
foreach my $route (@routes) {
chomp($route);
my @temp = split(/[\t ]+/, $route);
push(@network, $temp[0]);
push(@masklen, $temp[2]);
push(@colour, ${Header::colourblue} );
}
}
# Add STATIC RED aliases
if ($netsettings{'RED_DEV'}) {
# We have a RED eth iface
if ($netsettings{'RED_TYPE'} eq 'STATIC') {
# We have a STATIC RED eth iface
foreach my $line (@aliases)
{
chomp($line);
my @temp = split(/\,/,$line);
if ( $temp[0] ) {
push(@network, $temp[0]);
push(@masklen, $netsettings{'RED_NETMASK'} );
push(@colour, ${Header::colourfw} );
}
}
}
}
# Add VPNs
if ( $vpn[0] ne 'none' ) {
foreach my $line (@vpn) {
my @temp = split(/[\t ]+/,$line);
my @temp1 = split(/[\/:]+/,$temp[3]);
push(@network, $temp1[0]);
push(@masklen, ipv4_cidr2msk($temp1[1]));
push(@colour, ${Header::colourvpn} );
}
}
if (open(IP, "${General::swroot}/red/local-ipaddress")) {
my $redip = <IP>;
close(IP);
chomp $redip;
push(@network, $redip);
push(@masklen, '255.255.255.255' );
push(@colour, ${Header::colourfw} );
}
&Header::showhttpheaders();
&Header::openpage($Lang::tr{'connections'}, 1, '');
&Header::openbigbox('100%', 'left');
&Header::openbox('100%', 'left', $Lang::tr{'connection tracking'});
print <<END
<table width='60%'>
<tr><td align='center'><b>$Lang::tr{'legend'} : </b></td>
<td align='center' bgcolor='${Header::colourgreen}'><b><font color='#FFFFFF'>$Lang::tr{'lan'}</font></b></td>
<td align='center' bgcolor='${Header::colourred}'><b><font color='#FFFFFF'>$Lang::tr{'internet'}</font></b></td>
<td align='center' bgcolor='${Header::colourorange}'><b><font color='#FFFFFF'>$Lang::tr{'dmz'}</font></b></td>
<td align='center' bgcolor='${Header::colourblue}'><b><font color='#FFFFFF'>$Lang::tr{'wireless'}</font></b></td>
<td align='center' bgcolor='${Header::colourfw}'><b><font color='#FFFFFF'>IPCop</font></b></td>
<td align='center' bgcolor='${Header::colourvpn}'><b><font color='#FFFFFF'>$Lang::tr{'vpn'}</font></b></td>
</tr>
</table>
<br />
<table cellpadding='2'>
<tr><td align='center'><b>$Lang::tr{'protocol'}</b></td>
<td align='center'><b>$Lang::tr{'expires'}<br />($Lang::tr{'seconds'})</b></td>
<td align='center'><b>$Lang::tr{'connection'}<br />$Lang::tr{'status'}</b></td>
<td align='center'><b>$Lang::tr{'original'}<br />$Lang::tr{'source ip and port'}</b></td>
<td align='center'><b>$Lang::tr{'original'}<br />$Lang::tr{'dest ip and port'}</b></td>
<td align='center'><b>$Lang::tr{'expected'}<br />$Lang::tr{'source ip and port'}</b></td>
<td align='center'><b>$Lang::tr{'expected'}<br />$Lang::tr{'dest ip and port'}</b></td>
<td align='center'><b>$Lang::tr{'marked'}</b></td>
<td align='center'><b>$Lang::tr{'use'}</b></td>
</tr>
END
;
foreach my $line (@active)
{
my $protocol='';
my $expires='';
my $connstatus='';
my $orgsip='';
my $orgdip='';
my $orgsp='';
my $orgdp='';
my $exsip='';
my $exdip='';
my $exsp='';
my $exdp='';
my $marked='';
my $use='';
my $orgsipcolour='';
my $orgdipcolour='';
my $exsipcolour='';
my $exdipcolour='';
chomp($line);
my @temp = split(' ',$line);
print "<tr bgcolor='${Header::table1colour}'>\n";
if ($temp[0] eq 'udp') {
my $offset = 0;
$marked = '';
$protocol = $temp[0] . " (" . $temp[1] . ")";
$expires = $temp[2];
$connstatus = ' ';
$orgsip = substr $temp[3], 4;
$orgdip = substr $temp[4], 4;
$orgsp = substr $temp[5], 6;
$orgdp = substr $temp[6], 6;
if ($temp[7] eq '[UNREPLIED]') {
$marked = $temp[7];
$offset = 1;
}
else {
$connstatus = ' ';
}
$exsip = substr $temp[7 + $offset], 4;
$exdip = substr $temp[8 + $offset], 4;
$exsp = substr $temp[9 + $offset], 6;
$exdp = substr $temp[10 + $offset], 6;
if ($marked eq '[UNREPLIED]') {
$use = substr $temp[11 + $offset], 4;
}
else {
$marked = $temp[11 + $offset];
$use = substr $marked, 0, 3;
if ($use eq 'use' ) {
$marked = '';
$use = substr $temp[11 + $offset], 4;
}
else {
$use = substr $temp[12 + $offset], 4;
}
}
}
if ($temp[0] eq 'tcp') {
my $offset = 0;
$protocol = $temp[0] . " (" . $temp[1] . ")";
$expires = $temp[2];
$connstatus = $temp[3];
$orgsip = substr $temp[4], 4;
$orgdip = substr $temp[5], 4;
$orgsp = substr $temp[6], 6;
$orgdp = substr $temp[7], 6;
if ($temp[8] eq '[UNREPLIED]') {
$marked = $temp[8];
$offset = 1;
$use = substr $temp[13], 4;
}
else {
$marked = $temp[12];
$use = substr $temp[13], 4;
}
$exsip = substr $temp[8 + $offset], 4;
$exdip = substr $temp[9 + $offset], 4;
$exsp = substr $temp[10 + $offset], 6;
$exdp = substr $temp[11 + $offset], 6;
}
if ($temp[0] eq 'unknown') {
my $offset = 0;
$protocol = "??? (" . $temp[1] . ")";
$protocol = "esp (" . $temp[1] . ")" if ($temp[1] == 50);
$protocol = " ah (" . $temp[1] . ")" if ($temp[1] == 51);
$expires = $temp[2];
$connstatus = ' ';
$orgsip = substr $temp[3], 4;
$orgdip = substr $temp[4], 4;
$orgsp = ' ';
$orgdp = ' ';
$exsip = substr $temp[5], 4;
$exdip = substr $temp[6], 4;
$exsp = ' ';
$exdp = ' ';
$marked = ' ';
$use = ' ';
}
if ($temp[0] eq 'gre') {
my $offset = 0;
$protocol = $temp[0] . " (" . $temp[1] . ")";
$expires = $temp[2];
$orgsip = substr $temp[5], 4;
$orgdip = substr $temp[6], 4;
$orgsp = ' ';
$orgdp = ' ';
$exsip = substr $temp[11], 4;
$exdip = substr $temp[12], 4;
$exsp = ' ';
$exdp = ' ';
$marked = $temp[17];
$use = $temp[18];
}
$orgsipcolour = &ipcolour($orgsip);
$orgdipcolour = &ipcolour($orgdip);
$exsipcolour = &ipcolour($exsip);
$exdipcolour = &ipcolour($exdip);
print <<END
<td align='center'>$protocol</td>
<td align='center'>$expires</td>
<td align='center'>$connstatus</td>
<td align='center' bgcolor='$orgsipcolour'><a href='/cgi-bin/ipinfo.cgi?ip=$orgsip'><font color='#FFFFFF'>$orgsip</font></a><font color='#FFFFFF'>:$orgsp</font></td>
<td align='center' bgcolor='$orgdipcolour'><a href='/cgi-bin/ipinfo.cgi?ip=$orgdip'><font color='#FFFFFF'>$orgdip</font></a><font color='#FFFFFF'>:$orgdp</font></td>
<td align='center' bgcolor='$exsipcolour'><a href='/cgi-bin/ipinfo.cgi?ip=$exsip'><font color='#FFFFFF'>$exsip</font></a><font color='#FFFFFF'>:$exsp</font></td>
<td align='center' bgcolor='$exdipcolour'><a href='/cgi-bin/ipinfo.cgi?ip=$exdip'><font color='#FFFFFF'>$exdip</font></a><font color='#FFFFFF'>:$exdp</font></td>
<td align='center'>$marked</td><td align='center'>$use</td>
</tr>
END
;
}
print "</table>\n";
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
sub ipcolour($) {
my $id = 0;
my $line;
my $colour = ${Header::colourred};
my ($ip) = $_[0];
my $found = 0;
foreach $line (@network)
{
if (!$found && ipv4_in_network( $network[$id] , $masklen[$id], $ip) ) {
$found = 1;
$colour = $colour[$id];
}
$id++;
}
return $colour
}
#!/usr/bin/perl
#
# (c) 2001 Jack Beglinger <jackb_guppy@yahoo.com>
#
# (c) 2003 Dave Roberts <countzerouk@hotmail.com> - colour coded netfilter/iptables rewrite for 1.3
#
# $Id: connections.cgi,v 1.6.2.11 2005/02/24 07:44:35 gespinasse Exp $
#
# Setup GREEN, ORANGE, IPCOP, VPN CIDR networks, masklengths and colours only once
my @network=();
my @masklen=();
my @colour=();
use Net::IPv4Addr qw( :all );
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::table1colour} );
undef (@dummy);
# Read various files
my %netsettings=();
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
open (ACTIVE, "/proc/net/ip_conntrack") or die 'Unable to open ip_conntrack';
my @active = <ACTIVE>;
close (ACTIVE);
my @vpn = ('none');
open (ACTIVE, "/proc/net/ipsec_eroute") and @vpn = <ACTIVE>; close (ACTIVE);
my $aliasfile = "${General::swroot}/ethernet/aliases";
open(ALIASES, $aliasfile) or die 'Unable to open aliases file.';
my @aliases = <ALIASES>;
close(ALIASES);
# Add Green Firewall Interface
push(@network, $netsettings{'GREEN_ADDRESS'});
push(@masklen, "255.255.255.255" );
push(@colour, ${Header::colourfw} );
# Add Green Network to Array
push(@network, $netsettings{'GREEN_NETADDRESS'});
push(@masklen, $netsettings{'GREEN_NETMASK'} );
push(@colour, ${Header::colourgreen} );
# Add Green Routes to Array
my @routes = `/sbin/route -n | /bin/grep $netsettings{'GREEN_DEV'}`;
foreach my $route (@routes) {
chomp($route);
my @temp = split(/[\t ]+/, $route);
push(@network, $temp[0]);
push(@masklen, $temp[2]);
push(@colour, ${Header::colourgreen} );
}
# Add Firewall Localhost 127.0.0.1
push(@network, '127.0.0.1');
push(@masklen, '255.255.255.255' );
push(@colour, ${Header::colourfw} );
# Add Orange Network
if ($netsettings{'ORANGE_DEV'}) {
push(@network, $netsettings{'ORANGE_NETADDRESS'});
push(@masklen, $netsettings{'ORANGE_NETMASK'} );
push(@colour, ${Header::colourorange} );
# Add Orange Routes to Array
@routes = `/sbin/route -n | /bin/grep $netsettings{'ORANGE_DEV'}`;
foreach my $route (@routes) {
chomp($route);
my @temp = split(/[\t ]+/, $route);
push(@network, $temp[0]);
push(@masklen, $temp[2]);
push(@colour, ${Header::colourorange} );
}
}
# Add Blue Network
if ($netsettings{'BLUE_DEV'}) {
push(@network, $netsettings{'BLUE_NETADDRESS'});
push(@masklen, $netsettings{'BLUE_NETMASK'} );
push(@colour, ${Header::colourblue} );
# Add Blue Routes to Array
@routes = `/sbin/route -n | /bin/grep $netsettings{'BLUE_DEV'}`;
foreach my $route (@routes) {
chomp($route);
my @temp = split(/[\t ]+/, $route);
push(@network, $temp[0]);
push(@masklen, $temp[2]);
push(@colour, ${Header::colourblue} );
}
}
# Add STATIC RED aliases
if ($netsettings{'RED_DEV'}) {
# We have a RED eth iface
if ($netsettings{'RED_TYPE'} eq 'STATIC') {
# We have a STATIC RED eth iface
foreach my $line (@aliases)
{
chomp($line);
my @temp = split(/\,/,$line);
if ( $temp[0] ) {
push(@network, $temp[0]);
push(@masklen, $netsettings{'RED_NETMASK'} );
push(@colour, ${Header::colourfw} );
}
}
}
}
# Add VPNs
if ( $vpn[0] ne 'none' ) {
foreach my $line (@vpn) {
my @temp = split(/[\t ]+/,$line);
my @temp1 = split(/[\/:]+/,$temp[3]);
push(@network, $temp1[0]);
push(@masklen, ipv4_cidr2msk($temp1[1]));
push(@colour, ${Header::colourvpn} );
}
}
if (open(IP, "${General::swroot}/red/local-ipaddress")) {
my $redip = <IP>;
close(IP);
chomp $redip;
push(@network, $redip);
push(@masklen, '255.255.255.255' );
push(@colour, ${Header::colourfw} );
}
&Header::showhttpheaders();
&Header::openpage($Lang::tr{'connections'}, 1, '');
&Header::openbigbox('100%', 'left');
&Header::openbox('100%', 'left', $Lang::tr{'connection tracking'});
print <<END
<table width='60%'>
<tr><td align='center'><b>$Lang::tr{'legend'} : </b></td>
<td align='center' bgcolor='${Header::colourgreen}'><b><font color='#FFFFFF'>$Lang::tr{'lan'}</font></b></td>
<td align='center' bgcolor='${Header::colourred}'><b><font color='#FFFFFF'>$Lang::tr{'internet'}</font></b></td>
<td align='center' bgcolor='${Header::colourorange}'><b><font color='#FFFFFF'>$Lang::tr{'dmz'}</font></b></td>
<td align='center' bgcolor='${Header::colourblue}'><b><font color='#FFFFFF'>$Lang::tr{'wireless'}</font></b></td>
<td align='center' bgcolor='${Header::colourfw}'><b><font color='#FFFFFF'>IPCop</font></b></td>
<td align='center' bgcolor='${Header::colourvpn}'><b><font color='#FFFFFF'>$Lang::tr{'vpn'}</font></b></td>
</tr>
</table>
<br />
<table cellpadding='2'>
<tr><td align='center'><b>$Lang::tr{'protocol'}</b></td>
<td align='center'><b>$Lang::tr{'expires'}<br />($Lang::tr{'seconds'})</b></td>
<td align='center'><b>$Lang::tr{'connection'}<br />$Lang::tr{'status'}</b></td>
<td align='center'><b>$Lang::tr{'original'}<br />$Lang::tr{'source ip and port'}</b></td>
<td align='center'><b>$Lang::tr{'original'}<br />$Lang::tr{'dest ip and port'}</b></td>
<td align='center'><b>$Lang::tr{'expected'}<br />$Lang::tr{'source ip and port'}</b></td>
<td align='center'><b>$Lang::tr{'expected'}<br />$Lang::tr{'dest ip and port'}</b></td>
<td align='center'><b>$Lang::tr{'marked'}</b></td>
<td align='center'><b>$Lang::tr{'use'}</b></td>
</tr>
END
;
foreach my $line (@active)
{
my $protocol='';
my $expires='';
my $connstatus='';
my $orgsip='';
my $orgdip='';
my $orgsp='';
my $orgdp='';
my $exsip='';
my $exdip='';
my $exsp='';
my $exdp='';
my $marked='';
my $use='';
my $orgsipcolour='';
my $orgdipcolour='';
my $exsipcolour='';
my $exdipcolour='';
chomp($line);
my @temp = split(' ',$line);
print "<tr bgcolor='${Header::table1colour}'>\n";
if ($temp[0] eq 'udp') {
my $offset = 0;
$marked = '';
$protocol = $temp[0] . " (" . $temp[1] . ")";
$expires = $temp[2];
$connstatus = ' ';
$orgsip = substr $temp[3], 4;
$orgdip = substr $temp[4], 4;
$orgsp = substr $temp[5], 6;
$orgdp = substr $temp[6], 6;
if ($temp[7] eq '[UNREPLIED]') {
$marked = $temp[7];
$offset = 1;
}
else {
$connstatus = ' ';
}
$exsip = substr $temp[7 + $offset], 4;
$exdip = substr $temp[8 + $offset], 4;
$exsp = substr $temp[9 + $offset], 6;
$exdp = substr $temp[10 + $offset], 6;
if ($marked eq '[UNREPLIED]') {
$use = substr $temp[11 + $offset], 4;
}
else {
$marked = $temp[11 + $offset];
$use = substr $marked, 0, 3;
if ($use eq 'use' ) {
$marked = '';
$use = substr $temp[11 + $offset], 4;
}
else {
$use = substr $temp[12 + $offset], 4;
}
}
}
if ($temp[0] eq 'tcp') {
my $offset = 0;
$protocol = $temp[0] . " (" . $temp[1] . ")";
$expires = $temp[2];
$connstatus = $temp[3];
$orgsip = substr $temp[4], 4;
$orgdip = substr $temp[5], 4;
$orgsp = substr $temp[6], 6;
$orgdp = substr $temp[7], 6;
if ($temp[8] eq '[UNREPLIED]') {
$marked = $temp[8];
$offset = 1;
$use = substr $temp[13], 4;
}
else {
$marked = $temp[12];
$use = substr $temp[13], 4;
}
$exsip = substr $temp[8 + $offset], 4;
$exdip = substr $temp[9 + $offset], 4;
$exsp = substr $temp[10 + $offset], 6;
$exdp = substr $temp[11 + $offset], 6;
}
if ($temp[0] eq 'unknown') {
my $offset = 0;
$protocol = "??? (" . $temp[1] . ")";
$protocol = "esp (" . $temp[1] . ")" if ($temp[1] == 50);
$protocol = " ah (" . $temp[1] . ")" if ($temp[1] == 51);
$expires = $temp[2];
$connstatus = ' ';
$orgsip = substr $temp[3], 4;
$orgdip = substr $temp[4], 4;
$orgsp = ' ';
$orgdp = ' ';
$exsip = substr $temp[5], 4;
$exdip = substr $temp[6], 4;
$exsp = ' ';
$exdp = ' ';
$marked = ' ';
$use = ' ';
}
if ($temp[0] eq 'gre') {
my $offset = 0;
$protocol = $temp[0] . " (" . $temp[1] . ")";
$expires = $temp[2];
$orgsip = substr $temp[5], 4;
$orgdip = substr $temp[6], 4;
$orgsp = ' ';
$orgdp = ' ';
$exsip = substr $temp[11], 4;
$exdip = substr $temp[12], 4;
$exsp = ' ';
$exdp = ' ';
$marked = $temp[17];
$use = $temp[18];
}
$orgsipcolour = &ipcolour($orgsip);
$orgdipcolour = &ipcolour($orgdip);
$exsipcolour = &ipcolour($exsip);
$exdipcolour = &ipcolour($exdip);
print <<END
<td align='center'>$protocol</td>
<td align='center'>$expires</td>
<td align='center'>$connstatus</td>
<td align='center' bgcolor='$orgsipcolour'><a href='/cgi-bin/ipinfo.cgi?ip=$orgsip'><font color='#FFFFFF'>$orgsip</font></a><font color='#FFFFFF'>:$orgsp</font></td>
<td align='center' bgcolor='$orgdipcolour'><a href='/cgi-bin/ipinfo.cgi?ip=$orgdip'><font color='#FFFFFF'>$orgdip</font></a><font color='#FFFFFF'>:$orgdp</font></td>
<td align='center' bgcolor='$exsipcolour'><a href='/cgi-bin/ipinfo.cgi?ip=$exsip'><font color='#FFFFFF'>$exsip</font></a><font color='#FFFFFF'>:$exsp</font></td>
<td align='center' bgcolor='$exdipcolour'><a href='/cgi-bin/ipinfo.cgi?ip=$exdip'><font color='#FFFFFF'>$exdip</font></a><font color='#FFFFFF'>:$exdp</font></td>
<td align='center'>$marked</td><td align='center'>$use</td>
</tr>
END
;
}
print "</table>\n";
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
sub ipcolour($) {
my $id = 0;
my $line;
my $colour = ${Header::colourred};
my ($ip) = $_[0];
my $found = 0;
foreach $line (@network)
{
if (!$found && ipv4_in_network( $network[$id] , $masklen[$id], $ip) ) {
$found = 1;
$colour = $colour[$id];
}
$id++;
}
return $colour
}

View File

@@ -1,371 +1,371 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: credits.cgi,v 1.11.2.30 2006/01/08 13:33:36 eoberlander Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
&Header::showhttpheaders();
&Header::openpage($Lang::tr{'credits'}, 1, '');
&Header::openbigbox('100%', 'center');
&Header::openbox('100%', 'left', $Lang::tr{'credits'});
print <<END
<br /><center><b>Visit us on <a href='http://www.ipcop.org/'>http://www.ipcop.org/</a></b></center>
<p><b>Main Credits</b><br />
Project Member - Mark Wormgoor
(<a href='mailto:mark\@wormgoor.com'>mark\@wormgoor.com</a>)<br />
Project Member &amp; Configuration backup/restore - Eric S. Johansson
(<a href='mailto:esj\@harvee.billerica.ma.us'>esj\@harvee.billerica.ma.us</a>)<br />
Project Member - Jack Beglinger
(<a href='mailto:jackb_guppy\@yahoo.com'>jackb_guppy\@yahoo.com</a>)<br />
Developer - Darren Critchley
(<a href='mailto:darrenc\@telus.net'>darrenc\@telus.net</a>)<br />
Developer - Robert Kerr
(<a href='mailto:LittleThor\@xsw.terminator.net'>LittleThor\@xsw.terminator.net</a>)<br />
Developer - Alan Hourihane
(<a href='mailto:alanh\@fairlite.demon.co.uk'>alanh\@fairlite.demon.co.uk</a>)<br />
ADSL Developer - Gilles Espinasse
(<a href='mailto:g.esp.ipcop\@free.fr'>g.esp.ipcop\@free.fr</a>)<br />
Perl Developer - Franck Bourdonnec
(<a href='mailto:fbourdonnec\@chez.com'>fbourdonnec\@chez.com</a>)<br />
Testing - Dave Roberts
(<a href='mailto:dave\@daver.demon.co.uk'>dave\@daver.demon.co.uk</a>)<br />
Website Design + Graphics - Seth Bareiss
(<a href='mailto:seth\@fureai-ch.ne.jp'>seth\@fureai-ch.ne.jp</a>)<br />
Documentation - Harry Goldschmitt
(<a href='mailto:harry\@hgac.com'>harry\@hgac.com</a>)<br />
Red IP Aliasing - Steve Bootes
(<a href='mailto:Steve\@computingdynamics.co.uk'>Steve\@computingdynamics.co.uk</a>)<br />
Static DHCP Addresses - Graham Smith
(<a href='mailto:grhm\@grhm.co.uk'>grhm\@grhm.co.uk</a>)<br />
Squid graphs - Robert Wood
(<a href='rob\@empathymp3.co.uk'>rob\@empathymp3.co.uk</a>)<br />
Time Synchronization - Eric Oberlander
(<a href='mailto:eric\@oberlander.co.uk'>eric\@oberlander.co.uk</a>)<br />
Backup - Tim Butterfield
(<a href='mailto:timbutterfield\@mindspring.com'>timbutterfield\@mindspring.com</a>)<br />
DOV Support and Improved Dual ISDN Support - Traverse Technologies
(<a href='http://www.traverse.com.au/'>http://www.traverse.com.au/</a>)<br />
Traffic Shaping - David Kilpatrick
(<a href='mailto:dave\@thunder.com.au'>dave\@thunder.com.au</a>)<br />
Improved VPN Documentation - Christiaan Theron
(<a href='mailto:christiaan.theron\@virgin.net'>christiaan.theron\@virgin.net</a>)<br />
</p>
<p><b>Translations</b><br />
Rebecca Ward - Translation Coordinator
(<a href='mailto:rebeccaaward\@cox.net'>rebeccaaward\@cox.net</a>)<br />
Marco van Beek - Website Translation Database Developer
(<a href='mailto:mvanbeek\@supporting-role.co.uk'>mvanbeek\@supporting-role.co.uk</a>)<br />
Brazilian Portuguese:<br />
&nbsp; Edson-Empresa
(<a href='mailto:soma2\@somainformatica.com.br'>soma2\@somainformatica.com.br</a>)<br />
&nbsp; Claudio Corr&ecirc;a Porto
(<a href='mailto:claudio\@tsasp.com.br'>claudio\@tsasp.com.br</a>)<br />
&nbsp; Adilson Oliveira
(<a href='mailto:adilson\@linuxembarcado.com.br'>adilson\@linuxembarcado.com.br</a>)<br />
&nbsp; Mauricio Andrade
(<a href='mailto:mandrade\@mma.com.br'>mandrade\@mma.com.br</a>)<br />
&nbsp; Wladimir Nunes
(<a href='mailto:wnunes\@treesystems.com.br'>wnunes\@treesystems.com.br</a>)<br />
Chinese (Simplified):<br />
&nbsp; Vince Chu
(<a href='mailto:chuhei\@beunion.net'>chuhei\@beunion.net</a>)<br />
&nbsp; Yuan-Chen Cheng
(<a href='mailto:ycheng\@wiscore.com'>ycheng\@wiscore.com</a>)<br />
&nbsp; Sohoguard
(<a href='mailto:sohoguard\@hotmail.com'>sohoguard\@hotmail.com</a>)<br />
Chinese (Traditional):<br />
&nbsp; Ronald Ng
(<a href='mailto:mwpmo\@hotmail.com'>mwpmo\@hotmail.com</a>)<br />
Czech:<br />
&nbsp; Petr Dvoracek
(<a href='mailto:mandrake\@tiscali.cz'>mandrake\@tiscali.cz</a>)<br />
&nbsp; Jakub Moc
(<a href='mailto:Jakub.Moc\@seznam.cz'>Jakub.Moc\@seznam.cz</a>)<br />
Danish:<br />
&nbsp; Michael Rasmussen
(<a href='mailto:mir\@datanom.net'>mir\@datanom.net</a>)<br />
Dutch:<br />
&nbsp; Gerard Zwart
(<a href='mailto:zwartg\@home.nl'>zwartg\@home.nl</a>)<br />
&nbsp; Berdt van der Lingen
(<a href='mailto:berdt\@xs4all.nl'>berdt\@xs4all.nl</a>)<br />
&nbsp; Tony Vroon
(<a href='mailto:mrchainsaw\@users.sourceforge.net'>mrchainsaw\@users.sourceforge.net</a>)<br />
&nbsp; Mark Wormgoor<br />
&nbsp; Maikel Punie
(<a href='mailto:maikel.punie\@gmail.com'>maikel.punie\@gmail.com</a>)<br />
English:<br />
&nbsp; Jack Beglinger
(<a href='mailto:jackb_guppy\@yahoo.com'>jackb_guppy\@yahoo.com</a>)<br />
&nbsp; James Brice
(<a href='mailto:jbrice\@jamesbrice.com'>jbrice\@jamesbrice.com</a><br />
&nbsp; Tim Butterfield
(<a href='mailto:timbutterfield\@mindspring.com'>timbutterfield\@mindspring.com</a>)<br />
&nbsp; Chris Clancey
(<a href='mailto:chrisjc\@amoose.com'>chrisjc\@amoose.com</a>)<br />
&nbsp; Harry Goldschmitt
(<a href='mailto:harry\@hgac.com'>harry\@hgac.com</a>)<br />
&nbsp; John Kastner
(<a href='mailto:john\@kastner.us'>john\@kastner.us</a>)<br />
&nbsp; Eric Oberlander
(<a href='mailto:eric\@oberlander.co.uk'>eric\@oberlander.co.uk</a>)<br />
&nbsp; Stephen Pielschmidt
(<a href='mailto:stephen.pielschmidt\@sfp.com.au'>stephen.pielschmidt\@sfp.com.au</a>)<br />
&nbsp; Peter Walker
(<a href='mailto:peter.walker\@stockfast.co.uk'>peter.walker\@stockfast.co.uk</a>)<br />
Finnish:<br />
&nbsp; Kai Käpölä
(<a href='mailto:kai\@kapola.fi'>kai\@kapola.fi</a>)<br />
French:<br />
&nbsp; Bertrand Sarthre
(<a href='mailto:zetrebu\@softhome.net'>zetrebu\@softhome.net</a>)<br />
&nbsp; Michel Janssens
(<a href='mailto:micj\@ixus.net'>micj\@ixus.net</a>)<br />
&nbsp; Erwann Simon
(<a href='mailto:esn\@infobi.com'>esn\@infobi.com</a>) (<a href='mailto:wann\@ixus.net'>wann\@ixus.net</a>)<br />
&nbsp; Patrick Bernaud
(<a href='mailto:patrickbernaud\@users.sourceforge.net'>patrickbernaud\@users.sourceforge.net</a>)<br />
&nbsp; Marc Faid\'herbe
(<a href='mailto:marc\@decad.fr'>marc\@decad.fr</a>)<br />
&nbsp; Eric Legigan
(<a href='mailto:eric.legigan\@wanadoo.fr'>eric.legigan\@wanadoo.fr</a>)<br />
&nbsp; Eric Berthomier
(<a href='mailto:ebr\@infobi.com'>ebr\@infobi.com</a>)<br />
&nbsp; Stéphane Le Bourdon
(<a href='mailto:stephane.lebourdon\@free.fr'>stephane.lebourdon\@free.fr</a>)<br />
&nbsp; Stéphane Thirion
(<a href='mailto:sthirion\@activlan.com'>sthirion\@activlan.com</a>)<br />
&nbsp; Jan M. Dziewulski
(<a href='mailto:jan\@dziewulski.com'>jan\@dziewulski.com</a>)<br />
&nbsp;
(<a href='mailto:spoutnik\@inbox.lv'>spoutnik\@inbox.lv</a>)<br />
&nbsp; Eric
(<a href='mailto:darriak\@users.sourceforge.net'>darriak\@users.sourceforge.net</a>)<br />
&nbsp; Eric Boniface
(<a href='mailto:ericboniface\@chez.com'>ericboniface\@chez.com</a>)<br />
&nbsp; Franck Bourdonnec
(<a href='mailto:fbourdonnec\@chez.com'>fbourdonnec\@chez.com</a>)<br />
German:<br />
&nbsp; Dirk Loss
(<a href='mailto:dloss\@uni-muenster.de'>dloss\@uni-muenster.de</a>)<br />
&nbsp; Ludwig Steininger
(<a href='mailto:antispam1eastcomp\@gmx.de'>antispam1eastcomp\@gmx.de</a>)<br />
&nbsp; Helmet
(<a href='mailto:list\@metatalk.de'>list\@metatalk.de</a>)<br />
&nbsp; Markus
(<a href='mailto:mstl\@gmx.de'>mstl\@gmx.de</a>)<br />
&nbsp; Michael Knappe
(<a href='mailto:michael.knappe\@chello.at'>michael.knappe\@chello.at</a>)<br />
&nbsp; Michael Linke
(<a href='mailto:linke\@netmedia.de'>linke\@netmedia.de</a>)<br />
&nbsp; Richard Hartmann
(<a href='mailto:linux\@smhsoftware.de'>linux\@smhsoftware.de</a>)<br />
&nbsp; Ufuk Altinkaynak
(<a href='mailto:ufuk.altinkaynak\@wibo-werk.com'>ufuk.altinkaynak\@wibo-werk.com</a>)<br />
&nbsp; Gerhard Abrahams
(<a href='mailto:g.abrahams\@gmx.de'>g.abrahams\@gmx.de</a>)<br />
&nbsp; Benjamin Kohberg
(<a href='mailto:b.kohberg\@pci-software.de'>b.kohberg\@pci-software.de</a>)<br />
&nbsp; Samuel Wiktor
(<a href='mailto:samuel.wiktor\@stud.tu-ilmenau.de'>samuel.wiktor\@stud.tu-ilmenau.de</a>)<br />
Greek:<br />
&nbsp; Spyros Tsiolis
(<a href='mailto:info\@abaxb2b.com'>info\@abaxb2b.com</a>)<br />
&nbsp; A. Papageorgiou
(<a href='mailto:apap\@freemail.gr'>apap\@freemail.gr</a>)<br />
&nbsp; G. Xrysostomou
(<a href='mailto:gxry\@freemail.gr'>gxry\@freemail.gr</a>)<br />
Hungarian:<br />
&nbsp; Ádám Makovecz
(<a href='mailto:adam\@makovecz.hu'>adam\@makovecz.hu</a>)<br />
&nbsp; Ferenc Mányi-Szabó
(<a href='mailto:asd1234\@freemail.hu'>asd1234\@freemail.hu</a>)<br />
Italian:<br />
&nbsp; Fabio Gava
(<a href='mailto:fabio.gava\@bloomtech.it'>fabio.gava\@bloomtech.it</a>)<br />
&nbsp; Antonio Stano
(<a href='mailto:admin\@securityinfos.com'>admin\@securityinfos.com</a>)<br />
&nbsp; Marco Spreafico
(<a href='mailto:marco\@yetopen.it'>marco\@yetopen.it</a>)<br />
Latino Spanish:<br />
&nbsp; Fernando Díaz
(<a href='mailto:fernando.diaz\@adinet.com.uy'>fernando.diaz\@adinet.com.uy</a>)<br />
Lithuanian:<br />
&nbsp; Aurimas Fišeras
(<a href='mailto:aurimas\@gmail.com'>aurimas\@gmail.com</a>)<br />
&nbsp; Rodion Kotelnikov
(<a href='mailto:r0dik\@takas.lt'>r0dik\@takas.lt</a>)<br />
Norwegian:<br />
&nbsp; Morten Grendal
(<a href='mailto:morten\@grendal.no'>morten\@grendal.no</a>)<br />
&nbsp; Alexander Dawson
(<a href='mailto:daftkid\@users.sourceforge.net'>daftkid\@users.sourceforge.net</a>)<br />
&nbsp; Mounir S. Chermiti
(<a href='mailto:mounir\@solidonline.org'>mounir\@solidonline.org</a>)<br />
&nbsp; Runar Skraastad
(<a href='mailto:rus-\@home.no'>rus-\@home.no</a>)<br />
&nbsp; Alf-Ivar Holm
(<a href='mailto:alfh\@ifi.uio.no'>alfh\@ifi.uio.no</a>)<br />
Persian (Farsi):<br />
&nbsp; Ali Tajik
(<a href='mailto:trosec113\@gmail.com'>trosec113\@gmail.com</a>)<br />
&nbsp; A T Khalilian<br />
Polish:<br />
&nbsp; Jack Korzeniowski
(<a href='mailto:jk2002\@mail.com'>jk2002\@mail.com</a>)<br />
&nbsp; Piotr
(<a href='mailto:piotr\@esse.pl'>piotr\@esse.pl</a>)<br />
&nbsp; Andrzej Zolnierowicz
(<a href='mailto:zolnierowicz\@users.sourceforge.net'>zolnierowicz\@users.sourceforge.net</a>)<br />
&nbsp; Remi Schleicher
(remi(dot)schleicher(at)phreaker(dot)net)<br />
Portuguese:<br />
&nbsp; Luis Santos
(<a href='mailto:luis\@ciclo2000.com'>luis\@ciclo2000.com</a>)<br />
&nbsp; Renato Kenji Kano
(<a href='mailto:renato_kenji\@users.sourceforge.net'>renato_kenji\@users.sourceforge.net</a>)<br />
&nbsp; Mark Peter
(<a href='mailto:mark\@markpeter.com'>mark\@markpeter.com</a>)<br />
&nbsp; Wladimir Nunes
(<a href='mailto:wnunes\@users.sourceforge.net'>wnunes\@users.sourceforge.net</a>)<br />
&nbsp; Daniela Cattarossi
(<a href='mailto:daniela\@netpandora.com'>daniela\@netpandora.com</a>)<br />
Romanian:<br />
&nbsp; Viorel Melinte
(<a href='mailto:viorel.melinte\@hidro.ro'>viorel.melinte\@hidro.ro</a>)<br />
Russian/Ukranian:<br />
&nbsp; Vladimir Grichina
(<a href='mailto:vgua\@users.sourceforge.net'>vgua\@users.sourceforge.net</a>)<br />
&nbsp; Vitaly Tarasov
(<a href='mailto:vtarasov\@knoa.com'>vtarasov\@knoa.com</a>)<br />
&nbsp; Rodion Kotelnikov
(<a href='mailto:r0dik\@takas.lt'>r0dik\@takas.lt</a>)<br />
Slovak:<br />
&nbsp; Miloš Mráz
(<a href='mailto:Milos.Mraz\@svum.sk'>Milos.Mraz\@svum.sk</a>)<br />
&nbsp; Drlik Zbynek
(<a href='mailto:denix\@host.sk'>denix\@host.sk</a>)<br />
Slovenian:<br />
&nbsp; Miha Martinec
(<a href='mailto:miha\@martinec.si'>miha\@martinec.si</a>)<br />
&nbsp; Grega Varl
(<a href='mailto:gregav\@finea-holding.si'>gregav\@finea-holding.si</a>)<br />
Somali:<br />
&nbsp; Arnt Karlsen
(<a href='mailto:arnt\@c2i.net'>arnt\@c2i.net</a>)<br />
&nbsp; Mohamed Musa Ali
(<a href='mailto:alimuse\@hotmail.com'>alimuse\@hotmail.com</a>)<br />
&nbsp; Michael Spann
(<a href='mailto:dr-ms\@lycos.de'>dr-ms\@lycos.de</a>)<br />
Spanish:<br />
&nbsp; Curtis Anderson
(<a href='mailto:curtis_anderson\@curtisanderson.com'>curtis_anderson\@curtisanderson.com</a>)<br />
&nbsp; Diego Lombardia
(<a href='mailto:Diego.Lombardia\@IT-Plus.com.ar'>Diego.Lombardia\@IT-Plus.com.ar</a>)<br />
&nbsp; Mark Peter
(<a href='mailto:mark\@markpeter.com'>mark\@markpeter.com</a>)<br />
&nbsp; QuiQue Soriano
(<a href='mailto:jqsoriano\@hotmail.com'>jqsoriano\@hotmail.com</a>)<br />
&nbsp; David Cabrera Lozano
(<a href='mailto:silews\@users.sourceforge.net'>silews\@users.sourceforge.net</a>)<br />
&nbsp; Jose Sanchez
(<a href='mailto:jsanchez\@cyberdude.com'>jsanchez\@cyberdude.com</a>)<br />
&nbsp; Santiago Cassina
(<a href='mailto:scap2000\@yahoo.com'>scap2000\@yahoo.com</a>)<br />
&nbsp; Marcelo Zunino
(<a href='mailto:cezuni\@adinet.com.uy'>cezuni\@adinet.com.uy</a>)<br />
&nbsp; Alfredo Matignon
(<a href='mailto:amatignon\@softhome.net'>amatignon\@softhome.net</a>)<br />
&nbsp; Juan Janczuk
(<a href='mailto:jjanzcuk\@msn.com'>jjanzcuk\@msn.com</a>)<br />
Swedish:<br />
&nbsp; Anders Sahlman
(<a href='mailto:anders.sahlman\@dataunit.se'>anders.sahlman\@dataunit.se</a>)<br />
&nbsp; Christer Jonson
(<a href='mailto:christer.jonson\@swipnet.se'>christer.jonson\@swipnet.se</a>)<br />
Thai:<br />
&nbsp; Touchie
(<a href='mailto:pongsathorns\@se-ed.net'>pongsathorns\@se-ed.net</a>)<br />
Turkish:<br />
&nbsp; Ismail Murat Dilek
(<a href='mailto:olive\@zoom.co.uk'>olive\@zoom.co.uk</a>)<br />
&nbsp; Emre Sumengen
<br />
Vietnamese:<br />
&nbsp; Le Dinh Long
(<a href='mailto:longld\@yahoo.com'>longld\@yahoo.com</a>)<br />
</p>
<p><b>Smoothwall</b><br />
IPCop is partially based on the <a href='http://www.smoothwall.org'>Smoothwall</a> GPL
version, v0.9.9. We are grateful to them for both inspiring this product and
giving us the codebase to work with. Smoothwall was developed by:
</p>
<p>
Founder and Project Manager - Richard Morrell
(<a href='mailto:richard\@smoothwall.org'>richard\@smoothwall.org</a>)<br />
Development Team Leader and Author - Lawrence Manning
(<a href='mailto:lawrence\@smoothwall.org'>lawrence\@smoothwall.org</a>)<br />
Dan Goscomb - Architecture team leader, Core Developer &amp; Perl Guru
(<a href='mailto:dang\@smoothwall.org'>dang\@smoothwall.org</a>)<br />
Paul Tansom - Worldwide Community Liason
(<a href='mailto:paul\@smoothwall.org'>paul\@smoothwall.org</a>)<br />
William Anderson - Worldwide Online Team Manager &amp; Webmanager
(<a href='mailto:neuro\@smoothwall.org'>neuro\@smoothwall.org</a>)<br />
Rebecca Ward - Worldwide Online Support Manager
(<a href='mailto:becca\@smoothwall.org'>becca\@smoothwall.org</a>)<br />
Bill Ward - US Support &amp; Evangelist
(<a href='mailto:bill\@smoothwall.org'>bill\@smoothwall.org</a>)<br />
Chris Ross - Chief Wizard
(<a href='mailto:chris\@smoothwall.org'>chris\@smoothwall.org</a>)<br />
Mark Wormgoor - ISDN Lead Developer
(<a href='mailto:mark\@wormgoor.com'>mark\@wormgoor.com</a>)<br />
Eric Johansson - US Team Leader
(<a href='mailto:esj\@harvee.billerica.ma.us'>esj\@harvee.billerica.ma.us</a>)<br />
Dan Cuthbert - Lead Security Manager
(<a href='mailto:security\@smoothwall.org'>security\@smoothwall.org</a>)<br />
Pierre-Yves Paulus - Belgian Team Leader and PPPoE guru
(<a href='mailto:pauluspy\@easynet.be'>pauluspy\@easynet.be</a>)<br />
John Payne - DNS &amp; Tech Contibutor
(<a href='mailto:john\@sackheads.org'>john\@sackheads.org</a>)<br />
Adam Wilkinson - VPN Assistance
(<a href='mailto:aaw10\@hslmc.cam.ac.uk'>aaw10\@hslmc.cam.ac.uk</a>)<br />
Jez Tucker - Testing
(<a href='mailto:jez\@rib-it.org'>jez\@rib-it.org</a>)<br />
Pete Guyan - Tech testing &amp; Input
(<a href='mailto:pete\@snowplains.org'>pete\@snowplains.org</a>)<br />
Nigel Fenton - Development and Testing
(<a href='mailto:nigel.fenton\@btinternet.com'>nigel.fenton\@btinternet.com</a>)<br />
Bob Dunlop - The Guru's Guru &amp; Code Magician
(<a href='mailto:rjd\@xyzzy.clara.co.uk'>rjd\@xyzzy.clara.co.uk</a>)<br />
</p>
<br />
END
;
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: credits.cgi,v 1.11.2.30 2006/01/08 13:33:36 eoberlander Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
&Header::showhttpheaders();
&Header::openpage($Lang::tr{'credits'}, 1, '');
&Header::openbigbox('100%', 'center');
&Header::openbox('100%', 'left', $Lang::tr{'credits'});
print <<END
<br /><center><b>Visit us on <a href='http://www.ipcop.org/'>http://www.ipcop.org/</a></b></center>
<p><b>Main Credits</b><br />
Project Member - Mark Wormgoor
(<a href='mailto:mark\@wormgoor.com'>mark\@wormgoor.com</a>)<br />
Project Member &amp; Configuration backup/restore - Eric S. Johansson
(<a href='mailto:esj\@harvee.billerica.ma.us'>esj\@harvee.billerica.ma.us</a>)<br />
Project Member - Jack Beglinger
(<a href='mailto:jackb_guppy\@yahoo.com'>jackb_guppy\@yahoo.com</a>)<br />
Developer - Darren Critchley
(<a href='mailto:darrenc\@telus.net'>darrenc\@telus.net</a>)<br />
Developer - Robert Kerr
(<a href='mailto:LittleThor\@xsw.terminator.net'>LittleThor\@xsw.terminator.net</a>)<br />
Developer - Alan Hourihane
(<a href='mailto:alanh\@fairlite.demon.co.uk'>alanh\@fairlite.demon.co.uk</a>)<br />
ADSL Developer - Gilles Espinasse
(<a href='mailto:g.esp.ipcop\@free.fr'>g.esp.ipcop\@free.fr</a>)<br />
Perl Developer - Franck Bourdonnec
(<a href='mailto:fbourdonnec\@chez.com'>fbourdonnec\@chez.com</a>)<br />
Testing - Dave Roberts
(<a href='mailto:dave\@daver.demon.co.uk'>dave\@daver.demon.co.uk</a>)<br />
Website Design + Graphics - Seth Bareiss
(<a href='mailto:seth\@fureai-ch.ne.jp'>seth\@fureai-ch.ne.jp</a>)<br />
Documentation - Harry Goldschmitt
(<a href='mailto:harry\@hgac.com'>harry\@hgac.com</a>)<br />
Red IP Aliasing - Steve Bootes
(<a href='mailto:Steve\@computingdynamics.co.uk'>Steve\@computingdynamics.co.uk</a>)<br />
Static DHCP Addresses - Graham Smith
(<a href='mailto:grhm\@grhm.co.uk'>grhm\@grhm.co.uk</a>)<br />
Squid graphs - Robert Wood
(<a href='rob\@empathymp3.co.uk'>rob\@empathymp3.co.uk</a>)<br />
Time Synchronization - Eric Oberlander
(<a href='mailto:eric\@oberlander.co.uk'>eric\@oberlander.co.uk</a>)<br />
Backup - Tim Butterfield
(<a href='mailto:timbutterfield\@mindspring.com'>timbutterfield\@mindspring.com</a>)<br />
DOV Support and Improved Dual ISDN Support - Traverse Technologies
(<a href='http://www.traverse.com.au/'>http://www.traverse.com.au/</a>)<br />
Traffic Shaping - David Kilpatrick
(<a href='mailto:dave\@thunder.com.au'>dave\@thunder.com.au</a>)<br />
Improved VPN Documentation - Christiaan Theron
(<a href='mailto:christiaan.theron\@virgin.net'>christiaan.theron\@virgin.net</a>)<br />
</p>
<p><b>Translations</b><br />
Rebecca Ward - Translation Coordinator
(<a href='mailto:rebeccaaward\@cox.net'>rebeccaaward\@cox.net</a>)<br />
Marco van Beek - Website Translation Database Developer
(<a href='mailto:mvanbeek\@supporting-role.co.uk'>mvanbeek\@supporting-role.co.uk</a>)<br />
Brazilian Portuguese:<br />
&nbsp; Edson-Empresa
(<a href='mailto:soma2\@somainformatica.com.br'>soma2\@somainformatica.com.br</a>)<br />
&nbsp; Claudio Corr&ecirc;a Porto
(<a href='mailto:claudio\@tsasp.com.br'>claudio\@tsasp.com.br</a>)<br />
&nbsp; Adilson Oliveira
(<a href='mailto:adilson\@linuxembarcado.com.br'>adilson\@linuxembarcado.com.br</a>)<br />
&nbsp; Mauricio Andrade
(<a href='mailto:mandrade\@mma.com.br'>mandrade\@mma.com.br</a>)<br />
&nbsp; Wladimir Nunes
(<a href='mailto:wnunes\@treesystems.com.br'>wnunes\@treesystems.com.br</a>)<br />
Chinese (Simplified):<br />
&nbsp; Vince Chu
(<a href='mailto:chuhei\@beunion.net'>chuhei\@beunion.net</a>)<br />
&nbsp; Yuan-Chen Cheng
(<a href='mailto:ycheng\@wiscore.com'>ycheng\@wiscore.com</a>)<br />
&nbsp; Sohoguard
(<a href='mailto:sohoguard\@hotmail.com'>sohoguard\@hotmail.com</a>)<br />
Chinese (Traditional):<br />
&nbsp; Ronald Ng
(<a href='mailto:mwpmo\@hotmail.com'>mwpmo\@hotmail.com</a>)<br />
Czech:<br />
&nbsp; Petr Dvoracek
(<a href='mailto:mandrake\@tiscali.cz'>mandrake\@tiscali.cz</a>)<br />
&nbsp; Jakub Moc
(<a href='mailto:Jakub.Moc\@seznam.cz'>Jakub.Moc\@seznam.cz</a>)<br />
Danish:<br />
&nbsp; Michael Rasmussen
(<a href='mailto:mir\@datanom.net'>mir\@datanom.net</a>)<br />
Dutch:<br />
&nbsp; Gerard Zwart
(<a href='mailto:zwartg\@home.nl'>zwartg\@home.nl</a>)<br />
&nbsp; Berdt van der Lingen
(<a href='mailto:berdt\@xs4all.nl'>berdt\@xs4all.nl</a>)<br />
&nbsp; Tony Vroon
(<a href='mailto:mrchainsaw\@users.sourceforge.net'>mrchainsaw\@users.sourceforge.net</a>)<br />
&nbsp; Mark Wormgoor<br />
&nbsp; Maikel Punie
(<a href='mailto:maikel.punie\@gmail.com'>maikel.punie\@gmail.com</a>)<br />
English:<br />
&nbsp; Jack Beglinger
(<a href='mailto:jackb_guppy\@yahoo.com'>jackb_guppy\@yahoo.com</a>)<br />
&nbsp; James Brice
(<a href='mailto:jbrice\@jamesbrice.com'>jbrice\@jamesbrice.com</a><br />
&nbsp; Tim Butterfield
(<a href='mailto:timbutterfield\@mindspring.com'>timbutterfield\@mindspring.com</a>)<br />
&nbsp; Chris Clancey
(<a href='mailto:chrisjc\@amoose.com'>chrisjc\@amoose.com</a>)<br />
&nbsp; Harry Goldschmitt
(<a href='mailto:harry\@hgac.com'>harry\@hgac.com</a>)<br />
&nbsp; John Kastner
(<a href='mailto:john\@kastner.us'>john\@kastner.us</a>)<br />
&nbsp; Eric Oberlander
(<a href='mailto:eric\@oberlander.co.uk'>eric\@oberlander.co.uk</a>)<br />
&nbsp; Stephen Pielschmidt
(<a href='mailto:stephen.pielschmidt\@sfp.com.au'>stephen.pielschmidt\@sfp.com.au</a>)<br />
&nbsp; Peter Walker
(<a href='mailto:peter.walker\@stockfast.co.uk'>peter.walker\@stockfast.co.uk</a>)<br />
Finnish:<br />
&nbsp; Kai Käpölä
(<a href='mailto:kai\@kapola.fi'>kai\@kapola.fi</a>)<br />
French:<br />
&nbsp; Bertrand Sarthre
(<a href='mailto:zetrebu\@softhome.net'>zetrebu\@softhome.net</a>)<br />
&nbsp; Michel Janssens
(<a href='mailto:micj\@ixus.net'>micj\@ixus.net</a>)<br />
&nbsp; Erwann Simon
(<a href='mailto:esn\@infobi.com'>esn\@infobi.com</a>) (<a href='mailto:wann\@ixus.net'>wann\@ixus.net</a>)<br />
&nbsp; Patrick Bernaud
(<a href='mailto:patrickbernaud\@users.sourceforge.net'>patrickbernaud\@users.sourceforge.net</a>)<br />
&nbsp; Marc Faid\'herbe
(<a href='mailto:marc\@decad.fr'>marc\@decad.fr</a>)<br />
&nbsp; Eric Legigan
(<a href='mailto:eric.legigan\@wanadoo.fr'>eric.legigan\@wanadoo.fr</a>)<br />
&nbsp; Eric Berthomier
(<a href='mailto:ebr\@infobi.com'>ebr\@infobi.com</a>)<br />
&nbsp; Stéphane Le Bourdon
(<a href='mailto:stephane.lebourdon\@free.fr'>stephane.lebourdon\@free.fr</a>)<br />
&nbsp; Stéphane Thirion
(<a href='mailto:sthirion\@activlan.com'>sthirion\@activlan.com</a>)<br />
&nbsp; Jan M. Dziewulski
(<a href='mailto:jan\@dziewulski.com'>jan\@dziewulski.com</a>)<br />
&nbsp;
(<a href='mailto:spoutnik\@inbox.lv'>spoutnik\@inbox.lv</a>)<br />
&nbsp; Eric
(<a href='mailto:darriak\@users.sourceforge.net'>darriak\@users.sourceforge.net</a>)<br />
&nbsp; Eric Boniface
(<a href='mailto:ericboniface\@chez.com'>ericboniface\@chez.com</a>)<br />
&nbsp; Franck Bourdonnec
(<a href='mailto:fbourdonnec\@chez.com'>fbourdonnec\@chez.com</a>)<br />
German:<br />
&nbsp; Dirk Loss
(<a href='mailto:dloss\@uni-muenster.de'>dloss\@uni-muenster.de</a>)<br />
&nbsp; Ludwig Steininger
(<a href='mailto:antispam1eastcomp\@gmx.de'>antispam1eastcomp\@gmx.de</a>)<br />
&nbsp; Helmet
(<a href='mailto:list\@metatalk.de'>list\@metatalk.de</a>)<br />
&nbsp; Markus
(<a href='mailto:mstl\@gmx.de'>mstl\@gmx.de</a>)<br />
&nbsp; Michael Knappe
(<a href='mailto:michael.knappe\@chello.at'>michael.knappe\@chello.at</a>)<br />
&nbsp; Michael Linke
(<a href='mailto:linke\@netmedia.de'>linke\@netmedia.de</a>)<br />
&nbsp; Richard Hartmann
(<a href='mailto:linux\@smhsoftware.de'>linux\@smhsoftware.de</a>)<br />
&nbsp; Ufuk Altinkaynak
(<a href='mailto:ufuk.altinkaynak\@wibo-werk.com'>ufuk.altinkaynak\@wibo-werk.com</a>)<br />
&nbsp; Gerhard Abrahams
(<a href='mailto:g.abrahams\@gmx.de'>g.abrahams\@gmx.de</a>)<br />
&nbsp; Benjamin Kohberg
(<a href='mailto:b.kohberg\@pci-software.de'>b.kohberg\@pci-software.de</a>)<br />
&nbsp; Samuel Wiktor
(<a href='mailto:samuel.wiktor\@stud.tu-ilmenau.de'>samuel.wiktor\@stud.tu-ilmenau.de</a>)<br />
Greek:<br />
&nbsp; Spyros Tsiolis
(<a href='mailto:info\@abaxb2b.com'>info\@abaxb2b.com</a>)<br />
&nbsp; A. Papageorgiou
(<a href='mailto:apap\@freemail.gr'>apap\@freemail.gr</a>)<br />
&nbsp; G. Xrysostomou
(<a href='mailto:gxry\@freemail.gr'>gxry\@freemail.gr</a>)<br />
Hungarian:<br />
&nbsp; Ádám Makovecz
(<a href='mailto:adam\@makovecz.hu'>adam\@makovecz.hu</a>)<br />
&nbsp; Ferenc Mányi-Szabó
(<a href='mailto:asd1234\@freemail.hu'>asd1234\@freemail.hu</a>)<br />
Italian:<br />
&nbsp; Fabio Gava
(<a href='mailto:fabio.gava\@bloomtech.it'>fabio.gava\@bloomtech.it</a>)<br />
&nbsp; Antonio Stano
(<a href='mailto:admin\@securityinfos.com'>admin\@securityinfos.com</a>)<br />
&nbsp; Marco Spreafico
(<a href='mailto:marco\@yetopen.it'>marco\@yetopen.it</a>)<br />
Latino Spanish:<br />
&nbsp; Fernando Díaz
(<a href='mailto:fernando.diaz\@adinet.com.uy'>fernando.diaz\@adinet.com.uy</a>)<br />
Lithuanian:<br />
&nbsp; Aurimas Fišeras
(<a href='mailto:aurimas\@gmail.com'>aurimas\@gmail.com</a>)<br />
&nbsp; Rodion Kotelnikov
(<a href='mailto:r0dik\@takas.lt'>r0dik\@takas.lt</a>)<br />
Norwegian:<br />
&nbsp; Morten Grendal
(<a href='mailto:morten\@grendal.no'>morten\@grendal.no</a>)<br />
&nbsp; Alexander Dawson
(<a href='mailto:daftkid\@users.sourceforge.net'>daftkid\@users.sourceforge.net</a>)<br />
&nbsp; Mounir S. Chermiti
(<a href='mailto:mounir\@solidonline.org'>mounir\@solidonline.org</a>)<br />
&nbsp; Runar Skraastad
(<a href='mailto:rus-\@home.no'>rus-\@home.no</a>)<br />
&nbsp; Alf-Ivar Holm
(<a href='mailto:alfh\@ifi.uio.no'>alfh\@ifi.uio.no</a>)<br />
Persian (Farsi):<br />
&nbsp; Ali Tajik
(<a href='mailto:trosec113\@gmail.com'>trosec113\@gmail.com</a>)<br />
&nbsp; A T Khalilian<br />
Polish:<br />
&nbsp; Jack Korzeniowski
(<a href='mailto:jk2002\@mail.com'>jk2002\@mail.com</a>)<br />
&nbsp; Piotr
(<a href='mailto:piotr\@esse.pl'>piotr\@esse.pl</a>)<br />
&nbsp; Andrzej Zolnierowicz
(<a href='mailto:zolnierowicz\@users.sourceforge.net'>zolnierowicz\@users.sourceforge.net</a>)<br />
&nbsp; Remi Schleicher
(remi(dot)schleicher(at)phreaker(dot)net)<br />
Portuguese:<br />
&nbsp; Luis Santos
(<a href='mailto:luis\@ciclo2000.com'>luis\@ciclo2000.com</a>)<br />
&nbsp; Renato Kenji Kano
(<a href='mailto:renato_kenji\@users.sourceforge.net'>renato_kenji\@users.sourceforge.net</a>)<br />
&nbsp; Mark Peter
(<a href='mailto:mark\@markpeter.com'>mark\@markpeter.com</a>)<br />
&nbsp; Wladimir Nunes
(<a href='mailto:wnunes\@users.sourceforge.net'>wnunes\@users.sourceforge.net</a>)<br />
&nbsp; Daniela Cattarossi
(<a href='mailto:daniela\@netpandora.com'>daniela\@netpandora.com</a>)<br />
Romanian:<br />
&nbsp; Viorel Melinte
(<a href='mailto:viorel.melinte\@hidro.ro'>viorel.melinte\@hidro.ro</a>)<br />
Russian/Ukranian:<br />
&nbsp; Vladimir Grichina
(<a href='mailto:vgua\@users.sourceforge.net'>vgua\@users.sourceforge.net</a>)<br />
&nbsp; Vitaly Tarasov
(<a href='mailto:vtarasov\@knoa.com'>vtarasov\@knoa.com</a>)<br />
&nbsp; Rodion Kotelnikov
(<a href='mailto:r0dik\@takas.lt'>r0dik\@takas.lt</a>)<br />
Slovak:<br />
&nbsp; Miloš Mráz
(<a href='mailto:Milos.Mraz\@svum.sk'>Milos.Mraz\@svum.sk</a>)<br />
&nbsp; Drlik Zbynek
(<a href='mailto:denix\@host.sk'>denix\@host.sk</a>)<br />
Slovenian:<br />
&nbsp; Miha Martinec
(<a href='mailto:miha\@martinec.si'>miha\@martinec.si</a>)<br />
&nbsp; Grega Varl
(<a href='mailto:gregav\@finea-holding.si'>gregav\@finea-holding.si</a>)<br />
Somali:<br />
&nbsp; Arnt Karlsen
(<a href='mailto:arnt\@c2i.net'>arnt\@c2i.net</a>)<br />
&nbsp; Mohamed Musa Ali
(<a href='mailto:alimuse\@hotmail.com'>alimuse\@hotmail.com</a>)<br />
&nbsp; Michael Spann
(<a href='mailto:dr-ms\@lycos.de'>dr-ms\@lycos.de</a>)<br />
Spanish:<br />
&nbsp; Curtis Anderson
(<a href='mailto:curtis_anderson\@curtisanderson.com'>curtis_anderson\@curtisanderson.com</a>)<br />
&nbsp; Diego Lombardia
(<a href='mailto:Diego.Lombardia\@IT-Plus.com.ar'>Diego.Lombardia\@IT-Plus.com.ar</a>)<br />
&nbsp; Mark Peter
(<a href='mailto:mark\@markpeter.com'>mark\@markpeter.com</a>)<br />
&nbsp; QuiQue Soriano
(<a href='mailto:jqsoriano\@hotmail.com'>jqsoriano\@hotmail.com</a>)<br />
&nbsp; David Cabrera Lozano
(<a href='mailto:silews\@users.sourceforge.net'>silews\@users.sourceforge.net</a>)<br />
&nbsp; Jose Sanchez
(<a href='mailto:jsanchez\@cyberdude.com'>jsanchez\@cyberdude.com</a>)<br />
&nbsp; Santiago Cassina
(<a href='mailto:scap2000\@yahoo.com'>scap2000\@yahoo.com</a>)<br />
&nbsp; Marcelo Zunino
(<a href='mailto:cezuni\@adinet.com.uy'>cezuni\@adinet.com.uy</a>)<br />
&nbsp; Alfredo Matignon
(<a href='mailto:amatignon\@softhome.net'>amatignon\@softhome.net</a>)<br />
&nbsp; Juan Janczuk
(<a href='mailto:jjanzcuk\@msn.com'>jjanzcuk\@msn.com</a>)<br />
Swedish:<br />
&nbsp; Anders Sahlman
(<a href='mailto:anders.sahlman\@dataunit.se'>anders.sahlman\@dataunit.se</a>)<br />
&nbsp; Christer Jonson
(<a href='mailto:christer.jonson\@swipnet.se'>christer.jonson\@swipnet.se</a>)<br />
Thai:<br />
&nbsp; Touchie
(<a href='mailto:pongsathorns\@se-ed.net'>pongsathorns\@se-ed.net</a>)<br />
Turkish:<br />
&nbsp; Ismail Murat Dilek
(<a href='mailto:olive\@zoom.co.uk'>olive\@zoom.co.uk</a>)<br />
&nbsp; Emre Sumengen
<br />
Vietnamese:<br />
&nbsp; Le Dinh Long
(<a href='mailto:longld\@yahoo.com'>longld\@yahoo.com</a>)<br />
</p>
<p><b>Smoothwall</b><br />
IPCop is partially based on the <a href='http://www.smoothwall.org'>Smoothwall</a> GPL
version, v0.9.9. We are grateful to them for both inspiring this product and
giving us the codebase to work with. Smoothwall was developed by:
</p>
<p>
Founder and Project Manager - Richard Morrell
(<a href='mailto:richard\@smoothwall.org'>richard\@smoothwall.org</a>)<br />
Development Team Leader and Author - Lawrence Manning
(<a href='mailto:lawrence\@smoothwall.org'>lawrence\@smoothwall.org</a>)<br />
Dan Goscomb - Architecture team leader, Core Developer &amp; Perl Guru
(<a href='mailto:dang\@smoothwall.org'>dang\@smoothwall.org</a>)<br />
Paul Tansom - Worldwide Community Liason
(<a href='mailto:paul\@smoothwall.org'>paul\@smoothwall.org</a>)<br />
William Anderson - Worldwide Online Team Manager &amp; Webmanager
(<a href='mailto:neuro\@smoothwall.org'>neuro\@smoothwall.org</a>)<br />
Rebecca Ward - Worldwide Online Support Manager
(<a href='mailto:becca\@smoothwall.org'>becca\@smoothwall.org</a>)<br />
Bill Ward - US Support &amp; Evangelist
(<a href='mailto:bill\@smoothwall.org'>bill\@smoothwall.org</a>)<br />
Chris Ross - Chief Wizard
(<a href='mailto:chris\@smoothwall.org'>chris\@smoothwall.org</a>)<br />
Mark Wormgoor - ISDN Lead Developer
(<a href='mailto:mark\@wormgoor.com'>mark\@wormgoor.com</a>)<br />
Eric Johansson - US Team Leader
(<a href='mailto:esj\@harvee.billerica.ma.us'>esj\@harvee.billerica.ma.us</a>)<br />
Dan Cuthbert - Lead Security Manager
(<a href='mailto:security\@smoothwall.org'>security\@smoothwall.org</a>)<br />
Pierre-Yves Paulus - Belgian Team Leader and PPPoE guru
(<a href='mailto:pauluspy\@easynet.be'>pauluspy\@easynet.be</a>)<br />
John Payne - DNS &amp; Tech Contibutor
(<a href='mailto:john\@sackheads.org'>john\@sackheads.org</a>)<br />
Adam Wilkinson - VPN Assistance
(<a href='mailto:aaw10\@hslmc.cam.ac.uk'>aaw10\@hslmc.cam.ac.uk</a>)<br />
Jez Tucker - Testing
(<a href='mailto:jez\@rib-it.org'>jez\@rib-it.org</a>)<br />
Pete Guyan - Tech testing &amp; Input
(<a href='mailto:pete\@snowplains.org'>pete\@snowplains.org</a>)<br />
Nigel Fenton - Development and Testing
(<a href='mailto:nigel.fenton\@btinternet.com'>nigel.fenton\@btinternet.com</a>)<br />
Bob Dunlop - The Guru's Guru &amp; Code Magician
(<a href='mailto:rjd\@xyzzy.clara.co.uk'>rjd\@xyzzy.clara.co.uk</a>)<br />
</p>
<br />
END
;
&Header::closebox();
&Header::closebigbox();
&Header::closepage();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,35 +1,35 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: dial.cgi,v 1.4.2.3 2005/02/22 22:21:55 gespinasse Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %cgiparams=();
$cgiparams{'ACTION'} = '';
&Header::getcgihash(\%cgiparams);
if ($cgiparams{'ACTION'} eq $Lang::tr{'dial'}) {
system('/etc/rc.d/rc.red','start') == 0
or &General::log("Dial failed: $?"); }
elsif ($cgiparams{'ACTION'} eq $Lang::tr{'hangup'}) {
system('/etc/rc.d/rc.red','stop') == 0
or &General::log("Hangup failed: $?"); }
sleep 1;
print "Status: 302 Moved\nLocation: /cgi-bin/index.cgi\n\n";
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: dial.cgi,v 1.4.2.3 2005/02/22 22:21:55 gespinasse Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %cgiparams=();
$cgiparams{'ACTION'} = '';
&Header::getcgihash(\%cgiparams);
if ($cgiparams{'ACTION'} eq $Lang::tr{'dial'}) {
system('/etc/rc.d/rc.red','start') == 0
or &General::log("Dial failed: $?"); }
elsif ($cgiparams{'ACTION'} eq $Lang::tr{'hangup'}) {
system('/etc/rc.d/rc.red','stop') == 0
or &General::log("Hangup failed: $?"); }
sleep 1;
print "Status: 302 Moved\nLocation: /cgi-bin/index.cgi\n\n";

View File

@@ -1,440 +1,440 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: dmzholes.cgi,v 1.9.2.16 2005/10/18 17:05:27 franck78 Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::table2colour}, ${Header::colouryellow} );
undef (@dummy);
my %cgiparams=();
my %checked=();
my %selected=();
my %netsettings=();
my $errormessage = '';
my $filename = "${General::swroot}/dmzholes/config";
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
&Header::showhttpheaders();
$cgiparams{'ENABLED'} = 'off';
$cgiparams{'REMARK'} = '';
$cgiparams{'ACTION'} = '';
$cgiparams{'SRC_IP'} = '';
$cgiparams{'DEST_IP'} ='';
$cgiparams{'DEST_PORT'} = '';
&Header::getcgihash(\%cgiparams);
open(FILE, $filename) or die 'Unable to open config file.';
my @current = <FILE>;
close(FILE);
if ($cgiparams{'ACTION'} eq $Lang::tr{'add'})
{
unless($cgiparams{'PROTOCOL'} =~ /^(tcp|udp)$/) { $errormessage = $Lang::tr{'invalid input'}; }
unless(&General::validipormask($cgiparams{'SRC_IP'})) { $errormessage = $Lang::tr{'source ip bad'}; }
unless($errormessage){$errormessage = &General::validportrange($cgiparams{'DEST_PORT'},'dst');}
unless(&General::validipormask($cgiparams{'DEST_IP'})) { $errormessage = $Lang::tr{'destination ip bad'}; }
unless ($errormessage) {
$errormessage = &validNet($cgiparams{'SRC_NET'},$cgiparams{'DEST_NET'}); }
# Darren Critchley - Remove commas from remarks
$cgiparams{'REMARK'} = &Header::cleanhtml($cgiparams{'REMARK'});
unless ($errormessage)
{
if($cgiparams{'EDITING'} eq 'no') {
open(FILE,">>$filename") or die 'Unable to open config file.';
flock FILE, 2;
print FILE "$cgiparams{'PROTOCOL'},"; # [0]
print FILE "$cgiparams{'SRC_IP'},"; # [1]
print FILE "$cgiparams{'DEST_IP'},"; # [2]
print FILE "$cgiparams{'DEST_PORT'},"; # [3]
print FILE "$cgiparams{'ENABLED'},"; # [4]
print FILE "$cgiparams{'SRC_NET'},"; # [5]
print FILE "$cgiparams{'DEST_NET'},"; # [6]
print FILE "$cgiparams{'REMARK'}\n"; # [7]
} else {
open(FILE,">$filename") or die 'Unable to open config file.';
flock FILE, 2;
my $id = 0;
foreach my $line (@current)
{
$id++;
if ($cgiparams{'EDITING'} eq $id) {
print FILE "$cgiparams{'PROTOCOL'},"; # [0]
print FILE "$cgiparams{'SRC_IP'},"; # [1]
print FILE "$cgiparams{'DEST_IP'},"; # [2]
print FILE "$cgiparams{'DEST_PORT'},"; # [3]
print FILE "$cgiparams{'ENABLED'},"; # [4]
print FILE "$cgiparams{'SRC_NET'},"; # [5]
print FILE "$cgiparams{'DEST_NET'},"; # [6]
print FILE "$cgiparams{'REMARK'}\n"; # [7]
} else { print FILE "$line"; }
}
}
close(FILE);
undef %cgiparams;
&General::log($Lang::tr{'dmz pinhole rule added'});
system('/usr/local/bin/setdmzholes');
}
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'remove'})
{
my $id = 0;
open(FILE, ">$filename") or die 'Unable to open config file.';
flock FILE, 2;
foreach my $line (@current)
{
$id++;
unless ($cgiparams{'ID'} eq $id) { print FILE "$line"; }
}
close(FILE);
system('/usr/local/bin/setdmzholes');
&General::log($Lang::tr{'dmz pinhole rule removed'});
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'toggle enable disable'})
{
my $id = 0;
open(FILE, ">$filename") or die 'Unable to open config file.';
flock FILE, 2;
foreach my $line (@current)
{
$id++;
unless ($cgiparams{'ID'} eq $id) { print FILE "$line"; }
else
{
chomp($line);
my @temp = split(/\,/,$line);
print FILE "$temp[0],$temp[1],$temp[2],$temp[3],$cgiparams{'ENABLE'},$temp[5],$temp[6],$temp[7]\n";
}
}
close(FILE);
system('/usr/local/bin/setdmzholes');
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'})
{
my $id = 0;
foreach my $line (@current)
{
$id++;
if ($cgiparams{'ID'} eq $id)
{
chomp($line);
my @temp = split(/\,/,$line);
$cgiparams{'PROTOCOL'} = $temp[0];
$cgiparams{'SRC_IP'} = $temp[1];
$cgiparams{'DEST_IP'} = $temp[2];
$cgiparams{'DEST_PORT'} = $temp[3];
$cgiparams{'ENABLED'} = $temp[4];
$cgiparams{'SRC_NET'} = $temp[5];
$cgiparams{'DEST_NET'} = $temp[6];
$cgiparams{'REMARK'} = $temp[7];
}
}
}
if ($cgiparams{'ACTION'} eq '')
{
$cgiparams{'PROTOCOL'} = 'tcp';
$cgiparams{'ENABLED'} = 'on';
$cgiparams{'SRC_NET'} = 'orange';
$cgiparams{'DEST_NET'} = 'blue';
}
$selected{'PROTOCOL'}{'udp'} = '';
$selected{'PROTOCOL'}{'tcp'} = '';
$selected{'PROTOCOL'}{$cgiparams{'PROTOCOL'}} = "selected='selected'";
$selected{'SRC_NET'}{'orange'} = '';
$selected{'SRC_NET'}{'blue'} = '';
$selected{'SRC_NET'}{$cgiparams{'SRC_NET'}} = "selected='selected'";
$selected{'DEST_NET'}{'blue'} = '';
$selected{'DEST_NET'}{'green'} = '';
$selected{'DEST_NET'}{$cgiparams{'DEST_NET'}} = "selected='selected'";
$checked{'ENABLED'}{'off'} = '';
$checked{'ENABLED'}{'on'} = '';
$checked{'ENABLED'}{$cgiparams{'ENABLED'}} = "checked='checked'";
&Header::openpage($Lang::tr{'dmz pinhole configuration'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<class name='base'>$errormessage\n";
print "&nbsp;</class>\n";
&Header::closebox();
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
my $buttonText = $Lang::tr{'add'};
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'}) {
&Header::openbox('100%', 'left', $Lang::tr{'edit a rule'});
$buttonText = $Lang::tr{'update'};
} else {
&Header::openbox('100%', 'left', $Lang::tr{'add a new rule'});
}
print <<END
<table width='100%'>
<tr>
<td>
<select name='PROTOCOL'>
<option value='udp' $selected{'PROTOCOL'}{'udp'}>UDP</option>
<option value='tcp' $selected{'PROTOCOL'}{'tcp'}>TCP</option>
</select>
</td>
<td>
$Lang::tr{'source net'}:</td>
<td>
<select name='SRC_NET'>
END
;
if (&haveOrangeNet()) {
print "<option value='orange' $selected{'SRC_NET'}{'orange'}>$Lang::tr{'orange'}</option>";
}
if (&haveBlueNet()) {
print "<option value='blue' $selected{'SRC_NET'}{'blue'}>$Lang::tr{'blue'}</option>";
}
print <<END
</select>
</td>
<td class='base'>$Lang::tr{'source ip or net'}:</td>
<td><input type='text' name='SRC_IP' value='$cgiparams{'SRC_IP'}' size='15' /></td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
$Lang::tr{'destination net'}:</td>
<td>
<select name='DEST_NET'>
END
;
if (&haveOrangeNet() && &haveBlueNet()) {
print "<option value='blue' $selected{'DEST_NET'}{'blue'}>$Lang::tr{'blue'}</option>";
}
print <<END
<option value='green' $selected{'DEST_NET'}{'green'}>$Lang::tr{'green'}</option>
</select>
</td>
<td class='base'>
$Lang::tr{'destination ip or net'}:</td>
<td>
<input type='text' name='DEST_IP' value='$cgiparams{'DEST_IP'}' size='15' />
</td>
<td class='base'>
$Lang::tr{'destination port'}:&nbsp;
<input type='text' name='DEST_PORT' value='$cgiparams{'DEST_PORT'}' size='5' />
</td>
</tr>
</table>
<table width='100%'>
<tr>
<td colspan='3' width='50%' class='base'>
<font class='boldbase'>$Lang::tr{'remark title'}&nbsp;<img src='/blob.gif' alt='*' /></font>
<input type='text' name='REMARK' value='$cgiparams{'REMARK'}' size='55' maxlength='50' />
</td>
</tr>
<tr>
<td class='base' width='50%'>
<img src='/blob.gif' alt ='*' align='top' />&nbsp;
<font class='base'>$Lang::tr{'this field may be blank'}</font>
</td>
<td class='base' width='25%' align='center'>$Lang::tr{'enabled'}<input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td>
<td width='25%' align='center'>
<input type='hidden' name='ACTION' value='$Lang::tr{'add'}' />
<input type='submit' name='SUBMIT' value='$buttonText' />
</td>
</tr>
</table>
END
;
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'}) {
print "<input type='hidden' name='EDITING' value='$cgiparams{'ID'}' />\n";
} else {
print "<input type='hidden' name='EDITING' value='no' />\n";
}
&Header::closebox();
print "</form>\n";
&Header::openbox('100%', 'left', $Lang::tr{'current rules'});
print <<END
<table width='100%'>
<tr>
<td width='7%' class='boldbase' align='center'><b>$Lang::tr{'proto'}</b></td>
<td width='3%' class='boldbase' align='center'><b>$Lang::tr{'net'}</b></td>
<td width='25%' class='boldbase' align='center'><b>$Lang::tr{'source'}</b></td>
<td width='2%' class='boldbase' align='center'>&nbsp;</td>
<td width='3%' class='boldbase' align='center'><b>$Lang::tr{'net'}</b></td>
<td width='25%' class='boldbase' align='center'><b>$Lang::tr{'destination'}</b></td>
<td width='30%' class='boldbase' align='center'><b>$Lang::tr{'remark'}</b></td>
<td width='1%' class='boldbase' align='center'>&nbsp;</td>
<td width='4%' class='boldbase' colspan='3' align='center'><b>$Lang::tr{'action'}</b></td>
END
;
# Achim Weber: if i add a new rule, this rule is not displayed?!?
# we re-read always config.
# If something has happeened re-read config
#if($cgiparams{'ACTION'} ne '')
#{
open(FILE, $filename) or die 'Unable to open config file.';
@current = <FILE>;
close(FILE);
#}
my $id = 0;
foreach my $line (@current)
{
my $protocol='';
my $gif='';
my $toggle='';
my $gdesc='';
$id++;
chomp($line);
my @temp = split(/\,/,$line);
if ($temp[0] eq 'udp') { $protocol = 'UDP'; } else { $protocol = 'TCP' }
my $srcnetcolor = ($temp[5] eq 'blue')? ${Header::colourblue} : ${Header::colourorange};
my $destnetcolor = ($temp[6] eq 'blue')? ${Header::colourblue} : ${Header::colourgreen};
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'} && $cgiparams{'ID'} eq $id) {
print "<tr bgcolor='${Header::colouryellow}'>\n"; }
elsif ($id % 2) {
print "<tr bgcolor='${Header::table1colour}'>\n"; }
else {
print "<tr bgcolor='${Header::table2colour}'>\n"; }
if ($temp[4] eq 'on') { $gif='on.gif'; $toggle='off'; $gdesc=$Lang::tr{'click to disable'};}
else { $gif = 'off.gif'; $toggle='on'; $gdesc=$Lang::tr{'click to enable'}; }
# Darren Critchley - Get Port Service Name if we can - code borrowed from firewalllog.dat
my $dstprt =$temp[3];
$_=$temp[3];
if (/^\d+$/) {
my $servi = uc(getservbyport($temp[3], lc($temp[0])));
if ($servi ne '' && $temp[3] < 1024) {
$dstprt = "$dstprt($servi)"; }
}
# Darren Critchley - If the line is too long, wrap the port numbers
my $dstaddr = "$temp[2] : $dstprt";
if (length($dstaddr) > 26) {
$dstaddr = "$temp[2] :<br /> $dstprt";
}
print <<END
<td align='center'>$protocol</td>
<td bgcolor='$srcnetcolor'></td>
<td align='center'>$temp[1]</td>
<td align='center'><img src='/images/forward.gif' /></td>
<td bgcolor='$destnetcolor'></td>
<td align='center'>$dstaddr</td>
<td align='center'>$temp[7]</td>
<td align='center'>
<form method='post' name='frma$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' alt='$gdesc' />
<input type='hidden' name='ID' value='$id' />
<input type='hidden' name='ENABLE' value='$toggle' />
<input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
</form>
</td>
<td align='center'>
<form method='post' name='frmb$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' alt='$Lang::tr{'edit'}' />
<input type='hidden' name='ID' value='$id' />
<input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
</form>
</td>
<td align='center'>
<form method='post' name='frmc$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' alt='$Lang::tr{'remove'}' />
<input type='hidden' name='ID' value='$id' />
<input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
</form>
</td>
</tr>
END
;
}
print "</table>\n";
# If the fixed lease file contains entries, print Key to action icons
if ( ! -z "$filename") {
print <<END
<table>
<tr>
<td class='boldbase'>&nbsp; <b>$Lang::tr{'legend'}:</b></td>
<td>&nbsp; <img src='/images/on.gif' alt='$Lang::tr{'click to disable'}' /></td>
<td class='base'>$Lang::tr{'click to disable'}</td>
<td>&nbsp; &nbsp; <img src='/images/off.gif' alt='$Lang::tr{'click to enable'}' /></td>
<td class='base'>$Lang::tr{'click to enable'}</td>
<td>&nbsp; &nbsp; <img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
<td class='base'>$Lang::tr{'edit'}</td>
<td>&nbsp; &nbsp; <img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
<td class='base'>$Lang::tr{'remove'}</td>
</tr>
</table>
END
;
}
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
sub validNet
{
my $srcNet = $_[0];
my $destNet = $_[1];
if ($srcNet eq $destNet) {
return $Lang::tr{'dmzpinholes for same net not necessary'}; }
unless ($srcNet =~ /^(blue|orange)$/) {
return $Lang::tr{'select source net'}; }
unless ($destNet =~ /^(blue|green)$/) {
return $Lang::tr{'select dest net'}; }
return '';
}
sub haveOrangeNet
{
if ($netsettings{'CONFIG_TYPE'} == 1) {return 1;}
if ($netsettings{'CONFIG_TYPE'} == 3) {return 1;}
if ($netsettings{'CONFIG_TYPE'} == 5) {return 1;}
if ($netsettings{'CONFIG_TYPE'} == 7) {return 1;}
return 0;
}
sub haveBlueNet
{
if ($netsettings{'CONFIG_TYPE'} == 4) {return 1;}
if ($netsettings{'CONFIG_TYPE'} == 5) {return 1;}
if ($netsettings{'CONFIG_TYPE'} == 6) {return 1;}
if ($netsettings{'CONFIG_TYPE'} == 7) {return 1;}
return 0;
}
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: dmzholes.cgi,v 1.9.2.16 2005/10/18 17:05:27 franck78 Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::table2colour}, ${Header::colouryellow} );
undef (@dummy);
my %cgiparams=();
my %checked=();
my %selected=();
my %netsettings=();
my $errormessage = '';
my $filename = "${General::swroot}/dmzholes/config";
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
&Header::showhttpheaders();
$cgiparams{'ENABLED'} = 'off';
$cgiparams{'REMARK'} = '';
$cgiparams{'ACTION'} = '';
$cgiparams{'SRC_IP'} = '';
$cgiparams{'DEST_IP'} ='';
$cgiparams{'DEST_PORT'} = '';
&Header::getcgihash(\%cgiparams);
open(FILE, $filename) or die 'Unable to open config file.';
my @current = <FILE>;
close(FILE);
if ($cgiparams{'ACTION'} eq $Lang::tr{'add'})
{
unless($cgiparams{'PROTOCOL'} =~ /^(tcp|udp)$/) { $errormessage = $Lang::tr{'invalid input'}; }
unless(&General::validipormask($cgiparams{'SRC_IP'})) { $errormessage = $Lang::tr{'source ip bad'}; }
unless($errormessage){$errormessage = &General::validportrange($cgiparams{'DEST_PORT'},'dst');}
unless(&General::validipormask($cgiparams{'DEST_IP'})) { $errormessage = $Lang::tr{'destination ip bad'}; }
unless ($errormessage) {
$errormessage = &validNet($cgiparams{'SRC_NET'},$cgiparams{'DEST_NET'}); }
# Darren Critchley - Remove commas from remarks
$cgiparams{'REMARK'} = &Header::cleanhtml($cgiparams{'REMARK'});
unless ($errormessage)
{
if($cgiparams{'EDITING'} eq 'no') {
open(FILE,">>$filename") or die 'Unable to open config file.';
flock FILE, 2;
print FILE "$cgiparams{'PROTOCOL'},"; # [0]
print FILE "$cgiparams{'SRC_IP'},"; # [1]
print FILE "$cgiparams{'DEST_IP'},"; # [2]
print FILE "$cgiparams{'DEST_PORT'},"; # [3]
print FILE "$cgiparams{'ENABLED'},"; # [4]
print FILE "$cgiparams{'SRC_NET'},"; # [5]
print FILE "$cgiparams{'DEST_NET'},"; # [6]
print FILE "$cgiparams{'REMARK'}\n"; # [7]
} else {
open(FILE,">$filename") or die 'Unable to open config file.';
flock FILE, 2;
my $id = 0;
foreach my $line (@current)
{
$id++;
if ($cgiparams{'EDITING'} eq $id) {
print FILE "$cgiparams{'PROTOCOL'},"; # [0]
print FILE "$cgiparams{'SRC_IP'},"; # [1]
print FILE "$cgiparams{'DEST_IP'},"; # [2]
print FILE "$cgiparams{'DEST_PORT'},"; # [3]
print FILE "$cgiparams{'ENABLED'},"; # [4]
print FILE "$cgiparams{'SRC_NET'},"; # [5]
print FILE "$cgiparams{'DEST_NET'},"; # [6]
print FILE "$cgiparams{'REMARK'}\n"; # [7]
} else { print FILE "$line"; }
}
}
close(FILE);
undef %cgiparams;
&General::log($Lang::tr{'dmz pinhole rule added'});
system('/usr/local/bin/setdmzholes');
}
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'remove'})
{
my $id = 0;
open(FILE, ">$filename") or die 'Unable to open config file.';
flock FILE, 2;
foreach my $line (@current)
{
$id++;
unless ($cgiparams{'ID'} eq $id) { print FILE "$line"; }
}
close(FILE);
system('/usr/local/bin/setdmzholes');
&General::log($Lang::tr{'dmz pinhole rule removed'});
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'toggle enable disable'})
{
my $id = 0;
open(FILE, ">$filename") or die 'Unable to open config file.';
flock FILE, 2;
foreach my $line (@current)
{
$id++;
unless ($cgiparams{'ID'} eq $id) { print FILE "$line"; }
else
{
chomp($line);
my @temp = split(/\,/,$line);
print FILE "$temp[0],$temp[1],$temp[2],$temp[3],$cgiparams{'ENABLE'},$temp[5],$temp[6],$temp[7]\n";
}
}
close(FILE);
system('/usr/local/bin/setdmzholes');
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'})
{
my $id = 0;
foreach my $line (@current)
{
$id++;
if ($cgiparams{'ID'} eq $id)
{
chomp($line);
my @temp = split(/\,/,$line);
$cgiparams{'PROTOCOL'} = $temp[0];
$cgiparams{'SRC_IP'} = $temp[1];
$cgiparams{'DEST_IP'} = $temp[2];
$cgiparams{'DEST_PORT'} = $temp[3];
$cgiparams{'ENABLED'} = $temp[4];
$cgiparams{'SRC_NET'} = $temp[5];
$cgiparams{'DEST_NET'} = $temp[6];
$cgiparams{'REMARK'} = $temp[7];
}
}
}
if ($cgiparams{'ACTION'} eq '')
{
$cgiparams{'PROTOCOL'} = 'tcp';
$cgiparams{'ENABLED'} = 'on';
$cgiparams{'SRC_NET'} = 'orange';
$cgiparams{'DEST_NET'} = 'blue';
}
$selected{'PROTOCOL'}{'udp'} = '';
$selected{'PROTOCOL'}{'tcp'} = '';
$selected{'PROTOCOL'}{$cgiparams{'PROTOCOL'}} = "selected='selected'";
$selected{'SRC_NET'}{'orange'} = '';
$selected{'SRC_NET'}{'blue'} = '';
$selected{'SRC_NET'}{$cgiparams{'SRC_NET'}} = "selected='selected'";
$selected{'DEST_NET'}{'blue'} = '';
$selected{'DEST_NET'}{'green'} = '';
$selected{'DEST_NET'}{$cgiparams{'DEST_NET'}} = "selected='selected'";
$checked{'ENABLED'}{'off'} = '';
$checked{'ENABLED'}{'on'} = '';
$checked{'ENABLED'}{$cgiparams{'ENABLED'}} = "checked='checked'";
&Header::openpage($Lang::tr{'dmz pinhole configuration'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<class name='base'>$errormessage\n";
print "&nbsp;</class>\n";
&Header::closebox();
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
my $buttonText = $Lang::tr{'add'};
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'}) {
&Header::openbox('100%', 'left', $Lang::tr{'edit a rule'});
$buttonText = $Lang::tr{'update'};
} else {
&Header::openbox('100%', 'left', $Lang::tr{'add a new rule'});
}
print <<END
<table width='100%'>
<tr>
<td>
<select name='PROTOCOL'>
<option value='udp' $selected{'PROTOCOL'}{'udp'}>UDP</option>
<option value='tcp' $selected{'PROTOCOL'}{'tcp'}>TCP</option>
</select>
</td>
<td>
$Lang::tr{'source net'}:</td>
<td>
<select name='SRC_NET'>
END
;
if (&haveOrangeNet()) {
print "<option value='orange' $selected{'SRC_NET'}{'orange'}>$Lang::tr{'orange'}</option>";
}
if (&haveBlueNet()) {
print "<option value='blue' $selected{'SRC_NET'}{'blue'}>$Lang::tr{'blue'}</option>";
}
print <<END
</select>
</td>
<td class='base'>$Lang::tr{'source ip or net'}:</td>
<td><input type='text' name='SRC_IP' value='$cgiparams{'SRC_IP'}' size='15' /></td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
$Lang::tr{'destination net'}:</td>
<td>
<select name='DEST_NET'>
END
;
if (&haveOrangeNet() && &haveBlueNet()) {
print "<option value='blue' $selected{'DEST_NET'}{'blue'}>$Lang::tr{'blue'}</option>";
}
print <<END
<option value='green' $selected{'DEST_NET'}{'green'}>$Lang::tr{'green'}</option>
</select>
</td>
<td class='base'>
$Lang::tr{'destination ip or net'}:</td>
<td>
<input type='text' name='DEST_IP' value='$cgiparams{'DEST_IP'}' size='15' />
</td>
<td class='base'>
$Lang::tr{'destination port'}:&nbsp;
<input type='text' name='DEST_PORT' value='$cgiparams{'DEST_PORT'}' size='5' />
</td>
</tr>
</table>
<table width='100%'>
<tr>
<td colspan='3' width='50%' class='base'>
<font class='boldbase'>$Lang::tr{'remark title'}&nbsp;<img src='/blob.gif' alt='*' /></font>
<input type='text' name='REMARK' value='$cgiparams{'REMARK'}' size='55' maxlength='50' />
</td>
</tr>
<tr>
<td class='base' width='50%'>
<img src='/blob.gif' alt ='*' align='top' />&nbsp;
<font class='base'>$Lang::tr{'this field may be blank'}</font>
</td>
<td class='base' width='25%' align='center'>$Lang::tr{'enabled'}<input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td>
<td width='25%' align='center'>
<input type='hidden' name='ACTION' value='$Lang::tr{'add'}' />
<input type='submit' name='SUBMIT' value='$buttonText' />
</td>
</tr>
</table>
END
;
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'}) {
print "<input type='hidden' name='EDITING' value='$cgiparams{'ID'}' />\n";
} else {
print "<input type='hidden' name='EDITING' value='no' />\n";
}
&Header::closebox();
print "</form>\n";
&Header::openbox('100%', 'left', $Lang::tr{'current rules'});
print <<END
<table width='100%'>
<tr>
<td width='7%' class='boldbase' align='center'><b>$Lang::tr{'proto'}</b></td>
<td width='3%' class='boldbase' align='center'><b>$Lang::tr{'net'}</b></td>
<td width='25%' class='boldbase' align='center'><b>$Lang::tr{'source'}</b></td>
<td width='2%' class='boldbase' align='center'>&nbsp;</td>
<td width='3%' class='boldbase' align='center'><b>$Lang::tr{'net'}</b></td>
<td width='25%' class='boldbase' align='center'><b>$Lang::tr{'destination'}</b></td>
<td width='30%' class='boldbase' align='center'><b>$Lang::tr{'remark'}</b></td>
<td width='1%' class='boldbase' align='center'>&nbsp;</td>
<td width='4%' class='boldbase' colspan='3' align='center'><b>$Lang::tr{'action'}</b></td>
END
;
# Achim Weber: if i add a new rule, this rule is not displayed?!?
# we re-read always config.
# If something has happeened re-read config
#if($cgiparams{'ACTION'} ne '')
#{
open(FILE, $filename) or die 'Unable to open config file.';
@current = <FILE>;
close(FILE);
#}
my $id = 0;
foreach my $line (@current)
{
my $protocol='';
my $gif='';
my $toggle='';
my $gdesc='';
$id++;
chomp($line);
my @temp = split(/\,/,$line);
if ($temp[0] eq 'udp') { $protocol = 'UDP'; } else { $protocol = 'TCP' }
my $srcnetcolor = ($temp[5] eq 'blue')? ${Header::colourblue} : ${Header::colourorange};
my $destnetcolor = ($temp[6] eq 'blue')? ${Header::colourblue} : ${Header::colourgreen};
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'} && $cgiparams{'ID'} eq $id) {
print "<tr bgcolor='${Header::colouryellow}'>\n"; }
elsif ($id % 2) {
print "<tr bgcolor='${Header::table1colour}'>\n"; }
else {
print "<tr bgcolor='${Header::table2colour}'>\n"; }
if ($temp[4] eq 'on') { $gif='on.gif'; $toggle='off'; $gdesc=$Lang::tr{'click to disable'};}
else { $gif = 'off.gif'; $toggle='on'; $gdesc=$Lang::tr{'click to enable'}; }
# Darren Critchley - Get Port Service Name if we can - code borrowed from firewalllog.dat
my $dstprt =$temp[3];
$_=$temp[3];
if (/^\d+$/) {
my $servi = uc(getservbyport($temp[3], lc($temp[0])));
if ($servi ne '' && $temp[3] < 1024) {
$dstprt = "$dstprt($servi)"; }
}
# Darren Critchley - If the line is too long, wrap the port numbers
my $dstaddr = "$temp[2] : $dstprt";
if (length($dstaddr) > 26) {
$dstaddr = "$temp[2] :<br /> $dstprt";
}
print <<END
<td align='center'>$protocol</td>
<td bgcolor='$srcnetcolor'></td>
<td align='center'>$temp[1]</td>
<td align='center'><img src='/images/forward.gif' /></td>
<td bgcolor='$destnetcolor'></td>
<td align='center'>$dstaddr</td>
<td align='center'>$temp[7]</td>
<td align='center'>
<form method='post' name='frma$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' alt='$gdesc' />
<input type='hidden' name='ID' value='$id' />
<input type='hidden' name='ENABLE' value='$toggle' />
<input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
</form>
</td>
<td align='center'>
<form method='post' name='frmb$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' alt='$Lang::tr{'edit'}' />
<input type='hidden' name='ID' value='$id' />
<input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
</form>
</td>
<td align='center'>
<form method='post' name='frmc$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' alt='$Lang::tr{'remove'}' />
<input type='hidden' name='ID' value='$id' />
<input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
</form>
</td>
</tr>
END
;
}
print "</table>\n";
# If the fixed lease file contains entries, print Key to action icons
if ( ! -z "$filename") {
print <<END
<table>
<tr>
<td class='boldbase'>&nbsp; <b>$Lang::tr{'legend'}:</b></td>
<td>&nbsp; <img src='/images/on.gif' alt='$Lang::tr{'click to disable'}' /></td>
<td class='base'>$Lang::tr{'click to disable'}</td>
<td>&nbsp; &nbsp; <img src='/images/off.gif' alt='$Lang::tr{'click to enable'}' /></td>
<td class='base'>$Lang::tr{'click to enable'}</td>
<td>&nbsp; &nbsp; <img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
<td class='base'>$Lang::tr{'edit'}</td>
<td>&nbsp; &nbsp; <img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
<td class='base'>$Lang::tr{'remove'}</td>
</tr>
</table>
END
;
}
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
sub validNet
{
my $srcNet = $_[0];
my $destNet = $_[1];
if ($srcNet eq $destNet) {
return $Lang::tr{'dmzpinholes for same net not necessary'}; }
unless ($srcNet =~ /^(blue|orange)$/) {
return $Lang::tr{'select source net'}; }
unless ($destNet =~ /^(blue|green)$/) {
return $Lang::tr{'select dest net'}; }
return '';
}
sub haveOrangeNet
{
if ($netsettings{'CONFIG_TYPE'} == 1) {return 1;}
if ($netsettings{'CONFIG_TYPE'} == 3) {return 1;}
if ($netsettings{'CONFIG_TYPE'} == 5) {return 1;}
if ($netsettings{'CONFIG_TYPE'} == 7) {return 1;}
return 0;
}
sub haveBlueNet
{
if ($netsettings{'CONFIG_TYPE'} == 4) {return 1;}
if ($netsettings{'CONFIG_TYPE'} == 5) {return 1;}
if ($netsettings{'CONFIG_TYPE'} == 6) {return 1;}
if ($netsettings{'CONFIG_TYPE'} == 7) {return 1;}
return 0;
}

View File

@@ -1,148 +1,148 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: graphs.cgi,v 1.9.2.6 2005/02/22 22:21:55 gespinasse Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %cgiparams=();
my %pppsettings=();
my %netsettings=();
my @cgigraphs=();
my @graphs=();
my $iface='';
&Header::showhttpheaders();
my $graphdir = "/home/httpd/html/graphs";
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
$ENV{'QUERY_STRING'} =~ s/&//g;
@cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'});
$cgigraphs[1] = '' unless defined $cgigraphs[1];
if ($cgigraphs[1] =~ /(network|GREEN|BLUE|ORANGE|RED)/) {
&Header::openpage($Lang::tr{'network traffic graphs'}, 1, '');
} else {
&Header::openpage($Lang::tr{'system graphs'}, 1, '');
}
&Header::openbigbox('100%', 'left');
if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|cpu|memory|swap|disk)/) {
my $graph = $cgigraphs[1];
my $graphname = ucfirst(lc($cgigraphs[1]));
&Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
if (-e "$graphdir/${graph}-day.png") {
my $ftime = localtime((stat("$graphdir/${graph}-day.png"))[9]);
print "<center>";
print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br /><hr />\n";
print "<img src='/graphs/${graph}-day.png' border='0' /><hr />";
print "<img src='/graphs/${graph}-week.png' border='0' /><hr />";
print "<img src='/graphs/${graph}-month.png' border='0' /><hr />";
print "<img src='/graphs/${graph}-year.png' border='0' />";
} else {
print $Lang::tr{'no information available'};
}
&Header::closebox();
print "<div align='center'><table width='80%'><tr><td align='center'>";
if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED)/) {
print "<a href='/cgi-bin/graphs.cgi?graph=network'>";
} else {
print "<a href='/cgi-bin/graphs.cgi'>";
}
print "$Lang::tr{'back'}</a></td></tr></table></div>\n";
;
} elsif ($cgigraphs[1] =~ /network/) {
push (@graphs, ('GREEN'));
if ($netsettings{'BLUE_DEV'}) {
push (@graphs, ('BLUE')); }
if ($netsettings{'ORANGE_DEV'}) {
push (@graphs, ('ORANGE')); }
push (@graphs, ("RED"));
foreach my $graphname (@graphs) {
&Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
if (-e "$graphdir/${graphname}-day.png") {
my $ftime = localtime((stat("$graphdir/${graphname}-day.png"))[9]);
print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";
print "<img src='/graphs/${graphname}-day.png' border='0' />";
print "</a>";
} else {
print $Lang::tr{'no information available'};
}
print "<br />\n";
&Header::closebox();
}
} else {
&Header::openbox('100%', 'center', "CPU $Lang::tr{'graph'}");
if (-e "$graphdir/cpu-day.png") {
my $ftime = localtime((stat("$graphdir/cpu-day.png"))[9]);
print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
print "<a href='/cgi-bin/graphs.cgi?graph=cpu'>";
print "<img src='/graphs/cpu-day.png' border='0' />";
print "</a>";
} else {
print $Lang::tr{'no information available'};
}
print "<br />\n";
&Header::closebox();
&Header::openbox('100%', 'center', "Memory $Lang::tr{'graph'}");
if (-e "$graphdir/memory-day.png") {
my $ftime = localtime((stat("$graphdir/memory-day.png"))[9]);
print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
print "<a href='/cgi-bin/graphs.cgi?graph=memory'>";
print "<img src='/graphs/memory-day.png' border='0' />";
print "</a>";
} else {
print $Lang::tr{'no information available'};
}
print "<br />\n";
&Header::closebox();
&Header::openbox('100%', 'center', "Swap $Lang::tr{'graph'}");
if (-e "$graphdir/swap-day.png") {
my $ftime = localtime((stat("$graphdir/swap-day.png"))[9]);
print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
print "<a href='/cgi-bin/graphs.cgi?graph=swap'>";
print "<img src='/graphs/swap-day.png' border='0' />";
print "</a>";
} else {
print $Lang::tr{'no information available'};
}
print "<br />\n";
&Header::closebox();
&Header::openbox('100%', 'center', "Disk $Lang::tr{'graph'}");
if (-e "$graphdir/disk-day.png") {
my $ftime = localtime((stat("$graphdir/disk-day.png"))[9]);
print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
print "<a href='/cgi-bin/graphs.cgi?graph=disk'>";
print "<img src='/graphs/disk-day.png' border='0' />";
print "</a>";
} else {
print $Lang::tr{'no information available'};
}
print "<br />\n";
&Header::closebox();
}
&Header::closebigbox();
&Header::closepage();
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: graphs.cgi,v 1.9.2.6 2005/02/22 22:21:55 gespinasse Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %cgiparams=();
my %pppsettings=();
my %netsettings=();
my @cgigraphs=();
my @graphs=();
my $iface='';
&Header::showhttpheaders();
my $graphdir = "/home/httpd/html/graphs";
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
$ENV{'QUERY_STRING'} =~ s/&//g;
@cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'});
$cgigraphs[1] = '' unless defined $cgigraphs[1];
if ($cgigraphs[1] =~ /(network|GREEN|BLUE|ORANGE|RED)/) {
&Header::openpage($Lang::tr{'network traffic graphs'}, 1, '');
} else {
&Header::openpage($Lang::tr{'system graphs'}, 1, '');
}
&Header::openbigbox('100%', 'left');
if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|cpu|memory|swap|disk)/) {
my $graph = $cgigraphs[1];
my $graphname = ucfirst(lc($cgigraphs[1]));
&Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
if (-e "$graphdir/${graph}-day.png") {
my $ftime = localtime((stat("$graphdir/${graph}-day.png"))[9]);
print "<center>";
print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br /><hr />\n";
print "<img src='/graphs/${graph}-day.png' border='0' /><hr />";
print "<img src='/graphs/${graph}-week.png' border='0' /><hr />";
print "<img src='/graphs/${graph}-month.png' border='0' /><hr />";
print "<img src='/graphs/${graph}-year.png' border='0' />";
} else {
print $Lang::tr{'no information available'};
}
&Header::closebox();
print "<div align='center'><table width='80%'><tr><td align='center'>";
if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED)/) {
print "<a href='/cgi-bin/graphs.cgi?graph=network'>";
} else {
print "<a href='/cgi-bin/graphs.cgi'>";
}
print "$Lang::tr{'back'}</a></td></tr></table></div>\n";
;
} elsif ($cgigraphs[1] =~ /network/) {
push (@graphs, ('GREEN'));
if ($netsettings{'BLUE_DEV'}) {
push (@graphs, ('BLUE')); }
if ($netsettings{'ORANGE_DEV'}) {
push (@graphs, ('ORANGE')); }
push (@graphs, ("RED"));
foreach my $graphname (@graphs) {
&Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
if (-e "$graphdir/${graphname}-day.png") {
my $ftime = localtime((stat("$graphdir/${graphname}-day.png"))[9]);
print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";
print "<img src='/graphs/${graphname}-day.png' border='0' />";
print "</a>";
} else {
print $Lang::tr{'no information available'};
}
print "<br />\n";
&Header::closebox();
}
} else {
&Header::openbox('100%', 'center', "CPU $Lang::tr{'graph'}");
if (-e "$graphdir/cpu-day.png") {
my $ftime = localtime((stat("$graphdir/cpu-day.png"))[9]);
print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
print "<a href='/cgi-bin/graphs.cgi?graph=cpu'>";
print "<img src='/graphs/cpu-day.png' border='0' />";
print "</a>";
} else {
print $Lang::tr{'no information available'};
}
print "<br />\n";
&Header::closebox();
&Header::openbox('100%', 'center', "Memory $Lang::tr{'graph'}");
if (-e "$graphdir/memory-day.png") {
my $ftime = localtime((stat("$graphdir/memory-day.png"))[9]);
print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
print "<a href='/cgi-bin/graphs.cgi?graph=memory'>";
print "<img src='/graphs/memory-day.png' border='0' />";
print "</a>";
} else {
print $Lang::tr{'no information available'};
}
print "<br />\n";
&Header::closebox();
&Header::openbox('100%', 'center', "Swap $Lang::tr{'graph'}");
if (-e "$graphdir/swap-day.png") {
my $ftime = localtime((stat("$graphdir/swap-day.png"))[9]);
print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
print "<a href='/cgi-bin/graphs.cgi?graph=swap'>";
print "<img src='/graphs/swap-day.png' border='0' />";
print "</a>";
} else {
print $Lang::tr{'no information available'};
}
print "<br />\n";
&Header::closebox();
&Header::openbox('100%', 'center', "Disk $Lang::tr{'graph'}");
if (-e "$graphdir/disk-day.png") {
my $ftime = localtime((stat("$graphdir/disk-day.png"))[9]);
print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
print "<a href='/cgi-bin/graphs.cgi?graph=disk'>";
print "<img src='/graphs/disk-day.png' border='0' />";
print "</a>";
} else {
print $Lang::tr{'no information available'};
}
print "<br />\n";
&Header::closebox();
}
&Header::closebigbox();
&Header::closepage();

View File

@@ -1,229 +1,229 @@
#!/usr/bin/perl
#
# IPCop CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) Bill Ward
#
# $Id: gui.cgi,v 1.2.2.17 2005/07/06 09:21:22 franck78 Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %cgiparams=();
my %mainsettings=();
my %checked=();
my $errormessage='';
$cgiparams{'JAVASCRIPT'} = 'off';
$cgiparams{'WINDOWWITHHOSTNAME'} = 'off';
$cgiparams{'REFRESHINDEX'} = 'off';
$cgiparams{'ACTION'} = '';
&Header::getcgihash(\%cgiparams);
&Header::showhttpheaders();
&General::readhash("${General::swroot}/main/settings",\%mainsettings);
if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}")
{
open(FILE,"${General::swroot}/langs/list");
my $found=0;
while (<FILE>)
{
my $lang='';
my $engname='';
my $natname='';
chomp;
($lang,$engname,$natname) = split (/:/, $_,3);
if ($cgiparams{'lang'} eq $lang)
{
$found=1;
}
}
close (FILE);
if ( $found == 0 )
{
$errormessage="$errormessage<P>$Lang::tr{'invalid input'}";
goto SAVE_ERROR;
}
if ($cgiparams{'JAVASCRIPT'} !~ /^(on|off)$/) {
$errormessage = $Lang::tr{'invalid input'};
goto SAVE_ERROR;
}
# Set flag if index page is to refresh whilst ppp is up.
# Default is NO refresh.
if ($cgiparams{'REFRESHINDEX'} ne 'off') {
system ('/bin/touch', "${General::swroot}/main/refreshindex");
} else {
unlink "${General::swroot}/main/refreshindex";
}
# Beep on ip-up or ip-down. Default is ON.
if ($cgiparams{'PPPUPDOWNBEEP'} ne 'on') {
$cgiparams{'PPPUPDOWNBEEP'} = 'off';
system ('/bin/touch', "${General::swroot}/ppp/nobeeps");
} else {
unlink "${General::swroot}/ppp/nobeeps";
}
# write cgi vars to the file.
$mainsettings{'LANGUAGE'} = $cgiparams{'lang'};
$mainsettings{'JAVASCRIPT'} = $cgiparams{'JAVASCRIPT'};
$mainsettings{'WINDOWWITHHOSTNAME'} = $cgiparams{'WINDOWWITHHOSTNAME'};
$mainsettings{'PPPUPDOWNBEEP'} = $cgiparams{'PPPUPDOWNBEEP'};
$mainsettings{'REFRESHINDEX'} = $cgiparams{'REFRESHINDEX'};
&General::writehash("${General::swroot}/main/settings", \%mainsettings);
&Lang::reload($cgiparams{'lang'});
SAVE_ERROR:
} else {
if ($mainsettings{'JAVASCRIPT'}) {
$cgiparams{'JAVASCRIPT'} = $mainsettings{'JAVASCRIPT'};
} else {
$cgiparams{'JAVASCRIPT'} = 'on';
}
if ($mainsettings{'WINDOWWITHHOSTNAME'}) {
$cgiparams{'WINDOWWITHHOSTNAME'} = $mainsettings{'WINDOWWITHHOSTNAME'};
} else {
$cgiparams{'WINDOWWITHHOSTNAME'} = 'off';
}
if ($mainsettings{'PPPUPDOWNBEEP'}) {
$cgiparams{'PPPUPDOWNBEEP'} = $mainsettings{'PPPUPDOWNBEEP'};
} else {
$cgiparams{'PPPUPDOWNBEEP'} = 'on';
}
if($mainsettings{'REFRESHINDEX'}) {
$cgiparams{'REFRESHINDEX'} = $mainsettings{'REFRESHINDEX'};
} else {
$cgiparams{'REFRESHINDEX'} = 'off';
}
}
# Default settings
if ($cgiparams{'ACTION'} eq "$Lang::tr{'restore defaults'}")
{
$cgiparams{'JAVASCRIPT'} = 'on';
$cgiparams{'WINDOWWITHHOSTNAME'} = 'off';
$cgiparams{'PPPUPDOWNBEEP'} = 'on';
$cgiparams{'REFRESHINDEX'} = 'off';
}
$checked{'JAVASCRIPT'}{'off'} = '';
$checked{'JAVASCRIPT'}{'on'} = '';
$checked{'JAVASCRIPT'}{$cgiparams{'JAVASCRIPT'}} = "checked='checked'";
$checked{'WINDOWWITHHOSTNAME'}{'off'} = '';
$checked{'WINDOWWITHHOSTNAME'}{'on'} = '';
$checked{'WINDOWWITHHOSTNAME'}{$cgiparams{'WINDOWWITHHOSTNAME'}} = "checked='checked'";
$checked{'PPPUPDOWNBEEP'}{'off'} = '';
$checked{'PPPUPDOWNBEEP'}{'on'} = '';
$checked{'PPPUPDOWNBEEP'}{$cgiparams{'PPPUPDOWNBEEP'}} = "checked='checked'";
$checked{'REFRESHINDEX'}{'off'} = '';
$checked{'REFRESHINDEX'}{'on'} = '';
$checked{'REFRESHINDEX'}{$cgiparams{'REFRESHINDEX'}} = "checked='checked'";
&Header::openpage($Lang::tr{'gui settings'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%','left',$Lang::tr{'error messages'});
print "<font class='base'>${errormessage}&nbsp;</font>\n";
&Header::closebox();
}
&Header::openbox('100%','left',$Lang::tr{'gui settings'});
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<table width='100%'>
<tr>
<td colspan='2'><p><b>$Lang::tr{'display'}</b></td>
</tr>
<tr>
<td><input type='checkbox' name='JAVASCRIPT' $checked{'JAVASCRIPT'}{'on'} />
<td width='100%'>$Lang::tr{'enable javascript'}</td>
</tr>
<tr>
<td><input type='checkbox' name='WINDOWWITHHOSTNAME' $checked{'WINDOWWITHHOSTNAME'}{'on'} /></td>
<td>$Lang::tr{'display hostname in window title'}</td>
</tr>
<tr>
<td><input type='checkbox' name='REFRESHINDEX' $checked{'REFRESHINDEX'}{'on'} /></td>
<td>$Lang::tr{'refresh index page while connected'}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>$Lang::tr{'languagepurpose'}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><select name='lang'>
END
;
my $id=0;
open(FILE,"${General::swroot}/langs/list");
while (<FILE>)
{
my $lang='';
my $engname='';
my $natname='';
$id++;
chomp;
($lang,$engname,$natname) = split (/:/, $_, 3);
print "<option value='$lang' ";
if ($lang =~ /$mainsettings{'LANGUAGE'}/)
{
print " selected='selected'";
}
print <<END
>$engname ($natname)</option>
END
;
}
print <<END
</select></td></tr>
<tr>
<td colspan='2'><hr /><p><b>$Lang::tr{'sound'}</b></td>
</tr>
<tr>
<td><input type ='checkbox' name='PPPUPDOWNBEEP' $checked{'PPPUPDOWNBEEP'}{'on'} /></td>
<td>$Lang::tr{'beep when ppp connects or disconnects'}</td>
</tr>
<tr>
<td colspan='2'><hr /></td>
</tr>
</table>
<div align='center'>
<table width='80%'>
<tr>
<td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'restore defaults'}' /></td>
<td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
</tr>
</table>
</div>
</form>
END
;
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
#!/usr/bin/perl
#
# IPCop CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) Bill Ward
#
# $Id: gui.cgi,v 1.2.2.17 2005/07/06 09:21:22 franck78 Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %cgiparams=();
my %mainsettings=();
my %checked=();
my $errormessage='';
$cgiparams{'JAVASCRIPT'} = 'off';
$cgiparams{'WINDOWWITHHOSTNAME'} = 'off';
$cgiparams{'REFRESHINDEX'} = 'off';
$cgiparams{'ACTION'} = '';
&Header::getcgihash(\%cgiparams);
&Header::showhttpheaders();
&General::readhash("${General::swroot}/main/settings",\%mainsettings);
if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}")
{
open(FILE,"${General::swroot}/langs/list");
my $found=0;
while (<FILE>)
{
my $lang='';
my $engname='';
my $natname='';
chomp;
($lang,$engname,$natname) = split (/:/, $_,3);
if ($cgiparams{'lang'} eq $lang)
{
$found=1;
}
}
close (FILE);
if ( $found == 0 )
{
$errormessage="$errormessage<P>$Lang::tr{'invalid input'}";
goto SAVE_ERROR;
}
if ($cgiparams{'JAVASCRIPT'} !~ /^(on|off)$/) {
$errormessage = $Lang::tr{'invalid input'};
goto SAVE_ERROR;
}
# Set flag if index page is to refresh whilst ppp is up.
# Default is NO refresh.
if ($cgiparams{'REFRESHINDEX'} ne 'off') {
system ('/bin/touch', "${General::swroot}/main/refreshindex");
} else {
unlink "${General::swroot}/main/refreshindex";
}
# Beep on ip-up or ip-down. Default is ON.
if ($cgiparams{'PPPUPDOWNBEEP'} ne 'on') {
$cgiparams{'PPPUPDOWNBEEP'} = 'off';
system ('/bin/touch', "${General::swroot}/ppp/nobeeps");
} else {
unlink "${General::swroot}/ppp/nobeeps";
}
# write cgi vars to the file.
$mainsettings{'LANGUAGE'} = $cgiparams{'lang'};
$mainsettings{'JAVASCRIPT'} = $cgiparams{'JAVASCRIPT'};
$mainsettings{'WINDOWWITHHOSTNAME'} = $cgiparams{'WINDOWWITHHOSTNAME'};
$mainsettings{'PPPUPDOWNBEEP'} = $cgiparams{'PPPUPDOWNBEEP'};
$mainsettings{'REFRESHINDEX'} = $cgiparams{'REFRESHINDEX'};
&General::writehash("${General::swroot}/main/settings", \%mainsettings);
&Lang::reload($cgiparams{'lang'});
SAVE_ERROR:
} else {
if ($mainsettings{'JAVASCRIPT'}) {
$cgiparams{'JAVASCRIPT'} = $mainsettings{'JAVASCRIPT'};
} else {
$cgiparams{'JAVASCRIPT'} = 'on';
}
if ($mainsettings{'WINDOWWITHHOSTNAME'}) {
$cgiparams{'WINDOWWITHHOSTNAME'} = $mainsettings{'WINDOWWITHHOSTNAME'};
} else {
$cgiparams{'WINDOWWITHHOSTNAME'} = 'off';
}
if ($mainsettings{'PPPUPDOWNBEEP'}) {
$cgiparams{'PPPUPDOWNBEEP'} = $mainsettings{'PPPUPDOWNBEEP'};
} else {
$cgiparams{'PPPUPDOWNBEEP'} = 'on';
}
if($mainsettings{'REFRESHINDEX'}) {
$cgiparams{'REFRESHINDEX'} = $mainsettings{'REFRESHINDEX'};
} else {
$cgiparams{'REFRESHINDEX'} = 'off';
}
}
# Default settings
if ($cgiparams{'ACTION'} eq "$Lang::tr{'restore defaults'}")
{
$cgiparams{'JAVASCRIPT'} = 'on';
$cgiparams{'WINDOWWITHHOSTNAME'} = 'off';
$cgiparams{'PPPUPDOWNBEEP'} = 'on';
$cgiparams{'REFRESHINDEX'} = 'off';
}
$checked{'JAVASCRIPT'}{'off'} = '';
$checked{'JAVASCRIPT'}{'on'} = '';
$checked{'JAVASCRIPT'}{$cgiparams{'JAVASCRIPT'}} = "checked='checked'";
$checked{'WINDOWWITHHOSTNAME'}{'off'} = '';
$checked{'WINDOWWITHHOSTNAME'}{'on'} = '';
$checked{'WINDOWWITHHOSTNAME'}{$cgiparams{'WINDOWWITHHOSTNAME'}} = "checked='checked'";
$checked{'PPPUPDOWNBEEP'}{'off'} = '';
$checked{'PPPUPDOWNBEEP'}{'on'} = '';
$checked{'PPPUPDOWNBEEP'}{$cgiparams{'PPPUPDOWNBEEP'}} = "checked='checked'";
$checked{'REFRESHINDEX'}{'off'} = '';
$checked{'REFRESHINDEX'}{'on'} = '';
$checked{'REFRESHINDEX'}{$cgiparams{'REFRESHINDEX'}} = "checked='checked'";
&Header::openpage($Lang::tr{'gui settings'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%','left',$Lang::tr{'error messages'});
print "<font class='base'>${errormessage}&nbsp;</font>\n";
&Header::closebox();
}
&Header::openbox('100%','left',$Lang::tr{'gui settings'});
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<table width='100%'>
<tr>
<td colspan='2'><p><b>$Lang::tr{'display'}</b></td>
</tr>
<tr>
<td><input type='checkbox' name='JAVASCRIPT' $checked{'JAVASCRIPT'}{'on'} />
<td width='100%'>$Lang::tr{'enable javascript'}</td>
</tr>
<tr>
<td><input type='checkbox' name='WINDOWWITHHOSTNAME' $checked{'WINDOWWITHHOSTNAME'}{'on'} /></td>
<td>$Lang::tr{'display hostname in window title'}</td>
</tr>
<tr>
<td><input type='checkbox' name='REFRESHINDEX' $checked{'REFRESHINDEX'}{'on'} /></td>
<td>$Lang::tr{'refresh index page while connected'}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>$Lang::tr{'languagepurpose'}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><select name='lang'>
END
;
my $id=0;
open(FILE,"${General::swroot}/langs/list");
while (<FILE>)
{
my $lang='';
my $engname='';
my $natname='';
$id++;
chomp;
($lang,$engname,$natname) = split (/:/, $_, 3);
print "<option value='$lang' ";
if ($lang =~ /$mainsettings{'LANGUAGE'}/)
{
print " selected='selected'";
}
print <<END
>$engname ($natname)</option>
END
;
}
print <<END
</select></td></tr>
<tr>
<td colspan='2'><hr /><p><b>$Lang::tr{'sound'}</b></td>
</tr>
<tr>
<td><input type ='checkbox' name='PPPUPDOWNBEEP' $checked{'PPPUPDOWNBEEP'}{'on'} /></td>
<td>$Lang::tr{'beep when ppp connects or disconnects'}</td>
</tr>
<tr>
<td colspan='2'><hr /></td>
</tr>
</table>
<div align='center'>
<table width='80%'>
<tr>
<td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'restore defaults'}' /></td>
<td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
</tr>
</table>
</div>
</form>
END
;
&Header::closebox();
&Header::closebigbox();
&Header::closepage();

View File

@@ -1,449 +1,449 @@
#!/usr/bin/perl
#
# IPCop CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) Alan Hourihane <alanh@fairlite.demon.co.uk>
#
# $Id: hosts.cgi,v 1.4.2.20 2005/11/05 15:46:25 gespinasse Exp $
#
# Franck
# use dhcp.cgi model to rewrite this code
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::colouryellow} );
undef (@dummy);
# Files used
my $setting = "${General::swroot}/main/settings";
our $datafile = "${General::swroot}/main/hosts"; #(our: used in subroutine)
our %settings = ();
#Settings1
# removed
#Settings2 for editing the multi-line list
#Must not be saved !
$settings{'EN'} = ''; # reuse for dummy field in position zero
$settings{'IP'} = '';
$settings{'HOST'} = '';
$settings{'DOM'} = '';
my @nosaved=('EN','IP','HOST','DOM'); # List here ALL setting2 fields. Mandatory
$settings{'ACTION'} = ''; # add/edit/remove
$settings{'KEY1'} = ''; # point record for ACTION
#Define each field that can be used to sort columns
my $sortstring='^IP|^HOST|^DOM';
$settings{'SORT_HOSTSLIST'} = 'HOST';
my $errormessage = '';
my $warnmessage = '';
&Header::showhttpheaders();
#Get GUI values
&Header::getcgihash(\%settings);
# Load multiline data
our @current = ();
if (open(FILE, "$datafile")) {
@current = <FILE>;
close (FILE);
}
## Settings1 Box not used...
&General::readhash("${General::swroot}/main/settings", \%settings);
## Now manipulate the multi-line list with Settings2
# Basic actions are:
# toggle the check box
# add/update a new line
# begin editing a line
# remove a line
# Toggle enable/disable field. Field is in second position
if ($settings{'ACTION'} eq $Lang::tr{'toggle enable disable'}) {
#move out new line
chomp(@current[$settings{'KEY1'}]);
my @temp = split(/\,/,@current[$settings{'KEY1'}]);
$temp[0] = $temp[0] ne '' ? '' : 'on'; # Toggle the field
@current[$settings{'KEY1'}] = join (',',@temp)."\n";
$settings{'KEY1'} = ''; # End edit mode
&General::log($Lang::tr{'hosts config changed'});
#Save current
open(FILE, ">$datafile") or die 'hosts datafile error';
print FILE @current;
close(FILE);
# Rebuild configuration file
&BuildConfiguration;
}
if ($settings{'ACTION'} eq $Lang::tr{'add'}) {
# Validate inputs
unless(&General::validip($settings{'IP'})) {
$errormessage = $Lang::tr{'invalid fixed ip address'};
}
unless(&General::validhostname($settings{'HOST'})) {
$errormessage = $Lang::tr{'invalid hostname'};
}
if ($settings{'DOM'} && ! &General::validdomainname($settings{'DOM'})) {
$errormessage = $Lang::tr{'invalid domain name'};
}
unless ($errormessage) {
if ($settings{'KEY1'} eq '') { #add or edit ?
unshift (@current, "$settings{'EN'},$settings{'IP'},$settings{'HOST'},$settings{'DOM'}\n");
&General::log($Lang::tr{'hosts config added'});
} else {
@current[$settings{'KEY1'}] = "$settings{'EN'},$settings{'IP'},$settings{'HOST'},$settings{'DOM'}\n";
$settings{'KEY1'} = ''; # End edit mode
&General::log($Lang::tr{'hosts config changed'});
}
# Write changes to config file.
&SortDataFile; # sort newly added/modified entry
&BuildConfiguration; # then re-build new host
#map ($settings{$_}='' ,@nosaved); # Clear fields
}
}
if ($settings{'ACTION'} eq $Lang::tr{'edit'}) {
#move out new line
my $line = @current[$settings{'KEY1'}]; # KEY1 is the index in current
chomp($line);
my @temp = split(/\,/, $line);
$settings{'EN'}=$temp[0]; # Prepare the screen for editing
$settings{'IP'}=$temp[1];
$settings{'HOST'}=$temp[2];
$settings{'DOM'}=$temp[3];
}
if ($settings{'ACTION'} eq $Lang::tr{'remove'}) {
splice (@current,$settings{'KEY1'},1); # Delete line
open(FILE, ">$datafile") or die 'hosts datafile error';
print FILE @current;
close(FILE);
$settings{'KEY1'} = ''; # End remove mode
&General::log($Lang::tr{'hosts config changed'});
&BuildConfiguration; # then re-build conf which use new data
}
## Check if sorting is asked
# If same column clicked, reverse the sort.
if ($ENV{'QUERY_STRING'} =~ /$sortstring/ ) {
my $newsort=$ENV{'QUERY_STRING'};
my $actual=$settings{'SORT_HOSTSLIST'};
#Reverse actual sort ?
if ($actual =~ $newsort) {
my $Rev='';
if ($actual !~ 'Rev') {
$Rev='Rev';
}
$newsort.=$Rev;
}
$settings{'SORT_HOSTSLIST'}=$newsort;
map (delete ($settings{$_}) ,(@nosaved,'ACTION','KEY1'));# Must never be saved
&General::writehash($setting, \%settings);
&SortDataFile;
$settings{'ACTION'} = 'SORT'; # Create an 'ACTION'
map ($settings{$_} = '' ,@nosaved,'KEY1'); # and reinit vars to empty
}
if ($settings{'ACTION'} eq '' ) { # First launch from GUI
# Place here default value when nothing is initialized
$settings{'EN'} = 'on';
$settings{'DOM'} = $settings{'DOMAINNAME'};
}
&Header::openpage($Lang::tr{'hostname'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
my %checked=(); # Checkbox manipulations
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>";
&Header::closebox();
}
#
# Remove if no Setting1 needed
#
#if ($warnmessage) {
# $warnmessage = "<font color=${Header::colourred}><b>$Lang::tr{'capswarning'}</b></font>: $warnmessage";
#}
#&Header::openbox('100%', 'left', $Lang::tr{'settings'});
#print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>";
#print <<END
#<table width='100%'>
#<tr>
# <td class='base'>$Lang::tr{'domain name'} : $settings{'DOMAINNAME'}</td>
#</table>
#
#END
#;
#
#print <<END
#<table width='100%'>
#<hr />
#<tr>
# <td class='base' width='25%'><!--<img src='/blob.gif' align='top' alt='*' />&nbsp;$Lang::tr{'this field may be blank'}</td>-->
# <td class='base' width='25%'>$warnmessage</td>
# <td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' disabled='disabled' /></td>
#</tr>
#</table>
#</form>
#END
#;
#&Header::closebox(); # end of Settings1
#
# Second check box is for editing the list
#
$checked{'EN'}{'on'} = ($settings{'EN'} eq '' ) ? '' : "checked='checked'";
my $buttontext = $Lang::tr{'add'};
if ($settings{'KEY1'} ne '') {
$buttontext = $Lang::tr{'update'};
&Header::openbox('100%', 'left', $Lang::tr{'edit an existing host'});
} else {
&Header::openbox('100%', 'left', $Lang::tr{'add a host'});
}
#Edited line number (KEY1) passed until cleared by 'save' or 'remove' or 'new sort order'
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='KEY1' value='$settings{'KEY1'}' />
<table width='100%'>
<tr>
<td class='base'>$Lang::tr{'host ip'}:&nbsp;</td>
<td><input type='text' name='IP' value='$settings{'IP'}' /></td>
<td class='base'>$Lang::tr{'hostname'}:</td>
<td><input type='text' name='HOST' value='$settings{'HOST'}' /></td>
</tr><tr>
<td class='base'>$Lang::tr{'domain name'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
<td><input type='text' name='DOM' value='$settings{'DOM'}' /></td>
<td class='base'>$Lang::tr{'enabled'}</td>
<td><input type='checkbox' name='EN' $checked{'EN'}{'on'} /></td>
</tr>
</table>
<hr />
<table width='100%'>
<tr>
<td class='base' width='50%'><img src='/blob.gif' align='top' alt='*' />&nbsp;$Lang::tr{'this field may be blank'}</td>
<td width='50%' align='center'><input type='hidden' name='ACTION' value='$Lang::tr{'add'}' /><input type='submit' name='SUBMIT' value='$buttontext' /></td>
</tr>
</table>
</form>
END
;
&Header::closebox();
#
# Third box shows the list, in columns
#
# Columns headers may content a link. In this case it must be named in $sortstring
#
&Header::openbox('100%', 'left', $Lang::tr{'current hosts'});
print <<END
<table width='100%'>
<tr>
<td width='20%' align='center'><a href='$ENV{'SCRIPT_NAME'}?IP'><b>$Lang::tr{'host ip'}</b></a></td>
<td width='20%' align='center'><a href='$ENV{'SCRIPT_NAME'}?HOST'><b>$Lang::tr{'hostname'}</b></a></td>
<td width='50%' align='center'><a href='$ENV{'SCRIPT_NAME'}?DOM'><b>$Lang::tr{'domain name'}</b></a></td>
<td width='10%' colspan='3' class='boldbase' align='center'><b>$Lang::tr{'action'}</b></td>
</tr>
END
;
#
# Print each line of @current list
#
my $key = 0;
foreach my $line (@current) {
chomp($line); # remove newline
my @temp=split(/\,/,$line);
$temp[3] ='' unless defined $temp[3]; # not always populated
#Choose icon for checkbox
my $gif = '';
my $gdesc = '';
if ($temp[0] ne '' ) {
$gif = 'on.gif';
$gdesc = $Lang::tr{'click to disable'};
} else {
$gif = 'off.gif';
$gdesc = $Lang::tr{'click to enable'};
}
#Colorize each line
if ($settings{'KEY1'} eq $key) {
print "<tr bgcolor='${Header::colouryellow}'>";
} elsif ($key % 2) {
print "<tr bgcolor='${Header::table2colour}'>";
} else {
print "<tr bgcolor='${Header::table1colour}'>";
}
print <<END
<td align='center'>$temp[1]</td>
<td align='center'>$temp[2]</td>
<td align='center'>$temp[3]</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
<input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' alt='$gdesc' title='$gdesc' />
<input type='hidden' name='KEY1' value='$key' />
</form>
</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
<input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
<input type='hidden' name='KEY1' value='$key' />
</form>
</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
<input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' alt='$Lang::tr{'remove'}' title='$Lang::tr{'remove'}' />
<input type='hidden' name='KEY1' value='$key' />
</form>
</td>
</tr>
END
;
$key++;
}
print "</table>";
# If table contains entries, print 'Key to action icons'
if ($key) {
print <<END
<table>
<tr>
<td class='boldbase'>&nbsp;<b>$Lang::tr{'legend'}:&nbsp;</b></td>
<td><img src='/images/on.gif' alt='$Lang::tr{'click to disable'}' /></td>
<td class='base'>$Lang::tr{'click to disable'}</td>
<td>&nbsp;&nbsp;</td>
<td><img src='/images/off.gif' alt='$Lang::tr{'click to enable'}' /></td>
<td class='base'>$Lang::tr{'click to enable'}</td>
<td>&nbsp;&nbsp;</td>
<td><img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
<td class='base'>$Lang::tr{'edit'}</td>
<td>&nbsp;&nbsp;</td>
<td><img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
<td class='base'>$Lang::tr{'remove'}</td>
</tr>
</table>
END
;
}
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
## Ouf it's the end !
# Sort the "current" array according to choices
sub SortDataFile
{
our %entries = ();
# Sort pair of record received in $a $b special vars.
# When IP is specified use numeric sort else alpha.
# If sortname ends with 'Rev', do reverse sort.
#
sub fixedleasesort {
my $qs=''; # The sort field specified minus 'Rev'
if (rindex ($settings{'SORT_HOSTSLIST'},'Rev') != -1) {
$qs=substr ($settings{'SORT_HOSTSLIST'},0,length($settings{'SORT_HOSTSLIST'})-3);
if ($qs eq 'IP') {
my @a = split(/\./,$entries{$a}->{$qs});
my @b = split(/\./,$entries{$b}->{$qs});
($b[0]<=>$a[0]) ||
($b[1]<=>$a[1]) ||
($b[2]<=>$a[2]) ||
($b[3]<=>$a[3]);
} else {
$entries{$b}->{$qs} cmp $entries{$a}->{$qs};
}
} else { #not reverse
$qs=$settings{'SORT_HOSTSLIST'};
if ($qs eq 'IP') {
my @a = split(/\./,$entries{$a}->{$qs});
my @b = split(/\./,$entries{$b}->{$qs});
($a[0]<=>$b[0]) ||
($a[1]<=>$b[1]) ||
($a[2]<=>$b[2]) ||
($a[3]<=>$b[3]);
} else {
$entries{$a}->{$qs} cmp $entries{$b}->{$qs};
}
}
}
#Use an associative array (%entries)
my $key = 0;
foreach my $line (@current) {
chomp( $line); #remove newline because can be on field 5 or 6 (addition of REMARK)
my @temp = ( '','','', '');
@temp = split (',',$line);
# Build a pair 'Field Name',value for each of the data dataline.
# Each SORTABLE field must have is pair.
# Other data fields (non sortable) can be grouped in one
my @record = ('KEY',$key++,'EN',$temp[0],'IP',$temp[1],'HOST',$temp[2],'DOM',$temp[3]);
my $record = {}; # create a reference to empty hash
%{$record} = @record; # populate that hash with @record
$entries{$record->{KEY}} = $record; # add this to a hash of hashes
}
open(FILE, ">$datafile") or die 'hosts datafile error';
# Each field value is printed , with the newline ! Don't forget separator and order of them.
foreach my $entry (sort fixedleasesort keys %entries) {
print FILE "$entries{$entry}->{EN},$entries{$entry}->{IP},$entries{$entry}->{HOST},$entries{$entry}->{DOM}\n";
}
close(FILE);
# Reload sorted @current
open (FILE, "$datafile");
@current = <FILE>;
close (FILE);
}
#
# Build the configuration file
#
sub BuildConfiguration {
system '/usr/local/bin/rebuildhosts';
}
#!/usr/bin/perl
#
# IPCop CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) Alan Hourihane <alanh@fairlite.demon.co.uk>
#
# $Id: hosts.cgi,v 1.4.2.20 2005/11/05 15:46:25 gespinasse Exp $
#
# Franck
# use dhcp.cgi model to rewrite this code
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::colouryellow} );
undef (@dummy);
# Files used
my $setting = "${General::swroot}/main/settings";
our $datafile = "${General::swroot}/main/hosts"; #(our: used in subroutine)
our %settings = ();
#Settings1
# removed
#Settings2 for editing the multi-line list
#Must not be saved !
$settings{'EN'} = ''; # reuse for dummy field in position zero
$settings{'IP'} = '';
$settings{'HOST'} = '';
$settings{'DOM'} = '';
my @nosaved=('EN','IP','HOST','DOM'); # List here ALL setting2 fields. Mandatory
$settings{'ACTION'} = ''; # add/edit/remove
$settings{'KEY1'} = ''; # point record for ACTION
#Define each field that can be used to sort columns
my $sortstring='^IP|^HOST|^DOM';
$settings{'SORT_HOSTSLIST'} = 'HOST';
my $errormessage = '';
my $warnmessage = '';
&Header::showhttpheaders();
#Get GUI values
&Header::getcgihash(\%settings);
# Load multiline data
our @current = ();
if (open(FILE, "$datafile")) {
@current = <FILE>;
close (FILE);
}
## Settings1 Box not used...
&General::readhash("${General::swroot}/main/settings", \%settings);
## Now manipulate the multi-line list with Settings2
# Basic actions are:
# toggle the check box
# add/update a new line
# begin editing a line
# remove a line
# Toggle enable/disable field. Field is in second position
if ($settings{'ACTION'} eq $Lang::tr{'toggle enable disable'}) {
#move out new line
chomp(@current[$settings{'KEY1'}]);
my @temp = split(/\,/,@current[$settings{'KEY1'}]);
$temp[0] = $temp[0] ne '' ? '' : 'on'; # Toggle the field
@current[$settings{'KEY1'}] = join (',',@temp)."\n";
$settings{'KEY1'} = ''; # End edit mode
&General::log($Lang::tr{'hosts config changed'});
#Save current
open(FILE, ">$datafile") or die 'hosts datafile error';
print FILE @current;
close(FILE);
# Rebuild configuration file
&BuildConfiguration;
}
if ($settings{'ACTION'} eq $Lang::tr{'add'}) {
# Validate inputs
unless(&General::validip($settings{'IP'})) {
$errormessage = $Lang::tr{'invalid fixed ip address'};
}
unless(&General::validhostname($settings{'HOST'})) {
$errormessage = $Lang::tr{'invalid hostname'};
}
if ($settings{'DOM'} && ! &General::validdomainname($settings{'DOM'})) {
$errormessage = $Lang::tr{'invalid domain name'};
}
unless ($errormessage) {
if ($settings{'KEY1'} eq '') { #add or edit ?
unshift (@current, "$settings{'EN'},$settings{'IP'},$settings{'HOST'},$settings{'DOM'}\n");
&General::log($Lang::tr{'hosts config added'});
} else {
@current[$settings{'KEY1'}] = "$settings{'EN'},$settings{'IP'},$settings{'HOST'},$settings{'DOM'}\n";
$settings{'KEY1'} = ''; # End edit mode
&General::log($Lang::tr{'hosts config changed'});
}
# Write changes to config file.
&SortDataFile; # sort newly added/modified entry
&BuildConfiguration; # then re-build new host
#map ($settings{$_}='' ,@nosaved); # Clear fields
}
}
if ($settings{'ACTION'} eq $Lang::tr{'edit'}) {
#move out new line
my $line = @current[$settings{'KEY1'}]; # KEY1 is the index in current
chomp($line);
my @temp = split(/\,/, $line);
$settings{'EN'}=$temp[0]; # Prepare the screen for editing
$settings{'IP'}=$temp[1];
$settings{'HOST'}=$temp[2];
$settings{'DOM'}=$temp[3];
}
if ($settings{'ACTION'} eq $Lang::tr{'remove'}) {
splice (@current,$settings{'KEY1'},1); # Delete line
open(FILE, ">$datafile") or die 'hosts datafile error';
print FILE @current;
close(FILE);
$settings{'KEY1'} = ''; # End remove mode
&General::log($Lang::tr{'hosts config changed'});
&BuildConfiguration; # then re-build conf which use new data
}
## Check if sorting is asked
# If same column clicked, reverse the sort.
if ($ENV{'QUERY_STRING'} =~ /$sortstring/ ) {
my $newsort=$ENV{'QUERY_STRING'};
my $actual=$settings{'SORT_HOSTSLIST'};
#Reverse actual sort ?
if ($actual =~ $newsort) {
my $Rev='';
if ($actual !~ 'Rev') {
$Rev='Rev';
}
$newsort.=$Rev;
}
$settings{'SORT_HOSTSLIST'}=$newsort;
map (delete ($settings{$_}) ,(@nosaved,'ACTION','KEY1'));# Must never be saved
&General::writehash($setting, \%settings);
&SortDataFile;
$settings{'ACTION'} = 'SORT'; # Create an 'ACTION'
map ($settings{$_} = '' ,@nosaved,'KEY1'); # and reinit vars to empty
}
if ($settings{'ACTION'} eq '' ) { # First launch from GUI
# Place here default value when nothing is initialized
$settings{'EN'} = 'on';
$settings{'DOM'} = $settings{'DOMAINNAME'};
}
&Header::openpage($Lang::tr{'hostname'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
my %checked=(); # Checkbox manipulations
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>";
&Header::closebox();
}
#
# Remove if no Setting1 needed
#
#if ($warnmessage) {
# $warnmessage = "<font color=${Header::colourred}><b>$Lang::tr{'capswarning'}</b></font>: $warnmessage";
#}
#&Header::openbox('100%', 'left', $Lang::tr{'settings'});
#print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>";
#print <<END
#<table width='100%'>
#<tr>
# <td class='base'>$Lang::tr{'domain name'} : $settings{'DOMAINNAME'}</td>
#</table>
#
#END
#;
#
#print <<END
#<table width='100%'>
#<hr />
#<tr>
# <td class='base' width='25%'><!--<img src='/blob.gif' align='top' alt='*' />&nbsp;$Lang::tr{'this field may be blank'}</td>-->
# <td class='base' width='25%'>$warnmessage</td>
# <td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' disabled='disabled' /></td>
#</tr>
#</table>
#</form>
#END
#;
#&Header::closebox(); # end of Settings1
#
# Second check box is for editing the list
#
$checked{'EN'}{'on'} = ($settings{'EN'} eq '' ) ? '' : "checked='checked'";
my $buttontext = $Lang::tr{'add'};
if ($settings{'KEY1'} ne '') {
$buttontext = $Lang::tr{'update'};
&Header::openbox('100%', 'left', $Lang::tr{'edit an existing host'});
} else {
&Header::openbox('100%', 'left', $Lang::tr{'add a host'});
}
#Edited line number (KEY1) passed until cleared by 'save' or 'remove' or 'new sort order'
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='KEY1' value='$settings{'KEY1'}' />
<table width='100%'>
<tr>
<td class='base'>$Lang::tr{'host ip'}:&nbsp;</td>
<td><input type='text' name='IP' value='$settings{'IP'}' /></td>
<td class='base'>$Lang::tr{'hostname'}:</td>
<td><input type='text' name='HOST' value='$settings{'HOST'}' /></td>
</tr><tr>
<td class='base'>$Lang::tr{'domain name'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
<td><input type='text' name='DOM' value='$settings{'DOM'}' /></td>
<td class='base'>$Lang::tr{'enabled'}</td>
<td><input type='checkbox' name='EN' $checked{'EN'}{'on'} /></td>
</tr>
</table>
<hr />
<table width='100%'>
<tr>
<td class='base' width='50%'><img src='/blob.gif' align='top' alt='*' />&nbsp;$Lang::tr{'this field may be blank'}</td>
<td width='50%' align='center'><input type='hidden' name='ACTION' value='$Lang::tr{'add'}' /><input type='submit' name='SUBMIT' value='$buttontext' /></td>
</tr>
</table>
</form>
END
;
&Header::closebox();
#
# Third box shows the list, in columns
#
# Columns headers may content a link. In this case it must be named in $sortstring
#
&Header::openbox('100%', 'left', $Lang::tr{'current hosts'});
print <<END
<table width='100%'>
<tr>
<td width='20%' align='center'><a href='$ENV{'SCRIPT_NAME'}?IP'><b>$Lang::tr{'host ip'}</b></a></td>
<td width='20%' align='center'><a href='$ENV{'SCRIPT_NAME'}?HOST'><b>$Lang::tr{'hostname'}</b></a></td>
<td width='50%' align='center'><a href='$ENV{'SCRIPT_NAME'}?DOM'><b>$Lang::tr{'domain name'}</b></a></td>
<td width='10%' colspan='3' class='boldbase' align='center'><b>$Lang::tr{'action'}</b></td>
</tr>
END
;
#
# Print each line of @current list
#
my $key = 0;
foreach my $line (@current) {
chomp($line); # remove newline
my @temp=split(/\,/,$line);
$temp[3] ='' unless defined $temp[3]; # not always populated
#Choose icon for checkbox
my $gif = '';
my $gdesc = '';
if ($temp[0] ne '' ) {
$gif = 'on.gif';
$gdesc = $Lang::tr{'click to disable'};
} else {
$gif = 'off.gif';
$gdesc = $Lang::tr{'click to enable'};
}
#Colorize each line
if ($settings{'KEY1'} eq $key) {
print "<tr bgcolor='${Header::colouryellow}'>";
} elsif ($key % 2) {
print "<tr bgcolor='${Header::table2colour}'>";
} else {
print "<tr bgcolor='${Header::table1colour}'>";
}
print <<END
<td align='center'>$temp[1]</td>
<td align='center'>$temp[2]</td>
<td align='center'>$temp[3]</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
<input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' alt='$gdesc' title='$gdesc' />
<input type='hidden' name='KEY1' value='$key' />
</form>
</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
<input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
<input type='hidden' name='KEY1' value='$key' />
</form>
</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
<input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' alt='$Lang::tr{'remove'}' title='$Lang::tr{'remove'}' />
<input type='hidden' name='KEY1' value='$key' />
</form>
</td>
</tr>
END
;
$key++;
}
print "</table>";
# If table contains entries, print 'Key to action icons'
if ($key) {
print <<END
<table>
<tr>
<td class='boldbase'>&nbsp;<b>$Lang::tr{'legend'}:&nbsp;</b></td>
<td><img src='/images/on.gif' alt='$Lang::tr{'click to disable'}' /></td>
<td class='base'>$Lang::tr{'click to disable'}</td>
<td>&nbsp;&nbsp;</td>
<td><img src='/images/off.gif' alt='$Lang::tr{'click to enable'}' /></td>
<td class='base'>$Lang::tr{'click to enable'}</td>
<td>&nbsp;&nbsp;</td>
<td><img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
<td class='base'>$Lang::tr{'edit'}</td>
<td>&nbsp;&nbsp;</td>
<td><img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
<td class='base'>$Lang::tr{'remove'}</td>
</tr>
</table>
END
;
}
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
## Ouf it's the end !
# Sort the "current" array according to choices
sub SortDataFile
{
our %entries = ();
# Sort pair of record received in $a $b special vars.
# When IP is specified use numeric sort else alpha.
# If sortname ends with 'Rev', do reverse sort.
#
sub fixedleasesort {
my $qs=''; # The sort field specified minus 'Rev'
if (rindex ($settings{'SORT_HOSTSLIST'},'Rev') != -1) {
$qs=substr ($settings{'SORT_HOSTSLIST'},0,length($settings{'SORT_HOSTSLIST'})-3);
if ($qs eq 'IP') {
my @a = split(/\./,$entries{$a}->{$qs});
my @b = split(/\./,$entries{$b}->{$qs});
($b[0]<=>$a[0]) ||
($b[1]<=>$a[1]) ||
($b[2]<=>$a[2]) ||
($b[3]<=>$a[3]);
} else {
$entries{$b}->{$qs} cmp $entries{$a}->{$qs};
}
} else { #not reverse
$qs=$settings{'SORT_HOSTSLIST'};
if ($qs eq 'IP') {
my @a = split(/\./,$entries{$a}->{$qs});
my @b = split(/\./,$entries{$b}->{$qs});
($a[0]<=>$b[0]) ||
($a[1]<=>$b[1]) ||
($a[2]<=>$b[2]) ||
($a[3]<=>$b[3]);
} else {
$entries{$a}->{$qs} cmp $entries{$b}->{$qs};
}
}
}
#Use an associative array (%entries)
my $key = 0;
foreach my $line (@current) {
chomp( $line); #remove newline because can be on field 5 or 6 (addition of REMARK)
my @temp = ( '','','', '');
@temp = split (',',$line);
# Build a pair 'Field Name',value for each of the data dataline.
# Each SORTABLE field must have is pair.
# Other data fields (non sortable) can be grouped in one
my @record = ('KEY',$key++,'EN',$temp[0],'IP',$temp[1],'HOST',$temp[2],'DOM',$temp[3]);
my $record = {}; # create a reference to empty hash
%{$record} = @record; # populate that hash with @record
$entries{$record->{KEY}} = $record; # add this to a hash of hashes
}
open(FILE, ">$datafile") or die 'hosts datafile error';
# Each field value is printed , with the newline ! Don't forget separator and order of them.
foreach my $entry (sort fixedleasesort keys %entries) {
print FILE "$entries{$entry}->{EN},$entries{$entry}->{IP},$entries{$entry}->{HOST},$entries{$entry}->{DOM}\n";
}
close(FILE);
# Reload sorted @current
open (FILE, "$datafile");
@current = <FILE>;
close (FILE);
}
#
# Build the configuration file
#
sub BuildConfiguration {
system '/usr/local/bin/rebuildhosts';
}

View File

@@ -1,313 +1,313 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: ids.cgi,v 1.8.2.18 2005/07/27 21:35:22 franck78 Exp $
#
use LWP::UserAgent;
use File::Copy;
use File::Temp qw/ tempfile tempdir /;
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %snortsettings=();
my %checked=();
my %netsettings=();
our $errormessage = '';
our $md5 = '0';# not '' to avoid displaying the wrong message when INSTALLMD5 not set
our $realmd5 = '';
our $results = '';
our $tempdir = '';
our $url='';
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
&Header::showhttpheaders();
$snortsettings{'ENABLE_SNORT'} = 'off';
$snortsettings{'ENABLE_SNORT_GREEN'} = 'off';
$snortsettings{'ENABLE_SNORT_BLUE'} = 'off';
$snortsettings{'ENABLE_SNORT_ORANGE'} = 'off';
$snortsettings{'ACTION'} = '';
$snortsettings{'RULESTYPE'} = '';
$snortsettings{'OINKCODE'} = '';
$snortsettings{'INSTALLDATE'} = '';
$snortsettings{'INSTALLMD5'} = '';
&Header::getcgihash(\%snortsettings, {'wantfile' => 1, 'filevar' => 'FH'});
if ($snortsettings{'RULESTYPE'} eq 'subscripted') {
$url="http://www.snort.org/pub-bin/oinkmaster.cgi/$snortsettings{'OINKCODE'}/snortrules-snapshot-2.3_s.tar.gz";
} else {
$url="http://www.snort.org/pub-bin/oinkmaster.cgi/$snortsettings{'OINKCODE'}/snortrules-snapshot-2.3.tar.gz";
}
if ($snortsettings{'ACTION'} eq $Lang::tr{'save'})
{
$errormessage = $Lang::tr{'invalid input for oink code'} unless (
($snortsettings{'OINKCODE'} =~ /^[a-z0-9]+$/) ||
($snortsettings{'RULESTYPE'} eq 'nothing' ) );
&General::writehash("${General::swroot}/snort/settings", \%snortsettings);
if ($snortsettings{'ENABLE_SNORT'} eq 'on')
{
system ('/bin/touch', "${General::swroot}/snort/enable");
} else {
unlink "${General::swroot}/snort/enable";
}
if ($snortsettings{'ENABLE_SNORT_GREEN'} eq 'on')
{
system ('/bin/touch', "${General::swroot}/snort/enable_green");
} else {
unlink "${General::swroot}/snort/enable_green";
}
if ($snortsettings{'ENABLE_SNORT_BLUE'} eq 'on')
{
system ('/bin/touch', "${General::swroot}/snort/enable_blue");
} else {
unlink "${General::swroot}/snort/enable_blue";
}
if ($snortsettings{'ENABLE_SNORT_ORANGE'} eq 'on')
{
system ('/bin/touch', "${General::swroot}/snort/enable_orange");
} else {
unlink "${General::swroot}/snort/enable_orange";
}
system('/usr/local/bin/restartsnort','red','orange','blue','green');
} else {
# INSTALLMD5 is not in the form, so not retrieved by getcgihash
&General::readhash("${General::swroot}/snort/settings", \%snortsettings);
}
if ($snortsettings{'ACTION'} eq $Lang::tr{'download new ruleset'}) {
$md5 = &getmd5;
if (($snortsettings{'INSTALLMD5'} ne $md5) && defined $md5 ) {
chomp($md5);
my $filename = &downloadrulesfile();
if (defined $filename) {
# Check MD5sum
$realmd5 = `/usr/bin/md5sum $filename`;
chomp ($realmd5);
$realmd5 =~ s/^(\w+)\s.*$/$1/;
if ($md5 ne $realmd5) {
$errormessage = "$Lang::tr{'invalid md5sum'}";
} else {
$results = "<b>$Lang::tr{'installed updates'}</b>\n<pre>";
$results .=`/usr/local/bin/oinkmaster.pl -s -u file://$filename -C /var/ipcop/snort/oinkmaster.conf -o /etc/snort 2>&1`;
$results .= "</pre>";
}
unlink ($filename);
}
}
}
$checked{'ENABLE_SNORT'}{'off'} = '';
$checked{'ENABLE_SNORT'}{'on'} = '';
$checked{'ENABLE_SNORT'}{$snortsettings{'ENABLE_SNORT'}} = "checked='checked'";
$checked{'ENABLE_SNORT_GREEN'}{'off'} = '';
$checked{'ENABLE_SNORT_GREEN'}{'on'} = '';
$checked{'ENABLE_SNORT_GREEN'}{$snortsettings{'ENABLE_SNORT_GREEN'}} = "checked='checked'";
$checked{'ENABLE_SNORT_BLUE'}{'off'} = '';
$checked{'ENABLE_SNORT_BLUE'}{'on'} = '';
$checked{'ENABLE_SNORT_BLUE'}{$snortsettings{'ENABLE_SNORT_BLUE'}} = "checked='checked'";
$checked{'ENABLE_SNORT_ORANGE'}{'off'} = '';
$checked{'ENABLE_SNORT_ORANGE'}{'on'} = '';
$checked{'ENABLE_SNORT_ORANGE'}{$snortsettings{'ENABLE_SNORT_ORANGE'}} = "checked='checked'";
$checked{'RULESTYPE'}{'nothing'} = '';
$checked{'RULESTYPE'}{'registered'} = '';
$checked{'RULESTYPE'}{'subscripted'} = '';
$checked{'RULESTYPE'}{$snortsettings{'RULESTYPE'}} = "checked='checked'";
&Header::openpage($Lang::tr{'intrusion detection system'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<class name='base'>$errormessage\n";
print "&nbsp;</class>\n";
&Header::closebox();
}
&Header::openbox('100%', 'left', $Lang::tr{'intrusion detection system2'});
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'><table width='100%'>
<tr>
<td class='base'><input type='checkbox' name='ENABLE_SNORT_GREEN' $checked{'ENABLE_SNORT_GREEN'}{'on'} />
GREEN Snort</td>
</tr>
END
;
if ($netsettings{'BLUE_DEV'} ne '') {
print <<END
<tr>
<td class='base'><input type='checkbox' name='ENABLE_SNORT_BLUE' $checked{'ENABLE_SNORT_BLUE'}{'on'} />
BLUE Snort</td>
</tr>
END
;
}
if ($netsettings{'ORANGE_DEV'} ne '') {
print <<END
<tr>
<td class='base'><input type='checkbox' name='ENABLE_SNORT_ORANGE' $checked{'ENABLE_SNORT_ORANGE'}{'on'} />
ORANGE Snort</td>
</tr>
END
;
}
print <<END
<tr>
<td class='base'><input type='checkbox' name='ENABLE_SNORT' $checked{'ENABLE_SNORT'}{'on'} />
RED Snort</td>
</tr>
<tr>
<td><hr /></td>
</tr>
<tr>
<td><b>$Lang::tr{'ids rules update'}</b></td>
</tr>
<tr>
<td><input type='radio' name='RULESTYPE' value='nothing' $checked{'RULESTYPE'}{'nothing'} />
$Lang::tr{'no'}</td>
</tr>
<tr>
<td><input type='radio' name='RULESTYPE' value='registered' $checked{'RULESTYPE'}{'registered'} />
$Lang::tr{'registered user rules'}</td>
</tr>
<tr>
<td><input type='radio' name='RULESTYPE' value='subscripted' $checked{'RULESTYPE'}{'subscripted'} />
$Lang::tr{'subscripted user rules'}</td>
</tr>
<tr>
<td><br />
$Lang::tr{'ids rules license'} <a href='http://www.snort.org/' target='_blank'>http://www.snort.org</a>.<br />
<br />
$Lang::tr{'ids rules license2'} <a href='http://www.snort.org/reg-bin/userprefs.cgi' target='_blank'>USER PREFERENCES</a>, $Lang::tr{'ids rules license3'}<br />
</td>
</tr>
<tr>
<td nowrap='nowrap'>Oink Code:&nbsp;<input type='text' size='40' name='OINKCODE' value='$snortsettings{'OINKCODE'}' /></td>
</tr>
<tr>
<td width='30%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'download new ruleset'}' />
END
;
if ($snortsettings{'INSTALLMD5'} eq $md5) {
print "&nbsp;$Lang::tr{'rules already up to date'}</td>";
} else {
if ( $snortsettings{'ACTION'} eq $Lang::tr{'download new ruleset'} && $md5 eq $realmd5 ) {
$snortsettings{'INSTALLMD5'} = $realmd5;
$snortsettings{'INSTALLDATE'} = `/bin/date +'%Y-%m-%d'`;
&General::writehash("${General::swroot}/snort/settings", \%snortsettings);
}
print "&nbsp;$Lang::tr{'updates installed'}: $snortsettings{'INSTALLDATE'}</td>";
}
print <<END
</tr>
</table>
<hr />
<table width='100%'>
<tr>
<td width='55%'>&nbsp;</td>
<td width='40%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
<td width='5%'>
&nbsp; <!-- space for future online help link -->
</td>
</tr>
</table>
</form>
END
;
if ($results ne '') {
print "$results";
}
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
sub getmd5 {
# Retrieve MD5 sum from $url.md5 file
#
my $md5buf = &geturl("$url.md5");
return undef unless $md5buf;
if (0) { # 1 to debug
my $filename='';
my $fh='';
($fh, $filename) = tempfile('/tmp/XXXXXXXX',SUFFIX => '.md5' );
binmode ($fh);
syswrite ($fh, $md5buf->content);
close($fh);
}
return $md5buf->content;
}
sub downloadrulesfile {
my $return = &geturl($url);
return undef unless $return;
if (index($return->content, "\037\213") == -1 ) { # \037\213 is .gz beginning
$errormessage = $Lang::tr{'invalid loaded file'};
return undef;
}
my $filename='';
my $fh='';
($fh, $filename) = tempfile('/tmp/XXXXXXXX',SUFFIX => '.tar.gz' );#oinkmaster work only with this extension
binmode ($fh);
syswrite ($fh, $return->content);
close($fh);
return $filename;
}
sub geturl ($) {
my $url=$_[0];
unless (-e "${General::swroot}/red/active") {
$errormessage = $Lang::tr{'could not download latest updates'};
return undef;
}
my $downloader = LWP::UserAgent->new;
$downloader->timeout(5);
my %proxysettings=();
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
if ($proxysettings{'UPSTREAM_USER'}) {
$downloader->proxy("http","http://$proxysettings{'UPSTREAM_USER'}:$proxysettings{'UPSTREAM_PASSWORD'}@"."$peer:$peerport/");
} else {
$downloader->proxy("http","http://$peer:$peerport/");
}
}
my $return = $downloader->get($url,'Cache-Control','no-cache');
if ($return->code == 403) {
$errormessage = $Lang::tr{'access refused with this oinkcode'};
return undef;
} elsif (!$return->is_success()) {
$errormessage = $Lang::tr{'could not download latest updates'};
return undef;
}
return $return;
}
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: ids.cgi,v 1.8.2.18 2005/07/27 21:35:22 franck78 Exp $
#
use LWP::UserAgent;
use File::Copy;
use File::Temp qw/ tempfile tempdir /;
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %snortsettings=();
my %checked=();
my %netsettings=();
our $errormessage = '';
our $md5 = '0';# not '' to avoid displaying the wrong message when INSTALLMD5 not set
our $realmd5 = '';
our $results = '';
our $tempdir = '';
our $url='';
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
&Header::showhttpheaders();
$snortsettings{'ENABLE_SNORT'} = 'off';
$snortsettings{'ENABLE_SNORT_GREEN'} = 'off';
$snortsettings{'ENABLE_SNORT_BLUE'} = 'off';
$snortsettings{'ENABLE_SNORT_ORANGE'} = 'off';
$snortsettings{'ACTION'} = '';
$snortsettings{'RULESTYPE'} = '';
$snortsettings{'OINKCODE'} = '';
$snortsettings{'INSTALLDATE'} = '';
$snortsettings{'INSTALLMD5'} = '';
&Header::getcgihash(\%snortsettings, {'wantfile' => 1, 'filevar' => 'FH'});
if ($snortsettings{'RULESTYPE'} eq 'subscripted') {
$url="http://www.snort.org/pub-bin/oinkmaster.cgi/$snortsettings{'OINKCODE'}/snortrules-snapshot-2.3_s.tar.gz";
} else {
$url="http://www.snort.org/pub-bin/oinkmaster.cgi/$snortsettings{'OINKCODE'}/snortrules-snapshot-2.3.tar.gz";
}
if ($snortsettings{'ACTION'} eq $Lang::tr{'save'})
{
$errormessage = $Lang::tr{'invalid input for oink code'} unless (
($snortsettings{'OINKCODE'} =~ /^[a-z0-9]+$/) ||
($snortsettings{'RULESTYPE'} eq 'nothing' ) );
&General::writehash("${General::swroot}/snort/settings", \%snortsettings);
if ($snortsettings{'ENABLE_SNORT'} eq 'on')
{
system ('/bin/touch', "${General::swroot}/snort/enable");
} else {
unlink "${General::swroot}/snort/enable";
}
if ($snortsettings{'ENABLE_SNORT_GREEN'} eq 'on')
{
system ('/bin/touch', "${General::swroot}/snort/enable_green");
} else {
unlink "${General::swroot}/snort/enable_green";
}
if ($snortsettings{'ENABLE_SNORT_BLUE'} eq 'on')
{
system ('/bin/touch', "${General::swroot}/snort/enable_blue");
} else {
unlink "${General::swroot}/snort/enable_blue";
}
if ($snortsettings{'ENABLE_SNORT_ORANGE'} eq 'on')
{
system ('/bin/touch', "${General::swroot}/snort/enable_orange");
} else {
unlink "${General::swroot}/snort/enable_orange";
}
system('/usr/local/bin/restartsnort','red','orange','blue','green');
} else {
# INSTALLMD5 is not in the form, so not retrieved by getcgihash
&General::readhash("${General::swroot}/snort/settings", \%snortsettings);
}
if ($snortsettings{'ACTION'} eq $Lang::tr{'download new ruleset'}) {
$md5 = &getmd5;
if (($snortsettings{'INSTALLMD5'} ne $md5) && defined $md5 ) {
chomp($md5);
my $filename = &downloadrulesfile();
if (defined $filename) {
# Check MD5sum
$realmd5 = `/usr/bin/md5sum $filename`;
chomp ($realmd5);
$realmd5 =~ s/^(\w+)\s.*$/$1/;
if ($md5 ne $realmd5) {
$errormessage = "$Lang::tr{'invalid md5sum'}";
} else {
$results = "<b>$Lang::tr{'installed updates'}</b>\n<pre>";
$results .=`/usr/local/bin/oinkmaster.pl -s -u file://$filename -C /var/ipcop/snort/oinkmaster.conf -o /etc/snort 2>&1`;
$results .= "</pre>";
}
unlink ($filename);
}
}
}
$checked{'ENABLE_SNORT'}{'off'} = '';
$checked{'ENABLE_SNORT'}{'on'} = '';
$checked{'ENABLE_SNORT'}{$snortsettings{'ENABLE_SNORT'}} = "checked='checked'";
$checked{'ENABLE_SNORT_GREEN'}{'off'} = '';
$checked{'ENABLE_SNORT_GREEN'}{'on'} = '';
$checked{'ENABLE_SNORT_GREEN'}{$snortsettings{'ENABLE_SNORT_GREEN'}} = "checked='checked'";
$checked{'ENABLE_SNORT_BLUE'}{'off'} = '';
$checked{'ENABLE_SNORT_BLUE'}{'on'} = '';
$checked{'ENABLE_SNORT_BLUE'}{$snortsettings{'ENABLE_SNORT_BLUE'}} = "checked='checked'";
$checked{'ENABLE_SNORT_ORANGE'}{'off'} = '';
$checked{'ENABLE_SNORT_ORANGE'}{'on'} = '';
$checked{'ENABLE_SNORT_ORANGE'}{$snortsettings{'ENABLE_SNORT_ORANGE'}} = "checked='checked'";
$checked{'RULESTYPE'}{'nothing'} = '';
$checked{'RULESTYPE'}{'registered'} = '';
$checked{'RULESTYPE'}{'subscripted'} = '';
$checked{'RULESTYPE'}{$snortsettings{'RULESTYPE'}} = "checked='checked'";
&Header::openpage($Lang::tr{'intrusion detection system'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<class name='base'>$errormessage\n";
print "&nbsp;</class>\n";
&Header::closebox();
}
&Header::openbox('100%', 'left', $Lang::tr{'intrusion detection system2'});
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'><table width='100%'>
<tr>
<td class='base'><input type='checkbox' name='ENABLE_SNORT_GREEN' $checked{'ENABLE_SNORT_GREEN'}{'on'} />
GREEN Snort</td>
</tr>
END
;
if ($netsettings{'BLUE_DEV'} ne '') {
print <<END
<tr>
<td class='base'><input type='checkbox' name='ENABLE_SNORT_BLUE' $checked{'ENABLE_SNORT_BLUE'}{'on'} />
BLUE Snort</td>
</tr>
END
;
}
if ($netsettings{'ORANGE_DEV'} ne '') {
print <<END
<tr>
<td class='base'><input type='checkbox' name='ENABLE_SNORT_ORANGE' $checked{'ENABLE_SNORT_ORANGE'}{'on'} />
ORANGE Snort</td>
</tr>
END
;
}
print <<END
<tr>
<td class='base'><input type='checkbox' name='ENABLE_SNORT' $checked{'ENABLE_SNORT'}{'on'} />
RED Snort</td>
</tr>
<tr>
<td><hr /></td>
</tr>
<tr>
<td><b>$Lang::tr{'ids rules update'}</b></td>
</tr>
<tr>
<td><input type='radio' name='RULESTYPE' value='nothing' $checked{'RULESTYPE'}{'nothing'} />
$Lang::tr{'no'}</td>
</tr>
<tr>
<td><input type='radio' name='RULESTYPE' value='registered' $checked{'RULESTYPE'}{'registered'} />
$Lang::tr{'registered user rules'}</td>
</tr>
<tr>
<td><input type='radio' name='RULESTYPE' value='subscripted' $checked{'RULESTYPE'}{'subscripted'} />
$Lang::tr{'subscripted user rules'}</td>
</tr>
<tr>
<td><br />
$Lang::tr{'ids rules license'} <a href='http://www.snort.org/' target='_blank'>http://www.snort.org</a>.<br />
<br />
$Lang::tr{'ids rules license2'} <a href='http://www.snort.org/reg-bin/userprefs.cgi' target='_blank'>USER PREFERENCES</a>, $Lang::tr{'ids rules license3'}<br />
</td>
</tr>
<tr>
<td nowrap='nowrap'>Oink Code:&nbsp;<input type='text' size='40' name='OINKCODE' value='$snortsettings{'OINKCODE'}' /></td>
</tr>
<tr>
<td width='30%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'download new ruleset'}' />
END
;
if ($snortsettings{'INSTALLMD5'} eq $md5) {
print "&nbsp;$Lang::tr{'rules already up to date'}</td>";
} else {
if ( $snortsettings{'ACTION'} eq $Lang::tr{'download new ruleset'} && $md5 eq $realmd5 ) {
$snortsettings{'INSTALLMD5'} = $realmd5;
$snortsettings{'INSTALLDATE'} = `/bin/date +'%Y-%m-%d'`;
&General::writehash("${General::swroot}/snort/settings", \%snortsettings);
}
print "&nbsp;$Lang::tr{'updates installed'}: $snortsettings{'INSTALLDATE'}</td>";
}
print <<END
</tr>
</table>
<hr />
<table width='100%'>
<tr>
<td width='55%'>&nbsp;</td>
<td width='40%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
<td width='5%'>
&nbsp; <!-- space for future online help link -->
</td>
</tr>
</table>
</form>
END
;
if ($results ne '') {
print "$results";
}
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
sub getmd5 {
# Retrieve MD5 sum from $url.md5 file
#
my $md5buf = &geturl("$url.md5");
return undef unless $md5buf;
if (0) { # 1 to debug
my $filename='';
my $fh='';
($fh, $filename) = tempfile('/tmp/XXXXXXXX',SUFFIX => '.md5' );
binmode ($fh);
syswrite ($fh, $md5buf->content);
close($fh);
}
return $md5buf->content;
}
sub downloadrulesfile {
my $return = &geturl($url);
return undef unless $return;
if (index($return->content, "\037\213") == -1 ) { # \037\213 is .gz beginning
$errormessage = $Lang::tr{'invalid loaded file'};
return undef;
}
my $filename='';
my $fh='';
($fh, $filename) = tempfile('/tmp/XXXXXXXX',SUFFIX => '.tar.gz' );#oinkmaster work only with this extension
binmode ($fh);
syswrite ($fh, $return->content);
close($fh);
return $filename;
}
sub geturl ($) {
my $url=$_[0];
unless (-e "${General::swroot}/red/active") {
$errormessage = $Lang::tr{'could not download latest updates'};
return undef;
}
my $downloader = LWP::UserAgent->new;
$downloader->timeout(5);
my %proxysettings=();
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
if ($proxysettings{'UPSTREAM_USER'}) {
$downloader->proxy("http","http://$proxysettings{'UPSTREAM_USER'}:$proxysettings{'UPSTREAM_PASSWORD'}@"."$peer:$peerport/");
} else {
$downloader->proxy("http","http://$peer:$peerport/");
}
}
my $return = $downloader->get($url,'Cache-Control','no-cache');
if ($return->code == 403) {
$errormessage = $Lang::tr{'access refused with this oinkcode'};
return undef;
} elsif (!$return->is_success()) {
$errormessage = $Lang::tr{'could not download latest updates'};
return undef;
}
return $return;
}

View File

@@ -1,204 +1,204 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: index.cgi,v 1.15.2.18 2005/09/17 13:51:47 gespinasse Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %cgiparams=();
my %pppsettings=();
my %modemsettings=();
my %netsettings=();
my %ddnssettings=();
my $warnmessage = '';
my $refresh = '';
&Header::showhttpheaders();
$cgiparams{'ACTION'} = '';
&Header::getcgihash(\%cgiparams);
$pppsettings{'VALID'} = '';
$pppsettings{'PROFILENAME'} = 'None';
&General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
&General::readhash("${General::swroot}/modem/settings", \%modemsettings);
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
&General::readhash("${General::swroot}/ddns/settings", \%ddnssettings);
my $connstate = &Header::connectionstatus();
if ($connstate =~ /$Lang::tr{'dod waiting'}/ || -e "${General::swroot}/main/refreshindex") {
$refresh = "<meta http-equiv='refresh' content='30;'>";
} elsif ($connstate =~ /$Lang::tr{'connecting'}/) {
$refresh = "<meta http-equiv='refresh' content='5;'>";
}
&Header::openpage($Lang::tr{'main page'}, 1, $refresh);
&Header::openbigbox('', 'center');
&Header::openbox('100%', 'center', &Header::cleanhtml(`/bin/uname -n`,"y"));
# hide buttons only when pppsettings mandatory used and not valid
if ( ( $pppsettings{'VALID'} eq 'yes' ) ||
( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) ) {
print <<END
<table border='0'>
<tr>
<td align='center'><form method='post' action='/cgi-bin/dial.cgi'>
<input type='submit' name='ACTION' value='$Lang::tr{'dial'}' />
</form></td>
<td>&nbsp;&nbsp;</td>
<td align='center'><form method='post' action='/cgi-bin/dial.cgi'>
<input type='submit' name='ACTION' value='$Lang::tr{'hangup'}' />
</form></td>
<td>&nbsp;&nbsp;</td>
<td align='center'><form method='post' action="$ENV{'SCRIPT_NAME'}">
<input type='submit' name='ACTION' value='$Lang::tr{'refresh'}' />
</form></td>
</tr></table>
END
;
}
print "<font face='Helvetica' size='4'><b>";
if ( !( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) ) {
print "<u>$Lang::tr{'current profile'} $pppsettings{'PROFILENAME'}</u><br />\n";
}
if ( ( $pppsettings{'VALID'} eq 'yes'&& $modemsettings{'VALID'} eq 'yes' ) ||
( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ )) {
print $connstate;
print "</b></font>\n";
if ($connstate =~ /$Lang::tr{'connected'}/) {
my $fetch_ip='nothing';
if ($ddnssettings{'BEHINDROUTER'} eq 'FETCH_IP') {
if (open(IPADDR,"${General::swroot}/ddns/ipcache")) {
$fetch_ip = <IPADDR>;
close IPADDR;
chomp ($fetch_ip);
my $host_name = (gethostbyaddr(pack("C4", split(/\./, $fetch_ip)), 2))[0];
print "<br />$Lang::tr{'ip address'} (internet): $fetch_ip <br /> $Lang::tr{'ipcops hostname'} (internet): $host_name <br />";
}
}
if (open(IPADDR,"${General::swroot}/red/local-ipaddress")) {
my $ipaddr = <IPADDR>;
close IPADDR;
chomp ($ipaddr);
if ($ipaddr ne $fetch_ip){ #do not show info twice
my $host_name = (gethostbyaddr(pack("C4", split(/\./, $ipaddr)), 2))[0];
print "<br />$Lang::tr{'ip address'}: $ipaddr <br /> $Lang::tr{'ipcops hostname'}: $host_name <br />";
}
}
}
} elsif ($modemsettings{'VALID'} eq 'no') {
print "$Lang::tr{'modem settings have errors'}\n </b></font>\n";
} else {
print "$Lang::tr{'profile has errors'}\n </b></font>\n";
}
# Memory usage warning
my @free = `/usr/bin/free`;
$free[1] =~ m/(\d+)/;
my $mem = $1;
$free[2] =~ m/(\d+)/;
my $used = $1;
my $pct = int 100 * ($mem - $used) / $mem;
if ($used / $mem > 90) {
$warnmessage .= "<li> $Lang::tr{'high memory usage'}: $pct% !</li>\n";
}
# Diskspace usage warning
my @temp=();
my $temp2=();
my @df = `/bin/df -B M -x rootfs`;
foreach my $line (@df) {
next if $line =~ m/^Filesystem/;
if ($line =~ m/root/ ) {
$line =~ m/^.* (\d+)M.*$/;
@temp = split(/ +/,$line);
if ($1<5) {
# available:plain value in MB, and not %used as 10% is too much to waste on small disk
# and root size should not vary during time
$warnmessage .= "<li> $Lang::tr{'filesystem full'}: $temp[0] <b>$Lang::tr{'free'}=$1M</b> !</li>\n";
}
} else {
# $line =~ m/^.* (\d+)m.*$/;
$line =~ m/^.* (\d+)\%.*$/;
if ($1>90) {
@temp = split(/ /,$line);
$temp2=int(100-$1);
$warnmessage .= "<li> $Lang::tr{'filesystem full'}: $temp[0] <b>$Lang::tr{'free'}=$temp2%</b> !</li>\n";
}
}
}
# Patches warning
open(AV, "<${General::swroot}/patches/available") or die "Could not open available patches database ($!)";
my @av = <AV>;
close(AV);
open(PF, "<${General::swroot}/patches/installed") or die "Could not open installed patches file. ($!)<br />";
while(<PF>)
{
next if $_ =~ m/^#/;
@temp = split(/\|/,$_);
@av = grep(!/^$temp[0]/, @av);
}
close(PF);
if ($#av != -1)
{
$warnmessage .= "<li> $Lang::tr{'there are updates'}</li>";
}
my $age = &General::age("/${General::swroot}/patches/available");
if ($age =~ m/(\d{1,3})d/) {
if ($1 >= 7) {
$warnmessage .= "<li>$Lang::tr{'updates is old1'} $age $Lang::tr{'updates is old2'}</li>\n";
}
}
if ($warnmessage) {
print "<ol>$warnmessage</ol>";
}
print "<p>";
system('/usr/bin/uptime');
print "</p>\n";
&Header::closebox();
# Test browser, and direct User where to turn off Javascript if necessary
# only display message if Javascript is currently enabled
if (${Header::javascript}) {
print <<END
<script type='text/javascript'>\n
if(navigator.platform.indexOf("MacPPC")>(-1)){
document.write(
"<center><p>"
+ "$Lang::tr{'javascript menu error1'}"
+ " <a href='/cgi-bin/gui.cgi'>$Lang::tr{'gui settings'}</a> "
+ "$Lang::tr{'javascript menu error2'}"
+ "</p></center>"
)
}
</script>
END
;
}
&Header::closebigbox();
&Header::closepage();
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: index.cgi,v 1.15.2.18 2005/09/17 13:51:47 gespinasse Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %cgiparams=();
my %pppsettings=();
my %modemsettings=();
my %netsettings=();
my %ddnssettings=();
my $warnmessage = '';
my $refresh = '';
&Header::showhttpheaders();
$cgiparams{'ACTION'} = '';
&Header::getcgihash(\%cgiparams);
$pppsettings{'VALID'} = '';
$pppsettings{'PROFILENAME'} = 'None';
&General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
&General::readhash("${General::swroot}/modem/settings", \%modemsettings);
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
&General::readhash("${General::swroot}/ddns/settings", \%ddnssettings);
my $connstate = &Header::connectionstatus();
if ($connstate =~ /$Lang::tr{'dod waiting'}/ || -e "${General::swroot}/main/refreshindex") {
$refresh = "<meta http-equiv='refresh' content='30;'>";
} elsif ($connstate =~ /$Lang::tr{'connecting'}/) {
$refresh = "<meta http-equiv='refresh' content='5;'>";
}
&Header::openpage($Lang::tr{'main page'}, 1, $refresh);
&Header::openbigbox('', 'center');
&Header::openbox('100%', 'center', &Header::cleanhtml(`/bin/uname -n`,"y"));
# hide buttons only when pppsettings mandatory used and not valid
if ( ( $pppsettings{'VALID'} eq 'yes' ) ||
( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) ) {
print <<END
<table border='0'>
<tr>
<td align='center'><form method='post' action='/cgi-bin/dial.cgi'>
<input type='submit' name='ACTION' value='$Lang::tr{'dial'}' />
</form></td>
<td>&nbsp;&nbsp;</td>
<td align='center'><form method='post' action='/cgi-bin/dial.cgi'>
<input type='submit' name='ACTION' value='$Lang::tr{'hangup'}' />
</form></td>
<td>&nbsp;&nbsp;</td>
<td align='center'><form method='post' action="$ENV{'SCRIPT_NAME'}">
<input type='submit' name='ACTION' value='$Lang::tr{'refresh'}' />
</form></td>
</tr></table>
END
;
}
print "<font face='Helvetica' size='4'><b>";
if ( !( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) ) {
print "<u>$Lang::tr{'current profile'} $pppsettings{'PROFILENAME'}</u><br />\n";
}
if ( ( $pppsettings{'VALID'} eq 'yes'&& $modemsettings{'VALID'} eq 'yes' ) ||
( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ )) {
print $connstate;
print "</b></font>\n";
if ($connstate =~ /$Lang::tr{'connected'}/) {
my $fetch_ip='nothing';
if ($ddnssettings{'BEHINDROUTER'} eq 'FETCH_IP') {
if (open(IPADDR,"${General::swroot}/ddns/ipcache")) {
$fetch_ip = <IPADDR>;
close IPADDR;
chomp ($fetch_ip);
my $host_name = (gethostbyaddr(pack("C4", split(/\./, $fetch_ip)), 2))[0];
print "<br />$Lang::tr{'ip address'} (internet): $fetch_ip <br /> $Lang::tr{'ipcops hostname'} (internet): $host_name <br />";
}
}
if (open(IPADDR,"${General::swroot}/red/local-ipaddress")) {
my $ipaddr = <IPADDR>;
close IPADDR;
chomp ($ipaddr);
if ($ipaddr ne $fetch_ip){ #do not show info twice
my $host_name = (gethostbyaddr(pack("C4", split(/\./, $ipaddr)), 2))[0];
print "<br />$Lang::tr{'ip address'}: $ipaddr <br /> $Lang::tr{'ipcops hostname'}: $host_name <br />";
}
}
}
} elsif ($modemsettings{'VALID'} eq 'no') {
print "$Lang::tr{'modem settings have errors'}\n </b></font>\n";
} else {
print "$Lang::tr{'profile has errors'}\n </b></font>\n";
}
# Memory usage warning
my @free = `/usr/bin/free`;
$free[1] =~ m/(\d+)/;
my $mem = $1;
$free[2] =~ m/(\d+)/;
my $used = $1;
my $pct = int 100 * ($mem - $used) / $mem;
if ($used / $mem > 90) {
$warnmessage .= "<li> $Lang::tr{'high memory usage'}: $pct% !</li>\n";
}
# Diskspace usage warning
my @temp=();
my $temp2=();
my @df = `/bin/df -B M -x rootfs`;
foreach my $line (@df) {
next if $line =~ m/^Filesystem/;
if ($line =~ m/root/ ) {
$line =~ m/^.* (\d+)M.*$/;
@temp = split(/ +/,$line);
if ($1<5) {
# available:plain value in MB, and not %used as 10% is too much to waste on small disk
# and root size should not vary during time
$warnmessage .= "<li> $Lang::tr{'filesystem full'}: $temp[0] <b>$Lang::tr{'free'}=$1M</b> !</li>\n";
}
} else {
# $line =~ m/^.* (\d+)m.*$/;
$line =~ m/^.* (\d+)\%.*$/;
if ($1>90) {
@temp = split(/ /,$line);
$temp2=int(100-$1);
$warnmessage .= "<li> $Lang::tr{'filesystem full'}: $temp[0] <b>$Lang::tr{'free'}=$temp2%</b> !</li>\n";
}
}
}
# Patches warning
open(AV, "<${General::swroot}/patches/available") or die "Could not open available patches database ($!)";
my @av = <AV>;
close(AV);
open(PF, "<${General::swroot}/patches/installed") or die "Could not open installed patches file. ($!)<br />";
while(<PF>)
{
next if $_ =~ m/^#/;
@temp = split(/\|/,$_);
@av = grep(!/^$temp[0]/, @av);
}
close(PF);
if ($#av != -1)
{
$warnmessage .= "<li> $Lang::tr{'there are updates'}</li>";
}
my $age = &General::age("/${General::swroot}/patches/available");
if ($age =~ m/(\d{1,3})d/) {
if ($1 >= 7) {
$warnmessage .= "<li>$Lang::tr{'updates is old1'} $age $Lang::tr{'updates is old2'}</li>\n";
}
}
if ($warnmessage) {
print "<ol>$warnmessage</ol>";
}
print "<p>";
system('/usr/bin/uptime');
print "</p>\n";
&Header::closebox();
# Test browser, and direct User where to turn off Javascript if necessary
# only display message if Javascript is currently enabled
if (${Header::javascript}) {
print <<END
<script type='text/javascript'>\n
if(navigator.platform.indexOf("MacPPC")>(-1)){
document.write(
"<center><p>"
+ "$Lang::tr{'javascript menu error1'}"
+ " <a href='/cgi-bin/gui.cgi'>$Lang::tr{'gui settings'}</a> "
+ "$Lang::tr{'javascript menu error2'}"
+ "</p></center>"
)
}
</script>
END
;
}
&Header::closebigbox();
&Header::closepage();

View File

@@ -1,103 +1,103 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# (c) 2002 Josh Grubman <jg@false.net> - Multiple registry IP lookup code
#
# $Id: ipinfo.cgi,v 1.4.2.3 2005/02/22 22:21:56 gespinasse Exp $
#
use IO::Socket;
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %cgiparams=();
&Header::showhttpheaders();
&Header::getcgihash(\%cgiparams);
$ENV{'QUERY_STRING'} =~s/&//g;
my @addrs = split(/ip=/,$ENV{'QUERY_STRING'});
my %whois_servers = ("RIPE"=>"whois.ripe.net","APNIC"=>"whois.apnic.net","LACNIC"=>"whois.lacnic.net");
&Header::openpage($Lang::tr{'ip info'}, 1, '');
&Header::openbigbox('100%', 'left');
my @lines=();
my $extraquery='';
foreach my $addr (@addrs) {
next if $addr eq "";
$extraquery='';
@lines=();
my $whoisname = "whois.arin.net";
my $iaddr = inet_aton($addr);
my $hostname = gethostbyaddr($iaddr, AF_INET);
if (!$hostname) { $hostname = $Lang::tr{'lookup failed'}; }
my $sock = new IO::Socket::INET ( PeerAddr => $whoisname, PeerPort => 43, Proto => 'tcp');
if ($sock)
{
print $sock "$addr\n";
while (<$sock>) {
$extraquery = $1 if (/NetType: Allocated to (\S+)\s+/);
push(@lines,$_);
}
close($sock);
if ($extraquery) {
undef (@lines);
$whoisname = $whois_servers{$extraquery};
my $sock = new IO::Socket::INET ( PeerAddr => $whoisname, PeerPort => 43, Proto => 'tcp');
if ($sock)
{
print $sock "$addr\n";
while (<$sock>) {
push(@lines,$_);
}
}
else
{
@lines = ( "$Lang::tr{'unable to contact'} $whoisname" );
}
}
}
else
{
@lines = ( "$Lang::tr{'unable to contact'} $whoisname" );
}
&Header::openbox('100%', 'left', $addr . ' (' . $hostname . ') : '.$whoisname);
print "<pre>\n";
foreach my $line (@lines) {
print &Header::cleanhtml($line,"y");
}
print "</pre>\n";
&Header::closebox();
}
print <<END
<div align='center'>
<table width='80%'>
<tr>
<td align='center'><a href='$ENV{'HTTP_REFERER'}'>$Lang::tr{'back'}</a></td>
</tr>
</table>
</div>
END
;
&Header::closebigbox();
&Header::closepage();
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# (c) 2002 Josh Grubman <jg@false.net> - Multiple registry IP lookup code
#
# $Id: ipinfo.cgi,v 1.4.2.3 2005/02/22 22:21:56 gespinasse Exp $
#
use IO::Socket;
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %cgiparams=();
&Header::showhttpheaders();
&Header::getcgihash(\%cgiparams);
$ENV{'QUERY_STRING'} =~s/&//g;
my @addrs = split(/ip=/,$ENV{'QUERY_STRING'});
my %whois_servers = ("RIPE"=>"whois.ripe.net","APNIC"=>"whois.apnic.net","LACNIC"=>"whois.lacnic.net");
&Header::openpage($Lang::tr{'ip info'}, 1, '');
&Header::openbigbox('100%', 'left');
my @lines=();
my $extraquery='';
foreach my $addr (@addrs) {
next if $addr eq "";
$extraquery='';
@lines=();
my $whoisname = "whois.arin.net";
my $iaddr = inet_aton($addr);
my $hostname = gethostbyaddr($iaddr, AF_INET);
if (!$hostname) { $hostname = $Lang::tr{'lookup failed'}; }
my $sock = new IO::Socket::INET ( PeerAddr => $whoisname, PeerPort => 43, Proto => 'tcp');
if ($sock)
{
print $sock "$addr\n";
while (<$sock>) {
$extraquery = $1 if (/NetType: Allocated to (\S+)\s+/);
push(@lines,$_);
}
close($sock);
if ($extraquery) {
undef (@lines);
$whoisname = $whois_servers{$extraquery};
my $sock = new IO::Socket::INET ( PeerAddr => $whoisname, PeerPort => 43, Proto => 'tcp');
if ($sock)
{
print $sock "$addr\n";
while (<$sock>) {
push(@lines,$_);
}
}
else
{
@lines = ( "$Lang::tr{'unable to contact'} $whoisname" );
}
}
}
else
{
@lines = ( "$Lang::tr{'unable to contact'} $whoisname" );
}
&Header::openbox('100%', 'left', $addr . ' (' . $hostname . ') : '.$whoisname);
print "<pre>\n";
foreach my $line (@lines) {
print &Header::cleanhtml($line,"y");
}
print "</pre>\n";
&Header::closebox();
}
print <<END
<div align='center'>
<table width='80%'>
<tr>
<td align='center'><a href='$ENV{'HTTP_REFERER'}'>$Lang::tr{'back'}</a></td>
</tr>
</table>
</div>
END
;
&Header::closebigbox();
&Header::closepage();

View File

@@ -1,120 +1,120 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: modem.cgi,v 1.4.2.7 2005/02/22 22:21:56 gespinasse Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %modemsettings=();
my $errormessage = '';
&Header::showhttpheaders();
$modemsettings{'ACTION'} = '';
$modemsettings{'VALID'} = '';
&Header::getcgihash(\%modemsettings);
if ($modemsettings{'ACTION'} eq $Lang::tr{'save'})
{
if (!($modemsettings{'TIMEOUT'} =~ /^\d+$/))
{
$errormessage = $Lang::tr{'timeout must be a number'};
goto ERROR;
}
ERROR:
if ($errormessage) {
$modemsettings{'VALID'} = 'no'; }
else {
$modemsettings{'VALID'} = 'yes'; }
&General::writehash("${General::swroot}/modem/settings", \%modemsettings);
}
if ($modemsettings{'ACTION'} eq $Lang::tr{'restore defaults'})
{
system('/bin/cp', "${General::swroot}/modem/defaults", "${General::swroot}/modem/settings", '-f');
}
&General::readhash("${General::swroot}/modem/settings", \%modemsettings);
&Header::openpage($Lang::tr{'modem configuration'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>\n";
&Header::closebox();
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
&Header::openbox('100%', 'left', "$Lang::tr{'modem configuration'}:");
print <<END
<table width='100%'>
<tr>
<td width='25%' class='base'>$Lang::tr{'init string'}&nbsp;<img src='/blob.gif' alt='*' /></td>
<td width='25%'><input type='text' name='INIT' value='$modemsettings{'INIT'}' /></td>
<td width='25%' class='base'>$Lang::tr{'hangup string'}&nbsp;<img src='/blob.gif' alt='*' /></td>
<td width='25%'><input type='text' name='HANGUP' value='$modemsettings{'HANGUP'}' /></td>
</tr>
<tr>
<td class='base'>$Lang::tr{'speaker on'}&nbsp;<img src='/blob.gif' alt='*' /></td>
<td><input type='text' name='SPEAKER_ON' value='$modemsettings{'SPEAKER_ON'}' /></td>
<td class='base'>$Lang::tr{'speaker off'}&nbsp;<img src='/blob.gif' alt='*' /></td>
<td><input type='text' name='SPEAKER_OFF' value='$modemsettings{'SPEAKER_OFF'}' /></td>
</tr>
<tr>
<td class='base'>$Lang::tr{'tone dial'}&nbsp;<img src='/blob.gif' alt='*' /></td>
<td><input type='text' name='TONE_DIAL' value='$modemsettings{'TONE_DIAL'}' /></td>
<td class='base'>$Lang::tr{'pulse dial'}&nbsp;<img src='/blob.gif' alt='*' /></td>
<td><input type='text' name='PULSE_DIAL' value='$modemsettings{'PULSE_DIAL'}' /></td>
</tr>
<tr>
<td class='base'>$Lang::tr{'connect timeout'}</td>
<td><input type='text' name='TIMEOUT' value='$modemsettings{'TIMEOUT'}' /></td>
<td class='base'>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<table width='100%'>
<hr />
<tr>
<td width='33%'>
<img src='/blob.gif' align='top' alt='*' />&nbsp;
<font class='base'>$Lang::tr{'this field may be blank'}</font>
</td>
<td width='33%' align='center'>
<input type='submit' name='ACTION' value='$Lang::tr{'restore defaults'}' />
</td>
<td width='33%' align='center'>
<input type='submit' name='ACTION' value='$Lang::tr{'save'}' />
</td>
</tr>
</table>
</div>
END
;
&Header::closebox();
print "</form>\n";
&Header::closebigbox();
&Header::closepage();
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: modem.cgi,v 1.4.2.7 2005/02/22 22:21:56 gespinasse Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %modemsettings=();
my $errormessage = '';
&Header::showhttpheaders();
$modemsettings{'ACTION'} = '';
$modemsettings{'VALID'} = '';
&Header::getcgihash(\%modemsettings);
if ($modemsettings{'ACTION'} eq $Lang::tr{'save'})
{
if (!($modemsettings{'TIMEOUT'} =~ /^\d+$/))
{
$errormessage = $Lang::tr{'timeout must be a number'};
goto ERROR;
}
ERROR:
if ($errormessage) {
$modemsettings{'VALID'} = 'no'; }
else {
$modemsettings{'VALID'} = 'yes'; }
&General::writehash("${General::swroot}/modem/settings", \%modemsettings);
}
if ($modemsettings{'ACTION'} eq $Lang::tr{'restore defaults'})
{
system('/bin/cp', "${General::swroot}/modem/defaults", "${General::swroot}/modem/settings", '-f');
}
&General::readhash("${General::swroot}/modem/settings", \%modemsettings);
&Header::openpage($Lang::tr{'modem configuration'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>\n";
&Header::closebox();
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
&Header::openbox('100%', 'left', "$Lang::tr{'modem configuration'}:");
print <<END
<table width='100%'>
<tr>
<td width='25%' class='base'>$Lang::tr{'init string'}&nbsp;<img src='/blob.gif' alt='*' /></td>
<td width='25%'><input type='text' name='INIT' value='$modemsettings{'INIT'}' /></td>
<td width='25%' class='base'>$Lang::tr{'hangup string'}&nbsp;<img src='/blob.gif' alt='*' /></td>
<td width='25%'><input type='text' name='HANGUP' value='$modemsettings{'HANGUP'}' /></td>
</tr>
<tr>
<td class='base'>$Lang::tr{'speaker on'}&nbsp;<img src='/blob.gif' alt='*' /></td>
<td><input type='text' name='SPEAKER_ON' value='$modemsettings{'SPEAKER_ON'}' /></td>
<td class='base'>$Lang::tr{'speaker off'}&nbsp;<img src='/blob.gif' alt='*' /></td>
<td><input type='text' name='SPEAKER_OFF' value='$modemsettings{'SPEAKER_OFF'}' /></td>
</tr>
<tr>
<td class='base'>$Lang::tr{'tone dial'}&nbsp;<img src='/blob.gif' alt='*' /></td>
<td><input type='text' name='TONE_DIAL' value='$modemsettings{'TONE_DIAL'}' /></td>
<td class='base'>$Lang::tr{'pulse dial'}&nbsp;<img src='/blob.gif' alt='*' /></td>
<td><input type='text' name='PULSE_DIAL' value='$modemsettings{'PULSE_DIAL'}' /></td>
</tr>
<tr>
<td class='base'>$Lang::tr{'connect timeout'}</td>
<td><input type='text' name='TIMEOUT' value='$modemsettings{'TIMEOUT'}' /></td>
<td class='base'>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<table width='100%'>
<hr />
<tr>
<td width='33%'>
<img src='/blob.gif' align='top' alt='*' />&nbsp;
<font class='base'>$Lang::tr{'this field may be blank'}</font>
</td>
<td width='33%' align='center'>
<input type='submit' name='ACTION' value='$Lang::tr{'restore defaults'}' />
</td>
<td width='33%' align='center'>
<input type='submit' name='ACTION' value='$Lang::tr{'save'}' />
</td>
</tr>
</table>
</div>
END
;
&Header::closebox();
print "</form>\n";
&Header::closebigbox();
&Header::closepage();

View File

@@ -1,222 +1,222 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: netstatus.cgi,v 1.9.2.20 2005/11/05 15:46:25 gespinasse Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %dhcpsettings=();
my %netsettings=();
my %dhcpinfo=();
my %pppsettings=();
my $output='';
&General::readhash("${General::swroot}/dhcp/settings", \%dhcpsettings);
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
&General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
&Header::showhttpheaders();
&Header::openpage($Lang::tr{'network status information'}, 1, '');
&Header::openbigbox('100%', 'left');
print "<table width='100%' cellspacing='0' cellpadding='5'border='0'>\n";
print "<tr><td style='background-color: #EAE9EE;' align='left'>\n";
print "<a href='#interfaces'>$Lang::tr{'interfaces'}</a> |\n";
if ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} eq "DHCP") {
print "<a href='#reddhcp'>RED $Lang::tr{'dhcp configuration'}</a> |\n";
}
if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
print "<a href='#leases'>$Lang::tr{'current dynamic leases'}</a> |\n";
}
if ($pppsettings{'TYPE'} =~ /^(bewanadsl|alcatelusbk|conexantpciadsl|eagleusbadsl)$/) {
print "<a href='#adsl'>$Lang::tr{'adsl settings'}</a> |\n";
}
print "<a href='#routing'>$Lang::tr{'routing table entries'}</a> |\n";
print "<a href='#arp'> $Lang::tr{'arp table entries'}</a>\n";
print "</td></tr></table>\n";
print "<a name='interfaces'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'interfaces'});
$output = `/sbin/ifconfig -a`;
$output = &Header::cleanhtml($output,"y");
my @itfs = ('ORANGE','BLUE','GREEN');
foreach my $itf (@itfs) {
my $ColorName='';
my $lc_itf=lc($itf);
my $dev = $netsettings{"${itf}_DEV"};
if ($dev){
$ColorName = "${lc_itf}"; #dereference variable name...
$output =~ s/$dev/<b><font color="$ColorName">$dev<\/font><\/b>/ ;
}
}
if (open(REDIFACE, "${General::swroot}/red/iface")) {
my $lc_itf='red';
my $reddev = <REDIFACE>;
close(REDIFACE);
chomp $reddev;
$output =~ s/$reddev/<b><font color='red'>${reddev}<\/font><\/b>/;
}
print "<pre>$output</pre>\n";
&Header::closebox();
if ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} eq "DHCP") {
print "<a name='reddhcp'/>\n";
&Header::openbox('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
if (-s "${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
&General::readhash("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \%dhcpinfo);
my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`;
my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`;
my $lsetme=0;
my $leasetime="";
if ($dhcpinfo{'LEASETIME'} ne "") {
$lsetme=$dhcpinfo{'LEASETIME'};
$lsetme=($lsetme/60);
if ($lsetme > 59) {
$lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
} else {
$leasetime=$lsetme." Minute";
}
if ($lsetme > 1) {
$leasetime=$leasetime."s";
}
}
my $rentme=0;
my $rnwltime="";
if ($dhcpinfo{'RENEWALTIME'} ne "") {
$rentme=$dhcpinfo{'RENEWALTIME'};
$rentme=($rentme/60);
if ($rentme > 59){
$rentme=($rentme/60); $rnwltime=$rentme." Hour";
} else {
$rnwltime=$rentme." Minute";
}
if ($rentme > 1){
$rnwltime=$rnwltime."s";
}
}
my $maxtme=0;
my $maxtime="";
if ($dhcpinfo{'REBINDTIME'} ne "") {
$maxtme=$dhcpinfo{'REBINDTIME'};
$maxtme=($maxtme/60);
if ($maxtme > 59){
$maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
} else {
$maxtime=$maxtme." Minute";
}
if ($maxtme > 1) {
$maxtime=$maxtime."s";
}
}
print "<table width='100%'>";
if ($dhcpinfo{'HOSTNAME'}) {
print "<tr><td width='30%'>$Lang::tr{'hostname'}</td><td>$dhcpinfo{'HOSTNAME'}.$dhcpinfo{'DOMAIN'}</td></tr>\n";
} else {
print "<tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'DOMAIN'}</td></tr>\n";
}
print <<END
<tr><td>$Lang::tr{'gateway'}</td><td>$dhcpinfo{'GATEWAY'}</td></tr>
<tr><td>$Lang::tr{'primary dns'}</td><td>$DNS1</td></tr>
<tr><td>$Lang::tr{'secondary dns'}</td><td>$DNS2</td></tr>
<tr><td>$Lang::tr{'dhcp server'}</td><td>$dhcpinfo{'DHCPSIADDR'}</td></tr>
<tr><td>$Lang::tr{'def lease time'}</td><td>$leasetime</td></tr>
<tr><td>$Lang::tr{'default renewal time'}</td><td>$rnwltime</td></tr>
<tr><td>$Lang::tr{'max renewal time'}</td><td>$maxtime</td></tr>
</table>
END
;
}
else
{
print "$Lang::tr{'no dhcp lease'}";
}
&Header::closebox();
}
if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
print "<a name='leases'/>";
&Header::CheckSortOrder;
&Header::PrintActualLeases;
}
if ( $netsettings{'CONFIG_TYPE'} =~ /^(0|1|4|5)$/ && (exists($pppsettings{'TYPE'})) ) {
my $output1='';
my $output2='';
if ($pppsettings{'TYPE'} eq 'bewanadsl') {
print "<a name='adsl'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'adsl settings'});
$output1 = `/usr/bin/unicorn_status`;
$output1 = &Header::cleanhtml($output1,"y");
$output2 = `/bin/cat /proc/net/atm/UNICORN:*`;
$output2 = &Header::cleanhtml($output2,"y");
print "<pre>$output1$output2</pre>\n";
&Header::closebox();
}
if ($pppsettings{'TYPE'} eq 'alcatelusbk') {
print "<a name='adsl'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'adsl settings'});
$output = `/bin/cat /proc/net/atm/speedtch:*`;
$output = &Header::cleanhtml($output,"y");
print "<pre>$output</pre>\n";
&Header::closebox();
}
if ($pppsettings{'TYPE'} eq 'conexantpciadsl') {
print "<a name='adsl'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'adsl settings'});
$output = `/bin/cat /proc/net/atm/CnxAdsl:*`;
$output = &Header::cleanhtml($output,"y");
print "<pre>$output</pre>\n";
&Header::closebox();
}
if ($pppsettings{'TYPE'} eq 'eagleusbadsl') {
print "<a name='adsl'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'adsl settings'});
$output = `/usr/sbin/eaglestat`;
$output = &Header::cleanhtml($output,"y");
print "<pre>$output</pre>\n";
&Header::closebox();
}
}
print "<a name='routing'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'routing table entries'});
$output = `/sbin/route -n`;
$output = &Header::cleanhtml($output,"y");
print "<pre>$output</pre>\n";
&Header::closebox();
print "<a name='arp'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'arp table entries'});
$output = `/sbin/arp -n`;
$output = &Header::cleanhtml($output,"y");
print "<pre>$output</pre>\n";
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: netstatus.cgi,v 1.9.2.20 2005/11/05 15:46:25 gespinasse Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %dhcpsettings=();
my %netsettings=();
my %dhcpinfo=();
my %pppsettings=();
my $output='';
&General::readhash("${General::swroot}/dhcp/settings", \%dhcpsettings);
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
&General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
&Header::showhttpheaders();
&Header::openpage($Lang::tr{'network status information'}, 1, '');
&Header::openbigbox('100%', 'left');
print "<table width='100%' cellspacing='0' cellpadding='5'border='0'>\n";
print "<tr><td style='background-color: #EAE9EE;' align='left'>\n";
print "<a href='#interfaces'>$Lang::tr{'interfaces'}</a> |\n";
if ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} eq "DHCP") {
print "<a href='#reddhcp'>RED $Lang::tr{'dhcp configuration'}</a> |\n";
}
if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
print "<a href='#leases'>$Lang::tr{'current dynamic leases'}</a> |\n";
}
if ($pppsettings{'TYPE'} =~ /^(bewanadsl|alcatelusbk|conexantpciadsl|eagleusbadsl)$/) {
print "<a href='#adsl'>$Lang::tr{'adsl settings'}</a> |\n";
}
print "<a href='#routing'>$Lang::tr{'routing table entries'}</a> |\n";
print "<a href='#arp'> $Lang::tr{'arp table entries'}</a>\n";
print "</td></tr></table>\n";
print "<a name='interfaces'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'interfaces'});
$output = `/sbin/ifconfig -a`;
$output = &Header::cleanhtml($output,"y");
my @itfs = ('ORANGE','BLUE','GREEN');
foreach my $itf (@itfs) {
my $ColorName='';
my $lc_itf=lc($itf);
my $dev = $netsettings{"${itf}_DEV"};
if ($dev){
$ColorName = "${lc_itf}"; #dereference variable name...
$output =~ s/$dev/<b><font color="$ColorName">$dev<\/font><\/b>/ ;
}
}
if (open(REDIFACE, "${General::swroot}/red/iface")) {
my $lc_itf='red';
my $reddev = <REDIFACE>;
close(REDIFACE);
chomp $reddev;
$output =~ s/$reddev/<b><font color='red'>${reddev}<\/font><\/b>/;
}
print "<pre>$output</pre>\n";
&Header::closebox();
if ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} eq "DHCP") {
print "<a name='reddhcp'/>\n";
&Header::openbox('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
if (-s "${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
&General::readhash("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \%dhcpinfo);
my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`;
my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`;
my $lsetme=0;
my $leasetime="";
if ($dhcpinfo{'LEASETIME'} ne "") {
$lsetme=$dhcpinfo{'LEASETIME'};
$lsetme=($lsetme/60);
if ($lsetme > 59) {
$lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
} else {
$leasetime=$lsetme." Minute";
}
if ($lsetme > 1) {
$leasetime=$leasetime."s";
}
}
my $rentme=0;
my $rnwltime="";
if ($dhcpinfo{'RENEWALTIME'} ne "") {
$rentme=$dhcpinfo{'RENEWALTIME'};
$rentme=($rentme/60);
if ($rentme > 59){
$rentme=($rentme/60); $rnwltime=$rentme." Hour";
} else {
$rnwltime=$rentme." Minute";
}
if ($rentme > 1){
$rnwltime=$rnwltime."s";
}
}
my $maxtme=0;
my $maxtime="";
if ($dhcpinfo{'REBINDTIME'} ne "") {
$maxtme=$dhcpinfo{'REBINDTIME'};
$maxtme=($maxtme/60);
if ($maxtme > 59){
$maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
} else {
$maxtime=$maxtme." Minute";
}
if ($maxtme > 1) {
$maxtime=$maxtime."s";
}
}
print "<table width='100%'>";
if ($dhcpinfo{'HOSTNAME'}) {
print "<tr><td width='30%'>$Lang::tr{'hostname'}</td><td>$dhcpinfo{'HOSTNAME'}.$dhcpinfo{'DOMAIN'}</td></tr>\n";
} else {
print "<tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'DOMAIN'}</td></tr>\n";
}
print <<END
<tr><td>$Lang::tr{'gateway'}</td><td>$dhcpinfo{'GATEWAY'}</td></tr>
<tr><td>$Lang::tr{'primary dns'}</td><td>$DNS1</td></tr>
<tr><td>$Lang::tr{'secondary dns'}</td><td>$DNS2</td></tr>
<tr><td>$Lang::tr{'dhcp server'}</td><td>$dhcpinfo{'DHCPSIADDR'}</td></tr>
<tr><td>$Lang::tr{'def lease time'}</td><td>$leasetime</td></tr>
<tr><td>$Lang::tr{'default renewal time'}</td><td>$rnwltime</td></tr>
<tr><td>$Lang::tr{'max renewal time'}</td><td>$maxtime</td></tr>
</table>
END
;
}
else
{
print "$Lang::tr{'no dhcp lease'}";
}
&Header::closebox();
}
if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
print "<a name='leases'/>";
&Header::CheckSortOrder;
&Header::PrintActualLeases;
}
if ( $netsettings{'CONFIG_TYPE'} =~ /^(0|1|4|5)$/ && (exists($pppsettings{'TYPE'})) ) {
my $output1='';
my $output2='';
if ($pppsettings{'TYPE'} eq 'bewanadsl') {
print "<a name='adsl'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'adsl settings'});
$output1 = `/usr/bin/unicorn_status`;
$output1 = &Header::cleanhtml($output1,"y");
$output2 = `/bin/cat /proc/net/atm/UNICORN:*`;
$output2 = &Header::cleanhtml($output2,"y");
print "<pre>$output1$output2</pre>\n";
&Header::closebox();
}
if ($pppsettings{'TYPE'} eq 'alcatelusbk') {
print "<a name='adsl'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'adsl settings'});
$output = `/bin/cat /proc/net/atm/speedtch:*`;
$output = &Header::cleanhtml($output,"y");
print "<pre>$output</pre>\n";
&Header::closebox();
}
if ($pppsettings{'TYPE'} eq 'conexantpciadsl') {
print "<a name='adsl'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'adsl settings'});
$output = `/bin/cat /proc/net/atm/CnxAdsl:*`;
$output = &Header::cleanhtml($output,"y");
print "<pre>$output</pre>\n";
&Header::closebox();
}
if ($pppsettings{'TYPE'} eq 'eagleusbadsl') {
print "<a name='adsl'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'adsl settings'});
$output = `/usr/sbin/eaglestat`;
$output = &Header::cleanhtml($output,"y");
print "<pre>$output</pre>\n";
&Header::closebox();
}
}
print "<a name='routing'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'routing table entries'});
$output = `/sbin/route -n`;
$output = &Header::cleanhtml($output,"y");
print "<pre>$output</pre>\n";
&Header::closebox();
print "<a name='arp'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'arp table entries'});
$output = `/sbin/arp -n`;
$output = &Header::cleanhtml($output,"y");
print "<pre>$output</pre>\n";
&Header::closebox();
&Header::closebigbox();
&Header::closepage();

View File

@@ -1,420 +1,420 @@
#!/usr/bin/perl
#
# This file is part of the IPCop Firewall.
#
# IPCop is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# IPCop is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with IPCop; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Copyright (C) 2003-09-22 Darren Critchley <darrenc@telus.net>
#
# $Id: networks.cgi,v 1.2.2.3 2005/04/29 23:37:06 franck78 Exp $
#
use strict;
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %netsettings=();
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
my @networks=();
my $filename = "${General::swroot}/firewall/customnetworks";
&setup_default_networks();
&Header::getcgihash(\%cgiparams);
if ($cgiparams{'ACTION'} eq $Lang::tr{'add'}){
&validateparams();
unless($errormessage){
$key++; # Add one to last sequence number
open(FILE,">>$filename") or die 'Unable to open custom networks file.';
flock FILE, 2;
print FILE "$key,$cgiparams{'NAME'},$cgiparams{'IPADDRESS'},$cgiparams{'NETMASK'}\n";
close(FILE);
&General::log("$Lang::tr{'network added'}: $cgiparams{'NAME'}");
undef %cgiparams;
}
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'update'})
{
&validateparams();
# Darren Critchley - If there is an error don't waste any more processing time
if ($errormessage) { $cgiparams{'ACTION'} = $Lang::tr{'edit'}; goto UPD_ERROR; }
unless($errormessage){
open(FILE, $filename) or die 'Unable to open custom networks file.';
my @current = <FILE>;
close(FILE);
open(FILE, ">$filename") or die 'Unable to open config file.';
flock FILE, 2;
foreach my $line (@current) {
chomp($line);
my @temp = split(/\,/,$line);
if ($cgiparams{'KEY'} eq $temp[0]) {
print FILE "$cgiparams{'KEY'},$cgiparams{'NAME'},$cgiparams{'IPADDRESS'},$cgiparams{'NETMASK'}\n";
} else {
print FILE "$line\n";
}
}
close(FILE);
&General::log("$Lang::tr{'network updated'}: $cgiparams{'NAME'}");
undef %cgiparams;
}
UPD_ERROR:
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'})
{
open(FILE, "$filename") or die 'Unable to open custom networks file.';
my @current = <FILE>;
close(FILE);
unless ($errormessage)
{
foreach my $line (@current)
{
chomp($line);
my @temp = split(/\,/,$line);
if ($cgiparams{'KEY'} eq $temp[0]) {
$cgiparams{'NAME'} = $temp[1];
$cgiparams{'IPADDRESS'} = $temp[2];
$cgiparams{'NETMASK'} = $temp[3];
}
}
}
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'remove'})
{
open(FILE, $filename) or die 'Unable to open custom networks file.';
my @current = <FILE>;
close(FILE);
open(FILE, ">$filename") or die 'Unable to open custom networks file.';
flock FILE, 2;
foreach my $line (@current)
{
chomp($line);
if ($line ne '') {
my @temp = split(/\,/,$line);
if ($cgiparams{'KEY'} eq $temp[0]) {
&General::log("$Lang::tr{'network removed'}: $temp[1]");
} else {
print FILE "$temp[0],$temp[1],$temp[2],$temp[3]\n";
}
}
}
close(FILE);
undef %cgiparams;
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'reset'})
{
undef %cgiparams;
}
if ($cgiparams{'ACTION'} eq '')
{
$cgiparams{'KEY'} = '';
$cgiparams{'IPADDRESS'} = '';
$cgiparams{'NETMASK'} = '';
$cgiparams{'NAME'} = '';
}
&Header::showhttpheaders();
&Header::openpage($Lang::tr{'networks settings'}, 1, '');
&Header::openbigbox('100%', 'LEFT', '', $errormessage);
# DEBUG DEBUG
#&Header::openbox('100%', 'LEFT', 'DEBUG');
#foreach $line (keys %cgiparams) {
# print "<CLASS NAME='base'>$line = $cgiparams{$line}<BR>";
#}
#print "$ENV{'QUERY_STRING'}\n";
#print "&nbsp;</CLASS>\n";
#&Header::closebox();
if ($errormessage) {
&Header::openbox('100%', 'LEFT', $Lang::tr{'error messages'});
print "<CLASS NAME='base'><FONT COLOR='${Header::colourred}'>$errormessage\n</FONT>";
print "&nbsp;</CLASS>\n";
&Header::closebox();
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'}){
&Header::openbox('100%', 'LEFT', "$Lang::tr{'edit network'}:");
} else {
&Header::openbox('100%', 'LEFT', "$Lang::tr{'add network'}:");
}
print <<END
<FORM METHOD='POST'>
<DIV ALIGN='CENTER'>
<TABLE WIDTH='100%'>
<TR align="center">
<TD><strong>$Lang::tr{'name'}</strong></TD>
<TD><strong>$Lang::tr{'ip address'}</strong></TD>
<TD><strong>$Lang::tr{'netmask'}</strong></TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
</TR>
<TR align="center">
<TD>
<INPUT TYPE='TEXT' NAME='NAME' VALUE='$cgiparams{'NAME'}' SIZE='20' MAXLENGTH='20'>
</TD>
<TD>
<INPUT TYPE='TEXT' NAME='IPADDRESS' VALUE='$cgiparams{'IPADDRESS'}' SIZE='15' MAXLENGTH='15'>
</TD>
<TD>
<INPUT TYPE='TEXT' NAME='NETMASK' VALUE='$cgiparams{'NETMASK'}' SIZE='15' MAXLENGTH='15'>
</TD>
END
;
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'}){
# Darren Critchley - put in next release - author has authorized GPL inclusion
# print "<TD ALIGN='CENTER'><a href='ipcalc.cgi' target='_blank'>IP Calculator</a></TD>\n";
print "<TD ALIGN='CENTER'><INPUT TYPE='SUBMIT' NAME='ACTION' VALUE='$Lang::tr{'update'}'></TD>\n";
print "<INPUT TYPE='HIDDEN' NAME='KEY' VALUE='$cgiparams{'KEY'}'>\n";
print "<TD ALIGN='CENTER'><INPUT TYPE='SUBMIT' NAME='ACTION' VALUE='$Lang::tr{'reset'}'></TD>\n";
} else {
# Darren Critchley - put in next release - author has authorized GPL inclusion
# print "<TD ALIGN='CENTER'><a href='ipcalc.cgi' target='_blank'>IP Calculator</a></TD>\n";
print "<TD ALIGN='CENTER'><INPUT TYPE='SUBMIT' NAME='ACTION' VALUE='$Lang::tr{'add'}'></TD>\n";
print "<TD ALIGN='CENTER'><INPUT TYPE='SUBMIT' NAME='ACTION' VALUE='$Lang::tr{'reset'}'></TD>\n";
}
print <<END
</TR>
</TABLE>
</DIV>
</FORM>
END
;
&Header::closebox();
&Header::openbox('100%', 'LEFT', "$Lang::tr{'custom networks'}:");
print <<END
<DIV ALIGN='CENTER'>
<TABLE WIDTH='100%' ALIGN='CENTER'>
<TR align="center">
<TD><strong>$Lang::tr{'name'}</strong></TD>
<TD><strong>$Lang::tr{'ip address'}</strong></TD>
<TD><strong>$Lang::tr{'netmask'}</strong></TD>
</TR>
END
;
&display_custom_networks();
print <<END
</TABLE>
</DIV>
END
;
&Header::closebox();
&Header::openbox('100%', 'LEFT', "$Lang::tr{'default networks'}:");
print <<END
<DIV ALIGN='CENTER'>
<TABLE WIDTH='100%' ALIGN='CENTER'>
<TR align="center">
<TD><strong>$Lang::tr{'name'}</strong></TD>
<TD><strong>$Lang::tr{'ip address'}</strong></TD>
<TD><strong>$Lang::tr{'netmask'}</strong></TD>
</TR>
END
;
&display_default_networks();
print <<END
</TABLE>
</DIV>
END
;
&Header::closebox();
print "$Lang::tr{'this feature has been sponsored by'} : ";
print "<A HREF='http://www.kdi.ca/' TARGET='_blank'>Kobelt Development Inc.</A>.\n";
&Header::closebigbox();
&Header::closepage();
sub display_custom_networks
{
open(FILE, "$filename") or die 'Unable to open networks file.';
my @current = <FILE>;
close(FILE);
my $id = 0;
foreach $line (@current)
{
chomp($line);
if ($line ne ''){
my @temp = split(/\,/,$line);
# Darren Critchley highlight the row we are editing
if ( $cgiparams{'ACTION'} eq $Lang::tr{'edit'} && $cgiparams{'KEY'} eq $temp[0] ) {
print "<TR BGCOLOR='${Header::colouryellow}'>\n";
} else {
if ($id % 2) {
print "<TR BGCOLOR='${Header::table1colour}'>\n";
} else {
print "<TR BGCOLOR='${Header::table2colour}'>\n";
}
}
print "<TD>$temp[1]</TD>\n";
print "<TD ALIGN='CENTER'>$temp[2]</TD>\n";
print "<TD ALIGN='CENTER'>$temp[3]</TD>\n";
print <<END
<FORM METHOD='POST' NAME='frm$temp[0]'>
<TD ALIGN='CENTER'>
<INPUT TYPE='hidden' NAME='ACTION' VALUE='$Lang::tr{'edit'}'>
<INPUT TYPE='image' NAME='$Lang::tr{'edit'}' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' width='20' height='20' border='0'>
<INPUT TYPE='hidden' NAME='KEY' VALUE='$temp[0]'>
</TD>
</FORM>
<FORM METHOD='POST' NAME='frm$temp[0]b'>
<TD ALIGN='CENTER'>
<INPUT TYPE='hidden' NAME='ACTION' VALUE='$Lang::tr{'remove'}'>
<INPUT TYPE='image' NAME='$Lang::tr{'remove'}' src='/images/delete.gif' alt='$Lang::tr{'remove'}' title='$Lang::tr{'remove'}' width='20' height='20' border='0'>
<INPUT TYPE='hidden' NAME='KEY' VALUE='$temp[0]'>
</TD>
</FORM>
END
;
print "</TR>\n";
$id++;
}
}
}
sub display_default_networks
{
foreach $line (sort @networks)
{
my @temp = split(/\,/,$line);
if ($id % 2) {
print "<TR BGCOLOR='${Header::table1colour}'>\n";
} else {
print "<TR BGCOLOR='${Header::table2colour}'>\n";
}
print "<TD>$temp[0]</TD>\n";
print "<TD ALIGN='CENTER'>$temp[1]</TD>\n";
print "<TD ALIGN='CENTER'>$temp[2]</TD>\n";
print "</TR>\n";
$id++;
}
}
sub setup_default_networks
{
# Get current defined networks (Red, Green, Blue, Orange)
my $line = "Any,0.0.0.0,0.0.0.0";
push (@networks, $line);
$line = "localhost,127.0.0.1,255.255.255.255";
push (@networks, $line);
$line = "localnet,127.0.0.0,255.0.0.0";
push (@networks, $line);
$line = "Private Network 10.0.0.0,10.0.0.0,255.0.0.0";
push (@networks, $line);
$line = "Private Network 172.16.0.0,172.16.0.0,255.240.0.0";
push (@networks, $line);
$line = "Private Network 192.168.0.0,192.168.0.0,255.255.0.0";
push (@networks, $line);
my $red_address=`cat ${General::swroot}/red/local-ipaddress`;
$line = "Red Address,$red_address,";
push (@networks, $line);
$line = "Green Address,$netsettings{'GREEN_ADDRESS'},255.255.255.255";
push (@networks, $line);
$line = "Green Network,$netsettings{'GREEN_NETADDRESS'},$netsettings{'GREEN_NETMASK'}";
push (@networks, $line);
if ($netsettings{'ORANGE_DEV'}ne ''){
$line = "Orange Address,$netsettings{'ORANGE_ADDRESS'},255.255.255.255";
push (@networks, $line);
$line = "Orange Network,$netsettings{'ORANGE_NETADDRESS'},$netsettings{'ORANGE_NETMASK'}";
push (@networks, $line);
}
if ($netsettings{'BLUE_DEV'}ne ''){
$line = "Blue Address,$netsettings{'BLUE_ADDRESS'},255.255.255.255";
push (@networks, $line);
$line = "Blue Network,$netsettings{'BLUE_NETADDRESS'},$netsettings{'BLUE_NETMASK'}";
push (@networks, $line);
}
open(FILE, "${General::swroot}/ethernet/aliases") or die 'Unable to open aliases file.';
my @current = <FILE>;
close(FILE);
my $ctr = 0;
foreach my $lne (@current)
{
if ($lne ne ''){
chomp($lne);
my @temp = split(/\,/,$lne);
if ($temp[2] eq '') {
$temp[2] = "Alias $ctr : $temp[0]";
}
$line = "$temp[2],$temp[0],";
push (@networks, $line);
$ctr++;
}
}
}
# Validate Field Entries
sub validateparams
{
if ($cgiparams{'NAME'} eq '') {
$errormessage = $Lang::tr{'nonetworkname'};
return;
}
$cgiparams{'NAME'}=&Header::cleanhtml($cgiparams{'NAME'});
unless(&General::validip($cgiparams{'IPADDRESS'})){$errormessage = $Lang::tr{'invalid ip'}; }
unless($errormessage){
my @tmp = split(/\./,$cgiparams{'IPADDRESS'});
if ($cgiparams{'NETMASK'} eq '' && $tmp[3] ne '255' && $tmp[3] ne '0'){
$cgiparams{'NETMASK'} = "255.255.255.255";
}
}
unless(&General::validmask($cgiparams{'NETMASK'})){$errormessage = $Lang::tr{'subnet is invalid'}; }
open(FILE, $filename) or die 'Unable to open custom network file.';
my @current = <FILE>;
close(FILE);
foreach my $line (@current)
{
chomp($line);
if ($line ne '') {
my @temp = split(/\,/,$line);
if ($cgiparams{'NAME'} eq $temp[1] && $cgiparams{'KEY'} ne $temp[0]) {
$errormessage=$Lang::tr{'duplicate name'};
return;
}
$key=$temp[0];
}
}
foreach $line (@networks)
{
my @temp = split(/\,/,$line);
if ($cgiparams{'NAME'} eq $temp[0]) {
$errormessage=$Lang::tr{'duplicate name'};
return;
}
}
}
#!/usr/bin/perl
#
# This file is part of the IPCop Firewall.
#
# IPCop is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# IPCop is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with IPCop; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Copyright (C) 2003-09-22 Darren Critchley <darrenc@telus.net>
#
# $Id: networks.cgi,v 1.2.2.3 2005/04/29 23:37:06 franck78 Exp $
#
use strict;
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %netsettings=();
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
my @networks=();
my $filename = "${General::swroot}/firewall/customnetworks";
&setup_default_networks();
&Header::getcgihash(\%cgiparams);
if ($cgiparams{'ACTION'} eq $Lang::tr{'add'}){
&validateparams();
unless($errormessage){
$key++; # Add one to last sequence number
open(FILE,">>$filename") or die 'Unable to open custom networks file.';
flock FILE, 2;
print FILE "$key,$cgiparams{'NAME'},$cgiparams{'IPADDRESS'},$cgiparams{'NETMASK'}\n";
close(FILE);
&General::log("$Lang::tr{'network added'}: $cgiparams{'NAME'}");
undef %cgiparams;
}
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'update'})
{
&validateparams();
# Darren Critchley - If there is an error don't waste any more processing time
if ($errormessage) { $cgiparams{'ACTION'} = $Lang::tr{'edit'}; goto UPD_ERROR; }
unless($errormessage){
open(FILE, $filename) or die 'Unable to open custom networks file.';
my @current = <FILE>;
close(FILE);
open(FILE, ">$filename") or die 'Unable to open config file.';
flock FILE, 2;
foreach my $line (@current) {
chomp($line);
my @temp = split(/\,/,$line);
if ($cgiparams{'KEY'} eq $temp[0]) {
print FILE "$cgiparams{'KEY'},$cgiparams{'NAME'},$cgiparams{'IPADDRESS'},$cgiparams{'NETMASK'}\n";
} else {
print FILE "$line\n";
}
}
close(FILE);
&General::log("$Lang::tr{'network updated'}: $cgiparams{'NAME'}");
undef %cgiparams;
}
UPD_ERROR:
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'})
{
open(FILE, "$filename") or die 'Unable to open custom networks file.';
my @current = <FILE>;
close(FILE);
unless ($errormessage)
{
foreach my $line (@current)
{
chomp($line);
my @temp = split(/\,/,$line);
if ($cgiparams{'KEY'} eq $temp[0]) {
$cgiparams{'NAME'} = $temp[1];
$cgiparams{'IPADDRESS'} = $temp[2];
$cgiparams{'NETMASK'} = $temp[3];
}
}
}
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'remove'})
{
open(FILE, $filename) or die 'Unable to open custom networks file.';
my @current = <FILE>;
close(FILE);
open(FILE, ">$filename") or die 'Unable to open custom networks file.';
flock FILE, 2;
foreach my $line (@current)
{
chomp($line);
if ($line ne '') {
my @temp = split(/\,/,$line);
if ($cgiparams{'KEY'} eq $temp[0]) {
&General::log("$Lang::tr{'network removed'}: $temp[1]");
} else {
print FILE "$temp[0],$temp[1],$temp[2],$temp[3]\n";
}
}
}
close(FILE);
undef %cgiparams;
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'reset'})
{
undef %cgiparams;
}
if ($cgiparams{'ACTION'} eq '')
{
$cgiparams{'KEY'} = '';
$cgiparams{'IPADDRESS'} = '';
$cgiparams{'NETMASK'} = '';
$cgiparams{'NAME'} = '';
}
&Header::showhttpheaders();
&Header::openpage($Lang::tr{'networks settings'}, 1, '');
&Header::openbigbox('100%', 'LEFT', '', $errormessage);
# DEBUG DEBUG
#&Header::openbox('100%', 'LEFT', 'DEBUG');
#foreach $line (keys %cgiparams) {
# print "<CLASS NAME='base'>$line = $cgiparams{$line}<BR>";
#}
#print "$ENV{'QUERY_STRING'}\n";
#print "&nbsp;</CLASS>\n";
#&Header::closebox();
if ($errormessage) {
&Header::openbox('100%', 'LEFT', $Lang::tr{'error messages'});
print "<CLASS NAME='base'><FONT COLOR='${Header::colourred}'>$errormessage\n</FONT>";
print "&nbsp;</CLASS>\n";
&Header::closebox();
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'}){
&Header::openbox('100%', 'LEFT', "$Lang::tr{'edit network'}:");
} else {
&Header::openbox('100%', 'LEFT', "$Lang::tr{'add network'}:");
}
print <<END
<FORM METHOD='POST'>
<DIV ALIGN='CENTER'>
<TABLE WIDTH='100%'>
<TR align="center">
<TD><strong>$Lang::tr{'name'}</strong></TD>
<TD><strong>$Lang::tr{'ip address'}</strong></TD>
<TD><strong>$Lang::tr{'netmask'}</strong></TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
</TR>
<TR align="center">
<TD>
<INPUT TYPE='TEXT' NAME='NAME' VALUE='$cgiparams{'NAME'}' SIZE='20' MAXLENGTH='20'>
</TD>
<TD>
<INPUT TYPE='TEXT' NAME='IPADDRESS' VALUE='$cgiparams{'IPADDRESS'}' SIZE='15' MAXLENGTH='15'>
</TD>
<TD>
<INPUT TYPE='TEXT' NAME='NETMASK' VALUE='$cgiparams{'NETMASK'}' SIZE='15' MAXLENGTH='15'>
</TD>
END
;
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'}){
# Darren Critchley - put in next release - author has authorized GPL inclusion
# print "<TD ALIGN='CENTER'><a href='ipcalc.cgi' target='_blank'>IP Calculator</a></TD>\n";
print "<TD ALIGN='CENTER'><INPUT TYPE='SUBMIT' NAME='ACTION' VALUE='$Lang::tr{'update'}'></TD>\n";
print "<INPUT TYPE='HIDDEN' NAME='KEY' VALUE='$cgiparams{'KEY'}'>\n";
print "<TD ALIGN='CENTER'><INPUT TYPE='SUBMIT' NAME='ACTION' VALUE='$Lang::tr{'reset'}'></TD>\n";
} else {
# Darren Critchley - put in next release - author has authorized GPL inclusion
# print "<TD ALIGN='CENTER'><a href='ipcalc.cgi' target='_blank'>IP Calculator</a></TD>\n";
print "<TD ALIGN='CENTER'><INPUT TYPE='SUBMIT' NAME='ACTION' VALUE='$Lang::tr{'add'}'></TD>\n";
print "<TD ALIGN='CENTER'><INPUT TYPE='SUBMIT' NAME='ACTION' VALUE='$Lang::tr{'reset'}'></TD>\n";
}
print <<END
</TR>
</TABLE>
</DIV>
</FORM>
END
;
&Header::closebox();
&Header::openbox('100%', 'LEFT', "$Lang::tr{'custom networks'}:");
print <<END
<DIV ALIGN='CENTER'>
<TABLE WIDTH='100%' ALIGN='CENTER'>
<TR align="center">
<TD><strong>$Lang::tr{'name'}</strong></TD>
<TD><strong>$Lang::tr{'ip address'}</strong></TD>
<TD><strong>$Lang::tr{'netmask'}</strong></TD>
</TR>
END
;
&display_custom_networks();
print <<END
</TABLE>
</DIV>
END
;
&Header::closebox();
&Header::openbox('100%', 'LEFT', "$Lang::tr{'default networks'}:");
print <<END
<DIV ALIGN='CENTER'>
<TABLE WIDTH='100%' ALIGN='CENTER'>
<TR align="center">
<TD><strong>$Lang::tr{'name'}</strong></TD>
<TD><strong>$Lang::tr{'ip address'}</strong></TD>
<TD><strong>$Lang::tr{'netmask'}</strong></TD>
</TR>
END
;
&display_default_networks();
print <<END
</TABLE>
</DIV>
END
;
&Header::closebox();
print "$Lang::tr{'this feature has been sponsored by'} : ";
print "<A HREF='http://www.kdi.ca/' TARGET='_blank'>Kobelt Development Inc.</A>.\n";
&Header::closebigbox();
&Header::closepage();
sub display_custom_networks
{
open(FILE, "$filename") or die 'Unable to open networks file.';
my @current = <FILE>;
close(FILE);
my $id = 0;
foreach $line (@current)
{
chomp($line);
if ($line ne ''){
my @temp = split(/\,/,$line);
# Darren Critchley highlight the row we are editing
if ( $cgiparams{'ACTION'} eq $Lang::tr{'edit'} && $cgiparams{'KEY'} eq $temp[0] ) {
print "<TR BGCOLOR='${Header::colouryellow}'>\n";
} else {
if ($id % 2) {
print "<TR BGCOLOR='${Header::table1colour}'>\n";
} else {
print "<TR BGCOLOR='${Header::table2colour}'>\n";
}
}
print "<TD>$temp[1]</TD>\n";
print "<TD ALIGN='CENTER'>$temp[2]</TD>\n";
print "<TD ALIGN='CENTER'>$temp[3]</TD>\n";
print <<END
<FORM METHOD='POST' NAME='frm$temp[0]'>
<TD ALIGN='CENTER'>
<INPUT TYPE='hidden' NAME='ACTION' VALUE='$Lang::tr{'edit'}'>
<INPUT TYPE='image' NAME='$Lang::tr{'edit'}' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' width='20' height='20' border='0'>
<INPUT TYPE='hidden' NAME='KEY' VALUE='$temp[0]'>
</TD>
</FORM>
<FORM METHOD='POST' NAME='frm$temp[0]b'>
<TD ALIGN='CENTER'>
<INPUT TYPE='hidden' NAME='ACTION' VALUE='$Lang::tr{'remove'}'>
<INPUT TYPE='image' NAME='$Lang::tr{'remove'}' src='/images/delete.gif' alt='$Lang::tr{'remove'}' title='$Lang::tr{'remove'}' width='20' height='20' border='0'>
<INPUT TYPE='hidden' NAME='KEY' VALUE='$temp[0]'>
</TD>
</FORM>
END
;
print "</TR>\n";
$id++;
}
}
}
sub display_default_networks
{
foreach $line (sort @networks)
{
my @temp = split(/\,/,$line);
if ($id % 2) {
print "<TR BGCOLOR='${Header::table1colour}'>\n";
} else {
print "<TR BGCOLOR='${Header::table2colour}'>\n";
}
print "<TD>$temp[0]</TD>\n";
print "<TD ALIGN='CENTER'>$temp[1]</TD>\n";
print "<TD ALIGN='CENTER'>$temp[2]</TD>\n";
print "</TR>\n";
$id++;
}
}
sub setup_default_networks
{
# Get current defined networks (Red, Green, Blue, Orange)
my $line = "Any,0.0.0.0,0.0.0.0";
push (@networks, $line);
$line = "localhost,127.0.0.1,255.255.255.255";
push (@networks, $line);
$line = "localnet,127.0.0.0,255.0.0.0";
push (@networks, $line);
$line = "Private Network 10.0.0.0,10.0.0.0,255.0.0.0";
push (@networks, $line);
$line = "Private Network 172.16.0.0,172.16.0.0,255.240.0.0";
push (@networks, $line);
$line = "Private Network 192.168.0.0,192.168.0.0,255.255.0.0";
push (@networks, $line);
my $red_address=`cat ${General::swroot}/red/local-ipaddress`;
$line = "Red Address,$red_address,";
push (@networks, $line);
$line = "Green Address,$netsettings{'GREEN_ADDRESS'},255.255.255.255";
push (@networks, $line);
$line = "Green Network,$netsettings{'GREEN_NETADDRESS'},$netsettings{'GREEN_NETMASK'}";
push (@networks, $line);
if ($netsettings{'ORANGE_DEV'}ne ''){
$line = "Orange Address,$netsettings{'ORANGE_ADDRESS'},255.255.255.255";
push (@networks, $line);
$line = "Orange Network,$netsettings{'ORANGE_NETADDRESS'},$netsettings{'ORANGE_NETMASK'}";
push (@networks, $line);
}
if ($netsettings{'BLUE_DEV'}ne ''){
$line = "Blue Address,$netsettings{'BLUE_ADDRESS'},255.255.255.255";
push (@networks, $line);
$line = "Blue Network,$netsettings{'BLUE_NETADDRESS'},$netsettings{'BLUE_NETMASK'}";
push (@networks, $line);
}
open(FILE, "${General::swroot}/ethernet/aliases") or die 'Unable to open aliases file.';
my @current = <FILE>;
close(FILE);
my $ctr = 0;
foreach my $lne (@current)
{
if ($lne ne ''){
chomp($lne);
my @temp = split(/\,/,$lne);
if ($temp[2] eq '') {
$temp[2] = "Alias $ctr : $temp[0]";
}
$line = "$temp[2],$temp[0],";
push (@networks, $line);
$ctr++;
}
}
}
# Validate Field Entries
sub validateparams
{
if ($cgiparams{'NAME'} eq '') {
$errormessage = $Lang::tr{'nonetworkname'};
return;
}
$cgiparams{'NAME'}=&Header::cleanhtml($cgiparams{'NAME'});
unless(&General::validip($cgiparams{'IPADDRESS'})){$errormessage = $Lang::tr{'invalid ip'}; }
unless($errormessage){
my @tmp = split(/\./,$cgiparams{'IPADDRESS'});
if ($cgiparams{'NETMASK'} eq '' && $tmp[3] ne '255' && $tmp[3] ne '0'){
$cgiparams{'NETMASK'} = "255.255.255.255";
}
}
unless(&General::validmask($cgiparams{'NETMASK'})){$errormessage = $Lang::tr{'subnet is invalid'}; }
open(FILE, $filename) or die 'Unable to open custom network file.';
my @current = <FILE>;
close(FILE);
foreach my $line (@current)
{
chomp($line);
if ($line ne '') {
my @temp = split(/\,/,$line);
if ($cgiparams{'NAME'} eq $temp[1] && $cgiparams{'KEY'} ne $temp[0]) {
$errormessage=$Lang::tr{'duplicate name'};
return;
}
$key=$temp[0];
}
}
foreach $line (@networks)
{
my @temp = split(/\,/,$line);
if ($cgiparams{'NAME'} eq $temp[0]) {
$errormessage=$Lang::tr{'duplicate name'};
return;
}
}
}

View File

@@ -1,98 +1,98 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# Copyright (C) 01-02-2002 Graham Smith <grhm@grhm.co.uk>
#
# $Id: optionsfw.cgi,v 1.1.2.10 2005/10/03 00:34:10 gespinasse Exp $
#
#
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %checked =(); # Checkbox manipulations
# File used
my $filename = "${General::swroot}/optionsfw/settings";
our %settings=();
#Settings1
$settings{'DISABLEPING'} = 'NO';
$settings{'ACTION'} = ''; # add/edit/remove
my $errormessage = '';
my $warnmessage = '';
&Header::showhttpheaders();
#Get GUI values
&Header::getcgihash(\%settings);
if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
if ($settings{'DISABLEPING'} !~ /^(NO|ONLYRED|ALL)$/) {
$errormessage = $Lang::tr{'invalid input'};
goto ERROR; }
unless ($errormessage) { # Everything is ok, save settings
&General::writehash($filename, \%settings); # Save good settings
$settings{'ACTION'} = $Lang::tr{'save'}; # Recreate 'ACTION'
system('/usr/local/bin/setfilters');
}
ERROR: # Leave the faulty field untouched
} else {
&General::readhash($filename, \%settings); # Get saved settings and reset to good if needed
}
$checked{'DISABLEPING'}{'NO'} = '';
$checked{'DISABLEPING'}{'ONLYRED'} = '';
$checked{'DISABLEPING'}{'ALL'} = '';
$checked{'DISABLEPING'}{$settings{'DISABLEPING'}} = "checked='checked'";
&Header::openpage($Lang::tr{'options fw'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>";
&Header::closebox();
}
&Header::openbox('100%', 'left', $Lang::tr{'options fw'});
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>";
print <<END
<table width='100%'>
<tr>
<td class='base' width='100%' colspan='3'><b>$Lang::tr{'ping disabled'}</b></td>
</tr>
<tr>
<td class='base'><input type='radio' name='DISABLEPING' value='NO' $checked{'DISABLEPING'}{'NO'} />$Lang::tr{'no'}</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input type='radio' name='DISABLEPING' value='ONLYRED' $checked{'DISABLEPING'}{'ONLYRED'} />$Lang::tr{'only red'}</td>
<td width='80%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
</tr>
<tr>
<td><input type='radio' name='DISABLEPING' value='ALL' $checked{'DISABLEPING'}{'ALL'} />$Lang::tr{'all interfaces'}</td>
<td class='base' width='10%' align='right'><!-- Space for future online help link --></td>
</tr>
</table>
</form>
END
;
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# Copyright (C) 01-02-2002 Graham Smith <grhm@grhm.co.uk>
#
# $Id: optionsfw.cgi,v 1.1.2.10 2005/10/03 00:34:10 gespinasse Exp $
#
#
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %checked =(); # Checkbox manipulations
# File used
my $filename = "${General::swroot}/optionsfw/settings";
our %settings=();
#Settings1
$settings{'DISABLEPING'} = 'NO';
$settings{'ACTION'} = ''; # add/edit/remove
my $errormessage = '';
my $warnmessage = '';
&Header::showhttpheaders();
#Get GUI values
&Header::getcgihash(\%settings);
if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
if ($settings{'DISABLEPING'} !~ /^(NO|ONLYRED|ALL)$/) {
$errormessage = $Lang::tr{'invalid input'};
goto ERROR; }
unless ($errormessage) { # Everything is ok, save settings
&General::writehash($filename, \%settings); # Save good settings
$settings{'ACTION'} = $Lang::tr{'save'}; # Recreate 'ACTION'
system('/usr/local/bin/setfilters');
}
ERROR: # Leave the faulty field untouched
} else {
&General::readhash($filename, \%settings); # Get saved settings and reset to good if needed
}
$checked{'DISABLEPING'}{'NO'} = '';
$checked{'DISABLEPING'}{'ONLYRED'} = '';
$checked{'DISABLEPING'}{'ALL'} = '';
$checked{'DISABLEPING'}{$settings{'DISABLEPING'}} = "checked='checked'";
&Header::openpage($Lang::tr{'options fw'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>";
&Header::closebox();
}
&Header::openbox('100%', 'left', $Lang::tr{'options fw'});
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>";
print <<END
<table width='100%'>
<tr>
<td class='base' width='100%' colspan='3'><b>$Lang::tr{'ping disabled'}</b></td>
</tr>
<tr>
<td class='base'><input type='radio' name='DISABLEPING' value='NO' $checked{'DISABLEPING'}{'NO'} />$Lang::tr{'no'}</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input type='radio' name='DISABLEPING' value='ONLYRED' $checked{'DISABLEPING'}{'ONLYRED'} />$Lang::tr{'only red'}</td>
<td width='80%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
</tr>
<tr>
<td><input type='radio' name='DISABLEPING' value='ALL' $checked{'DISABLEPING'}{'ALL'} />$Lang::tr{'all interfaces'}</td>
<td class='base' width='10%' align='right'><!-- Space for future online help link --></td>
</tr>
</table>
</form>
END
;
&Header::closebox();
&Header::closebigbox();
&Header::closepage();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,421 +1,421 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: proxy.cgi,v 1.13.2.23 2006/01/29 09:29:47 eoberlander Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %proxysettings=();
my %netsettings=();
my %mainsettings=();
my $errormessage = '';
my $NeedDoHTML = 1;
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
&General::readhash("${General::swroot}/main/settings", \%mainsettings);
&Header::showhttpheaders();
$proxysettings{'ACTION'} = '';
$proxysettings{'VALID'} = '';
$proxysettings{'UPSTREAM_PROXY'} = '';
$proxysettings{'UPSTREAM_USER'} = '';
$proxysettings{'UPSTREAM_PASSWORD'} = '';
$proxysettings{'ENABLE'} = 'off';
$proxysettings{'ENABLE_BLUE'} = 'off';
$proxysettings{'CACHE_SIZE'} = '50';
$proxysettings{'TRANSPARENT'} = 'off';
$proxysettings{'TRANSPARENT_BLUE'} = 'off';
$proxysettings{'MAX_SIZE'} = '4096';
$proxysettings{'MIN_SIZE'} = '0';
$proxysettings{'MAX_OUTGOING_SIZE'} = '0';
$proxysettings{'MAX_INCOMING_SIZE'} = '0';
$proxysettings{'LOGGING'} = 'off';
$proxysettings{'PROXY_PORT'} = '800';
$proxysettings{'EXTENSION_METHODS'} = '';
&Header::getcgihash(\%proxysettings);
my $needhup = 0;
my $cachemem = '';
if ($proxysettings{'ACTION'} eq $Lang::tr{'save'})
{
#assume error
my $configerror = 1;
if ($proxysettings{'ENABLE'} !~ /^(on|off)$/ ||
$proxysettings{'TRANSPARENT'} !~ /^(on|off)$/ ||
$proxysettings{'ENABLE_BLUE'} !~ /^(on|off)$/ ||
$proxysettings{'TRANSPARENT_BLUE'} !~ /^(on|off)$/ ) {
$errormessage = $Lang::tr{'invalid input'};
goto ERROR;
}
if (!($proxysettings{'CACHE_SIZE'} =~ /^\d+/) ||
($proxysettings{'CACHE_SIZE'} < 10))
{
$errormessage = $Lang::tr{'invalid cache size'};
goto ERROR;
}
if (!($proxysettings{'MAX_SIZE'} =~ /^\d+/))
{
$errormessage = $Lang::tr{'invalid maximum object size'};
goto ERROR;
}
if (!($proxysettings{'MIN_SIZE'} =~ /^\d+/))
{
$errormessage = $Lang::tr{'invalid minimum object size'};
goto ERROR;
}
if (!($proxysettings{'MAX_OUTGOING_SIZE'} =~ /^\d+/))
{
$errormessage = $Lang::tr{'invalid maximum outgoing size'};
goto ERROR;
}
if (!($proxysettings{'MAX_INCOMING_SIZE'} =~ /^\d+/))
{
$errormessage = $Lang::tr{'invalid maximum incoming size'};
goto ERROR;
}
if (!($proxysettings{'EXTENSION_METHODS'} =~ /^(|[A-Z0-9 _-]+)$/))
{
$errormessage = $Lang::tr{'squid extension methods invalid'};
goto ERROR;
}
# Quick parent proxy error checking of username and password info. If username password don't both exist give an error.
my $proxy1 = 'YES';
my $proxy2 = 'YES';
if (($proxysettings{'UPSTREAM_USER'} eq '')) {$proxy1 = '';}
if (($proxysettings{'UPSTREAM_PASSWORD'} eq '')) {$proxy2 = '';}
if (($proxy1 ne $proxy2))
{
$errormessage = $Lang::tr{'invalid upstream proxy username or password setting'};
goto ERROR;
}
$_ = $proxysettings{'UPSTREAM_PROXY'};
my ($remotehost, $remoteport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
$remoteport = 80 if ($remoteport eq '');
$proxysettings{'VALID'} = 'yes';
&General::writehash("${General::swroot}/proxy/settings", \%proxysettings);
#
# NAH, 03-Jan-2004
#
my @free = `/usr/bin/free`;
$free[1] =~ m/(\d+)/;
$cachemem = int $1 / 10;
if ($cachemem < 4096) {
$cachemem = 4096;
}
if ($cachemem > $proxysettings{'CACHE_SIZE'} * 40) {
$cachemem = ( $proxysettings{'CACHE_SIZE'} * 40 );
}
open(FILE, ">/${General::swroot}/proxy/squid.conf") or die "Unable to write squid.conf file";
flock(FILE, 2);
print FILE <<END
shutdown_lifetime 5 seconds
icp_port 0
http_port $netsettings{'GREEN_ADDRESS'}:$proxysettings{'PROXY_PORT'}
END
;
print FILE "\nextension_methods $proxysettings{'EXTENSION_METHODS'}\n" if ($proxysettings{'EXTENSION_METHODS'} ne '');
if ($netsettings{'BLUE_DEV'} && $proxysettings{'ENABLE_BLUE'} eq 'on') {
print FILE "http_port $netsettings{'BLUE_ADDRESS'}:$proxysettings{'PROXY_PORT'}\n";
}
print FILE <<END
acl QUERY urlpath_regex cgi-bin \\?
no_cache deny QUERY
cache_effective_user squid
cache_effective_group squid
pid_filename /var/run/squid.pid
END
;
if ($proxysettings{'LOGGING'} eq 'on')
{
print FILE <<END
cache_access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log
cache_store_log none
END
;} else {
print FILE <<END
cache_access_log /dev/null
cache_log /dev/null
cache_store_log none
END
;}
print FILE <<END
log_mime_hdrs off
forwarded_for off
END
;
#Insert acl file and replace __VAR__ with correct values
my $blue_net = ''; #BLUE empty by default
my $blue_ip = '';
if ($netsettings{'BLUE_DEV'} && $proxysettings{'ENABLE_BLUE'} eq 'on') {
$blue_net = "$netsettings{'BLUE_NETADDRESS'}/$netsettings{'BLUE_NETMASK'}";
$blue_ip = "$netsettings{'BLUE_ADDRESS'}";
}
open (ACL, "${General::swroot}/proxy/acl") or die "Unable to open ACL list file";
while (<ACL>) {
$_ =~ s/__GREEN_IP__/$netsettings{'GREEN_ADDRESS'}/;
$_ =~ s/__GREEN_NET__/$netsettings{'GREEN_NETADDRESS'}\/$netsettings{'GREEN_NETMASK'}/;
$_ =~ s/__BLUE_IP__/$blue_ip/;
$_ =~ s/__BLUE_NET__/$blue_net/;
$_ =~ s/__PROXY_PORT__/$proxysettings{'PROXY_PORT'}/;
print FILE $_;
}
close (ACL);
# This value is in bytes, so we must turn it from KB into bytes
my $max_incoming_size = $proxysettings{'MAX_INCOMING_SIZE'} * 1024;
print FILE <<END
maximum_object_size $proxysettings{'MAX_SIZE'} KB
minimum_object_size $proxysettings{'MIN_SIZE'} KB
cache_mem $cachemem KB
cache_dir aufs /var/log/cache $proxysettings{'CACHE_SIZE'} 16 256
request_body_max_size $proxysettings{'MAX_OUTGOING_SIZE'} KB
reply_body_max_size $max_incoming_size allow all
visible_hostname $mainsettings{'HOSTNAME'}.$mainsettings{'DOMAINNAME'}
END
;
# Write the parent proxy info, if needed.
if ($remotehost ne '')
{
# Enter authentication for the parent cache (format is login=user:password)
if ($proxy1 eq 'YES') {
print FILE <<END
cache_peer $remotehost parent $remoteport 3130 login=$proxysettings{'UPSTREAM_USER'}:$proxysettings{'UPSTREAM_PASSWORD'} default no-query
END
;
} else {
# Not using authentication with the parent cache
print FILE <<END
cache_peer $remotehost parent $remoteport 3130 default no-query
END
;
}
print FILE "never_direct allow all\n";
}
if (($proxysettings{'TRANSPARENT'} eq 'on') ||
($proxysettings{'TRANSPARENT_BLUE'} eq 'on'))
{
print FILE <<END
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
END
;
}
close FILE;
$configerror = 0; ## a good config!
ERROR:
unlink "${General::swroot}/proxy/enable";
unlink "${General::swroot}/proxy/transparent";
unlink "${General::swroot}/proxy/enable_blue";
unlink "${General::swroot}/proxy/transparent_blue";
&DoHTML;
if (!$configerror)
{
if ($proxysettings{'ENABLE'} eq 'on') {
system ('/bin/touch', "${General::swroot}/proxy/enable"); }
if ($proxysettings{'TRANSPARENT'} eq 'on') {
system ('/bin/touch', "${General::swroot}/proxy/transparent"); }
if ($proxysettings{'ENABLE_BLUE'} eq 'on') {
system ('/bin/touch', "${General::swroot}/proxy/enable_blue"); }
if ($proxysettings{'TRANSPARENT_BLUE'} eq 'on') {
system ('/bin/touch', "${General::swroot}/proxy/transparent_blue"); }
system('/usr/local/bin/restartsquid');
}
}
if ($proxysettings{'ACTION'} eq $Lang::tr{'clear cache'})
{
&DoHTML;
system('/usr/local/bin/restartsquid','-f');
}
&DoHTML if $NeedDoHTML;
sub DoHTML {
$NeedDoHTML = 0;
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
my %checked=();
$checked{'ENABLE'}{'off'} = '';
$checked{'ENABLE'}{'on'} = '';
$checked{'ENABLE'}{$proxysettings{'ENABLE'}} = "checked='checked'";
$checked{'TRANSPARENT'}{'off'} = '';
$checked{'TRANSPARENT'}{'on'} = '';
$checked{'TRANSPARENT'}{$proxysettings{'TRANSPARENT'}} = "checked='checked'";
$checked{'ENABLE_BLUE'}{'off'} = '';
$checked{'ENABLE_BLUE'}{'on'} = '';
$checked{'ENABLE_BLUE'}{$proxysettings{'ENABLE_BLUE'}} = "checked='checked'";
$checked{'TRANSPARENT_BLUE'}{'off'} = '';
$checked{'TRANSPARENT_BLUE'}{'on'} = '';
$checked{'TRANSPARENT_BLUE'}{$proxysettings{'TRANSPARENT_BLUE'}} = "checked='checked'";
$checked{'LOGGING'}{'off'} = '';
$checked{'LOGGING'}{'on'} = '';
$checked{'LOGGING'}{$proxysettings{'LOGGING'}} = "checked='checked'";
&Header::openpage($Lang::tr{'web proxy configuration'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>\n";
&Header::closebox();
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
&Header::openbox('100%', 'left', "$Lang::tr{'web proxy'}:");
print <<END
<table width='100%'>
<tr>
<td width='25%' class='base'>$Lang::tr{'enabled on'} <font color="${Header::colourgreen}">Green</font>:</td>
<td width='15%'><input type='checkbox' name='ENABLE' $checked{'ENABLE'}{'on'} /></td>
<td width='30%' class='base'>$Lang::tr{'upstream proxy host:port'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
<td width='30%'><input type='text' name='UPSTREAM_PROXY' value='$proxysettings{'UPSTREAM_PROXY'}' /></td>
</tr>
<tr>
<td class='base'>$Lang::tr{'transparent on'} <font color="${Header::colourgreen}">Green</font>:</td>
<td><input type='checkbox' name='TRANSPARENT' $checked{'TRANSPARENT'}{'on'} /></td>
<td class='base'>$Lang::tr{'upstream username'}&nbsp;<img src='/blob.gif' alt='*' /></td>
<td><input type='text' name='UPSTREAM_USER' value='$proxysettings{'UPSTREAM_USER'}' /></td>
</tr>
<tr>
END
;
if ($netsettings{'BLUE_DEV'}) {
print "<td class='base'>$Lang::tr{'enabled on'} <font color='${Header::colourblue}'>Blue</font>:</td>";
print "<td><input type='checkbox' name='ENABLE_BLUE' $checked{'ENABLE_BLUE'}{'on'} /></td>";
} else {
print "<td colspan='2'>&nbsp;</td>";
}
print <<END
<td class='base'>$Lang::tr{'upstream password'}&nbsp;<img src='/blob.gif' alt='*' /></td>
<td><input type='password' name='UPSTREAM_PASSWORD' value='$proxysettings{'UPSTREAM_PASSWORD'}' /></td>
</tr>
<tr>
END
;
if ($netsettings{'BLUE_DEV'}) {
print "<td class='base'>$Lang::tr{'transparent on'} <font color='${Header::colourblue}'>Blue</font>:</td>";
print "<td><input type='checkbox' name='TRANSPARENT_BLUE' $checked{'TRANSPARENT_BLUE'}{'on'} /></td>";
} else {
print "<td colspan='2'>&nbsp;</td>";
}
print <<END
<td class='base'>$Lang::tr{'proxy port'}:</td>
<td><input type='text' name='PROXY_PORT' value='$proxysettings{'PROXY_PORT'}' size='5' /></td>
</tr>
<tr>
<td class='base'>$Lang::tr{'log enabled'}:</td>
<td><input type='checkbox' name='LOGGING' $checked{'LOGGING'}{'on'} /></td>
<td>$Lang::tr{'squid extension methods'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
<td><input type='text' name='EXTENSION_METHODS' value='$proxysettings{'EXTENSION_METHODS'}' /></td>
</tr>
<!--TAG FOR ADDONS-->
<tr>
<td colspan='4'><hr /><b>$Lang::tr{'cache management'}</b></td>
</tr>
<tr>
<td width='25%' class='base'>$Lang::tr{'cache size'}</td>
<td><input type='text' name='CACHE_SIZE' value='$proxysettings{'CACHE_SIZE'}' size='5' /></td>
</tr>
<tr>
<td class='base'>$Lang::tr{'min size'}</td>
<td><input type='text' name='MIN_SIZE' value='$proxysettings{'MIN_SIZE'}' size='5' /></td>
<td class='base'>$Lang::tr{'max size'}</td>
<td><input type='text' name='MAX_SIZE' value='$proxysettings{'MAX_SIZE'}' size='5' /></td>
</tr>
<tr>
<td colspan='4'><hr /><b>$Lang::tr{'transfer limits'}</b></td>
</tr>
<tr>
<td class='base'>$Lang::tr{'max incoming size'}</td>
<td><input type='text' name='MAX_INCOMING_SIZE' value='$proxysettings{'MAX_INCOMING_SIZE'}' size='5' /></td>
<td class='base'>$Lang::tr{'max outgoing size'}</td>
<td><input type='text' name='MAX_OUTGOING_SIZE' value='$proxysettings{'MAX_OUTGOING_SIZE'}' size='5' /></td>
</tr>
</table>
<table width='100%'>
<hr />
<tr>
<td width='28%'>
<img src='/blob.gif' align='top' alt='*' />&nbsp;
<font class='base'>$Lang::tr{'this field may be blank'}</font>
</td>
<td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'clear cache'}' /></td>
<td width=33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
<td width='5%' align='right'>
<a href='${General::adminmanualurl}/services.html#services_webproxy' target='_blank'>
<img src='/images/web-support.png' title='$Lang::tr{'online help en'}' /></a></td>
</tr>
</table>
END
;
&Header::closebox();
print "</form>\n";
&Header::closebigbox();
&Header::closepage();
} # end sub DoHTML
1
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: proxy.cgi,v 1.13.2.23 2006/01/29 09:29:47 eoberlander Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %proxysettings=();
my %netsettings=();
my %mainsettings=();
my $errormessage = '';
my $NeedDoHTML = 1;
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
&General::readhash("${General::swroot}/main/settings", \%mainsettings);
&Header::showhttpheaders();
$proxysettings{'ACTION'} = '';
$proxysettings{'VALID'} = '';
$proxysettings{'UPSTREAM_PROXY'} = '';
$proxysettings{'UPSTREAM_USER'} = '';
$proxysettings{'UPSTREAM_PASSWORD'} = '';
$proxysettings{'ENABLE'} = 'off';
$proxysettings{'ENABLE_BLUE'} = 'off';
$proxysettings{'CACHE_SIZE'} = '50';
$proxysettings{'TRANSPARENT'} = 'off';
$proxysettings{'TRANSPARENT_BLUE'} = 'off';
$proxysettings{'MAX_SIZE'} = '4096';
$proxysettings{'MIN_SIZE'} = '0';
$proxysettings{'MAX_OUTGOING_SIZE'} = '0';
$proxysettings{'MAX_INCOMING_SIZE'} = '0';
$proxysettings{'LOGGING'} = 'off';
$proxysettings{'PROXY_PORT'} = '800';
$proxysettings{'EXTENSION_METHODS'} = '';
&Header::getcgihash(\%proxysettings);
my $needhup = 0;
my $cachemem = '';
if ($proxysettings{'ACTION'} eq $Lang::tr{'save'})
{
#assume error
my $configerror = 1;
if ($proxysettings{'ENABLE'} !~ /^(on|off)$/ ||
$proxysettings{'TRANSPARENT'} !~ /^(on|off)$/ ||
$proxysettings{'ENABLE_BLUE'} !~ /^(on|off)$/ ||
$proxysettings{'TRANSPARENT_BLUE'} !~ /^(on|off)$/ ) {
$errormessage = $Lang::tr{'invalid input'};
goto ERROR;
}
if (!($proxysettings{'CACHE_SIZE'} =~ /^\d+/) ||
($proxysettings{'CACHE_SIZE'} < 10))
{
$errormessage = $Lang::tr{'invalid cache size'};
goto ERROR;
}
if (!($proxysettings{'MAX_SIZE'} =~ /^\d+/))
{
$errormessage = $Lang::tr{'invalid maximum object size'};
goto ERROR;
}
if (!($proxysettings{'MIN_SIZE'} =~ /^\d+/))
{
$errormessage = $Lang::tr{'invalid minimum object size'};
goto ERROR;
}
if (!($proxysettings{'MAX_OUTGOING_SIZE'} =~ /^\d+/))
{
$errormessage = $Lang::tr{'invalid maximum outgoing size'};
goto ERROR;
}
if (!($proxysettings{'MAX_INCOMING_SIZE'} =~ /^\d+/))
{
$errormessage = $Lang::tr{'invalid maximum incoming size'};
goto ERROR;
}
if (!($proxysettings{'EXTENSION_METHODS'} =~ /^(|[A-Z0-9 _-]+)$/))
{
$errormessage = $Lang::tr{'squid extension methods invalid'};
goto ERROR;
}
# Quick parent proxy error checking of username and password info. If username password don't both exist give an error.
my $proxy1 = 'YES';
my $proxy2 = 'YES';
if (($proxysettings{'UPSTREAM_USER'} eq '')) {$proxy1 = '';}
if (($proxysettings{'UPSTREAM_PASSWORD'} eq '')) {$proxy2 = '';}
if (($proxy1 ne $proxy2))
{
$errormessage = $Lang::tr{'invalid upstream proxy username or password setting'};
goto ERROR;
}
$_ = $proxysettings{'UPSTREAM_PROXY'};
my ($remotehost, $remoteport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
$remoteport = 80 if ($remoteport eq '');
$proxysettings{'VALID'} = 'yes';
&General::writehash("${General::swroot}/proxy/settings", \%proxysettings);
#
# NAH, 03-Jan-2004
#
my @free = `/usr/bin/free`;
$free[1] =~ m/(\d+)/;
$cachemem = int $1 / 10;
if ($cachemem < 4096) {
$cachemem = 4096;
}
if ($cachemem > $proxysettings{'CACHE_SIZE'} * 40) {
$cachemem = ( $proxysettings{'CACHE_SIZE'} * 40 );
}
open(FILE, ">/${General::swroot}/proxy/squid.conf") or die "Unable to write squid.conf file";
flock(FILE, 2);
print FILE <<END
shutdown_lifetime 5 seconds
icp_port 0
http_port $netsettings{'GREEN_ADDRESS'}:$proxysettings{'PROXY_PORT'}
END
;
print FILE "\nextension_methods $proxysettings{'EXTENSION_METHODS'}\n" if ($proxysettings{'EXTENSION_METHODS'} ne '');
if ($netsettings{'BLUE_DEV'} && $proxysettings{'ENABLE_BLUE'} eq 'on') {
print FILE "http_port $netsettings{'BLUE_ADDRESS'}:$proxysettings{'PROXY_PORT'}\n";
}
print FILE <<END
acl QUERY urlpath_regex cgi-bin \\?
no_cache deny QUERY
cache_effective_user squid
cache_effective_group squid
pid_filename /var/run/squid.pid
END
;
if ($proxysettings{'LOGGING'} eq 'on')
{
print FILE <<END
cache_access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log
cache_store_log none
END
;} else {
print FILE <<END
cache_access_log /dev/null
cache_log /dev/null
cache_store_log none
END
;}
print FILE <<END
log_mime_hdrs off
forwarded_for off
END
;
#Insert acl file and replace __VAR__ with correct values
my $blue_net = ''; #BLUE empty by default
my $blue_ip = '';
if ($netsettings{'BLUE_DEV'} && $proxysettings{'ENABLE_BLUE'} eq 'on') {
$blue_net = "$netsettings{'BLUE_NETADDRESS'}/$netsettings{'BLUE_NETMASK'}";
$blue_ip = "$netsettings{'BLUE_ADDRESS'}";
}
open (ACL, "${General::swroot}/proxy/acl") or die "Unable to open ACL list file";
while (<ACL>) {
$_ =~ s/__GREEN_IP__/$netsettings{'GREEN_ADDRESS'}/;
$_ =~ s/__GREEN_NET__/$netsettings{'GREEN_NETADDRESS'}\/$netsettings{'GREEN_NETMASK'}/;
$_ =~ s/__BLUE_IP__/$blue_ip/;
$_ =~ s/__BLUE_NET__/$blue_net/;
$_ =~ s/__PROXY_PORT__/$proxysettings{'PROXY_PORT'}/;
print FILE $_;
}
close (ACL);
# This value is in bytes, so we must turn it from KB into bytes
my $max_incoming_size = $proxysettings{'MAX_INCOMING_SIZE'} * 1024;
print FILE <<END
maximum_object_size $proxysettings{'MAX_SIZE'} KB
minimum_object_size $proxysettings{'MIN_SIZE'} KB
cache_mem $cachemem KB
cache_dir aufs /var/log/cache $proxysettings{'CACHE_SIZE'} 16 256
request_body_max_size $proxysettings{'MAX_OUTGOING_SIZE'} KB
reply_body_max_size $max_incoming_size allow all
visible_hostname $mainsettings{'HOSTNAME'}.$mainsettings{'DOMAINNAME'}
END
;
# Write the parent proxy info, if needed.
if ($remotehost ne '')
{
# Enter authentication for the parent cache (format is login=user:password)
if ($proxy1 eq 'YES') {
print FILE <<END
cache_peer $remotehost parent $remoteport 3130 login=$proxysettings{'UPSTREAM_USER'}:$proxysettings{'UPSTREAM_PASSWORD'} default no-query
END
;
} else {
# Not using authentication with the parent cache
print FILE <<END
cache_peer $remotehost parent $remoteport 3130 default no-query
END
;
}
print FILE "never_direct allow all\n";
}
if (($proxysettings{'TRANSPARENT'} eq 'on') ||
($proxysettings{'TRANSPARENT_BLUE'} eq 'on'))
{
print FILE <<END
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
END
;
}
close FILE;
$configerror = 0; ## a good config!
ERROR:
unlink "${General::swroot}/proxy/enable";
unlink "${General::swroot}/proxy/transparent";
unlink "${General::swroot}/proxy/enable_blue";
unlink "${General::swroot}/proxy/transparent_blue";
&DoHTML;
if (!$configerror)
{
if ($proxysettings{'ENABLE'} eq 'on') {
system ('/bin/touch', "${General::swroot}/proxy/enable"); }
if ($proxysettings{'TRANSPARENT'} eq 'on') {
system ('/bin/touch', "${General::swroot}/proxy/transparent"); }
if ($proxysettings{'ENABLE_BLUE'} eq 'on') {
system ('/bin/touch', "${General::swroot}/proxy/enable_blue"); }
if ($proxysettings{'TRANSPARENT_BLUE'} eq 'on') {
system ('/bin/touch', "${General::swroot}/proxy/transparent_blue"); }
system('/usr/local/bin/restartsquid');
}
}
if ($proxysettings{'ACTION'} eq $Lang::tr{'clear cache'})
{
&DoHTML;
system('/usr/local/bin/restartsquid','-f');
}
&DoHTML if $NeedDoHTML;
sub DoHTML {
$NeedDoHTML = 0;
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
my %checked=();
$checked{'ENABLE'}{'off'} = '';
$checked{'ENABLE'}{'on'} = '';
$checked{'ENABLE'}{$proxysettings{'ENABLE'}} = "checked='checked'";
$checked{'TRANSPARENT'}{'off'} = '';
$checked{'TRANSPARENT'}{'on'} = '';
$checked{'TRANSPARENT'}{$proxysettings{'TRANSPARENT'}} = "checked='checked'";
$checked{'ENABLE_BLUE'}{'off'} = '';
$checked{'ENABLE_BLUE'}{'on'} = '';
$checked{'ENABLE_BLUE'}{$proxysettings{'ENABLE_BLUE'}} = "checked='checked'";
$checked{'TRANSPARENT_BLUE'}{'off'} = '';
$checked{'TRANSPARENT_BLUE'}{'on'} = '';
$checked{'TRANSPARENT_BLUE'}{$proxysettings{'TRANSPARENT_BLUE'}} = "checked='checked'";
$checked{'LOGGING'}{'off'} = '';
$checked{'LOGGING'}{'on'} = '';
$checked{'LOGGING'}{$proxysettings{'LOGGING'}} = "checked='checked'";
&Header::openpage($Lang::tr{'web proxy configuration'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>\n";
&Header::closebox();
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
&Header::openbox('100%', 'left', "$Lang::tr{'web proxy'}:");
print <<END
<table width='100%'>
<tr>
<td width='25%' class='base'>$Lang::tr{'enabled on'} <font color="${Header::colourgreen}">Green</font>:</td>
<td width='15%'><input type='checkbox' name='ENABLE' $checked{'ENABLE'}{'on'} /></td>
<td width='30%' class='base'>$Lang::tr{'upstream proxy host:port'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
<td width='30%'><input type='text' name='UPSTREAM_PROXY' value='$proxysettings{'UPSTREAM_PROXY'}' /></td>
</tr>
<tr>
<td class='base'>$Lang::tr{'transparent on'} <font color="${Header::colourgreen}">Green</font>:</td>
<td><input type='checkbox' name='TRANSPARENT' $checked{'TRANSPARENT'}{'on'} /></td>
<td class='base'>$Lang::tr{'upstream username'}&nbsp;<img src='/blob.gif' alt='*' /></td>
<td><input type='text' name='UPSTREAM_USER' value='$proxysettings{'UPSTREAM_USER'}' /></td>
</tr>
<tr>
END
;
if ($netsettings{'BLUE_DEV'}) {
print "<td class='base'>$Lang::tr{'enabled on'} <font color='${Header::colourblue}'>Blue</font>:</td>";
print "<td><input type='checkbox' name='ENABLE_BLUE' $checked{'ENABLE_BLUE'}{'on'} /></td>";
} else {
print "<td colspan='2'>&nbsp;</td>";
}
print <<END
<td class='base'>$Lang::tr{'upstream password'}&nbsp;<img src='/blob.gif' alt='*' /></td>
<td><input type='password' name='UPSTREAM_PASSWORD' value='$proxysettings{'UPSTREAM_PASSWORD'}' /></td>
</tr>
<tr>
END
;
if ($netsettings{'BLUE_DEV'}) {
print "<td class='base'>$Lang::tr{'transparent on'} <font color='${Header::colourblue}'>Blue</font>:</td>";
print "<td><input type='checkbox' name='TRANSPARENT_BLUE' $checked{'TRANSPARENT_BLUE'}{'on'} /></td>";
} else {
print "<td colspan='2'>&nbsp;</td>";
}
print <<END
<td class='base'>$Lang::tr{'proxy port'}:</td>
<td><input type='text' name='PROXY_PORT' value='$proxysettings{'PROXY_PORT'}' size='5' /></td>
</tr>
<tr>
<td class='base'>$Lang::tr{'log enabled'}:</td>
<td><input type='checkbox' name='LOGGING' $checked{'LOGGING'}{'on'} /></td>
<td>$Lang::tr{'squid extension methods'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
<td><input type='text' name='EXTENSION_METHODS' value='$proxysettings{'EXTENSION_METHODS'}' /></td>
</tr>
<!--TAG FOR ADDONS-->
<tr>
<td colspan='4'><hr /><b>$Lang::tr{'cache management'}</b></td>
</tr>
<tr>
<td width='25%' class='base'>$Lang::tr{'cache size'}</td>
<td><input type='text' name='CACHE_SIZE' value='$proxysettings{'CACHE_SIZE'}' size='5' /></td>
</tr>
<tr>
<td class='base'>$Lang::tr{'min size'}</td>
<td><input type='text' name='MIN_SIZE' value='$proxysettings{'MIN_SIZE'}' size='5' /></td>
<td class='base'>$Lang::tr{'max size'}</td>
<td><input type='text' name='MAX_SIZE' value='$proxysettings{'MAX_SIZE'}' size='5' /></td>
</tr>
<tr>
<td colspan='4'><hr /><b>$Lang::tr{'transfer limits'}</b></td>
</tr>
<tr>
<td class='base'>$Lang::tr{'max incoming size'}</td>
<td><input type='text' name='MAX_INCOMING_SIZE' value='$proxysettings{'MAX_INCOMING_SIZE'}' size='5' /></td>
<td class='base'>$Lang::tr{'max outgoing size'}</td>
<td><input type='text' name='MAX_OUTGOING_SIZE' value='$proxysettings{'MAX_OUTGOING_SIZE'}' size='5' /></td>
</tr>
</table>
<table width='100%'>
<hr />
<tr>
<td width='28%'>
<img src='/blob.gif' align='top' alt='*' />&nbsp;
<font class='base'>$Lang::tr{'this field may be blank'}</font>
</td>
<td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'clear cache'}' /></td>
<td width=33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
<td width='5%' align='right'>
<a href='${General::adminmanualurl}/services.html#services_webproxy' target='_blank'>
<img src='/images/web-support.png' title='$Lang::tr{'online help en'}' /></a></td>
</tr>
</table>
END
;
&Header::closebox();
print "</form>\n";
&Header::closebigbox();
&Header::closepage();
} # end sub DoHTML
1

View File

@@ -1,63 +1,63 @@
#!/usr/bin/perl
#
# (c) 2002 Robert Wood <rob@empathymp3.co.uk>
#
# $Id: proxygraphs.cgi,v 1.2.2.5 2005/02/22 22:21:56 gespinasse Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %cgiparams=();
my %pppsettings=();
my %netsettings=();
my @graphs=();
&Header::showhttpheaders();
my $dir = "/home/httpd/html/sgraph";
$cgiparams{'ACTION'} = '';
&Header::getcgihash(\%cgiparams);
my $sgraphdir = "/home/httpd/html/sgraph";
&Header::openpage($Lang::tr{'proxy access graphs'}, 1, '');
&Header::openbigbox('100%', 'left');
&Header::openbox('100%', 'left', $Lang::tr{'proxy access graphs'} . ":" );
if (open(IPACHTML, "$sgraphdir/index.html"))
{
my $skip = 1;
while (<IPACHTML>)
{
$skip = 1 if /^<HR>$/;
if ($skip)
{
$skip = 0 if /<H1>/;
next;
}
s/<IMG SRC=([^"'>]+)>/<img src='\/sgraph\/$1' alt='Graph' \/>/;
s/<HR>/<hr \/>/g;
s/<BR>/<br \/>/g;
s/<([^>]*)>/\L<$1>\E/g;
s/(size|align|border|color)=([^'"> ]+)/$1='$2'/g;
print;
}
close(IPACHTML);
}
else {
print $Lang::tr{'no information available'}; }
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
#!/usr/bin/perl
#
# (c) 2002 Robert Wood <rob@empathymp3.co.uk>
#
# $Id: proxygraphs.cgi,v 1.2.2.5 2005/02/22 22:21:56 gespinasse Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %cgiparams=();
my %pppsettings=();
my %netsettings=();
my @graphs=();
&Header::showhttpheaders();
my $dir = "/home/httpd/html/sgraph";
$cgiparams{'ACTION'} = '';
&Header::getcgihash(\%cgiparams);
my $sgraphdir = "/home/httpd/html/sgraph";
&Header::openpage($Lang::tr{'proxy access graphs'}, 1, '');
&Header::openbigbox('100%', 'left');
&Header::openbox('100%', 'left', $Lang::tr{'proxy access graphs'} . ":" );
if (open(IPACHTML, "$sgraphdir/index.html"))
{
my $skip = 1;
while (<IPACHTML>)
{
$skip = 1 if /^<HR>$/;
if ($skip)
{
$skip = 0 if /<H1>/;
next;
}
s/<IMG SRC=([^"'>]+)>/<img src='\/sgraph\/$1' alt='Graph' \/>/;
s/<HR>/<hr \/>/g;
s/<BR>/<br \/>/g;
s/<([^>]*)>/\L<$1>\E/g;
s/(size|align|border|color)=([^'"> ]+)/$1='$2'/g;
print;
}
close(IPACHTML);
}
else {
print $Lang::tr{'no information available'}; }
&Header::closebox();
&Header::closebigbox();
&Header::closepage();

View File

@@ -1,180 +1,180 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: remote.cgi,v 1.6.2.8 2005/02/22 22:21:56 gespinasse Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %remotesettings=();
my %checked=();
my $errormessage='';
&Header::showhttpheaders();
$remotesettings{'ENABLE_SSH'} = 'off';
$remotesettings{'ENABLE_SSH_PROTOCOL1'} = 'off';
$remotesettings{'ENABLE_SSH_PORTFW'} = 'off';
$remotesettings{'ACTION'} = '';
&Header::getcgihash(\%remotesettings);
if ($remotesettings{'ACTION'} eq $Lang::tr{'save'})
{
# not existing here indicates the box is unticked
$remotesettings{'ENABLE_SSH_PASSWORDS'} = 'off' unless exists $remotesettings{'ENABLE_SSH_PASSWORDS'};
$remotesettings{'ENABLE_SSH_KEYS'} = 'off' unless exists $remotesettings{'ENABLE_SSH_KEYS'};
&General::writehash("${General::swroot}/remote/settings", \%remotesettings);
if ($remotesettings{'ENABLE_SSH'} eq 'on')
{
&General::log($Lang::tr{'ssh is enabled'});
if ($remotesettings{'ENABLE_SSH_PASSWORDS'} eq 'off'
and $remotesettings{'ENABLE_SSH_KEYS'} eq 'off')
{
$errormessage = $Lang::tr{'ssh no auth'};
}
system ('/bin/touch', "${General::swroot}/remote/enablessh");
}
else
{
&General::log($Lang::tr{'ssh is disabled'});
unlink "${General::swroot}/remote/enablessh";
}
if ($remotesettings{'ENABLE_SSH_PROTOCOL1'} eq 'on')
{
&General::log($Lang::tr{'ssh1 enabled'});
}
else
{
&General::log($Lang::tr{'ssh1 disabled'});
}
system('/usr/local/bin/restartssh') == 0
or $errormessage = "$Lang::tr{'bad return code'} " . $?/256;
}
&General::readhash("${General::swroot}/remote/settings", \%remotesettings);
# not existing here means they're undefined and the default value should be
# used
$remotesettings{'ENABLE_SSH_PASSWORDS'} = 'on' unless exists $remotesettings{'ENABLE_SSH_PASSWORDS'};
$remotesettings{'ENABLE_SSH_KEYS'} = 'on' unless exists $remotesettings{'ENABLE_SSH_KEYS'};
$checked{'ENABLE_SSH'}{'off'} = '';
$checked{'ENABLE_SSH'}{'on'} = '';
$checked{'ENABLE_SSH'}{$remotesettings{'ENABLE_SSH'}} = "checked='checked'";
$checked{'ENABLE_SSH_PROTOCOL1'}{'off'} = '';
$checked{'ENABLE_SSH_PROTOCOL1'}{'on'} = '';
$checked{'ENABLE_SSH_PROTOCOL1'}{$remotesettings{'ENABLE_SSH_PROTOCOL1'}} = "checked='checked'";
$checked{'ENABLE_SSH_PORTFW'}{'off'} = '';
$checked{'ENABLE_SSH_PORTFW'}{'on'} = '';
$checked{'ENABLE_SSH_PORTFW'}{$remotesettings{'ENABLE_SSH_PORTFW'}} = "checked='checked'";
$checked{'ENABLE_SSH_PASSWORDS'}{'off'} = '';
$checked{'ENABLE_SSH_PASSWORDS'}{'on'} = '';
$checked{'ENABLE_SSH_PASSWORDS'}{$remotesettings{'ENABLE_SSH_PASSWORDS'}} = "checked='checked'";
$checked{'ENABLE_SSH_KEYS'}{'off'} = '';
$checked{'ENABLE_SSH_KEYS'}{'on'} = '';
$checked{'ENABLE_SSH_KEYS'}{$remotesettings{'ENABLE_SSH_KEYS'}} = "checked='checked'";
&Header::openpage($Lang::tr{'remote access'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<FONT CLASS='base'>$errormessage&nbsp;</FONT>\n";
&Header::closebox();
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
&Header::openbox('100%', 'left', 'SSH:');
print <<END
<table width='100%'>
<tr>
<td><input type='checkbox' name='ENABLE_SSH' $checked{'ENABLE_SSH'}{'on'} /></td>
<td class='base' colspan='2'>$Lang::tr{'ssh access'}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type='checkbox' name='ENABLE_SSH_PROTOCOL1' $checked{'ENABLE_SSH_PROTOCOL1'}{'on'} /></td>
<td width='100%' class='base'>$Lang::tr{'ssh1 support'}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type='checkbox' name='ENABLE_SSH_PORTFW' $checked{'ENABLE_SSH_PORTFW'}{'on'} /></td>
<td width='100%' class='base'>$Lang::tr{'ssh portfw'}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type='checkbox' name='ENABLE_SSH_PASSWORDS' $checked{'ENABLE_SSH_PASSWORDS'}{'on'} /></td>
<td width='100%' class='base'>$Lang::tr{'ssh passwords'}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type='checkbox' name='ENABLE_SSH_KEYS' $checked{'ENABLE_SSH_KEYS'}{'on'} /></td>
<td width='100%' class='base'>$Lang::tr{'ssh keys'}</td>
</tr>
<tr>
<td colspan='3' align='center'><hr /><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
</tr>
</table>
END
;
&Header::closebox();
print "</form>\n";
&Header::openbox('100%', 'left', $Lang::tr{'ssh host keys'});
print "<table>\n";
print <<END
<tr><td class='boldbase'><b>$Lang::tr{'ssh key'}</b></td>
<td class='boldbase'><b>$Lang::tr{'ssh fingerprint'}</b></td>
<td class='boldbase'><b>$Lang::tr{'ssh key size'}</b></td></tr>
END
;
&viewkey("/etc/ssh/ssh_host_key.pub","RSA1");
&viewkey("/etc/ssh/ssh_host_rsa_key.pub","RSA2");
&viewkey("/etc/ssh/ssh_host_dsa_key.pub","DSA");
print "</table>\n";
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
sub viewkey
{
my $key = $_[0];
my $name = $_[1];
if ( -e $key )
{
my @temp = split(/ /,`/usr/bin/ssh-keygen -l -f $key`);
my $keysize = &Header::cleanhtml($temp[0],"y");
my $fingerprint = &Header::cleanhtml($temp[1],"y");
print "<tr><td>$key ($name)</td><td><code>$fingerprint</code></td><td align='center'>$keysize</td></tr>\n";
}
}
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: remote.cgi,v 1.6.2.8 2005/02/22 22:21:56 gespinasse Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %remotesettings=();
my %checked=();
my $errormessage='';
&Header::showhttpheaders();
$remotesettings{'ENABLE_SSH'} = 'off';
$remotesettings{'ENABLE_SSH_PROTOCOL1'} = 'off';
$remotesettings{'ENABLE_SSH_PORTFW'} = 'off';
$remotesettings{'ACTION'} = '';
&Header::getcgihash(\%remotesettings);
if ($remotesettings{'ACTION'} eq $Lang::tr{'save'})
{
# not existing here indicates the box is unticked
$remotesettings{'ENABLE_SSH_PASSWORDS'} = 'off' unless exists $remotesettings{'ENABLE_SSH_PASSWORDS'};
$remotesettings{'ENABLE_SSH_KEYS'} = 'off' unless exists $remotesettings{'ENABLE_SSH_KEYS'};
&General::writehash("${General::swroot}/remote/settings", \%remotesettings);
if ($remotesettings{'ENABLE_SSH'} eq 'on')
{
&General::log($Lang::tr{'ssh is enabled'});
if ($remotesettings{'ENABLE_SSH_PASSWORDS'} eq 'off'
and $remotesettings{'ENABLE_SSH_KEYS'} eq 'off')
{
$errormessage = $Lang::tr{'ssh no auth'};
}
system ('/bin/touch', "${General::swroot}/remote/enablessh");
}
else
{
&General::log($Lang::tr{'ssh is disabled'});
unlink "${General::swroot}/remote/enablessh";
}
if ($remotesettings{'ENABLE_SSH_PROTOCOL1'} eq 'on')
{
&General::log($Lang::tr{'ssh1 enabled'});
}
else
{
&General::log($Lang::tr{'ssh1 disabled'});
}
system('/usr/local/bin/restartssh') == 0
or $errormessage = "$Lang::tr{'bad return code'} " . $?/256;
}
&General::readhash("${General::swroot}/remote/settings", \%remotesettings);
# not existing here means they're undefined and the default value should be
# used
$remotesettings{'ENABLE_SSH_PASSWORDS'} = 'on' unless exists $remotesettings{'ENABLE_SSH_PASSWORDS'};
$remotesettings{'ENABLE_SSH_KEYS'} = 'on' unless exists $remotesettings{'ENABLE_SSH_KEYS'};
$checked{'ENABLE_SSH'}{'off'} = '';
$checked{'ENABLE_SSH'}{'on'} = '';
$checked{'ENABLE_SSH'}{$remotesettings{'ENABLE_SSH'}} = "checked='checked'";
$checked{'ENABLE_SSH_PROTOCOL1'}{'off'} = '';
$checked{'ENABLE_SSH_PROTOCOL1'}{'on'} = '';
$checked{'ENABLE_SSH_PROTOCOL1'}{$remotesettings{'ENABLE_SSH_PROTOCOL1'}} = "checked='checked'";
$checked{'ENABLE_SSH_PORTFW'}{'off'} = '';
$checked{'ENABLE_SSH_PORTFW'}{'on'} = '';
$checked{'ENABLE_SSH_PORTFW'}{$remotesettings{'ENABLE_SSH_PORTFW'}} = "checked='checked'";
$checked{'ENABLE_SSH_PASSWORDS'}{'off'} = '';
$checked{'ENABLE_SSH_PASSWORDS'}{'on'} = '';
$checked{'ENABLE_SSH_PASSWORDS'}{$remotesettings{'ENABLE_SSH_PASSWORDS'}} = "checked='checked'";
$checked{'ENABLE_SSH_KEYS'}{'off'} = '';
$checked{'ENABLE_SSH_KEYS'}{'on'} = '';
$checked{'ENABLE_SSH_KEYS'}{$remotesettings{'ENABLE_SSH_KEYS'}} = "checked='checked'";
&Header::openpage($Lang::tr{'remote access'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<FONT CLASS='base'>$errormessage&nbsp;</FONT>\n";
&Header::closebox();
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
&Header::openbox('100%', 'left', 'SSH:');
print <<END
<table width='100%'>
<tr>
<td><input type='checkbox' name='ENABLE_SSH' $checked{'ENABLE_SSH'}{'on'} /></td>
<td class='base' colspan='2'>$Lang::tr{'ssh access'}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type='checkbox' name='ENABLE_SSH_PROTOCOL1' $checked{'ENABLE_SSH_PROTOCOL1'}{'on'} /></td>
<td width='100%' class='base'>$Lang::tr{'ssh1 support'}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type='checkbox' name='ENABLE_SSH_PORTFW' $checked{'ENABLE_SSH_PORTFW'}{'on'} /></td>
<td width='100%' class='base'>$Lang::tr{'ssh portfw'}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type='checkbox' name='ENABLE_SSH_PASSWORDS' $checked{'ENABLE_SSH_PASSWORDS'}{'on'} /></td>
<td width='100%' class='base'>$Lang::tr{'ssh passwords'}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type='checkbox' name='ENABLE_SSH_KEYS' $checked{'ENABLE_SSH_KEYS'}{'on'} /></td>
<td width='100%' class='base'>$Lang::tr{'ssh keys'}</td>
</tr>
<tr>
<td colspan='3' align='center'><hr /><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
</tr>
</table>
END
;
&Header::closebox();
print "</form>\n";
&Header::openbox('100%', 'left', $Lang::tr{'ssh host keys'});
print "<table>\n";
print <<END
<tr><td class='boldbase'><b>$Lang::tr{'ssh key'}</b></td>
<td class='boldbase'><b>$Lang::tr{'ssh fingerprint'}</b></td>
<td class='boldbase'><b>$Lang::tr{'ssh key size'}</b></td></tr>
END
;
&viewkey("/etc/ssh/ssh_host_key.pub","RSA1");
&viewkey("/etc/ssh/ssh_host_rsa_key.pub","RSA2");
&viewkey("/etc/ssh/ssh_host_dsa_key.pub","DSA");
print "</table>\n";
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
sub viewkey
{
my $key = $_[0];
my $name = $_[1];
if ( -e $key )
{
my @temp = split(/ /,`/usr/bin/ssh-keygen -l -f $key`);
my $keysize = &Header::cleanhtml($temp[0],"y");
my $fingerprint = &Header::cleanhtml($temp[1],"y");
print "<tr><td>$key ($name)</td><td><code>$fingerprint</code></td><td align='center'>$keysize</td></tr>\n";
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,367 +1,367 @@
#!/usr/bin/perl
#
# Traffic shaping CGI
#
# Copyright 2003-04-06 David Kilpatrick <dave@thunder.com.au>
#
# $Id: shaping.cgi,v 1.3.2.15 2005/02/27 13:42:05 eoberlander Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::table2colour}, ${Header::colouryellow} );
undef (@dummy);
my %shapingsettings=();
my $configfile = "${General::swroot}/shaping/config";
my $settingsfile = "${General::swroot}/shaping/settings";
my $errormessage = '';
&Header::showhttpheaders();
$shapingsettings{'ACTION'} = '';
$shapingsettings{'ENABLE'} = 'off';
$shapingsettings{'VALID'} = '';
$shapingsettings{'UPLINK'} = '';
$shapingsettings{'DOWNLINK'} = '';
$shapingsettings{'SERVICE_ENABLED'} = '';
$shapingsettings{'SERVICE_PROT'} = '';
$shapingsettings{'SERVICE_PRIO'} = '';
$shapingsettings{'SERVICE_PORT'} = '';
&Header::getcgihash(\%shapingsettings);
open(FILE, "$configfile") or die 'Unable to open shaping config file.';
my @current = <FILE>;
close(FILE);
if ($shapingsettings{'ACTION'} eq $Lang::tr{'save'})
{
if (!($shapingsettings{'UPLINK'} =~ /^\d+$/) ||
($shapingsettings{'UPLINK'} < 2))
{
$errormessage = $Lang::tr{'invalid uplink speed'};
goto ERROR;
}
if (!($shapingsettings{'DOWNLINK'} =~ /^\d+$/) ||
($shapingsettings{'DOWNLINK'} < 2))
{
$errormessage = $Lang::tr{'invalid downlink speed'};
goto ERROR;
}
ERROR:
if ($errormessage) {
$shapingsettings{'VALID'} = 'no'; }
else {
$shapingsettings{'VALID'} = 'yes'; }
open(FILE,">$settingsfile") or die 'Unable to open shaping settings file.';
flock FILE, 2;
print FILE "VALID=$shapingsettings{'VALID'}\n";
print FILE "ENABLE=$shapingsettings{'ENABLE'}\n";
print FILE "UPLINK=$shapingsettings{'UPLINK'}\n";
print FILE "DOWNLINK=$shapingsettings{'DOWNLINK'}\n";
close FILE;
if ($shapingsettings{'VALID'} eq 'yes') {
system('/usr/local/bin/restartshaping');
}
}
if ($shapingsettings{'ACTION'} eq $Lang::tr{'add'})
{
unless($shapingsettings{'SERVICE_PROT'} =~ /^(tcp|udp)$/) { $errormessage = $Lang::tr{'invalid input'}; }
unless($shapingsettings{'SERVICE_PRIO'} =~ /^(10|20|30)$/) { $errormessage = $Lang::tr{'invalid input'}; }
unless(&General::validport($shapingsettings{'SERVICE_PORT'})) { $errormessage = $Lang::tr{'invalid port'}; }
if ( ! $errormessage)
{
if ($shapingsettings{'EDITING'} eq 'no')
{
open(FILE,">>$configfile") or die 'Unable to open shaping config file';
flock FILE, 2;
print FILE "$shapingsettings{'SERVICE_PROT'},$shapingsettings{'SERVICE_PORT'},$shapingsettings{'SERVICE_PRIO'},$shapingsettings{'SERVICE_ENABLED'}\n";
} else {
open(FILE,">$configfile") or die 'Unable to open shaping config file';
flock FILE, 2;
my $id = 0;
foreach my $line (@current)
{
$id++;
chomp($line);
my @temp = split(/\,/,$line);
if ($shapingsettings{'EDITING'} eq $id) {
print FILE "$shapingsettings{'SERVICE_PROT'},$shapingsettings{'SERVICE_PORT'},$shapingsettings{'SERVICE_PRIO'},$shapingsettings{'SERVICE_ENABLED'}\n";
} else {
print FILE "$line\n";
}
}
}
close FILE;
undef %shapingsettings;
system ('/usr/local/bin/restartshaping');
} else {
# stay on edit mode if an error occur
if ($shapingsettings{'EDITING'} ne 'no')
{
$shapingsettings{'ACTION'} = $Lang::tr{'edit'};
$shapingsettings{'ID'} = $shapingsettings{'EDITING'};
}
}
}
if ($shapingsettings{'ACTION'} eq $Lang::tr{'edit'})
{
my $id = 0;
foreach my $line (@current)
{
$id++;
if ($shapingsettings{"ID"} eq $id)
{
chomp($line);
my @temp = split(/\,/,$line);
$shapingsettings{'SERVICE_PROT'} = $temp[0];
$shapingsettings{'SERVICE_PORT'} = $temp[1];
$shapingsettings{'SERVICE_PRIO'} = $temp[2];
$shapingsettings{'SERVICE_ENABLED'} = $temp[3];
}
}
}
if ($shapingsettings{'ACTION'} eq $Lang::tr{'remove'} || $shapingsettings{'ACTION'} eq $Lang::tr{'toggle enable disable'})
{
open(FILE, ">$configfile") or die 'Unable to open config file.';
flock FILE, 2;
my $id = 0;
foreach my $line (@current)
{
$id++;
unless ($shapingsettings{"ID"} eq $id) { print FILE "$line"; }
elsif ($shapingsettings{'ACTION'} eq $Lang::tr{'toggle enable disable'})
{
chomp($line);
my @temp = split(/\,/,$line);
if ($temp[3] eq "on") {
print FILE "$temp[0],$temp[1],$temp[2],off\n";
} else {
print FILE "$temp[0],$temp[1],$temp[2],on\n";
}
}
}
close(FILE);
system ('/usr/local/bin/restartshaping');
}
&General::readhash("${General::swroot}/shaping/settings", \%shapingsettings);
if ($shapingsettings{'ACTION'} eq '')
{
$shapingsettings{'SERVICE_ENABLED'} = 'on';
$shapingsettings{'SERVICE_PROT'} = 'tcp';
$shapingsettings{'SERVICE_PRIO'} = '20';
$shapingsettings{'SERVICE_PORT'} = '';
}
my %checked=();
$checked{'ENABLE'}{'off'} = '';
$checked{'ENABLE'}{'on'} = '';
$checked{'ENABLE'}{$shapingsettings{'ENABLE'}} = "checked='checked'";
my %service_checked=();
$service_checked{'SERVICE_ENABLED'}{'off'} = '';
$service_checked{'SERVICE_ENABLED'}{'on'} = '';
$service_checked{'SERVICE_ENABLED'}{$shapingsettings{'SERVICE_ENABLED'}} = "checked='checked'";
my %service_selected=();
$service_selected{'SERVICE_PROT'}{'udp'} = '';
$service_selected{'SERVICE_PROT'}{'tcp'} = '';
$service_selected{'SERVICE_PROT'}{$shapingsettings{'SERVICE_PROT'}} = "selected='selected'";
$service_selected{'SERVICE_PRIO'}{'10'} = '';
$service_selected{'SERVICE_PRIO'}{'20'} = '';
$service_selected{'SERVICE_PRIO'}{'30'} = '';
$service_selected{'SERVICE_PRIO'}{$shapingsettings{'SERVICE_PRIO'}} = "selected='selected'";
&Header::openpage($Lang::tr{'traffic shaping settings'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>\n";
&Header::closebox();
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
&Header::openbox('100%', 'left', "$Lang::tr{'settings'}:");
print <<END
<table width='100%'>
<tr>
<td><input type='checkbox' name='ENABLE' $checked{'ENABLE'}{'on'} /></td>
<td class='base' colspan='2'>$Lang::tr{'traffic shaping'}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td width='30%' class='base'>$Lang::tr{'downlink speed'}:&nbsp;</td>
<td width='70%'><input type='text' name='DOWNLINK' value='$shapingsettings{'DOWNLINK'}' size='5' /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td class='base'>$Lang::tr{'uplink speed'}:&nbsp;</td>
<td><input type='text' name='UPLINK' value='$shapingsettings{'UPLINK'}' size='5' /></td>
</tr>
</table>
<table width='100%'>
<hr />
<tr>
<td width='50%'> &nbsp; </td>
<td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
</tr>
</table>
END
;
&Header::closebox;
print "</form>\n";
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
my $buttontext = $Lang::tr{'add'};
if($shapingsettings{'ACTION'} eq $Lang::tr{'edit'}) {
$buttontext = $Lang::tr{'update'};
&Header::openbox('100%', 'left', $Lang::tr{'edit service'});
} else {
&Header::openbox('100%', 'left', $Lang::tr{'add service'});
}
print <<END
<table width='100%'>
<tr>
<td class='base'>$Lang::tr{'priority'}:&nbsp;</td>
<td><select name='SERVICE_PRIO'>
<option value='10' $service_selected{'SERVICE_PRIO'}{'10'}>$Lang::tr{'high'}</option>
<option value='20' $service_selected{'SERVICE_PRIO'}{'20'}>$Lang::tr{'medium'}</option>
<option value='30' $service_selected{'SERVICE_PRIO'}{'30'}>$Lang::tr{'low'}</option>
</select></td>
<td width='20%' class='base' align='right'>$Lang::tr{'port'}:&nbsp;</td>
<td><input type='text' name='SERVICE_PORT' value='$shapingsettings{'SERVICE_PORT'}' size='5' /></td>
<td width='20%' class='base' align='right'>$Lang::tr{'protocol'}:&nbsp;</td>
<td><select name='SERVICE_PROT'>
<option value='tcp' $service_selected{'SERVICE_PROT'}{'tcp'}>TCP</option>
<option value='udp' $service_selected{'SERVICE_PROT'}{'udp'}>UDP</option>
</select></td>
<td width='20%' class='base' align='right'>$Lang::tr{'enabled'}&nbsp;</td>
<td width='20%'><input type='checkbox' name='SERVICE_ENABLED' $service_checked{'SERVICE_ENABLED'}{'on'} /></td>
</tr>
</table>
<table width='100%'>
<hr />
<tr>
<td width='50%'>&nbsp;</td>
<td width='50%' align='center'><input type='submit' name='SUBMIT' value='$buttontext' /><input type='hidden' name='ACTION' value='$Lang::tr{'add'}' /></td>
</tr>
</table>
END
;
&Header::closebox;
if ($shapingsettings{'ACTION'} eq $Lang::tr{'edit'}) {
print "<input type='hidden' name='EDITING' value='$shapingsettings{'ID'}' />\n";
} else {
print "<input type='hidden' name='EDITING' value='no' />\n";
}
print "</form>\n";
&Header::openbox('100%', 'left', $Lang::tr{'shaping list options'});
print <<END
<table width='100%' align='center'>
<tr>
<td width='33%' align='center' class='boldbase'><b>$Lang::tr{'priority'}</b></td>
<td width='33%' align='center' class='boldbase'><b>$Lang::tr{'port'}</b></td>
<td width='33%' align='center' class='boldbase'><b>$Lang::tr{'protocol'}</b></td>
<td align='center' class='boldbase' colspan='3'><b>$Lang::tr{'action'}</b></td>
</tr>
END
;
my $id = 0;
open(SERVICES, "$configfile") or die 'Unable to open shaping config file.';
while (<SERVICES>)
{
my $gif = '';
my $prio = '';
my $gdesc = '';
$id++;
chomp($_);
my @temp = split(/\,/,$_);
if ($temp[3] eq "on") {
$gif = 'on.gif'; $gdesc=$Lang::tr{'click to disable'}; }
else {
$gif = 'off.gif'; $gdesc=$Lang::tr{'click to enable'}; }
if ($shapingsettings{'ACTION'} eq $Lang::tr{'edit'} && $shapingsettings{'ID'} eq $id) {
print "<tr bgcolor='${Header::colouryellow}'>\n"; }
elsif ($id % 2) {
print "<tr bgcolor='${Header::table1colour}'>\n"; }
else {
print "<tr bgcolor='${Header::table2colour}'>\n"; }
if ($temp[2] eq "10") { $prio = $Lang::tr{'high'}; }
if ($temp[2] eq "20") { $prio = $Lang::tr{'medium'}; }
if ($temp[2] eq "30") { $prio = $Lang::tr{'low'}; }
print <<END
<td align='center'>$prio</td>
<td align='center'>$temp[1]</td>
<td align='center'>$temp[0]</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}' name='frma$id'>
<input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' alt='$gdesc' title='$gdesc' />
<input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
<input type='hidden' name='ID' value='$id' />
</form>
</td>
<td align='center'>
<form method='post' name='frmb$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' title='$Lang::tr{'edit'}' alt='$Lang::tr{'edit'}' />
<input type='hidden' name='ID' value='$id' />
<input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
</form>
</td>
<td align='center'>
<form method='post' name='frmc$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' title='$Lang::tr{'remove'}' alt='$Lang::tr{'remove'}' />
<input type='hidden' name='ID' value='$id' />
<input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
</form>
</td>
</tr>
END
;
}
close(SERVICES);
print <<END
</table>
END
;
&Header::closebox;
&Header::closebigbox();
&Header::closepage;
#!/usr/bin/perl
#
# Traffic shaping CGI
#
# Copyright 2003-04-06 David Kilpatrick <dave@thunder.com.au>
#
# $Id: shaping.cgi,v 1.3.2.15 2005/02/27 13:42:05 eoberlander Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::table2colour}, ${Header::colouryellow} );
undef (@dummy);
my %shapingsettings=();
my $configfile = "${General::swroot}/shaping/config";
my $settingsfile = "${General::swroot}/shaping/settings";
my $errormessage = '';
&Header::showhttpheaders();
$shapingsettings{'ACTION'} = '';
$shapingsettings{'ENABLE'} = 'off';
$shapingsettings{'VALID'} = '';
$shapingsettings{'UPLINK'} = '';
$shapingsettings{'DOWNLINK'} = '';
$shapingsettings{'SERVICE_ENABLED'} = '';
$shapingsettings{'SERVICE_PROT'} = '';
$shapingsettings{'SERVICE_PRIO'} = '';
$shapingsettings{'SERVICE_PORT'} = '';
&Header::getcgihash(\%shapingsettings);
open(FILE, "$configfile") or die 'Unable to open shaping config file.';
my @current = <FILE>;
close(FILE);
if ($shapingsettings{'ACTION'} eq $Lang::tr{'save'})
{
if (!($shapingsettings{'UPLINK'} =~ /^\d+$/) ||
($shapingsettings{'UPLINK'} < 2))
{
$errormessage = $Lang::tr{'invalid uplink speed'};
goto ERROR;
}
if (!($shapingsettings{'DOWNLINK'} =~ /^\d+$/) ||
($shapingsettings{'DOWNLINK'} < 2))
{
$errormessage = $Lang::tr{'invalid downlink speed'};
goto ERROR;
}
ERROR:
if ($errormessage) {
$shapingsettings{'VALID'} = 'no'; }
else {
$shapingsettings{'VALID'} = 'yes'; }
open(FILE,">$settingsfile") or die 'Unable to open shaping settings file.';
flock FILE, 2;
print FILE "VALID=$shapingsettings{'VALID'}\n";
print FILE "ENABLE=$shapingsettings{'ENABLE'}\n";
print FILE "UPLINK=$shapingsettings{'UPLINK'}\n";
print FILE "DOWNLINK=$shapingsettings{'DOWNLINK'}\n";
close FILE;
if ($shapingsettings{'VALID'} eq 'yes') {
system('/usr/local/bin/restartshaping');
}
}
if ($shapingsettings{'ACTION'} eq $Lang::tr{'add'})
{
unless($shapingsettings{'SERVICE_PROT'} =~ /^(tcp|udp)$/) { $errormessage = $Lang::tr{'invalid input'}; }
unless($shapingsettings{'SERVICE_PRIO'} =~ /^(10|20|30)$/) { $errormessage = $Lang::tr{'invalid input'}; }
unless(&General::validport($shapingsettings{'SERVICE_PORT'})) { $errormessage = $Lang::tr{'invalid port'}; }
if ( ! $errormessage)
{
if ($shapingsettings{'EDITING'} eq 'no')
{
open(FILE,">>$configfile") or die 'Unable to open shaping config file';
flock FILE, 2;
print FILE "$shapingsettings{'SERVICE_PROT'},$shapingsettings{'SERVICE_PORT'},$shapingsettings{'SERVICE_PRIO'},$shapingsettings{'SERVICE_ENABLED'}\n";
} else {
open(FILE,">$configfile") or die 'Unable to open shaping config file';
flock FILE, 2;
my $id = 0;
foreach my $line (@current)
{
$id++;
chomp($line);
my @temp = split(/\,/,$line);
if ($shapingsettings{'EDITING'} eq $id) {
print FILE "$shapingsettings{'SERVICE_PROT'},$shapingsettings{'SERVICE_PORT'},$shapingsettings{'SERVICE_PRIO'},$shapingsettings{'SERVICE_ENABLED'}\n";
} else {
print FILE "$line\n";
}
}
}
close FILE;
undef %shapingsettings;
system ('/usr/local/bin/restartshaping');
} else {
# stay on edit mode if an error occur
if ($shapingsettings{'EDITING'} ne 'no')
{
$shapingsettings{'ACTION'} = $Lang::tr{'edit'};
$shapingsettings{'ID'} = $shapingsettings{'EDITING'};
}
}
}
if ($shapingsettings{'ACTION'} eq $Lang::tr{'edit'})
{
my $id = 0;
foreach my $line (@current)
{
$id++;
if ($shapingsettings{"ID"} eq $id)
{
chomp($line);
my @temp = split(/\,/,$line);
$shapingsettings{'SERVICE_PROT'} = $temp[0];
$shapingsettings{'SERVICE_PORT'} = $temp[1];
$shapingsettings{'SERVICE_PRIO'} = $temp[2];
$shapingsettings{'SERVICE_ENABLED'} = $temp[3];
}
}
}
if ($shapingsettings{'ACTION'} eq $Lang::tr{'remove'} || $shapingsettings{'ACTION'} eq $Lang::tr{'toggle enable disable'})
{
open(FILE, ">$configfile") or die 'Unable to open config file.';
flock FILE, 2;
my $id = 0;
foreach my $line (@current)
{
$id++;
unless ($shapingsettings{"ID"} eq $id) { print FILE "$line"; }
elsif ($shapingsettings{'ACTION'} eq $Lang::tr{'toggle enable disable'})
{
chomp($line);
my @temp = split(/\,/,$line);
if ($temp[3] eq "on") {
print FILE "$temp[0],$temp[1],$temp[2],off\n";
} else {
print FILE "$temp[0],$temp[1],$temp[2],on\n";
}
}
}
close(FILE);
system ('/usr/local/bin/restartshaping');
}
&General::readhash("${General::swroot}/shaping/settings", \%shapingsettings);
if ($shapingsettings{'ACTION'} eq '')
{
$shapingsettings{'SERVICE_ENABLED'} = 'on';
$shapingsettings{'SERVICE_PROT'} = 'tcp';
$shapingsettings{'SERVICE_PRIO'} = '20';
$shapingsettings{'SERVICE_PORT'} = '';
}
my %checked=();
$checked{'ENABLE'}{'off'} = '';
$checked{'ENABLE'}{'on'} = '';
$checked{'ENABLE'}{$shapingsettings{'ENABLE'}} = "checked='checked'";
my %service_checked=();
$service_checked{'SERVICE_ENABLED'}{'off'} = '';
$service_checked{'SERVICE_ENABLED'}{'on'} = '';
$service_checked{'SERVICE_ENABLED'}{$shapingsettings{'SERVICE_ENABLED'}} = "checked='checked'";
my %service_selected=();
$service_selected{'SERVICE_PROT'}{'udp'} = '';
$service_selected{'SERVICE_PROT'}{'tcp'} = '';
$service_selected{'SERVICE_PROT'}{$shapingsettings{'SERVICE_PROT'}} = "selected='selected'";
$service_selected{'SERVICE_PRIO'}{'10'} = '';
$service_selected{'SERVICE_PRIO'}{'20'} = '';
$service_selected{'SERVICE_PRIO'}{'30'} = '';
$service_selected{'SERVICE_PRIO'}{$shapingsettings{'SERVICE_PRIO'}} = "selected='selected'";
&Header::openpage($Lang::tr{'traffic shaping settings'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>\n";
&Header::closebox();
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
&Header::openbox('100%', 'left', "$Lang::tr{'settings'}:");
print <<END
<table width='100%'>
<tr>
<td><input type='checkbox' name='ENABLE' $checked{'ENABLE'}{'on'} /></td>
<td class='base' colspan='2'>$Lang::tr{'traffic shaping'}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td width='30%' class='base'>$Lang::tr{'downlink speed'}:&nbsp;</td>
<td width='70%'><input type='text' name='DOWNLINK' value='$shapingsettings{'DOWNLINK'}' size='5' /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td class='base'>$Lang::tr{'uplink speed'}:&nbsp;</td>
<td><input type='text' name='UPLINK' value='$shapingsettings{'UPLINK'}' size='5' /></td>
</tr>
</table>
<table width='100%'>
<hr />
<tr>
<td width='50%'> &nbsp; </td>
<td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
</tr>
</table>
END
;
&Header::closebox;
print "</form>\n";
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
my $buttontext = $Lang::tr{'add'};
if($shapingsettings{'ACTION'} eq $Lang::tr{'edit'}) {
$buttontext = $Lang::tr{'update'};
&Header::openbox('100%', 'left', $Lang::tr{'edit service'});
} else {
&Header::openbox('100%', 'left', $Lang::tr{'add service'});
}
print <<END
<table width='100%'>
<tr>
<td class='base'>$Lang::tr{'priority'}:&nbsp;</td>
<td><select name='SERVICE_PRIO'>
<option value='10' $service_selected{'SERVICE_PRIO'}{'10'}>$Lang::tr{'high'}</option>
<option value='20' $service_selected{'SERVICE_PRIO'}{'20'}>$Lang::tr{'medium'}</option>
<option value='30' $service_selected{'SERVICE_PRIO'}{'30'}>$Lang::tr{'low'}</option>
</select></td>
<td width='20%' class='base' align='right'>$Lang::tr{'port'}:&nbsp;</td>
<td><input type='text' name='SERVICE_PORT' value='$shapingsettings{'SERVICE_PORT'}' size='5' /></td>
<td width='20%' class='base' align='right'>$Lang::tr{'protocol'}:&nbsp;</td>
<td><select name='SERVICE_PROT'>
<option value='tcp' $service_selected{'SERVICE_PROT'}{'tcp'}>TCP</option>
<option value='udp' $service_selected{'SERVICE_PROT'}{'udp'}>UDP</option>
</select></td>
<td width='20%' class='base' align='right'>$Lang::tr{'enabled'}&nbsp;</td>
<td width='20%'><input type='checkbox' name='SERVICE_ENABLED' $service_checked{'SERVICE_ENABLED'}{'on'} /></td>
</tr>
</table>
<table width='100%'>
<hr />
<tr>
<td width='50%'>&nbsp;</td>
<td width='50%' align='center'><input type='submit' name='SUBMIT' value='$buttontext' /><input type='hidden' name='ACTION' value='$Lang::tr{'add'}' /></td>
</tr>
</table>
END
;
&Header::closebox;
if ($shapingsettings{'ACTION'} eq $Lang::tr{'edit'}) {
print "<input type='hidden' name='EDITING' value='$shapingsettings{'ID'}' />\n";
} else {
print "<input type='hidden' name='EDITING' value='no' />\n";
}
print "</form>\n";
&Header::openbox('100%', 'left', $Lang::tr{'shaping list options'});
print <<END
<table width='100%' align='center'>
<tr>
<td width='33%' align='center' class='boldbase'><b>$Lang::tr{'priority'}</b></td>
<td width='33%' align='center' class='boldbase'><b>$Lang::tr{'port'}</b></td>
<td width='33%' align='center' class='boldbase'><b>$Lang::tr{'protocol'}</b></td>
<td align='center' class='boldbase' colspan='3'><b>$Lang::tr{'action'}</b></td>
</tr>
END
;
my $id = 0;
open(SERVICES, "$configfile") or die 'Unable to open shaping config file.';
while (<SERVICES>)
{
my $gif = '';
my $prio = '';
my $gdesc = '';
$id++;
chomp($_);
my @temp = split(/\,/,$_);
if ($temp[3] eq "on") {
$gif = 'on.gif'; $gdesc=$Lang::tr{'click to disable'}; }
else {
$gif = 'off.gif'; $gdesc=$Lang::tr{'click to enable'}; }
if ($shapingsettings{'ACTION'} eq $Lang::tr{'edit'} && $shapingsettings{'ID'} eq $id) {
print "<tr bgcolor='${Header::colouryellow}'>\n"; }
elsif ($id % 2) {
print "<tr bgcolor='${Header::table1colour}'>\n"; }
else {
print "<tr bgcolor='${Header::table2colour}'>\n"; }
if ($temp[2] eq "10") { $prio = $Lang::tr{'high'}; }
if ($temp[2] eq "20") { $prio = $Lang::tr{'medium'}; }
if ($temp[2] eq "30") { $prio = $Lang::tr{'low'}; }
print <<END
<td align='center'>$prio</td>
<td align='center'>$temp[1]</td>
<td align='center'>$temp[0]</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}' name='frma$id'>
<input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' alt='$gdesc' title='$gdesc' />
<input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
<input type='hidden' name='ID' value='$id' />
</form>
</td>
<td align='center'>
<form method='post' name='frmb$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' title='$Lang::tr{'edit'}' alt='$Lang::tr{'edit'}' />
<input type='hidden' name='ID' value='$id' />
<input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
</form>
</td>
<td align='center'>
<form method='post' name='frmc$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' title='$Lang::tr{'remove'}' alt='$Lang::tr{'remove'}' />
<input type='hidden' name='ID' value='$id' />
<input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
</form>
</td>
</tr>
END
;
}
close(SERVICES);
print <<END
</table>
END
;
&Header::closebox;
&Header::closebigbox();
&Header::closepage;

View File

@@ -1,253 +1,253 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: shutdown.cgi,v 1.5.2.10 2006/01/02 16:21:00 eoberlander Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %cgiparams=();
my $death = 0;
my $rebirth = 0;
my $default_time = '03:15';
&Header::showhttpheaders();
$cgiparams{'ACTION'} = '';
&Header::getcgihash(\%cgiparams);
if ($cgiparams{'ACTION'} eq $Lang::tr{'shutdown'}) {
$death = 1;
&General::log($Lang::tr{'shutting down ipcop'});
#system '/usr/local/bin/ipcopdeath';
system '/usr/local/bin/ipcopreboot down';
} elsif ($cgiparams{'ACTION'} eq $Lang::tr{'reboot'}) {
$rebirth = 1;
&General::log($Lang::tr{'rebooting ipcop'});
#system '/usr/local/bin/ipcoprebirth';
system '/usr/local/bin/ipcopreboot boot';
} elsif ($cgiparams{'ACTION'} eq $Lang::tr{'save'}) {
my $days='';
my $n = 1;
# build list of days
map ($cgiparams{$_} eq 'on' ? $days .= ",".$n++ : $n++ ,
('MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY','SUNDAY') );
# if days is empty, it is a remove else it is a change
if (length ($days)){
substr($days,0,1) = ''; #kill front comma
&General::log("Scheduling reboot on $days at $cgiparams{'TIME'}");
my $min;
my $hour;
($hour,$min) = split (':', $cgiparams{'TIME'});
$days = "'*'" if ($days eq '1,2,3,4,5,6,7');
my $mode = ($cgiparams{'MODE'} eq 'halt') ? '-h' : '-r';
system "/usr/local/bin/ipcopreboot cron+ $min $hour $days $mode"; #reboot checks values of $hour & $min
} else {
&General::log("Remove scheduled reboot");
system '/usr/local/bin/ipcopreboot cron-';
}
}
if ($death == 0 && $rebirth == 0) {
&Header::openpage($Lang::tr{'shutdown control'}, 1, '');
&Header::openbigbox('100%', 'left');
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
&Header::openbox('100%', 'left', $Lang::tr{'shutdown2'});
print <<END
<table width='100%'>
<tr>
<td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'reboot'}' /></td>
<td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'shutdown'}' /></td>
</tr>
</table>
END
;
&Header::closebox();
&Header::openbox('100%', 'left', $Lang::tr{'reboot schedule'});
my %checked=();
my $reboot_at = $default_time;
my $days = '';
#decode the shutdown line stored in crontab
#get the line
open(FILE, "/usr/local/bin/ipcopreboot cron?|");
my $schedule = <FILE>;
close (FILE);
if ($schedule) { # something exist
$schedule =~ /(\d+) (\d+) \* \* ([1234567*,]+) .* (-[h|r])/;
$reboot_at = sprintf("%.02d",$2) . ':' . sprintf("%.02d",$1); # hour (03:45)
$days = $3; # 1,2,3... or *
if ($4 eq '-h') {
$checked{'MODE'}{'halt'} = "checked='checked'";
} else {
$checked{'MODE'}{'reboot'} = "checked='checked'";
}
}
#decode $days
if ($days eq '*') {
$checked{'MONDAY'} = "checked='checked'";
$checked{'TUESDAY'} = "checked='checked'";
$checked{'WEDNESDAY'} = "checked='checked'";
$checked{'THURSDAY'} = "checked='checked'";
$checked{'FRIDAY'} = "checked='checked'";
$checked{'SATURDAY'} = "checked='checked'";
$checked{'SUNDAY'} = "checked='checked'";
} else {
$checked{'MONDAY'} = "checked='checked'" if ($days =~ /1/);
$checked{'TUESDAY'} = "checked='checked'" if ($days =~ /2/);
$checked{'WEDNESDAY'} = "checked='checked'" if ($days =~ /3/);
$checked{'THURSDAY'} = "checked='checked'" if ($days =~ /4/);
$checked{'FRIDAY'} = "checked='checked'" if ($days =~ /5/);
$checked{'SATURDAY'} = "checked='checked'" if ($days =~ /6/);
$checked{'SUNDAY'} = "checked='checked'" if ($days =~ /7/);
}
print <<END
<table width='100%'>
<tr>
<td class='boldbase' colspan='2'><b>$Lang::tr{'time'}</b></td>
<td class='boldbase' colspan='2'><b>$Lang::tr{'day'}</b></td>
<td class='boldbase'><b>$Lang::tr{'action'}</b></td>
</tr>
<tr>
END
;
print "<td align='left' width='15%' class='base' valign='top' rowspan='2'>", &select_hour_var("TIME", $reboot_at);
print <<END
</td>
<td>
<input type='checkbox' name='MONDAY' $checked{'MONDAY'}></td>
<td width='15%' class='base'>
$Lang::tr{'monday'}</td>
<td>
<input type='radio' name='MODE' value='reboot' $checked{'MODE'}{'reboot'} /></td>
<td width='70%' class='base'>$Lang::tr{'reboot'}</td></tr>
<tr>
<td>
<input type='checkbox' name='TUESDAY' $checked{'TUESDAY'}></td>
<td width='15%' class='base'>
$Lang::tr{'tuesday'}</td>
<td>
<input type='radio' name='MODE' value='halt' $checked{'MODE'}{'halt'} /></td>
<td class='base'>$Lang::tr{'shutdown'}</td></tr>
<tr>
<td>&nbsp;</td>
<td>
<input type='checkbox' name='WEDNESDAY' $checked{'WEDNESDAY'}></td>
<td width='15%' class='base'>
$Lang::tr{'wednesday'}</td></tr>
<tr>
<td>&nbsp;</td>
<td>
<input type='checkbox' name='THURSDAY' $checked{'THURSDAY'}></td>
<td width='15%' class='base'>
$Lang::tr{'thursday'}</td></tr>
<tr>
<td>&nbsp;</td>
<td>
<input type='checkbox' name='FRIDAY' $checked{'FRIDAY'}></td>
<td width='15%' class='base'>
$Lang::tr{'friday'}</td></tr>
<tr>
<td>&nbsp;</td>
<td>
<input type='checkbox' name='SATURDAY' $checked{'SATURDAY'}></td>
<td width='15%' class='base'>
$Lang::tr{'saturday'}</td></tr>
<tr>
<td>&nbsp;</td>
<td>
<input type='checkbox' name='SUNDAY' $checked{'SUNDAY'}></td>
<td width='15%' class='base'>
$Lang::tr{'sunday'}</td></tr>
</table>
<table width='100%'>
<hr />
<tr>
<td width='60%'>&nbsp;</td>
<td width='30%' align='center'>
<input type='submit' name='ACTION' value='$Lang::tr{'save'}' />
</td>
<td width='10%' align='right'>
<a href='${General::adminmanualurl}/system.html#shutdown' target='_blank'>
<img src='/images/web-support.png' title='$Lang::tr{'online help en'}' /></a></td>
</tr>
</table>
END
;
&Header::closebox();
print "</form>\n";
} else {
my $message='';
my $title='';
my $refresh = "<meta http-equiv='refresh' content='5; URL=/cgi-bin/index.cgi' />";
if ($death) {
$title = $Lang::tr{'shutting down'};
$message = $Lang::tr{'ipcop has now shutdown'};
} else {
$title = $Lang::tr{'rebooting'};
$message = $Lang::tr{'ipcop has now rebooted'};
}
&Header::openpage($title, 0, $refresh);
&Header::openbigbox('100%', 'center');
print <<END
<div align='center'>
<table width='100%' bgcolor='#ffffff'>
<tr><td align='center'>
<br /><br /><img src='/ipcop_big.gif' /><br /><br /><br />
</td></tr>
</table>
<br />
<font size='6'>$message</font>
</div>
END
;
}
&Header::closebigbox();
&Header::closepage();
# Create a named select box containing valid times from quarter to quarter.
sub select_hour_var {
# Create a variable containing the SELECT with selected value variable name and current value selected
my $select_hour_var = shift;
my $selected_hour = shift;
my $select_hour = "<select name='$select_hour_var'>";
my $hh = 0;
my $mm = 15;
my $str = '00:00';
for (my $x=0; $x<(24*4); $x++) {
my $check = $selected_hour eq $str ? "selected='selected'" : '';
$select_hour .= "<Option $check value='$str'>$str";
$str = sprintf("%.02d", $hh) . ":" . sprintf("%.02d", $mm);
$mm += 15;
if ($mm==60) {$mm=0; $hh++; }
}
$select_hour .= "</select>\n";
return ($select_hour);
}
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: shutdown.cgi,v 1.5.2.10 2006/01/02 16:21:00 eoberlander Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %cgiparams=();
my $death = 0;
my $rebirth = 0;
my $default_time = '03:15';
&Header::showhttpheaders();
$cgiparams{'ACTION'} = '';
&Header::getcgihash(\%cgiparams);
if ($cgiparams{'ACTION'} eq $Lang::tr{'shutdown'}) {
$death = 1;
&General::log($Lang::tr{'shutting down ipcop'});
#system '/usr/local/bin/ipcopdeath';
system '/usr/local/bin/ipcopreboot down';
} elsif ($cgiparams{'ACTION'} eq $Lang::tr{'reboot'}) {
$rebirth = 1;
&General::log($Lang::tr{'rebooting ipcop'});
#system '/usr/local/bin/ipcoprebirth';
system '/usr/local/bin/ipcopreboot boot';
} elsif ($cgiparams{'ACTION'} eq $Lang::tr{'save'}) {
my $days='';
my $n = 1;
# build list of days
map ($cgiparams{$_} eq 'on' ? $days .= ",".$n++ : $n++ ,
('MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY','SUNDAY') );
# if days is empty, it is a remove else it is a change
if (length ($days)){
substr($days,0,1) = ''; #kill front comma
&General::log("Scheduling reboot on $days at $cgiparams{'TIME'}");
my $min;
my $hour;
($hour,$min) = split (':', $cgiparams{'TIME'});
$days = "'*'" if ($days eq '1,2,3,4,5,6,7');
my $mode = ($cgiparams{'MODE'} eq 'halt') ? '-h' : '-r';
system "/usr/local/bin/ipcopreboot cron+ $min $hour $days $mode"; #reboot checks values of $hour & $min
} else {
&General::log("Remove scheduled reboot");
system '/usr/local/bin/ipcopreboot cron-';
}
}
if ($death == 0 && $rebirth == 0) {
&Header::openpage($Lang::tr{'shutdown control'}, 1, '');
&Header::openbigbox('100%', 'left');
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
&Header::openbox('100%', 'left', $Lang::tr{'shutdown2'});
print <<END
<table width='100%'>
<tr>
<td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'reboot'}' /></td>
<td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'shutdown'}' /></td>
</tr>
</table>
END
;
&Header::closebox();
&Header::openbox('100%', 'left', $Lang::tr{'reboot schedule'});
my %checked=();
my $reboot_at = $default_time;
my $days = '';
#decode the shutdown line stored in crontab
#get the line
open(FILE, "/usr/local/bin/ipcopreboot cron?|");
my $schedule = <FILE>;
close (FILE);
if ($schedule) { # something exist
$schedule =~ /(\d+) (\d+) \* \* ([1234567*,]+) .* (-[h|r])/;
$reboot_at = sprintf("%.02d",$2) . ':' . sprintf("%.02d",$1); # hour (03:45)
$days = $3; # 1,2,3... or *
if ($4 eq '-h') {
$checked{'MODE'}{'halt'} = "checked='checked'";
} else {
$checked{'MODE'}{'reboot'} = "checked='checked'";
}
}
#decode $days
if ($days eq '*') {
$checked{'MONDAY'} = "checked='checked'";
$checked{'TUESDAY'} = "checked='checked'";
$checked{'WEDNESDAY'} = "checked='checked'";
$checked{'THURSDAY'} = "checked='checked'";
$checked{'FRIDAY'} = "checked='checked'";
$checked{'SATURDAY'} = "checked='checked'";
$checked{'SUNDAY'} = "checked='checked'";
} else {
$checked{'MONDAY'} = "checked='checked'" if ($days =~ /1/);
$checked{'TUESDAY'} = "checked='checked'" if ($days =~ /2/);
$checked{'WEDNESDAY'} = "checked='checked'" if ($days =~ /3/);
$checked{'THURSDAY'} = "checked='checked'" if ($days =~ /4/);
$checked{'FRIDAY'} = "checked='checked'" if ($days =~ /5/);
$checked{'SATURDAY'} = "checked='checked'" if ($days =~ /6/);
$checked{'SUNDAY'} = "checked='checked'" if ($days =~ /7/);
}
print <<END
<table width='100%'>
<tr>
<td class='boldbase' colspan='2'><b>$Lang::tr{'time'}</b></td>
<td class='boldbase' colspan='2'><b>$Lang::tr{'day'}</b></td>
<td class='boldbase'><b>$Lang::tr{'action'}</b></td>
</tr>
<tr>
END
;
print "<td align='left' width='15%' class='base' valign='top' rowspan='2'>", &select_hour_var("TIME", $reboot_at);
print <<END
</td>
<td>
<input type='checkbox' name='MONDAY' $checked{'MONDAY'}></td>
<td width='15%' class='base'>
$Lang::tr{'monday'}</td>
<td>
<input type='radio' name='MODE' value='reboot' $checked{'MODE'}{'reboot'} /></td>
<td width='70%' class='base'>$Lang::tr{'reboot'}</td></tr>
<tr>
<td>
<input type='checkbox' name='TUESDAY' $checked{'TUESDAY'}></td>
<td width='15%' class='base'>
$Lang::tr{'tuesday'}</td>
<td>
<input type='radio' name='MODE' value='halt' $checked{'MODE'}{'halt'} /></td>
<td class='base'>$Lang::tr{'shutdown'}</td></tr>
<tr>
<td>&nbsp;</td>
<td>
<input type='checkbox' name='WEDNESDAY' $checked{'WEDNESDAY'}></td>
<td width='15%' class='base'>
$Lang::tr{'wednesday'}</td></tr>
<tr>
<td>&nbsp;</td>
<td>
<input type='checkbox' name='THURSDAY' $checked{'THURSDAY'}></td>
<td width='15%' class='base'>
$Lang::tr{'thursday'}</td></tr>
<tr>
<td>&nbsp;</td>
<td>
<input type='checkbox' name='FRIDAY' $checked{'FRIDAY'}></td>
<td width='15%' class='base'>
$Lang::tr{'friday'}</td></tr>
<tr>
<td>&nbsp;</td>
<td>
<input type='checkbox' name='SATURDAY' $checked{'SATURDAY'}></td>
<td width='15%' class='base'>
$Lang::tr{'saturday'}</td></tr>
<tr>
<td>&nbsp;</td>
<td>
<input type='checkbox' name='SUNDAY' $checked{'SUNDAY'}></td>
<td width='15%' class='base'>
$Lang::tr{'sunday'}</td></tr>
</table>
<table width='100%'>
<hr />
<tr>
<td width='60%'>&nbsp;</td>
<td width='30%' align='center'>
<input type='submit' name='ACTION' value='$Lang::tr{'save'}' />
</td>
<td width='10%' align='right'>
<a href='${General::adminmanualurl}/system.html#shutdown' target='_blank'>
<img src='/images/web-support.png' title='$Lang::tr{'online help en'}' /></a></td>
</tr>
</table>
END
;
&Header::closebox();
print "</form>\n";
} else {
my $message='';
my $title='';
my $refresh = "<meta http-equiv='refresh' content='5; URL=/cgi-bin/index.cgi' />";
if ($death) {
$title = $Lang::tr{'shutting down'};
$message = $Lang::tr{'ipcop has now shutdown'};
} else {
$title = $Lang::tr{'rebooting'};
$message = $Lang::tr{'ipcop has now rebooted'};
}
&Header::openpage($title, 0, $refresh);
&Header::openbigbox('100%', 'center');
print <<END
<div align='center'>
<table width='100%' bgcolor='#ffffff'>
<tr><td align='center'>
<br /><br /><img src='/ipcop_big.gif' /><br /><br /><br />
</td></tr>
</table>
<br />
<font size='6'>$message</font>
</div>
END
;
}
&Header::closebigbox();
&Header::closepage();
# Create a named select box containing valid times from quarter to quarter.
sub select_hour_var {
# Create a variable containing the SELECT with selected value variable name and current value selected
my $select_hour_var = shift;
my $selected_hour = shift;
my $select_hour = "<select name='$select_hour_var'>";
my $hh = 0;
my $mm = 15;
my $str = '00:00';
for (my $x=0; $x<(24*4); $x++) {
my $check = $selected_hour eq $str ? "selected='selected'" : '';
$select_hour .= "<Option $check value='$str'>$str";
$str = sprintf("%.02d", $hh) . ":" . sprintf("%.02d", $mm);
$mm += 15;
if ($mm==60) {$mm=0; $hh++; }
}
$select_hour .= "</select>\n";
return ($select_hour);
}

View File

@@ -1,325 +1,325 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: status.cgi,v 1.6.2.7 2005/02/24 07:44:35 gespinasse Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::colourred} );
undef (@dummy);
my %netsettings=();
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
my %cgiparams=();
# Maps a nice printable name to the changing part of the pid file, which
# is also the name of the program
my %servicenames =
(
$Lang::tr{'dhcp server'} => 'dhcpd',
$Lang::tr{'web server'} => 'httpd',
$Lang::tr{'cron server'} => 'fcron',
$Lang::tr{'dns proxy server'} => 'dnsmasq',
$Lang::tr{'logging server'} => 'syslogd',
$Lang::tr{'kernel logging server'} => 'klogd',
$Lang::tr{'ntp server'} => 'ntpd',
$Lang::tr{'secure shell server'} => 'sshd',
$Lang::tr{'vpn'} => 'pluto',
$Lang::tr{'web proxy'} => 'squid'
);
my $iface = '';
if (open(FILE, "${General::swroot}/red/iface"))
{
$iface = <FILE>;
close FILE;
chomp $iface;
}
$servicenames{"$Lang::tr{'intrusion detection system'} (RED)"} = "snort_${iface}";
$servicenames{"$Lang::tr{'intrusion detection system'} (GREEN)"} = "snort_$netsettings{'GREEN_DEV'}";
if ($netsettings{'ORANGE_DEV'} ne '') {
$servicenames{"$Lang::tr{'intrusion detection system'} (ORANGE)"} = "snort_$netsettings{'ORANGE_DEV'}";
}
if ($netsettings{'BLUE_DEV'} ne '') {
$servicenames{"$Lang::tr{'intrusion detection system'} (BLUE)"} = "snort_$netsettings{'BLUE_DEV'}";
}
&Header::showhttpheaders();
&Header::getcgihash(\%cgiparams);
&Header::openpage($Lang::tr{'status information'}, 1, '');
&Header::openbigbox('100%', 'left');
print <<END
<table width='100%' cellspacing='0' cellpadding='5'border='0'>
<tr><td style="background-color: #EAE9EE;" align='left'>
<a href='#services'>$Lang::tr{'services'}</a> |
<a href='#memory'>$Lang::tr{'memory'}</a> |
<a href='#disk'>$Lang::tr{'disk usage'}</a> |
<a href='#uptime'>$Lang::tr{'uptime and users'}</a> |
<a href='#modules'>$Lang::tr{'loaded modules'}</a> |
<a href='#kernel'>$Lang::tr{'kernel version'}</a>
</td></tr></table>
END
;
print "<a name='services'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'services'});
print <<END
<div align='center'>
<table width='60%' cellspacing='0' border='0'>
END
;
my $lines = 0;
my $key = '';
foreach $key (sort keys %servicenames)
{
if ($lines % 2) {
print "<tr bgcolor='${Header::table1colour}'>\n"; }
else {
print "<tr bgcolor='${Header::table2colour}'>\n"; }
print "<td align='left'>$key</td>\n";
my $shortname = $servicenames{$key};
my $status = &isrunning($shortname);
print "$status\n";
print "</tr>\n";
$lines++;
}
print "</table></div>\n";
&Header::closebox();
print "<a name='memory'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'memory'});
print "<table><tr><td><table>";
my $ram=0;
my $size=0;
my $used=0;
my $free=0;
my $percent=0;
my $shared=0;
my $buffers=0;
my $cached=0;
open(FREE,'/usr/bin/free |');
while(<FREE>)
{
if ($_ =~ m/^\s+total\s+used\s+free\s+shared\s+buffers\s+cached$/ )
{
print <<END
<tr>
<td>&nbsp;</td>
<td align='center' class='boldbase'><b>$Lang::tr{'size'}</b></td>
<td align='center' class='boldbase'><b>$Lang::tr{'used'}</b></td>
<td align='center' class='boldbase'><b>$Lang::tr{'free'}</b></td>
<td align='left' class='boldbase' colspan='2'><b>$Lang::tr{'percentage'}</b></td>
</tr>
END
;
} else {
if ($_ =~ m/^Mem:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/) {
($ram,$size,$used,$free,$shared,$buffers,$cached) = ($1,$1,$2,$3,$4,$5,$6);
($percent = ($used/$size)*100) =~ s/^(\d+)(\.\d+)?$/$1%/;
print <<END
<tr>
<td class='boldbase'><b>$Lang::tr{'ram'}</b></td>
<td align='right'>$size</td>
END
;
} elsif ($_ =~ m/^Swap:\s+(\d+)\s+(\d+)\s+(\d+)$/) {
($size,$used,$free) = ($1,$2,$3);
if ($size != 0)
{
($percent = ($used/$size)*100) =~ s/^(\d+)(\.\d+)?$/$1%/;
} else {
($percent = '');
}
print <<END
<tr>
<td class='boldbase'><b>$Lang::tr{'swap'}</b></td>
<td align='right'>$size</td>
END
;
} elsif ($ram and $_ =~ m/^-\/\+ buffers\/cache:\s+(\d+)\s+(\d+)$/ ) {
($used,$free) = ($1,$2);
($percent = ($used/$ram)*100) =~ s/^(\d+)(\.\d+)?$/$1%/;
print "<tr><td colspan='2' class='boldbase'><b>$Lang::tr{'excluding buffers and cache'}</b></td>"
}
print <<END
<td align='right'>$used</td>
<td align='right'>$free</td>
<td>
END
;
&percentbar($percent);
print <<END
</td>
<td align='right'>$percent</td>
</tr>
END
;
}
}
close FREE;
print <<END
</table></td><td>
<table>
<tr><td class='boldbase'><b>$Lang::tr{'shared'}</b></td><td align='right'>$shared</td></tr>
<tr><td class='boldbase'><b>$Lang::tr{'buffers'}</b></td><td align='right'>$buffers</td></tr>
<tr><td class='boldbase'><b>$Lang::tr{'cached'}</b></td><td align='right'>$cached</td></tr>
</table>
</td></tr></table>
END
;
&Header::closebox();
print "<a name='disk'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'disk usage'});
print "<table>\n";
open(DF,'/bin/df -B M -x rootfs|');
while(<DF>)
{
if ($_ =~ m/^Filesystem/ )
{
print <<END
<tr>
<td align='left' class='boldbase'><b>$Lang::tr{'device'}</b></td>
<td align='left' class='boldbase'><b>$Lang::tr{'mounted on'}</b></td>
<td align='center' class='boldbase'><b>$Lang::tr{'size'}</b></td>
<td align='center' class='boldbase'><b>$Lang::tr{'used'}</b></td>
<td align='center' class='boldbase'><b>$Lang::tr{'free'}</b></td>
<td align='left' class='boldbase' colspan='2'><b>$Lang::tr{'percentage'}</b></td>
</tr>
END
;
}
else
{
my ($device,$size,$used,$free,$percent,$mount) = split;
print <<END
<tr>
<td>$device</td>
<td>$mount</td>
<td align='right'>$size</td>
<td align='right'>$used</td>
<td align='right'>$free</td>
<td>
END
;
&percentbar($percent);
print <<END
</td>
<td align='right'>$percent</td>
</tr>
END
;
}
}
close DF;
print "</table>\n";
&Header::closebox();
print "<a name='uptime'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'uptime and users'});
my $output = `/usr/bin/w`;
$output = &Header::cleanhtml($output,"y");
print "<pre>$output</pre>\n";
&Header::closebox();
print "<a name='modules'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'loaded modules'});
$output = qx+/sbin/lsmod+;
($output = &Header::cleanhtml($output,"y")) =~ s/\[.*\]//g;
print "<pre>\n$output\n</pre>\n";
&Header::closebox();
print "<a name='kernel'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'kernel version'});
print "<pre>\n";
print `/bin/uname -a`;
print "</pre>\n";
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
sub isrunning
{
my $cmd = $_[0];
my $status = "<td bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td>";
my $pid = '';
my $testcmd = '';
my $exename;
$cmd =~ /(^[a-z]+)/;
$exename = $1;
if (open(FILE, "/var/run/${cmd}.pid"))
{
$pid = <FILE>; chomp $pid;
close FILE;
if (open(FILE, "/proc/${pid}/status"))
{
while (<FILE>)
{
if (/^Name:\W+(.*)/) {
$testcmd = $1; }
}
close FILE;
if ($testcmd =~ /$exename/)
{
$status = "<td bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";
}
}
}
return $status;
}
sub percentbar
{
my $percent = $_[0];
my $fg = '#a0a0a0';
my $bg = '#e2e2e2';
if ($percent =~ m/^(\d+)%$/ )
{
print <<END
<table width='100' border='1' cellspacing='0' cellpadding='0' style='border-width:1px;border-style:solid;border-color:$fg;width:100px;height:10px;'>
<tr>
END
;
if ($percent eq "100%") {
print "<td width='100%' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'>"
} elsif ($percent eq "0%") {
print "<td width='100%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
} else {
print "<td width='$percent' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'></td><td width='" . (100-$1) . "%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
}
print <<END
<img src='/images/null.gif' width='1' height='1' alt='' /></td></tr></table>
END
;
}
}
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: status.cgi,v 1.6.2.7 2005/02/24 07:44:35 gespinasse Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::colourred} );
undef (@dummy);
my %netsettings=();
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
my %cgiparams=();
# Maps a nice printable name to the changing part of the pid file, which
# is also the name of the program
my %servicenames =
(
$Lang::tr{'dhcp server'} => 'dhcpd',
$Lang::tr{'web server'} => 'httpd',
$Lang::tr{'cron server'} => 'fcron',
$Lang::tr{'dns proxy server'} => 'dnsmasq',
$Lang::tr{'logging server'} => 'syslogd',
$Lang::tr{'kernel logging server'} => 'klogd',
$Lang::tr{'ntp server'} => 'ntpd',
$Lang::tr{'secure shell server'} => 'sshd',
$Lang::tr{'vpn'} => 'pluto',
$Lang::tr{'web proxy'} => 'squid'
);
my $iface = '';
if (open(FILE, "${General::swroot}/red/iface"))
{
$iface = <FILE>;
close FILE;
chomp $iface;
}
$servicenames{"$Lang::tr{'intrusion detection system'} (RED)"} = "snort_${iface}";
$servicenames{"$Lang::tr{'intrusion detection system'} (GREEN)"} = "snort_$netsettings{'GREEN_DEV'}";
if ($netsettings{'ORANGE_DEV'} ne '') {
$servicenames{"$Lang::tr{'intrusion detection system'} (ORANGE)"} = "snort_$netsettings{'ORANGE_DEV'}";
}
if ($netsettings{'BLUE_DEV'} ne '') {
$servicenames{"$Lang::tr{'intrusion detection system'} (BLUE)"} = "snort_$netsettings{'BLUE_DEV'}";
}
&Header::showhttpheaders();
&Header::getcgihash(\%cgiparams);
&Header::openpage($Lang::tr{'status information'}, 1, '');
&Header::openbigbox('100%', 'left');
print <<END
<table width='100%' cellspacing='0' cellpadding='5'border='0'>
<tr><td style="background-color: #EAE9EE;" align='left'>
<a href='#services'>$Lang::tr{'services'}</a> |
<a href='#memory'>$Lang::tr{'memory'}</a> |
<a href='#disk'>$Lang::tr{'disk usage'}</a> |
<a href='#uptime'>$Lang::tr{'uptime and users'}</a> |
<a href='#modules'>$Lang::tr{'loaded modules'}</a> |
<a href='#kernel'>$Lang::tr{'kernel version'}</a>
</td></tr></table>
END
;
print "<a name='services'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'services'});
print <<END
<div align='center'>
<table width='60%' cellspacing='0' border='0'>
END
;
my $lines = 0;
my $key = '';
foreach $key (sort keys %servicenames)
{
if ($lines % 2) {
print "<tr bgcolor='${Header::table1colour}'>\n"; }
else {
print "<tr bgcolor='${Header::table2colour}'>\n"; }
print "<td align='left'>$key</td>\n";
my $shortname = $servicenames{$key};
my $status = &isrunning($shortname);
print "$status\n";
print "</tr>\n";
$lines++;
}
print "</table></div>\n";
&Header::closebox();
print "<a name='memory'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'memory'});
print "<table><tr><td><table>";
my $ram=0;
my $size=0;
my $used=0;
my $free=0;
my $percent=0;
my $shared=0;
my $buffers=0;
my $cached=0;
open(FREE,'/usr/bin/free |');
while(<FREE>)
{
if ($_ =~ m/^\s+total\s+used\s+free\s+shared\s+buffers\s+cached$/ )
{
print <<END
<tr>
<td>&nbsp;</td>
<td align='center' class='boldbase'><b>$Lang::tr{'size'}</b></td>
<td align='center' class='boldbase'><b>$Lang::tr{'used'}</b></td>
<td align='center' class='boldbase'><b>$Lang::tr{'free'}</b></td>
<td align='left' class='boldbase' colspan='2'><b>$Lang::tr{'percentage'}</b></td>
</tr>
END
;
} else {
if ($_ =~ m/^Mem:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/) {
($ram,$size,$used,$free,$shared,$buffers,$cached) = ($1,$1,$2,$3,$4,$5,$6);
($percent = ($used/$size)*100) =~ s/^(\d+)(\.\d+)?$/$1%/;
print <<END
<tr>
<td class='boldbase'><b>$Lang::tr{'ram'}</b></td>
<td align='right'>$size</td>
END
;
} elsif ($_ =~ m/^Swap:\s+(\d+)\s+(\d+)\s+(\d+)$/) {
($size,$used,$free) = ($1,$2,$3);
if ($size != 0)
{
($percent = ($used/$size)*100) =~ s/^(\d+)(\.\d+)?$/$1%/;
} else {
($percent = '');
}
print <<END
<tr>
<td class='boldbase'><b>$Lang::tr{'swap'}</b></td>
<td align='right'>$size</td>
END
;
} elsif ($ram and $_ =~ m/^-\/\+ buffers\/cache:\s+(\d+)\s+(\d+)$/ ) {
($used,$free) = ($1,$2);
($percent = ($used/$ram)*100) =~ s/^(\d+)(\.\d+)?$/$1%/;
print "<tr><td colspan='2' class='boldbase'><b>$Lang::tr{'excluding buffers and cache'}</b></td>"
}
print <<END
<td align='right'>$used</td>
<td align='right'>$free</td>
<td>
END
;
&percentbar($percent);
print <<END
</td>
<td align='right'>$percent</td>
</tr>
END
;
}
}
close FREE;
print <<END
</table></td><td>
<table>
<tr><td class='boldbase'><b>$Lang::tr{'shared'}</b></td><td align='right'>$shared</td></tr>
<tr><td class='boldbase'><b>$Lang::tr{'buffers'}</b></td><td align='right'>$buffers</td></tr>
<tr><td class='boldbase'><b>$Lang::tr{'cached'}</b></td><td align='right'>$cached</td></tr>
</table>
</td></tr></table>
END
;
&Header::closebox();
print "<a name='disk'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'disk usage'});
print "<table>\n";
open(DF,'/bin/df -B M -x rootfs|');
while(<DF>)
{
if ($_ =~ m/^Filesystem/ )
{
print <<END
<tr>
<td align='left' class='boldbase'><b>$Lang::tr{'device'}</b></td>
<td align='left' class='boldbase'><b>$Lang::tr{'mounted on'}</b></td>
<td align='center' class='boldbase'><b>$Lang::tr{'size'}</b></td>
<td align='center' class='boldbase'><b>$Lang::tr{'used'}</b></td>
<td align='center' class='boldbase'><b>$Lang::tr{'free'}</b></td>
<td align='left' class='boldbase' colspan='2'><b>$Lang::tr{'percentage'}</b></td>
</tr>
END
;
}
else
{
my ($device,$size,$used,$free,$percent,$mount) = split;
print <<END
<tr>
<td>$device</td>
<td>$mount</td>
<td align='right'>$size</td>
<td align='right'>$used</td>
<td align='right'>$free</td>
<td>
END
;
&percentbar($percent);
print <<END
</td>
<td align='right'>$percent</td>
</tr>
END
;
}
}
close DF;
print "</table>\n";
&Header::closebox();
print "<a name='uptime'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'uptime and users'});
my $output = `/usr/bin/w`;
$output = &Header::cleanhtml($output,"y");
print "<pre>$output</pre>\n";
&Header::closebox();
print "<a name='modules'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'loaded modules'});
$output = qx+/sbin/lsmod+;
($output = &Header::cleanhtml($output,"y")) =~ s/\[.*\]//g;
print "<pre>\n$output\n</pre>\n";
&Header::closebox();
print "<a name='kernel'/>\n";
&Header::openbox('100%', 'left', $Lang::tr{'kernel version'});
print "<pre>\n";
print `/bin/uname -a`;
print "</pre>\n";
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
sub isrunning
{
my $cmd = $_[0];
my $status = "<td bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td>";
my $pid = '';
my $testcmd = '';
my $exename;
$cmd =~ /(^[a-z]+)/;
$exename = $1;
if (open(FILE, "/var/run/${cmd}.pid"))
{
$pid = <FILE>; chomp $pid;
close FILE;
if (open(FILE, "/proc/${pid}/status"))
{
while (<FILE>)
{
if (/^Name:\W+(.*)/) {
$testcmd = $1; }
}
close FILE;
if ($testcmd =~ /$exename/)
{
$status = "<td bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";
}
}
}
return $status;
}
sub percentbar
{
my $percent = $_[0];
my $fg = '#a0a0a0';
my $bg = '#e2e2e2';
if ($percent =~ m/^(\d+)%$/ )
{
print <<END
<table width='100' border='1' cellspacing='0' cellpadding='0' style='border-width:1px;border-style:solid;border-color:$fg;width:100px;height:10px;'>
<tr>
END
;
if ($percent eq "100%") {
print "<td width='100%' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'>"
} elsif ($percent eq "0%") {
print "<td width='100%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
} else {
print "<td width='$percent' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'></td><td width='" . (100-$1) . "%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
}
print <<END
<img src='/images/null.gif' width='1' height='1' alt='' /></td></tr></table>
END
;
}
}

View File

@@ -1,391 +1,391 @@
#!/usr/bin/perl
#
# IPCop CGIs
#
# This file is part of the IPCop Project
#
# This code is distributed under the terms of the GPL
#
# (c) Eric Oberlander June 2002
#
# (c) Darren Critchley June 2003 - added real time clock setting, etc
#
# $Id: time.cgi,v 1.4.2.11 2005/05/28 12:16:18 eoberlander Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %timesettings=();
my $errormessage = '';
&Header::showhttpheaders();
$timesettings{'ACTION'} = '';
$timesettings{'VALID'} = '';
$timesettings{'ENABLENTP'} = 'off';
$timesettings{'NTP_ADDR_1'} = '';
$timesettings{'NTP_ADDR_2'} = '';
$timesettings{'UPDATE_METHOD'} = 'manually';
$timesettings{'UPDATE_VALUE'} = '0';
$timesettings{'UPDATE_PERIOD'} = '';
$timesettings{'ENABLECLNTP'} = 'off';
$timesettings{'SETHOUR'} = '';
$timesettings{'SETMINUTES'} = '';
$timesettings{'SETDAY'} = '';
$timesettings{'SETMONTH'} = '';
$timesettings{'SETYEAR'} = '';
&Header::getcgihash(\%timesettings);
if ($timesettings{'ACTION'} eq $Lang::tr{'instant update'})
{
if ($timesettings{'SETHOUR'} eq '' || $timesettings{'SETHOUR'} < 0 || $timesettings{'SETHOUR'} > 23) {
$errormessage = $Lang::tr{'invalid time entered'};
goto UPDTERROR;
}
if ($timesettings{'SETMINUTES'} eq '' || $timesettings{'SETMINUTES'} < 0 || $timesettings{'SETMINUTES'} > 59) {
$errormessage = $Lang::tr{'invalid time entered'};
goto UPDTERROR;
}
if ($timesettings{'SETDAY'} eq '' || $timesettings{'SETDAY'} < 1 || $timesettings{'SETDAY'} > 31) {
$errormessage = $Lang::tr{'invalid date entered'};
goto UPDTERROR;
}
if ($timesettings{'SETMONTH'} eq '' || $timesettings{'SETMONTH'} < 1 || $timesettings{'SETMONTH'} > 12) {
$errormessage = $Lang::tr{'invalid date entered'};
goto UPDTERROR;
}
if ($timesettings{'SETYEAR'} eq '' || $timesettings{'SETYEAR'} < 2003 || $timesettings{'SETYEAR'} > 2030) {
$errormessage = $Lang::tr{'invalid date entered'};
goto UPDTERROR;
}
UPDTERROR:
if ($errormessage) {
$timesettings{'VALID'} = 'no'; }
else {
$timesettings{'VALID'} = 'yes'; }
if ($timesettings{'VALID'} eq 'yes') {
# we want date in YYYY-MM-DD HH:MM format for date command
# EAO changed datestring to ISO 6801 format 2003-08-11
my $datestring = "$timesettings{'SETYEAR'}-$timesettings{'SETMONTH'}-$timesettings{'SETDAY'}";
my $timestring = "$timesettings{'SETHOUR'}:$timesettings{'SETMINUTES'}";
# EAO setdate.c also revised for ISO 6801 date format 2003-08-11
system ('/usr/local/bin/setdate', $datestring, $timestring);
&General::log("$Lang::tr{'time date manually reset'} $datestring $timestring");
}
unless ($errormessage) {
undef %timesettings;
}
}
if ($timesettings{'ACTION'} eq $Lang::tr{'save'})
{
if ($timesettings{'ENABLENTP'} eq 'on')
{
if ( ! ( &General::validfqdn($timesettings{'NTP_ADDR_1'}) ||
&General::validip ($timesettings{'NTP_ADDR_1'})))
{
$errormessage = $Lang::tr{'invalid primary ntp'};
goto ERROR;
}
}
if ($timesettings{'NTP_ADDR_2'})
{
if ( ! ( &General::validfqdn($timesettings{'NTP_ADDR_2'}) ||
&General::validip ($timesettings{'NTP_ADDR_2'})))
{
$errormessage = $Lang::tr{'invalid secondary ntp'};
goto ERROR;
}
}
if (!($timesettings{'NTP_ADDR_1'}) && $timesettings{'NTP_ADDR_2'})
{
$errormessage = $Lang::tr{'cannot specify secondary ntp without specifying primary'};
goto ERROR;
}
if (!($timesettings{'UPDATE_VALUE'} =~ /^\d+$/) || $timesettings{'UPDATE_VALUE'} <= 0)
{
$errormessage = $Lang::tr{'invalid time period'};
goto ERROR;
}
if ($timesettings{'ENABLENTP'} ne "on" && $timesettings{'ENABLECLNTP'} eq "on")
{
$errormessage = $Lang::tr{'ntp must be enabled to have clients'};
goto ERROR;
}
if ($timesettings{'ENABLENTP'} eq "on" && !($timesettings{'NTP_ADDR_1'}) && !($timesettings{'NTP_ADDR_2'}))
{
$errormessage = $Lang::tr{'cannot enable ntp without specifying primary'};
goto ERROR;
}
ERROR:
if ($errormessage) {
$timesettings{'VALID'} = 'no'; }
else {
$timesettings{'VALID'} = 'yes'; }
&General::writehash("${General::swroot}/time/settings", \%timesettings);
open(FILE, ">/${General::swroot}/time/settime.conf") or die "Unable to write settime.conf file";
flock(FILE, 2);
print FILE "$timesettings{'NTP_ADDR_1'} $timesettings{'NTP_ADDR_2'}\n";
close FILE;
my $updateperiod=0;
if ($timesettings{'UPDATE_PERIOD'} eq 'daily') {
$updateperiod = $timesettings{'UPDATE_VALUE'} * 1440; }
elsif ($timesettings{'UPDATE_PERIOD'} eq 'weekly') {
$updateperiod = $timesettings{'UPDATE_VALUE'} * 10080; }
elsif ($timesettings{'UPDATE_PERIOD'} eq 'monthly') {
$updateperiod = $timesettings{'UPDATE_VALUE'} * 40320; }
else {
$updateperiod = $timesettings{'UPDATE_VALUE'} * 60; }
$updateperiod = $updateperiod - 5;
if ($updateperiod <= 5) {
$updateperiod = 5; }
open(FILE, ">/${General::swroot}/time/counter.conf") or die "Unable to write counter.conf file";
flock(FILE, 2);
print FILE "$updateperiod\n";
close FILE;
if ($timesettings{'ENABLENTP'} eq 'on' && $timesettings{'VALID'} eq 'yes')
{
system ('/bin/touch', "${General::swroot}/time/enable");
&General::log($Lang::tr{'ntp syncro enabled'});
unlink "${General::swroot}/time/counter";
if ($timesettings{'UPDATE_METHOD'} eq 'periodically')
{
open(FILE, ">/${General::swroot}/time/counter") or die "Unable to write counter file";
flock(FILE, 2);
print FILE "$updateperiod\n";
close FILE;
}
if ($timesettings{'ENABLECLNTP'} eq 'on') # DPC added to 1.3.1
{
system ('/bin/touch', "${General::swroot}/time/allowclients"); # DPC added to 1.3.1
&General::log($Lang::tr{'ntpd restarted'}); # DPC added to 1.3.1
} else {
unlink "${General::swroot}/time/allowclients";
}
}
else
{
unlink "${General::swroot}/time/enable";
unlink "${General::swroot}/time/settimenow";
unlink "${General::swroot}/time/allowclients"; # DPC added to 1.3.1
&General::log($Lang::tr{'ntp syncro disabled'})
}
if (! $errormessage) {
system ('/usr/local/bin/restartntpd'); # DPC added to 1.3.1
}
}
# To enter an ' into a pushbutton solution is to use &#039; in it's definition
# but returned value when pressed is ' not the code. Cleanhtml recode the ' to enable comparison.
$timesettings{'ACTION'} = &Header::cleanhtml ($timesettings{'ACTION'});
if ($timesettings{'ACTION'} eq $Lang::tr{'set time now'} && $timesettings{'ENABLENTP'} eq 'on')
{
system ('/bin/touch', "${General::swroot}/time/settimenow");
}
&General::readhash("${General::swroot}/time/settings", \%timesettings);
if ($timesettings{'VALID'} eq '')
{
$timesettings{'ENABLENTP'} = 'off';
$timesettings{'UPDATE_METHOD'} = 'manually';
$timesettings{'UPDATE_VALUE'} = '1';
$timesettings{'UPDATE_PERIOD'} = 'daily';
$timesettings{'NTP_ADDR_1'} = 'pool.ntp.org';
$timesettings{'NTP_ADDR_2'} = 'pool.ntp.org';
}
unless ($errormessage) {
$timesettings{'SETMONTH'} = `date +'%m %e %Y %H %M'|cut -c 1-2`;
$timesettings{'SETDAY'} = `date +'%m %e %Y %H %M'|cut -c 4-5`;
$timesettings{'SETYEAR'} = `date +'%m %e %Y %H %M'|cut -c 7-10`;
$timesettings{'SETHOUR'} = `date +'%m %e %Y %H %M'|cut -c 12-13`;
$timesettings{'SETMINUTES'} = `date +'%m %e %Y %H %M'|cut -c 15-16`;
$_=$timesettings{'SETDAY'};
$timesettings{'SETDAY'}=~ tr/ /0/;
}
my %selected=();
my %checked=();
$checked{'ENABLENTP'}{'off'} = '';
$checked{'ENABLENTP'}{'on'} = '';
$checked{'ENABLENTP'}{$timesettings{'ENABLENTP'}} = "checked='checked'";
$checked{'ENABLECLNTP'}{'off'} = '';
$checked{'ENABLECLNTP'}{'on'} = '';
$checked{'ENABLECLNTP'}{$timesettings{'ENABLECLNTP'}} = "checked='checked'";
$checked{'UPDATE_METHOD'}{'manually'} = '';
$checked{'UPDATE_METHOD'}{'periodically'} = '';
$checked{'UPDATE_METHOD'}{$timesettings{'UPDATE_METHOD'}} = "checked='checked'";
$selected{'UPDATE_PERIOD'}{'hourly'} = '';
$selected{'UPDATE_PERIOD'}{'daily'} = '';
$selected{'UPDATE_PERIOD'}{'weekly'} = '';
$selected{'UPDATE_PERIOD'}{'monthly'} = '';
$selected{'UPDATE_PERIOD'}{$timesettings{'UPDATE_PERIOD'}} = "selected='selected'";
# added to v0.0.4 to refresh screen if syncro event queued
my $refresh = '';
if ( -e "${General::swroot}/time/settimenow") {
$refresh = "<meta http-equiv='refresh' content='60;' />";
}
&Header::openpage($Lang::tr{'ntp configuration'}, 1, $refresh);
&Header::openbigbox('100%', 'left', '', $errormessage);
# DPC move error message to top so it is seen!
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>\n";
&Header::closebox();
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
&Header::openbox('100%', 'left', $Lang::tr{'network time'});
print <<END
<table width='100%'>
<tr>
<td><input type='checkbox' name='ENABLENTP' $checked{'ENABLENTP'}{'on'} /></td>
<td width='100%' colspan='4' class='base'>$Lang::tr{'network time from'}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td width='100%' class='base' colspan='4'>
END
;
if ( -e "${General::swroot}/time/lastset")
{
print "$Lang::tr{'clock last synchronized at'}\n";
my $output = `cat ${General::swroot}/time/lastset`;
print $output;
}
else
{
print "$Lang::tr{'clock has not been synchronized'}\n";
}
print <<END
</td></tr>
<tr>
<td>&nbsp;</td>
<td width='25%' class='base'>$Lang::tr{'primary ntp server'}:</td>
<td width='25%'><input type='text' name='NTP_ADDR_1' value='$timesettings{'NTP_ADDR_1'}' /></td>
<td width='25%' class='base'>$Lang::tr{'secondary ntp server'}: &nbsp;<img src='/blob.gif' align='top' alt='*' /></td>
<td width='25%'><input type='text' name='NTP_ADDR_2' value='$timesettings{'NTP_ADDR_2'}' /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td class='base' colspan='4'><input type='checkbox' name='ENABLECLNTP' $checked{'ENABLECLNTP'}{'on'} /> $Lang::tr{'clenabled'}</td>
</tr>
</table>
<table width='100%'>
<tr>
<td colspan='4'><hr /><b>$Lang::tr{'update time'}</b></td>
</tr>
<tr>
<td>&nbsp;</td>
<td class='base' colspan='2'>$Lang::tr{'set time now help'}</td>
</tr>
<tr>
<td class='base'><input type='radio' name='UPDATE_METHOD' value='periodically' $checked{'UPDATE_METHOD'}{'periodically'} /></td>
<td width='15%'>$Lang::tr{'every'}: </td>
<td width='35%'><input type='text' name='UPDATE_VALUE' size='3' maxlength='3' value='$timesettings{'UPDATE_VALUE'}' />
<select name='UPDATE_PERIOD'>
<option value='hourly' $selected{'UPDATE_PERIOD'}{'hourly'}>$Lang::tr{'hours'}</option>
<option value='daily' $selected{'UPDATE_PERIOD'}{'daily'}>$Lang::tr{'days'}</option>
<option value='weekly' $selected{'UPDATE_PERIOD'}{'weekly'}>$Lang::tr{'weeks'}</option>
<option value='monthly' $selected{'UPDATE_PERIOD'}{'monthly'}>$Lang::tr{'months'}</option>
</select></td>
<td width='50%'>&nbsp;</td>
</tr>
<tr>
<td class='base'><input type='radio' name='UPDATE_METHOD' value='manually' $checked{'UPDATE_METHOD'}{'manually'} /></td>
<td colspan='2'>$Lang::tr{'manually'}</td>
</tr>
END
;
if ( -e "${General::swroot}/time/settimenow") {
print "<tr>\n<td align='center'><img src='/images/clock.gif' alt='' /></td>\n";
print "<td colspan='2'><font color='red'>$Lang::tr{'waiting to synchronize clock'}...</font></td></tr>\n";
}
print <<END
</table>
<br />
<hr />
<table width='100%'>
<tr>
<td width='30%'><img src='/blob.gif' alt='*' /> $Lang::tr{'this field may be blank'}</td>
<td width='40%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'set time now'}' /></td>
<td width='25%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
<td width='5%' align='right'>
<a href='${General::adminmanualurl}/services.html#services_time' target='_blank'><img src='/images/web-support.png' title='$Lang::tr{'online help en'}' /></a>
</td>
</tr>
</table>
END
;
&Header::closebox();
&Header::openbox('100%', 'left', $Lang::tr{'update time'});
print <<END
<table width='100%'>
<tr>
<td width='65%' class='base'>
<table>
<tr>
<td>$Lang::tr{'year'}:&nbsp;</td>
<td><input type='text' name='SETYEAR' size='4' maxlength='4' value='$timesettings{'SETYEAR'}' /></td>
<td>&nbsp;$Lang::tr{'month'}:&nbsp;</td>
<td><input type='text' name='SETMONTH' size='2' maxlength='2' value='$timesettings{'SETMONTH'}' /></td>
<td>&nbsp;$Lang::tr{'day'}:&nbsp;</td>
<td><input type='text' name='SETDAY' size='2' maxlength='2' value='$timesettings{'SETDAY'}' /></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;$Lang::tr{'hours2'}:&nbsp;</td>
<td><input type='text' name='SETHOUR' size='2' maxlength='2' value='$timesettings{'SETHOUR'}' /></td>
<td>&nbsp;$Lang::tr{'minutes'}:&nbsp;</td>
<td><input type='text' name='SETMINUTES' size='2' maxlength='2' value='$timesettings{'SETMINUTES'}' /></td>
</tr>
</table>
</td>
<td width='35%' align='center' class='base'><input type='submit' name='ACTION' value='$Lang::tr{'instant update'}' /></td>
</tr>
</table>
END
;
&Header::closebox();
print "</form>\n";
&Header::closebigbox();
&Header::closepage();
#!/usr/bin/perl
#
# IPCop CGIs
#
# This file is part of the IPCop Project
#
# This code is distributed under the terms of the GPL
#
# (c) Eric Oberlander June 2002
#
# (c) Darren Critchley June 2003 - added real time clock setting, etc
#
# $Id: time.cgi,v 1.4.2.11 2005/05/28 12:16:18 eoberlander Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %timesettings=();
my $errormessage = '';
&Header::showhttpheaders();
$timesettings{'ACTION'} = '';
$timesettings{'VALID'} = '';
$timesettings{'ENABLENTP'} = 'off';
$timesettings{'NTP_ADDR_1'} = '';
$timesettings{'NTP_ADDR_2'} = '';
$timesettings{'UPDATE_METHOD'} = 'manually';
$timesettings{'UPDATE_VALUE'} = '0';
$timesettings{'UPDATE_PERIOD'} = '';
$timesettings{'ENABLECLNTP'} = 'off';
$timesettings{'SETHOUR'} = '';
$timesettings{'SETMINUTES'} = '';
$timesettings{'SETDAY'} = '';
$timesettings{'SETMONTH'} = '';
$timesettings{'SETYEAR'} = '';
&Header::getcgihash(\%timesettings);
if ($timesettings{'ACTION'} eq $Lang::tr{'instant update'})
{
if ($timesettings{'SETHOUR'} eq '' || $timesettings{'SETHOUR'} < 0 || $timesettings{'SETHOUR'} > 23) {
$errormessage = $Lang::tr{'invalid time entered'};
goto UPDTERROR;
}
if ($timesettings{'SETMINUTES'} eq '' || $timesettings{'SETMINUTES'} < 0 || $timesettings{'SETMINUTES'} > 59) {
$errormessage = $Lang::tr{'invalid time entered'};
goto UPDTERROR;
}
if ($timesettings{'SETDAY'} eq '' || $timesettings{'SETDAY'} < 1 || $timesettings{'SETDAY'} > 31) {
$errormessage = $Lang::tr{'invalid date entered'};
goto UPDTERROR;
}
if ($timesettings{'SETMONTH'} eq '' || $timesettings{'SETMONTH'} < 1 || $timesettings{'SETMONTH'} > 12) {
$errormessage = $Lang::tr{'invalid date entered'};
goto UPDTERROR;
}
if ($timesettings{'SETYEAR'} eq '' || $timesettings{'SETYEAR'} < 2003 || $timesettings{'SETYEAR'} > 2030) {
$errormessage = $Lang::tr{'invalid date entered'};
goto UPDTERROR;
}
UPDTERROR:
if ($errormessage) {
$timesettings{'VALID'} = 'no'; }
else {
$timesettings{'VALID'} = 'yes'; }
if ($timesettings{'VALID'} eq 'yes') {
# we want date in YYYY-MM-DD HH:MM format for date command
# EAO changed datestring to ISO 6801 format 2003-08-11
my $datestring = "$timesettings{'SETYEAR'}-$timesettings{'SETMONTH'}-$timesettings{'SETDAY'}";
my $timestring = "$timesettings{'SETHOUR'}:$timesettings{'SETMINUTES'}";
# EAO setdate.c also revised for ISO 6801 date format 2003-08-11
system ('/usr/local/bin/setdate', $datestring, $timestring);
&General::log("$Lang::tr{'time date manually reset'} $datestring $timestring");
}
unless ($errormessage) {
undef %timesettings;
}
}
if ($timesettings{'ACTION'} eq $Lang::tr{'save'})
{
if ($timesettings{'ENABLENTP'} eq 'on')
{
if ( ! ( &General::validfqdn($timesettings{'NTP_ADDR_1'}) ||
&General::validip ($timesettings{'NTP_ADDR_1'})))
{
$errormessage = $Lang::tr{'invalid primary ntp'};
goto ERROR;
}
}
if ($timesettings{'NTP_ADDR_2'})
{
if ( ! ( &General::validfqdn($timesettings{'NTP_ADDR_2'}) ||
&General::validip ($timesettings{'NTP_ADDR_2'})))
{
$errormessage = $Lang::tr{'invalid secondary ntp'};
goto ERROR;
}
}
if (!($timesettings{'NTP_ADDR_1'}) && $timesettings{'NTP_ADDR_2'})
{
$errormessage = $Lang::tr{'cannot specify secondary ntp without specifying primary'};
goto ERROR;
}
if (!($timesettings{'UPDATE_VALUE'} =~ /^\d+$/) || $timesettings{'UPDATE_VALUE'} <= 0)
{
$errormessage = $Lang::tr{'invalid time period'};
goto ERROR;
}
if ($timesettings{'ENABLENTP'} ne "on" && $timesettings{'ENABLECLNTP'} eq "on")
{
$errormessage = $Lang::tr{'ntp must be enabled to have clients'};
goto ERROR;
}
if ($timesettings{'ENABLENTP'} eq "on" && !($timesettings{'NTP_ADDR_1'}) && !($timesettings{'NTP_ADDR_2'}))
{
$errormessage = $Lang::tr{'cannot enable ntp without specifying primary'};
goto ERROR;
}
ERROR:
if ($errormessage) {
$timesettings{'VALID'} = 'no'; }
else {
$timesettings{'VALID'} = 'yes'; }
&General::writehash("${General::swroot}/time/settings", \%timesettings);
open(FILE, ">/${General::swroot}/time/settime.conf") or die "Unable to write settime.conf file";
flock(FILE, 2);
print FILE "$timesettings{'NTP_ADDR_1'} $timesettings{'NTP_ADDR_2'}\n";
close FILE;
my $updateperiod=0;
if ($timesettings{'UPDATE_PERIOD'} eq 'daily') {
$updateperiod = $timesettings{'UPDATE_VALUE'} * 1440; }
elsif ($timesettings{'UPDATE_PERIOD'} eq 'weekly') {
$updateperiod = $timesettings{'UPDATE_VALUE'} * 10080; }
elsif ($timesettings{'UPDATE_PERIOD'} eq 'monthly') {
$updateperiod = $timesettings{'UPDATE_VALUE'} * 40320; }
else {
$updateperiod = $timesettings{'UPDATE_VALUE'} * 60; }
$updateperiod = $updateperiod - 5;
if ($updateperiod <= 5) {
$updateperiod = 5; }
open(FILE, ">/${General::swroot}/time/counter.conf") or die "Unable to write counter.conf file";
flock(FILE, 2);
print FILE "$updateperiod\n";
close FILE;
if ($timesettings{'ENABLENTP'} eq 'on' && $timesettings{'VALID'} eq 'yes')
{
system ('/bin/touch', "${General::swroot}/time/enable");
&General::log($Lang::tr{'ntp syncro enabled'});
unlink "${General::swroot}/time/counter";
if ($timesettings{'UPDATE_METHOD'} eq 'periodically')
{
open(FILE, ">/${General::swroot}/time/counter") or die "Unable to write counter file";
flock(FILE, 2);
print FILE "$updateperiod\n";
close FILE;
}
if ($timesettings{'ENABLECLNTP'} eq 'on') # DPC added to 1.3.1
{
system ('/bin/touch', "${General::swroot}/time/allowclients"); # DPC added to 1.3.1
&General::log($Lang::tr{'ntpd restarted'}); # DPC added to 1.3.1
} else {
unlink "${General::swroot}/time/allowclients";
}
}
else
{
unlink "${General::swroot}/time/enable";
unlink "${General::swroot}/time/settimenow";
unlink "${General::swroot}/time/allowclients"; # DPC added to 1.3.1
&General::log($Lang::tr{'ntp syncro disabled'})
}
if (! $errormessage) {
system ('/usr/local/bin/restartntpd'); # DPC added to 1.3.1
}
}
# To enter an ' into a pushbutton solution is to use &#039; in it's definition
# but returned value when pressed is ' not the code. Cleanhtml recode the ' to enable comparison.
$timesettings{'ACTION'} = &Header::cleanhtml ($timesettings{'ACTION'});
if ($timesettings{'ACTION'} eq $Lang::tr{'set time now'} && $timesettings{'ENABLENTP'} eq 'on')
{
system ('/bin/touch', "${General::swroot}/time/settimenow");
}
&General::readhash("${General::swroot}/time/settings", \%timesettings);
if ($timesettings{'VALID'} eq '')
{
$timesettings{'ENABLENTP'} = 'off';
$timesettings{'UPDATE_METHOD'} = 'manually';
$timesettings{'UPDATE_VALUE'} = '1';
$timesettings{'UPDATE_PERIOD'} = 'daily';
$timesettings{'NTP_ADDR_1'} = 'pool.ntp.org';
$timesettings{'NTP_ADDR_2'} = 'pool.ntp.org';
}
unless ($errormessage) {
$timesettings{'SETMONTH'} = `date +'%m %e %Y %H %M'|cut -c 1-2`;
$timesettings{'SETDAY'} = `date +'%m %e %Y %H %M'|cut -c 4-5`;
$timesettings{'SETYEAR'} = `date +'%m %e %Y %H %M'|cut -c 7-10`;
$timesettings{'SETHOUR'} = `date +'%m %e %Y %H %M'|cut -c 12-13`;
$timesettings{'SETMINUTES'} = `date +'%m %e %Y %H %M'|cut -c 15-16`;
$_=$timesettings{'SETDAY'};
$timesettings{'SETDAY'}=~ tr/ /0/;
}
my %selected=();
my %checked=();
$checked{'ENABLENTP'}{'off'} = '';
$checked{'ENABLENTP'}{'on'} = '';
$checked{'ENABLENTP'}{$timesettings{'ENABLENTP'}} = "checked='checked'";
$checked{'ENABLECLNTP'}{'off'} = '';
$checked{'ENABLECLNTP'}{'on'} = '';
$checked{'ENABLECLNTP'}{$timesettings{'ENABLECLNTP'}} = "checked='checked'";
$checked{'UPDATE_METHOD'}{'manually'} = '';
$checked{'UPDATE_METHOD'}{'periodically'} = '';
$checked{'UPDATE_METHOD'}{$timesettings{'UPDATE_METHOD'}} = "checked='checked'";
$selected{'UPDATE_PERIOD'}{'hourly'} = '';
$selected{'UPDATE_PERIOD'}{'daily'} = '';
$selected{'UPDATE_PERIOD'}{'weekly'} = '';
$selected{'UPDATE_PERIOD'}{'monthly'} = '';
$selected{'UPDATE_PERIOD'}{$timesettings{'UPDATE_PERIOD'}} = "selected='selected'";
# added to v0.0.4 to refresh screen if syncro event queued
my $refresh = '';
if ( -e "${General::swroot}/time/settimenow") {
$refresh = "<meta http-equiv='refresh' content='60;' />";
}
&Header::openpage($Lang::tr{'ntp configuration'}, 1, $refresh);
&Header::openbigbox('100%', 'left', '', $errormessage);
# DPC move error message to top so it is seen!
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>\n";
&Header::closebox();
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
&Header::openbox('100%', 'left', $Lang::tr{'network time'});
print <<END
<table width='100%'>
<tr>
<td><input type='checkbox' name='ENABLENTP' $checked{'ENABLENTP'}{'on'} /></td>
<td width='100%' colspan='4' class='base'>$Lang::tr{'network time from'}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td width='100%' class='base' colspan='4'>
END
;
if ( -e "${General::swroot}/time/lastset")
{
print "$Lang::tr{'clock last synchronized at'}\n";
my $output = `cat ${General::swroot}/time/lastset`;
print $output;
}
else
{
print "$Lang::tr{'clock has not been synchronized'}\n";
}
print <<END
</td></tr>
<tr>
<td>&nbsp;</td>
<td width='25%' class='base'>$Lang::tr{'primary ntp server'}:</td>
<td width='25%'><input type='text' name='NTP_ADDR_1' value='$timesettings{'NTP_ADDR_1'}' /></td>
<td width='25%' class='base'>$Lang::tr{'secondary ntp server'}: &nbsp;<img src='/blob.gif' align='top' alt='*' /></td>
<td width='25%'><input type='text' name='NTP_ADDR_2' value='$timesettings{'NTP_ADDR_2'}' /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td class='base' colspan='4'><input type='checkbox' name='ENABLECLNTP' $checked{'ENABLECLNTP'}{'on'} /> $Lang::tr{'clenabled'}</td>
</tr>
</table>
<table width='100%'>
<tr>
<td colspan='4'><hr /><b>$Lang::tr{'update time'}</b></td>
</tr>
<tr>
<td>&nbsp;</td>
<td class='base' colspan='2'>$Lang::tr{'set time now help'}</td>
</tr>
<tr>
<td class='base'><input type='radio' name='UPDATE_METHOD' value='periodically' $checked{'UPDATE_METHOD'}{'periodically'} /></td>
<td width='15%'>$Lang::tr{'every'}: </td>
<td width='35%'><input type='text' name='UPDATE_VALUE' size='3' maxlength='3' value='$timesettings{'UPDATE_VALUE'}' />
<select name='UPDATE_PERIOD'>
<option value='hourly' $selected{'UPDATE_PERIOD'}{'hourly'}>$Lang::tr{'hours'}</option>
<option value='daily' $selected{'UPDATE_PERIOD'}{'daily'}>$Lang::tr{'days'}</option>
<option value='weekly' $selected{'UPDATE_PERIOD'}{'weekly'}>$Lang::tr{'weeks'}</option>
<option value='monthly' $selected{'UPDATE_PERIOD'}{'monthly'}>$Lang::tr{'months'}</option>
</select></td>
<td width='50%'>&nbsp;</td>
</tr>
<tr>
<td class='base'><input type='radio' name='UPDATE_METHOD' value='manually' $checked{'UPDATE_METHOD'}{'manually'} /></td>
<td colspan='2'>$Lang::tr{'manually'}</td>
</tr>
END
;
if ( -e "${General::swroot}/time/settimenow") {
print "<tr>\n<td align='center'><img src='/images/clock.gif' alt='' /></td>\n";
print "<td colspan='2'><font color='red'>$Lang::tr{'waiting to synchronize clock'}...</font></td></tr>\n";
}
print <<END
</table>
<br />
<hr />
<table width='100%'>
<tr>
<td width='30%'><img src='/blob.gif' alt='*' /> $Lang::tr{'this field may be blank'}</td>
<td width='40%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'set time now'}' /></td>
<td width='25%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
<td width='5%' align='right'>
<a href='${General::adminmanualurl}/services.html#services_time' target='_blank'><img src='/images/web-support.png' title='$Lang::tr{'online help en'}' /></a>
</td>
</tr>
</table>
END
;
&Header::closebox();
&Header::openbox('100%', 'left', $Lang::tr{'update time'});
print <<END
<table width='100%'>
<tr>
<td width='65%' class='base'>
<table>
<tr>
<td>$Lang::tr{'year'}:&nbsp;</td>
<td><input type='text' name='SETYEAR' size='4' maxlength='4' value='$timesettings{'SETYEAR'}' /></td>
<td>&nbsp;$Lang::tr{'month'}:&nbsp;</td>
<td><input type='text' name='SETMONTH' size='2' maxlength='2' value='$timesettings{'SETMONTH'}' /></td>
<td>&nbsp;$Lang::tr{'day'}:&nbsp;</td>
<td><input type='text' name='SETDAY' size='2' maxlength='2' value='$timesettings{'SETDAY'}' /></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;$Lang::tr{'hours2'}:&nbsp;</td>
<td><input type='text' name='SETHOUR' size='2' maxlength='2' value='$timesettings{'SETHOUR'}' /></td>
<td>&nbsp;$Lang::tr{'minutes'}:&nbsp;</td>
<td><input type='text' name='SETMINUTES' size='2' maxlength='2' value='$timesettings{'SETMINUTES'}' /></td>
</tr>
</table>
</td>
<td width='35%' align='center' class='base'><input type='submit' name='ACTION' value='$Lang::tr{'instant update'}' /></td>
</tr>
</table>
END
;
&Header::closebox();
print "</form>\n";
&Header::closebigbox();
&Header::closepage();

View File

@@ -1,269 +1,269 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: updates.cgi,v 1.9.2.22 2005/12/01 20:41:53 franck78 Exp $
#
use LWP::UserAgent;
use File::Copy;
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
#workaround to suppress a warning when a variable is used only once
my @dummy = ( $General::version );
undef (@dummy);
my $warnmessage='';
my $errormessage='';
my @av=('');
my @pf=('');
&Header::showhttpheaders();
my %uploadsettings=();
$uploadsettings{'ACTION'} = '';
&Header::getcgihash(\%uploadsettings, {'wantfile' => 1, 'filevar' => 'FH'});
if ($uploadsettings{'ACTION'} eq $Lang::tr{'upload'}) {
# This code do not serve a lot because $General::version cannot change while the module is loaded. So no change
# can appear. More, this call should be called 'after' update is done !
# my $return = &downloadlist();
# if ($return && $return->is_success) {
# if (open(LIST, ">${General::swroot}/patches/available")){
# flock LIST, 2;
# my @this = split(/----START LIST----\n/,$return->content);
# print LIST $this[1];
# close(LIST);
# } else {
# $errormessage = $Lang::tr{'could not open available updates file'};
# }
# } else {
# if (open(LIST, "<${General::swroot}/patches/available")) {
# my @list = <LIST>;
# close(LIST);
# }
# $warnmessage = $Lang::tr{'could not download the available updates list'};
# }
if (copy ($uploadsettings{'FH'}, "/var/patches/patch-$$.tar.gz.gpg") != 1) {
$errormessage = $!;
} else {
my $exitcode = system("/usr/local/bin/installpackage $$ > /dev/null") >> 8;
if ($exitcode == 0) {
#Hack to get correct version displayed after update
open (XX,"perl -e \"require'${General::swroot}/general-functions.pl';print \\\$General::version\"|");
$General::version=<XX>;
close (XX);
&General::log("$Lang::tr{'the following update was successfully installed'} ($General::version)");
}
elsif($exitcode == 2) {
$errormessage = "$Lang::tr{'could not create directory'}";
}
elsif($exitcode == 3) {
$errormessage = "$Lang::tr{'this is not an authorised update'}";
}
elsif($exitcode == 4) {
$errormessage = "$Lang::tr{'this is not a valid archive'}";
}
elsif($exitcode == 5) {
$errormessage = "$Lang::tr{'could not open update information file'}";
}
elsif($exitcode == 6) {
$errormessage = "$Lang::tr{'could not open installed updates file'}";
}
elsif($exitcode == 7) {
$errormessage = "$Lang::tr{'this update is already installed'}";
}
elsif($exitcode == 11) {
$errormessage = "$Lang::tr{'not enough disk space'}";
} else {
$errormessage = "$Lang::tr{'package failed to install'}";
}
}
}
elsif ($uploadsettings{'ACTION'} eq $Lang::tr{'refresh update list'}) {
my $return = &downloadlist();
if ($return && $return->is_success) {
if (open(LIST, ">${General::swroot}/patches/available")) {
flock LIST, 2;
my @this = split(/----START LIST----\n/,$return->content);
print LIST $this[1];
close(LIST);
&General::log($Lang::tr{'successfully refreshed updates list'});
} else {
$errormessage = $Lang::tr{'could not open available updates file'};
}
} else {
$errormessage = $Lang::tr{'could not download the available updates list'};
}
}
elsif ($uploadsettings{'ACTION'} eq "$Lang::tr{'clear cache'} (squid)") {
system('/usr/local/bin/restartsquid','-f');
}
if (!open(AV, "<${General::swroot}/patches/available")) {
$errormessage = $Lang::tr{'could not open available updates file'};
} else {
@av = <AV>;
close(AV);
}
if (!open (PF, "<${General::swroot}/patches/installed")) {
$errormessage = $Lang::tr{'could not open installed updates file'};
} else {
@pf = <PF>;
close (PF);
#substract installed patch from list displayed (AV list may not be updated)
foreach my $P (@pf) {
$P =~ /^(...)/;
my $order=$1;
my $idx=0;
foreach my $A (@av) {
$A =~ /^(...)/;
if ($1 eq $order) { # match
splice (@av,$idx,1);
last;
}
$idx++;
}
}
}
&Header::openpage($Lang::tr{'updates'}, 1, '');
&Header::openbigbox('100%', 'left', 'download.png', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print $errormessage;
print "&nbsp;";
&Header::closebox();
}
if ($warnmessage) {
&Header::openbox('100%', 'LEFT', "$Lang::tr{'warning messages'}:");
print "<CLASS NAME='base'>$warnmessage \n";
print "&nbsp;</CLASS>\n";
&Header::closebox();
}
&Header::openbox('100%', 'left', $Lang::tr{'available updates'});
if ( defined $av[0] ) {
print $Lang::tr{'there are updates available'};
print qq|<table width='100%' border='0' cellpadding='2' cellspacing='0'>
<tr>
<td width='5%'><b>$Lang::tr{'id'}</b></td>
<td width='15%'><b>$Lang::tr{'title'}</b></td>
<td width='50%'><b>$Lang::tr{'description'}</b></td>
<td width='15%'><b>$Lang::tr{'released'}</b></td>
<td width='15%'>&nbsp;</td>
</tr>
|;
foreach (@av) {
my @temp = split(/\|/,$_);
print "<tr><td valign='top'>$temp[0]</td><td valign='top'>$temp[1]</td><td valign='top'>$temp[2]</td><td valign='top'>$temp[3]</td><td valign='top'><a href='$temp[4]' target='_new'>$Lang::tr{'info'}</a></td></tr>";
}
print "</table>";
} else {
print $Lang::tr{'all updates installed'};
}
print qq|<hr /><br>
$Lang::tr{'to install an update'}
<br />
<form method='post' action='/cgi-bin/updates.cgi' enctype='multipart/form-data'>
<table>
<tr>
<td align='right' class='base'>
<b>$Lang::tr{'upload update file'}</b></td>
<td><input type="file" size='40' name="FH" /> <input type='submit' name='ACTION' value='$Lang::tr{'upload'}' />
</td></tr>
</table>|;
print "<b>$Lang::tr{'disk usage'}</b>";
open (XX,'df -h / /var/log|');
my @df=<XX>;
close (XX);
print "<table cellpadding='2'>";
map ( $_ =~ s/ +/<td>/g,@df); # tablify each line!
print "<tr><td>$df[0]</tr>";
print "<tr><td>$df[1]</tr>";
print "<tr><td>$df[2]<td><input type='submit' name='ACTION' value='$Lang::tr{'clear cache'} (squid)' /></tr>";
print "</table>";
print "\n<hr />";
print "\n<table width='100%'>\n<tr>";
print "\n\t<td width='50%'>&nbsp;</td>";
print "\n\t<td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'refresh update list'}' /></td></tr>";
print "\n</table>\n";
print "</form>";
&Header::closebox();
&Header::openbox('100%', 'LEFT', $Lang::tr{'installed updates'});
print qq|<table width='100%' border='0' cellpadding='2' cellspacing='0'>
<tr>
<td width='5%'><b>$Lang::tr{'id'}</b></td>
<td width='15%'><b>$Lang::tr{'title'}</b></td>
<td width='50%'><b>$Lang::tr{'description'}</b></td>
<td width='15%'><b>$Lang::tr{'released'}</b></td>
<td width='15%'><b>$Lang::tr{'installed'}</b></td>
</tr>
|;
foreach my $pf (@pf) {
next if $pf =~ m/^#/;
my @temp = split(/\|/,$pf);
#??? @av = grep(!/^$temp[0]/, @av);
print "<tr><td valign='top'>" . join("</td><td valign='top'>",@temp) . "</td></tr>";
}
close(PF);
print "</table>";
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
sub downloadlist {
unless (-e "${General::swroot}/red/active") {
return 0;
}
my $downloader = LWP::UserAgent->new;
$downloader->timeout(5);
my %proxysettings=();
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
if ($proxysettings{'UPSTREAM_USER'}) {
$downloader->proxy("http","http://$proxysettings{'UPSTREAM_USER'}:$proxysettings{'UPSTREAM_PASSWORD'}@"."$peer:$peerport/");
} else {
$downloader->proxy("http","http://$peer:$peerport/");
}
}
return $downloader->get("http://www.ipcop.org/patches/${General::version}", 'Cache-Control', 'no-cache');
}
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: updates.cgi,v 1.9.2.22 2005/12/01 20:41:53 franck78 Exp $
#
use LWP::UserAgent;
use File::Copy;
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
#workaround to suppress a warning when a variable is used only once
my @dummy = ( $General::version );
undef (@dummy);
my $warnmessage='';
my $errormessage='';
my @av=('');
my @pf=('');
&Header::showhttpheaders();
my %uploadsettings=();
$uploadsettings{'ACTION'} = '';
&Header::getcgihash(\%uploadsettings, {'wantfile' => 1, 'filevar' => 'FH'});
if ($uploadsettings{'ACTION'} eq $Lang::tr{'upload'}) {
# This code do not serve a lot because $General::version cannot change while the module is loaded. So no change
# can appear. More, this call should be called 'after' update is done !
# my $return = &downloadlist();
# if ($return && $return->is_success) {
# if (open(LIST, ">${General::swroot}/patches/available")){
# flock LIST, 2;
# my @this = split(/----START LIST----\n/,$return->content);
# print LIST $this[1];
# close(LIST);
# } else {
# $errormessage = $Lang::tr{'could not open available updates file'};
# }
# } else {
# if (open(LIST, "<${General::swroot}/patches/available")) {
# my @list = <LIST>;
# close(LIST);
# }
# $warnmessage = $Lang::tr{'could not download the available updates list'};
# }
if (copy ($uploadsettings{'FH'}, "/var/patches/patch-$$.tar.gz.gpg") != 1) {
$errormessage = $!;
} else {
my $exitcode = system("/usr/local/bin/installpackage $$ > /dev/null") >> 8;
if ($exitcode == 0) {
#Hack to get correct version displayed after update
open (XX,"perl -e \"require'${General::swroot}/general-functions.pl';print \\\$General::version\"|");
$General::version=<XX>;
close (XX);
&General::log("$Lang::tr{'the following update was successfully installed'} ($General::version)");
}
elsif($exitcode == 2) {
$errormessage = "$Lang::tr{'could not create directory'}";
}
elsif($exitcode == 3) {
$errormessage = "$Lang::tr{'this is not an authorised update'}";
}
elsif($exitcode == 4) {
$errormessage = "$Lang::tr{'this is not a valid archive'}";
}
elsif($exitcode == 5) {
$errormessage = "$Lang::tr{'could not open update information file'}";
}
elsif($exitcode == 6) {
$errormessage = "$Lang::tr{'could not open installed updates file'}";
}
elsif($exitcode == 7) {
$errormessage = "$Lang::tr{'this update is already installed'}";
}
elsif($exitcode == 11) {
$errormessage = "$Lang::tr{'not enough disk space'}";
} else {
$errormessage = "$Lang::tr{'package failed to install'}";
}
}
}
elsif ($uploadsettings{'ACTION'} eq $Lang::tr{'refresh update list'}) {
my $return = &downloadlist();
if ($return && $return->is_success) {
if (open(LIST, ">${General::swroot}/patches/available")) {
flock LIST, 2;
my @this = split(/----START LIST----\n/,$return->content);
print LIST $this[1];
close(LIST);
&General::log($Lang::tr{'successfully refreshed updates list'});
} else {
$errormessage = $Lang::tr{'could not open available updates file'};
}
} else {
$errormessage = $Lang::tr{'could not download the available updates list'};
}
}
elsif ($uploadsettings{'ACTION'} eq "$Lang::tr{'clear cache'} (squid)") {
system('/usr/local/bin/restartsquid','-f');
}
if (!open(AV, "<${General::swroot}/patches/available")) {
$errormessage = $Lang::tr{'could not open available updates file'};
} else {
@av = <AV>;
close(AV);
}
if (!open (PF, "<${General::swroot}/patches/installed")) {
$errormessage = $Lang::tr{'could not open installed updates file'};
} else {
@pf = <PF>;
close (PF);
#substract installed patch from list displayed (AV list may not be updated)
foreach my $P (@pf) {
$P =~ /^(...)/;
my $order=$1;
my $idx=0;
foreach my $A (@av) {
$A =~ /^(...)/;
if ($1 eq $order) { # match
splice (@av,$idx,1);
last;
}
$idx++;
}
}
}
&Header::openpage($Lang::tr{'updates'}, 1, '');
&Header::openbigbox('100%', 'left', 'download.png', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print $errormessage;
print "&nbsp;";
&Header::closebox();
}
if ($warnmessage) {
&Header::openbox('100%', 'LEFT', "$Lang::tr{'warning messages'}:");
print "<CLASS NAME='base'>$warnmessage \n";
print "&nbsp;</CLASS>\n";
&Header::closebox();
}
&Header::openbox('100%', 'left', $Lang::tr{'available updates'});
if ( defined $av[0] ) {
print $Lang::tr{'there are updates available'};
print qq|<table width='100%' border='0' cellpadding='2' cellspacing='0'>
<tr>
<td width='5%'><b>$Lang::tr{'id'}</b></td>
<td width='15%'><b>$Lang::tr{'title'}</b></td>
<td width='50%'><b>$Lang::tr{'description'}</b></td>
<td width='15%'><b>$Lang::tr{'released'}</b></td>
<td width='15%'>&nbsp;</td>
</tr>
|;
foreach (@av) {
my @temp = split(/\|/,$_);
print "<tr><td valign='top'>$temp[0]</td><td valign='top'>$temp[1]</td><td valign='top'>$temp[2]</td><td valign='top'>$temp[3]</td><td valign='top'><a href='$temp[4]' target='_new'>$Lang::tr{'info'}</a></td></tr>";
}
print "</table>";
} else {
print $Lang::tr{'all updates installed'};
}
print qq|<hr /><br>
$Lang::tr{'to install an update'}
<br />
<form method='post' action='/cgi-bin/updates.cgi' enctype='multipart/form-data'>
<table>
<tr>
<td align='right' class='base'>
<b>$Lang::tr{'upload update file'}</b></td>
<td><input type="file" size='40' name="FH" /> <input type='submit' name='ACTION' value='$Lang::tr{'upload'}' />
</td></tr>
</table>|;
print "<b>$Lang::tr{'disk usage'}</b>";
open (XX,'df -h / /var/log|');
my @df=<XX>;
close (XX);
print "<table cellpadding='2'>";
map ( $_ =~ s/ +/<td>/g,@df); # tablify each line!
print "<tr><td>$df[0]</tr>";
print "<tr><td>$df[1]</tr>";
print "<tr><td>$df[2]<td><input type='submit' name='ACTION' value='$Lang::tr{'clear cache'} (squid)' /></tr>";
print "</table>";
print "\n<hr />";
print "\n<table width='100%'>\n<tr>";
print "\n\t<td width='50%'>&nbsp;</td>";
print "\n\t<td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'refresh update list'}' /></td></tr>";
print "\n</table>\n";
print "</form>";
&Header::closebox();
&Header::openbox('100%', 'LEFT', $Lang::tr{'installed updates'});
print qq|<table width='100%' border='0' cellpadding='2' cellspacing='0'>
<tr>
<td width='5%'><b>$Lang::tr{'id'}</b></td>
<td width='15%'><b>$Lang::tr{'title'}</b></td>
<td width='50%'><b>$Lang::tr{'description'}</b></td>
<td width='15%'><b>$Lang::tr{'released'}</b></td>
<td width='15%'><b>$Lang::tr{'installed'}</b></td>
</tr>
|;
foreach my $pf (@pf) {
next if $pf =~ m/^#/;
my @temp = split(/\|/,$pf);
#??? @av = grep(!/^$temp[0]/, @av);
print "<tr><td valign='top'>" . join("</td><td valign='top'>",@temp) . "</td></tr>";
}
close(PF);
print "</table>";
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
sub downloadlist {
unless (-e "${General::swroot}/red/active") {
return 0;
}
my $downloader = LWP::UserAgent->new;
$downloader->timeout(5);
my %proxysettings=();
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
if ($proxysettings{'UPSTREAM_USER'}) {
$downloader->proxy("http","http://$proxysettings{'UPSTREAM_USER'}:$proxysettings{'UPSTREAM_PASSWORD'}@"."$peer:$peerport/");
} else {
$downloader->proxy("http","http://$peer:$peerport/");
}
}
return $downloader->get("http://www.ipcop.org/patches/${General::version}", 'Cache-Control', 'no-cache');
}

View File

@@ -1,187 +1,187 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: upload.cgi,v 1.2.2.21 2005/08/14 23:43:38 gespinasse Exp $
#
use File::Copy;
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %uploadsettings=();
my $errormessage = '';
&Header::showhttpheaders();
$uploadsettings{'ACTION'} = '';
&Header::getcgihash(\%uploadsettings, {'wantfile' => 1, 'filevar' => 'FH'});
my $extraspeedtouchmessage='';
my $extrafritzdslmessage='';
my $extraeciadslmessage='';
my $modem='';
my $firmwarename='';
my $kernel='';
my $speedtouch = &Header::speedtouchversion;
if ($speedtouch == 4) {
$modem='v4_b';
$firmwarename="$Lang::tr{'upload'} ZZZL_3.012";
} else {
$modem='v0123';
$firmwarename="$Lang::tr{'upload'} KQD6_3.012";
}
$kernel=`/bin/uname -r | /usr/bin/tr -d '\012'`;
if ($uploadsettings{'ACTION'} eq $firmwarename) {
if ($modem eq 'v0123' || $modem eq 'v4_b') {
if (copy ($uploadsettings{'FH'}, "${General::swroot}/alcatelusb/firmware.$modem.bin") != 1) {
$errormessage = $!;
} else {
$extraspeedtouchmessage = $Lang::tr{'upload successful'};
}
}
}
elsif ($uploadsettings{'ACTION'} eq "$Lang::tr{'upload'} fcdsl-${General::version}.tgz")
{
if (copy ($uploadsettings{'FH'}, "/var/patches/fcdsl-x.tgz") != 1) {
$errormessage = $!;
} else {
$extrafritzdslmessage = $Lang::tr{'upload successful'};
}
}
elsif ($uploadsettings{'ACTION'} eq $Lang::tr{'upload synch.bin'})
{
if (copy ($uploadsettings{'FH'}, "${General::swroot}/eciadsl/synch.bin") != 1) {
$errormessage = $!;
} else {
$extraeciadslmessage = $Lang::tr{'upload successful'};
}
}
&Header::openpage($Lang::tr{'firmware upload'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>\n";
&Header::closebox();
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>\n";
&Header::openbox('100%','left', $Lang::tr{'alcatelusb upload'});
print <<END
<table width='100%'>
<tr>
<td colspan='4'>$Lang::tr{'alcatelusb help'}<br />
URL: <a href='http://www.speedtouch.com/support.htm'>http://www.speedtouch.com/support.htm</a>
</td>
</tr>
<tr><td colspan='4'>$Lang::tr{'modem'}: Rev <b>$speedtouch</b></td></tr>
<tr>
<td width='5%' class='base' nowrap='nowrap'>$Lang::tr{'upload file'}:&nbsp;</td>
<td width='45%'><input type="file" size='30' name="FH" /></td>
<td width='35%' align='center'><input type='submit' name='ACTION' value='$firmwarename' /></td>
<td width='15%'>
END
;
if (-e "${General::swroot}/alcatelusb/firmware.$modem.bin") {
if ($extraspeedtouchmessage ne '') {
print ("$extraspeedtouchmessage</td>");
} else {
print ("$Lang::tr{'present'}</td>");
}
} else {
print ("$Lang::tr{'not present'}</td>");
}
print <<END
</tr>
</table>
END
;
&Header::closebox();
&Header::openbox('100%','left', $Lang::tr{'eciadsl upload'});
print <<END
<table width='100%'>
<tr>
<td colspan='4'>$Lang::tr{'eciadsl help'}<br />
URL: <a href='http://eciadsl.flashtux.org/'>http://eciadsl.flashtux.org/</a>
</td>
</tr>
<tr>
<td width='5%' class='base' nowrap='nowrap'>$Lang::tr{'upload file'}:&nbsp;</td>
<td width='45%'><input type="file" size='30' name="FH" /></td>
<td width='35%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'upload synch.bin'}' /></td>
<td width='15%'>
END
;
if (-e "${General::swroot}/eciadsl/synch.bin") {
if ($extraeciadslmessage ne '') {
print ("$extraeciadslmessage</td>");
} else {
print ("$Lang::tr{'present'}</td>");
}
} else {
print ("$Lang::tr{'not present'}</td>");
}
print <<END
</tr>
</table>
END
;
&Header::closebox();
&Header::openbox('100%','left', $Lang::tr{'fritzdsl upload'});
print <<END
<table width='100%'>
<tr>
<td colspan='4'>$Lang::tr{'fritzdsl help'}<br />
URL: <a href='http://www.ipcop.org/'>http://www.ipcop.org/</a>
</td>
</tr>
<tr>
<td width='5%' class='base' nowrap='nowrap'>$Lang::tr{'upload file'}:&nbsp;</td>
<td width='45%'><input type="file" size='30' name="FH" /></td>
<td width='35%' align='center'><input type='submit' name='ACTION' value="$Lang::tr{'upload'} fcdsl-${General::version}.tgz"/></td>
<td width='15%'>
END
;
if ($extrafritzdslmessage ne '') {
print ("$extrafritzdslmessage</td></tr><tr><td>&nbsp;</td><td><pre>");
print `/usr/local/bin/installfcdsl`;
print ("</pre></td>");
} else {
if (-e "/lib/modules/$kernel/misc/fcdsl.o.gz") {
print ("$Lang::tr{'present'}</td>");
} else {
print ("$Lang::tr{'not present'}</td>");
}
}
print <<END
</tr>
</table>
END
;
&Header::closebox();
print "</form>\n";
&Header::closebigbox();
&Header::closepage();
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: upload.cgi,v 1.2.2.21 2005/08/14 23:43:38 gespinasse Exp $
#
use File::Copy;
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %uploadsettings=();
my $errormessage = '';
&Header::showhttpheaders();
$uploadsettings{'ACTION'} = '';
&Header::getcgihash(\%uploadsettings, {'wantfile' => 1, 'filevar' => 'FH'});
my $extraspeedtouchmessage='';
my $extrafritzdslmessage='';
my $extraeciadslmessage='';
my $modem='';
my $firmwarename='';
my $kernel='';
my $speedtouch = &Header::speedtouchversion;
if ($speedtouch == 4) {
$modem='v4_b';
$firmwarename="$Lang::tr{'upload'} ZZZL_3.012";
} else {
$modem='v0123';
$firmwarename="$Lang::tr{'upload'} KQD6_3.012";
}
$kernel=`/bin/uname -r | /usr/bin/tr -d '\012'`;
if ($uploadsettings{'ACTION'} eq $firmwarename) {
if ($modem eq 'v0123' || $modem eq 'v4_b') {
if (copy ($uploadsettings{'FH'}, "${General::swroot}/alcatelusb/firmware.$modem.bin") != 1) {
$errormessage = $!;
} else {
$extraspeedtouchmessage = $Lang::tr{'upload successful'};
}
}
}
elsif ($uploadsettings{'ACTION'} eq "$Lang::tr{'upload'} fcdsl-${General::version}.tgz")
{
if (copy ($uploadsettings{'FH'}, "/var/patches/fcdsl-x.tgz") != 1) {
$errormessage = $!;
} else {
$extrafritzdslmessage = $Lang::tr{'upload successful'};
}
}
elsif ($uploadsettings{'ACTION'} eq $Lang::tr{'upload synch.bin'})
{
if (copy ($uploadsettings{'FH'}, "${General::swroot}/eciadsl/synch.bin") != 1) {
$errormessage = $!;
} else {
$extraeciadslmessage = $Lang::tr{'upload successful'};
}
}
&Header::openpage($Lang::tr{'firmware upload'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>\n";
&Header::closebox();
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>\n";
&Header::openbox('100%','left', $Lang::tr{'alcatelusb upload'});
print <<END
<table width='100%'>
<tr>
<td colspan='4'>$Lang::tr{'alcatelusb help'}<br />
URL: <a href='http://www.speedtouch.com/support.htm'>http://www.speedtouch.com/support.htm</a>
</td>
</tr>
<tr><td colspan='4'>$Lang::tr{'modem'}: Rev <b>$speedtouch</b></td></tr>
<tr>
<td width='5%' class='base' nowrap='nowrap'>$Lang::tr{'upload file'}:&nbsp;</td>
<td width='45%'><input type="file" size='30' name="FH" /></td>
<td width='35%' align='center'><input type='submit' name='ACTION' value='$firmwarename' /></td>
<td width='15%'>
END
;
if (-e "${General::swroot}/alcatelusb/firmware.$modem.bin") {
if ($extraspeedtouchmessage ne '') {
print ("$extraspeedtouchmessage</td>");
} else {
print ("$Lang::tr{'present'}</td>");
}
} else {
print ("$Lang::tr{'not present'}</td>");
}
print <<END
</tr>
</table>
END
;
&Header::closebox();
&Header::openbox('100%','left', $Lang::tr{'eciadsl upload'});
print <<END
<table width='100%'>
<tr>
<td colspan='4'>$Lang::tr{'eciadsl help'}<br />
URL: <a href='http://eciadsl.flashtux.org/'>http://eciadsl.flashtux.org/</a>
</td>
</tr>
<tr>
<td width='5%' class='base' nowrap='nowrap'>$Lang::tr{'upload file'}:&nbsp;</td>
<td width='45%'><input type="file" size='30' name="FH" /></td>
<td width='35%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'upload synch.bin'}' /></td>
<td width='15%'>
END
;
if (-e "${General::swroot}/eciadsl/synch.bin") {
if ($extraeciadslmessage ne '') {
print ("$extraeciadslmessage</td>");
} else {
print ("$Lang::tr{'present'}</td>");
}
} else {
print ("$Lang::tr{'not present'}</td>");
}
print <<END
</tr>
</table>
END
;
&Header::closebox();
&Header::openbox('100%','left', $Lang::tr{'fritzdsl upload'});
print <<END
<table width='100%'>
<tr>
<td colspan='4'>$Lang::tr{'fritzdsl help'}<br />
URL: <a href='http://www.ipcop.org/'>http://www.ipcop.org/</a>
</td>
</tr>
<tr>
<td width='5%' class='base' nowrap='nowrap'>$Lang::tr{'upload file'}:&nbsp;</td>
<td width='45%'><input type="file" size='30' name="FH" /></td>
<td width='35%' align='center'><input type='submit' name='ACTION' value="$Lang::tr{'upload'} fcdsl-${General::version}.tgz"/></td>
<td width='15%'>
END
;
if ($extrafritzdslmessage ne '') {
print ("$extrafritzdslmessage</td></tr><tr><td>&nbsp;</td><td><pre>");
print `/usr/local/bin/installfcdsl`;
print ("</pre></td>");
} else {
if (-e "/lib/modules/$kernel/misc/fcdsl.o.gz") {
print ("$Lang::tr{'present'}</td>");
} else {
print ("$Lang::tr{'not present'}</td>");
}
}
print <<END
</tr>
</table>
END
;
&Header::closebox();
print "</form>\n";
&Header::closebigbox();
&Header::closepage();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,363 +1,363 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
# Copyright (c) 2002/04/13 Steve Bootes - Add destination IP support
#
# $Id: xtaccess.cgi,v 1.6.2.15 2005/03/05 08:44:32 eoberlander Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::colouryellow} );
undef (@dummy);
my %cgiparams=();
my %checked=();
my %selected=();
my $errormessage = '';
my $filename = "${General::swroot}/xtaccess/config";
my $aliasfile = "${General::swroot}/ethernet/aliases";
my $changed = 'no';
&Header::showhttpheaders();
$cgiparams{'ENABLED'} = 'off';
$cgiparams{'ACTION'} = '';
$cgiparams{'SRC'} = '';
$cgiparams{'DEST_PORT'} = '';
$cgiparams{'REMARK'} ='';
&Header::getcgihash(\%cgiparams);
open(FILE, $filename) or die 'Unable to open config file.';
my @current = <FILE>;
close(FILE);
if ($cgiparams{'ACTION'} eq $Lang::tr{'add'})
{
unless($cgiparams{'PROTOCOL'} =~ /^(tcp|udp)$/) { $errormessage = $Lang::tr{'invalid input'}; }
unless(&General::validipormask($cgiparams{'SRC'}))
{
if ($cgiparams{'SRC'} ne '') {
$errormessage = $Lang::tr{'source ip bad'}; }
else {
$cgiparams{'SRC'} = '0.0.0.0/0'; }
}
unless($errormessage){ $errormessage = &General::validportrange($cgiparams{'DEST_PORT'},'dst'); }
if ( ! $errormessage)
{
$cgiparams{'REMARK'} = &Header::cleanhtml($cgiparams{'REMARK'});
if($cgiparams{'EDITING'} eq 'no') {
open(FILE,">>$filename") or die 'Unable to open config file.';
flock FILE, 2;
print FILE "$cgiparams{'PROTOCOL'},$cgiparams{'SRC'},$cgiparams{'DEST_PORT'},$cgiparams{'ENABLED'},$cgiparams{'DEST'},$cgiparams{'REMARK'}\n";
} else {
open(FILE, ">$filename") or die 'Unable to open config file.';
flock FILE, 2;
my $id = 0;
foreach my $line (@current)
{
$id++;
if ($cgiparams{'EDITING'} eq $id) {
print FILE "$cgiparams{'PROTOCOL'},$cgiparams{'SRC'},$cgiparams{'DEST_PORT'},$cgiparams{'ENABLED'},$cgiparams{'DEST'},$cgiparams{'REMARK'}\n";
} else { print FILE "$line"; }
}
}
close(FILE);
undef %cgiparams;
$changed = 'yes';
&General::log($Lang::tr{'external access rule added'});
system('/usr/local/bin/setxtaccess');
} else {
# stay on edit mode if an error occur
if ($cgiparams{'EDITING'} ne 'no')
{
$cgiparams{'ACTION'} = $Lang::tr{'edit'};
$cgiparams{'ID'} = $cgiparams{'EDITING'};
}
}
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'remove'})
{
my $id = 0;
open(FILE, ">$filename") or die 'Unable to open config file.';
flock FILE, 2;
foreach my $line (@current)
{
$id++;
unless ($cgiparams{'ID'} eq $id) { print FILE "$line"; }
}
close(FILE);
system('/usr/local/bin/setxtaccess');
&General::log($Lang::tr{'external access rule removed'});
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'toggle enable disable'})
{
open(FILE, ">$filename") or die 'Unable to open config file.';
flock FILE, 2;
my $id = 0;
foreach my $line (@current)
{
$id++;
unless ($cgiparams{'ID'} eq $id) { print FILE "$line"; }
else
{
chomp($line);
my @temp = split(/\,/,$line);
print FILE "$temp[0],$temp[1],$temp[2],$cgiparams{'ENABLE'},$temp[4],$temp[5]\n";
}
}
close(FILE);
system('/usr/local/bin/setxtaccess');
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'})
{
my $id = 0;
foreach my $line (@current)
{
$id++;
if ($cgiparams{'ID'} eq $id)
{
chomp($line);
my @temp = split(/\,/,$line);
$cgiparams{'PROTOCOL'} = $temp[0];
$cgiparams{'SRC'} = $temp[1];
$cgiparams{'DEST_PORT'} = $temp[2];
$cgiparams{'ENABLED'} = $temp[3];
$cgiparams{'DEST'} = $temp[4];
$cgiparams{'REMARK'} = $temp[5];
}
}
}
if ($cgiparams{'ACTION'} eq '')
{
$cgiparams{'PROTOCOL'} = 'tcp';
$cgiparams{'DEST'} = '0.0.0.0';
$cgiparams{'ENABLED'} = 'on';
}
$selected{'PROTOCOL'}{'udp'} = '';
$selected{'PROTOCOL'}{'tcp'} = '';
$selected{'PROTOCOL'}{$cgiparams{'PROTOCOL'}} = "selected='selected'";
$selected{'DEST'}{$cgiparams{'DEST'}} = "selected='selected'";
$checked{'ENABLED'}{'off'} = '';
$checked{'ENABLED'}{'on'} = '';
$checked{'ENABLED'}{$cgiparams{'ENABLED'}} = "checked='checked'";
&Header::openpage($Lang::tr{'external access configuration'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<class name='base'>$errormessage\n";
print "&nbsp;</class>\n";
&Header::closebox();
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
my $buttontext = $Lang::tr{'add'};
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'}) {
&Header::openbox('100%', 'left', $Lang::tr{'edit a rule'});
$buttontext = $Lang::tr{'update'};
} else {
&Header::openbox('100%', 'left', $Lang::tr{'add a new rule'});
}
print <<END
<table width='100%'>
<tr>
<td width='10%'>
<select name='PROTOCOL'>
<option value='udp' $selected{'PROTOCOL'}{'udp'}>UDP</option>
<option value='tcp' $selected{'PROTOCOL'}{'tcp'}>TCP</option>
</select>
</td>
<td class='base'><font color='${Header::colourred}'>$Lang::tr{'source network'}</font></td>
<td><input type='text' name='SRC' value='$cgiparams{'SRC'}' size='32' /></td>
<td class='base'><font color='${Header::colourred}'>$Lang::tr{'destination port'}:</font></td>
<td><input type='text' name='DEST_PORT' value='$cgiparams{'DEST_PORT'}' size='5' /></td>
</tr>
</table>
<table width='100%'>
<tr>
<td width='10%' class='base'>$Lang::tr{'enabled'}<input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td>
<td class='base'><font color='${Header::colourred}'>$Lang::tr{'destination ip'}:&nbsp;</font>
<select name='DEST'>
<option value='0.0.0.0' $selected{'DEST'}{'0.0.0.0'}>DEFAULT IP</option>
END
;
open(ALIASES, "$aliasfile") or die 'Unable to open aliases file.';
while (<ALIASES>)
{
chomp($_);
my @temp = split(/\,/,$_);
if ($temp[1] eq 'on') {
print "<option value='$temp[0]' $selected{'DEST'}{$temp[0]}>$temp[0]";
if (defined $temp[2] and ($temp[2] ne '')) { print " ($temp[2])"; }
print "</option>\n";
}
}
close(ALIASES);
print <<END
</select>
</td>
</tr>
</table>
<table width='100%'>
<tr>
<td width ='10%' class='base'>
<font class='boldbase'>$Lang::tr{'remark'}:</font>&nbsp;<img src='/blob.gif' alt='*' />
</td>
<td width='65%'>
<input type='text' name='REMARK' value='$cgiparams{'REMARK'}' size='55' maxlength='50' />
</td>
<td width='25%' align='center'>
<input type='hidden' name='ACTION' value='$Lang::tr{'add'}' />
<input type='submit' name='SUBMIT' value='$buttontext' />
</td>
</tr>
</table>
<table width='100%'>
<tr>
<td class='base' width='30%'><img src='/blob.gif' alt ='*' align='top' />&nbsp;<font class='base'>$Lang::tr{'this field may be blank'}</font>
</td>
</tr>
</table>
END
;
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'}) {
print "<input type='hidden' name='EDITING' value='$cgiparams{'ID'}' />\n";
} else {
print "<input type='hidden' name='EDITING' value='no' />\n";
}
&Header::closebox();
print "</form>\n";
&Header::openbox('100%', 'left', $Lang::tr{'current rules'});
print <<END
<table width='100%'>
<tr>
<td width='10%' class='boldbase' align='center'><b>$Lang::tr{'proto'}</b></td>
<td width='20%' class='boldbase' align='center'><b>$Lang::tr{'source ip'}</b></td>
<td width='20%' class='boldbase' align='center'><b>$Lang::tr{'destination ip'}</b></td>
<td width='15%' class='boldbase' align='center'><b>$Lang::tr{'destination port'}</b></td>
<td width='30%' class='boldbase' align='center'><b>$Lang::tr{'remark'}</b></td>
<td width='5%' class='boldbase' colspan='3' align='center'><b>$Lang::tr{'action'}</b></td>
</tr>
END
;
# If something has happened re-read config
if($cgiparams{'ACTION'} ne '' or $changed ne 'no')
{
open(FILE, $filename) or die 'Unable to open config file.';
@current = <FILE>;
close(FILE);
}
my $id = 0;
foreach my $line (@current)
{
$id++;
chomp($line);
my @temp = split(/\,/,$line);
my $protocol = '';
my $gif = '';
my $gdesc = '';
my $toggle = '';
if ($temp[0] eq 'udp') {
$protocol = 'UDP'; }
else {
$protocol = 'TCP' }
if($cgiparams{'ACTION'} eq $Lang::tr{'edit'} && $cgiparams{'ID'} eq $id) {
print "<tr bgcolor='${Header::colouryellow}'>\n"; }
elsif ($id % 2) {
print "<tr bgcolor='${Header::table1colour}'>\n"; }
else {
print "<tr bgcolor='${Header::table2colour}'>\n"; }
if ($temp[3] eq 'on') { $gif='on.gif'; $toggle='off'; $gdesc=$Lang::tr{'click to disable'};}
else { $gif='off.gif'; $toggle='on'; $gdesc=$Lang::tr{'click to enable'}; }
if ($temp[1] eq '0.0.0.0/0') {
$temp[1] = $Lang::tr{'caps all'}; }
# catch for 'old-style' rules file - assume default ip if
# none exists
if (!&General::validip($temp[4]) || $temp[4] eq '0.0.0.0') {
$temp[4] = 'DEFAULT IP'; }
$temp[5] = '' unless defined $temp[5];
print <<END
<td align='center'>$protocol</td>
<td align='center'>$temp[1]</td>
<td align='center'>$temp[4]</td>
<td align='center'>$temp[2]</td>
<td align='left'>&nbsp;$temp[5]</td>
<td align='center'>
<form method='post' name='frma$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' title='$gdesc' alt='$gdesc' />
<input type='hidden' name='ID' value='$id' />
<input type='hidden' name='ENABLE' value='$toggle' />
<input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
</form>
</td>
<td align='center'>
<form method='post' name='frmb$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' title='$Lang::tr{'edit'}' alt='$Lang::tr{'edit'}' />
<input type='hidden' name='ID' value='$id' />
<input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
</form>
</td>
<td align='center'>
<form method='post' name='frmc$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' title='$Lang::tr{'remove'}' alt='$Lang::tr{'remove'}' />
<input type='hidden' name='ID' value='$id' />
<input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
</form>
</td>
</tr>
END
;
}
print "</table>\n";
# If the xt access file contains entries, print Key to action icons
if ( ! -z "$filename") {
print <<END
<table>
<tr>
<td class='boldbase'>&nbsp; <b>$Lang::tr{'legend'}:</b></td>
<td>&nbsp; <img src='/images/on.gif' alt='$Lang::tr{'click to disable'}' /></td>
<td class='base'>$Lang::tr{'click to disable'}</td>
<td>&nbsp; &nbsp; <img src='/images/off.gif' alt='$Lang::tr{'click to enable'}' /></td>
<td class='base'>$Lang::tr{'click to enable'}</td>
<td>&nbsp; &nbsp; <img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
<td class='base'>$Lang::tr{'edit'}</td>
<td>&nbsp; &nbsp; <img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
<td class='base'>$Lang::tr{'remove'}</td>
</tr>
</table>
END
;
}
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
# Copyright (c) 2002/04/13 Steve Bootes - Add destination IP support
#
# $Id: xtaccess.cgi,v 1.6.2.15 2005/03/05 08:44:32 eoberlander Exp $
#
use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::colouryellow} );
undef (@dummy);
my %cgiparams=();
my %checked=();
my %selected=();
my $errormessage = '';
my $filename = "${General::swroot}/xtaccess/config";
my $aliasfile = "${General::swroot}/ethernet/aliases";
my $changed = 'no';
&Header::showhttpheaders();
$cgiparams{'ENABLED'} = 'off';
$cgiparams{'ACTION'} = '';
$cgiparams{'SRC'} = '';
$cgiparams{'DEST_PORT'} = '';
$cgiparams{'REMARK'} ='';
&Header::getcgihash(\%cgiparams);
open(FILE, $filename) or die 'Unable to open config file.';
my @current = <FILE>;
close(FILE);
if ($cgiparams{'ACTION'} eq $Lang::tr{'add'})
{
unless($cgiparams{'PROTOCOL'} =~ /^(tcp|udp)$/) { $errormessage = $Lang::tr{'invalid input'}; }
unless(&General::validipormask($cgiparams{'SRC'}))
{
if ($cgiparams{'SRC'} ne '') {
$errormessage = $Lang::tr{'source ip bad'}; }
else {
$cgiparams{'SRC'} = '0.0.0.0/0'; }
}
unless($errormessage){ $errormessage = &General::validportrange($cgiparams{'DEST_PORT'},'dst'); }
if ( ! $errormessage)
{
$cgiparams{'REMARK'} = &Header::cleanhtml($cgiparams{'REMARK'});
if($cgiparams{'EDITING'} eq 'no') {
open(FILE,">>$filename") or die 'Unable to open config file.';
flock FILE, 2;
print FILE "$cgiparams{'PROTOCOL'},$cgiparams{'SRC'},$cgiparams{'DEST_PORT'},$cgiparams{'ENABLED'},$cgiparams{'DEST'},$cgiparams{'REMARK'}\n";
} else {
open(FILE, ">$filename") or die 'Unable to open config file.';
flock FILE, 2;
my $id = 0;
foreach my $line (@current)
{
$id++;
if ($cgiparams{'EDITING'} eq $id) {
print FILE "$cgiparams{'PROTOCOL'},$cgiparams{'SRC'},$cgiparams{'DEST_PORT'},$cgiparams{'ENABLED'},$cgiparams{'DEST'},$cgiparams{'REMARK'}\n";
} else { print FILE "$line"; }
}
}
close(FILE);
undef %cgiparams;
$changed = 'yes';
&General::log($Lang::tr{'external access rule added'});
system('/usr/local/bin/setxtaccess');
} else {
# stay on edit mode if an error occur
if ($cgiparams{'EDITING'} ne 'no')
{
$cgiparams{'ACTION'} = $Lang::tr{'edit'};
$cgiparams{'ID'} = $cgiparams{'EDITING'};
}
}
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'remove'})
{
my $id = 0;
open(FILE, ">$filename") or die 'Unable to open config file.';
flock FILE, 2;
foreach my $line (@current)
{
$id++;
unless ($cgiparams{'ID'} eq $id) { print FILE "$line"; }
}
close(FILE);
system('/usr/local/bin/setxtaccess');
&General::log($Lang::tr{'external access rule removed'});
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'toggle enable disable'})
{
open(FILE, ">$filename") or die 'Unable to open config file.';
flock FILE, 2;
my $id = 0;
foreach my $line (@current)
{
$id++;
unless ($cgiparams{'ID'} eq $id) { print FILE "$line"; }
else
{
chomp($line);
my @temp = split(/\,/,$line);
print FILE "$temp[0],$temp[1],$temp[2],$cgiparams{'ENABLE'},$temp[4],$temp[5]\n";
}
}
close(FILE);
system('/usr/local/bin/setxtaccess');
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'})
{
my $id = 0;
foreach my $line (@current)
{
$id++;
if ($cgiparams{'ID'} eq $id)
{
chomp($line);
my @temp = split(/\,/,$line);
$cgiparams{'PROTOCOL'} = $temp[0];
$cgiparams{'SRC'} = $temp[1];
$cgiparams{'DEST_PORT'} = $temp[2];
$cgiparams{'ENABLED'} = $temp[3];
$cgiparams{'DEST'} = $temp[4];
$cgiparams{'REMARK'} = $temp[5];
}
}
}
if ($cgiparams{'ACTION'} eq '')
{
$cgiparams{'PROTOCOL'} = 'tcp';
$cgiparams{'DEST'} = '0.0.0.0';
$cgiparams{'ENABLED'} = 'on';
}
$selected{'PROTOCOL'}{'udp'} = '';
$selected{'PROTOCOL'}{'tcp'} = '';
$selected{'PROTOCOL'}{$cgiparams{'PROTOCOL'}} = "selected='selected'";
$selected{'DEST'}{$cgiparams{'DEST'}} = "selected='selected'";
$checked{'ENABLED'}{'off'} = '';
$checked{'ENABLED'}{'on'} = '';
$checked{'ENABLED'}{$cgiparams{'ENABLED'}} = "checked='checked'";
&Header::openpage($Lang::tr{'external access configuration'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<class name='base'>$errormessage\n";
print "&nbsp;</class>\n";
&Header::closebox();
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
my $buttontext = $Lang::tr{'add'};
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'}) {
&Header::openbox('100%', 'left', $Lang::tr{'edit a rule'});
$buttontext = $Lang::tr{'update'};
} else {
&Header::openbox('100%', 'left', $Lang::tr{'add a new rule'});
}
print <<END
<table width='100%'>
<tr>
<td width='10%'>
<select name='PROTOCOL'>
<option value='udp' $selected{'PROTOCOL'}{'udp'}>UDP</option>
<option value='tcp' $selected{'PROTOCOL'}{'tcp'}>TCP</option>
</select>
</td>
<td class='base'><font color='${Header::colourred}'>$Lang::tr{'source network'}</font></td>
<td><input type='text' name='SRC' value='$cgiparams{'SRC'}' size='32' /></td>
<td class='base'><font color='${Header::colourred}'>$Lang::tr{'destination port'}:</font></td>
<td><input type='text' name='DEST_PORT' value='$cgiparams{'DEST_PORT'}' size='5' /></td>
</tr>
</table>
<table width='100%'>
<tr>
<td width='10%' class='base'>$Lang::tr{'enabled'}<input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td>
<td class='base'><font color='${Header::colourred}'>$Lang::tr{'destination ip'}:&nbsp;</font>
<select name='DEST'>
<option value='0.0.0.0' $selected{'DEST'}{'0.0.0.0'}>DEFAULT IP</option>
END
;
open(ALIASES, "$aliasfile") or die 'Unable to open aliases file.';
while (<ALIASES>)
{
chomp($_);
my @temp = split(/\,/,$_);
if ($temp[1] eq 'on') {
print "<option value='$temp[0]' $selected{'DEST'}{$temp[0]}>$temp[0]";
if (defined $temp[2] and ($temp[2] ne '')) { print " ($temp[2])"; }
print "</option>\n";
}
}
close(ALIASES);
print <<END
</select>
</td>
</tr>
</table>
<table width='100%'>
<tr>
<td width ='10%' class='base'>
<font class='boldbase'>$Lang::tr{'remark'}:</font>&nbsp;<img src='/blob.gif' alt='*' />
</td>
<td width='65%'>
<input type='text' name='REMARK' value='$cgiparams{'REMARK'}' size='55' maxlength='50' />
</td>
<td width='25%' align='center'>
<input type='hidden' name='ACTION' value='$Lang::tr{'add'}' />
<input type='submit' name='SUBMIT' value='$buttontext' />
</td>
</tr>
</table>
<table width='100%'>
<tr>
<td class='base' width='30%'><img src='/blob.gif' alt ='*' align='top' />&nbsp;<font class='base'>$Lang::tr{'this field may be blank'}</font>
</td>
</tr>
</table>
END
;
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'}) {
print "<input type='hidden' name='EDITING' value='$cgiparams{'ID'}' />\n";
} else {
print "<input type='hidden' name='EDITING' value='no' />\n";
}
&Header::closebox();
print "</form>\n";
&Header::openbox('100%', 'left', $Lang::tr{'current rules'});
print <<END
<table width='100%'>
<tr>
<td width='10%' class='boldbase' align='center'><b>$Lang::tr{'proto'}</b></td>
<td width='20%' class='boldbase' align='center'><b>$Lang::tr{'source ip'}</b></td>
<td width='20%' class='boldbase' align='center'><b>$Lang::tr{'destination ip'}</b></td>
<td width='15%' class='boldbase' align='center'><b>$Lang::tr{'destination port'}</b></td>
<td width='30%' class='boldbase' align='center'><b>$Lang::tr{'remark'}</b></td>
<td width='5%' class='boldbase' colspan='3' align='center'><b>$Lang::tr{'action'}</b></td>
</tr>
END
;
# If something has happened re-read config
if($cgiparams{'ACTION'} ne '' or $changed ne 'no')
{
open(FILE, $filename) or die 'Unable to open config file.';
@current = <FILE>;
close(FILE);
}
my $id = 0;
foreach my $line (@current)
{
$id++;
chomp($line);
my @temp = split(/\,/,$line);
my $protocol = '';
my $gif = '';
my $gdesc = '';
my $toggle = '';
if ($temp[0] eq 'udp') {
$protocol = 'UDP'; }
else {
$protocol = 'TCP' }
if($cgiparams{'ACTION'} eq $Lang::tr{'edit'} && $cgiparams{'ID'} eq $id) {
print "<tr bgcolor='${Header::colouryellow}'>\n"; }
elsif ($id % 2) {
print "<tr bgcolor='${Header::table1colour}'>\n"; }
else {
print "<tr bgcolor='${Header::table2colour}'>\n"; }
if ($temp[3] eq 'on') { $gif='on.gif'; $toggle='off'; $gdesc=$Lang::tr{'click to disable'};}
else { $gif='off.gif'; $toggle='on'; $gdesc=$Lang::tr{'click to enable'}; }
if ($temp[1] eq '0.0.0.0/0') {
$temp[1] = $Lang::tr{'caps all'}; }
# catch for 'old-style' rules file - assume default ip if
# none exists
if (!&General::validip($temp[4]) || $temp[4] eq '0.0.0.0') {
$temp[4] = 'DEFAULT IP'; }
$temp[5] = '' unless defined $temp[5];
print <<END
<td align='center'>$protocol</td>
<td align='center'>$temp[1]</td>
<td align='center'>$temp[4]</td>
<td align='center'>$temp[2]</td>
<td align='left'>&nbsp;$temp[5]</td>
<td align='center'>
<form method='post' name='frma$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' title='$gdesc' alt='$gdesc' />
<input type='hidden' name='ID' value='$id' />
<input type='hidden' name='ENABLE' value='$toggle' />
<input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
</form>
</td>
<td align='center'>
<form method='post' name='frmb$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' title='$Lang::tr{'edit'}' alt='$Lang::tr{'edit'}' />
<input type='hidden' name='ID' value='$id' />
<input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
</form>
</td>
<td align='center'>
<form method='post' name='frmc$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' title='$Lang::tr{'remove'}' alt='$Lang::tr{'remove'}' />
<input type='hidden' name='ID' value='$id' />
<input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
</form>
</td>
</tr>
END
;
}
print "</table>\n";
# If the xt access file contains entries, print Key to action icons
if ( ! -z "$filename") {
print <<END
<table>
<tr>
<td class='boldbase'>&nbsp; <b>$Lang::tr{'legend'}:</b></td>
<td>&nbsp; <img src='/images/on.gif' alt='$Lang::tr{'click to disable'}' /></td>
<td class='base'>$Lang::tr{'click to disable'}</td>
<td>&nbsp; &nbsp; <img src='/images/off.gif' alt='$Lang::tr{'click to enable'}' /></td>
<td class='base'>$Lang::tr{'click to enable'}</td>
<td>&nbsp; &nbsp; <img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
<td class='base'>$Lang::tr{'edit'}</td>
<td>&nbsp; &nbsp; <img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
<td class='base'>$Lang::tr{'remove'}</td>
</tr>
</table>
END
;
}
&Header::closebox();
&Header::closebigbox();
&Header::closepage();

View File

@@ -1,122 +1,122 @@
body {
margin: 0px;
padding: 0px;
background: url(/images/header.png) no-repeat;
background-color: #D7D8E8;
color: #000000;
font-family: Verdana, Tahoma, Arial, Sans-serif;
font-size: 11px;
}
td {
font-size: 11px;
}
img {
border: 0;
border-width : 0;
border-style : none;
border-color : inherit;
}
pre {
font-size: 12px;
}
a {
color: #000000;
}
form {
margin: 0;
padding: 0;
}
td.ipcop_menuLocationMain {
color: #FFFFFF;
font-family: Verdana, Tahoma, Arial, Sans-serif;
font-size: 16px;
font-weight: bold;
font-variant: small-caps;
}
td.ipcop_menuLocationSub {
color: #FFFFFF;
font-family: Verdana, Tahoma, Arial, Sans-serif;
font-size: 11px;
font-weight: bold;
font-variant: small-caps;
}
td.ipcop_Version {
color: #10044A;
font-size: 10px;
font-weight: bold;
}
/* Dommenu */
.ipcop_menuElementTD {
border: 0;
color: #DEDFEF;
font-size: 11px;
font-weight: bold;
text-decoration: none;
width: 90px;
padding: 0px 0px 5px 0px;
margin: 0px 10px 0px 10px;
}
.ipcop_menuElementNoJS {
color: #DEDFEF;
font-size: 11px;
font-weight: bold;
text-decoration: none;
padding: 0px 0px 5px 0px;
margin: 0px 10px 0px 10px;
}
div.ipcop_menuBar {
margin-bottom: 1px;
}
div.ipcop_subMenuBar {
border: 0;
background-color: #6B69AD;
}
div.ipcop_menuElement, div.ipcop_subMenuElement {
border: 0;
color: #DEDFEF;
font-variant: small-caps;
font-size: 11px;
font-weight: bold;
}
div.ipcop_menuElement {
width: 70px;
margin: 4px 10px 4px 10px;
}
div.ipcop_menuElementHover {
color: #FFFFFF;
}
div.ipcop_subMenuElement {
padding: 3px;
color: #DEDFEF;
}
div.ipcop_subMenuElementHover {
padding: 3px;
color: #FFFFFF;
}
/* Connection Status */
span.ipcop_StatusBig {
font-weight: bold;
font-size: 14px;
}
span.ipcop_StatusBigRed {
color: #FF0000;
font-weight: bold;
}
body {
margin: 0px;
padding: 0px;
background: url(/images/header.png) no-repeat;
background-color: #D7D8E8;
color: #000000;
font-family: Verdana, Tahoma, Arial, Sans-serif;
font-size: 11px;
}
td {
font-size: 11px;
}
img {
border: 0;
border-width : 0;
border-style : none;
border-color : inherit;
}
pre {
font-size: 12px;
}
a {
color: #000000;
}
form {
margin: 0;
padding: 0;
}
td.ipcop_menuLocationMain {
color: #FFFFFF;
font-family: Verdana, Tahoma, Arial, Sans-serif;
font-size: 16px;
font-weight: bold;
font-variant: small-caps;
}
td.ipcop_menuLocationSub {
color: #FFFFFF;
font-family: Verdana, Tahoma, Arial, Sans-serif;
font-size: 11px;
font-weight: bold;
font-variant: small-caps;
}
td.ipcop_Version {
color: #10044A;
font-size: 10px;
font-weight: bold;
}
/* Dommenu */
.ipcop_menuElementTD {
border: 0;
color: #DEDFEF;
font-size: 11px;
font-weight: bold;
text-decoration: none;
width: 90px;
padding: 0px 0px 5px 0px;
margin: 0px 10px 0px 10px;
}
.ipcop_menuElementNoJS {
color: #DEDFEF;
font-size: 11px;
font-weight: bold;
text-decoration: none;
padding: 0px 0px 5px 0px;
margin: 0px 10px 0px 10px;
}
div.ipcop_menuBar {
margin-bottom: 1px;
}
div.ipcop_subMenuBar {
border: 0;
background-color: #6B69AD;
}
div.ipcop_menuElement, div.ipcop_subMenuElement {
border: 0;
color: #DEDFEF;
font-variant: small-caps;
font-size: 11px;
font-weight: bold;
}
div.ipcop_menuElement {
width: 70px;
margin: 4px 10px 4px 10px;
}
div.ipcop_menuElementHover {
color: #FFFFFF;
}
div.ipcop_subMenuElement {
padding: 3px;
color: #DEDFEF;
}
div.ipcop_subMenuElementHover {
padding: 3px;
color: #FFFFFF;
}
/* Connection Status */
span.ipcop_StatusBig {
font-weight: bold;
font-size: 14px;
}
span.ipcop_StatusBigRed {
color: #FF0000;
font-weight: bold;
}

View File

@@ -1,8 +1,8 @@
#!/usr/bin/perl
#
# $Id: index.cgi,v 1.4 2003/12/11 11:06:41 riddles Exp $
#
print "Status: 302 Moved\n";
print "Location: /cgi-bin/index.cgi\n\n";
#!/usr/bin/perl
#
# $Id: index.cgi,v 1.4 2003/12/11 11:06:41 riddles Exp $
#
print "Status: 302 Moved\n";
print "Location: /cgi-bin/index.cgi\n\n";