]>
git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/upnp.cgi
5 # This code is distributed under the terms of the GPL
11 # enable only the following on debugging purpose
13 use CGI
::Carp
'fatalsToBrowser';
15 require '/var/ipfire/general-functions.pl';
16 require "${General::swroot}/lang.pl";
17 require "${General::swroot}/header.pl";
19 my %upnpsettings = ();
23 my $errormessage = "";
25 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
29 'UPnP Daemon' => 'upnpd',
32 &Header
::showhttpheaders
();
33 ############################################################################################################################
34 ############################################### Setzen von Standartwerten ##################################################
36 $upnpsettings{'DEBUGMODE'} = '3';
37 $upnpsettings{'FORWARDRULES'} = 'yes';
38 $upnpsettings{'FORWARDCHAIN'} = 'FORWARD';
39 $upnpsettings{'PREROUTINGCHAIN'} = 'PORTFW';
40 $upnpsettings{'DOWNSTREAM'} = '900000';
41 $upnpsettings{'UPSTREAM'} = '16000000';
42 $upnpsettings{'DESCRIPTION'} = 'gatedesc.xml';
43 $upnpsettings{'XML'} = '/etc/linuxigd';
44 $upnpsettings{'ENABLED'} = 'off';
45 $upnpsettings{'GREENi'} = 'on';
46 $upnpsettings{'BLUEi'} = 'off';
47 $upnpsettings{'REDi'} = 'off';
48 $upnpsettings{'ORANGEi'} = 'off';
49 $upnpsettings{'GREENe'} = 'off';
50 $upnpsettings{'BLUEe'} = 'off';
51 $upnpsettings{'REDe'} = 'on';
52 $upnpsettings{'ORANGEe'} = 'off';
53 ### Values that have to be initialized
54 $upnpsettings{'ACTION'} = '';
56 &General
::readhash
("${General::swroot}/upnp/settings", \
%upnpsettings);
57 &Header
::getcgihash
(\
%upnpsettings);
59 &Header
::openpage
('UPnP', 1, '');
60 &Header
::openbigbox
('100%', 'left', '', $errormessage);
62 ############################################################################################################################
63 ################################################### Speichern der Config ###################################################
65 if ($upnpsettings{'ACTION'} eq $Lang::tr
{'save'})
67 &General
::writehash
("${General::swroot}/upnp/settings", \
%upnpsettings);
69 open (FILE
, ">${General::swroot}/upnp/upnpd.conf") or die "Can't save the upnp config: $!";
74 # UPnP Config by Ipfire Project
76 debug_mode = $upnpsettings{'DEBUGMODE'}
77 insert_forward_rules = $upnpsettings{'FORWARDRULES'}
78 forward_chain_name = $upnpsettings{'FORWARDCHAIN'}
79 prerouting_chain_name = $upnpsettings{'PREROUTINGCHAIN'}
80 upstream_bitrate = $upnpsettings{'DOWNSTREAM'}
81 downstream_bitrate = $upnpsettings{'UPSTREAM'}
82 description_document_name = $upnpsettings{'DESCRIPTION'}
83 xml_document_path = $upnpsettings{'XML'}
89 elsif ($upnpsettings{'ACTION'} eq 'Start')
91 $upnpsettings{'ENABLED'} = 'on';
92 &General
::writehash
("${General::swroot}/upnp/settings", \
%upnpsettings);
93 system('/usr/local/bin/upnpctrl upnpdstart $netsettings{'RED_DEV
'} $netsettings{'GREEN_DEV
'}');
95 elsif ($upnpsettings{'ACTION'} eq 'Stop')
97 $upnpsettings{'ENABLED'} = 'off';
98 &General
::writehash
("${General::swroot}/upnp/settings", \
%upnpsettings);
99 system('/usr/local/bin/upnpctrl upnpstop');
101 elsif ($upnpsettings{'ACTION'} eq $Lang::tr
{'restart'})
103 &General
::writehash
("${General::swroot}/upnp/settings", \
%upnpsettings);
104 system('/usr/local/bin/upnpctrl upnpstop');
105 system('/usr/local/bin/upnpctrl upnpstart $netsettings{'RED_DEV
'} $netsettings{'GREEN_DEV
'}');
108 &General
::readhash
("${General::swroot}/upnp/settings", \
%upnpsettings);
111 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
112 print "<class name='base'>$errormessage\n";
113 print " </class>\n";
117 $checked{'GREENi'}{'on'} = '';
118 $checked{'GREENi'}{'off'} = '';
119 $checked{'GREENi'}{"$upnpsettings{'GREENi'}"} = 'checked';
120 $checked{'BLUEi'}{'on'} = '';
121 $checked{'BLUEi'}{'off'} = '';
122 $checked{'BLUEi'}{"$upnpsettings{'BLUEi'}"} = 'checked';
123 $checked{'REDi'}{'on'} = '';
124 $checked{'REDi'}{'off'} = '';
125 $checked{'REDi'}{"$upnpsettings{'REDi'}"} = 'checked';
126 $checked{'ORANGEi'}{'on'} = '';
127 $checked{'ORANGEi'}{'off'} = '';
128 $checked{'ORANGEi'}{"$upnpsettings{'ORANGEi'}"} = 'checked';
129 $checked{'GREENe'}{'on'} = '';
130 $checked{'GREENe'}{'off'} = '';
131 $checked{'GREENe'}{"$upnpsettings{'GREENe'}"} = 'checked';
132 $checked{'BLUEe'}{'on'} = '';
133 $checked{'BLUEe'}{'off'} = '';
134 $checked{'BLUEe'}{"$upnpsettings{'BLUEe'}"} = 'checked';
135 $checked{'REDe'}{'on'} = '';
136 $checked{'REDe'}{'off'} = '';
137 $checked{'REDe'}{"$upnpsettings{'REDe'}"} = 'checked';
138 $checked{'ORANGEe'}{'on'} = '';
139 $checked{'ORANGEe'}{'off'} = '';
140 $checked{'ORANGEe'}{"$upnpsettings{'ORANGEe'}"} = 'checked';
142 ############################################################################################################################
143 ############################################################################################################################
145 &Header
::openbox
('100%', 'center', 'UPnP');
147 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
148 <table width='95%' cellspacing='0'>
151 if ( $message ne "" ) {
152 print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
157 foreach $key (sort keys %servicenames)
160 print "<tr bgcolor='${Header::table1colour}'>\n"; }
162 print "<tr bgcolor='${Header::table2colour}'>\n"; }
163 print "<td align='left'>$key\n";
164 my $shortname = $servicenames{$key};
165 my $status = &isrunning
($shortname);
170 <tr><td><b>Alle Dienste:</b></td><td colspan='2'>
171 <input type='submit' name='ACTION' value='Start' />
172 <input type='submit' name='ACTION' value='Stop' />
173 <input type='submit' name='ACTION' value='$Lang::tr{'restart'}' />
182 # <table width='95%'>
183 # <tr><td colspan='2' align='left' bgcolor='${Header::table1colour}'><b>External Interface</b></td></tr>
184 # <tr><td align='left'> </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>
185 # <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>
188 # if (&Header::blue_used()){
190 # <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>
194 # if (&Header::orange_used()){
196 # <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>
202 # <tr><td colspan='2' align='left'><br></br></td></tr>
203 # <tr><td colspan='2' align='left' bgcolor='${Header::table1colour}'><b>Internal Interface</b></td></tr>
204 # <tr><td align='left'> </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>
205 # <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>
208 # if (&Header::blue_used()){
210 # <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>
214 # if (&Header::orange_used()){
216 # <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>
225 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
226 <table width='95%' cellspacing='0'>
227 <tr><td colspan='2' align='left' bgcolor='${Header::table1colour}'><b>$Lang::tr{'options'}</b></td></tr>
228 <tr><td colspan='2' align='left'><br></br></td></tr>
229 <tr><td align='left'>Debug Mode:</td><td><input type='text' name='DEBUGMODE' value='$upnpsettings{'DEBUGMODE'}' size="30"></input></td></tr>
230 <tr><td align='left'>Forward Rules:</td><td><input type='text' name='FORWARDRULES' value='$upnpsettings{'FORWARDRULES'}' size="30"></input></td></tr>
231 <tr><td align='left'>Forward Chain:</td><td><input type='text' name='FORWARDCHAIN' value='$upnpsettings{'FORWARDCHAIN'}' size="30"></input></td></tr>
232 <tr><td align='left'>Prerouting Chain:</td><td><input type='text' name='PREROUTINGCHAIN' value='$upnpsettings{'PREROUTINGCHAIN'}' size="30"></input></td></tr>
233 <tr><td align='left'>Down Stream:</td><td><input type='text' name='DOWNSTREAM' value='$upnpsettings{'DOWNSTREAM'}' size="30"></input></td></tr>
234 <tr><td align='left'>Up Strean:</td><td><input type='text' name='UPSTREAM' value='$upnpsettings{'UPSTREAM'}' size="30"></input></td></tr>
235 <tr><td align='left'>Description Document:</td><td><input type='text' name='DESCRIPTION' value='$upnpsettings{'DESCRIPTION'}' size="30"></input></td></tr>
236 <tr><td align='left'>XML Document:</td><td><input type='text' name='XML' value='$upnpsettings{'XML'}' size="30"></input></td></tr>
237 <tr><td colspan='2' align='left'><br></br></td></tr>
238 <tr><td colspan='2' align='center'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
246 &Header
::closebigbox
();
247 &Header
::closepage
();
249 ############################################################################################################################
250 ############################################################################################################################
255 my $status = "<td bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td>";
263 if (open(FILE
, "/var/run/${cmd}.pid"))
265 $pid = <FILE
>; chomp $pid;
267 if (open(FILE
, "/proc/${pid}/status"))
271 if (/^Name:\W+(.*)/) {
275 if ($testcmd =~ /$exename/)
277 $status = "<td bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";