git-svn-id: http://svn.ipfire.org/svn/ipfire/IPFire/source@16 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8

This commit is contained in:
ipfire
2006-02-15 21:15:54 +00:00
parent 6d63f4c4b3
commit cd1a292722
1206 changed files with 185026 additions and 0 deletions

2
html/CVS/Entries Normal file
View File

@@ -0,0 +1,2 @@
D/cgi-bin////
D/html////

1
html/CVS/Repository Normal file
View File

@@ -0,0 +1 @@
ipcop/html

1
html/CVS/Root Normal file
View File

@@ -0,0 +1 @@
:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ipcop

1
html/CVS/Tag Normal file
View File

@@ -0,0 +1 @@
TIPCOP_v1_4_0

36
html/cgi-bin/CVS/Entries Normal file
View File

@@ -0,0 +1,36 @@
/aliases.cgi/1.5.2.14/Fri Jan 13 20:14:48 2006//TIPCOP_v1_4_0
/backup.cgi/1.2.2.15/Sun Jan 29 15:31:49 2006//TIPCOP_v1_4_0
/base.cgi/1.1.2.10/Thu Nov 3 19:20:50 2005//TIPCOP_v1_4_0
/changepw.cgi/1.4.2.6/Mon Mar 7 21:28:03 2005//TIPCOP_v1_4_0
/connections.cgi/1.6.2.11/Thu Feb 24 07:44:35 2005//TIPCOP_v1_4_0
/credits.cgi/1.11.2.30/Sun Jan 8 13:33:36 2006//TIPCOP_v1_4_0
/ddns.cgi/1.7.2.41/Tue Feb 7 01:29:47 2006//TIPCOP_v1_4_0
/dhcp.cgi/1.14.2.81/Fri Jan 20 12:05:29 2006//TIPCOP_v1_4_0
/dial.cgi/1.4.2.3/Tue Feb 22 22:21:55 2005//TIPCOP_v1_4_0
/dmzholes.cgi/1.9.2.16/Tue Oct 18 17:05:27 2005//TIPCOP_v1_4_0
/graphs.cgi/1.9.2.6/Tue Feb 22 22:21:55 2005//TIPCOP_v1_4_0
/gui.cgi/1.2.2.17/Wed Jul 6 09:21:22 2005//TIPCOP_v1_4_0
/hosts.cgi/1.4.2.20/Sat Nov 5 15:46:25 2005//TIPCOP_v1_4_0
/ids.cgi/1.8.2.18/Wed Jul 27 21:35:22 2005//TIPCOP_v1_4_0
/index.cgi/1.15.2.18/Sat Sep 17 13:51:47 2005//TIPCOP_v1_4_0
/ipinfo.cgi/1.4.2.3/Tue Feb 22 22:21:56 2005//TIPCOP_v1_4_0
/modem.cgi/1.4.2.7/Tue Feb 22 22:21:56 2005//TIPCOP_v1_4_0
/netstatus.cgi/1.9.2.20/Sat Nov 5 15:46:25 2005//TIPCOP_v1_4_0
/networks.cgi/1.2.2.3/Fri Apr 29 23:37:06 2005//TIPCOP_v1_4_0
/optionsfw.cgi/1.1.2.10/Mon Oct 3 00:34:10 2005//TIPCOP_v1_4_0
/portfw.cgi/1.5.2.18/Mon May 2 16:19:49 2005//TIPCOP_v1_4_0
/pppsetup.cgi/1.17.2.49/Thu Dec 1 16:20:35 2005//TIPCOP_v1_4_0
/proxy.cgi/1.13.2.23/Sun Jan 29 09:29:47 2006//TIPCOP_v1_4_0
/proxygraphs.cgi/1.2.2.5/Tue Feb 22 22:21:56 2005//TIPCOP_v1_4_0
/remote.cgi/1.6.2.8/Tue Feb 22 22:21:56 2005//TIPCOP_v1_4_0
/services.cgi/1.2.2.3/Fri Apr 29 23:37:07 2005//TIPCOP_v1_4_0
/shaping.cgi/1.3.2.15/Sun Feb 27 13:42:05 2005//TIPCOP_v1_4_0
/shutdown.cgi/1.5.2.10/Mon Jan 2 16:21:00 2006//TIPCOP_v1_4_0
/status.cgi/1.6.2.7/Thu Feb 24 07:44:35 2005//TIPCOP_v1_4_0
/time.cgi/1.4.2.11/Sat May 28 12:16:18 2005//TIPCOP_v1_4_0
/updates.cgi/1.9.2.22/Thu Dec 1 20:41:53 2005//TIPCOP_v1_4_0
/upload.cgi/1.2.2.21/Sun Aug 14 23:43:38 2005//TIPCOP_v1_4_0
/vpnmain.cgi/1.10.2.69/Tue Jan 31 02:07:19 2006//TIPCOP_v1_4_0
/wireless.cgi/1.4.2.15/Sat Jun 11 12:14:49 2005//TIPCOP_v1_4_0
/xtaccess.cgi/1.6.2.15/Sat Mar 5 08:44:32 2005//TIPCOP_v1_4_0
D/logs.cgi////

View File

@@ -0,0 +1 @@
ipcop/html/cgi-bin

1
html/cgi-bin/CVS/Root Normal file
View File

@@ -0,0 +1 @@
:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ipcop

1
html/cgi-bin/CVS/Tag Normal file
View File

@@ -0,0 +1 @@
TIPCOP_v1_4_0

482
html/cgi-bin/aliases.cgi Normal file
View File

@@ -0,0 +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';
}

652
html/cgi-bin/backup.cgi Normal file
View File

@@ -0,0 +1,652 @@
#!/usr/bin/perl
#
# IPCop CGI's - backup.cgi: manage import/export of configuration files
#
# This code is distributed under the terms of the GPL
#
# (c) The IPCop Team
# 2005 Franck Bourdonnec, major rewrite
#
# $Id: backup.cgi,v 1.2.2.15 2006/01/29 15:31:49 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;
use File::Copy;
use Sys::Hostname;
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my $errormessage = '';
my $warnmessage = '';
my $setdir = '/home/httpd/html/backup'; # location where sets are stored and imported
my $datafile = hostname() . '.dat'; # file containing data backup
my $datefile = $datafile . '.time'; # and creation date
# ask if backup crypting key exists
my $tmpkeyfile = "$setdir/key"; # import the backup key
# Get GUI values
my %settings = ();
&Header::getcgihash(\%settings, {'wantfile' => 1, 'filevar' => 'FH'});
##
## Backup key management
##
#
# Export the key. root pw is required to avoid user 'noboby' uses the helper to read it and creates
# fake backup.
#
if ($settings{'ACTION'} eq $Lang::tr{'backup export key'}) {
my $size = 0;
if ($settings{'PASSWORD1'} ne '' && $settings{'PASSWORD1'} ne $settings{'PASSWORD2'} ){
$errormessage = $Lang::tr{'passwords do not match'}
} else {
my @lines = `/usr/local/bin/ipcopbackup -keycat $settings{'PASSWORD'}`;
# If previous operation succeded and the key need to be crypted, redo operation with pipe to openssl
if (@lines && $settings{'PASSWORD1'}) {
@lines = `/usr/local/bin/ipcopbackup -keycat $settings{'PASSWORD'}|openssl enc -a -e -aes256 -salt -pass pass:$settings{'PASSWORD1'} `;
}
if (@lines) {
use bytes;
foreach (@lines) {$size += length($_)};
print "Pragma: no-cache\n";
print "Cache-control: no-cache\n";
print "Connection: close\n";
print "Content-type: application/octet-stream\n";
print "Content-Disposition: filename=backup.key\n";
print "Content-Length: $size\n\n";
print @lines;
exit (0);
} else {
$errormessage = $Lang::tr{'incorrect password'};
}
}
}
#
# Import the key. Fail if key exists. This avoid creating fake backup.
#
if ($settings{'ACTION'} eq $Lang::tr{'backup import key'}) {
if (ref ($settings{'FH'}) ne 'Fh') {
$errormessage = $Lang::tr{'no cfg upload'};
} else {
if (copy ($settings{'FH'}, $tmpkeyfile) != 1) {
$errormessage = $Lang::tr{'save error'};
} else {
# if a password is given, decrypt the key received in $tmpkeyfile file with it.
# no error is produce if the password is wrong.
if ($settings{'PASSWORD1'}) {
my @lines = `openssl enc -a -d -aes256 -salt -pass pass:$settings{'PASSWORD1'} -in $tmpkeyfile`;
open(FILE,">$tmpkeyfile");
print FILE @lines;
close (FILE);
}
$errormessage = &get_bk_error(system ('/usr/local/bin/ipcopbackup -key import')>>8);
}
}
}
#
# Import the key. Fail if key exists. Key is extracted from a non-encrypted backup (pre 1.4.10)
#
if ($settings{'ACTION'} eq $Lang::tr{'backup extract key'}) {
if (ref ($settings{'FH'}) ne 'Fh') {
$errormessage = $Lang::tr{'no cfg upload'};
} else {
if (copy ($settings{'FH'}, '/tmp/tmptarfile.tgz') != 1) {
$errormessage = $Lang::tr{'save error'};
} else {
system( "tar -C /tmp -xzf /tmp/tmptarfile.tgz */backup/backup.key;\
mv -f /tmp${General::swroot}/backup/backup.key $tmpkeyfile;\
rm -rf /tmp${General::swroot};\
rm /tmp/tmptarfile.tgz");
$errormessage = &get_bk_error(system ('/usr/local/bin/ipcopbackup -key import')>>8);
}
}
}
#
# Create the key. Cannot overwrite existing key to avoid difference with exported (saved) key
#
if ($settings{'ACTION'} eq $Lang::tr{'backup generate key'}) {
$errormessage = &get_bk_error(system('/usr/local/bin/ipcopbackup -key new')>>8);
}
my $cryptkeymissing = system ('/usr/local/bin/ipcopbackup -key exist')>>8;
&Header::showhttpheaders();
if ($cryptkeymissing) { #If no key is present, force creation or import
&Header::openpage($Lang::tr{'backup configuration'}, 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{'backup key'});
print <<END
<form method = 'post' enctype = 'multipart/form-data'>
<table>
<tr>
<td colspan='2'>
$Lang::tr{'backup explain key'}:
<ul>
<li>$Lang::tr{'backup explain key li1'}
<li>$Lang::tr{'backup explain key li2'}
<li>$Lang::tr{'backup explain key li3'}
</ul>
</td>
</tr><tr>
<td width='15%'></td><td width='20%'></td><td>
<input type = 'submit' name = 'ACTION' value = '$Lang::tr{'backup generate key'}' />
</td>
</tr><tr>
<td align='right'>$Lang::tr{'backup key file'}:</td><td><input type = 'file' name = 'FH' size = '30' value='backup.key' />
</td><td>
<input type = 'submit' name = 'ACTION' value = '$Lang::tr{'backup import key'}' />
</tr><tr>
<td align='right'>$Lang::tr{'backup protect key password'}:<td><input type = 'password' name='PASSWORD1' size='10' />
</td>
</tr><tr>
<td align='right'>$Lang::tr{'backup clear archive'}:</td><td><input type = 'file' name = 'FH' size = '30' value='your-ipcop.tar.gz' />
</td><td>
<input type = 'submit' name = 'ACTION' value = '$Lang::tr{'backup extract key'}' />
</td>
</tr>
</table>
$Lang::tr{'notes'}:
<ul>
<li>$Lang::tr{'backup explain key no1'}
<li>$Lang::tr{'backup explain key no2'}
</ul>
</form>
END
;
&floppybox();
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
exit (0);
}
##
## Sets management (create/delete/import/restore)
##
erase_files ($setdir); #clean up
#
# create new archive set
#
if ($settings{'ACTION'} eq $Lang::tr{'create'}) {
$errormessage = &get_bk_error(system('/usr/local/bin/ipcopbkcfg > /dev/null')>>8);
&import_set (" ".&Header::cleanhtml ($settings{'COMMENT'})) if (!$errormessage);
}
#
# delete a backup set
#
if ($settings{'ACTION'} eq $Lang::tr{'remove'}) {
erase_files (&Header::cleanhtml ($settings{'KEY'})); # remove files
rmdir($settings{'KEY'}); # remove directory
}
#
# import an archive set
#
if ($settings{'ACTION'} eq $Lang::tr{'import'}) {
if (ref ($settings{'FH'}) ne 'Fh') {
$errormessage = $Lang::tr{'no cfg upload'};
} else {
if (!copy ($settings{'FH'}, "$setdir/$datafile")) {
$errormessage = $Lang::tr{'save error'};
} else {
&import_set ('&nbsp;(imported)');
}
}
}
#
# restore an archive
#
if ($settings{'ACTION'} eq $Lang::tr{'restore'}) {
if ($settings{'AreYouSure'} eq 'yes') {
if (!$cryptkeymissing) { # if keyfile exists
if (-e "$settings{'KEY'}/$datafile"){ # encrypted dat is required
copy_files($settings{'KEY'}, $setdir); # to working dir
$errormessage = get_rs_error(system("/usr/local/bin/ipcoprscfg"
. ($settings{'RESTOREHW'} eq 'on' ? ' --hardware' : '')
. ' >/dev/null')>>8);
if (!$errormessage) {
# restored ok, recommend restarting system
$warnmessage = $Lang::tr{'cfg restart'};
}
erase_files ($setdir); #clean up
} else {
$errormessage = $Lang::tr{'missing dat'}."$settings{'KEY'}/$datafile";
}
} else { # if keyfile does not exist
$errormessage = $Lang::tr{'backup missing key'};
}
} else { # not AreYouSure=yes
&Header::openpage($Lang::tr{'backup configuration'}, 1, '');
&Header::openbigbox('100%', 'left');
&Header::openbox('100%', 'left', $Lang::tr{'are you sure'});
print <<END
<form method = 'post'>
<input type = 'hidden' name = 'KEY' value ='$settings{'KEY'}' />
<input type = 'hidden' name = 'AreYouSure' value ='yes' />
<table align = 'center'>
<tr>
<td align = 'center'>
<input type = 'submit' name = 'ACTION' value = '$Lang::tr{'restore'}' />
</td><td>
<input type = 'submit' name = 'ACTION' value = '$Lang::tr{'cancel'}' />
</td>
</tr><tr>
<td>
$Lang::tr{'restore hardware settings'}: <input type = 'checkbox' name = 'RESTOREHW'>
</td>
</tr>
</table>
</form>
END
;
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
exit (0);
}
}
##
## Media management
##
#
# now build the list of removable device
#
# Read partitions sizes registered with the system
my %partitions;
foreach my $li (`/usr/local/bin/ipcopbackup -proc partitions`) { # use suid helper...
# partitions{'sda1'} = 128M if /major minor blocks name/
$partitions{$4} = &kmgt($3*1024,4) if ($li =~ /(\d+) +(\d+) +(\d+) +(.*)/);
}
# Search usb-storage scsi device
my %medias;
foreach (`/usr/local/bin/ipcopbackup -glob '/proc/scsi/usb-storage*/*'`) {# use suid helper...
my $m;
foreach ( `cat $_` ) { # list each line of information for the device:
# Host scsi0: usb-storage
# Vendor: SWISSBIT
# Product: Black Silver
# Serial Number: D0ED423A4F84A31E
# Protocol: Transparent SCSI
# Transport: Bulk
# GUID: 13706828d0ed423a4f84a31e
# Attached: Yes
chomp;
my ($key,$val) = split(': ',$_,2);
$key =~ s/^ *//; # remove front space
# convert 'scsi?' key to sda, sdb,... and use it as a %medias keyhash
if ($key =~ /Host scsi(.)/) {
$val = $m = 'sd' . chr(97+$1);
$key = 'Host';
}
$medias{$m}{$key} = $val; # save data
}
}
#
# Switch mounted media
#
if ($settings{'ACTION'} eq $Lang::tr{'mount'})
{
# Find what is really mounted under backup. Can be local hard disk or any removable media
my $mounted = &findmounted();
#umount previous, even if same device already mouted.
system ("/usr/local/bin/ipcopbackup -U $mounted") if ($mounted ne $Lang::tr{'local hard disk'});
$errormessage = `/usr/local/bin/ipcopbackup -M $settings{'SELECT'}` if (grep (/$settings{'SELECT'}/,%partitions));
}
#
# Compute a full description of device
#
my $mounted = &findmounted();
my $media_des = $mounted; # Description
if ($mounted ne $Lang::tr{'local hard disk'}) {
$_ = $mounted; # sda1 => sda
tr/0-9//d;
$media_des = "$medias{$_}{'Product'} ($media_des, $partitions{$mounted})";
}
&Header::openpage($Lang::tr{'backup configuration'}, 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();
}
$warnmessage = "<font color=${Header::colourred}><b>$Lang::tr{'capswarning'}</b></font>: $warnmessage <p>" if ($warnmessage);
&Header::openbox('100%', 'left', $Lang::tr{'backup configuration'});
#Divide the window in two : left and right
print <<END
<table width = '100%' >
<tr>
<th width = '50%'>$Lang::tr{'current media'}:<font color=${Header::colourred}><b>$media_des</b></font></th>
<th width = '3%'></th>
<th>$Lang::tr{'choose media'}</th>
</tr>
END
;
# Left part of window
print <<END
<tr><td>
<ul>
<li>$Lang::tr{'backup sets'}:
<table width = '80%' border='0'>
<tr>
<th class = 'boldbase' align = 'center'>$Lang::tr{'name'}</th>
<th class = 'boldbase' align = 'center' colspan = '3'>$Lang::tr{'action'}</th>
</tr>
END
;
# get list of available sets by globbing directories under $setdir
# External device (usk key) are mounted in $setdir. -R permits finding sets in hierarchy.
my $i = 0;
foreach my $set (`ls -Rt1 $setdir`) {
chop ($set); #remove ':' & newline from line
chop ($set);
if (-d $set && ($set =~ m!/.+/\d{8}_\d{6}! ) ) { # filter out things not sets !
if ($i++ % 2) {
print "<tr bgcolor = '$Header::table2colour'>";
} else {
print "<tr bgcolor = '$Header::table1colour'>";
}
my $settime = read_timefile( "$set/$datefile", "$set/$datafile" );
my $name = substr ($set,length($setdir)+1);
print<<EOF
<td>
$settime
</td>
<td align = 'center'>
<form method = 'post'>
<input type = 'hidden' name = 'ACTION' value ='$Lang::tr{'restore'}' />
<input type = 'image' name = '$Lang::tr{'restore'}' src = '/images/reload.gif' alt = '$Lang::tr{'restore'}' title = '$Lang::tr{'restore'}' />
<input type = 'hidden' name = 'KEY' value = '$set' />
</form>
</td>
<td align = 'center'>
<a href = '/backup/$name/$datafile'><img src = '/images/floppy.gif' title = '$Lang::tr{'export'}'></a>
</td>
<td align = 'center'>
<form method = 'post'>
<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'}' border = '0' />
<input type = 'hidden' name = 'KEY' value = '$set' />
</form>
</td>
</tr>
EOF
;
}
}
print "</table>" . ($i ? "<br>" : "$Lang::tr{'empty'}!<hr /><br>");
print <<EOF
$warnmessage
<form method = 'post'>
<li>$Lang::tr{'backup configuration'}<br>
$Lang::tr{'description'}:<input type = 'text' name = 'COMMENT' size='30' />
<input type = 'submit' name = 'ACTION' value = '$Lang::tr{'create'}' />
</form><p>
<form method = 'post' enctype = 'multipart/form-data'>
<li>$Lang::tr{'backup import dat file'}:<br>
<input type = 'file' name = 'FH' size = '20' />
<input type = 'submit' name = 'ACTION' value = '$Lang::tr{'import'}' />
</form>
</ul>
EOF
;
print "</td><td></td><td valign='top'>"; # Start right part (devices selection)
print $Lang::tr{'backup media info'};
print "<form method = 'post'>";
print "<table width = '100%'><tr><td>";
my $nodev = 1; # nothing present
foreach my $media (keys %medias) {
if ( $medias{$media}{'Attached'} eq 'Yes') { # device is attached to USB bus ?
$nodev = 0; # at least one device present
my $checked = $medias{$media}{'Host'} eq $mounted ? "checked='checked'" : '';
print "<input type='radio' name = 'SELECT' value = '$medias{$media}{'Host'}' $checked />";
print "<b>$medias{$media}{'Product'}</b><br>";
# list attached partitions to this media
foreach my $part (sort (keys (%partitions))) {
if ($part =~ /$medias{$media}{'Host'}./) {
my $checked = $part eq $mounted ? "checked='checked'" : '';
print "&nbsp;&nbsp;&nbsp;<input type='radio' name = 'SELECT' value = '$part' $checked />$part ($partitions{$part})<br>";
}
}
}
}
if ($nodev) {
print "<br>$Lang::tr{'insert removable device'}";
print "</td><td>";
print "<br><input type = 'submit' name = 'ACTION' value = '$Lang::tr{'done'}' />";
} else {
#Add an entry for the local disk
my $checked = $Lang::tr{'local hard disk'} eq $mounted ? "checked='checked'" : '';
print "<input type = 'radio' name = 'SELECT' value = '$Lang::tr{'local hard disk'}' $checked />";
print "<b>$Lang::tr{'local hard disk'}</b>";
print "</td><td>";
print "<br><input type = 'submit' name = 'ACTION' value = '$Lang::tr{'mount'}' />";
}
print "</tr></table>";
print "</form>";
#
#Backup key
#
print<<EOF
<hr />
<form method='post'>
<b>$Lang::tr{'backup key'}</b><br>
$Lang::tr{'backup key info'}<br>
<table><tr>
<td align= 'right'>$Lang::tr{'root user password'}:
<td align='left'><input type = 'password' name='PASSWORD' />
<input type = 'submit' name = 'ACTION' value = '$Lang::tr{'backup export key'}' />
</tr><tr>
<td align='right'>$Lang::tr{'backup protect key password'}:
<td align='left'><input type = 'password' name='PASSWORD1' size='10' />
</tr><tr>
<td align='right'>$Lang::tr{'again'}
<td align='left'><input type = 'password' name='PASSWORD2' size='10'/>
</tr></table>
</form>
EOF
;
# End of right table
print "</td></tr></table>";
&floppybox();
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
sub floppybox {
print <<END
<hr />
<form method = 'post'>
<table width='100%'>
<tr>
<td>
<b>$Lang::tr{'backup to floppy'}</b>
</td>
</tr>
<tr>
<td width='50%'>
$Lang::tr{'insert floppy'}
</td>
<td align='center'>
<input type='submit' name='ACTION' value='$Lang::tr{'backup to floppy'}' />
</td>
</tr>
</table>
</form>
END
;
print "<b>$Lang::tr{'alt information'}</b><pre>" .
`/usr/local/bin/ipcopbackup -savecfg floppy` .
'&nbsp;</pre>' if ($settings{'ACTION'} eq $Lang::tr{'backup to floppy'} );
}
# Return device name of what is mounted under 'backup'
sub findmounted() {
my $mounted = `mount|grep ' /home/httpd/html/backup '`;
if ($mounted) { # extract device name
$mounted =~ m!^/dev/(.*) on!; # device on mountmoint options
return $1;
} else { # it's the normal subdir
return $Lang::tr{'local hard disk'};
}
}
# read and return a date/time string from a time file
sub read_timefile() {
my $fname = shift; # name of file to read from
my $fname2 = shift; # if first file doesn't exist, get date of this file
my $dt;
if (defined(open(FH, "<$fname"))) {
$dt = <FH>;
chomp $dt;
close(FH);
} else {
$dt = &get_fdate($fname2); # get file date/time
write_timefile($fname, $dt); # write to expected time file
}
return $dt;
}
# write a date/time string to a time file
sub write_timefile() {
my $fname = shift; # name of file to write to
my $dt = shift; # date/time string to write
if (open(FH, ">$fname")) {
print FH "$dt\n";
close(FH);
}
}
# move a dat file without time stamp to subdir
sub import_set() {
my $dt = get_fdate("$setdir/$datafile") . shift;
&write_timefile("$setdir/$datefile", $dt);
# create set directory
my $setname = "$setdir/" . get_ddate("$setdir/$datafile");
mkdir($setname);
# move files to the new set directory
copy_files($setdir, $setname);
erase_files ($setdir);
}
# get date/time string from file
sub get_fdate() {
my $fname = shift;
open(DT, "/bin/date -r $fname|");
my $dt = <DT>;
close(DT);
chomp $dt;
$dt =~ s/\s+/ /g; # remove duplicate spaces
return $dt;
}
# get date/time string from file for use as directory name
sub get_ddate() {
my $fname = shift;
open(DT, "/bin/date -r $fname +%Y%m%d_%H%M%S|");
my $dt = <DT>;
close(DT);
chomp $dt;
return $dt;
}
# copy archive files from source directory to destination directory
sub copy_files() {
my $src_dir = shift;
my $dest_dir = shift;
map (copy ("$src_dir/$_", "$dest_dir/$_"), ($datafile, $datefile) );
}
# erase set files
sub erase_files() {
my $src_dir = shift;
map (unlink ("$src_dir/$_"), ($datafile, $datefile));
}
# get backup error text
sub get_bk_error() {
my $exit_code = shift || return '';
if ($exit_code == 0) {
return '';
} elsif ($exit_code == 2) {
return $Lang::tr{'err bk 2 key'};
} elsif ($exit_code == 3) {
return $Lang::tr{'err bk 3 tar'};
} elsif ($exit_code == 4) {
return $Lang::tr{'err bk 4 gz'};
} elsif ($exit_code == 5) {
return $Lang::tr{'err bk 5 encrypt'};
} else {
return $Lang::tr{'err bk 1'};
}
}
# show any restore errors
sub get_rs_error() {
my $exit_code = shift || return '';
if ($exit_code == 0) {
return '';
} elsif ($exit_code == 6) {
return $Lang::tr{'err rs 6 decrypt'};
} elsif ($exit_code == 7) {
return $Lang::tr{'err rs 7 untartst'};
} elsif ($exit_code == 8) {
return $Lang::tr{'err rs 8 untar'};
} elsif ($exit_code == 9) {
return $Lang::tr{'missing dat'};
} else {
return $Lang::tr{'err rs 1'}."($exit_code)";
}
}
sub kmgt {
my ($value,$length,$opt_U) = @_;
if ( $value > 10**( $length + 8 ) or $opt_U eq 'T' ) {
return sprintf( "%d%s", int( ( $value / 1024**4 ) + .5 ), 'T' );
} elsif ( $value > 10**( $length + 5 ) or $opt_U eq 'G' ) {
return sprintf( "%d%s", int( ( $value / 1024**3 ) + .5 ), 'G' );
} elsif ( $value > 10**( $length + 2 ) or $opt_U eq 'M' ) {
return sprintf( "%d%s", int( ( $value / 1024**2 ) + .5 ), 'M' );
} elsif ( $value > 10**($length) or $opt_U eq 'K' ) {
return sprintf( "%d%s", int( ( $value / 1024 ) + .5 ), 'K' );
} else {
return $value;
}
}
1;

