diff --git a/trunk/AUTHORS b/trunk/AUTHORS index f116149..83b7995 100644 --- a/trunk/AUTHORS +++ b/trunk/AUTHORS @@ -1,2 +1,2 @@ Nils Dagsson Moskopp (erlehmann) -Johannes Schauer (Josch) +Johannes Schauer (josch) diff --git a/trunk/account.pl b/trunk/account.pl index d880596..cee165f 100644 --- a/trunk/account.pl +++ b/trunk/account.pl @@ -7,6 +7,16 @@ $session = new CGI::Session; @userinfo = get_userinfo_from_sid($session->id); +if($userinfo->{'username'}) +{ + if($query->param('show') eq 'settings' and $query->param('submit')) + { + $dbh->do(qq{update users set locale = ?, pagesize = ?, cortado = ? where id = ?}, undef, $query->param('locale'), $query->param('pagesize'), $query->param('cortado'), $userinfo->{'id'} ) or die $dbh->errstr; + } +} + +@userinfo = get_userinfo_from_sid($session->id); + @page = get_page_array(@userinfo); if($userinfo->{'username'}) @@ -14,9 +24,9 @@ if($userinfo->{'username'}) if($query->param('show') eq 'settings') { $page->{'account'}->{'show'} = 'settings'; - #results per page - #language - #cortado or plugin + $page->{'account'}->{'locale'} = $userinfo->{'locale'}; + $page->{'account'}->{'pagesize'} = $userinfo->{'pagesize'}; + $page->{'account'}->{'cortado'} = $userinfo->{'cortado'} } elsif($query->param('show') eq 'bookmarks') { diff --git a/trunk/daemon.pl b/trunk/daemon.pl index 1f95a16..df4a50b 100755 --- a/trunk/daemon.pl +++ b/trunk/daemon.pl @@ -130,19 +130,17 @@ while(1) $thumbnailsec = int($duration/3 + .5); #the width/height calculation could of course be much shorter but less readable then - $tnmaxwidth = 160; - $tnmaxheight = 120 - $tnwidth = $tnmaxwidth; - $tnheight = int($tnwidth*($height/$width)/2 + .5)*2; - if($tnheight > $tnmaxheight) - { - $tnheight = $tnmaxheight; - $tnwidth = int($tnheight*($width/$height)/2 + .5)*2; - } + #all thumbs have equal height + $tnmaxheight = 120; + $tnheight = $tnmaxheight; + $tnwidth = int($tnheight*($width/$height)/2 + .5)*2; + system "ffmpeg -i $root/tmp/$id -vcodec mjpeg -vframes 1 -an -f rawvideo -ss $thumbnailsec -s ".$tnwidth."x$tnheight $root/video-stills/$id"; - #check if the upload already is in the right format - if ($container eq 'ogg' and $video eq 'theora' and $audio eq 'vorbis') + $vmaxheight = 240; + + #check if the upload already is in the right format and smaller/equal max-width/height + if ($container eq 'ogg' and $video eq 'theora' and $audio eq 'vorbis' and $height <= $vmaxheight) { appendlog $id, "file already is ogg-theora/vorbis"; @@ -158,16 +156,20 @@ while(1) } else #encode video { + #calculate video width + $vheight = $vmaxheight <= $height ? $vmaxheight : $height; + $vwidth = int($vheight*($width/$height)/2 + .5)*2; + #TODO: addmetadata information - system "ffmpeg2theora --optimize --videobitrate 1000 --audiobitrate 64 --sharpness 0 --output $root/videos/$id $root/tmp/$id 2>&1"; - appendlog $id, $audio, $video, $width, $height, $fps, $duration, $sha; + system "ffmpeg2theora --optimize --videobitrate 1000 --audiobitrate 64 --sharpness 0 --width $vwidth --height $vheight --output $root/videos/$id $root/tmp/$id 2>&1"; + appendlog $id, $audio, $video, $vwidth, $vheight, $fps, $duration, $sha; #add video to videos table $dbh->do(qq{insert into videos select id, title, description, userid, timestamp, creator, subject, contributor, source, language, coverage, rights, license, notice, derivativeworks, sharealike, commercialuse, ?, ?, ?, ?, ?, ?, 0, 0 - from uploaded where id = ?}, undef, $filesize, $duration, $width, - $height, $fps, $sha, $id) or interrupt $dbh->errstr; + from uploaded where id = ?}, undef, $filesize, $duration, $vwidth, + $vheight, $fps, $sha, $id) or interrupt $dbh->errstr; #delete temp file unlink "$root/tmp/$id"; diff --git a/trunk/download.pl b/trunk/download.pl index 3b48fcb..287607b 100644 --- a/trunk/download.pl +++ b/trunk/download.pl @@ -8,9 +8,6 @@ $session = new CGI::Session; #do we have an id? if($query->param('id')) { - #connect to db - $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass); - #check if video with requested id is in the database my $sth = $dbh->prepare(qq{select title from videos where id = ? }); $sth->execute($query->param('id')); @@ -19,8 +16,7 @@ if($query->param('id')) { #if referer is not the local site update referer table $referer = $query->referer() or $referer = ''; - $server_name = $query->server_name(); - if($referer !~ /^\w+:\/\/$server_name/) + if($referer !~ /^$domain/) { #check if already in database $sth = $dbh->prepare(qq{select 1 from referer where videoid = ? and referer = ? }) or die $dbh->errstr; @@ -78,9 +74,6 @@ if($query->param('id')) #print xml print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page'); } - - #disconnect db - $dbh->disconnect(); } else { diff --git a/trunk/functions.pl b/trunk/functions.pl index c3f6665..65f5cb8 100644 --- a/trunk/functions.pl +++ b/trunk/functions.pl @@ -5,9 +5,6 @@ sub get_userinfo_from_sid #get parameters my ($sid) = @_; - #connect to db - my $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass); - #prepare query my $sth = $dbh->prepare(qq{select id, username, locale, pagesize, cortado from users where sid = ?}) or die $dbh->errstr; @@ -20,9 +17,6 @@ sub get_userinfo_from_sid #finish query $sth->finish() or die $dbh->errstr; - #close db - $dbh->disconnect() or die $dbh->errstr; - #return return @userinfo; } @@ -43,7 +37,7 @@ sub get_page_array { ($page->{'locale'}) = $query->http('HTTP_ACCEPT_LANGUAGE') =~ /^([^,]+),.*$/; } - $page->{stylesheet} = $stylesheet; + $page->{'stylesheet'} = $stylesheet; $page->{'xmlns:dc'} = $xmlns_dc; $page->{'xmlns:cc'} = $xmlns_cc; $page->{'xmlns:rdf'} = $xmlns_rdf; @@ -54,16 +48,13 @@ sub get_page_array # and account.pl (display own videos) sub fill_results { - #connect to db - my $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass); - #prepare query my $sth = $dbh->prepare($dbquery) or die $dbh->errstr; #execute it $resultcount = $sth->execute(@_) or die $dbh->errstr; - $pagesize = $query->param('pagesize') or $pagesize = 5; + $pagesize = $query->param('pagesize') or $pagesize = $userinfo->{'pagesize'} or $pagesize = 5; #rediculous but funny round up, will fail with 100000000000000 results per page #on 0.0000000000001% of all queries - this is a risk we can handle @@ -84,6 +75,12 @@ sub fill_results $page->{'results'}->{'resultcount'} = $resultcount eq '0E0' ? 0 : $resultcount; $page->{'results'}->{'pagesize'} = $pagesize; + if($resultcount eq '0E0') + { + $page->{'message'}->{'type'} = "information"; + $page->{'message'}->{'text'} = "information_no_results"; + } + #get every returned value while (my ($id, $title, $description, $publisher, $timestamp, $creator, $subject, $contributor, $source, $language, $coverage, $rights, @@ -126,9 +123,6 @@ sub fill_results #finish query $sth->finish() or die $dbh->errstr; - - #close db - $dbh->disconnect() or die $dbh->errstr; } #replace chars in url as said in this rfc: http://www.rfc-editor.org/rfc/rfc1738.txt diff --git a/trunk/include.pl b/trunk/include.pl index 871a8e0..7f11292 100644 --- a/trunk/include.pl +++ b/trunk/include.pl @@ -26,5 +26,5 @@ $stylesheet = "/style/default.css"; $xmlns_dc = "http://purl.org/dc/elements/1.1/"; $xmlns_cc = "http://web.resource.org/cc/"; $xmlns_rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; - +$dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass); 1; diff --git a/trunk/index.pl b/trunk/index.pl index e63c54a..0b9126c 100644 --- a/trunk/index.pl +++ b/trunk/index.pl @@ -24,8 +24,6 @@ elsif($query->param('error')) $page->{'message'}->{'text'} = $query->param('error'); } -#connect to db -my $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass); #prepare query my $sth = $dbh->prepare(qq{select text, count from tagcloud }) or die $dbh->errstr; @@ -51,4 +49,3 @@ print $session->header(-type=>'text/xml', -charset=>'UTF-8'); #print xml print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); - diff --git a/trunk/init_sql.pl b/trunk/init_sql.pl index 42c8457..e817e9f 100644 --- a/trunk/init_sql.pl +++ b/trunk/init_sql.pl @@ -2,8 +2,6 @@ CGI::Session->name($session_name); my $session = new CGI::Session; -my $dbh = DBI->connect("DBI:mysql:$database:$host", $dbuser, $dbpass) or die $dbh->errstr; - $dbh->do(qq{drop table config}); $dbh->do(qq{drop table users}); @@ -149,7 +147,5 @@ $dbh->do(qq{create table ) }) or die $dbh->errstr; -$dbh->disconnect() or die $dbh->errstr; - print $session->header(); print "initiated database"; diff --git a/trunk/locale/en-us.xml b/trunk/locale/en-us.xml index 5c759ad..c0479f1 100755 --- a/trunk/locale/en-us.xml +++ b/trunk/locale/en-us.xml @@ -54,7 +54,6 @@ Please insert a username. Please insert a password. Please repeat your password. - There are no results satisfying your query. @@ -65,6 +64,7 @@ Your comment has been submitted. Your account has been created. Your file has been uploaded. + There are no results satisfying your query. @@ -181,6 +181,9 @@ my uploads edit my settings my bookmarks + locale + pagesize + cortado diff --git a/trunk/login.pl b/trunk/login.pl index 2933514..2eb097d 100644 --- a/trunk/login.pl +++ b/trunk/login.pl @@ -12,9 +12,6 @@ $session = new CGI::Session; #check if action is set if($query->param('action')) { - #connect to db - $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass); - if($query->param('action') eq "logout") { #if logout is requested @@ -155,9 +152,6 @@ if($query->param('action')) print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); } - - #disconnect db - $dbh->disconnect(); } #check if user is logged in elsif($userinfo->{'username'}) diff --git a/trunk/register.pl b/trunk/register.pl index 2d454a6..718f357 100644 --- a/trunk/register.pl +++ b/trunk/register.pl @@ -25,15 +25,9 @@ elsif($query->param('user') and $query->param('pass') and $query->param('pass_re { if($query->param('pass') eq $query->param('pass_repeat')) { - #connect to db - my $dbh = DBI->connect("DBI:mysql:$database:$host", $dbuser, $dbpass) or die $dbh->errstr; - #do query $dbh->do(qq{insert into users (username, password, timestamp, locale) values ( ?, password( ? ), unix_timestamp(), ?)}, undef, $query->param("user"), $query->param("pass"), $page->{'locale'}) or die $dbh->errstr; - - #disconnect db - $dbh->disconnect() or die $dbh->errstr; print $query->redirect("index.pl?information=information_registered"); } diff --git a/trunk/search.pl b/trunk/search.pl index 608c8bb..844bbd1 100644 --- a/trunk/search.pl +++ b/trunk/search.pl @@ -12,6 +12,8 @@ $session = new CGI::Session; #check if query is set if($query->param('query') or $query->param('orderby')) { + #TODO: clean up scriptname, argument, value only being there because of + #TODO: account.pl also calling fill_results() which will be changed $page->{'search'} = ['']; $page->{'results'}->{'scriptname'} = 'search.pl'; $page->{'results'}->{'argument'} = 'query'; diff --git a/trunk/site/main.xml b/trunk/site/main.xml index bdd8f99..ca6243a 100755 --- a/trunk/site/main.xml +++ b/trunk/site/main.xml @@ -12,7 +12,6 @@ /account.pl?show=settings /account.pl?show=uploads /account.pl?show=bookmarks - /login.pl /login.pl?action=openid /login.pl?action=logout diff --git a/trunk/uploader.pl b/trunk/uploader.pl index 58ed925..0e93def 100644 --- a/trunk/uploader.pl +++ b/trunk/uploader.pl @@ -22,9 +22,6 @@ sub hook if($userinfo->{'id'}&&$query->param("DC.Title") && $query->param("DC.Description") && $query->param("DC.Subject")) { - #connect to db - my $dbh = DBI->connect("DBI:mysql:$database:$host", $dbuser, $dbpass) or die $dbh->errstr; - #make new entry for video into the databse #FIXME: contributor, rights $dbh->do(qq{insert into uploaded (title, description, userid, timestamp, @@ -51,9 +48,6 @@ if($userinfo->{'id'}&&$query->param("DC.Title") && $query->param("DC.Description $page->{'message'}->{'type'} = "information"; $page->{'message'}->{'text'} = "information_uploaded"; - - #disconnect db - $dbh->disconnect() or die $dbh->errstr; } else { diff --git a/trunk/video.pl b/trunk/video.pl index 181cb8d..fd2eb88 100644 --- a/trunk/video.pl +++ b/trunk/video.pl @@ -20,9 +20,6 @@ if($query->url_param('action') eq 'bookmark' and $query->url_param('id')) #check if id or title is passed elsif($query->url_param('title') or $query->url_param('id')) { - #connect to db - my $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass) or die $dbh->errstr; - if($query->url_param('id')) { #if id is passed ignore title and check for the id @@ -103,8 +100,7 @@ elsif($query->url_param('title') or $query->url_param('id')) #if referer is not the local site update referer table $referer = $query->referer() or $referer = ''; - $server_name = $query->server_name(); - if($referer !~ /^\w+:\/\/$server_name/) + if($referer !~ /^$domain/) { #check if already in database $sth = $dbh->prepare(qq{select 1 from referer where videoid = ? and referer = ? }) or die $dbh->errstr; @@ -123,11 +119,32 @@ elsif($query->url_param('title') or $query->url_param('id')) } } + if($query->param('cortado') eq 'true') + { + $cortado = 'true'; + } + elsif($query->param('cortado') eq 'false') + { + $cortado = 'false' + } + elsif($userinfo->{'cortado'} = 1) + { + $cortado = 'true'; + } + elsif($userinfo->{'cortado'} = 0) + { + $cortado = 'false'; + } + else + { + $cortado = 'true'; + } + #before code cleanup, this was a really obfuscated array/hash creation push @{ $page->{'video'} }, { 'thumbnail' => "$domain/video-stills/$id", - 'cortado' => $query->param('cortado') eq 'false' ? "false" : "true", + 'cortado' => $cortado, 'filesize' => $filesize, 'duration' => $duration, 'width' => $width, @@ -202,9 +219,6 @@ elsif($query->url_param('title') or $query->url_param('id')) fill_results(@args); } - - #close db - $dbh->disconnect() or die $dbh->errstr; } else { diff --git a/trunk/xsl/xhtml.xsl b/trunk/xsl/xhtml.xsl index 659fa66..0d101c7 100755 --- a/trunk/xsl/xhtml.xsl +++ b/trunk/xsl/xhtml.xsl @@ -30,9 +30,7 @@ - - en-us - + en-us @@ -147,7 +145,7 @@ - + diff --git a/trunk/xsl/xhtml/account.xsl b/trunk/xsl/xhtml/account.xsl index d40d638..ffc7261 100644 --- a/trunk/xsl/xhtml/account.xsl +++ b/trunk/xsl/xhtml/account.xsl @@ -54,45 +54,132 @@ -

results

+

-

settings

-
+

+ + + + +
- locale +


- + +
- pagesize +


- + + + + + + +
- cortado - video plugin +

+ + + + checked + + + + +
+ + + + checked + + + +
- +
-

bookmarks

+

+

coming soon...

+ +

+
diff --git a/trunk/xsl/xhtml/results.xsl b/trunk/xsl/xhtml/results.xsl index 5cc9d61..10a9fac 100644 --- a/trunk/xsl/xhtml/results.xsl +++ b/trunk/xsl/xhtml/results.xsl @@ -47,6 +47,11 @@ + + +
@@ -142,6 +147,7 @@
+
diff --git a/trunk/xsl/xhtml/video.xsl b/trunk/xsl/xhtml/video.xsl index 9a97252..fccdfd0 100644 --- a/trunk/xsl/xhtml/video.xsl +++ b/trunk/xsl/xhtml/video.xsl @@ -90,10 +90,10 @@ - + - +