]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/qos.cgi
HinzugefĆ¼gt:
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / qos.cgi
1 #!/usr/bin/perl
2 #
3 # IPFire CGIs
4 #
5 # This code is distributed under the terms of the GPL
6 #
7 # (c) The IPFire Team
8 #
9
10 use strict;
11 # enable only the following on debugging purpose
12 use warnings;
13 use CGI::Carp 'fatalsToBrowser';
14
15 require '/var/ipfire/general-functions.pl';
16 require "${General::swroot}/lang.pl";
17 require "${General::swroot}/header.pl";
18
19 my %qossettings=();
20 my %checked=();
21 my %netsettings=();
22 my $errormessage = "";
23 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
24
25 &Header::showhttpheaders();
26
27 $qossettings{'ACTION'} = '';
28 $qossettings{'ACTION_BW'} = '';
29 $qossettings{'ENABLED'} = '';
30 $qossettings{'OUT_SPD'} = '';
31 $qossettings{'INC_SPD'} = '';
32 $qossettings{'RED_DEV'} = `cat /var/ipfire/red/iface`;
33 $qossettings{'IMQ_DEV'} = 'imq0';
34
35 &General::readhash("${General::swroot}/qos/settings", \%qossettings);
36 &Header::getcgihash(\%qossettings);
37
38 &Header::openpage('QoS', 1, '');
39
40 &Header::openbigbox('100%', 'left', '', $errormessage);
41
42
43 if ($qossettings{'ACTION'} eq 'Start')
44 {
45 system("/bin/touch /var/ipfire/qos/enable");
46 $qossettings{'ENABLED'} = 'on';
47 &General::writehash("${General::swroot}/qos/settings", \%qossettings);
48 }
49 elsif ($qossettings{'ACTION'} eq 'Stop')
50 {
51 unlink "/var/ipfire/qos/enable";
52 $qossettings{'ENABLED'} = 'off';
53 &General::writehash("${General::swroot}/qos/settings", \%qossettings);
54 }
55 elsif ($qossettings{'ACTION'} eq $Lang::tr{'save'})
56 {
57 &General::writehash("${General::swroot}/qos/settings", \%qossettings);
58 }
59 if ($qossettings{'ACTION_BW'} eq 'Andern')
60 {
61 &Header::openbox('100%', 'center', 'Bandbreiteneinstellungen');
62 if ($qossettings{'ENABLED'} eq 'on') {
63 print "Sie koennen die Bandbreiteneinstellungen nicht bearbeiten, wenn QoS eingeschaltet ist. Schalten sie es zuerst dazu aus.<p>";
64 print "<a href='/cgi-bin/qos.cgi'>Zurueck</a>";
65 } else {
66 print <<END
67 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
68 <table width='66%'>
69 <tr><td width='100%' colspan='3'>Geben Sie bitte hier ihre Download- bzw. Upload-Geschwindigkeit ein <br> und klicken Sie danach auf <i>Speichern</i>.
70 <tr><td width='33%' align='right'>Download-Geschwindigkeit:<td width='33%' align='left'><input type='text' name='INC_SPD' maxlength='8' value=$qossettings{'INC_SPD'}> &nbsp; kbps<td width='33%' align='center'>&nbsp;
71 <tr><td width='33%' align='right'>Upload-Geschwindigkeit:<td width='33%' align='left'><input type='text' name='OUT_SPD' maxlength='8'value=$qossettings{'OUT_SPD'}> &nbsp; kbps<td width='33%' align='center'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
72 </table>
73 </form>
74 END
75 ;
76 }
77 &Header::closebox();
78 &Header::closebigbox();
79 &Header::closepage();
80 exit
81 }
82
83 &General::readhash("${General::swroot}/qos/settings", \%qossettings);
84
85 my $status = $Lang::tr{'stopped'};
86 my $statuscolor = $Header::colourred;
87 if ( $qossettings{'ENABLED'} eq 'on' ) {
88 $status = $Lang::tr{'running'};
89 $statuscolor = $Header::colourgreen;
90 }
91
92 if ( $netsettings{'RED_TYPE'} ne 'PPPOE' ) {
93 $qossettings{'RED_DEV'} = $netsettings{'RED_DEV'};
94 }
95
96 if ($errormessage) {
97 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
98 print "<class name='base'>$errormessage\n";
99 print "&nbsp;</class>\n";
100 &Header::closebox();
101 }
102
103 &Header::openbox('100%', 'center', 'Quality of Service');
104 print <<END
105 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
106 <table width='33%'>
107 <tr><td width='50%' align='left'><b>Quality of Service:</b>
108 <td width='50%' align='center' bgcolor='$statuscolor'><font color='white'>$status</font>
109 <tr><td width='100%' align='center' colspan='2'> <input type='submit' name='ACTION' value='Start' />
110 <input type='submit' name='ACTION' value='Stop' />
111 <input type='submit' name='ACTION' value='$Lang::tr{'restart'}' />
112 END
113 ;
114 if (($qossettings{'OUT_SPD'} ne '') && ($qossettings{'INC_SPD'} ne '')) {
115 print <<END
116 <tr><td colspan='3'>&nbsp;
117 <tr><td width='40%' align='right'>Downloadgeschwindigkeit: <td width='40%' align='left'>$qossettings{'INC_SPD'} <td width='20%' rowspan='2' align='center' valign='middle'><input type='submit' name='ACTION_BW' value='Andern'>
118 <tr><td width='40%' align='right'>Uploadgeschwindigkeit: <td width='40%' align='left'>$qossettings{'OUT_SPD'}
119
120 END
121 ;
122 }
123 print "</table>";
124 &Header::closebox();
125
126 if ( ($qossettings{'OUT_SPD'} eq '') || ($qossettings{'INC_SPD'} eq '') ) {
127 &Header::openbox('100%', 'center', "Outgoing ($qossettings{'RED_DEV'})");
128 print <<END
129 <table width='66%'>
130 <tr><td width='100%' colspan='3'>Geben Sie bitte hier ihre Download- bzw. Upload-Geschwindigkeit ein <br> und klicken Sie danach auf <i>Speichern</i>.
131 <tr><td width='33%' align='right'>Download-Geschwindigkeit:<td width='33%' align='left'><input type='text' name='INC_SPD' maxlength='8'> &nbsp; kbps<td width='33%' align='center'>&nbsp;
132 <tr><td width='33%' align='right'>Upload-Geschwindigkeit:<td width='33%' align='left'><input type='text' name='OUT_SPD' maxlength='8'> &nbsp; kbps<td width='33%' align='center'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
133 </table>
134 </form>
135 END
136 ;
137 &Header::closebox();
138 &Header::closebigbox();
139 &Header::closepage();
140 exit
141 }
142
143 if ( $qossettings{'RED_DEV'} ne '' ) {
144 &Header::openbox('100%', 'center', 'Outgoing Interface');
145 print <<END
146 <table border='0' width='100%' cellspacing='0'>
147 <tr><td bgcolor='lightgrey' width='20%'>Interface<td bgcolor='lightgrey' width='20%'>Klasse<td bgcolor='lightgrey' width='20%'>Maximale Geschwindigkeit<td bgcolor='lightgrey' width='40%'>Aktionen
148 <tr><td bgcolor='black' height='2px' colspan='4'>
149 <tr><td>ppp0<td>198<td>512<td>BLA
150 <tr><td bgcolor='lightgrey'>ppp0<td bgcolor='lightgrey'>199<td bgcolor='lightgrey'>512<td bgcolor='lightgrey'>BLA
151 </table>
152 END
153 ;
154 &Header::closebox();
155 } else {
156 &Header::openbox('100%', 'center', 'Outgoing Interface');
157 print "Es ist kein rotes Interface vorhanden.";
158 &Header::closebox();
159 &Header::closebigbox();
160 &Header::closepage();
161 exit
162 }
163
164 &Header::closebigbox();
165 &Header::closepage();
166