Server IP : 195.201.23.43 / Your IP : 18.117.161.73 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 : |
#!/usr/bin/perl # Create, update or delete a template require './virtual-server-lib.pl'; &can_edit_templates() || &error($text{'newtmpl_ecannot'}); &ReadParse(); @tmpls = &list_templates(); if (!$in{'new'}) { # Fetch existing template object ($tmpl) = grep { $_->{'id'} == $in{'id'} } @tmpls; $tmpl || &error($text{'tmpl_egone'}); } elsif ($in{'cloneof'}) { # Fetch source for clone ($cloneof) = grep { $_->{'id'} == $in{'cloneof'} } @tmpls; $tmpl = { %$cloneof }; $tmpl->{'id'} = undef; $tmpl->{'standard'} = 0; } elsif ($in{'cp'}) { # Fetch source for copy ($cloneof) = grep { $_->{'id'} == 0 } @tmpls; $tmpl = { %$cloneof }; $tmpl->{'id'} = undef; $tmpl->{'standard'} = 0; $tmpl->{'default'} = 0; } else { # Start with blank, with some sensible defaults $tmpl = { 'web_php_suexec' => 3 }; } if ($in{'delete'}) { if ($in{'confirm'}) { # Just delete this template &delete_template($tmpl); &webmin_log("delete", "template", $tmpl->{'name'}); &redirect("edit_newtmpl.cgi"); } else { # Ask first, and check for domains using it &ui_print_header($tmpl->{'name'}, $text{'tmpl_title5'}, ""); @users = &get_domain_by("template", $tmpl->{'id'}); print &ui_confirmation_form( "save_tmpl.cgi", $text{'tmpl_deletewarn'}, [ [ "id", $in{'id'} ], [ "delete", 1 ] ], [ [ "confirm", $text{'tmpl_deleteconfirm'} ] ], undef, @users ? &text('tmpl_deleteusers', scalar(@users)) : ''); &ui_print_footer("edit_newtmpl.cgi", $text{'newtmpl_return'}, "", $text{'index_return'}); } exit; } elsif ($in{'clone'}) { # Re-direct to creation page, in clone mode &redirect("edit_tmpl.cgi?new=1&clone=$in{'id'}"); exit; } # Validate and store all inputs $oldname = $tmpl->{'name'}; &error_setup($text{'tmpl_err'}); $pfunc = "parse_template_".$in{'editmode'}; &$pfunc($tmpl); # Check for name clash if ($in{'new'} || lc($tmpl->{'name'}) ne lc($oldname)) { ($clash) = grep { lc($_->{'name'}) eq lc($tmpl->{'name'}) && $_->{'id'} ne $tmpl->{'id'} && !$_->{'deleted'} } @tmpls; $clash && &error($text{'tmpl_eclash'}); } # Create or update the template &save_template($tmpl); if ($in{'cloneof'} || $in{'cp'}) { # Also copy template scripts $scripts = &list_template_scripts($cloneof); &save_template_scripts($tmpl, $scripts); } &webmin_log($in{'new'} ? "create" : "modify", "template", $tmpl->{'name'}); # Call post-save function $psfunc = "postsave_template_".$in{'editmode'}; if (defined(&$psfunc)) { &$psfunc($tmpl); } # Update all Webmin users for domains on this template, if a template # section that effects Webmin users was changed if (!$in{'new'} && &indexof($in{'editmode'}, @template_features_effecting_webmin) >= 0) { &set_all_null_print(); &modify_all_webmin($tmpl->{'standard'} ? undef : $tmpl->{'id'}); &run_post_actions(); } if ($in{'next'}) { # And go to next section @editmodes = &list_template_editmodes($tmpl); $idx = &indexof($in{'editmode'}, @editmodes); if ($idx == @editmodes-1) { $nextmode = $editmodes[0]; } else { $nextmode = $editmodes[$idx+1]; } &redirect("edit_tmpl.cgi?id=$tmpl->{'id'}&editmode=$nextmode"); } else { # Return to template list &redirect("edit_newtmpl.cgi"); } # parse_none_def(name) sub parse_none_def { if ($in{$_[0]."_mode"} == 0) { return "none"; } elsif ($in{$_[0]."_mode"} == 1) { return undef; } else { $in{$_[0]} =~ s/\t/ /g; $in{$_[0]} =~ s/\r//g; $in{$_[0]} =~ s/\n/\t/g; return $in{$_[0]}; } }Private