Server IP : 195.201.23.43 / Your IP : 13.59.203.127 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 or delete a database require './virtual-server-lib.pl'; &ReadParse(); $d = &get_domain($in{'dom'}); $d || &error($text{'edit_egone'}); &can_edit_domain($d) || &error($text{'edit_ecannot'}); &can_edit_databases($d) || &error($text{'databases_ecannot'}); $tmpl = &get_template($d->{'template'}); if ($in{'ui_dbwarn'}) { # If dismissing a warning &merge_domain_config($d, { ui_dbwarn => 1 }); &lock_domain($d); &save_domain($d); &unlock_domain($d); &redirect(&get_referer_relative()); exit; } if ($in{'new'}) { # Create one, after checking for clashes &error_setup($text{'database_err'}); ($dleft, $dreason, $dmax) = &count_feature("dbs"); $dleft == 0 && &error($text{'database_emax'}); # Append prefix, if any if ($tmpl->{'mysql_suffix'} ne "none") { $prefix = &substitute_domain_template( $tmpl->{'mysql_suffix'}, $d); $prefix = &fix_database_name($prefix, $in{'type'}); if ($in{'name'} !~ /^\Q$prefix\E/i) { $in{'name'} = $prefix.$in{'name'}; } } # Validate name $in{'name'} = lc($in{'name'}); $err = &validate_database_name($d, $in{'type'}, $in{'name'}); &error($err) if ($err); # Parse type-specific options if (&indexof($in{'type'}, &list_database_plugins()) < 0) { # Core DB type $ofunc = "creation_parse_$in{'type'}"; if ($in{'new'} && defined(&$ofunc)) { $opts = &$ofunc($d, \%in); } } else { # Plugin type options if ($in{'new'} && &plugin_defined($in{'type'}, "creation_parse")) { $opts = &plugin_call($in{'type'}, "creation_parse", $d, \%in); } } if (&indexof($in{'type'}, &list_database_plugins()) >= 0) { &plugin_call($in{'type'}, "database_clash", $d, $in{'name'}) && &error($text{'database_eclash'}); } else { $cfunc = "check_".$in{'type'}."_database_clash"; &$cfunc($d, $in{'name'}) && &error($text{'database_eclash'}); } # Go for it &ui_print_header(&domain_in($d), $text{'database_title1'}, ""); if (&indexof($in{'type'}, &list_database_plugins()) >= 0) { &plugin_call($in{'type'}, "database_create", $d, $in{'name'}, $opts); } else { $crfunc = "create_".$in{'type'}."_database"; &$crfunc($d, $in{'name'}, $opts); } &save_domain($d); &refresh_webmin_user($d); &run_post_actions(); &webmin_log("create", "database", $in{'name'}, { 'type' => $in{'type'}, 'dom' => $d->{'dom'} }); } elsif ($in{'delete'} && !$in{'confirm'}) { # Ask the user if he wants to delete &ui_print_header(&domain_in($d), $text{'database_title3'}, ""); print "<center>",&text('database_rusure', $in{'name'}),"<p>\n"; print &ui_form_start("save_database.cgi", "post"); foreach $i ("dom", "name", "type", "delete") { print &ui_hidden($i, $in{$i}),"\n"; } print &ui_submit($text{'database_ok'}, "confirm"),"</center>\n"; print &ui_form_end(); } elsif ($in{'delete'}) { # Delete now if ($in{'name'} eq $d->{'db'} && !&can_edit_database_name()) { # Not allowed according to nodbname &error($text{'database_edbdef'}); } &ui_print_header(&domain_in($d), $text{'database_title3'}, ""); if (&indexof($in{'type'}, &list_database_plugins()) >= 0) { &plugin_call($in{'type'}, "database_delete", $d, $in{'name'}); } else { $dfunc = "delete_".$in{'type'}."_database"; &$dfunc($d, $in{'name'}); } &save_domain_print($d); &refresh_webmin_user($d); &run_post_actions(); &webmin_log("delete", "database", $in{'name'}, { 'type' => $in{'type'}, 'dom' => $d->{'dom'} }); } elsif ($in{'disc'}) { # Remove from server's list &ui_print_header(&domain_in($d), $text{'database_title4'}, ""); @dbs = split(/\s+/, $d->{'db_'.$in{'type'}}); @dbs = grep { $_ ne $in{'name'} } @dbs; $d->{'db_'.$in{'type'}} = join(" ", @dbs); # Call the revoke function to actually remove access $gfunc = "revoke_".$in{'type'}."_database"; if (defined(&$gfunc)) { &$gfunc($d, $in{'name'}); } &save_domain_print($d); &refresh_webmin_user($d); &run_post_actions(); &webmin_log("export", "database", $in{'name'}, { 'type' => $in{'type'}, 'dom' => $d->{'dom'} }); } elsif ($in{'manage'}) { # Just redirect to module to manage ($db) = grep { $_->{'name'} eq $in{'name'} && $_->{'type'} eq $in{'type'} } &domain_databases($d); &redirect($db->{'link'}); exit; } &ui_print_footer("list_databases.cgi?dom=$in{'dom'}", $text{'databases_return'}, &domain_footer_link($d), "", $text{'index_return'}); sub save_domain_print { &$first_print($text{'setup_save'}); &save_domain($_[0]); &$second_print($text{'setup_done'}); }Private