]> git.sesse.net Git - ccbs/blob - html/do-update-shorttitles.pl
03c9f13b154c27ddfadc754cdca5fd4d422612ea
[ccbs] / html / do-update-shorttitles.pl
1 #! /usr/bin/perl
2
3 use ccbs;
4 use strict;
5 use warnings;
6
7 ccbs::admin_only();
8
9 my $dbh = ccbs::db_connect();
10 my $cgi = new CGI;
11
12 # This is ugly, but we don't need more than one people updating this at a
13 # time anyhow (we hope).
14 $dbh->{AutoCommit} = 0;
15 $dbh->{RaiseError} = 1;
16 $dbh->do('DELETE FROM songshorttitles');
17
18 for my $p ($cgi->param()) {
19         $p =~ /^st(\d+)$/ or next;
20         my $num = $1;
21         my $st = $cgi->param($p);
22
23         my $q = $dbh->prepare('INSERT INTO songshorttitles (song, shorttitle) VALUES (?, ?)');
24         if ($st !~ /^\s*$/) {
25                 $q->execute($num, $st);
26         }
27 }
28 $dbh->commit;
29 $dbh->disconnect;
30
31 ccbs::print_see_other('shorttitles.pl');
32