]>
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
();
34 $upnpsettings{'ENABLED'} = 'off';
35 $upnpsettings{'GREEN'} = 'on';
36 $upnpsettings{'BLUE'} = 'off';
37 ### Values that have to be initialized
38 $upnpsettings{'ACTION'} = '';
40 &General
::readhash
("${General::swroot}/upnp/settings", \
%upnpsettings);
41 &Header
::getcgihash
(\
%upnpsettings);
43 &Header
::openpage
('UPnP', 1, '');
44 &Header
::openbigbox
('100%', 'left', '', $errormessage);
46 ############################################################################################################################
47 ############################################################################################################################
49 if ($upnpsettings{'ACTION'} eq $Lang::tr
{'save'})
51 &General
::writehash
("${General::swroot}/upnp/settings", \
%upnpsettings);
53 elsif ($upnpsettings{'ACTION'} eq 'Start')
55 $upnpsettings{'ENABLED'} = 'on';
56 &General
::writehash
("${General::swroot}/upnp/settings", \
%upnpsettings);
57 system('/usr/local/bin/upnpctrl start');
59 elsif ($upnpsettings{'ACTION'} eq 'Stop')
61 $upnpsettings{'ENABLED'} = 'off';
62 &General
::writehash
("${General::swroot}/upnp/settings", \
%upnpsettings);
63 system('/usr/local/bin/upnpctrl stop');
65 elsif ($upnpsettings{'ACTION'} eq $Lang::tr
{'restart'})
67 &General
::writehash
("${General::swroot}/upnp/settings", \
%upnpsettings);
68 system('/usr/local/bin/upnpctrl restart');
71 &General
::readhash
("${General::swroot}/upnp/settings", \
%upnpsettings);
74 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
75 print "<class name='base'>$errormessage\n";
76 print " </class>\n";
80 $checked{'GREEN'}{'on'} = '';
81 $checked{'GREEN'}{'off'} = '';
82 $checked{'GREEN'}{"$upnpsettings{'GREEN'}"} = 'checked';
83 $checked{'BLUE'}{'on'} = '';
84 $checked{'BLUE'}{'off'} = '';
85 $checked{'BLUE'}{"$upnpsettings{'BLUE'}"} = 'checked';
87 ############################################################################################################################
88 ############################################################################################################################
90 &Header
::openbox
('100%', 'center', 'UPnP');
92 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
93 <table width='400' cellspacing='0'>
96 if ( $message ne "" ) {
97 print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
102 foreach $key (sort keys %servicenames)
105 print "<tr bgcolor='${Header::table1colour}'>\n"; }
107 print "<tr bgcolor='${Header::table2colour}'>\n"; }
108 print "<td align='left'>$key\n";
109 my $shortname = $servicenames{$key};
110 my $status = &isrunning
($shortname);
115 <tr><td><b>Alle Dienste:</b></td><td colspan='2'>
116 <input type='submit' name='ACTION' value='Start' />
117 <input type='submit' name='ACTION' value='Stop' />
118 <input type='submit' name='ACTION' value='$Lang::tr{'restart'}' />
122 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
124 <tr><td colspan='2' align='left'><b>$Lang::tr{'options'}</b>
125 <tr><td align='left'>$Lang::tr{'interfaces'}
126 <td align='left'> <td><input type='checkbox' name='GREEN' $checked{'GREEN'}{'on'} /> <font size='2' color='$Header::colourgreen'><b>$Lang::tr{'green'} - $netsettings{'GREEN_DEV'}</b></font>
129 if (&Header
::blue_used
()){
131 <tr><td align='left'> <td><input type='checkbox' name='BLUE' $checked{'BLUE'}{'on'} /> <font size='2' color='$Header::colourblue'><b>$Lang::tr{'wireless'} - $netsettings{'BLUE_DEV'}</b></font>
136 <tr><td colspan='2' align='right'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
143 &Header
::closebigbox
();
144 &Header
::closepage
();
146 ############################################################################################################################
147 ############################################################################################################################
152 my $status = "<td bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td>";
160 if (open(FILE
, "/var/run/${cmd}.pid"))
162 $pid = <FILE
>; chomp $pid;
164 if (open(FILE
, "/proc/${pid}/status"))
168 if (/^Name:\W+(.*)/) {
172 if ($testcmd =~ /$exename/)
174 $status = "<td bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";