]> git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/shutdown.cgi
ids.cgi: Format and show date of the current ruleset again
[ipfire-2.x.git] / html / cgi-bin / shutdown.cgi
1 #!/usr/bin/perl
2 #
3 # SmoothWall CGIs
4 #
5 # This code is distributed under the terms of the GPL
6 #
7 # (c) The SmoothWall Team
8 #
9
10 use strict;
11
12 # enable only the following on debugging purpose
13 #use warnings;
14 #use CGI::Carp 'fatalsToBrowser';
15
16 require '/var/ipfire/general-functions.pl';
17 require "${General::swroot}/lang.pl";
18 require "${General::swroot}/header.pl";
19
20 my %cgiparams=();
21 my $death = 0;
22 my $rebirth = 0;
23
24 &Header::showhttpheaders();
25
26 $cgiparams{'ACTION'} = '';
27 &Header::getcgihash(\%cgiparams);
28
29 if ($cgiparams{'ACTION'} eq $Lang::tr{'shutdown'}) {
30 $death = 1;
31 &General::log($Lang::tr{'shutting down ipfire'});
32 system '/usr/local/bin/ipfirereboot down';
33 } elsif ($cgiparams{'ACTION'} eq $Lang::tr{'reboot'}) {
34 $rebirth = 1;
35 &General::log($Lang::tr{'rebooting ipfire'});
36 system '/usr/local/bin/ipfirereboot boot';
37 }
38 if ($death == 0 && $rebirth == 0) {
39
40 &Header::openpage($Lang::tr{'shutdown control'}, 1, '');
41
42 &Header::openbigbox('100%', 'left');
43
44 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
45
46 &Header::openbox('100%', 'left', );
47 print <<END
48 <table width='100%'>
49 <tr>
50 <td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'reboot'}' /></td>
51 <td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'shutdown'}' /></td>
52 </tr>
53 </table>
54 END
55 ;
56 &Header::closebox();
57
58 } else {
59 my $message='';
60 my $title='';
61 my $refresh = "<meta http-equiv='refresh' content='5; URL=/cgi-bin/index.cgi' />";
62 if ($death) {
63 $title = $Lang::tr{'shutting down'};
64 $message = $Lang::tr{'ipfire has now shutdown'};
65 } else {
66 $title = $Lang::tr{'rebooting'};
67 $message = $Lang::tr{'ipfire has now rebooted'};
68 }
69 &Header::openpage($title, 0, $refresh);
70
71 &Header::openbigbox('100%', 'center');
72 print <<END
73 <div align='center'>
74 <table width='100%' bgcolor='#ffffff'>
75 <tr><td align='center'>
76 <br /><br /><img src='/images/IPFire.png' /><br /><br /><br />
77 </td></tr>
78 </table>
79 <br />
80 <font size='6'>$message</font>
81 </div>
82 END
83 ;
84 }
85
86 &Header::closebigbox();
87 &Header::closepage();
88