From 790f80663a0ddcb4f2496bad4b2e0bfa80bc3210 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 20 Jan 2004 20:30:03 +0000 Subject: add database dump from web interface --- httemplate/misc/dump.cgi | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 httemplate/misc/dump.cgi (limited to 'httemplate/misc/dump.cgi') diff --git a/httemplate/misc/dump.cgi b/httemplate/misc/dump.cgi new file mode 100644 index 000000000..2c7dfc455 --- /dev/null +++ b/httemplate/misc/dump.cgi @@ -0,0 +1,19 @@ +<% + if ( driver_name =~ /^Pg$/ ) { + my $dbname = (split(':', datasrc))[2]; + if ( $dbname =~ /[;=]/ ) { + my %elements = map { /^(\w+)=(.*)$/; $1=>$2 } split(';', $dbname); + $dbname = $elements{'dbname'}; + } + open(DUMP,"pg_dump $dbname |"); + } else { + eidiot "don't (yet) know how to dump ". driver_name. " databases\n"; + } + + http_header('Content-Type' => 'text/plain' ); + + while () { + chomp; +%><%= $_ %><% } + close DUMP; +%> -- cgit v1.2.1 From eef42f43c02b386ed7a0b1ce9911964bb94d3e96 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 21 Jan 2004 23:45:03 +0000 Subject: fix newline problem in dump --- httemplate/misc/dump.cgi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'httemplate/misc/dump.cgi') diff --git a/httemplate/misc/dump.cgi b/httemplate/misc/dump.cgi index 2c7dfc455..dc1323bb3 100644 --- a/httemplate/misc/dump.cgi +++ b/httemplate/misc/dump.cgi @@ -13,7 +13,7 @@ http_header('Content-Type' => 'text/plain' ); while () { - chomp; -%><%= $_ %><% } - close DUMP; + print $_; + } + close DUMP; %> -- cgit v1.2.1