488
html/cgi-bin/base.cgi Normal file
View File

@@ -0,0 +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';
}

123
html/cgi-bin/changepw.cgi Normal file
View File

@@ -0,0 +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();

View File

@@ -0,0 +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
}

371
html/cgi-bin/credits.cgi Normal file
View File

@@ -0,0 +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();

537
html/cgi-bin/ddns.cgi Normal file
View File

@@ -0,0 +1,537 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: ddns.cgi,v 1.7.2.41 2006/02/07 01:29:47 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 $ddnsprefix = $Lang::tr{'ddns noip prefix'};
$ddnsprefix =~ s/%/$General::noipprefix/;
# Files used
my $setting = "${General::swroot}/ddns/settings";
our $datafile = "${General::swroot}/ddns/config";
my %settings=();
#Settings1
$settings{'BEHINDROUTER'} = 'RED_IP';
$settings{'MINIMIZEUPDATES'} = '';
#Settings2 for editing the multi-line list
#Must not be saved !
$settings{'HOSTNAME'} = '';
$settings{'DOMAIN'} = '';
$settings{'LOGIN'} = '';
$settings{'PASSWORD'} = '';
$settings{'PASSWORD2'} = '';
$settings{'ENABLED'} = '';
$settings{'PROXY'} = '';
$settings{'WILDCARDS'} = '';
$settings{'SERVICE'} = '';
my @nosaved=('HOSTNAME','DOMAIN','LOGIN','PASSWORD','PASSWORD2',
'ENABLED','PROXY','WILDCARDS','SERVICE'); # List here ALL setting2 fields. Mandatory
$settings{'ACTION'} = ''; # add/edit/remove
$settings{'KEY1'} = ''; # point record for ACTION
$settings{'KEY2'} = ''; # point record for ACTION
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);
}
#
# Check Settings1 first because they are needed before working on @current
#
if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
# No user input to check. !
#unless ($errormessage) { # Everything is ok, save settings
$settings{'BEHINDROUTERWAITLOOP'} = '-1'; # init & will update on next setddns.pl call
map (delete ($settings{$_}) ,(@nosaved,'ACTION','KEY1','KEY2'));# Must never be saved
&General::writehash($setting, \%settings); # Save good settings
$settings{'ACTION'} = $Lang::tr{'save'}; # Recreate 'ACTION'
map ($settings{$_}= '',(@nosaved,'KEY1','KEY2')); # and reinit var to empty
#}
} else {
&General::readhash($setting, \%settings); # Get saved settings and reset to good if needed
}
#
# Now manipulate the multi-line list with Settings2
#
# 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'}]);
my $K2=$settings{'KEY2'};
$temp[ $K2 ] = ( $temp[ $K2 ] eq 'on') ? '' : 'on'; # Toggle the field
@current[$settings{'KEY1'}] = join (',',@temp)."\n";
$settings{'KEY1'} = ''; # End edit mode
&General::log($Lang::tr{'ddns hostname modified'});
# Write changes to config file.
&WriteDataFile; # sort newly added/modified entry
}
if ($settings{'ACTION'} eq $Lang::tr{'add'}) {
# Validate inputs
unless ($settings{'LOGIN'} ne '') {
$errormessage = $Lang::tr{'username not set'};
}
# list box returns 'service optional synonyms'
# keep only first name
$settings{'SERVICE'} =~ s/ .*$//;
# for freedns.afraid.org, only 'connect string' is mandatory
if ($settings{'SERVICE'} ne 'freedns.afraid.org') {
unless ($settings{'SERVICE'} eq 'regfish.com' || $settings{'PASSWORD'} ne '') {
$errormessage = $Lang::tr{'password not set'};
}
unless ($settings{'PASSWORD'} eq $settings{'PASSWORD2'}) {
$errormessage = $Lang::tr{'passwords do not match'};
}
# Permit an empty HOSTNAME for the nsupdate, regfish, dyndns, enom, ovh, zoneedit, no-ip, easydns
unless ($settings{'SERVICE'} eq 'zoneedit.com' || $settings{'SERVICE'} eq 'nsupdate' ||
$settings{'SERVICE'} eq 'dyndns-custom'|| $settings{'SERVICE'} eq 'regfish.com' ||
$settings{'SERVICE'} eq 'enom.com' || $settings{'SERVICE'} eq 'dnspark.com' ||
$settings{'SERVICE'} eq 'ovh.com' || $settings{'HOSTNAME'} ne '' ||
$settings{'SERVICE'} eq 'no-ip.com' || $settings{'SERVICE'} eq 'easydns.com' ) {
$errormessage = $Lang::tr{'hostname not set'};
}
unless ($settings{'HOSTNAME'} eq '' || $settings{'HOSTNAME'} =~ /^[a-zA-Z_0-9-]+$/) {
$errormessage = $Lang::tr{'invalid hostname'};
}
unless ($settings{'DOMAIN'} ne '') {
$errormessage = $Lang::tr{'domain not set'};
}
unless ($settings{'DOMAIN'} =~ /^[a-zA-Z_0-9.-]+$/) {
$errormessage = $Lang::tr{'invalid domain name'};
}
unless ($settings{'DOMAIN'} =~ /[.]/) {
$errormessage = $Lang::tr{'invalid domain name'};
}
}
# recheck service wich don't need too much fields
if ($settings{'SERVICE'} eq 'cjb.net') {
$errormessage = ''; # clear previous error
unless ($settings{'LOGIN'} ne '') {
$errormessage = $Lang::tr{'username not set'};
}
unless ($settings{'PASSWORD'} ne '') {
$errormessage = $Lang::tr{'password not set'};
}
unless ($settings{'PASSWORD'} eq $settings{'PASSWORD2'}) {
$errormessage = $Lang::tr{'passwords do not match'};
}
}
unless ($errormessage) {
if ($settings{'KEY1'} eq '') { #add or edit ?
unshift (@current, "$settings{'SERVICE'},$settings{'HOSTNAME'},$settings{'DOMAIN'},$settings{'PROXY'},$settings{'WILDCARDS'},$settings{'LOGIN'},$settings{'PASSWORD'},$settings{'ENABLED'}\n");
&General::log($Lang::tr{'ddns hostname added'});
} else {
@current[$settings{'KEY1'}] = "$settings{'SERVICE'},$settings{'HOSTNAME'},$settings{'DOMAIN'},$settings{'PROXY'},$settings{'WILDCARDS'},$settings{'LOGIN'},$settings{'PASSWORD'},$settings{'ENABLED'}\n";
$settings{'KEY1'} = ''; # End edit mode
&General::log($Lang::tr{'ddns hostname modified'});
}
map ($settings{$_}='' ,@nosaved); # Clear fields
# Write changes to config file.
&WriteDataFile; # sort newly added/modified entry
}
}
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{'SERVICE'} = $temp[0];
$settings{'HOSTNAME'} = $temp[1];
$settings{'DOMAIN'} = $temp[2];
$settings{'PROXY'} = $temp[3];
$settings{'WILDCARDS'} = $temp[4];
$settings{'LOGIN'} = $temp[5];
$settings{'PASSWORD'} = $settings{'PASSWORD2'} = $temp[6];
$settings{'ENABLED'} = $temp[7];
}
if ($settings{'ACTION'} eq $Lang::tr{'remove'}) {
splice (@current,$settings{'KEY1'},1); # Delete line
open(FILE, ">$datafile") or die 'ddns datafile error';
print FILE @current;
close(FILE);
$settings{'KEY1'} = ''; # End remove mode
&General::log($Lang::tr{'ddns hostname removed'});
# Write changes to config file.
&WriteDataFile;
}
if ($settings{'ACTION'} eq $Lang::tr{'instant update'}) {
system('/usr/local/bin/setddns.pl', '-f');
}
if ($settings{'ACTION'} eq '')
{
$settings{'SERVICE'} = 'dyndns.org';
$settings{'ENABLED'} = 'on';
}
&Header::openpage($Lang::tr{'dynamic dns'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
my %checked =(); # Checkbox manipulations
$checked{'SERVICE'}{'cjb.net'} = '';
$checked{'SERVICE'}{'dhs.org'} = '';
$checked{'SERVICE'}{'dnspark.com'} = '';
$checked{'SERVICE'}{'dtdns.com'} = '';
$checked{'SERVICE'}{'dyndns.org'} = '';
$checked{'SERVICE'}{'dyndns-custom'} = '';
$checked{'SERVICE'}{'dyndns-static'} = '';
$checked{'SERVICE'}{'dyns.cx'} = '';
$checked{'SERVICE'}{'dynu.ca'} = '';
$checked{'SERVICE'}{'easydns.com'} = '';
$checked{'SERVICE'}{'enom.com'} = '';
$checked{'SERVICE'}{'freedns.afraid.org'} = '';
$checked{'SERVICE'}{'hn.org'} = '';
$checked{'SERVICE'}{'no-ip.com'} = '';
$checked{'SERVICE'}{'nsupdate'} = '';
$checked{'SERVICE'}{'ovh.com'} = '';
$checked{'SERVICE'}{'regfish.com'} = '';
$checked{'SERVICE'}{'selfhost.de'} = '';
$checked{'SERVICE'}{'tzo.com'} = '';
$checked{'SERVICE'}{'zoneedit.com'} = '';
$checked{'SERVICE'}{$settings{'SERVICE'}} = "selected='selected'";
$checked{'BEHINDROUTER'}{'RED_IP'} = '';
$checked{'BEHINDROUTER'}{'FETCH_IP'} = '';
$checked{'BEHINDROUTER'}{$settings{'BEHINDROUTER'}} = "checked='checked'";
$checked{'MINIMIZEUPDATES'} = ($settings{'MINIMIZEUPDATES'} eq '' ) ? '' : "checked='checked'";
$checked{'PROXY'}{'on'} = ($settings{'PROXY'} eq '') ? '' : "checked='checked'";
$checked{'WILDCARDS'}{'on'} = ($settings{'WILDCARDS'} eq '') ? '' : "checked='checked'";
$checked{'ENABLED'}{'on'} = ($settings{'ENABLED'} eq '' ) ? '' : "checked='checked'";
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage&nbsp;</font>";
&Header::closebox();
}
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{'dyn dns source choice'}</td>
</tr><tr>
<td class='base'><input type='radio' name='BEHINDROUTER' value='RED_IP' $checked{'BEHINDROUTER'}{'RED_IP'} />
$Lang::tr{'use ipcop red ip'}</td>
</tr><tr>
<td class='base'><input type='radio' name='BEHINDROUTER' value='FETCH_IP' $checked{'BEHINDROUTER'}{'FETCH_IP'} />
$Lang::tr{'fetch ip from'} <img src='/blob.gif' alt='*' /></td>
</tr>
<tr>
<td class='base'><input type='checkbox' name='MINIMIZEUPDATES' $checked{'MINIMIZEUPDATES'} />
$Lang::tr{'ddns minimize updates'}</td>
</tr>
</table>
<br /><hr />
END
;
print <<END
<table width='100%'>
<tr>
<td class='base' valign='top'><img src='/blob.gif' alt='*' /></td>
<td width='70%' class='base'>$Lang::tr{'avoid dod'}</td>
<td width='30%' align='center' class='base'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
</tr>
</table>
</form>
END
;
&Header::closebox(); # end of Settings1
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'
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='KEY1' value='$settings{'KEY1'}' />
<table width='100%'>
<tr>
<td width='25%' class='base'>$Lang::tr{'service'}:</td>
<td width='25%'><select size='1' name='SERVICE'>
<option $checked{'SERVICE'}{'cjb.net'}>cjb.net</option>
<option $checked{'SERVICE'}{'dhs.org'}>dhs.org</option>
<option $checked{'SERVICE'}{'dnspark.com'}>dnspark.com</option>
<option $checked{'SERVICE'}{'dtdns.com'}>dtdns.com</option>
<option $checked{'SERVICE'}{'dyndns.org'}>dyndns.org</option>
<option $checked{'SERVICE'}{'dyndns-custom'}>dyndns-custom</option>
<option $checked{'SERVICE'}{'dyndns-static'}>dyndns-static</option>
<option $checked{'SERVICE'}{'dyns.cx'}>dyns.cx</option>
<option $checked{'SERVICE'}{'dynu.ca'}>dynu.ca dyn.ee dynserv.(ca|org|net|com)</option>
<option $checked{'SERVICE'}{'easydns.com'}>easydns.com</option>
<option $checked{'SERVICE'}{'enom.com'}>enom.com</option>
<option $checked{'SERVICE'}{'freedns.afraid.org'}>freedns.afraid.org</option>
<option $checked{'SERVICE'}{'hn.org'}>hn.org</option>
<option $checked{'SERVICE'}{'no-ip.com'}>no-ip.com</option>
<option $checked{'SERVICE'}{'nsupdate'}>nsupdate</option>
<option $checked{'SERVICE'}{'ovh.com'}>ovh.com</option>
<option $checked{'SERVICE'}{'regfish.com'}>regfish.com</option>
<option $checked{'SERVICE'}{'selfhost.de'}>selfhost.de</option>
<!-- <option $checked{'SERVICE'}{'tzo.com'}>tzo.com</option> comment this service out until a working fix is developed -->
<option $checked{'SERVICE'}{'zoneedit.com'}>zoneedit.com</option>
</select></td>
<td width='20%' class='base'>$Lang::tr{'hostname'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
<td width='30%'><input type='text' name='HOSTNAME' value='$settings{'HOSTNAME'}' /></td>
</tr><tr>
<td class='base'>$Lang::tr{'behind a proxy'}</td>
<td><input type='checkbox' name='PROXY' value='on' $checked{'PROXY'}{'on'} /></td>
<td class='base'>$Lang::tr{'domain'}:</td>
<td><input type='text' name='DOMAIN' value='$settings{'DOMAIN'}' /></td>
</tr><tr>
<td class='base'>$Lang::tr{'enable wildcards'}</td>
<td><input type='checkbox' name='WILDCARDS' value='on' $checked{'WILDCARDS'}{'on'} /></td>
<td class='base'>$Lang::tr{'username'}</td>
<td><input type='text' name='LOGIN' value='$settings{'LOGIN'}' /></td>
</tr><tr>
<td></td>
<td></td>
<td class='base'>$Lang::tr{'password'}</td>
<td><input type='password' name='PASSWORD' value='$settings{'PASSWORD'}' /></td>
</tr><tr>
<td class='base'>$Lang::tr{'enabled'}</td>
<td><input type='checkbox' name='ENABLED' value='on' $checked{'ENABLED'}{'on'} /></td>
<td class='base'>$Lang::tr{'again'}</td>
<td><input type='password' name='PASSWORD2' value='$settings{'PASSWORD2'}' /></td>
</tr>
</table>
<hr />
<table width='100%'>
<tr>
<td class='base' valign='top'><img src='/blob.gif' alt='*' /></td>
<td width='70%' class='base'>$ddnsprefix</td>
<td width='30%' align='center' class='base'>
<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
#
&Header::openbox('100%', 'left', $Lang::tr{'current hosts'});
print <<END
<table width='100%'>
<tr>
<td width='15%' align='center' class='boldbase'><b>$Lang::tr{'service'}</b></td>
<td width='25%' align='center' class='boldbase'><b>$Lang::tr{'hostname'}</b></td>
<td width='30%' align='center' class='boldbase'><b>$Lang::tr{'domain'}</b></td>
<td width='10%' align='center' class='boldbase'><b>$Lang::tr{'proxy'}</b></td>
<td width='10%' align='center' class='boldbase'><b>$Lang::tr{'wildcards'}</b></td>
<td width='10%' colspan='3' class='boldbase' align='center'><b>$Lang::tr{'action'}</b></td>
</tr>
END
;
my $ip = &General::GetDyndnsRedIP;
my $key = 0;
foreach my $line (@current) {
chomp($line); # remove newline
my @temp = split(/\,/,$line);
if ($temp[0] eq 'no-ip.com') {
$temp[1] =~ s!$General::noipprefix(.*)!<b>group:</b>$1 !;
}
#Choose icon for checkbox
my $gifproxy='';
my $descproxy='';
if ($temp[3] eq "on") {
$gifproxy = 'on.gif';
$descproxy = $Lang::tr{'click to disable'};
} else {
$gifproxy = 'off.gif';
$descproxy = $Lang::tr{'click to enable'};
}
my $gifwildcard='';
my $descwildcard='';
if ($temp[4] eq "on") {
$gifwildcard = 'on.gif';
$descwildcard = $Lang::tr{'click to disable'};
} else {
$gifwildcard = 'off.gif';
$descwildcard = $Lang::tr{'click to enable'};
}
my $sync = "<font color='blue'>";
my $gif = '';
my $gdesc = '';
if ($temp[7] eq "on") {
$gif = 'on.gif';
$gdesc = $Lang::tr{'click to disable'};
$sync = (&General::DyndnsServiceSync ($ip,$temp[1], $temp[2]) ? "<font color='green'>": "<font color='red'>") ;
} 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}'>";
}
#if a field is empty, replace it with a '---' to see colorized info!
$temp[1] = '---' if (!$temp[1]);
$temp[2] = '---' if (!$temp[2]);
print <<END
<td align='center'><a href='http://$temp[0]'>$temp[0]</a></td>
<td align='center'>$sync$temp[1]</td>
<td align='center'>$sync$temp[2]</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/$gifproxy' alt='$descproxy' title='$descproxy' />
<input type='hidden' name='KEY1' value='$key' />
<input type='hidden' name='KEY2' value='3' />
</form>
</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/$gifwildcard' alt='$descwildcard' title='$descwildcard' />
<input type='hidden' name='KEY1' value='$key' />
<input type='hidden' name='KEY2' value='4' />
</form>
</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' />
<input type='hidden' name='KEY2' value='7' />
</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 width='100%'>
<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>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<td align='center' width='30%'><input type='submit' name='ACTION' value='$Lang::tr{'instant update'}' /></td>
</form>
</tr>
</table>
END
;
}
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
## Ouf it's the end !
# write the "current" array
sub WriteDataFile {
#Save current
open(FILE, ">$datafile") or die 'ddns datafile error';
print FILE @current;
close (FILE);
}

