]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/upnp.cgi
upnp.cgi und status.cgi von Maniac eingebaut
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / upnp.cgi
index 3afaee2c47ea91e28bcd27203c403b045f79089c..2b7168c9cc25f427165e1caf02c6e507bafcc7cb 100644 (file)
@@ -26,7 +26,7 @@ my %selected= () ;
 
 my %servicenames =
 (
-       'UPnP Daemon' => 'upnpd',
+        'UPnP Daemon' => 'upnpd',
 );
 
 &Header::showhttpheaders();
@@ -42,8 +42,14 @@ $upnpsettings{'UPSTREAM'} = '16000000';
 $upnpsettings{'DESCRIPTION'} = 'gatedesc.xml';
 $upnpsettings{'XML'} = '/etc/linuxigd';
 $upnpsettings{'ENABLED'} = 'off';
-$upnpsettings{'GREEN'} = 'on';
-$upnpsettings{'BLUE'} = 'off';
+$upnpsettings{'GREENi'} = 'on';
+$upnpsettings{'BLUEi'} = 'off';
+$upnpsettings{'REDi'} = 'off';
+$upnpsettings{'ORANGEi'} = 'off';
+$upnpsettings{'GREENe'} = 'off';
+$upnpsettings{'BLUEe'} = 'off';
+$upnpsettings{'REDe'} = 'on';
+$upnpsettings{'ORANGEe'} = 'off';
 ### Values that have to be initialized
 $upnpsettings{'ACTION'} = '';
 
@@ -60,9 +66,9 @@ if ($upnpsettings{'ACTION'} eq $Lang::tr{'save'})
 {
 &General::writehash("${General::swroot}/upnp/settings", \%upnpsettings);
 
-       open (FILE, ">${General::swroot}/upnp/upnpd.conf") or die "Can't save the upnp config: $!";
-       flock (FILE, 2);
-
+       open (FILE, ">${General::swroot}/upnp/upnpd.conf") or die "Can't save the upnp config: $!";
+       flock (FILE, 2);
+       
 print FILE <<END
 
 # UPnP Config by Ipfire Project
@@ -82,90 +88,144 @@ close FILE;
 }
 elsif ($upnpsettings{'ACTION'} eq 'Start')
 {
-       $upnpsettings{'ENABLED'} = 'on';
-       &General::writehash("${General::swroot}/upnp/settings", \%upnpsettings);
-       system('/usr/local/bin/upnpctrl start');
-}
+        $upnpsettings{'ENABLED'} = 'on';
+        &General::writehash("${General::swroot}/upnp/settings", \%upnpsettings);
+        system('/usr/local/bin/upnpctrl upnpdstart $netsettings{'RED_DEV'} $netsettings{'GREEN_DEV'}');
+} 
 elsif ($upnpsettings{'ACTION'} eq 'Stop')
 {
-       $upnpsettings{'ENABLED'} = 'off';
-       &General::writehash("${General::swroot}/upnp/settings", \%upnpsettings);
-       system('/usr/local/bin/upnpctrl stop');
-}
+        $upnpsettings{'ENABLED'} = 'off';
+        &General::writehash("${General::swroot}/upnp/settings", \%upnpsettings);
+        system('/usr/local/bin/upnpctrl upnpstop');
+} 
 elsif ($upnpsettings{'ACTION'} eq $Lang::tr{'restart'})
 {
-       &General::writehash("${General::swroot}/upnp/settings", \%upnpsettings);
-       system('/usr/local/bin/upnpctrl restart');
+        &General::writehash("${General::swroot}/upnp/settings", \%upnpsettings);
+        system('/usr/local/bin/upnpctrl upnpstop');
+        system('/usr/local/bin/upnpctrl upnpstart $netsettings{'RED_DEV'} $netsettings{'GREEN_DEV'}');
 }
 
 &General::readhash("${General::swroot}/upnp/settings", \%upnpsettings);
 
 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{'error messages'});
+        print "<class name='base'>$errormessage\n";
+        print "&nbsp;</class>\n";
+        &Header::closebox();
 }
 
