]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/upnp.cgi
Add pound to make.sh.
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / upnp.cgi
index d2faaa160f0e42838bf123bd8ee6a534f965948d..8d2666ec75be4292aac4611dbf5efe8becf2438e 100644 (file)
@@ -1,16 +1,28 @@
 #!/usr/bin/perl
-#
-# IPFire CGIs
-#
-# This code is distributed under the terms of the GPL
-#
-# (c) The IPFire Team
-#
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2007  Michael Tremer & Christian Schmidt                      #
+#                                                                             #
+# This program 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 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
 
 use strict;
 # enable only the following on debugging purpose
-use warnings;
-use CGI::Carp 'fatalsToBrowser';
+#use warnings;
+#use CGI::Carp 'fatalsToBrowser';
 
 require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
@@ -24,18 +36,23 @@ my %selected= () ;
 
 my %servicenames =('UPnP Daemon' => 'upnpd',);
 
+my %color = ();
+my %mainsettings = ();
+&General::readhash("${General::swroot}/main/settings", \%mainsettings);
+&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
+
 &Header::showhttpheaders();
 ############################################################################################################################
 ############################################### Setzen von Standartwerten ##################################################
 
 $upnpsettings{'DEBUGMODE'} = '3';
 $upnpsettings{'FORWARDRULES'} = 'yes';
-$upnpsettings{'DOWNSTREAM'} = '900000';
-$upnpsettings{'UPSTREAM'} = '16000000';
+$upnpsettings{'DOWNSTREAM'} = '1048576';
+$upnpsettings{'UPSTREAM'} = '131072';
 $upnpsettings{'DESCRIPTION'} = 'gatedesc.xml';
 $upnpsettings{'XML'} = '/etc/linuxigd';
 $upnpsettings{'ENABLED'} = 'off';
-$upnpsettings{'friendlyName'} = 'IpFire Upnp Device';
+$upnpsettings{'friendlyName'} = 'IPFire Gateway';
 ### Values that have to be initialized
 $upnpsettings{'ACTION'} = '';
 
@@ -51,8 +68,8 @@ $upnpsettings{'ACTION'} = '';
 
 if ($upnpsettings{'ACTION'} eq $Lang::tr{'save'})
        {
-       $upnpsettings{'DOWNSTREAM'} = $upnpsettings{'DOWNSTREAM'} * 8;
-       $upnpsettings{'UPSTREAM'} = $upnpsettings{'UPSTREAM'} * 8;
+       $upnpsettings{'DOWNSTREAM'} = $upnpsettings{'DOWNSTREAM'} * 1024;
+       $upnpsettings{'UPSTREAM'} = $upnpsettings{'UPSTREAM'} * 1024;
        &General::writehash("${General::swroot}/upnp/settings", \%upnpsettings);
 
        open (FILE, ">${General::swroot}/upnp/upnpd.conf") or die "Can't save the upnp config: $!";
@@ -74,7 +91,7 @@ xml_document_path = $upnpsettings{'XML'}
 END
 ;
        close FILE;
-       system("/usr/local/bin/upnpctrl upnpxml $upnpsettings{'XML'} $upnpsettings{'DESCRIPTION'} $upnpsettings{'manufacturer'}");
+       system("/usr/local/bin/upnpctrl","upnpxml","$upnpsettings{'friendlyName'}","$upnpsettings{'XML'}","$upnpsettings{'DESCRIPTION'}");
        }
 elsif ($upnpsettings{'ACTION'} eq 'Start')
        {
@@ -96,8 +113,8 @@ elsif ($upnpsettings{'ACTION'} eq $Lang::tr{'restart'})
        }
 
 &General::readhash("${General::swroot}/upnp/settings", \%upnpsettings);