1245
html/cgi-bin/dhcp.cgi Normal file

File diff suppressed because it is too large Load Diff

35
html/cgi-bin/dial.cgi Normal file
View File

@@ -0,0 +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";

440
html/cgi-bin/dmzholes.cgi Normal file
View File

@@ -0,0 +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;
}

148
html/cgi-bin/graphs.cgi Normal file
View File

@@ -0,0 +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();

229
html/cgi-bin/gui.cgi Normal file
View File

@@ -0,0 +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();

449
html/cgi-bin/hosts.cgi Normal file
View File

@@ -0,0 +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';
}

313
html/cgi-bin/ids.cgi Normal file
View File

@@ -0,0 +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;
}

204
html/cgi-bin/index.cgi Normal file
View File

@@ -0,0 +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();

103
html/cgi-bin/ipinfo.cgi Normal file
View File

@@ -0,0 +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();

View File

@@ -0,0 +1,7 @@
/config.dat/1.2.2.10/Tue Jun 14 12:32:07 2005//TIPCOP_v1_4_0
/firewalllog.dat/1.4.2.18/Tue Aug 23 12:01:50 2005//TIPCOP_v1_4_0
/ids.dat/1.6.2.16/Tue Jun 14 08:25:30 2005//TIPCOP_v1_4_0
/log.dat/1.6.2.22/Tue Jan 3 12:47:17 2006//TIPCOP_v1_4_0
/proxylog.dat/1.4.2.25/Thu Jul 7 17:32:24 2005//TIPCOP_v1_4_0
/summary.dat/1.3.2.14/Sun Jul 10 00:48:42 2005//TIPCOP_v1_4_0
D

View File

@@ -0,0 +1 @@
ipcop/html/cgi-bin/logs.cgi

View File

@@ -0,0 +1 @@
:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ipcop

View File

@@ -0,0 +1 @@
TIPCOP_v1_4_0

View File

