diff --git a/trunk/account.pl b/trunk/account.pl index 155c142..8c6c232 100644 --- a/trunk/account.pl +++ b/trunk/account.pl @@ -7,18 +7,11 @@ CGI::Session->name($session_name); $query = new CGI; $session = new CGI::Session; -$username = get_username_from_sid($session->id); +@userinfo = get_userinfo_from_sid($session->id); -%page = (); - -$page->{'username'} = $username; -$page->{'locale'} = $locale; -$page->{'stylesheet'} = $stylesheet; -$page->{'xmlns:dc'} = $xmlns_dc; -$page->{'xmlns:cc'} = $xmlns_cc; -$page->{'xmlns:rdf'} = $xmlns_rdf; +@page = get_page_array(@userinfo); -if($username) +if($userinfo->{'username'}) { if($query->param('show') eq 'settings') { @@ -113,7 +106,7 @@ if($username) 'thumbnail' => $duration == 0 ? "/images/tango/video-x-generic.png" : "/video-stills/$id", 'duration' => $duration, 'viewcount' => $viewcount, - 'edit' => $username eq $publisher ? "true" : "false", + 'edit' => $userinfo->{'username'} eq $publisher ? "true" : "false", 'rdf:RDF' => { 'cc:Work' => diff --git a/trunk/download.pl b/trunk/download.pl index da7a7a9..58324e4 100644 --- a/trunk/download.pl +++ b/trunk/download.pl @@ -67,15 +67,9 @@ if($query->param('id')) } else { - #there is no video with this id - %page = (); - - $page->{'username'} = get_username_from_sid($session->id); - $page->{'locale'} = $locale; - $page->{'stylesheet'} = $stylesheet; - $page->{'xmlns:dc'} = $xmlns_dc; - $page->{'xmlns:cc'} = $xmlns_cc; - $page->{'xmlns:rdf'} = $xmlns_rdf; + @userinfo = get_userinfo_from_sid($session->id); + + @page = get_page_array(@userinfo); $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = "error_202c"; @@ -92,15 +86,9 @@ if($query->param('id')) } else { - %page = (); - - #if a username is associated with session id, username is nonempty - $page->{'username'} = get_username_from_sid($session->id); - $page->{'locale'} = $locale; - $page->{'stylesheet'} = $stylesheet; - $page->{'xmlns:dc'} = $xmlns_dc; - $page->{'xmlns:cc'} = $xmlns_cc; - $page->{'xmlns:rdf'} = $xmlns_rdf; + @userinfo = get_userinfo_from_sid($session->id); + + @page = get_page_array(@userinfo); $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = "error_202c"; diff --git a/trunk/functions.pl b/trunk/functions.pl index 496b731..b72450e 100644 --- a/trunk/functions.pl +++ b/trunk/functions.pl @@ -27,8 +27,7 @@ sub fill_tagcloud $dbh->disconnect() or die $dbh->errstr; } -#return a username from passed session id -sub get_username_from_sid +sub get_userinfo_from_sid { #get parameters my ($sid) = @_; @@ -37,13 +36,13 @@ sub get_username_from_sid my $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass) or die $dbh->errstr; #prepare query - my $sth = $dbh->prepare(qq{select username from users where sid = ?}) or die $dbh->errstr; + my $sth = $dbh->prepare(qq{select id, username, locale, pagesize, cortado from users where sid = ?}) or die $dbh->errstr; #execute it $sth->execute($sid) or die $dbh->errstr; #save the resulting username - my ($username) = $sth->fetchrow_array(); + ($userinfo->{'id'}, $userinfo->{'username'}, $userinfo->{'locale'}, $userinfo->{'pagesize'}, $userinfo->{'cortado'}) = $sth->fetchrow_array(); #finish query $sth->finish() or die $dbh->errstr; @@ -52,33 +51,27 @@ sub get_username_from_sid $dbh->disconnect() or die $dbh->errstr; #return - return $username; + return @userinfo; } -#return a username from passed session id -sub get_userid_from_sid +sub get_page_array { #get parameters - my ($sid) = @_; + my (@userinfo) = @_; - #connect to db - my $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass) or die $dbh->errstr; - - #prepare query - my $sth = $dbh->prepare(qq{select id from users where sid = ?}) or die $dbh->errstr; - - #execute it - $sth->execute($sid) or die $dbh->errstr; - - #save the resulting username - my ($username) = $sth->fetchrow_array(); - - #finish query - $sth->finish() or die $dbh->errstr; - - #close db - $dbh->disconnect() or die $dbh->errstr; - - #return - return $username; + $page->{'username'} = $userinfo->{'username'}; + #if user is logged in, use his locale setting + if($userinfo->{'locale'}) + { + $page->{'locale'} = $userinfo->{'locale'}; + } + #else get the locale from the http server variable + else + { + ($page->{'locale'}) = $query->http('HTTP_ACCEPT_LANGUAGE') =~ /^([^,]+),.*$/; + } + $page->{stylesheet} = $stylesheet; + $page->{'xmlns:dc'} = $xmlns_dc; + $page->{'xmlns:cc'} = $xmlns_cc; + $page->{'xmlns:rdf'} = $xmlns_rdf; } diff --git a/trunk/images/yolanda-big.png b/trunk/images/yolanda-big.png index cf98766..1bddbb6 100644 Binary files a/trunk/images/yolanda-big.png and b/trunk/images/yolanda-big.png differ diff --git a/trunk/images/yolanda.svg b/trunk/images/yolanda.svg index 456e207..28e385e 100644 --- a/trunk/images/yolanda.svg +++ b/trunk/images/yolanda.svg @@ -176,7 +176,9 @@ x="452.15411" y="450.49475" id="text7102" - transform="scale(1.0438982,0.9579479)">name($session_name); $query = new CGI; my $session = new CGI::Session; -%page = (); +@userinfo = get_userinfo_from_sid($session->id); -#if a username is associated with session id, username is nonempty -$page->{username} = get_username_from_sid($session->id); -$page->{locale} = $locale; -$page->{stylesheet} = $stylesheet; -$page->{frontpage} = ['']; +@page = get_page_array(@userinfo); + +$page->{frontpage} = ['']; if($query->param('information')) { diff --git a/trunk/locale/en-US.xml b/trunk/locale/en-US.xml deleted file mode 100755 index a806752..0000000 --- a/trunk/locale/en-US.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - | - - - to upload videos, log in first. - - register - login - login with OpenID - - upload video - bookmarks - account details - - logged in as - logout - - - © 2007 GNUtube team - license - download source code - - - Find - Instant Access - - latest additions - most downloads - best rated - - - Error 202c - Access forbidden by government. - You did not supply a file. - You did not supply a title. - You did not supply a creator. - You did not supply any keywords. - You did not supply a description. - You did not supply a publisher. - You did not supply a title. - You did not supply a source. - You did not supply a language. - You did not supply a coverage. - You did not supply a rights holder. - You seem to be already registered. Please log out to create a new account. - You seem to be already logged in. Please log out to log in again. - Username and password do not match. - - - - - - You are now logged in. - You are now logged out. - To put the video into context, additional metainformation is needed. - - Your comment has been created. - You successfully created yourself an account - You succcessfully uploaded your file - - - - - results for query - ordered by - ascending - descending - results on - pages - relevance - duration - filesize - viewcount - downloadcount - timestamp - - - search - - - username - password - register - login - - - file - next page - upload - Specify the file you want to upload. - State the title of the video. - Specify the creator of the video. - State some keywords, separated by commas. - Describe the video in natural language. - Specify the source, preferably by URL. - State the language of the video. - Specify the time and location covered. - This is page 1 of 3. - This is page 2 of 3. - This is page 3 of 3. - - - download video - license conditions - Flamewar area below. Proceed with Caution. - post comment - - - title - author - subject - description - uploader - contributor - date - source - language - coverage - righs holder - - duration - viewcount - - - - diff --git a/trunk/login.pl b/trunk/login.pl index 44ff9e7..8a4e21e 100644 --- a/trunk/login.pl +++ b/trunk/login.pl @@ -7,16 +7,9 @@ CGI::Session->name($session_name); $query = new CGI; $session = new CGI::Session; -$username = get_username_from_sid($session->id); +@userinfo = get_userinfo_from_sid($session->id); -%page = (); - -$page->{'username'} = $username; -$page->{'locale'} = $locale; -$page->{'stylesheet'} = $stylesheet; -$page->{'xmlns:dc'} = $xmlns_dc; -$page->{'xmlns:cc'} = $xmlns_cc; -$page->{'xmlns:rdf'} = $xmlns_rdf; +@page = get_page_array(@userinfo); #check if action is set if($query->param('action')) @@ -28,12 +21,12 @@ if($query->param('action')) { #if logout is requested #remove sid from database - $dbh->do(qq{update users set sid = '' where username = ?}, undef, get_username_from_sid($session->id)) or die $dbh->errstr; + $dbh->do(qq{update users set sid = '' where id = ?}, undef, $userinfo->{'id'}) or die $dbh->errstr; $session->delete(); print $query->redirect("index.pl?information=information_logged_out"); } #check if user is logged in - elsif($username) + elsif($userinfo->{'username'}) { $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = "error_already_logged_in"; @@ -169,7 +162,7 @@ if($query->param('action')) $dbh->disconnect(); } #check if user is logged in -elsif($username) +elsif($userinfo->{'username'}) { $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = "error_already_logged_in"; diff --git a/trunk/register.pl b/trunk/register.pl index 390f81b..cadcbe7 100644 --- a/trunk/register.pl +++ b/trunk/register.pl @@ -7,16 +7,9 @@ CGI::Session->name($session_name); $query = new CGI; $session = new CGI::Session; -$username = get_username_from_sid($session->id); +@userinfo = get_userinfo_from_sid($session->id); -%page = (); - -$page->{'username'} = $username; -($page->{'locale'}) = $query->http('HTTP_ACCEPT_LANGUAGE') =~ /^([^,]+),.*$/; -$page->{'stylesheet'} = $stylesheet; -$page->{'xmlns:dc'} = $xmlns_dc; -$page->{'xmlns:cc'} = $xmlns_cc; -$page->{'xmlns:rdf'} = $xmlns_rdf; +@page = get_page_array(@userinfo); #check if user is logged in if($username) @@ -50,19 +43,19 @@ elsif($query->param('user') and $query->param('pass') and $query->param('pass_re $page->{'message'}->{'text'} = "error_passwords_do_not_match"; } } -elsif(not $query->param('user')) +elsif(not $query->param('user') and ($query->param('pass') or $query->param('pass_repeat'))) { $page->{'registerform'} = ['']; $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = "error_insert_username"; } -elsif(not $query->param('pass')) +elsif(not $query->param('pass') and ($query->param('user') or $query->param('pass_repeat'))) { $page->{'registerform'} = ['']; $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = "error_insert_password"; } -elsif(not $query->param('pass_repeat')) +elsif(not $query->param('pass_repeat') and ($query->param('user') or $query->param('pass'))) { $page->{'registerform'} = ['']; $page->{'message'}->{'type'} = "error"; diff --git a/trunk/search.pl b/trunk/search.pl index cd1835c..56d6356 100644 --- a/trunk/search.pl +++ b/trunk/search.pl @@ -6,16 +6,9 @@ CGI::Session->name($session_name); $query = new CGI; $session = new CGI::Session; -$username = get_username_from_sid($session->id); +@userinfo = get_userinfo_from_sid($session->id); -%page = (); - -$page->{'username'} = $username; -$page->{'locale'} = $locale; -$page->{'stylesheet'} = $stylesheet; -$page->{'xmlns:dc'} = $xmlns_dc; -$page->{'xmlns:cc'} = $xmlns_cc; -$page->{'xmlns:rdf'} = $xmlns_rdf; +@page = get_page_array(@userinfo); #check if query is set if($query->param('query') or $query->param('orderby')) @@ -111,7 +104,7 @@ if($query->param('query') or $query->param('orderby')) $page->{'results'}->{'lastpage'} = $lastpage; $page->{'results'}->{'currentpage'} = $currentpage; - $page->{'results'}->{'resultcount'} = $resultcount; + $page->{'results'}->{'resultcount'} = $resultcount eq '0E0' ? 0 : $resultcount; $page->{'results'}->{'pagesize'} = $pagesize; #get every returned value @@ -123,7 +116,7 @@ if($query->param('query') or $query->param('orderby')) 'thumbnail' => "./video-stills/$id", 'duration' => $duration, 'viewcount' => $viewcount, - 'edit' => $username eq $publisher ? "true" : "false", + 'edit' => $userinfo->{'username'} eq $publisher ? "true" : "false", 'rdf:RDF' => { 'cc:Work' => diff --git a/trunk/upload.pl b/trunk/upload.pl index f215d8a..2bc9fd2 100644 --- a/trunk/upload.pl +++ b/trunk/upload.pl @@ -6,21 +6,13 @@ require "functions.pl"; CGI::Session->name($session_name); my $session = new CGI::Session; -my $username = get_username_from_sid($session->id); +@userinfo = get_userinfo_from_sid($session->id); -%page = (); +@page = get_page_array(@userinfo); -#if a username is associated with session id, username is nonempty -$page->{'username'} = $username; -$page->{'locale'} = $locale; -$page->{'stylesheet'} = $stylesheet; -$page->{'xmlns:dc'} = $xmlns_dc; -$page->{'xmlns:cc'} = $xmlns_cc; -$page->{'xmlns:rdf'} = $xmlns_rdf; - -if($username) +if($userinfo->{'username'}) { - $page->{uploadform} = {'page' => '2'}; + $page->{uploadform} = {'page' => '1'}; } else { diff --git a/trunk/uploader.pl b/trunk/uploader.pl index 6ef7583..f5fca25 100644 --- a/trunk/uploader.pl +++ b/trunk/uploader.pl @@ -18,19 +18,11 @@ sub hook #close TEMP; } -my $userid = get_userid_from_sid($session->id); +@userinfo = get_userinfo_from_sid($session->id); -%page = (); - -#if a username is associated with session id, username is nonempty -$page->{'username'} = get_username_from_sid($session->id); -$page->{'locale'} = $locale; -$page->{'stylesheet'} = $stylesheet; -$page->{'xmlns:dc'} = $xmlns_dc; -$page->{'xmlns:cc'} = $xmlns_cc; -$page->{'xmlns:rdf'} = $xmlns_rdf; +@page = get_page_array(@userinfo); -if($userid) +if($userinfo->{'id'}) { #connect to db my $dbh = DBI->connect("DBI:mysql:$database:$host", $dbuser, $dbpass) or die $dbh->errstr; @@ -40,7 +32,7 @@ if($userid) $dbh->do(qq{insert into uploaded (title, description, userid, timestamp, creator, subject, contributor, source, language, coverage, rights) values ( ?, ?, ?, unix_timestamp(), ?, ?, ?, ?, ?, ?, ? )}, undef, - $query->param("DC.Title"), $query->param("DC.Description"), $userid, + $query->param("DC.Title"), $query->param("DC.Description"), $userinfo->{'id'}, $query->param("DC.Creator"), $query->param("DC.Subject"), '', $query->param("DC.Source"), $query->param("DC.Language"), $query->param("DC.Coverage"), '') or die $dbh->errstr; diff --git a/trunk/video.pl b/trunk/video.pl index 4f7f9ec..f5af415 100644 --- a/trunk/video.pl +++ b/trunk/video.pl @@ -6,15 +6,9 @@ CGI::Session->name($session_name); $query = new CGI; $session = new CGI::Session; -%page = (); +@userinfo = get_userinfo_from_sid($session->id); -#if a username is associated with session id, username is nonempty -$page->{'username'} = get_username_from_sid($session->id); -$page->{'locale'} = $locale; -$page->{'stylesheet'} = $stylesheet; -$page->{'xmlns:dc'} = $xmlns_dc; -$page->{'xmlns:cc'} = $xmlns_cc; -$page->{'xmlns:rdf'} = $xmlns_rdf; +@page = get_page_array(@userinfo); if($query->url_param('edit') eq 'true' and $query->url_param('id')) { @@ -79,7 +73,7 @@ elsif($query->url_param('title') or $query->url_param('id')) $sth->finish() or die $dbh->errstr; #if user is logged in - if($userid = get_userid_from_sid($session->id)) + if($userinfo->{'username'}) { #check if a comment is about to be created if($query->param('comment')) @@ -89,7 +83,8 @@ elsif($query->url_param('title') or $query->url_param('id')) $page->{'message'}->{'text'} = "information_comment_created"; #add to database - $dbh->do(qq{insert into comments (userid, videoid, text, timestamp) values (?, ?, ?, unix_timestamp())}, undef, $userid, $id, $query->param('comment')) or die $dbh->errstr; + $dbh->do(qq{insert into comments (userid, videoid, text, timestamp) values (?, ?, ?, unix_timestamp())}, undef, + $userinfo->{'id'}, $id, $query->param('comment')) or die $dbh->errstr; } } diff --git a/trunk/xsl/xhtml.xsl b/trunk/xsl/xhtml.xsl index ae4db16..70644d0 100755 --- a/trunk/xsl/xhtml.xsl +++ b/trunk/xsl/xhtml.xsl @@ -144,7 +144,11 @@
- + + + + + @@ -323,9 +327,6 @@ - - -
@@ -358,9 +359,6 @@ - - -
@@ -427,13 +425,10 @@ - - -
- + @@ -464,7 +459,7 @@ - +
diff --git a/trunk/xsl/xhtml/results.xsl b/trunk/xsl/xhtml/results.xsl index b588e74..58a782d 100644 --- a/trunk/xsl/xhtml/results.xsl +++ b/trunk/xsl/xhtml/results.xsl @@ -7,8 +7,6 @@ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" > - -
diff --git a/trunk/xsl/xhtml/video.xsl b/trunk/xsl/xhtml/video.xsl index d964eb4..d88a6f3 100644 --- a/trunk/xsl/xhtml/video.xsl +++ b/trunk/xsl/xhtml/video.xsl @@ -8,9 +8,6 @@ > - - -