diff --git a/trunk/account.pl b/trunk/account.pl
index 8c6c232..e4aeba6 100644
--- a/trunk/account.pl
+++ b/trunk/account.pl
@@ -15,26 +15,29 @@ if($userinfo->{'username'})
{
if($query->param('show') eq 'settings')
{
+ $page->{'account'}->{'show'} = 'settings';
#results per page
#language
#cortado or plugin
}
elsif($query->param('show') eq 'uploads')
{
+ $page->{'account'}->{'show'} = 'uploads';
$page->{'results'}->{'scriptname'} = 'account.pl';
$page->{'results'}->{'argument'} = 'show';
$page->{'results'}->{'value'} = 'uploads';
$page->{'results'}->{'orderby'} = $query->param('orderby');
$page->{'results'}->{'sort'} = $query->param('sort');
- #connect to db
- my $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass) or die $dbh->errstr;
-
#build mysql query
- $dbquery = "(select v.id, v.title, u.username, from_unixtime( v.timestamp ) as timestamp, v.duration, v.viewcount
+ $dbquery = "(select v.id, v.title, v.description, u.username, from_unixtime( v.timestamp ) as timestamp,
+ v.creator, v.subject, v.contributor, v.source, v.language, v.coverage, v.rights,
+ v.license, filesize, duration, width, height, fps, viewcount, downloadcount
from videos as v, users as u where v.userid = u.id and u.sid = ?)
union
- (select v.id, v.title, u.username, from_unixtime( v.timestamp ) as timestamp, 0, 0
+ (select v.id, v.title, '', u.username, from_unixtime( v.timestamp ) as timestamp,
+ v.creator, v.subject, v.contributor, v.source, v.language, v.coverage, v.rights,
+ v.license, 0, 0, 0, 0, 0, 0, 0
from uploaded as v, users as u where v.userid = u.id and u.sid = ?)";
if($query->param('orderby'))
@@ -70,65 +73,7 @@ if($userinfo->{'username'})
}
}
- #prepare query
- my $sth = $dbh->prepare($dbquery) or die $dbh->errstr;
-
- #execute it
- $resultcount = $sth->execute($session->id, $session->id) or die $dbh->errstr;
-
- $pagesize = 2;
-
- #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
- $lastpage = int($resultcount/$pagesize+0.99999999999999);
-
- $currentpage = $query->param('page') or $currentpage = 1;
-
- $dbquery .= " limit ".($currentpage-1)*$pagesize.", ".$pagesize;
-
- #prepare query
- $sth = $dbh->prepare($dbquery) or die $dbh->errstr;
-
- #execute it
- $sth->execute($session->id, $session->id) or die $dbquery;
-
- $page->{'results'}->{'lastpage'} = $lastpage;
- $page->{'results'}->{'currentpage'} = $currentpage;
- $page->{'results'}->{'resultcount'} = $resultcount;
- $page->{'results'}->{'pagesize'} = $pagesize;
-
- #get every returned value
- while (my ($id, $title, $publisher, $timestamp, $duration, $viewcount) = $sth->fetchrow_array())
- {
- #before code cleanup, this was a really obfuscated array/hash creation
- push @{ $page->{'results'}->{'result'} },
- {
- 'thumbnail' => $duration == 0 ? "/images/tango/video-x-generic.png" : "/video-stills/$id",
- 'duration' => $duration,
- 'viewcount' => $viewcount,
- 'edit' => $userinfo->{'username'} eq $publisher ? "true" : "false",
- 'rdf:RDF' =>
- {
- 'cc:Work' =>
- {
- 'dc:title' => [$title],
- 'dc:date' => [$timestamp],
- 'dc:identifier' => ["$domain/video/$title/$id" . ($duration == 0 ? "/edit=true" : "") ],
- 'dc:publisher' => [$publisher]
- },
- 'cc:License' =>
- {
- 'rdf:about' => 'http://creativecommons.org/licenses/GPL/2.0/'
- }
- }
- };
- }
-
- #finish query
- $sth->finish() or die $dbh->errstr;
-
- #close db
- $dbh->disconnect() or die $dbh->errstr;
+ fill_results($session->id, $session->id);
}
else
{
diff --git a/trunk/functions.pl b/trunk/functions.pl
index b72450e..736607a 100644
--- a/trunk/functions.pl
+++ b/trunk/functions.pl
@@ -75,3 +75,73 @@ sub get_page_array
$page->{'xmlns:cc'} = $xmlns_cc;
$page->{'xmlns:rdf'} = $xmlns_rdf;
}
+
+sub fill_results
+{
+ #connect to db
+ my $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass) or die $dbh->errstr;
+
+ #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;
+
+ #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
+ $lastpage = int($resultcount/$pagesize+0.99999999999999);
+
+ $currentpage = $query->param('page') or $currentpage = 1;
+
+ $dbquery .= " limit ".($currentpage-1)*$pagesize.", ".$pagesize;
+
+ #prepare query
+ $sth = $dbh->prepare($dbquery) or die $dbh->errstr;
+
+ #execute it
+ $sth->execute(@_) or die $dbquery;
+
+ $page->{'results'}->{'lastpage'} = $lastpage;
+ $page->{'results'}->{'currentpage'} = $currentpage;
+ $page->{'results'}->{'resultcount'} = $resultcount eq '0E0' ? 0 : $resultcount;
+ $page->{'results'}->{'pagesize'} = $pagesize;
+
+ #get every returned value
+ while (my ($id, $title, $description, $publisher, $timestamp, $creator, $subject,
+ $contributor, $source, $language, $coverage, $rights, $license,
+ $filesize, $duration, $width, $height, $fps, $viewcount, $downloadcount) = $sth->fetchrow_array())
+ {
+ #before code cleanup, this was a really obfuscated array/hash creation
+ push @{ $page->{'results'}->{'result'} },
+ {
+ 'thumbnail' => "./video-stills/$id",
+ 'duration' => $duration,
+ 'viewcount' => $viewcount,
+ 'edit' => $userinfo->{'username'} eq $publisher ? "true" : "false",
+ 'rdf:RDF' =>
+ {
+ 'cc:Work' =>
+ {
+ 'rdf:about' => "$domain/download/$id",
+ 'dc:title' => [$title],
+ 'dc:creator' => [$creator],
+ 'dc:date' => [$timestamp],
+ 'dc:identifier' => ["$domain/video/$title/$id"],
+ 'dc:publisher' => [$publisher]
+ },
+ 'cc:License' =>
+ {
+ 'rdf:about' => 'http://creativecommons.org/licenses/GPL/2.0/'
+ }
+ }
+ };
+ }
+
+ #finish query
+ $sth->finish() or die $dbh->errstr;
+
+ #close db
+ $dbh->disconnect() or die $dbh->errstr;
+}
diff --git a/trunk/locale/en-us.xml b/trunk/locale/en-us.xml
index 5e08dad..ffa1c0d 100755
--- a/trunk/locale/en-us.xml
+++ b/trunk/locale/en-us.xml
@@ -126,6 +126,13 @@
duration
viewcount
+
+
+ my uploads
+ edit my settings
+ my bookmarks
+
+
diff --git a/trunk/search.pl b/trunk/search.pl
index 56d6356..8aa1f17 100644
--- a/trunk/search.pl
+++ b/trunk/search.pl
@@ -13,19 +13,19 @@ $session = new CGI::Session;
#check if query is set
if($query->param('query') or $query->param('orderby'))
{
+ $page->{'search'} = [''];
$page->{'results'}->{'scriptname'} = 'search.pl';
$page->{'results'}->{'argument'} = 'query';
$page->{'results'}->{'value'} = $query->param('query');
$page->{'results'}->{'orderby'} = $query->param('orderby');
$page->{'results'}->{'sort'} = $query->param('sort');
- #connect to db
- my $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass) or die $dbh->errstr;
-
my @args = ();
#build mysql query
- $dbquery = "select v.id, v.title, v.creator, v.description, u.username, from_unixtime( v.timestamp ), v.duration, v.viewcount";
+ $dbquery = "select v.id, v.title, v.description, u.username, from_unixtime( v.timestamp ),
+ v.creator, v.subject, v.contributor, v.source, v.language, v.coverage, v.rights,
+ v.license, filesize, duration, width, height, fps, viewcount, downloadcount";
if($query->param('query'))
{
@@ -80,67 +80,7 @@ if($query->param('query') or $query->param('orderby'))
}
}
- #prepare query
- my $sth = $dbh->prepare($dbquery) or die $dbh->errstr;
-
- #execute it
- $resultcount = $sth->execute(@args) or die $dbh->errstr;
-
- $pagesize = $query->param('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
- $lastpage = int($resultcount/$pagesize+0.99999999999999);
-
- $currentpage = $query->param('page') or $currentpage = 1;
-
- $dbquery .= " limit ".($currentpage-1)*$pagesize.", ".$pagesize;
-
- #prepare query
- $sth = $dbh->prepare($dbquery) or die $dbh->errstr;
-
- #execute it
- $sth->execute(@args) or die $dbquery;
-
- $page->{'results'}->{'lastpage'} = $lastpage;
- $page->{'results'}->{'currentpage'} = $currentpage;
- $page->{'results'}->{'resultcount'} = $resultcount eq '0E0' ? 0 : $resultcount;
- $page->{'results'}->{'pagesize'} = $pagesize;
-
- #get every returned value
- while (my ($id, $title, $creator, $description, $publisher, $timestamp, $duration, $viewcount, $relevance) = $sth->fetchrow_array())
- {
- #before code cleanup, this was a really obfuscated array/hash creation
- push @{ $page->{'results'}->{'result'} },
- {
- 'thumbnail' => "./video-stills/$id",
- 'duration' => $duration,
- 'viewcount' => $viewcount,
- 'edit' => $userinfo->{'username'} eq $publisher ? "true" : "false",
- 'rdf:RDF' =>
- {
- 'cc:Work' =>
- {
- 'rdf:about' => "$domain/download/$id",
- 'dc:title' => [$title],
- 'dc:creator' => [$creator],
- 'dc:date' => [$timestamp],
- 'dc:identifier' => ["$domain/video/$title/$id"],
- 'dc:publisher' => [$publisher]
- },
- 'cc:License' =>
- {
- 'rdf:about' => 'http://creativecommons.org/licenses/GPL/2.0/'
- }
- }
- };
- }
-
- #finish query
- $sth->finish() or die $dbh->errstr;
-
- #close db
- $dbh->disconnect() or die $dbh->errstr;
+ fill_results(@args);
}
else
{
diff --git a/trunk/site/gnutube.xml b/trunk/site/gnutube.xml
index 385b0e8..b5f87c0 100755
--- a/trunk/site/gnutube.xml
+++ b/trunk/site/gnutube.xml
@@ -12,6 +12,8 @@
-->
/account.pl
+ /account.pl?show=settings
+ /account.pl?show=uploads
/login.pl
/login.pl?action=openid
diff --git a/trunk/upload.pl b/trunk/upload.pl
index 2bc9fd2..52d25b8 100644
--- a/trunk/upload.pl
+++ b/trunk/upload.pl
@@ -4,6 +4,7 @@ require "functions.pl";
#create or resume session
CGI::Session->name($session_name);
+$query = new CGI;
my $session = new CGI::Session;
@userinfo = get_userinfo_from_sid($session->id);
diff --git a/trunk/video.pl b/trunk/video.pl
index f5af415..0e41186 100644
--- a/trunk/video.pl
+++ b/trunk/video.pl
@@ -23,35 +23,42 @@ elsif($query->url_param('title') or $query->url_param('id'))
if($query->url_param('id'))
{
#if id is passed ignore title and check for the id
- $sth = $dbh->prepare(qq{select v.id, v.title, v.description, u.username, from_unixtime( v.timestamp ),
+ $dbquery = "select v.id, v.title, v.description, u.username, from_unixtime( v.timestamp ),
v.creator, v.subject, v.contributor, v.source, v.language, v.coverage, v.rights,
- v.license, filesize, duration, width, height, fps, viewcount,
- downloadcount
- from videos as v, users as u where v.id = ? and u.id=v.userid }) or die $dbh->errstr;
- $rowcount = $sth->execute($query->url_param('id')) or die $dbh->errstr;
+ v.license, filesize, duration, width, height, fps, viewcount, downloadcount
+ from videos as v, users as u where v.id = ? and u.id=v.userid";
+
+ @args = ($query->url_param('id'));
}
else
{
#if no id was passed there has to be a title we search for
- $sth = $dbh->prepare(qq{select v.id, v.title, v.description, u.username, from_unixtime( v.timestamp ),
+ $dbquery = "select v.id, v.title, v.description, u.username, from_unixtime( v.timestamp ),
v.creator, v.subject, v.contributor, v.source, v.language, v.coverage, v.rights,
- v.license, filesize, duration, width, height, fps, viewcount,
- downloadcount
- from videos as v, users as u where v.title = ? and u.id=v.userid }) or die $dbh->errstr;
- $rowcount = $sth->execute($query->url_param('title')) or die $dbh->errstr;
+ v.license, filesize, duration, width, height, fps, viewcount, downloadcount
+ from videos as v, users as u where v.title = ? and u.id=v.userid";
+
+ @args = ($query->url_param('title'));
}
+ $sth = $dbh->prepare($dbquery);
+ $rowcount = $sth->execute(@args) or die $dbh->errstr;
+
#if the args are wrong there my be zero results
#if there was a title passed, then perform a search
if($rowcount == 0 and $query->url_param('title'))
{
- $sth = $dbh->prepare(qq{select v.id, v.title, v.description, u.username, from_unixtime( v.timestamp ),
+ $dbquery = "select v.id, v.title, v.description, u.username, from_unixtime( v.timestamp ),
v.creator, v.subject, v.contributor, v.source, v.language, v.coverage, v.rights,
- v.license, filesize, duration, width, height, fps, viewcount,
- downloadcount
- from videos as v, users as u where match(v.title, v.description, v.subject) against( ? )
- and u.id=v.userid }) or die $dbh->errstr;
- $rowcount = $sth->execute($query->url_param('title')) or die $dbh->errstr;
+ v.license, filesize, duration, width, height, fps, viewcount, downloadcount";
+ $dbquery .= ", match(v.title, v.description, v.subject) against( ? in boolean mode) as relevance";
+ $dbquery .= " from videos as v, users as u where u.id = v.userid";
+ $dbquery .= " and match(v.title, v.description, v.subject) against( ? in boolean mode)";
+
+ @args = ($query->url_param('title'));
+
+ $sth = $dbh->prepare($dbquery);
+ $rowcount = $sth->execute(@args) or die $dbh->errstr;
}
#from this point on, do not use $query->param('id') anymore - we do not know what was given
@@ -65,7 +72,7 @@ elsif($query->url_param('title') or $query->url_param('id'))
elsif($rowcount == 1)
{
#if there was a single result, display the video
- my ($id, $title, $description, $username, $timestamp, $creator, $subject,
+ my ($id, $title, $description, $publisher, $timestamp, $creator, $subject,
$contributor, $source, $language, $coverage, $rights, $license,
$filesize, $duration, $width, $height, $fps, $viewcount, $downloadcount) = $sth->fetchrow_array();
@@ -131,7 +138,7 @@ elsif($query->url_param('title') or $query->url_param('id'))
'dc:creator' => [$creator],
'dc:subject' => [$subject],
'dc:description' => [$description],
- 'dc:publisher' => [$username],
+ 'dc:publisher' => [$publisher],
'dc:contributor' => [$contributor],
'dc:date' => [$timestamp],
'dc:identifier' => ["$domain/video/$title/$id"],
@@ -177,33 +184,17 @@ elsif($query->url_param('title') or $query->url_param('id'))
else
{
#when an ambigous title was passed there may me many results - display them like search.pl does
- $page->{results}->{query} = $query->url_param('title');
- #get every returned value
- while (my ($id, $title, $description, $userid, $timestamp) = $sth->fetchrow_array())
- {
- #before code cleanup, this was a really obfuscated array/hash creation
- push @{ $page->{'results'}->{'result'} },
- {
- 'thumbnail' => ['./video-stills/225x150/4chan_city_mashup.png'],
- 'rdf:RDF' =>
- {
- 'cc:Work' =>
- {
- 'rdf:about' => "./video.pl?title=$title&id=".$id,
- 'dc:title' => [$title],
- 'dc:date' => [$timestamp],
- 'dc:publisher' => [get_username_from_id($userid)],
- 'dc:description'=> [$description]
- },
- 'cc:License' =>
- {
- 'rdf:about' => 'http://creativecommons.org/licenses/GPL/2.0/'
- }
- }
- };
- }
- #finish query
- $sth->finish() or die $dbh->errstr;
+
+ $page->{'search'} = [''];
+ $page->{'results'}->{'scriptname'} = 'video.pl';
+ $page->{'results'}->{'argument'} = 'title';
+ $page->{'results'}->{'value'} = $query->param('title');
+ $page->{'results'}->{'orderby'} = $query->param('orderby');
+ $page->{'results'}->{'sort'} = $query->param('sort');
+
+ $page->{'search'} = [''];
+
+ fill_results(@args);
}
#close db
diff --git a/trunk/xsl/xhtml.xsl b/trunk/xsl/xhtml.xsl
index 70644d0..9db3906 100755
--- a/trunk/xsl/xhtml.xsl
+++ b/trunk/xsl/xhtml.xsl
@@ -166,12 +166,15 @@
-
-
+
+
+
+
+