Private
Server IP : 195.201.23.43  /  Your IP : 3.148.227.197
Web Server : Apache
System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64
User : kdecoratie ( 1041)
PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/webmin/bacula-backup/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/share/webmin/bacula-backup/list.cgi
#!/usr/bin/perl
# Returns a list of files and directories under some directory

$trust_unknown_referers = 1;
use JSON::PP;
require './bacula-backup-lib.pl';
&ReadParse();

# Input sanitization
die "Illegal input" if ($in{'job'} and $in{'job'} !~ /^\d+\z/);

# Output the appropriate content-type
if ($in{'fmt'} eq "json") {
	print "Content-type: application/json\n\n";
}
else {
	print "Content-type: text/plain\n\n";
}

# Format the parent with ending slash if missing
$d = ($in{'dir'} =~ /\/\z/) ? $in{'dir'} : $in{'dir'}."/";
$wind = &unix_to_dos($d);

# Get the parent directory ID
$dbh = &connect_to_database();
$cmd = $dbh->prepare("SELECT PathId FROM Path WHERE Path = ?");
$cmd->execute($wind);
($pid) = $cmd->fetchrow();
$cmd->finish();

if ($in{'job'}) {
	$jobsql = "AND Job.JobId = $in{'job'}";
}

@nodes = ();

if ($in{'volume'}) {
	# Search just within one volume
	# Subdirectories of directory, that are on this volume
	$cmd = $dbh->prepare("
		SELECT DISTINCT Path.Path
		FROM Job, File, Path, JobMedia, Media
		WHERE Job.JobId        = File.JobId
		  AND Job.JobId        = JobMedia.JobId
		  AND File.PathId      = Path.PathId
		  AND JobMedia.MediaId = Media.MediaId
		  AND Media.VolumeName = ?
		  $jobsql
		ORDER BY Path.Path
	");

	$cmd->execute($in{'volume'}) || die "db error: ".$dbh->errstr;
}
else {
	# Search all files
	# Subdirectories of directory
	$cmd = $dbh->prepare("
		SELECT DISTINCT Path.Path
		FROM Job, File, Path
		WHERE Job.JobId   = File.JobId
		  AND File.PathId = Path.PathId
		  $jobsql
		ORDER BY Path.Path
	");

	$cmd->execute() || die "db error: ".$dbh->errstr;
}

# Push all folders direcly under the starting path
while(($f) = $cmd->fetchrow()) {
	$f = &dos_to_unix($f);
	if ($f =~ /^(\Q$d\E([^\/]+)\/)/) {
		push(@rv, $1);
	}
}

$cmd->finish();

@rv = &unique(@rv);

# Build the nodes structure for folders
foreach $f (@rv) {
	$f =~ /([^\/]+)\/\Z/;
	push @nodes, {
		text     => $1,
		fullpath => $f,
		children => JSON::PP::true,
		icon     => "jstree-folder"
	};
}

if ($in{'volume'}) {
	# Files in directory, that are on this volume
	$cmd = $dbh->prepare("
		SELECT Filename.Name
		FROM File, Filename, Job, JobMedia, Media
		WHERE File.FilenameId  = Filename.FilenameId
		  AND File.JobId       = Job.JobId
		  AND Job.JobId        = JobMedia.JobId
		  AND JobMedia.MediaId = Media.MediaId
		  AND File.PathId      = ?
		  AND Media.VolumeName = ?
		  $jobsql
		ORDER BY Filename.Name
	");

	$cmd->execute($pid, $in{'volume'}) || die "db error: ".$dbh->errstr;
}
else {
	# Files in directory
	$cmd = $dbh->prepare("
		SELECT Filename.Name
		FROM Job, File, Filename
		WHERE Job.JobId       = File.JobId
		  AND File.FilenameId = Filename.FilenameId
		  AND File.PathId     = ?
		  $jobsql
		ORDER BY Filename.Name
	");

	$cmd->execute($pid) || die "db error: ".$dbh->errstr;
}

# Push all the files in the starting path
while(($f) = $cmd->fetchrow()) {
	if ($f =~ /\S/) {
		push(@rv, "$d$f");

		# Build the nodes structure for files
		push @nodes, {
			text     => $f,
			fullpath => "$d$f",
			children => JSON::PP::false,
			icon     => "jstree-file"
		};
	}
}

$cmd->finish();

# Return output

if($in{'fmt'} eq "json") {
	print JSON::PP->new->utf8->encode(\@nodes);
}
else {
	print "\n";
	foreach $f (@rv) {
		print $f,"\n";
	}
}
Private