]> git.sesse.net Git - ccbs/commitdiff
Add backend for updating short titles.
authorSteinar H. Gunderson <sesse@samfundet.no>
Sat, 23 Apr 2005 01:41:05 +0000 (01:41 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sat, 23 Apr 2005 01:41:05 +0000 (01:41 +0000)
html/do-update-shorttitles.pl [new file with mode: 0755]

diff --git a/html/do-update-shorttitles.pl b/html/do-update-shorttitles.pl
new file mode 100755 (executable)
index 0000000..03c9f13
--- /dev/null
@@ -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');
+