[!
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 $out = '';
my $html = '';
my $pkglist = PVE::APLInfo::load_data();
my $form = PVE::HTMLForm->new (\%fdat);
if ($udat{action} =~ m/^delete(openvz|iso)$/) {
my $type = $1;
eval {
check_write_mode ($udat{AM});
my $conn = PVE::ConfigClient::connect();
$conn->delete_template ($type, $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});
my $conn = PVE::ConfigClient::connect();
# hack use "$fn" instead of $fn (avoid bug #419)
$conn->install_template ($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();
$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 ("menu0", "?action=deleteopenvz", __('Delete'));
$ddown->add_item ("menu1", "?action=deleteiso", __('Delete'));
$out .= $ddown->out_dropdown_menu("menu0");
$out .= $ddown->out_dropdown_menu("menu1");
my $tmpllist = PVE::Config::get_template_list();
my $table = PVE::HTMLTable->new ([]);
$table->add_headline (\@header);
$html = '';
foreach my $k (@$tmpllist) {
my $d = $pkglist->{'all'}->{$k};
my $menu = $ddown->out_symbol ('menu0', '', "&aa=$k");
my $desc = $d ? $d->{headline} : '-- unknown --';
$table->set_row_link ("?showinfo=$k") if $d;
$table->add_row ('', $menu, $desc, $k);
}
$html .= $table->out_table ();
$out .= PVE::HTMLUtils::create_statusframe ('', __("OpenVZ Templates"), undef, $html);
$out .= "
\n";
$html = '';
my $medialist = PVE::Config::get_media_list();
$table = PVE::HTMLTable->new ([]);
$table->add_headline (\@header);
foreach my $k (@$medialist) {
next if ref ($k);
my $d = $pkglist->{'all'}->{$k};
my $menu = $ddown->out_symbol ('menu1', '', "&aa=$k");
$table->set_row_link ("?showinfo=$k") if $d;
my $desc = $d ? $d->{headline} : undef;
if (!$desc) {
if ($k =~ m/\.iso$/i) {
$desc = 'ISO Image';
} else {
$desc = '-- unknown --';
}
}
$table->add_row ('', $menu, $desc, $k);
}
$html .= $table->out_table ();
$out .= PVE::HTMLUtils::create_statusframe ('', __("Qemu/KVM Templates and ISO images"), undef, $html);
print OUT $out;
-]