From ce5fb790ef712c58f8eaff1f8ae3b97b886a6cbf Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 23 Apr 2005 01:41:05 +0000 Subject: [PATCH] Add backend for updating short titles. --- html/do-update-shorttitles.pl | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 html/do-update-shorttitles.pl diff --git a/html/do-update-shorttitles.pl b/html/do-update-shorttitles.pl new file mode 100755 index 0000000..03c9f13 --- /dev/null +++ b/html/do-update-shorttitles.pl @@ -0,0 +1,32 @@ +#! /usr/bin/perl + +use ccbs; +use strict; +use warnings; + +ccbs::admin_only(); + +my $dbh = ccbs::db_connect(); +my $cgi = new CGI; + +# This is ugly, but we don't need more than one people updating this at a +# time anyhow (we hope). +$dbh->{AutoCommit} = 0; +$dbh->{RaiseError} = 1; +$dbh->do('DELETE FROM songshorttitles'); + +for my $p ($cgi->param()) { + $p =~ /^st(\d+)$/ or next; + my $num = $1; + my $st = $cgi->param($p); + + my $q = $dbh->prepare('INSERT INTO songshorttitles (song, shorttitle) VALUES (?, ?)'); + if ($st !~ /^\s*$/) { + $q->execute($num, $st); + } +} +$dbh->commit; +$dbh->disconnect; + +ccbs::print_see_other('shorttitles.pl'); + -- 2.39.2