[! 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::Storage; !] [- use strict; my $cinfo = $fdat{__cinfo}; my $conn = PVE::ConfigClient::connect ($udat{auth_cookie}); my $stinfo = $conn->storage_user_info ()->result; $fdat{isostore} = $stinfo->{iso_default} if !$fdat{isostore}; my @sids = keys %{$stinfo->{iso}}; my $out = ''; my $form = PVE::HTMLForm->new (\%fdat); if ($udat{action} eq 'delete') { eval { check_write_mode ($udat{AM}); $conn->delete_volume ($fdat{aa}); }; $udat{popup_error} = $@ if $@; } 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}); die __("missing '.iso' extension") . "\n" if $fn !~ m/\.iso$/i; # hack use "$fn" instead of $fn (avoid bug #419) $conn->install_template ($fdat{isostore}, 'iso', $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 $isostorelist = PVE::HTMLUtils::storage_format_storage_list($stinfo, 'iso'); my $grid = PVE::HTMLGrid->new ('fw1', 'fw2to4'); $grid->add_row (__("ISO Storage") . ':', $form->create_element ('isostore', 'dynamicdropdown', $fdat{isostore}, $isostorelist)); $grid->add_row (__('ISO Image') . ':', $form->create_element ('filename', 'file', undef, undef, 400)); $grid->add_row ('', $form->create_cmdbutton ('upload')); my $html = $grid->html(); $out .= PVE::HTMLUtils::create_statusframe ('', __("Upload File"), undef, $html); $out .= "
\n"; $out .= $form->create_footer(); } if ($fdat{isostore}) { my $vlist = $conn->storage_list_iso ($fdat{isostore})->result; my $ddown = PVE::HTMLDropDown->new (); $ddown->add_item ("menu", "?action=delete", __('Delete')); $out .= $ddown->out_dropdown_menu("menu"); my $table = PVE::HTMLTable->new ([]); my @header = ('1', '20px', ' ', '1', '700px', __('File name'), ); $table->add_headline (\@header); my $found; PVE::Storage::foreach_volid ($vlist, sub { my ($volid, $sid, $volname, $info) = @_; my (undef, $name) = PVE::Storage::parse_volname_dir ($volname); my $menu = $ddown->out_symbol ('menu', '', "&aa=$volid"); $table->add_row ('', $menu, $name); $found = 1; }); my $headline = sprintf __("Storage '%s'") . ': ' . __("ISO Images"), $fdat{isostore}; $table->add_row ('', __("no entries"), '', '') if !$found; my $html = $table->out_table(); $out .= PVE::HTMLUtils::create_statusframe ('', $headline, undef, $html); } print OUT $out; -]