@@ -0,0 +1,165 @@
#!/usr/bin/perl
#
# IPCop CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The IPCop Team
#
# $Id: config.dat,v 1.2.2.10 2005/06/14 12:32:07 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 %logsettings=();
my %checked=();
my %selected=();
my $errormessage='';
&Header::showhttpheaders();
$logsettings{'LOGVIEW_REVERSE'} = 'off';
$logsettings{'LOGVIEW_VIEWSIZE'} = '150';
$logsettings{'LOGWATCH_LEVEL'} = 'Low';
$logsettings{'LOGWATCH_KEEP'} = '56';
my @VS = ('15','50','100','150','250','500');
$logsettings{'ENABLE_REMOTELOG'} = 'off';
$logsettings{'REMOTELOG_ADDR'} = '';
$logsettings{'ACTION'} = '';
&Header::getcgihash(\%logsettings);
if ($logsettings{'ACTION'} eq $Lang::tr{'save'})
{
if ($logsettings{'ENABLE_REMOTELOG'} eq 'on')
{
unless ( &General::validfqdn($logsettings{'REMOTELOG_ADDR'}) ||
&General::validip ($logsettings{'REMOTELOG_ADDR'}))
{
$errormessage = $Lang::tr{'invalid logserver address'};
}
}
unless ($logsettings{'LOGWATCH_KEEP'} =~ /^\d+$/)
{
$errormessage = $Lang::tr{'invalid keep time'};
}
unless ($logsettings{'LOGWATCH_LEVEL'} =~ /^Low|Med|High$/)
{
$errormessage = $Lang::tr{'invalid input'};
}
unless ($errormessage)
{
&General::writehash("${General::swroot}/logging/settings", \%logsettings);
system('/usr/local/bin/restartsyslogd') == 0
or $errormessage = "$Lang::tr{'bad return code'} " . $?/256;
}
}
&General::readhash("${General::swroot}/logging/settings", \%logsettings);
$checked{'ENABLE_REMOTELOG'}{'off'} = '';
$checked{'ENABLE_REMOTELOG'}{'on'} = '';
$checked{'ENABLE_REMOTELOG'}{$logsettings{'ENABLE_REMOTELOG'}} = "checked='checked'";
$checked{'LOGVIEW_REVERSE'}{'off'} = '';
$checked{'LOGVIEW_REVERSE'}{'on'} = '';
$checked{'LOGVIEW_REVERSE'}{$logsettings{'LOGVIEW_REVERSE'}} = "checked='checked'";
$selected{'LOGWATCH_LEVEL'}{'Low'} = '';
$selected{'LOGWATCH_LEVEL'}{'Med'} = '';
$selected{'LOGWATCH_LEVEL'}{'High'} = '';
$selected{'LOGWATCH_LEVEL'}{$logsettings{'LOGWATCH_LEVEL'}} = "selected='selected'";
map ($selected{'LOGVIEW_VIEWSIZE'}{$_} = '', @VS);
$selected{'LOGVIEW_VIEWSIZE'}{$logsettings{'LOGVIEW_VIEWSIZE'}} = "selected='selected'";
&Header::openpage($Lang::tr{'log 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{'log viewing options'});
print <<END
<table width='100%'>
<tr>
<td><input type='checkbox' name='LOGVIEW_REVERSE' $checked{'LOGVIEW_REVERSE'}{'on'} /></td>
<td class='base' width='50%'>$Lang::tr{'reverse sort'}</td>
<td class='base' width='25%' align='right'>$Lang::tr{'log lines per page'}:&nbsp;</td>
<td width='25%'><select name='LOGVIEW_VIEWSIZE'>
END
;
foreach my $vs (@VS) {
print "\t<option value='$vs' $selected{'LOGVIEW_VIEWSIZE'}{$vs}>$vs</option>\n";
}
print <<END
</select></td>
</tr>
</table>
END
;
&Header::closebox();
&Header::openbox('100%', 'left', $Lang::tr{'log summaries'});
print <<END
<table width='100%'>
<tr>
<td class='base' width='50%'>$Lang::tr{'summaries kept'}&nbsp;
<input type='text' name='LOGWATCH_KEEP'
value='$logsettings{'LOGWATCH_KEEP'}' size='4' />&nbsp;$Lang::tr{'days'}</td>
<td>$Lang::tr{'detail level'}:</td><td>
<select name='LOGWATCH_LEVEL'>
<option value='Low' $selected{'LOGWATCH_LEVEL'}{'Low'}>$Lang::tr{'low'}</option>
<option value='Med' $selected{'LOGWATCH_LEVEL'}{'Med'}>$Lang::tr{'medium'}</option>
<option value='High' $selected{'LOGWATCH_LEVEL'}{'High'}>$Lang::tr{'high'}</option>
</select></td>
</tr>
</table>
END
;
&Header::closebox();
&Header::openbox('100%', 'left', $Lang::tr{'remote logging'});
print <<END
<table width='100%'>
<tr>
<td class='base'>$Lang::tr{'enabled'}</td><td><input type='checkbox' name='ENABLE_REMOTELOG' $checked{'ENABLE_REMOTELOG'}{'on'} /></td>
<td>$Lang::tr{'log server address'}</td><td><input type='text' name='REMOTELOG_ADDR' value='$logsettings{'REMOTELOG_ADDR'}' /></td>
</tr>
</table>
END
;
&Header::closebox();
print <<END
<div align='center'>
<table width='60%'>
<tr>
<td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
</tr>
</table>
</div>
END
;
print "</form>\n";
&Header::closebigbox();
&Header::closepage();

View File

@@ -0,0 +1,411 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: firewalllog.dat,v 1.4.2.18 2005/08/23 12:01:50 eoberlander Exp $
#
# July 28, 2003 - Darren Critchley - darren@kdi.ca
# - added source mac adapter to layout
#
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";
use POSIX();
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::table2colour} );
undef (@dummy);
my %cgiparams=();
my %logsettings=();
my $errormessage = '';
my @shortmonths = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
'Sep', 'Oct', 'Nov', 'Dec' );
my @longmonths = ( $Lang::tr{'january'}, $Lang::tr{'february'}, $Lang::tr{'march'},
$Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july'}, $Lang::tr{'august'},
$Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'},
$Lang::tr{'december'} );
my @now = localtime();
my $dow = $now[6];
my $doy = $now[7];
my $tdoy = $now[7];
my $year = $now[5]+1900;
$cgiparams{'DAY'} = $now[3];
$cgiparams{'MONTH'} = $now[4];
$cgiparams{'ACTION'} = '';
&Header::getcgihash(\%cgiparams);
$logsettings{'LOGVIEW_REVERSE'} = 'off';
&General::readhash("${General::swroot}/logging/settings", \%logsettings);
${Header::viewsize} = defined ($logsettings{'LOGVIEW_VIEWSIZE'}) ? $logsettings{'LOGVIEW_VIEWSIZE'} : 150;
my $start = ($logsettings{'LOGVIEW_REVERSE'} eq 'on') ? 0x7FFFF000 : 0; #index of firts line number to display
if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'})
{
my @temp = split(',',$ENV{'QUERY_STRING'});
$start = $temp[0];
$cgiparams{'MONTH'} = $temp[1];
$cgiparams{'DAY'} = $temp[2];
}
if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) ||
!($cgiparams{'DAY'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)$/))
{
$cgiparams{'DAY'} = $now[3];
$cgiparams{'MONTH'} = $now[4];
}
elsif($cgiparams{'ACTION'} eq '>>')
{
my @temp_then=();
my @temp_now = localtime(time);
$temp_now[4] = $cgiparams{'MONTH'};
$temp_now[3] = $cgiparams{'DAY'};
if ($cgiparams{'DAY'}) {
@temp_then = localtime(POSIX::mktime(@temp_now) + 86400);
## Retrieve the same time on the next day +
## 86400 seconds in a day
} else {
$temp_now[3] = 1;
$temp_now[4] = ($temp_now[4]+1) %12;
@temp_then = localtime(POSIX::mktime(@temp_now) );
$temp_then[3] = 0;
}
$cgiparams{'MONTH'} = $temp_then[4];
$cgiparams{'DAY'} = $temp_then[3];
}
elsif($cgiparams{'ACTION'} eq '<<')
{
my @temp_then=();
my @temp_now = localtime(time);
$temp_now[4] = $cgiparams{'MONTH'};
$temp_now[3] = $cgiparams{'DAY'};
if ($cgiparams{'DAY'}) {
@temp_then = localtime(POSIX::mktime(@temp_now) - 86400);
## Retrieve the same time on the next day -
## 86400 seconds in a day
} else {
$temp_now[3] = 1;
$temp_now[4] = ($temp_now[4]-1) %12;
@temp_then = localtime(POSIX::mktime(@temp_now) );
$temp_then[3] = 0;
}
$cgiparams{'MONTH'} = $temp_then[4];
$cgiparams{'DAY'} = $temp_then[3];
}
# Find in which file.gz is the log. Can be calculated because WEEKLY ROTATING of access.log
my $gzindex;
my $date = $cgiparams{'DAY'} == 0 ? '' : $cgiparams{'DAY'} <= 9 ? "0$cgiparams{'DAY'}" : "$cgiparams{'DAY'}";
{
my $xday;
# Calculate time. If future date, calculate for past year !!!
if (( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) ||
( $cgiparams{'MONTH'} > $now[4] ) ) {
$xday = POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 );
$date = "$longmonths[$cgiparams{'MONTH'}] $date, ". int($year-1);
} else {
$xday = POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 );
$date = "$longmonths[$cgiparams{'MONTH'}] $date, $year";
}
# calculate end of active week (saturday 23H59)
my @then = ();
@then = localtime(time());
my $sunday = POSIX::mktime( 0, 0, 0, @then[3], @then[4], @then[5]);
$sunday += (6-$then[6]) * 86400;
# Convert delta in second to full weeks
$gzindex = int (($sunday-$xday)/604800 );
}
my $monthstr = $shortmonths[$cgiparams{'MONTH'}];
my $daystr = $cgiparams{'DAY'} == 0 ? '..' : $cgiparams{'DAY'} <= 9 ? " $cgiparams{'DAY'}" : "$cgiparams{'DAY'}";
my $lines = 0;
my @log=();
my $loop = 1;
my $filestr = 0;
my $lastdatetime; # for debug
my $search_for_end = 0;
while ($gzindex >=0 && $loop) {
# calculate file name
if ($gzindex == 0) {
$filestr = "/var/log/messages";
} else {
$filestr = "/var/log/messages.$gzindex";
$filestr = "$filestr.gz" if -f "$filestr.gz";
}
# now read file if existing
if (open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr))) {
#&General::log("reading $filestr");
READ:while (<FILE>) {
my $line = $_;
if ($line =~ /^${monthstr} ${daystr} ..:..:.. [\w\-]+ kernel:.*IN=.*$/) {
# when standart viewing, just keep in memory the correct slice
# it starts a '$start' and size is $viewport
# If export, then keep all lines...
if ($cgiparams{'ACTION'} eq $Lang::tr{'export'}){
$log[$lines++] = "$line";
} else {
if ($lines++ < ($start + $Header::viewsize)) {
push(@log,"$line");
if (@log > $Header::viewsize) {
shift (@log);
}
#} else { dont do this optimisation, need to count lines !
# $datetime = $maxtime; # we have read viewsize lines, stop main loop
# last READ; # exit read file
}
}
$search_for_end = 1; # we find the start of slice, can look for end now
} else {
if ($search_for_end == 1) {
#finish read files when date is over (test month equality only)
$line =~ /^(...) (..) ..:..:..*$/;
$loop = 0 if ( ($1 ne $monthstr) || ( ($daystr ne '..') && ($daystr ne $2) ) );
}
}
}
close (FILE);
}
$gzindex--; # will try next gz file eg 40,39,38,.... because it may have holes when ipcop stopped
# for a long time
}# while
# $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}";
if ($cgiparams{'ACTION'} eq $Lang::tr{'export'})
{
print "Content-type: text/plain\n\n";
print "IPCop firewall log\r\n";
print "$Lang::{'date'}: $date\r\n\r\n";
if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @log = reverse @log; }
foreach $_ (@log)
{
/^... (..) (..:..:..) [\w\-]+ kernel:.*(IN=.*)$/;
my $day = $1;
$day =~ tr / /0/;
my $time = $cgiparams{'DAY'} ? "$2" : "$day/$2" ;
print "$time $3\r\n";
}
exit 0;
}
&Header::showhttpheaders();
&Header::openpage($Lang::tr{'firewall log'}, 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{'settings'}:");
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<table width='100%'>
<tr>
<td width='10%' class='base'>$Lang::tr{'month'}:&nbsp;</td>
<td width='10%'>
<select name='MONTH'>
END
;
for (my $month = 0; $month < 12; $month++)
{
print "\t<option ";
if ($month == $cgiparams{'MONTH'}) {
print "selected='selected' "; }
print "value='$month'>$longmonths[$month]</option>\n";
}
print <<END
</select>
</td>
<td width='10%' class='base' align='right'>&nbsp;$Lang::tr{'day'}:&nbsp;</td>
<td width='40%'>
<select name='DAY'>
END
;
print "<option value='0'>$Lang::tr{'all'}</option>\n";
for (my $day = 1; $day <= 31; $day++)
{
print "\t<option ";
if ($day == $cgiparams{'DAY'}) {
print "selected='selected' "; }
print "value='$day'>$day</option>\n";
}
print <<END
</select>
</td>
<td width='5%' align='center'><input type='submit' name='ACTION' title='$Lang::tr{'day before'}' value='&lt;&lt;' /></td>
<td width='5%' align='center'><input type='submit' name='ACTION' title='$Lang::tr{'day after'}' value='&gt;&gt;' /></td>
<td width='10%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'update'}' /></td>
<td width='10%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'export'}' /></td>
</tr>
</table>
</form>
END
;
&Header::closebox();
&Header::openbox('100%', 'left', $Lang::tr{'log'});
print "<p><b>$Lang::tr{'firewall hits'} $date: $lines</b></p>";
$start = $lines - ${Header::viewsize} if ($start >= $lines - ${Header::viewsize});
$start = 0 if ($start < 0);
my $prev;
if ($start == 0) {
$prev = -1;
} else {
$prev = $start - ${Header::viewsize};
$prev = 0 if ( $prev < 0);
}
my $next;
if ($start == $lines - ${Header::viewsize}) {
$next = -1;
} else {
$next = $start + ${Header::viewsize};
$next = $lines - ${Header::viewsize} if ($next >= $lines - ${Header::viewsize});
}
if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @log = reverse @log; }
if ($lines != 0) { &oldernewer(); }
print <<END
<table width='100%'>
<tr>
<td width='10%' align='center' class='boldbase'><b>$Lang::tr{'time'}</b></td>
<td width='13%' align='center' class='boldbase'><b>$Lang::tr{'chain'}</b></td>
<td width='5%' align='center' class='boldbase'><b>$Lang::tr{'iface'}</b></td>
<td width='5%' align='center' class='boldbase'><b>$Lang::tr{'proto'}</b></td>
<td width='16%' align='center' class='boldbase'><b>$Lang::tr{'source'}</b></td>
<td width='10%' align='center' class='boldbase'><b>$Lang::tr{'src port'}</b></td>
<td width='5%' align='center' class='boldbase'><b>$Lang::tr{'mac address'}</b></td>
<td width='16%' align='center' class='boldbase'><b>$Lang::tr{'destination'}</b></td>
<td width='20%' align='center' class='boldbase'><b>$Lang::tr{'dst port'}</b></td>
</tr>
END
;
$lines = 0;
foreach $_ (@log)
{
/^... (..) (..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/;
my $day = $1;
$day =~ tr / /0/;
my $time = $cgiparams{'DAY'} ? "$2" : "$day/$2" ;
my $comment = $3;
my $packet = $4;
$packet =~ /IN=(\w+)/; my $iface=$1;
$packet =~ /SRC=([\d\.]+)/; my $srcaddr=$1;
$packet =~ /DST=([\d\.]+)/; my $dstaddr=$1;
$packet =~ /MAC=([\w+\:]+)/; my $macaddr=$1;
$packet =~ /PROTO=(\w+)/; my $proto=$1;
$packet =~ /SPT=(\d+)/; my $srcport=$1;
$packet =~ /DPT=(\d+)/; my $dstport=$1;
my $servi = uc(getservbyport($srcport, lc($proto)));
if ($servi ne '' && $srcport < 1024) {
$srcport = "$srcport($servi)"; }
$servi = uc(getservbyport($dstport, lc($proto)));
if ($servi ne '' && $dstport < 1024) {
$dstport = "$dstport($servi)";}
my @mactemp = split(/:/,$macaddr);
$macaddr = "$mactemp[6]:$mactemp[7]:$mactemp[8]:$mactemp[9]:$mactemp[10]:$mactemp[11]";
if ($lines % 2) {
print "<tr bgcolor='${Header::table1colour}'>\n"; }
else {
print "<tr bgcolor='${Header::table2colour}'>\n"; }
print <<END
<td align='center'>$time</td>
<td align='center'>$comment</td>
<td align='center'>$iface</td>
<td align='center'>$proto</td>
<td align='center'>
<table width='100%' cellpadding='0' cellspacing='0'><tr>
<td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a></td>
</tr></table>
</td>
<td align='center'>$srcport</td>
<td align='center'>$macaddr</td>
<td align='center'>
<table width='100%' cellpadding='0' cellspacing='0'><tr>
<td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td>
</tr></table>
</td>
<td align='center'>$dstport</td>
</tr>
END
;
$lines++;
}
print "</table>";
&oldernewer();
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
sub oldernewer
{
print <<END
<table width='100%'>
<tr>
END
;
print "<td align='center' width='50%'>";
if ($prev != -1) {
print "<a href='/cgi-bin/logs.cgi/firewalllog.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'older'}</a>"; }
else {
print "$Lang::tr{'older'}"; }
print "</td>\n";
print "<td align='center' width='50%'>";
if ($next >= 0) {
print "<a href='/cgi-bin/logs.cgi/firewalllog.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'newer'}</a>"; }
else {
print "$Lang::tr{'newer'}"; }
print "</td>\n";
print <<END
</tr>
</table>
END
;
}

View File

@@ -0,0 +1,458 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# Copyright (C) 18-03-2002 Mark Wormgoor <mark@wormgoor.com>
# - Added links to Snort database and ipinfo.cgi
#
# $Id: ids.dat,v 1.6.2.16 2005/06/14 08:25:30 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";
use POSIX();
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::table1colour}, ${Header::table2colour} );
undef (@dummy);
my %cgiparams=();
my %logsettings=();
my @log=();
my $errormessage = '';
my @shortmonths = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
'Sep', 'Oct', 'Nov', 'Dec' );
my @longmonths = ( $Lang::tr{'january'}, $Lang::tr{'february'}, $Lang::tr{'march'},
$Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july'}, $Lang::tr{'august'},
$Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'},
$Lang::tr{'december'} );
my @now = localtime(time);
my $dow = $now[6];
my $doy = $now[7];
my $tdoy = $now[7];
my $year = $now[5]+1900;
$cgiparams{'DAY'} = $now[3];
$cgiparams{'MONTH'} = $now[4];
$cgiparams{'ACTION'} = '';
&Header::getcgihash(\%cgiparams);
$logsettings{'LOGVIEW_REVERSE'} = 'off';
&General::readhash("${General::swroot}/logging/settings", \%logsettings);
${Header::viewsize} = defined ($logsettings{'LOGVIEW_VIEWSIZE'}) ? $logsettings{'LOGVIEW_VIEWSIZE'} : 150;
$Header::viewsize /= 5; # each ids is displayed on 5 lines
$now[4] = $cgiparams{'MONTH'}+1;
if($now[4] < 10) {
$now[4] = "0$now[4]"; }
my $start = -1;
if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'})
{
my @temp = split(',',$ ENV{'QUERY_STRING'});
$start = $temp[0];
$cgiparams{'MONTH'} = $temp[1];
$cgiparams{'DAY'} = $temp[2];
}
if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) ||
!($cgiparams{'DAY'} =~ /^(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)$/))
{
$cgiparams{'DAY'} = $now[3];
$cgiparams{'MONTH'} = $now[4];
}
elsif($cgiparams{'ACTION'} eq '>>')
{
my @temp_then=();
my @temp_now = localtime(time);
$temp_now[4] = $cgiparams{'MONTH'};
$temp_now[3] = $cgiparams{'DAY'};
@temp_then = localtime(POSIX::mktime(@temp_now) + 86400);
## Retrieve the same time on the next day +
## 86400 seconds in a day
$cgiparams{'MONTH'} = $temp_then[4];
$cgiparams{'DAY'} = $temp_then[3];
}
elsif($cgiparams{'ACTION'} eq '<<')
{
my @temp_then=();
my @temp_now = localtime(time);
$temp_now[4] = $cgiparams{'MONTH'};
$temp_now[3] = $cgiparams{'DAY'};
@temp_then = localtime(POSIX::mktime(@temp_now) - 86400);
## Retrieve the same time on the previous day -
## 86400 seconds in a day
$cgiparams{'MONTH'} = $temp_then[4];
$cgiparams{'DAY'} = $temp_then[3];
}
if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4]))
{
my @then = ();
if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) ||
( $cgiparams{'MONTH'} > $now[4] ) ) {
@then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 ));
} else {
@then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 ));
}
$tdoy = $then[7];
my $lastleap=($year-1)%4;
if ($tdoy>$doy) {
if ($lastleap == 0 && $tdoy < 60) {
$doy=$doy+366;
} else {
$doy=$doy+365;
}
}
}
my $datediff=0;
my $dowd=0;
my $multifile=0;
if ($tdoy ne $doy) {
$datediff=int(($doy-$tdoy)/7);
$dowd=($doy-$tdoy)%7;
if (($dow-$dowd)<1) {
$datediff=$datediff+1;
}
if (($dow-$dowd)==0) {
$multifile=1;
}
}
my $longmonthstr = $longmonths[$cgiparams{'MONTH'}];
my $monthnum = $cgiparams{'MONTH'} + 1;
my $monthstr = $monthnum <= 9 ? "0$monthnum" : "$monthnum";
my $daystr = $cgiparams{'DAY'} <= 9 ? "0$cgiparams{'DAY'}" : "$cgiparams{'DAY'}";
my $lines = 0;
my ($title,$classification,$priority,$date,$time,$srcip,$srcport,$destip,$destport, $sid, @refs);
&processevent;
if ($multifile) {
$datediff=$datediff-1;
&processevent;
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'export'})
{
print "Content-type: text/plain\n\n";
print "IPCop IDS snort log\r\n";
print "Date: $cgiparams{'DAY'} $longmonths[$cgiparams{'MONTH'}]\r\n";
print "\r\n";
if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @log = reverse @log; }
foreach $_ (@log)
{
my ($datetime,$title,$priority,$classification,$srcip,$srcport,$destip,$destport,$sid,$refs) = split(/\|/);
$refs =~ s/,$//;
print "Date: $datetime\n";
print "Name: $title\n";
print "Priority: $priority\n";
print "Type: $classification\n";
print "IP Info: ";
print "$srcip";
if ($srcport != "n/a") {
print ":$srcport";
}
print " -> ";
print "$destip";
if ($destport != "n/a") {
print ":$destport";
}
print "\n";
print "SID: $sid\n";
print "Refs: $refs\n\n";
}
exit;
}
&Header::showhttpheaders();
&Header::openpage($Lang::tr{'ids log viewer'}, 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{'settings'}:");
print <<END
<form method='post' action="$ENV{'SCRIPT_NAME'}">
<table width='100%'>
<tr>
<td width='10%' class='base'>$Lang::tr{'month'}:&nbsp;</td>
<td width='10%'>
<select name='MONTH'>
END
;
for (my $month = 0; $month < 12; $month++)
{
print "\t<option ";
if ($month == $cgiparams{'MONTH'}) {
print 'selected="selected" '; }
print "value='$month'>$longmonths[$month]</option>\n";
}
print <<END
</select>
</td>
<td width='10%' class='base' align='right'>&nbsp;$Lang::tr{'day'}:&nbsp;</td>
<td width='40%'>
<select name='DAY'>
END
;
for (my $day = 1; $day <= 31; $day++)
{
print "\t<option ";
if ($day == $cgiparams{'DAY'}) {
print 'selected="selected" '; }
print "value='$day'>$day</option>\n";
}
print <<END
</select>
</td>
<td width='5%' align='center'><input type='submit' name='ACTION' title='$Lang::tr{'day before'}' value='&lt;&lt;' /></td>
<td width='5%' align='center'><input type='submit' name='ACTION' title='$Lang::tr{'day after'}' value='&gt;&gt;' /></td>
<td width='10%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'update'}' /></td>
<td width='10%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'export'}' /></td>
</tr>
</table>
</form>
END
;
&Header::closebox();
&Header::openbox('100%', 'left', $Lang::tr{'log'});
print "<p><b>$Lang::tr{'snort hits'} $longmonthstr $daystr: $lines</b></p>";
if ($start == -1) {
$start = $lines - ${Header::viewsize}; }
if ($start >= $lines - ${Header::viewsize}) { $start = $lines - ${Header::viewsize}; };
if ($start < 0) { $start = 0; }
my $prev = $start - ${Header::viewsize};
my $next = $start + ${Header::viewsize};
if ($prev < 0) { $prev = 0; }
if ($next >= $lines) { $next = -1 }
if ($start == 0) { $prev = -1; }
my @slice = splice(@log, $start, ${Header::viewsize});
if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @slice = reverse @slice; }
if ($lines != 0) {
&oldernewer();
$lines = 0;
print <<END
<table width='100%'>
END
;
foreach $_ (@slice)
{
if ($lines % 2) {
print "<tr bgcolor='${Header::table1colour}'><td>\n"; }
else {
print "<tr bgcolor='${Header::table2colour}'><td>\n"; }
my ($datetime,$title,$priority,$classification,$srcip,$srcport,$destip,$destport,$sid,$refs) = split(/\|/);
print <<END
<table width='100%'>
<tr>
<td width='15%'><b>$Lang::tr{'date'}:</b></td><td width='25%'>$datetime</td>
<td width='10%'><b>$Lang::tr{'name'}:</b></td><td width='50%'>$title</td>
</tr>
<tr><td><b>$Lang::tr{'priority'}:</b></td><td>$priority</td>
<td><b>$Lang::tr{'type'}:</b></td><td>$classification</td>
</tr>
<tr><td><b>$Lang::tr{'ipinfo'}:</b></td>
<td colspan='3'>
END
;
if ($srcip ne "n/a") {
print "<a href='/cgi-bin/ipinfo.cgi?ip=$srcip'>$srcip</a>";
} else {
print "$srcip";
}
print ":$srcport -&gt; ";
if ($destip ne "n/a") {
print "<a href='/cgi-bin/ipinfo.cgi?ip=$destip'>$destip</a>";
} else {
print "$destip";
}
print ":$destport";
print <<END
</td>
</tr>
<tr><td valign='top'><b>$Lang::tr{'references'}:</b></td><td valign='top'>
END
;
foreach my $ref (split(/,/,$refs)) {
if ($ref =~ m/url (.*)/) {
print "<a href='http://$1'>$1</a><br />";
} elsif ($ref =~ m/cve (.*)/) {
print "<a href='http://cve.mitre.org/cgi-bin/cvename.cgi?name=$1'>$1</a><br />";
} elsif ($ref =~ m/nessus (.*)/) {
print "<a href='http://cgi.nessus.org/plugins/dump.php3?id=$1'>Nessus $1</a><br />";
} elsif ($ref =~ m/bugtraq (.*)/) {
print "<a href='http://www.securityfocus.com/bid/$1'>Bugtraq $1</a><br />";
} else {
print "$ref<br />";
}
}
print $Lang::tr{'none found'} unless $refs =~ /,/;
print <<END
<td valign='top'><b>SID:</b></td>
<td valign='top'>
END
;
if ($sid ne "n/a") {
print "<a href='http://www.snort.org/pub-bin/sigs.cgi?sid=$sid' ";
print "target='_blank'>$sid</a></td>\n";
} else {
print $sid;
}
print <<END
</tr>
</table>
</td></tr>
END
;
$lines++;
}
print "</table>";
}
&oldernewer();
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
sub processevent
{
our ($title,$classification,$priority,$date,$time,$srcip,$srcport,$destip,$destport, $sid, @refs);
my $filestr='';
if ($datediff==0) {
$filestr="/var/log/snort/alert";
} else {
$filestr="/var/log/snort/alert.$datediff";
$filestr = "$filestr.gz" if -f "$filestr.gz";
}
if (!(open (LOG,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) {
$errormessage="$errormessage$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}";
} else {
my $line = 0;
while(<LOG>) {
$line++;
if ($_ =~ m/\[\*\*\]/) {
unless ($line == 1 || $date ne "$monthstr/$daystr") {
&append;
$line = 1;
}
($title,$classification,$priority,$date,$time,$srcip,$srcport,$destip,$destport, $sid) = ("n/a","n/a","n/a","n/a","n/a","n/a","n/a","n/a","n/a", "n/a");
@refs = ();
$_ =~ m/:([0-9]{1,4})\] (.*) \[\*\*\]/;
$title = &Header::cleanhtml($2,"y");
}
if ($_ =~ m/Classification: (.*)\] \[Priority: (\d)\]/) {
$classification = &Header::cleanhtml($1,"y");
$priority = $2;
}
if ($_ =~ m/([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3}) \-\> ([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/) {
$srcip = $1 . "." . $2 . "." . $3 . "." . $4;
$destip = $5 . "." . $6 . "." . $7 . "." . $8;
}
if ($_ =~ m/([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\:([0-9]{1,6}) \-\> ([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\:([0-9]{1,6})/) {
$srcip = $1 . "." . $2 . "." . $3 . "." . $4;
$srcport = $5;
$destip = $6 . "." . $7 . "." . $8 . "." . $9;
$destport = $10;
}
if ($_ =~ m/^([0-9\/]{3,5})\-([0-9\:]{5,8})\.([0-9]{1,14})/) {
($date,$time) = ($1,$2);
}
if ($_ =~ m/\[Xref \=\>.*\]/) {
$_ =~ s/\]\[Xref \=\> /, /g;
$_ =~ m/\[Xref \=\> (.*)\]/;
push(@refs, $1);
}
if ($_ =~ m/\[1:([0-9]+):[0-9]+\]/) {
$sid = $1;
}
}
$line++;
unless ($line == 1 || $date ne "$monthstr/$daystr") { &append; }
close(LOG);
}
}
sub append
{
our ($title,$classification,$priority,$date,$time,$srcip,$srcport,$destip,$destport, $sid, @refs);
$log[$lines] = "$date $time|$title|$priority|$classification|$srcip|$srcport|$destip|$destport|$sid|";
foreach $_ (@refs) {
$log[$lines] = "$log[$lines]$_,"; }
$lines++;
}
sub oldernewer
{
print <<END
<table width='100%'>
<tr>
END
;
print "<td align='center' width='50%'>";
if ($prev != -1) {
print "<a href='/cgi-bin/logs.cgi/ids.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'older'}</a>"; }
else {
print "$Lang::tr{'older'}"; }
print "</td>\n";
print "<td align='center' width='50%'>";
if ($next != -1) {
print "<a href='/cgi-bin/logs.cgi/ids.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'newer'}</a>"; }
else {
print "$Lang::tr{'newer'}"; }
print "</td>\n";
print <<END
</tr>
</table>
END
;
}

View File

@@ -0,0 +1,426 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: log.dat,v 1.6.2.22 2006/01/03 12:47:17 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";
use POSIX();
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::table2colour} );
undef (@dummy);
my %cgiparams=();
my %logsettings=();
my $errormessage = '';
my @shortmonths = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
'Sep', 'Oct', 'Nov', 'Dec' );
my @longmonths = ( $Lang::tr{'january'}, $Lang::tr{'february'}, $Lang::tr{'march'},
$Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july'}, $Lang::tr{'august'},
$Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'},
$Lang::tr{'december'} );
my @now = localtime();
my $dow = $now[6];
my $doy = $now[7];
my $tdoy = $now[7];
my $year = $now[5]+1900;
$cgiparams{'DAY'} = $now[3];
$cgiparams{'MONTH'} = $now[4];
$cgiparams{'ACTION'} = '';
$cgiparams{'SECTION'} = 'ipcop';
my %sections = (
'ipcop' => '(ipcop)',
'red' => '(red.*|kernel: usb.*|pppd\[.*\]|chat\[.*\]|pppoe\[.*\]|pptp\[.*\]|pppoa\[.*\]|pppoa3\[.*\]|pppoeci\[.*\]|ipppd|ipppd\[.*\]|kernel: ippp\d|kernel: isdn.*|ibod\[.*\]|kernel: eth.*|dhcpcd\[.*\]|modem_run\[.*\])',
'dns' => '(dnsmasq\[.*\])',
'dhcp' => '(dhcpd)',
'cron' => '(fcron\[.*\])',
'ntp' => '(ntpd(?:ate)?\[.*\])',
'ssh' => '(sshd(?:\(.*\))?\[.*\])',
'auth' => '(\w+\(pam_unix\)\[.*\])',
'kernel' => '(kernel)',
'ipsec' => '(ipsec_[\w_]+|pluto\[.*\])',
'snort' => '(snort)',
'installpackage' => '(installpackage\[.*\])'
);
# Translations for the %sections array.
my %trsections = (
'ipcop' => 'IPCop',
'red' => 'RED',
'dns' => 'DNS',
'dhcp' => "$Lang::tr{'dhcp server'}",
'cron' => 'Cron',
'ntp' => 'NTP',
'ssh' => 'SSH',
'auth' => "$Lang::tr{'loginlogout'}",
'kernel' => "$Lang::tr{'kernel'}",
'ipsec' => 'IPSec',
'snort' => 'Snort',
'installpackage' => "$Lang::tr{'update transcript'}"
);
&Header::getcgihash(\%cgiparams);
$logsettings{'LOGVIEW_REVERSE'} = 'off';
&General::readhash("${General::swroot}/logging/settings", \%logsettings);
${Header::viewsize} = defined ($logsettings{'LOGVIEW_VIEWSIZE'}) ? $logsettings{'LOGVIEW_VIEWSIZE'} : 150;
my $start = ($logsettings{'LOGVIEW_REVERSE'} eq 'on') ? 0x7FFFF000 : 0; #index of firts line number to display
if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'})
{
my @temp = split(',',$ENV{'QUERY_STRING'});
$start = $temp[0];
$cgiparams{'MONTH'} = $temp[1];
$cgiparams{'DAY'} = $temp[2];
$cgiparams{'SECTION'} = $temp[3];
}
if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) ||
!($cgiparams{'DAY'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)$/))
{
$cgiparams{'DAY'} = $now[3];
$cgiparams{'MONTH'} = $now[4];
}
elsif($cgiparams{'ACTION'} eq '>>')
{
my @temp_then=();
my @temp_now = localtime(time);
$temp_now[4] = $cgiparams{'MONTH'};
$temp_now[3] = $cgiparams{'DAY'};
if ($cgiparams{'DAY'}) {
@temp_then = localtime(POSIX::mktime(@temp_now) + 86400);
## Retrieve the same time on the next day +
## 86400 seconds in a day
} else {
$temp_now[3] = 1;
$temp_now[4] = ($temp_now[4]+1) %12;
@temp_then = localtime(POSIX::mktime(@temp_now) );
$temp_then[3] = 0;
}
$cgiparams{'MONTH'} = $temp_then[4];
$cgiparams{'DAY'} = $temp_then[3];
}
elsif($cgiparams{'ACTION'} eq '<<')
{
my @temp_then=();
my @temp_now = localtime(time);
$temp_now[4] = $cgiparams{'MONTH'};
$temp_now[3] = $cgiparams{'DAY'};
if ($cgiparams{'DAY'}) {
@temp_then = localtime(POSIX::mktime(@temp_now) - 86400);
## Retrieve the same time on the next day -
## 86400 seconds in a day
} else {
$temp_now[3] = 1;
$temp_now[4] = ($temp_now[4]-1) %12;
@temp_then = localtime(POSIX::mktime(@temp_now) );
$temp_then[3] = 0;
}
$cgiparams{'MONTH'} = $temp_then[4];
$cgiparams{'DAY'} = $temp_then[3];
}
# Find in which file.gz is the log. Can be calculated because WEEKLY ROTATING of access.log
my $gzindex;
my $date = $cgiparams{'DAY'} == 0 ? '' : $cgiparams{'DAY'} <= 9 ? "0$cgiparams{'DAY'}" : "$cgiparams{'DAY'}";
{
my $xday;
# Calculate time. If future date, calculate for past year !!!
if (( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) ||
( $cgiparams{'MONTH'} > $now[4] ) ) {
$xday = POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 );
$date = "$longmonths[$cgiparams{'MONTH'}] $date, ". int($year-1);
} else {
$xday = POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 );
$date = "$longmonths[$cgiparams{'MONTH'}] $date, $year";
}
# calculate end of active week (saturday 23H59)
my @then = ();
@then = localtime(time());
my $sunday = POSIX::mktime( 0, 0, 0, @then[3], @then[4], @then[5]);
$sunday += (6-$then[6]) * 86400;
# Convert delta in second to full weeks
$gzindex = int (($sunday-$xday)/604800 );
}
my $monthstr = $shortmonths[$cgiparams{'MONTH'}];
my $daystr = $cgiparams{'DAY'} == 0 ? '..' : $cgiparams{'DAY'} <= 9 ? " $cgiparams{'DAY'}" : "$cgiparams{'DAY'}";
my $section = $sections{$cgiparams{'SECTION'}};
my $lines = 0;
my @log=();
my $loop = 1;
my $filestr = 0;
my $lastdatetime; # for debug
my $search_for_end = 0;
while ($gzindex >=0 && $loop) {
# calculate file name
if ($gzindex == 0) {
$filestr = "/var/log/messages";
} else {
$filestr = "/var/log/messages.$gzindex";
$filestr = "$filestr.gz" if -f "$filestr.gz";
}
# now read file if existing
if (open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr))) {
#&General::log("reading $filestr");
READ:while (<FILE>) {
my $line = $_;
if ($line =~ /^${monthstr} ${daystr} ..:..:.. [\w\-]+ ${section}: (.*)/) {
# when standart viewing, just keep in memory the correct slice
# it starts a '$start' and size is $viewport
# If export, then keep all lines...
if ($cgiparams{'ACTION'} eq $Lang::tr{'export'}){
$log[$lines++] = "$line";
} else {
if ($lines++ < ($start + $Header::viewsize)) {
push(@log,"$line");
if (@log > $Header::viewsize) {
shift (@log);
}
#} else { dont do this optimisation, need to count lines !
# $datetime = $maxtime; # we have read viewsize lines, stop main loop
# last READ; # exit read file
}
}
$search_for_end = 1; # we find the start of slice, can look for end now
} else {
if ($search_for_end == 1) {
#finish read files when date is over (test month equality only)
$line =~ /^(...) (..) ..:..:..*$/;
$loop = 0 if ( ($1 ne $monthstr) || ( ($daystr ne '..') && ($daystr ne $2) ) );
}
}
}
close (FILE);
}
$gzindex--; # will try next gz file eg 40,39,38,.... because it may have holes when ipcop stopped
# for a long time
}# while
# $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}";
if ($cgiparams{'ACTION'} eq $Lang::tr{'export'})
{
print "Content-type: text/plain\n\n";
print "IPCop diagnostics\r\n";
print "$Lang::tr{'section'}: $cgiparams{'SECTION'}\n";
print "$Lang::tr{'date'}: $date\r\n\r\n";
if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @log = reverse @log; }
foreach $_ (@log)
{
/^... (..) (..:..:..) [\w\-]+ ${section}: (.*)$/;
my $day = $1;
$day =~ tr / /0/;
my $time = $cgiparams{'DAY'} ? "$2" : "$day/$2" ;
print "$time $3 $4\r\n";
}
exit 0;
}
&Header::showhttpheaders();
&Header::openpage($Lang::tr{'firewall log'}, 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{'settings'}:");
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<table width='100%'>
<tr>
<td width='10%' class='base'>$Lang::tr{'section'}:&nbsp;</td>
<td width='20%'>
<select name='SECTION'>
END
;
foreach $section (keys %sections) {
print "\t<option ";
if ($section eq $cgiparams{'SECTION'}) {
print "selected='selected' "; }
print "value='$section'>$trsections{$section}</option>\n";
}
print <<END
</select>
</td>
<td width='10%' class='base' align='right'>$Lang::tr{'month'}:&nbsp;</td>
<td width='10%'>
<select name='MONTH'>
END
;
for (my $month = 0; $month < 12; $month++)
{
print "\t<option ";
if ($month == $cgiparams{'MONTH'}) {
print "selected='selected' "; }
print "value='$month'>$longmonths[$month]</option>\n";
}
print <<END
</select>
</td>
<td width='10%' class='base' align='right'>&nbsp;$Lang::tr{'day'}:&nbsp;</td>
<td width='40%'>
<select name='DAY'>
END
;
print "<option value='0'>$Lang::tr{'all'}</option>\n";
for (my $day = 1; $day <= 31; $day++)
{
print "\t<option ";
if ($day == $cgiparams{'DAY'}) {
print "selected='selected' "; }
print "value='$day'>$day</option>\n";
}
print <<END
</select>
</td>
<td width='5%' align='center'><input type='submit' name='ACTION' title='$Lang::tr{'day before'}' value='&lt;&lt;' /></td>
<td width='5%' align='center'><input type='submit' name='ACTION' title='$Lang::tr{'day after'}' value='&gt;&gt;' /></td>
<td width='10%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'update'}' /></td>
<td width='10%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'export'}' /></td>
</tr>
</table>
</form>
END
;
&Header::closebox();
&Header::openbox('100%', 'left', $Lang::tr{'log'});
print "<p><b>$Lang::tr{'total hits for log section'} $cgiparams{'SECTION'} $date: $lines</b></p>";
$start = $lines - ${Header::viewsize} if ($start >= $lines - ${Header::viewsize});
$start = 0 if ($start < 0);
my $prev;
if ($start == 0) {
$prev = -1;
} else {
$prev = $start - ${Header::viewsize};
$prev = 0 if ( $prev < 0);
}
my $next;
if ($start == $lines - ${Header::viewsize}) {
$next = -1;
} else {
$next = $start + ${Header::viewsize};
$next = $lines - ${Header::viewsize} if ($next >= $lines - ${Header::viewsize});
}
if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @log = reverse @log; }
if ($lines != 0) { &oldernewer(); }
print <<END
<table width='100%'>
<tr>
<td width='10%' align='center' class='boldbase'><b>$Lang::tr{'time'}</b></td>
<td width='15%' align='center' class='boldbase'><b>$Lang::tr{'section'}</b></td>
<td width='75%'>&nbsp;</td>
</tr>
END
;
$lines = 0;
#print '<tt>';
foreach $_ (@log)
{
/^... (..) (..:..:..) [\w\-]+ ${section}: (.*)$/;
my $day = $1;
$day =~ tr / /0/;
my $time = $cgiparams{'DAY'} ? "$2" : "$day/$2" ;
my $sec = $3;
my $data = $4;
# correct the cut position, just when section=RED
if (($cgiparams{'SECTION'} eq 'red' ) && ($sec =~ /(kernel:)(.*)/)) {
$sec = 'kernel';
$data = $2.': '.$data;
}
my $d = substr ($data,0,80);
while (length($data)>80){ #very basic breaking of lines...
$data = substr ($data,80); #permit correct display in table cell
$d .= ' ' . substr ($data,0,80);
}
if ($lines % 2) {
print "<tr bgcolor='${Header::table1colour}'>"; }
else {
print "<tr bgcolor='${Header::table2colour}'>"; }
print "<td>$time<td>$sec<td>" .&Header::cleanhtml ("$d", 'y') . "</td></tr>\n";
$lines++;
}
#print '</tt>';
print "</table>";
&oldernewer();
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
sub oldernewer
{
print <<END
<table width='100%'>
<tr>
END
;
print "<td align='center' width='50%'>";
if ($prev != -1) {
print "<a href='/cgi-bin/logs.cgi/log.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{'SECTION'}'>$Lang::tr{'older'}</a>"; }
else {
print "$Lang::tr{'older'}"; }
print "</td>\n";
print "<td align='center' width='50%'>";
if ($next >= 0) {
print "<a href='/cgi-bin/logs.cgi/log.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{'SECTION'}'>$Lang::tr{'newer'}</a>"; }
else {
print "$Lang::tr{'newer'}"; }
print "</td>\n";
print <<END
</tr>
</table>
END
;
}

