#!/usr/bin/perl
use utf8;
-use strict;
+#use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use Encode 'decode';
use File::Slurp;
use YAML::XS;
-
+use URI::Escape;
#
# Libre10
#
my $dbh = DBI->connect( "dbi:SQLite:dbname=$confdata->{dburl}",
"", "", { RaiseError => 1, AutoCommit => 1 } );
my $pdflist = $dbh->selectall_hashref(
-"SELECT id, path, page, title, part, genre, startpage, endpage, showpagediff, indexpage
+"SELECT id, path, page, title, title_id, part, genre, startpage, endpage, showpagediff, indexpage
FROM pdffile"
, 'id'
);
exit;
}
elsif ( $mode eq 'showpagediff' ) {
- my $dnum = $cgi->int( param("diff") );
- my $title = $cgi->param("title");
+ my $dnum = int($cgi->param("diff") );
+ my $title = decode('utf-8',uri_unescape($cgi->param("title")));
if ( $dnum > 0 ) {
my $sqls =
- "UPDATE pdffile SET showpagediff = $dnum WHERE title_group=$title";
+ "UPDATE pdffile SET showpagediff = $dnum WHERE title_id=\"$title\"";
+ print $sqls;
$dbs = $dbh->prepare($sqls);
$dbs->execute();
}
}
+elsif ( $mode eq 'genre') {
+ my $genre = $cgi->param("genre");
+ my $title = decode('utf-8',uri_unescape($cgi->param("title")));
+ $lgenre = length $genre;
+ if ( $lgenre > 0 ) {
+ my $sqls =
+ "UPDATE pdffile SET genre = \"$genre\" WHERE title_id=\"$title\"";
+ print $sqls;
+ $dbs = $dbh->prepare($sqls);
+ $dbs->execute();
+ }
+}
+elsif ( $mode eq 'index') {
+ my $index = int($cgi->param("index"));
+ my $title = decode('utf-8',uri_unescape($cgi->param("title")));
+ if ( $index > 0 ) {
+ my $sqls =
+ "UPDATE pdffile SET indexpage = \"$index\" WHERE title_id=\"$title\"";
+ print $sqls;
+ $dbs = $dbh->prepare($sqls);
+ $dbs->execute();
+ }
+}
else {
list_all_pdf();
}
print
qq {Partial PDF = ./pdfmanager.pl?mode=partpdf&pdfid=68fc6a6a1cdd79227d0f2fe2f03dd510&pdftk=765-765\n};
my $ary_ref = $dbh->selectall_arrayref(
-"SELECT id, path, page, title, part, genre, startpage, endpage, showpagediff, indexpage
+"SELECT id, path, page, title_id, title, part, genre, startpage, endpage, showpagediff, indexpage
FROM pdffile"
, { Slice => {} }
);
print qq {<th>id</th>\n};
print qq {<th>path</th>\n};
print qq {<th>page</th>\n};
+ print qq {<th>title_id</th>\n};
print qq {<th>title</th>\n};
print qq {<th>part</th>\n};
print qq {<th>genre</th>\n};
print qq {<th>start</th>\n};
print qq {<th>end</th>\n};
- #print qq {<th>showpagediff</th>\n};
+ print qq {<th>showpagediff</th>\n};
#print qq {<th>indexpage</th>\n};
print qq {</tr>\n};
foreach my $line ( @{$ary_ref} ) {
qq {<td><a href="./htmlserver.pl?pdfpath=$line->{id}&pagenum=1">$line->{id}</a></td>\n};
print qq {<td>$line->{path}</td>\n};
print qq {<td>$line->{page}</td>\n};
+ print qq {<td>$line->{title_id}</td>\n};
print qq {<td>$line->{title}</td>\n};
print qq {<td>$line->{part}</td>\n};
print qq {<td>$line->{genre}</td>\n};
print qq {<td>$line->{startpage}</td>\n};
print qq {<td>$line->{endpage}</td>\n};
- #print qq {<td>$line->{showpagediff}</td>\n};
+ print qq {<td>$line->{showpagediff}</td>\n};
#print qq {<td>$line->{indexpage}</td>\n};
print qq {</tr>\n};
}