From f4de6ea4949d8f89f8ff8c3fb51fe3a9c47b35ff Mon Sep 17 00:00:00 2001 From: josch Date: Mon, 22 Oct 2007 20:50:45 +0000 Subject: [PATCH] comments completely usable git-svn-id: http://yolanda.mister-muffin.de/svn@125 7eef14d0-6ed0-489d-bf55-20463b2d70db --- trunk/init_sql.pl | 2 +- trunk/video.pl | 14 +++++++++++++- trunk/xsl/xhtml.xsl | 13 +++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/trunk/init_sql.pl b/trunk/init_sql.pl index bcb0580..a45a85a 100644 --- a/trunk/init_sql.pl +++ b/trunk/init_sql.pl @@ -142,7 +142,7 @@ $dbh->do(qq{create table id int auto_increment not null, userid int not null, videoid int not null, - message varchar(255) not null, + text varchar(255) not null, primary key (id) ) }) or die $dbh->errstr; diff --git a/trunk/video.pl b/trunk/video.pl index 4880405..8d65d46 100644 --- a/trunk/video.pl +++ b/trunk/video.pl @@ -70,7 +70,7 @@ if($query->param('title') or $query->param('id')) #check if a comment is about to be created and the user is logged in if($query->param('comment') and $userid = get_userid_from_sid($session->id)) { - $dbh->do(qq{insert into comments (userid, videoid, message) values (?, ?, ?)}, undef, $userid, $id, $query->param('comment')) or die $dbh->errstr; + $dbh->do(qq{insert into comments (userid, videoid, text) values (?, ?, ?)}, undef, $userid, $id, $query->param('comment')) or die $dbh->errstr; } #if referer is not the local site update referer table @@ -127,6 +127,18 @@ if($query->param('title') or $query->param('id')) } } }; + + #get comments + $sth = $dbh->prepare(qq{select comments.text, users.username from comments, users where + comments.videoid=? and users.id=comments.userid}); + $sth->execute($id); + while (my ($text, $username) = $sth->fetchrow_array()) + { + push @{ $page->{'comments'}->{'comment'} }, { + 'text' => decode_utf8($text), + 'user' => $username + }; + } } else { diff --git a/trunk/xsl/xhtml.xsl b/trunk/xsl/xhtml.xsl index 9708f23..66476ec 100755 --- a/trunk/xsl/xhtml.xsl +++ b/trunk/xsl/xhtml.xsl @@ -501,6 +501,19 @@ + + + + + + + + +
+ + + +