View File

@@ -0,0 +1,494 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: proxylog.dat,v 1.4.2.25 2005/07/07 17:32:24 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";
use POSIX();
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::table2colour} );
undef (@dummy);
my %cgiparams=();
my %logsettings=();
my %ips=();
my %selected=();
my %checked=();
my @log=();
my $errormessage = '';
my @shortmonths = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
'Sep', 'Oct', 'Nov', 'Dec' );
my @longmonths = ( $Lang::tr{'january'}, $Lang::tr{'february'}, $Lang::tr{'march'},
$Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july'}, $Lang::tr{'august'},
$Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'},
$Lang::tr{'december'} );
my @now = localtime();
my $dow = $now[6]; # day of week
my $doy = $now[7]; # day of year (0..364)
my $tdoy = $now[7];
my $year = $now[5]+1900;
$cgiparams{'DAY'} = $now[3];
$cgiparams{'MONTH'} = $now[4];
$cgiparams{'SOURCE_IP'} = 'ALL';
$cgiparams{'FILTER'} = "[.](gif|jpeg|jpg|png|css|js)\$";
$cgiparams{'ENABLE_FILTER'} = 'off';
$cgiparams{'ACTION'} = '';
&Header::getcgihash(\%cgiparams);
$logsettings{'LOGVIEW_REVERSE'} = 'off';
&General::readhash("${General::swroot}/logging/settings", \%logsettings);
${Header::viewsize} = defined ($logsettings{'LOGVIEW_VIEWSIZE'}) ? $logsettings{'LOGVIEW_VIEWSIZE'} : 150;
if ($cgiparams{'ACTION'} eq '')
{
$cgiparams{'ENABLE_FILTER'} = 'on';
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'restore defaults'})
{
$cgiparams{'FILTER'} = "[.](gif|jpeg|jpg|png|css|js)\$";
$cgiparams{'ENABLE_FILTER'} = 'off';
}
{
my %save=();
$save{'FILTER'} = $cgiparams{'FILTER'};
$save{'ENABLE_FILTER'} = $cgiparams{'ENABLE_FILTER'};
&General::writehash("${General::swroot}/proxy/viewersettings", \%save);
&General::readhash("${General::swroot}/proxy/viewersettings", \%save);
}
my $start = ($logsettings{'LOGVIEW_REVERSE'} eq 'on') ? 0x7FFFF000 : 0; #index of first line number to display
if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'})
{
my @temp = split(',',$ENV{'QUERY_STRING'});
$start = $temp[0];
$cgiparams{'MONTH'} = $temp[1];
$cgiparams{'DAY'} = $temp[2];
$cgiparams{'SOURCE_IP'} = $temp[3];
}
if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) ||
!($cgiparams{'DAY'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)$/))
{
$cgiparams{'DAY'} = $now[3];
$cgiparams{'MONTH'} = $now[4];
}
elsif($cgiparams{'ACTION'} eq '>>')
{
my @temp_then=();
my @temp_now = localtime(time);
$temp_now[4] = $cgiparams{'MONTH'};
$temp_now[3] = $cgiparams{'DAY'};
if ($cgiparams{'DAY'}) {
@temp_then = localtime(POSIX::mktime(@temp_now) + 86400);
## Retrieve the same time on the next day +
## 86400 seconds in a day
$cgiparams{'MONTH'} = $temp_then[4];
$cgiparams{'DAY'} = $temp_then[3];
} else {
$temp_now[3] = 1;
$temp_now[4] = ($temp_now[4]+1) %12;
@temp_then = localtime(POSIX::mktime(@temp_now) );
@temp_then[3] = 0;
}
$cgiparams{'MONTH'} = $temp_then[4];
$cgiparams{'DAY'} = $temp_then[3];
}
elsif($cgiparams{'ACTION'} eq '<<')
{
my @temp_then=();
my @temp_now = localtime(time);
$temp_now[4] = $cgiparams{'MONTH'};
$temp_now[3] = $cgiparams{'DAY'};
if ($cgiparams{'DAY'}) {
@temp_then = localtime(POSIX::mktime(@temp_now) - 86400);
## Retrieve the same time on the next day -
## 86400 seconds in a day
$cgiparams{'MONTH'} = $temp_then[4];
$cgiparams{'DAY'} = $temp_then[3];
} else {
$temp_now[3] = 1;
$temp_now[4] = ($temp_now[4]-1) %12;
@temp_then = localtime(POSIX::mktime(@temp_now) );
@temp_then[3] = 0;
}
$cgiparams{'MONTH'} = $temp_then[4];
$cgiparams{'DAY'} = $temp_then[3];
}
# Find in which file.gz is the log. Can be calculated because WEEKLY ROTATING of *.log
my $gzindex;
my $daystr = $cgiparams{'DAY'} == 0 ? '' :$cgiparams{'DAY'} <= 9 ? "0$cgiparams{'DAY'}" : "$cgiparams{'DAY'}";
{
my $xday;
# Calculate time. If future date, calculate for past year !!!
if (( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) ||
( $cgiparams{'MONTH'} > $now[4] ) ) {
$xday = POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 );
$daystr = "$longmonths[$cgiparams{'MONTH'}] $daystr, ". int($year-1);
} else {
$xday = POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 );
$daystr = "$longmonths[$cgiparams{'MONTH'}] $daystr, $year";
}
# calculate end of active week (saturday 23H59)
my @then = ();
@then = localtime(time());
my $sunday = POSIX::mktime( 0, 0, 0, @then[3], @then[4], @then[5]);
$sunday += (6-$then[6]) * 86400;
# Convert delta in second to full weeks
$gzindex = int (($sunday-$xday)/604800 );
}
my $filter = $cgiparams{'ENABLE_FILTER'} eq 'on' ? $cgiparams{'FILTER'} : '';
my $sourceip = $cgiparams{'SOURCE_IP'};
my $sourceall = $cgiparams{'SOURCE_IP'} eq 'ALL' ? 1 : 0;
my $lines = 0;
my $temp = ();
my $thiscode = '$temp =~ /$filter/;';
eval($thiscode);
if ($@ ne '')
{
$errormessage = "$Lang::tr{'bad ignore filter'}.$@<P>";
$filter = '';
} else {
my $loop = 1;
my $filestr = 0;
my $lastdatetime; # for debug
while ($gzindex >=0 && $loop) {
# calculate file name
if ($gzindex == 0) {
$filestr = "/var/log/squid/access.log";
} else {
$filestr = "/var/log/squid/access.log.$gzindex";
$filestr = "$filestr.gz" if -f "$filestr.gz";
}
# now read file if existing
if (open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr))) {
#&General::log("reading $filestr");
my @temp_now = localtime(time);
$temp_now[4] = $cgiparams{'MONTH'};
$temp_now[3] = $cgiparams{'DAY'};
if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) ||
( $cgiparams{'MONTH'} > $now[4] ) ) {
$temp_now[5]--; # past year
}
$temp_now[2] = $temp_now[1] = $temp_now[0] = 0; # start at 00:00:00
$temp_now[3] = 1 if ($cgiparams{'DAY'}==0); # All days selected, start at '1'
my $mintime = POSIX::mktime(@temp_now);
my $maxtime;
if ($cgiparams{'DAY'}==0) { # full month
if ($temp_now[4]++ == 12){
$temp_now[4] = 0;
$temp_now[5]++;
};
$maxtime = POSIX::mktime(@temp_now);
} else {
$maxtime = $mintime + 86400; # full day
}
READ:while (<FILE>) {
my ($datetime,$do,$ip,$ray,$me,$far,$url,$so) = split;
$ips{$ip}++;
# for debug
#$lastdatetime = $datetime;
# collect lines between date && filter
if (( ($datetime>$mintime)&&($datetime<$maxtime)) && !($url =~ /$filter/) &&
((($ip eq $sourceip) || $sourceall)))
{
# when standart viewing, just keep in memory the correct slices
# it starts a '$start' and size is $viewport
# If export, then keep all lines...
if ($cgiparams{'ACTION'} eq $Lang::tr{'export'}){
$log[$lines++] = "$datetime $ip $url";
} else {
if ($lines++ < ($start + $Header::viewsize)) {
push(@log,"$datetime $ip $url");
if (@log > $Header::viewsize) {
shift (@log);
}
#} else { dont do this optimisation, need to count lines !
# $datetime = $maxtime; # we have read viewsize lines, stop main loop
# last READ; # exit read file
}
}
}
# finish loop when date of lines are past maxtime
$loop = ($datetime < $maxtime);
}
close (FILE);
}
$gzindex--; # will try next gz file eg 40,39,38,.... because it may have holes when ipcop stopped
# for a long time
}
#$errormessage="$errormessage$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}";
if (0) { # print last date record read
my ($SECdt, $MINdt, $HOURdt, $DAYdt, $MONTHdt, $YEARdt) = localtime($lastdatetime);
$SECdt = sprintf ("%.02d",$SECdt);
$MINdt = sprintf ("%.02d",$MINdt);
$HOURdt = sprintf ("%.02d",$HOURdt);
$DAYdt = sprintf ("%.02d",$DAYdt);
$MONTHdt = sprintf ("%.02d",$MONTHdt+1);
$YEARdt = sprintf ("%.04d",$YEARdt+1900);
&General::log ("$HOURdt:$MINdt:$SECdt, $DAYdt/$MONTHdt/$YEARdt--");
}
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'export'})
{
print "Content-type: text/plain\n\n";
print "IPCop proxy log\r\n";
print "$Lang::tr{'date'}: $daystr\r\n";
print "Source IP: $cgiparams{'SOURCE_IP'}\r\n";
if ($cgiparams{'ENABLE_FILTER'} eq 'on') {
print "Ignore filter: $cgiparams{'FILTER'}\r\n"; }
print "\r\n";
if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @log = reverse @log; }
foreach $_ (@log) {
my ($datetime,$ip,$url) = split;
my ($SECdt, $MINdt, $HOURdt, $DAYdt, $MONTHdt, $YEARdt) = localtime($datetime);
$SECdt = sprintf ("%.02d",$SECdt);
$MINdt = sprintf ("%.02d",$MINdt);
$HOURdt = sprintf ("%.02d",$HOURdt);
if ($cgiparams{'DAY'}==0) { # full month
$DAYdt = sprintf ("%.02d",$DAYdt);
print "$DAYdt/$HOURdt:$MINdt:$SECdt $ip $url\n";
} else {
print "$HOURdt:$MINdt:$SECdt $ip $url\n";
}
}
exit;
}
$selected{'SOURCE_IP'}{$cgiparams{'SOURCE_IP'}} = "selected='selected'";
$checked{'ENABLE_FILTER'}{'off'} = '';
$checked{'ENABLE_FILTER'}{'on'} = '';
$checked{'ENABLE_FILTER'}{$cgiparams{'ENABLE_FILTER'}} = "checked='checked'";
&Header::showhttpheaders();
&Header::openpage($Lang::tr{'proxy log viewer'}, 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{'settings'}:");
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<table width='100%'>
<tr>
<td width='10%' class='base'>$Lang::tr{'month'}:</td>
<td width='20%'>
<select name='MONTH'>
END
;
for (my $month = 0; $month < 12; $month++)
{
print "\t<option ";
if ($month == $cgiparams{'MONTH'}) {
print "selected='selected' "; }
print "value='$month'>$longmonths[$month]</option>\n";
}
print <<END
</select>
</td>
<td width='10%' class='base' align='right'>$Lang::tr{'day'}:&nbsp;</td>
<td width='10%'>
<select name='DAY'>
END
;
print "<option value='0'>$Lang::tr{'all'}</option>";
for (my $day = 1; $day <= 31; $day++)
{
print "\t<option ";
if ($day == $cgiparams{'DAY'}) {
print "selected='selected' "; }
print "value='$day'>$day</option>\n";
}
print <<END
</select>
</td>
<td width='5%' align='center'><input type='submit' name='ACTION' title='$Lang::tr{'day before'}' value='&lt;&lt;' /></td>
<td width='5%' align='center'><input type='submit' name='ACTION' title='$Lang::tr{'day after'}' value='&gt;&gt;' /></td>
<td width='25%' class='base'>$Lang::tr{'source ip'}:</td>
<td width='15%'>
<select name='SOURCE_IP'>
<option value='ALL' $selected{'SOURCE_IP'}{'ALL'}>$Lang::tr{'caps all'}</option>
END
;
foreach my $ip (keys %ips) {
print "<option value='$ip' $selected{'SOURCE_IP'}{$ip}>$ip</option>\n"; }
print <<END
</select>
</td>
</tr>
<tr>
<td class='base'>$Lang::tr{'ignore filter'}:</td>
<td colspan='5'><input type='text' name='FILTER' value='$cgiparams{'FILTER'}' size='40' /></td>
<td class='base'>$Lang::tr{'enable ignore filter'}:</td>
<td><input type='checkbox' name='ENABLE_FILTER' value='on' $checked{'ENABLE_FILTER'}{'on'} /></td>
</tr>
</table>
<div align='center'>
<table width='50%'>
<tr>
<td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'restore defaults'}' /></td>
<td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'update'}' /></td>
<td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'export'}' /></td>
</tr>
</table>
</div>
</form>
END
;
&Header::closebox();
&Header::openbox('100%', 'left', $Lang::tr{'log'});
$start = $lines - ${Header::viewsize} if ($start >= $lines - ${Header::viewsize});
$start = 0 if ($start < 0);
my $prev;
if ($start == 0) {
$prev = -1;
} else {
$prev = $start - ${Header::viewsize};
$prev = 0 if ( $prev < 0);
}
my $next;
if ($start == $lines - ${Header::viewsize}) {
$next = -1;
} else {
$next = $start + ${Header::viewsize};
$next = $lines - ${Header::viewsize} if ($next >= $lines - ${Header::viewsize});
}
if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @log = reverse @log; }
print "<p><b>$Lang::tr{'web hits'} $daystr: $lines</b></p>";
if ($lines != 0) { &oldernewer(); }
print <<END
<table width='100%'>
<tr>
<td width='10%' align='center' class='boldbase'><b>$Lang::tr{'time'}</b></td>
<td width='15%' align='center' class='boldbase'><b>$Lang::tr{'source ip'}</b></td>
<td width='75%' align='center' class='boldbase'><b>$Lang::tr{'website'}</b></td>
</tr>
END
;
my $ll = 0;
foreach $_ (@log)
{
if ($ll % 2) {
print "<tr bgcolor='${Header::table1colour}'>\n"; }
else {
print "<tr bgcolor='${Header::table2colour}'>\n"; }
my ($datetime,$ip,$url) = split;
my ($SECdt, $MINdt, $HOURdt, $DAYdt, $MONTHdt, $YEARdt) = localtime($datetime);
$SECdt = sprintf ("%.02d",$SECdt);
$MINdt = sprintf ("%.02d",$MINdt);
$HOURdt = sprintf ("%.02d",$HOURdt);
$url =~ /(^.{0,60})/;
my $part = $1;
unless (length($part) < 60) { $part = "${part}..."; }
$url = &Header::cleanhtml($url,"y");
$part = &Header::cleanhtml($part,"y");
if ($cgiparams{'DAY'}==0) { # full month
$DAYdt = sprintf ("%.02d/",$DAYdt);
} else {
$DAYdt='';
}
print <<END
<td align='center'>$DAYdt$HOURdt:$MINdt:$SECdt</td>
<td align='center'>$ip</td>
<td align='left'><a href='$url' title='$url' target='_new'>$part</a></td>
</tr>
END
;
$ll++;
}
print "</table>";
&oldernewer();
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
sub oldernewer
{
print <<END
<table width='100%'>
<tr>
END
;
print "<td align='center' width='50%'>";
if ($prev != -1) {
print "<a href='/cgi-bin/logs.cgi/proxylog.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{'SOURCE_IP'}'>$Lang::tr{'older'}</a>"; }
else {
print "$Lang::tr{'older'}"; }
print "</td>\n";
print "<td align='center' width='50%'>";
if ($next >= 0 ) {
print "<a href='/cgi-bin/logs.cgi/proxylog.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{'SOURCE_IP'}'>$Lang::tr{'newer'}</a>"; }
else {
print "$Lang::tr{'newer'}"; }
print "</td>\n";
print <<END
</tr>
</table>
END
;
}

