summaryrefslogtreecommitdiff
path: root/index.cgi
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2012-09-05 18:45:13 +0000
committerDimitri Sokolyuk <demon@dim13.org>2012-09-05 18:45:13 +0000
commite24ee07d2bed5982c07b91d3586ea54158a418b7 (patch)
tree14ca3914c4ff12eb6a782aedc85f261bb8cd9906 /index.cgi
parentd1e4715af64a1c38e6fbf3333ca01c3cbdc393c5 (diff)
html5 theme
Diffstat (limited to 'index.cgi')
-rwxr-xr-xindex.cgi17
1 files changed, 8 insertions, 9 deletions
diff --git a/index.cgi b/index.cgi
index 9c2321c..28a0737 100755
--- a/index.cgi
+++ b/index.cgi
@@ -43,6 +43,7 @@ $blog_url .= '/' unless ($blog_url =~ /^.*\/$/);
my $blog_owner = $Blogsum::Config::blog_owner;
my $blog_rights = $Blogsum::Config::blog_rights;
my $feed_updates = $Blogsum::Config::feed_updates;
+my $captcha_api_server = $Blogsum::Config::captcha_api_server;
my $captcha_pubkey = $Blogsum::Config::captcha_pubkey;
my $captcha_seckey = $Blogsum::Config::captcha_seckey;
my $comment_max_length = $Blogsum::Config::comment_max_length;
@@ -61,6 +62,7 @@ $page_not_found_error ||= '404 page not found';
# main execution #
###########################
my $cgi = CGI->new;
+$cgi->charset('UTF-8');
my $dbh = DBI->connect("DBI:SQLite:dbname=$database", '', '', { RaiseError => 1 }) || die $DBI::errstr;
my $template = HTML::Template->new(filename => "themes/${blog_theme}/index.tmpl", die_on_bad_params => 0);
if ($cgi->param('rss')) {
@@ -70,6 +72,7 @@ if ($cgi->param('rss')) {
my $articles = get_articles();
my $archives = get_archives();
my $tagcloud = get_tag_cloud();
+ my @status = ();
$template->param( archives => $archives );
$template->param( tagcloud => $tagcloud );
$template->param( theme => $blog_theme );
@@ -88,8 +91,9 @@ if ($cgi->param('rss')) {
}
} else {
$template->param( error => $page_not_found_error );
+ @status = ( -status => '404 Not Found' );
}
- print $cgi->header(), $template->output;
+ print $cgi->header(@status), $template->output;
}
$dbh->disconnect;
@@ -269,10 +273,7 @@ sub get_archives {
while (my $result = $sth->fetchrow_hashref) {
$result->{'date'} =~ /(\d{4})\-(\d{2})\-\d{2} \d{2}\:\d{2}\:\d{2}/;
($result->{'year'}, $result->{'month'}) = ($1, $2);
- my $title = my $full_title = $result->{'title'};
- if (length($title) > 28) {
- $title = substr($title, 0, 25) . '...';
- }
+ my $title = $result->{'title'};
if (($result->{'year'} eq $current_year) && ($result->{'month'} eq $current_month) && $result->{'uri'}) {
push(@{$history{$result->{'year'}}{$result->{'month'}}->{'uri_loop'}},
@@ -281,7 +282,6 @@ sub get_archives {
month => $result->{'month'},
month_name => $months{$result->{'month'}},
title => $title,
- full_title => $full_title,
uri => $result->{'uri'},
}
);
@@ -343,13 +343,12 @@ sub read_comment {
if ($result->{'success'}) {
# save comment
- my $comment = HTML::Entities::encode($cgi->param('comment'));
my $stmt = "INSERT INTO comments VALUES (NULL, ?, datetime('now', 'localtime'), ?, ?, ?, ?, 0)";
my $sth = $dbh->prepare($stmt);
my $comment_name = $cgi->param('name') ? substr($cgi->param('name'), 0, 100) : 'anonymous';
my $comment_email = $cgi->param('email') ? substr($cgi->param('email'), 0, 100) : undef;
my $comment_url = $cgi->param('url') ? substr($cgi->param('url'), 0, 100) : undef;
- my $comment_body = substr(HTML::Entities::encode($cgi->param('comment')), 0, $comment_max_length);
+ my $comment_body = substr(HTML::Entities::encode($cgi->param('comment'), "<>&"), 0, $comment_max_length);
$sth->execute($cgi->param('id'), $comment_name, $comment_email, $comment_url, $comment_body) || die $dbh->errstr;
$template->param( message => 'comment awaiting moderation, thank you' );
@@ -386,7 +385,7 @@ sub read_comment {
}
# present the challenge
- $template->param( captcha_api_server => 'http://api.recaptcha.net', captcha_pubkey => $captcha_pubkey );
+ $template->param( captcha_api_server => $captcha_api_server, captcha_pubkey => $captcha_pubkey );
}
sub verify_captcha {