-$upnpsettings{'DOWNSTREAM'} = $upnpsettings{'DOWNSTREAM'} / 8;
-$upnpsettings{'UPSTREAM'} = $upnpsettings{'UPSTREAM'} / 8;
+$upnpsettings{'DOWNSTREAM'} = $upnpsettings{'DOWNSTREAM'} / 1024;
+$upnpsettings{'UPSTREAM'} = $upnpsettings{'UPSTREAM'} / 1024;
 
 if ($errormessage)
        {
@@ -122,12 +139,7 @@ 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\n";
+  print "<tr><td align='left'>$key\n";
        my $shortname = $servicenames{$key};
        my $status = &isrunning($shortname);
        print "$status\n";
@@ -144,27 +156,42 @@ print <<END
 <br />
 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
 <table width='95%' cellspacing='0'>
-<tr><td colspan='2' align='left' bgcolor='${Header::table1colour}'><b>$Lang::tr{'options'}</b></td></tr>
-<tr><td colspan='2' align='left'><br></br></td></tr>
-<tr><td align='left'>Debug Mode:</td><td><input type='text' name='DEBUGMODE' value='$upnpsettings{'DEBUGMODE'}' size="30" /></td></tr>
-<tr><td align='left'>Forward Rules:</td><td><input type='text' name='FORWARDRULES' value='$upnpsettings{'FORWARDRULES'}' size="30" /></td></tr>
+<tr><td colspan='2' align='left' bgcolor='$color{'color20'}'><b>$Lang::tr{'options'}</b></td></tr>
+<tr><td align='left' colspan='2'><br /></td></tr>
+<tr><td align='left'>UPnP Device Name:</td><td><input type='text' name='friendlyName' value='$upnpsettings{'friendlyName'}' size="30" /></td></tr>
 <tr><td align='left' colspan='2'><br /></td></tr>
-<tr><td align='left'>Down Stream in KB:</td><td><input type='text' name='DOWNSTREAM' value='$upnpsettings{'DOWNSTREAM'}' size="30" /></td></tr>
-<tr><td align='left'>Up Strean in KB:</td><td><input type='text' name='UPSTREAM' value='$upnpsettings{'UPSTREAM'}' size="30" /></td></tr>
+<tr><td align='left'>Downstream in KB:</td><td><input type='text' name='DOWNSTREAM' value='$upnpsettings{'DOWNSTREAM'}' size="30" /></td></tr>
+<tr><td align='left'>Upstream in KB:</td><td><input type='text' name='UPSTREAM' value='$upnpsettings{'UPSTREAM'}' size="30" /></td></tr>
 <tr><td align='left' colspan='2'><br /></td></tr>
-<tr><td align='left'>XML Document:</td><td><input type='text' name='XML' value='$upnpsettings{'XML'}' size="30" /></td></tr>
-<tr><td align='left'>Description Document:</td><td><input type='text' name='DESCRIPTION' value='$upnpsettings{'DESCRIPTION'}' size="30" /></td></tr>
-<tr><td align='left'>Upnp Device Name:</td><td><input type='text' name='friendlyName' value='$upnpsettings{'friendlyName'}' size="30" /></td></tr>
-<tr><td colspan='2' align='left'><br></br></td></tr>
-<tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value=$Lang::tr{'save'} />
+<tr><td colspan='2' align='center'>    <input type='hidden' name='ACTION' value=$Lang::tr{'save'} />
                                                                                                                                                <input type='image' alt=$Lang::tr{'save'} src='/images/floppy.gif' /></td></tr>
 </table></form>
-<br />
-<hr />
 END
 ;
 &Header::closebox();
 
+&Header::openbox('100%', 'center', 'Aktuell geoeffnete Ports');
+my @output = qx(iptables -t nat -n -L PORTFW);
+my ($outputline, $extip, $extport, $int);
+my @output2;
+print "<table>";
+foreach $outputline (@output) {
+       if ( $outputline =~ /^DNAT/ ) { 
+               @output2 = split(/ /, $outputline);
+               $extip = $output2[23];
+               $extport = $output2[29];
+               $extport =~ s/dpt://;
+               $int = "$output2[31]";
+               $int =~ s/to://;
+               print "<tr><td>$extip:$extport<td align='center'><img src='/images/forward.gif' alt='=&gt;' /><td>$int";
+
+       }
+}
+
+print "</table>";
+
+&Header::closebox();
+
 &Header::closebigbox();
 &Header::closepage();
 
@@ -197,4 +224,4 @@ sub isrunning
                }
 
                return $status;
-       }
\ No newline at end of file
+       }