View File

@@ -0,0 +1,213 @@
#!/usr/bin/perl
#
# SmoothWall CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The SmoothWall Team
#
# $Id: summary.dat,v 1.3.2.14 2005/07/10 00:48:42 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";
use POSIX();
my %cgiparams=();
my $errormessage = '';
my @longmonths = ( $Lang::tr{'january'}, $Lang::tr{'february'}, $Lang::tr{'march'},
$Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july'}, $Lang::tr{'august'},
$Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'},
$Lang::tr{'december'} );
my @now = localtime();
my $year = $now[5]+1900;
$cgiparams{'MONTH'} = '';
$cgiparams{'DAY'} = '';
$cgiparams{'ACTION'} = '';
&Header::getcgihash(\%cgiparams);
my $start = -1;
if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'}) {
my @temp = split(',',$ENV{'QUERY_STRING'});
$start = $temp[0];
$cgiparams{'MONTH'} = $temp[1];
$cgiparams{'DAY'} = $temp[2];
}
if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) ||
!($cgiparams{'DAY'} =~ /^(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)$/)) {
# Reports are generated at the end of the day, so if nothing is selected
# we need to display yesterdays (todays won't have been generated yet)
my @temp_then=();
my @temp_now = localtime(time);
$temp_now[4] = $now[4];
$temp_now[3] = $now[3];
@temp_then = localtime(POSIX::mktime(@temp_now) - 86400);
## Retrieve the same time on the previous day -
## 86400 seconds in a day
$cgiparams{'MONTH'} = $temp_then[4];
$cgiparams{'DAY'} = $temp_then[3];
}
elsif($cgiparams{'ACTION'} eq '>>') {
my @temp_then=();
my @temp_now = localtime(time);
$temp_now[4] = $cgiparams{'MONTH'};
$temp_now[3] = $cgiparams{'DAY'};
@temp_then = localtime(POSIX::mktime(@temp_now) + 86400);
## Retrieve the same time on the next day +
## 86400 seconds in a day
$cgiparams{'MONTH'} = $temp_then[4];
$cgiparams{'DAY'} = $temp_then[3];
}
elsif($cgiparams{'ACTION'} eq '<<') {
my @temp_then=();
my @temp_now = localtime(time);
$temp_now[4] = $cgiparams{'MONTH'};
$temp_now[3] = $cgiparams{'DAY'};
@temp_then = localtime(POSIX::mktime(@temp_now) - 86400);
## Retrieve the same time on the previous day -
## 86400 seconds in a day
$cgiparams{'MONTH'} = $temp_then[4];
$cgiparams{'DAY'} = $temp_then[3];
}
if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4])) {
if ( ($cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) ||
($cgiparams{'MONTH'} > $now[4]) ) {
$year = $year - 1;
}
}
my $monthnum = $cgiparams{'MONTH'} + 1;
my $monthstr = $monthnum <= 9 ? "0$monthnum" : "$monthnum";
my $longmonthstr = $longmonths[$cgiparams{'MONTH'}];
my $daystr = $cgiparams{'DAY'} <= 9 ? "0$cgiparams{'DAY'}" : "$cgiparams{'DAY'}";
my $skip=0;
my $filestr="/var/log/logwatch/$year-$monthstr-$daystr";
if (!(open (FILE,$filestr))) {
$errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}";
$skip=1;
# Note: This is in case the log does not exist for that date
}
if (! $skip && $cgiparams{'ACTION'} eq $Lang::tr{'export'}) {
print "Content-type: text/plain\n\n";
while (<FILE>) {
print "$_\r\n";
}
close (FILE);
exit 0;
}
&Header::showhttpheaders();
&Header::openpage($Lang::tr{'log summary'}, 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{'settings'}:");
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<table width='100%'>
<tr>
<td width='10%' class='base'>$Lang::tr{'month'}:</td>
<td width='25%'>
<select name='MONTH'>
END
;
for (my $month = 0; $month < 12; $month++)
{
print "\t<option ";
if ($month == $cgiparams{'MONTH'}) {
print "selected='selected' "; }
print "value='$month'>$longmonths[$month]</option>\n";
}
print <<END
</select>
</td>
<td width='10%' class='base'>$Lang::tr{'day'}:</td>
<td width='25%'>
<select name='DAY'>
END
;
for (my $day = 1; $day <= 31; $day++)
{
print "\t<option ";
if ($day == $cgiparams{'DAY'}) {
print "selected='selected' "; }
print "value='$day'>$day</option>\n";
}
print <<END
</select>
</td>
<td width='5%' align='center'><input type='submit' name='ACTION' title='$Lang::tr{'day before'}' value='&lt;&lt;' /></td>
<td width='5%' align='center'><input type='submit' name='ACTION' title='$Lang::tr{'day after'}' value='&gt;&gt;' /></td>
<td width='10%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'update'}' /></td>
<td width='10%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'export'}' /></td>
</tr>
</table>
</form>
END
;
&Header::closebox();
my $header = 0;
my @content=();
if(!$skip)
{
while (<FILE>) {
if (/^\s*--+ ([^-]+) Begin --+\s*$/) {
# New Section. open box
@content = ();
&Header::openbox('100%', 'left', $Lang::tr{"ls_\L$1"} ? $Lang::tr{"ls_\L$1"} : $1);
print "<pre>";
} elsif (/^\s*--+ ([^-]+) End --+\s*$/) {
# End of Section, kill leading and trailing blanks, print info, close
# box
while ( $content[0] =~ /^\s*$/ ) { shift @content; }
while ( $content[$#content] =~ /^\s*$/ ) { pop @content; }
foreach $_ (@content) { $_ =~ s/\s*$//; print &Header::cleanhtml($_,"y")."\n"; }
print "\n</pre>";
&Header::closebox();
} elsif (/^\s*#+ LogWatch [^#]+[)] #+\s*$/) {
# Start of logwatch header, skip it
$header = 1;
} elsif (/^\s*#+\s*$/) {
# End of logwatch header
$header = 0;
} elsif (/^\s*#+ LogWatch End #+\s*$/) {
# End of report
} elsif ($header eq 0) {
push(@content,$_);
}
}
close (FILE);
}
&Header::closebigbox();
&Header::closepage();

120
html/cgi-bin/modem.cgi Normal file
View File

@@ -0,0 +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();

222
html/cgi-bin/netstatus.cgi Normal file
View File

@@ -0,0 +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();

420
html/cgi-bin/networks.cgi Normal file
View File

@@ -0,0 +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;
}
}
}

View File

@@ -0,0 +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();

1179
html/cgi-bin/portfw.cgi Normal file

File diff suppressed because it is too large Load Diff

1205
html/cgi-bin/pppsetup.cgi Normal file

File diff suppressed because it is too large Load Diff

421
html/cgi-bin/proxy.cgi Normal file
View File

@@ -0,0 +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

View File

@@ -0,0 +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();

180
html/cgi-bin/remote.cgi Normal file
View File

@@ -0,0 +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";
}
}

