~allison/ubuntu/oneiric/backuppc/merge-debian-inetutils

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/perl
#============================================================= -*-perl-*-w
#
# BackupPC_Admin: Apache/CGI interface for BackupPC.
#
# DESCRIPTION
#   BackupPC_Admin provides a flexible web interface for BackupPC.
#   It is a CGI script that runs under Apache.
#
#   It requires that Apache pass in $ENV{SCRIPT_NAME} and
#   $ENV{REMOTE_USER}. The latter requires .ht_access style
#   authentication. Replace the code below if you are using some other
#   type of authentication, and have a different way of getting the
#   user name.
#
#   Also, this script needs to run as the BackupPC user.  To accomplish
#   this the script is typically installed as setuid to the BackupPC user,
#   or it can run under mod_perl with httpd running as the BackupPC user.
#
# AUTHOR
#   Craig Barratt  <cbarratt@users.sourceforge.net>
#
# COPYRIGHT
#   Copyright (C) 2001-2009  Craig Barratt
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#========================================================================
#
# Version 3.2.0, released 31 Jul 2010.
#
# See http://backuppc.sourceforge.net.
#
#========================================================================

use strict;
no  utf8;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use lib "__INSTALLDIR__/lib";

use BackupPC::Lib;
use BackupPC::CGI::Lib qw(:all);

BackupPC::CGI::Lib::NewRequest;

my %ActionDispatch = (
    "summary"             	 => "Summary",
    "Start_Incr_Backup"          => "StartStopBackup",
    "Start_Full_Backup"          => "StartStopBackup",
    "Stop_Dequeue_Backup"        => "StartStopBackup",
    "Stop_Dequeue_Archive"       => "StartStopBackup",
    "queue"               	 => "Queue",
    "view"                	 => "View",
    "LOGlist"             	 => "LOGlist",
    "emailSummary"        	 => "EmailSummary",
    "browse"              	 => "Browse",
    "dirHistory"              	 => "DirHistory",
    "Restore"           	 => "Restore",
    "RestoreFile"         	 => "RestoreFile",
    "hostInfo"		       	 => "HostInfo",
    "generalInfo"         	 => "GeneralInfo",
    "restoreInfo"         	 => "RestoreInfo",
    "archiveInfo"         	 => "ArchiveInfo",
    "Start_Archive"              => "Archive",
    "Archive"                    => "Archive",
    "Reload"                     => "ReloadServer",
    "startServer"                => "StartServer",
    "Stop"                       => "StopServer",
    "adminOpts"                  => "AdminOptions",
    "editConfig"                 => "EditConfig",
    "rss"                        => "RSS",
);

#
# Set default actions, then call sub handler
#
if ( !defined($ActionDispatch{$In{action}}) ) {
    $In{action} = defined($In{host}) ? "hostInfo" : "generalInfo";
}
my $action = $ActionDispatch{$In{action}};

#
# For some reason under mod_perl, the use lib above is unreliable,
# and sometimes the module below cannot be found.  Explicitly push
# the directory onto INC if it is missing.  This is an ugly hack;
# need to figure out what's really going on...
#
my $installDir = '__INSTALLDIR__/lib';
push(@INC, $installDir) if ( !grep($_ eq $installDir, @INC) );

#
# Load the relevant action script and run it
#
require "BackupPC/CGI/$action.pm"
	    if ( !defined($BackupPC::CGI::{"${action}::"}) );
$BackupPC::CGI::{"${action}::"}{action}();