-$checked{'GREEN'}{'on'} = '';
-$checked{'GREEN'}{'off'} = '';
-$checked{'GREEN'}{"$upnpsettings{'GREEN'}"} = 'checked';
-$checked{'BLUE'}{'on'} = '';
-$checked{'BLUE'}{'off'} = '';
-$checked{'BLUE'}{"$upnpsettings{'BLUE'}"} = 'checked';
+$checked{'GREENi'}{'on'} = '';
+$checked{'GREENi'}{'off'} = '';
+$checked{'GREENi'}{"$upnpsettings{'GREENi'}"} = 'checked';
+$checked{'BLUEi'}{'on'} = '';
+$checked{'BLUEi'}{'off'} = '';
+$checked{'BLUEi'}{"$upnpsettings{'BLUEi'}"} = 'checked';
+$checked{'REDi'}{'on'} = '';
+$checked{'REDi'}{'off'} = '';
+$checked{'REDi'}{"$upnpsettings{'REDi'}"} = 'checked';
+$checked{'ORANGEi'}{'on'} = '';
+$checked{'ORANGEi'}{'off'} = '';
+$checked{'ORANGEi'}{"$upnpsettings{'ORANGEi'}"} = 'checked';
+$checked{'GREENe'}{'on'} = '';
+$checked{'GREENe'}{'off'} = '';
+$checked{'GREENe'}{"$upnpsettings{'GREENe'}"} = 'checked';
+$checked{'BLUEe'}{'on'} = '';
+$checked{'BLUEe'}{'off'} = '';
+$checked{'BLUEe'}{"$upnpsettings{'BLUEe'}"} = 'checked';
+$checked{'REDe'}{'on'} = '';
+$checked{'REDe'}{'off'} = '';
+$checked{'REDe'}{"$upnpsettings{'REDe'}"} = 'checked';
+$checked{'ORANGEe'}{'on'} = '';
+$checked{'ORANGEe'}{'off'} = '';
+$checked{'ORANGEe'}{"$upnpsettings{'ORANGEe'}"} = 'checked';
 
 ############################################################################################################################
 ############################################################################################################################
 
 &Header::openbox('100%', 'center', 'UPnP');
 print <<END
-       <form method='post' action='$ENV{'SCRIPT_NAME'}'>
-       <table width='400' cellspacing='0'>
+        <form method='post' action='$ENV{'SCRIPT_NAME'}'>
+        <table width='95%' cellspacing='0'>
 END
 ;
-       if ( $message ne "" ) {
-               print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
-       }
-
-       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";
-               my $shortname = $servicenames{$key};
-               my $status = &isrunning($shortname);
-               print "$status\n";
-               $lines++;
-       }
-       print <<END
-               <tr><td><b>Alle Dienste:</b></td><td colspan='2'>
-               <input type='submit' name='ACTION' value='Start' />
-               <input type='submit' name='ACTION' value='Stop' />
-               <input type='submit' name='ACTION' value='$Lang::tr{'restart'}' />
-       </table>
-       </form>
-       <hr />
-       <form method='post' action='$ENV{'SCRIPT_NAME'}'>
-       <table width='500'>
-       <tr><td colspan='2' align='left'><b>$Lang::tr{'options'}</b>
-       <tr><td align='left'>$Lang::tr{'interfaces'}
-            <td align='left'>&nbsp;<td><input type='checkbox' name='GREEN' $checked{'GREEN'}{'on'} /> <font size='2' color='$Header::colourgreen'><b>$Lang::tr{'green'} - $netsettings{'GREEN_DEV'}</b></font>
-END
-;
-        if (&Header::blue_used()){
+        if ( $message ne "" ) {
+                print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
+        }
+
+        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";
+                my $shortname = $servicenames{$key};
+                my $status = &isrunning($shortname);
+                print "$status\n";
+                $lines++;
+        }
         print <<END
-        <tr><td align='left'>&nbsp;<td><input type='checkbox' name='BLUE' $checked{'BLUE'}{'on'} /> <font size='2' color='$Header::colourblue'><b>$Lang::tr{'wireless'} - $netsettings{'BLUE_DEV'}</b></font>
+                <tr><td><b>Alle Dienste:</b></td><td colspan='2'>
+                <input type='submit' name='ACTION' value='Start' /> 
+                <input type='submit' name='ACTION' value='Stop' /> 
+                <input type='submit' name='ACTION' value='$Lang::tr{'restart'}' />
+        </table>
 END
 ;