586
html/cgi-bin/services.cgi Normal file
View File

@@ -0,0 +1,586 @@
#!/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: services.cgi,v 1.2.2.3 2005/04/29 23:37:07 franck78 Exp $
#
use strict;
require 'CONFIG_ROOT/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my @icmptypes = &get_icmptypes();
&Header::showhttpheaders();
my %cgiparams=();
my %selected=();
my %checked=();
my $filename = "${General::swroot}/firewall/customservices";
my $key = 0; # used for finding last sequence number used
# Darren Critchley - vars for setting up sort order
my $sort_col = '1';
my $sort_type = 'a';
my $sort_dir = 'asc';
if ($ENV{'QUERY_STRING'} ne '') {
my ($item1, $item2, $item3) = split(/\&/,$ENV{'QUERY_STRING'});
if ($item1 ne '') {
($junk, $sort_col) = split(/\=/,$item1)
}
if ($item2 ne '') {
($junk, $sort_type) = split(/\=/,$item2)
}
if ($item3 ne '') {
($junk, $sort_dir) = split(/\=/,$item3)
}
}
$cgiparams{'KEY'} = '';
$cgiparams{'PORTS'} = '';
$cgiparams{'PROTOCOL'} = '6';
$cgiparams{'NAME'} = '';
$cgiparams{'PORT_INVERT'} = 'off';
$cgiparams{'PROTOCOL_INVERT'} = 'off';
$cgiparams{'ICMP'} = 'BLANK';
&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 config file.';
flock FILE, 2;
print FILE "$key,$cgiparams{'NAME'},$cgiparams{'PORTS'},$cgiparams{'PROTOCOL'},$cgiparams{'PORT_INVERT'},$cgiparams{'PROTOCOL_INVERT'},$cgiparams{'ICMP'}\n";
close(FILE);
&General::log("$Lang::tr{'service 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 services file.';
my @current = <FILE>;
close(FILE);
my $line;
open(FILE, ">$filename") or die 'Unable to open config file.';
flock FILE, 2;
foreach $line (@current) {
chomp($line);
my @temp = split(/\,/,$line);
if ($cgiparams{'KEY'} eq $temp[0]) {
print FILE "$cgiparams{'KEY'},$cgiparams{'NAME'},$cgiparams{'PORTS'},$cgiparams{'PROTOCOL'},$cgiparams{'PORT_INVERT'},$cgiparams{'PROTOCOL_INVERT'},$cgiparams{'ICMP'}\n";
} else {
print FILE "$line\n";
}
}
close(FILE);
&General::log("$Lang::tr{'service updated'}: $cgiparams{'NAME'}");
undef %cgiparams;
}
UPD_ERROR:
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'})
{
open(FILE, "$filename") or die 'Unable to open custom services 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{'PORTS'} = $temp[2];
$cgiparams{'PROTOCOL'} = $temp[3];
$cgiparams{'PORT_INVERT'} = $temp[4];
$cgiparams{'PROTOCOL_INVERT'} = $temp[5];
$cgiparams{'ICMP'} = $temp[6];
}
}
}
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'remove'})
{
open(FILE, $filename) or die 'Unable to open custom services file.';
my @current = <FILE>;
close(FILE);
open(FILE, ">$filename") or die 'Unable to open custom services 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{'service removed'}: $temp[1]");
} else {
print FILE "$temp[0],$temp[1],$temp[2],$temp[3],$temp[4],$temp[5],$temp[6]\n";
}
}
}
close(FILE);
undef %cgiparams;
}
if ($cgiparams{'ACTION'} eq $Lang::tr{'reset'})
{
undef %cgiparams;
}
if ($cgiparams{'ACTION'} eq '')
{
$cgiparams{'KEY'} = '';
$cgiparams{'PORTS'} = '';
$cgiparams{'PROTOCOL'} = '6';
$cgiparams{'NAME'} = '';
$cgiparams{'PORT_INVERT'} = 'off';
$cgiparams{'PROTOCOL_INVERT'} = 'off';
$cgiparams{'ICMP'} = 'BLANK';
}
# Darren Critchley - Bring in the protocols file built from /etc/protocols into hash %protocol
require "${General::swroot}/firewall/protocols.pl";
# Darren Critchley - figure out which protocol is selected
$selected{'PROTOCOL'}{'tcpudp'}= '';
$selected{'PROTOCOL'}{'all'}= '';
foreach $line (keys %protocols) {
# $selected{'PROTOCOL'}{"$protocols{$line}"}= '';
$selected{'PROTOCOL'}{$line}= '';
}
$selected{'PROTOCOL'}{$cgiparams{'PROTOCOL'}} = 'SELECTED';
# Darren Critchley - figure out which icmptype is selected
$selected{'ICMP'}{$cgiparams{'ICMP'}} = 'SELECTED';
$checked{'PORT_INVERT'}{'off'} = '';
$checked{'PORT_INVERT'}{'on'} = '';
$checked{'PORT_INVERT'}{$cgiparams{'PORT_INVERT'}} = 'CHECKED';
$checked{'PROTOCOL_INVERT'}{'off'} = '';
$checked{'PROTOCOL_INVERT'}{'on'} = '';
$checked{'PROTOCOL_INVERT'}{$cgiparams{'PROTOCOL_INVERT'}} = 'CHECKED';
&Header::openpage($Lang::tr{'services 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 "$sort_col\n";
#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 service'}:");
} else {
&Header::openbox('100%', 'LEFT', "$Lang::tr{'add service'}:");
}
# Darren Critchley - Show protocols with TCP, UDP, etc at the top of the list.
print <<END
<FORM METHOD='POST'>
<DIV ALIGN='CENTER'>
<TABLE WIDTH='100%' ALIGN='CENTER'>
<TR align="center">
<TD><strong>$Lang::tr{'servicename'}</strong></TD>
<TD ALIGN='RIGHT'><strong>$Lang::tr{'invert'}</strong></TD>
<TD><strong>$Lang::tr{'ports'}</strong></TD>
<TD ALIGN='RIGHT'><strong>$Lang::tr{'invert'}</strong></TD>
<TD><strong>$Lang::tr{'protocol'}</strong></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 ALIGN='RIGHT'>
<INPUT TYPE='CHECKBOX' NAME='PORT_INVERT' $checked{'PORT_INVERT'}{'on'}>
</TD>
<TD>
<INPUT TYPE='TEXT' NAME='PORTS' VALUE='$cgiparams{'PORTS'}' SIZE='15' MAXLENGTH='11'>
</TD>
<TD ALIGN='RIGHT'>
<INPUT TYPE='CHECKBOX' NAME='PROTOCOL_INVERT' $checked{'PROTOCOL_INVERT'}{'on'}>
</TD>
<TD ALIGN='LEFT'>
<SELECT NAME='PROTOCOL'>
<OPTION VALUE='tcp' $selected{'PROTOCOL'}{'tcp'}>TCP</OPTION>
<OPTION VALUE='udp' $selected{'PROTOCOL'}{'udp'}>UDP</OPTION>
<OPTION VALUE='tcpudp' $selected{'PROTOCOL'}{'tcpudp'}>TCP & UDP</OPTION>
<OPTION VALUE='all' $selected{'PROTOCOL'}{'all'}>ALL</OPTION>
<OPTION VALUE='icmp' $selected{'PROTOCOL'}{'icmp'}>ICMP</OPTION>
<OPTION VALUE='gre' $selected{'PROTOCOL'}{'gre'}>GRE</OPTION>
END
;
foreach $line (sort keys %protocols) {
# Darren Critchley - do not have duplicates in the list
if ($protocols{$line} ne '6' && $protocols{$line} ne '17' && $protocols{$line} ne '1' && $protocols{$line} ne '47'){
# print "<OPTION VALUE='$line' $selected{'PROTOCOL'}{$protocols{$line}}>".uc($line)."</OPTION>\n";
print "<OPTION VALUE='$line' $selected{'PROTOCOL'}{$line}>".uc($line)."</OPTION>\n";
}
}
print <<END
</SELECT>
</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD><strong>$Lang::tr{'icmp type'}:</strong></TD>
<TD ALIGN='LEFT'>
<SELECT NAME='ICMP'>
<OPTION VALUE='BLANK' $selected{'ICMP'}{'BLANK'}>Valid ICMP Types</OPTION>
END
;
foreach $line (@icmptypes) {
if ($cgiparams{'ICMP'} eq $line){
print "<OPTION VALUE='$line' SELECTED>$line</OPTION>\n";
} else {
print "<OPTION VALUE='$line' >$line</OPTION>\n";
}
}
print <<END
</SELECT>
</TD>
</TR>
<TR>
END
;
if ($cgiparams{'ACTION'} eq $Lang::tr{'edit'}){
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 {
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 services'}:");
print <<END
<DIV ALIGN='CENTER'>
<TABLE WIDTH='100%' ALIGN='CENTER'>
<TR align="center">
END
;
if ($sort_dir eq 'asc' && $sort_col eq '2') {
print "<TD WIDTH='25%'><strong><a href='services.cgi?sortcol=2&srtype=a&srtdir=dsc' title='$Lang::tr{'sort descending'}'>$Lang::tr{'servicename'}</a></strong></TD>\n";
} else {
print "<TD WIDTH='25%'><strong><a href='services.cgi?sortcol=2&srtype=a&srtdir=asc' title='$Lang::tr{'sort ascending'}'>$Lang::tr{'servicename'}</a></strong></TD>\n";
}
if ($sort_dir eq 'asc' && $sort_col eq '3') {
print "<TD WIDTH='25%'><strong><a href='services.cgi?sortcol=3&srtype=n&srtdir=dsc' title='$Lang::tr{'sort descending'}'>$Lang::tr{'ports'}</a></strong></TD>\n";
} else {
print "<TD WIDTH='25%'><strong><a href='services.cgi?sortcol=3&srtype=n&srtdir=asc' title='$Lang::tr{'sort ascending'}'>$Lang::tr{'ports'}</a></strong></TD>\n";
}
if ($sort_dir eq 'asc' && $sort_col eq '4') {
print "<TD WIDTH='25%'><strong><a href='services.cgi?sortcol=4&srtype=a&srtdir=dsc' title='$Lang::tr{'sort descending'}'>$Lang::tr{'protocol'}</a></strong></TD>\n";
} else {
print "<TD WIDTH='25%'><strong><a href='services.cgi?sortcol=4&srtype=a&srtdir=asc' title='$Lang::tr{'sort ascending'}'>$Lang::tr{'protocol'}</a></strong></TD>\n";
}
print <<END
<TD WIDTH='25%'><strong>$Lang::tr{'icmp type'}</strong></TD>
<TD WIDTH='5%'>&nbsp;</TD>
<TD WIDTH='5%'>&nbsp;</TD>
</TR>
END
;
&display_custom_services();
print <<END
</TABLE>
</DIV>
END
;
&Header::closebox();
&Header::openbox('100%', 'LEFT', "$Lang::tr{'default services'}:");
print <<END
<DIV ALIGN='CENTER'>
<TABLE WIDTH='100%' ALIGN='CENTER'>
<TR align="center">
<TD><strong>$Lang::tr{'servicename'}</strong></TD>
<TD><strong>$Lang::tr{'ports'}</strong></TD>
<TD><strong>$Lang::tr{'protocol'}</strong></TD>
</TR>
END
;
&display_default_services();
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_services
{
open(FILE, "$filename") or die 'Unable to open services file.';
my @current = <FILE>;
close(FILE);
my $id = 0;
my $port_inv = '';
my $prot_inv = '';
my $port_inv_tail = '';
my $prot_inv_tail = '';
my @outarray = &General::srtarray($sort_col,$sort_type,$sort_dir,@current);
foreach $line (@outarray)
{
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";
if ($temp[4] eq 'on'){$port_inv = " <strong><font color='RED'>! (</font></strong>";$port_inv_tail = "<strong><font color='RED'>)</font></strong>";}else{$port_inv='';$port_inv_tail='';}
print "<TD ALIGN='CENTER'>" . $port_inv . &cleanport("$temp[2]") . $port_inv_tail . "</TD>\n";
if ($temp[5] eq 'on'){$prot_inv = " <strong><font color='RED'>! (</font></strong>";$prot_inv_tail = "<strong><font color='RED'>)</font></strong>";}else{$prot_inv='';$prot_inv_tail='';}
print "<TD ALIGN='CENTER'>" . $prot_inv . &cleanprotocol("$temp[3]") . $prot_inv_tail . "</TD>\n";
if ($temp[6] eq 'BLANK') {
print "<TD ALIGN='CENTER'>N/A</TD>\n";
} else {
print "<TD ALIGN='CENTER'>$temp[6]</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_services
{
my $fname = "${General::swroot}/firewall/defaultservices";
my $prev = "";
my $newline="";
open(FILE, "$fname") or die 'Unable to open default services file.';
my @current = <FILE>;
close(FILE);
my $id = 0;
foreach my $line (sort @current)
{
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'>" . &cleanprotocol("$temp[2]") . "</TD>\n";
print "</TR>\n";
$id++;
}
}
sub cleanprotocol
{
my $prtcl = $_[0];
chomp($prtcl);
if ($prtcl eq 'tcpudp') {
$prtcl = 'TCP & UDP';
} else {
$prtcl = uc($prtcl);
}
return $prtcl;
}
sub cleanport
{
my $prt = $_[0];
chomp($prt);
# Darren Critchley - Format the ports
$prt =~ s/-/ - /;
$prt =~ s/:/ - /;
return $prt;
}
# Validate Field Entries
sub validateparams
{
$erromessage='';
if ($cgiparams{'PROTOCOL'} eq 'tcp' || $cgiparams{'PROTOCOL'} eq 'udp' || $cgiparams{'PROTOCOL'} eq 'tcpudp' || $cgiparams{'PROTOCOL'} eq 'all') {
# Darren Critchley - Get rid of dashes in port ranges
$cgiparams{'PORTS'}=~ tr/-/:/;
# Darren Critchley - code to substitue wildcards
if ($cgiparams{'PORTS'} eq "*") {
$cgiparams{'PORTS'} = "1:65535";
}
if ($cgiparams{'PORTS'} =~ /^(\D)\:(\d+)$/) {
$cgiparams{'PORTS'} = "1:$2";
}
if ($cgiparams{'PORTS'} =~ /^(\d+)\:(\D)$/) {
$cgiparams{'PORTS'} = "$1:65535";
}
# Darren Critchley - watch the order here, the validportrange sets errormessage=''
$errormessage = &General::validportrange($cgiparams{'PORTS'}, 'src');
if ($errormessage) {return;}
} else {
$cgiparams{'PORTS'} = "";
}
if ($cgiparams{'PROTOCOL'} eq 'tcp') {
$cgiparams{'ICMP'} = "BLANK";
}
if($cgiparams{'PORTS'} eq '' && $cgiparams{'PORT_INVERT'} ne 'off'){
$cgiparams{'PORT_INVERT'} = 'off';
}
if ($cgiparams{'NAME'} eq '') {
$errormessage = $Lang::tr{'noservicename'};
return;
}
if ($cgiparams{'PROTOCOL'} eq 'icmp' && $cgiparams{'ICMP'} eq 'BLANK'){
$errormessage = $Lang::tr{'icmp selected but no type'};
return;
}
unless($errormessage){
$cgiparams{'NAME'}=&Header::cleanhtml($cgiparams{'NAME'});
open(FILE, $filename) or die 'Unable to open custom services 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];
}
}
unless($errormessage){
my $fname = "${General::swroot}/firewall/defaultservices";
my $prev = "";
my $newline="";
open(FILE, "$fname") or die 'Unable to open default services file.';
my @current = <FILE>;
close(FILE);
foreach my $line (sort @current)
{
my @temp = split(/\,/,$line);
if ($cgiparams{'NAME'} eq $temp[0]) {
$errormessage=$Lang::tr{'duplicate name'};
return;
}
}
}
}
}
sub get_icmptypes
{
my $fname = "${General::swroot}/firewall/icmptypes";
my $newline="";
my @newarray=();
open(FILE, "$fname") or die 'Unable to open icmp file.';
my @current = <FILE>;
close(FILE);
foreach $newline (sort @current)
{
chomp ($newline);
if (substr($newline, 0, 1) ne "#") {
push (@newarray, $newline);
}
}
return (@newarray);
}

367
html/cgi-bin/shaping.cgi Normal file
View File

@@ -0,0 +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;

253
html/cgi-bin/shutdown.cgi Normal file
View File

@@ -0,0 +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);
}

325
html/cgi-bin/status.cgi Normal file
View File

@@ -0,0 +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
;
}
}

391
html/cgi-bin/time.cgi Normal file
View File

@@ -0,0 +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();

269
html/cgi-bin/updates.cgi Normal file
View File

@@ -0,0 +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');
}

187
html/cgi-bin/upload.cgi Normal file
View File

@@ -0,0 +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();

2580
html/cgi-bin/vpnmain.cgi Normal file

File diff suppressed because it is too large Load Diff

508
html/cgi-bin/wireless.cgi Normal file
View File

