Private
Server IP : 195.201.23.43  /  Your IP : 3.144.46.149
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/virtual-server/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/share/webmin/virtual-server/edit_bucket.cgi
#!/usr/bin/perl
# Show details of an S3 bucket

require './virtual-server-lib.pl';
&ReadParse();
&can_backup_buckets() || &error($text{'buckets_ecannot'});

@accounts = &list_all_s3_accounts();
if ($in{'new'}) {
	&ui_print_header(undef, $text{'bucket_title1'}, "");
	$bucket = { };
	$info = { };
	}
else {
	&ui_print_header(undef, $text{'bucket_title2'}, "");

	# Get the account and bucket
	($account) = grep { $_->[0] eq $in{'account'} } @accounts;
	$account || &error($text{'bucket_eagone'});
	$buckets = &s3_list_buckets($account->[0], $account->[1]);
	ref($buckets) || &error(&text('bucket_elist', $buckets));
	($bucket) = grep { $_->{'Name'} eq $in{'name'} } @$buckets;
	$bucket || &error($text{'bucket_egone'});
	$info = &s3_get_bucket($account->[0], $account->[1], $in{'name'});
	}

print &ui_form_start("save_bucket.cgi", "post");
if ($in{'new'}) {
	print &ui_hidden("new", 1);
	}
else {
	print &ui_hidden("account", $in{'account'});
	print &ui_hidden("name", $in{'name'});
	}

print &ui_table_start($text{'bucket_header'}, "width=100%", 2);
if ($in{'new'}) {
	# Can select account, enter a bucket name and choose a location
	print &ui_table_row($text{'bucket_account'},
		&ui_select("account", undef, [ map { [ $_->[0], $_->[3]->{'desc'} ] } @accounts ]));

	print &ui_table_row($text{'bucket_name'},
		&ui_textbox("name", undef, 40));

	print &ui_table_row($text{'bucket_location'},
		&ui_select("location", $config{'s3_location'},
			   [ [ "", $text{'default'} ],
			     &s3_list_locations($account->[0], $account->[1]) ]));
	}
else {
	# Account, bucket and location are fixed
	if ($account->[3]) {
		print &ui_table_row($text{'bucket_account2'},
			$account->[3]->{'desc'} || $account->[3]->{'access'});
		}
	else {
		print &ui_table_row($text{'bucket_account'},
			"<tt>$in{'account'}</tt>");
		}

	print &ui_table_row($text{'bucket_name'},
		"<tt>$in{'name'}</tt>");

	print &ui_table_row($text{'bucket_location'},
		$info->{'location'} ? "<tt>$info->{'location'}</tt>"
				    : $text{'default'});

	print &ui_table_row($text{'bucket_owner'},
	    "<tt>".($info->{'acl'}->{'Owner'}->[0]->{'DisplayName'}->[0] ||
		    $info->{'acl'}->{'Owner'}->[0]->{'ID'}->[0])."</tt>");

	# Show file count and size
	$files = &s3_list_files($account->[0], $account->[1], $in{'name'});
	if (ref($files)) {
		$size = 0;
		foreach my $f (@$files) {
			$size += $f->{'Size'};
			}
		print &ui_table_row($text{'bucket_size'},
			@$files ? &text('bucket_sizestr', &nice_size($size),
							  scalar(@$files))
				: $text{'bucket_empty'});
		}
	}

# Bucket permissions
$ptable = &ui_columns_start([ $text{'bucket_type'},
			      $text{'bucket_grantee'},
			      $text{'bucket_perm'} ]);
$grant = $in{'new'} ? [ ] :
	    $info->{'acl'}->{'AccessControlList'}->[0]->{'Grant'};
$i = 0;
foreach my $g (@$grant, { }) {
	$grantee = $g->{'Grantee'}->[0]->{'DisplayName'}->[0] ||
		   $g->{'Grantee'}->[0]->{'ID'}->[0] ||
		   $g->{'Grantee'}->[0]->{'URI'}->[0];
	$grantee =~ s/^\Q$s3_groups_uri\E//;
	$ptable .= &ui_columns_row([
		&ui_select("type_$i",
			   $g->{'Grantee'}->[0]->{'xsi:type'},
			   [ [ "", "&nbsp;" ],
			     [ "CanonicalUser", $text{'bucket_user'} ],
			     [ "Group", $text{'bucket_group'} ] ]),
		&ui_textbox("grantee_$i", $grantee, 30),
		&ui_select("perm_$i", $g->{'Permission'}->[0] || "READ",
			   [ "FULL_CONTROL", "READ", "WRITE", "READ_ACP",
			     "WRITE_ACP" ]),
		]);
	$i++;
	}
$ptable .= &ui_columns_end();
print &ui_table_row($text{'bucket_grant'}, $ptable);

# Lifecycle policies
$ltable = &ui_columns_start([ $text{'bucket_lprefix'},
			      $text{'bucket_lstatus'},
			      $text{'bucket_lglacier'},
			      $text{'bucket_ldelete'} ]);
$lifecycle = !$in{'new'} && $info->{'lifecycle'} ?
		$info->{'lifecycle'}->{'Rule'} : [ ];
$i = 0;
foreach my $l (@$lifecycle, { }) {
	$prefix = $l->{'Prefix'} ? $l->{'Prefix'}->[0] : undef;
	$prefix = undef if (ref($prefix));
	$mode = !(keys %$l) ? 2 : $prefix ? 0 : 1;
	$ltable .= &ui_columns_row([
		&ui_radio("lprefix_def_$i", $mode,
			  [ [ 2, $text{'bucket_lnone'}."<br>" ],
			    [ 1, $text{'bucket_lall'}."<br>" ],
			    [ 0, $text{'bucket_lstart'}." ".
				 &ui_textbox("lprefix_$i", $prefix, 10) ] ]),
		&ui_checkbox("lstatus_$i", 1, "",
			     $l->{'Status'}->[0] eq 'Enabled'),
		&days_date_field("lglacier_$i", $l->{'Transition'}->[0]),
		&days_date_field("ldelete_$i", $l->{'Expiration'}->[0]),
		]);
	$i++;
	}
$ltable .= &ui_columns_end();
print &ui_table_row($text{'bucket_lifecycle'}, $ltable);

print &ui_table_end();
if ($in{'new'}) {
	print &ui_form_end([ [ undef, $text{'create'} ] ]);
	}
else {
	print &ui_form_end([ [ undef, $text{'save'} ],
			     [ 'delete', $text{'delete'} ] ]);
	}

&ui_print_footer("list_buckets.cgi", $text{'buckets_return'});

# days_date_field(name, object)
# Returns HTML for selecting a day or date policy
sub days_date_field
{
local ($name, $obj) = @_;
local $mode = $obj->{'Days'} ? 1 : $obj->{'Date'} ? 2 : 0;
local ($y, $m, $d) = $obj->{'Date'}->[0] =~ /^(\d+)\-(\d+)\-(\d+)/ ?
			($1, $2, $3) : ( );
return &ui_radio($name, $mode,
	[ [ 0, $text{'bucket_lnever'}."<br>" ],
	  [ 1, &text('bucket_ldays',
	          &ui_textbox($name."_days", $obj->{'Days'}->[0], 5))."<br>" ],
	  [ 2, &text('bucket_ldate',
		  &ui_date_input($d, $m, $y, $name."_day", $name."_month",
				 $name."_year")) ] ]);
}
Private