-                                   }
-       print <<END
-       </table>
-
+#print <<END
+#        <br></br>
+#        <hr />
+#        <br></br>
+#        
+#        <table width='95%'>
+#        <tr><td colspan='2' align='left' bgcolor='${Header::table1colour}'><b>External Interface</b></td></tr>
+#        <tr><td align='left'>&nbsp;</td><td><input type='radio' name='External' value='$netsettings{'RED_DEV'}' $checked{'REDe'}{'on'}><font size='2' color='$Header::colourred'><b>RED - $netsettings{'RED_DEV'}</b></font><br></br>
+#                                            <input type='radio' name='External' value='$netsettings{'GREEN_DEV'}' $checked{'GREENe'}{'on'}><font size='2' color='$Header::colourgreen'><b>$Lang::tr{'green'} - $netsettings{'GREEN_DEV'}</b></font><br></br>
+#END
+#;
+#         if (&Header::blue_used()){
+#         print <<END
+#                                             <input type='radio' name='External' value='$netsettings{'BLUE_DEV'}' $checked{'BLUEe'}{'on'}><font size='2' color='$Header::colourblue'><b>$Lang::tr{'wireless'} - $netsettings{'BLUE_DEV'}</b></font><br></br>
+#END
+#;
+#                                    }
+#         if (&Header::orange_used()){
+#         print <<END
+#                                             <input type='radio' name='External' value='$netsettings{'ORANGE_DEV'}' $checked{'ORANGEe'}{'on'}><font size='2' color='$Header::colourorange'><b>$Lang::tr{'dmz'} - $netsettings{'ORANGE_DEV'}</b></font><br></br>
+#END
+#;
+#                                    }
+#        print <<END
+#        </td></tr>
+#        <tr><td colspan='2' align='left'><br></br></td></tr>
+#        <tr><td colspan='2' align='left' bgcolor='${Header::table1colour}'><b>Internal Interface</b></td></tr>
+#        <tr><td align='left'>&nbsp;</td><td><input type='radio' name='Internal' value='$netsettings{'RED_DEV'}' $checked{'REDi'}{'on'}><font size='2' color='$Header::colourred'><b>RED - $netsettings{'RED_DEV'}</b></font><br></br>
+#                                            <input type='radio' name='Internal' value='$netsettings{'GREEN_DEV'}' $checked{'GREENi'}{'on'}><font size='2' color='$Header::colourgreen'><b>$Lang::tr{'green'} - $netsettings{'GREEN_DEV'}</b></font><br></br>
+#END
+#;
+#         if (&Header::blue_used()){
+#         print <<END
+#                                            <input type='radio' name='Internal' value='$netsettings{'BLUE_DEV'}' $checked{'BLUEi'}{'on'}><font size='2' color='$Header::colourblue'><b>$Lang::tr{'wireless'} - $netsettings{'BLUE_DEV'}</b></font><br></br>
+#END
+#;
+#                                    }
+#         if (&Header::orange_used()){
+#         print <<END
+#                                            <input type='radio' name='Internal' value='$netsettings{'ORANGE_DEV'}' $checked{'ORANGEi'}{'on'}><font size='2' color='$Header::colourorange'><b>$Lang::tr{'dmz'} - $netsettings{'ORANGE_DEV'}</b></font><br></br>
+#END
+#;
+#                                    }
+#        print <<END
+#        </td></tr></table>
+print <<END
+</form>
+<br></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"></input></td></tr>
 <tr><td align='left'>Forward Rules:</td><td><input type='text' name='FORWARDRULES' value='$upnpsettings{'FORWARDRULES'}' size="30"></input></td></tr>
 <tr><td align='left'>Forward Chain:</td><td><input type='text' name='FORWARDCHAIN' value='$upnpsettings{'FORWARDCHAIN'}' size="30"></input></td></tr>
@@ -174,6 +234,7 @@ END
 <tr><td align='left'>Up Strean:</td><td><input type='text' name='UPSTREAM' value='$upnpsettings{'UPSTREAM'}' size="30"></input></td></tr>
 <tr><td align='left'>Description Document:</td><td><input type='text' name='DESCRIPTION' value='$upnpsettings{'DESCRIPTION'}' size="30"></input></td></tr>
 <tr><td align='left'>XML Document:</td><td><input type='text' name='XML' value='$upnpsettings{'XML'}' size="30"></input></td></tr>
+<tr><td colspan='2' align='left'><br></br></td></tr>
 <tr><td colspan='2' align='center'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
 </table></form>
 <br></br>
@@ -190,33 +251,33 @@ END
 
 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;
-}
+        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;
+}
\ No newline at end of file