#!/usr/local/bin/perl # backup_form.cgi # Display a form for backing up this database, or all databases require './mysql-lib.pl'; &ReadParse(); if ($in{'all'}) { @alldbs = &list_databases(); @dbs = grep { &can_edit_db($_) } @alldbs; @alldbs == @dbs || &error($text{'dbase_ecannot'}); } else { &can_edit_db($in{'db'}) || &error($text{'dbase_ecannot'}); } $access{'edonly'} && &error($text{'dbase_ecannot'}); $access{'buser'} || &error($text{'dbase_ecannot'}); &ui_print_header(undef, $in{'all'} ? $text{'backup_title2'} : $text{'backup_title'}, "", "backup_form"); if (!-x $config{'mysqldump'}) { print &text('backup_edump', "$config{'mysqldump'}", "$gconfig{'webprefix'}/config.cgi?$module_name"),"

\n"; &ui_print_footer("edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'}); exit; } $cron = !$module_info{'usermin'} && $access{'buser'} eq 'root' && !$access{'user'} && &foreign_installed("cron"); if ($in{'all'}) { print "$text{'backup_desc3'}\n"; } else { print &text('backup_desc', "$in{'db'}"),"\n"; } if ($cron) { print "$text{'backup_desc2'}\n"; } print "

\n"; %c = $module_info{'usermin'} ? %userconfig : %config; print "

\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
$text{'backup_header'}
\n"; if ($in{'all'}) { print "\n"; } else { print "\n"; } printf "\n", $c{'backup_'.$in{'db'}}, &file_chooser_button("file"); if (!$in{'all'}) { # Show input to select tables $t = $c{'backup_tables_'.$in{'db'}}; print "\n"; } # Show input for where clause $w = $c{'backup_where_'.$in{'db'}}; print "\n"; print "\n"; # Show option to include drop statements in SQL $d = $c{'backup_drop_'.$in{'db'}}; print "\n"; print "\n"; # Show input for character set $s = $c{'backup_charset_'.$in{'db'}}; print "\n"; print "\n"; if ($mysql_version >= 5.0) { # Show compatability format option $cf = $c{'backup_compatible_'.$in{'db'}}; print "\n"; print "\n"; %co = map { $_, 1 } split(/\s+/, $c{'backup_options_'.$in{'db'}}); print "\n"; } else { print &ui_hidden("compatible_def", 1),"\n"; } # Show compression option $cp = int($c{'backup_compress_'.$in{'db'}}); print "\n"; print "\n"; if ($cron) { # Show before/after commands $b = $c{'backup_before_'.$in{'db'}}; print "\n"; printf "\n", $b; $a = $c{'backup_after_'.$in{'db'}}; print "\n"; printf "\n", $a; if ($in{'all'}) { # Command mode option $cmode = $c{'backup_cmode_'.$in{'db'}}; print "\n"; print "\n"; } # Show cron time &foreign_require("cron", "cron-lib.pl"); @jobs = &cron::list_cron_jobs(); $cmd = $in{'all'} ? "$cron_cmd --all" : "$cron_cmd $in{'db'}"; ($job) = grep { $_->{'command'} eq $cmd } @jobs; print "\n"; printf "\n", $job ? "checked" : "", $text{'backup_sched1'}; print "\n"; } print "
$text{'backup_file2'}
$text{'backup_file'} %s
$text{'backup_tables'} \n"; printf " %s\n", $t ? "" : "checked", $text{'backup_alltables'}; printf " %s
\n", $t ? "checked" : "", $text{'backup_seltables'}; @tables = &list_tables($in{'db'}); %got = map { $_, 1 } split(/\s+/, $t); print "
$text{'backup_where'}",&ui_opt_textbox("where", $w, 30, $text{'backup_none'}), "
$text{'backup_drop'}",&ui_yesno_radio("drop", $d ? 1 : 0),"
$text{'backup_charset'}",&ui_radio("charset_def", $s ? 0 : 1, [ [ 1, $text{'default'} ], [ 0, &ui_select("charset", $s, [ &list_character_sets($in{'db'}) ]) ] ]), "
$text{'backup_compatible'}",&ui_radio("compatible_def", $cf ? 0 : 1, [ [ 1, $text{'default'} ], [ 0, &text('backup_compwith', &ui_select("compatible", $cf, [ &list_compatible_formats() ])) ] ]), "
$text{'backup_options'} \n"; foreach $o (&list_compatible_options()) { print &ui_checkbox("options", $o->[0], $o->[1] || $o->[0], $co{$o->[0]}),"
\n"; } print "
$text{'backup_compress'}",&ui_radio("compress", $cp, [ [ 0, $text{'backup_cnone'} ], [ 1, $text{'backup_gzip'} ], [ 2, $text{'backup_bzip2'} ] ]),"
$text{'backup_before'}
$text{'backup_after'}
$text{'backup_cmode'}",&ui_radio("cmode", int($cmode), [ [ 0, $text{'backup_cmode0'} ], [ 1, $text{'backup_cmode1'} ] ]),"
$text{'backup_sched'} %s\n", $job ? "" : "checked", $text{'no'}; printf " %s
\n"; $job ||= { 'mins' => 0, 'hours' => 0, 'days' => '*', 'months' => '*', 'weekdays' => '*' }; &cron::show_times_input($job); print "
\n"; if ($cron) { print "\n"; print "\n"; } else { print "\n"; } print "
\n"; print "
\n"; if ($in{'all'}) { &ui_print_footer("", $text{'index_return'}); } else { &ui_print_footer("edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'}, "", $text{'index_return'}); }