/[BackupPC]/upstream/2.1.0/lib/BackupPC/CGI/StartStopBackup.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /upstream/2.1.0/lib/BackupPC/CGI/StartStopBackup.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (hide annotations)
Wed Jun 22 19:12:04 2005 UTC (18 years, 11 months ago) by dpavlin
File size: 3418 byte(s)
import of version 2.1.0

1 dpavlin 1 #============================================================= -*-perl-*-
2     #
3     # BackupPC::CGI::StartStopBackup package
4     #
5     # DESCRIPTION
6     #
7     # This module implements the StartStopBackup action for the CGI interface.
8     #
9     # AUTHOR
10     # Craig Barratt <cbarratt@users.sourceforge.net>
11     #
12     # COPYRIGHT
13     # Copyright (C) 2003 Craig Barratt
14     #
15     # This program is free software; you can redistribute it and/or modify
16     # it under the terms of the GNU General Public License as published by
17     # the Free Software Foundation; either version 2 of the License, or
18     # (at your option) any later version.
19     #
20     # This program is distributed in the hope that it will be useful,
21     # but WITHOUT ANY WARRANTY; without even the implied warranty of
22     # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23     # GNU General Public License for more details.
24     #
25     # You should have received a copy of the GNU General Public License
26     # along with this program; if not, write to the Free Software
27     # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28     #
29     #========================================================================
30     #
31     # Version 2.1.0, released 20 Jun 2004.
32     #
33     # See http://backuppc.sourceforge.net.
34     #
35     #========================================================================
36    
37     package BackupPC::CGI::StartStopBackup;
38    
39     use strict;
40     use BackupPC::CGI::Lib qw(:all);
41    
42     sub action
43     {
44     my($str, $reply);
45    
46     my $start = 1 if ( $In{action} eq $Lang->{Start_Incr_Backup}
47     || $In{action} eq $Lang->{Start_Full_Backup} );
48     my $doFull = $In{action} eq $Lang->{Start_Full_Backup} ? 1 : 0;
49     my $type = $doFull ? $Lang->{Type_full} : $Lang->{Type_incr};
50     my $host = $In{host};
51     my $Privileged = CheckPermission($host);
52    
53     if ( !$Privileged ) {
54     ErrorExit(eval("qq{$Lang->{Only_privileged_users_can_stop_or_start_backups}}"));
55     }
56     ServerConnect();
57    
58     if ( $In{doit} ) {
59     if ( $start ) {
60     if ( $Hosts->{$host}{dhcp} ) {
61     $reply = $bpc->ServerMesg("backup $In{hostIP} ${EscURI($host)}"
62     . " $User $doFull");
63     $str = eval("qq{$Lang->{Backup_requested_on_DHCP__host}}");
64     } else {
65     $reply = $bpc->ServerMesg("backup ${EscURI($host)}"
66     . " ${EscURI($host)} $User $doFull");
67     $str = eval("qq{$Lang->{Backup_requested_on__host_by__User}}");
68     }
69     } else {
70     $reply = $bpc->ServerMesg("stop ${EscURI($host)} $User $In{backoff}");
71     $str = eval("qq{$Lang->{Backup_stopped_dequeued_on__host_by__User}}");
72     }
73     my $content = eval ("qq{$Lang->{REPLY_FROM_SERVER}}");
74     Header(eval ("qq{$Lang->{BackupPC__Backup_Requested_on__host}}"),$content);
75    
76     Trailer();
77     } else {
78     if ( $start ) {
79     my $ipAddr = ConfirmIPAddress($host);
80     my $content = eval("qq{$Lang->{Are_you_sure_start}}");
81     Header(eval("qq{$Lang->{BackupPC__Start_Backup_Confirm_on__host}}"),$content);
82     } else {
83     my $backoff = "";
84     GetStatusInfo("host(${EscURI($host)})");
85     if ( $StatusHost{backoffTime} > time ) {
86     $backoff = sprintf("%.1f",
87     ($StatusHost{backoffTime} - time) / 3600);
88     }
89     my $content = eval ("qq{$Lang->{Are_you_sure_stop}}");
90     Header(eval("qq{$Lang->{BackupPC__Stop_Backup_Confirm_on__host}}"),
91     $content);
92     }
93     Trailer();
94     }
95     }
96    
97     1;

  ViewVC Help
Powered by ViewVC 1.1.26