Unser Paketmanager...
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / pakfire.cgi
1 #!/usr/bin/perl
2 #
3 # IPFire CGIs
4 #
5 # This file is part of the IPFire Project
6 #
7 # This code is distributed under the terms of the GPL
8 #
9 # (c) Eric Oberlander June 2002
10 #
11 # (c) Darren Critchley June 2003 - added real time clock setting, etc
12 #
13
14 use strict;
15
16 # enable only the following on debugging purpose
17 use warnings;
18 use CGI::Carp 'fatalsToBrowser';
19
20 require '/var/ipfire/general-functions.pl';
21 require "${General::swroot}/lang.pl";
22 require "${General::swroot}/header.pl";
23 require "/opt/pakfire/lib/functions.pl";
24
25 my %pakfiresettings=();
26 my $errormessage = '';
27
28 &Header::showhttpheaders();
29
30 $pakfiresettings{'ACTION'} = '';
31 $pakfiresettings{'VALID'} = '';
32
33 $pakfiresettings{'INSPAKS'} = '';
34 $pakfiresettings{'DELPAKS'} = '';
35 $pakfiresettings{'AUTOUPDATE'} = '';
36
37 &Header::getcgihash(\%pakfiresettings);
38
39 &Header::openpage($Lang::tr{'pakfire configuration'}, 1);
40 &Header::openbigbox('100%', 'left', '', $errormessage);
41
42 if ($pakfiresettings{'ACTION'} eq 'install')
43 {
44 my @inspaks = split(/\|/, "$pakfiresettings{'INSPAKS'}");
45 &General::writehash("${General::swroot}/pakfire/settings", \%pakfiresettings);
46 my @deps = "";
47 foreach (@inspaks) {
48 push(@deps, $_);
49 my @add = split(/ /, `/usr/local/bin/pakfire resolvedeps $_`);
50 foreach (@add) { push(@deps, $_); }
51 }
52 &Header::openbox("100%", "center", "Pakfire");
53 print "Wenn sie die Pakete @inspaks installieren wollen müssen sie auch folgende Pakete installieren: @deps";
54 &Header::closebox();
55 exit 0;
56 }
57 elsif ($pakfiresettings{'ACTION'} eq 'remove')
58 {
59 $errormessage = "$pakfiresettings{'DELPAKS'}";
60 &General::writehash("${General::swroot}/pakfire/settings", \%pakfiresettings);
61 } elsif ($pakfiresettings{'ACTION'} eq "$Lang::tr{'save'}")
62 {
63 &General::writehash("${General::swroot}/pakfire/settings", \%pakfiresettings);
64 }
65
66 &General::readhash("${General::swroot}/pakfire/settings", \%pakfiresettings);
67
68
69 my %selected=();
70 my %checked=();
71
72 $checked{'AUTOUPDATE'}{'off'} = '';
73 $checked{'AUTOUPDATE'}{'on'} = '';
74 $checked{'AUTOUPDATE'}{$pakfiresettings{'AUTOUPDATE'}} = "checked='checked'";
75
76 # DPC move error message to top so it is seen!
77 if ($errormessage) {
78 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
79 print "<font class='base'>$errormessage&nbsp;</font>\n";
80 &Header::closebox();
81 }
82
83 &Header::openbox("100%", "center", "Pakfire");
84
85 print <<END;
86 <table width='100%'>
87 <tr><td width='40%' align="center">Verfuegbare Addons:<br />
88 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
89 <select name="INSPAKS" size="10" multiple>
90 END
91 &Pakfire::dblist("notinstalled", "forweb");
92
93 print <<END;
94 </select>
95 </td>
96 <td width='20%' align="center">
97 <input type='hidden' name='ACTION' value='install' />
98 <input type='image' alt='$Lang::tr{'install'}' src='/images/list-add.png' />
99 </form><br />
100
101 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
102 <input type='submit' value='Liste aktualisieren' /><br />
103 </form>
104
105 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
106 <input type='hidden' name='ACTION' value='remove' />
107 <input type='image' alt='$Lang::tr{'remove'}' src='/images/list-remove.png' />
108 </td>
109 <td width='40%' align="center">Installierte Addons:<br />
110 <select name="DELPAKS" size="10" multiple>
111 <option value="postfix">Postfix v2.4.0-1</option>
112 </select>
113 </table></form>
114 <br /><hr /><br />
115 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
116 <table width='100%'>
117 <tr><td width='40%' align="right">Automatische Updates taeglich ausfuehren:
118 <td width='10%' align="left"><input type="checkbox" name="AUTOUPDATE" $checked{'AUTOUPDATE'}{'on'} />
119 <td width='40%' align="right">Test:
120 <td width='10%' align="left"><input type="checkbox" name="AUTOUPDATE" $checked{'AUTOUPDATE'}{'on'} />
121 <tr><td width='100%' colspan="4" align="right"><input type="submit" name="ACTION" value="$Lang::tr{'save'}" />
122 </table>
123 </form>
124 END
125
126 &Header::closebox();
127
128 &Header::closebigbox();
129
130 &Header::closepage();
131