@@ -0,0 +1,508 @@
#!/usr/bin/perl
#
# IPCop CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) 2003 Alan Hourihane <alanh@fairlite.demon.co.uk>
# (c) 2005 Eric Oberlander, Robert Kerr - Inline editing & DHCP leases
#
# $Id: wireless.cgi,v 1.4.2.15 2005/06/11 12:14:49 eoberlander Exp $
#
use strict;
use Time::Local;
# 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 $errormessage = '';
my $filename = "${General::swroot}/wireless/config";
my $hostsfile = "${General::swroot}/main/hosts";
our %dhcpsettings=();
our %netsettings=();
$cgiparams{'ENABLED'} = 'off';
$cgiparams{'ACTION'} = '';
$cgiparams{'VALID'} = '';
$cgiparams{'SOURCE_IP'} ='';
$cgiparams{'SOURCE_MAC'} ='';
$cgiparams{'REMARK'} ='';
&Header::getcgihash(\%cgiparams);
&General::readhash("${General::swroot}/dhcp/settings", \%dhcpsettings);
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
&Header::showhttpheaders();
open(FILE, $filename) or die 'Unable to open config file.';
my @current = <FILE>;
close(FILE);
if ($cgiparams{'ACTION'} eq 'add')
{
if ($cgiparams{'SOURCE_IP'} eq '' && $cgiparams{'SOURCE_MAC'} eq '')
{
goto ADDEXIT;
}
$cgiparams{'SOURCE_MAC'} =~ tr/-/:/;
my $key = 0;
foreach my $line (@current)
{
$key++;
my @temp = split(/\,/,$line);
if ($temp[1] ne '' && $cgiparams{'SOURCE_IP'} eq $temp[1] && $cgiparams{'EDITING'} ne $key)
{
$errormessage = $Lang::tr{'duplicate ip'};
goto ADDERROR;
}
if ($temp[2] ne '' && lc($cgiparams{'SOURCE_MAC'}) eq lc($temp[2]) && $cgiparams{'EDITING'} ne $key)
{
$errormessage = $Lang::tr{'duplicate mac'};
goto ADDERROR;
}
}
if ($cgiparams{'SOURCE_IP'} eq '')
{
$cgiparams{'SOURCE_IP'} = 'NONE';
} else {
unless(&General::validip($cgiparams{'SOURCE_IP'}))
{
$errormessage = $Lang::tr{'invalid fixed ip address'};
goto ADDERROR;
}
}
if ($cgiparams{'SOURCE_MAC'} eq '')
{
$cgiparams{'SOURCE_MAC'} = 'NONE';
} else {
unless(&General::validmac($cgiparams{'SOURCE_MAC'}))
{
$errormessage = $Lang::tr{'invalid fixed mac address'};
}
}
ADDERROR:
if ($errormessage)
{
$cgiparams{'SOURCE_MAC'} = '' if $cgiparams{'SOURCE_MAC'} eq 'NONE';
$cgiparams{'SOURCE_IP'} = '' if $cgiparams{'SOURCE_IP'} eq 'NONE';
} else {
if ($cgiparams{'EDITING'} eq 'no') {
open(FILE,">>$filename") or die 'Unable to open config file.';
flock FILE, 2;
print FILE "$key,$cgiparams{'SOURCE_IP'},$cgiparams{'SOURCE_MAC'},$cgiparams{'ENABLED'},$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 "$id,$cgiparams{'SOURCE_IP'},$cgiparams{'SOURCE_MAC'},$cgiparams{'ENABLED'},$cgiparams{'REMARK'}\n";
} else { print FILE "$line"; }
}
}
close(FILE);
undef %cgiparams;
&General::log($Lang::tr{'wireless config added'});
system('/usr/local/bin/restartwireless');
}
ADDEXIT:
}
if ($cgiparams{'ACTION'} eq 'edit')
{
my $id = 0;
foreach my $line (@current)
{
$id++;
if ($cgiparams{'ID'} eq $id)
{
chomp($line);
my @temp = split(/\,/,$line);
$cgiparams{'SOURCE_IP'} = $temp[1];
$cgiparams{'SOURCE_MAC'} = $temp[2];
$cgiparams{'ENABLED'} = $temp[3];
$cgiparams{'REMARK'} = $temp[4];
$cgiparams{'SOURCE_IP'} = '' if $cgiparams{'SOURCE_IP'} eq 'NONE';
$cgiparams{'SOURCE_MAC'} = '' if $cgiparams{'SOURCE_MAC'} eq 'NONE';
}
}
&General::log($Lang::tr{'wireless config changed'});
system('/usr/local/bin/restartwireless');
}
if ($cgiparams{'ACTION'} eq 'remove' || $cgiparams{'ACTION'} eq 'toggle')
{
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"; }
elsif ($cgiparams{'ACTION'} eq 'toggle')
{
chomp($line);
my @temp = split(/\,/,$line);
print FILE "$temp[0],$temp[1],$temp[2],$cgiparams{'ENABLE'},$temp[4]\n";
}
}
close(FILE);
&General::log($Lang::tr{'wireless config changed'});
system('/usr/local/bin/restartwireless');
}
$checked{'ENABLED'}{'off'} = '';
$checked{'ENABLED'}{'on'} = '';
$checked{'ENABLED'}{$cgiparams{'ENABLED'}} = "checked='checked'";
&Header::openpage($Lang::tr{'wireless 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 'edit') {
&Header::openbox('100%', 'left', "$Lang::tr{'edit device'}");
$buttontext = $Lang::tr{'update'};
} else {
&Header::openbox('100%', 'left', "$Lang::tr{'add device'}");
}
print <<END
<table width='100%'>
<tr>
<td width='25%' class='base'>$Lang::tr{'source ip'}:&nbsp;</td>
<td width='25%' ><input type='text' name='SOURCE_IP' value='$cgiparams{'SOURCE_IP'}' size='25' /></td>
<td width='25%' class='base' align='right'>$Lang::tr{'enabled'}&nbsp;</td>
<td width='25%'><input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td>
</tr>
<tr>
<td width='25%' class='base'>$Lang::tr{'source'} $Lang::tr{'mac address'}:&nbsp;</td>
<td colspan='3'><input type='text' name='SOURCE_MAC' value='$cgiparams{'SOURCE_MAC'}' size='25' /></td>
</tr>
<tr>
<td width='25%' class='base'>$Lang::tr{'remark'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
<td colspan='3'><input type='text' name='REMARK' value='$cgiparams{'REMARK'}' size='40' /></td>
</tr>
</table>
<hr />
<table width='100%'>
<tr>
<td class='base' valign='top'><img src='/blob.gif' alt='*' /></td>
<td width='55%' class='base'>$Lang::tr{'this field may be blank'}</td>
<td width='40%' align='center'>
<input type='hidden' name='ACTION' value='add' />
<input type='submit' name='SUBMIT' value='$buttontext' />
</td>
<td width='5%' align='right'>
<a href='${General::adminmanualurl}/section-firewall.html#section-blue-access' target='_blank'>
<img src='/images/web-support.png' alt='$Lang::tr{'online help en'}' title='$Lang::tr{'online help en'}' /></a></td>
</tr>
</table>
END
;
if ($cgiparams{'ACTION'} eq '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{'devices on blue'}");
print <<END
<div align='center'>
END
;
open (FILE, "$filename");
my @current = <FILE>;
close (FILE);
print <<END
<table width='100%'>
<tr>
<td align='center' width='20%'><b>$Lang::tr{'hostname'}</b></td>
<td align='center' width='20%'><b>$Lang::tr{'source ip'}</b></td>
<td align='center' width='20%'><b>$Lang::tr{'mac address'}</b></td>
<td align='center' width='35%'><b>$Lang::tr{'remark'}</b></td>
<td align='center' colspan='3'><b>$Lang::tr{'action'}</b></td>
</tr>
END
;
my $id = 0;
open (HOSTFILE, "$hostsfile");
my @curhosts = <HOSTFILE>;
close (HOSTFILE);
my $connstate = &Header::connectionstatus();
my @arp = `/sbin/arp -n`;
shift @arp;
foreach my $line (@current)
{
$id++;
chomp($line);
my $gif = "";
my $gdesc = "";
my $hname = "";
my $toggle = "";
my @temp = split(/\,/,$line);
my $wirelessid = $temp[0];
my $sourceip = $temp[1];
my $sourcemac = $temp[2];
if ( $sourceip eq 'NONE' ) {
foreach my $aline ( @arp )
{
chomp($aline);
my @atemp = split( m{\s+}, $aline );
my $aipaddr = $atemp[0];
my $amacaddr = lc( $atemp[2] );
if ( $amacaddr eq $sourcemac ) {
$sourceip = $aipaddr;
last;
}
}
}
# SourceIP could now have been set by the ARP probe.
if ( $sourceip ne 'NONE' ) {
foreach my $hline (@curhosts)
{
chomp($hline);
my @htemp = split(/\,/,$hline);
my $hkey = $htemp[0];
my $hipaddr = $htemp[1];
my $hostname = $htemp[2];
my $domainname = $htemp[3];
if ($sourceip eq $hipaddr) {
$hname = "$hostname.$domainname";
last;
}
}
if ( $hname eq "" ) {
my ($aliases, $addrtype, $length, @addrs);
($hname, $aliases, $addrtype, $length, @addrs) =
gethostbyaddr(pack("C4", split(/\./, $sourceip)), 2);
}
}
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'};}
my $remark = &Header::cleanhtml($temp[4]);
if ($cgiparams{'ACTION'} eq '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";
}
print "<td align='center'>$hname</td>\n";
print "<td align='center'>$sourceip</td>\n";
print "<td align='center'>$sourcemac</td>\n";
print "<td align='center'>$remark</td>\n";
print<<END
<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' title='$gdesc' />
<input type='hidden' name='ACTION' value='toggle'}' />
<input type='hidden' name='ID' value='$id' />
<input type='hidden' name='ENABLE' value='$toggle' />
</form>
</td>
<td align='center'>
<form method='post' name='frmb$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='edit' />
<input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
<input type='hidden' name='ID' value='$id' />
</form>
</td>
<td align='center'>
<form method='post' name='frmc$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='remove' />
<input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' alt='$Lang::tr{'remove'}' title='$Lang::tr{'remove'}' />
<input type='hidden' name='ID' value='$id' />
</form>
</td>
END
;
print "</tr>\n";
}
print "</table>\n";
print "</div>\n";
&Header::closebox();
if ( $dhcpsettings{"ENABLE_BLUE"} eq 'on') {
&printblueleases;
}
&Header::closebigbox();
&Header::closepage();
sub printblueleases
{
our %entries = ();
sub blueleasesort {
# Sort by IP address
my $qs ='IPADDR';
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]);
}
&Header::openbox('100%', 'left', "$Lang::tr{'current dhcp leases on blue'}");
print <<END
<table width='100%'>
<tr>
<td width='25%' align='center'><b>$Lang::tr{'ip address'}</b></td>
<td width='25%' align='center'><b>$Lang::tr{'mac address'}</b></td>
<td width='20%' align='center'><b>$Lang::tr{'hostname'}</b></td>
<td width='30%' align='center'><b>$Lang::tr{'lease expires'} (local time d/m/y)</b></td>
</tr>
END
;
my ($ip, $endtime, $ether, $hostname, @record, $record);
open(LEASES,"/var/state/dhcp/dhcpd.leases") or die "Can't open dhcpd.leases";
while (my $line = <LEASES>) {
next if( $line =~ /^\s*#/ );
chomp($line);
my @temp = split (' ', $line);
if ($line =~ /^\s*lease/) {
$ip = $temp[1];
# All fields are not necessarily read. Clear everything
$endtime = 0;
$ether = "";
$hostname = "";
} elsif ($line =~ /^\s*ends never;/) {
$endtime = 'never';
} elsif ($line =~ /^\s*ends/) {
$line =~ /(\d+)\/(\d+)\/(\d+) (\d+):(\d+):(\d+)/;
$endtime = timegm($6, $5, $4, $3, $2 - 1, $1 - 1900);
} elsif ($line =~ /^\s*hardware ethernet/) {
$ether = $temp[2];
$ether =~ s/;//g;
} elsif ($line =~ /^\s*client-hostname/) {
shift (@temp);
$hostname = join (' ',@temp);
$hostname =~ s/;//g;
$hostname =~ s/\"//g;
} elsif ($line eq "}") {
# Select records in Blue subnet
if ( &General::IpInSubnet ( $ip,
$netsettings{"BLUE_NETADDRESS"},
$netsettings{"BLUE_NETMASK"} ) ) {
@record = ('IPADDR',$ip,'ENDTIME',$endtime,'ETHER',$ether,'HOSTNAME',$hostname);
$record = {}; # create a reference to empty hash
%{$record} = @record; # populate that hash with @record
$entries{$record->{'IPADDR'}} = $record; # add this to a hash of hashes
}
}
}
close(LEASES);
my $id = 0;
foreach my $key (sort blueleasesort keys %entries) {
my $hostname = &Header::cleanhtml($entries{$key}->{HOSTNAME},"y");
if ($id % 2) {
print "<tr bgcolor='$Header::table2colour'>";
} else {
print "<tr bgcolor='$Header::table1colour'>";
}
print <<END
<td align='center'>$entries{$key}->{IPADDR}</td>
<td align='center'>$entries{$key}->{ETHER}</td>
<td align='center'>&nbsp;$hostname </td>
<td align='center'>
END
;
if ($entries{$key}->{ENDTIME} eq 'never') {
print "$Lang::tr{'no time limit'}";
} else {
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $dst);
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $dst) = localtime ($entries{$key}->{ENDTIME});
my $enddate = sprintf ("%02d/%02d/%d %02d:%02d:%02d",$mday,$mon+1,$year+1900,$hour,$min,$sec);
if ($entries{$key}->{ENDTIME} < time() ){
print "<strike>$enddate</strike>";
} else {
print "$enddate";
}
}
if ( $hostname eq '' ) {
$hostname = $Lang::tr{'device'};
}
print <<END
<td align='center'>
<form method='post' name='frmd$id' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='add' />
<input type='hidden' name='SOURCE_IP' value='' />
<input type='hidden' name='SOURCE_MAC' value='$entries{$key}->{ETHER}' />
<input type='hidden' name='REMARK' value='$hostname $Lang::tr{'added from dhcp lease list'}' />
<input type='hidden' name='ENABLED' value='on' />
<input type='hidden' name='EDITING' value='no' />
<input type='image' name='$Lang::tr{'add device'}' src='/images/addblue.gif' alt='$Lang::tr{'add device'}' title='$Lang::tr{'add device'}' />
</form>
</td></tr>
END
;
$id++;
}
print "</table>";
&Header::closebox();
}

363
html/cgi-bin/xtaccess.cgi Normal file
View File

@@ -0,0 +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();

6
html/html/CVS/Entries Normal file
View File

@@ -0,0 +1,6 @@
/blob.gif/1.3/Thu Dec 11 11:06:41 2003/-kb/TIPCOP_v1_4_0
/favicon.ico/1.2/Thu Dec 11 11:06:41 2003/-kb/TIPCOP_v1_4_0
/index.cgi/1.4/Thu Dec 11 11:06:41 2003//TIPCOP_v1_4_0
/ipcop_big.gif/1.4/Thu Dec 11 11:06:41 2003/-kb/TIPCOP_v1_4_0
D/images////
D/include////

1
html/html/CVS/Repository Normal file
View File

@@ -0,0 +1 @@
ipcop/html/html

1
html/html/CVS/Root Normal file
View File

@@ -0,0 +1 @@
:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ipcop

1
html/html/CVS/Tag Normal file
View File

@@ -0,0 +1 @@
TIPCOP_v1_4_0

BIN
html/html/blob.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 B

BIN
html/html/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1,25 @@
/add.gif/1.4/Mon Mar 1 09:00:30 2004/-kb/TIPCOP_v1_4_0
/addblue.gif/1.1.2.1/Sat May 21 08:07:47 2005/-kb/TIPCOP_v1_4_0
/bounceback.png/1.2/Thu Dec 11 11:06:41 2003/-kb/TIPCOP_v1_4_0
/boxbottom1.png/1.2/Thu Dec 11 11:06:41 2003/-kb/TIPCOP_v1_4_0
/boxbottom2.png/1.2/Thu Dec 11 11:06:41 2003/-kb/TIPCOP_v1_4_0
/boxbottom3.png/1.2/Thu Dec 11 11:06:41 2003/-kb/TIPCOP_v1_4_0
/boxleft.png/1.2/Thu Dec 11 11:06:41 2003/-kb/TIPCOP_v1_4_0
/boxright.png/1.2/Thu Dec 11 11:06:41 2003/-kb/TIPCOP_v1_4_0
/boxtop1.png/1.2/Thu Dec 11 11:06:41 2003/-kb/TIPCOP_v1_4_0
/boxtop2.png/1.2/Thu Dec 11 11:06:41 2003/-kb/TIPCOP_v1_4_0
/boxtop3.png/1.2/Thu Dec 11 11:06:41 2003/-kb/TIPCOP_v1_4_0
/clock.gif/1.2/Thu Dec 11 11:06:41 2003/-kb/TIPCOP_v1_4_0
/delete.gif/1.3/Mon Feb 23 08:47:53 2004/-kb/TIPCOP_v1_4_0
/download.png/1.2/Thu Dec 11 11:06:41 2003/-kb/TIPCOP_v1_4_0
/edit.gif/1.4/Mon Mar 1 09:00:30 2004/-kb/TIPCOP_v1_4_0
/floppy.gif/1.4/Mon Mar 1 09:00:30 2004/-kb/TIPCOP_v1_4_0
/forward.gif/1.2.2.1/Sat Dec 18 17:25:09 2004/-kb/TIPCOP_v1_4_0
/header.png/1.2/Thu Dec 11 11:06:41 2003/-kb/TIPCOP_v1_4_0
/info.gif/1.3/Sun Feb 29 12:55:39 2004/-kb/TIPCOP_v1_4_0
/null.gif/1.3/Thu Dec 11 11:06:41 2003/-kb/TIPCOP_v1_4_0
/off.gif/1.4/Sat Feb 28 13:29:28 2004/-kb/TIPCOP_v1_4_0
/on.gif/1.4/Sat Feb 28 13:29:28 2004/-kb/TIPCOP_v1_4_0
/reload.gif/1.3/Mon Mar 1 09:00:30 2004/-kb/TIPCOP_v1_4_0
/web-support.png/1.1.2.1/Sat Mar 26 07:11:11 2005/-kb/TIPCOP_v1_4_0
D

View File

@@ -0,0 +1 @@
ipcop/html/html/images

View File

@@ -0,0 +1 @@
:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ipcop

1
html/html/images/CVS/Tag Normal file
View File

@@ -0,0 +1 @@
TIPCOP_v1_4_0

BIN
html/html/images/add.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
html/html/images/clock.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 817 B

BIN
html/html/images/delete.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
html/html/images/edit.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

BIN
html/html/images/floppy.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

BIN
html/html/images/header.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
html/html/images/info.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

BIN
html/html/images/null.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

BIN
html/html/images/off.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

BIN
html/html/images/on.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

BIN
html/html/images/reload.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,3 @@
/domMenu.js/1.2.2.1/Thu Jul 1 18:59:12 2004//TIPCOP_v1_4_0
/ipcop.css/1.5.2.1/Sat Apr 17 17:10:24 2004//TIPCOP_v1_4_0
D

View File

@@ -0,0 +1 @@
ipcop/html/html/include

View File

@@ -0,0 +1 @@
:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ipcop

View File

@@ -0,0 +1 @@
TIPCOP_v1_4_0

1167
html/html/include/domMenu.js Normal file

File diff suppressed because it is too large Load Diff

122
html/html/include/ipcop.css Normal file
View File

@@ -0,0 +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;
}

8
html/html/index.cgi Normal file
View File

@@ -0,0 +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";

BIN
html/html/ipcop_big.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB