[!
use strict;
use PVE::pvecfg;
use PVE::I18N;
use PVE::Config;
use PVE::ConfigServer;
use PVE::HTMLTable;
use PVE::HTMLControls;
use PVE::HTMLDropDown;
use PVE::HTMLForm;
use PVE::HTMLUtils;
use PVE::APLInfo;
!]
[-
use strict;
my $cinfo = $fdat{__cinfo};
my $conn = PVE::ConfigClient::connect ($udat{auth_cookie});
my $out = '';
my $pkglist = PVE::APLInfo::load_data();
my $form = PVE::HTMLForm->new (\%fdat);
if ($udat{action} eq 'delete') {
my $type = $1;
eval {
check_write_mode ($udat{AM});
$conn->delete_volume ($fdat{aa});
};
$udat{popup_error} = $@ if $@;
}
if ($fdat{showinfo} && (my $d = $pkglist->{'all'}->{$fdat{showinfo}})) {
print OUT PVE::HTMLUtils::create_pkginfo_frame ($d);
return;
}
if ($form->action eq 'upload') {
if ($fdat{filename} !~ m/^\s*$/) {
my $buffer = "";
my $tmpname = "/tmp/proxmox_upload-$$.bin";
open FILE, ">$tmpname";
print FILE $buffer while read($fdat{filename}, $buffer, 32768);
close FILE;
my $fn = $fdat{filename};
chomp $fn;
$fn =~ s/^.*[\/\\]//;
$fn =~ s/\s/_/g;
eval {
check_write_mode ($udat{AM});
PVE::HTMLUtils::check_vztmpl_name ($fn);
# hack use "$fn" instead of $fn (avoid bug #419)
$conn->install_template ('local', 'vztmpl', $tmpname, "$fn");
};
my $err = $@;
unlink $tmpname;
if ($err) {
$udat{popup_error} = $err;
} else {
$udat{popup_info} = __("upload successful");
}
}
}
if ($udat{AM} eq 'w') {
$out .= $form->create_header();
my $html .= $form->create_element ('filename', 'file', undef, undef, 400);
$html .= $form->create_cmdbutton ('upload');
$out .= PVE::HTMLUtils::create_statusframe ('', __("Upload File"), undef, $html);
$out .= "
\n";
$out .= $form->create_footer();
}
my @header = ('1', '20px', ' ',
'1', '250px', __('Description'),
'1', '450px', __('File name'),
);
my $ddown = PVE::HTMLDropDown->new ();
$ddown->add_item ("menu", "?action=delete", __('Delete'));
$out .= $ddown->out_dropdown_menu("menu");
my $tmpllist = $conn->storage_list_vztmpl ('local')->result;
my $table = PVE::HTMLTable->new ([]);
$table->add_headline (\@header);
my $html = '';
my $found;
PVE::Storage::foreach_volid ($tmpllist, sub {
my ($volid, $sid, $volname, $info) = @_;
my (undef, $name) = PVE::Storage::parse_volname_dir ($volname);
my $d = $pkglist->{'all'}->{$name};
my $desc = $d ? $d->{headline} : '-- unknown --';
my $menu = $ddown->out_symbol ('menu', '', "&aa=$volid");
$table->set_row_link ("?showinfo=$name") if $d;
$table->add_row ('', $menu, $desc, $name);
$found = 1;
});
$table->add_row ('', __("no entries"), '', '') if !$found;
$html .= $table->out_table ();
$out .= PVE::HTMLUtils::create_statusframe ('', __("OpenVZ Templates"), undef, $html);
$out .= "
\n";
print OUT $out;
-]