Files
smeserver-BackupPC/root/usr/share/smanager/lib/SrvMngr/Controller/Backuppc.pm
Brian Read ec6b312c35 * Sun Oct 05 2025 Brian Read <brianr@koozali.org> 0.2-21.sme
- Add UTF8 and avoid potential DB caching problems [SME: 13209]
2025-10-05 11:34:03 +01:00

75 lines
1.7 KiB
Perl

package SrvMngr::Controller::Backuppc;
#----------------------------------------------------------------------
# heading : Administration
# description : BackupPC
# navigation : 4000 4200
#----------------------------------------------------------------------
# name : backuppc, method : get, url : /backuppc, ctlact : Backuppc#main
# routes : end
use strict;
use warnings;
use Mojo::Base 'Mojolicious::Controller';
use utf8;
use Locale::gettext;
use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session ip_number_or_blank);
use Quota;
use esmith::ConfigDB::UTF8;
use esmith::AccountsDB::UTF8;
use esmith::util;
use File::Basename;
use File::Find;
use File::Path qw(make_path remove_tree);
use esmith::Backup;
use esmith::BackupHistoryDB;
use esmith::lockfile;
use constant DEBUG => $ENV{MOJO_SMANAGER_DEBUG} || 0;
my $cdb;
my $adb;
sub main {
my $c = shift;
$c->app->log->info($c->log_req);
$cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open config db";
$adb = esmith::AccountsDB::UTF8->open || die "Couldn't open accounts db";
my $url = "https://".$c->session->{'SystemName'}.".".$c->session->{"DomainName"}."/BackupPC";
$c->stash(url => $url );
$c->render(template => 'backuppc');
}
sub get_backuppc {
my ($c) = @_;
my $tx = $c->tx;
my $req = $tx->req;
my $res = `/usr/share/BackupPC/sbin/BackupPC_Admin`; #
my $step = 0;
my $out;
my @lines = split /\n/, $res;
# remove except 'body'
foreach my $line (@lines) {
if ( $line =~ m|<body>| ) {
$step = 1;
} elsif ( $line =~ m|</body>| ) {
$step = 2;
} elsif ( $step == 1 ) {
$out .= $line;
}
}
return $out;
}
1;