3 # Execute some SQL command and display output
5 require './mysql-lib.pl';
7 &can_edit_db($in{'db'}) || &error($text{'dbase_ecannot'});
8 $access{'edonly'} && &error($text{'dbase_ecannot'});
9 &error_setup($text{'exec_err'});
12 # Delete the history file
13 &unlink_file($commands_file.".".$in{'db'});
14 &redirect("exec_form.cgi?db=$in{'db'}");
18 $in{'cmd'} = join(" ", split(/[\r\n]+/, $in{'cmd'}));
19 $cmd = $in{'cmd'} ? $in{'cmd'} : $in{'old'};
20 $d = &execute_sql_logged($in{'db'}, $cmd);
22 &ui_print_header(undef, $text{'exec_title'}, "");
23 print &text('exec_out', "<tt>".&html_escape($cmd)."</tt>"),"<p>\n";
24 @data = @{$d->{'data'}};
26 print &ui_columns_start($d->{'titles'});
28 print &ui_columns_row($r);
30 print &ui_columns_end();
33 print "<b>$text{'exec_none'}</b> <p>\n";
36 &open_readfile(OLD, "$commands_file.$in{'db'}");
39 $already++ if ($_ eq $in{'cmd'});
42 if (!$already && $in{'cmd'} =~ /\S/) {
43 &open_lock_tempfile(OLD, ">>$commands_file.$in{'db'}");
44 &print_tempfile(OLD, "$in{'cmd'}\n");
46 chmod(0700, "$commands_file.$in{'db'}");
48 &webmin_log("exec", undef, $in{'db'}, \%in);
50 &ui_print_footer("exec_form.cgi?db=$in{'db'}", $text{'exec_return'},
51 "edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'},
52 "", $text{'index_return'});