2007-10-17 19:14:34 +00:00
|
|
|
require "functions.pl";
|
|
|
|
|
|
|
|
#initialize session data
|
|
|
|
CGI::Session->name($session_name);
|
|
|
|
$query = new CGI;
|
|
|
|
$session = new CGI::Session;
|
|
|
|
|
2007-10-29 15:00:40 +00:00
|
|
|
@userinfo = get_userinfo_from_sid($session->id);
|
2007-10-27 09:17:30 +00:00
|
|
|
|
2007-10-29 15:00:40 +00:00
|
|
|
@page = get_page_array(@userinfo);
|
2007-10-27 09:17:30 +00:00
|
|
|
|
2008-04-13 22:19:59 +00:00
|
|
|
# wtf is this shit ?
|
2007-11-26 14:25:31 +00:00
|
|
|
if($query->url_param('action') eq 'edit' and $query->url_param('id'))
|
|
|
|
{
|
2008-02-14 22:15:38 +00:00
|
|
|
$page->{'message'}->{'type'} = "information";
|
2007-11-26 14:25:31 +00:00
|
|
|
}
|
|
|
|
if($query->url_param('action') eq 'bookmark' and $query->url_param('id'))
|
2007-10-27 11:59:23 +00:00
|
|
|
{
|
2008-02-14 22:15:38 +00:00
|
|
|
$page->{'message'}->{'type'} = "information";
|
2007-10-27 11:59:23 +00:00
|
|
|
}
|
2007-10-21 16:41:29 +00:00
|
|
|
#check if id or title is passed
|
2008-04-09 14:16:57 +00:00
|
|
|
if($query->url_param('id'))
|
2007-10-17 19:14:34 +00:00
|
|
|
{
|
2008-04-09 14:16:57 +00:00
|
|
|
$dbquery = "select v.id, v.title, v.description, u.username, from_unixtime( v.timestamp ),
|
|
|
|
v.creator, v.subject, 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";
|
|
|
|
|
|
|
|
@args = ($query->url_param('id'));
|
2008-02-14 22:15:38 +00:00
|
|
|
|
|
|
|
$sth = $dbh->prepare($dbquery);
|
|
|
|
$rowcount = $sth->execute(@args) or die $dbh->errstr;
|
|
|
|
|
2008-04-09 14:16:57 +00:00
|
|
|
#if there are still no results
|
2008-02-14 22:15:38 +00:00
|
|
|
if($rowcount == 0)
|
|
|
|
{
|
2008-04-09 14:16:57 +00:00
|
|
|
#check if maybe the video has not yet been converted
|
|
|
|
$dbquery = "select id from uploaded where id = ?";
|
|
|
|
$sth = $dbh->prepare($dbquery);
|
|
|
|
$rowcount = $sth->execute($query->url_param('id')) or die $dbh->errstr;
|
|
|
|
|
|
|
|
#if id is found
|
|
|
|
if($rowcount == 1)
|
|
|
|
{
|
2008-04-09 19:41:56 +00:00
|
|
|
$sth = $dbh->prepare("select sum(duration) from uploaded where id < ?");
|
|
|
|
$sth->execute($query->url_param('id')) or die $dbh->errstr;
|
2008-04-09 14:16:57 +00:00
|
|
|
($length) = $sth->fetchrow_array();
|
|
|
|
$h = int($length/3600);
|
|
|
|
$m = int($length/60-$h*60);
|
|
|
|
$s = int($length-$m*60-$h*3600);
|
|
|
|
print $query->redirect("/index.pl?information=information_video_not_yet_available&value=".$h."h ".$m."m ".$s."s");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-13 22:19:59 +00:00
|
|
|
# there is nothing we can do now - this video doesn't exist...
|
2008-04-09 14:16:57 +00:00
|
|
|
print $query->redirect("/index.pl?error=error_no_video");
|
2008-04-13 22:19:59 +00:00
|
|
|
# this is a typical 404 situation, why is there no 404 ?
|
2008-04-09 14:16:57 +00:00
|
|
|
}
|
2008-02-14 22:15:38 +00:00
|
|
|
}
|
|
|
|
elsif($rowcount == 1)
|
|
|
|
{
|
|
|
|
if($query->param('embed') eq "video")
|
|
|
|
{
|
|
|
|
$page->{'embed'} = "video";
|
|
|
|
}
|
|
|
|
elsif($query->param('embed') eq "preview")
|
|
|
|
{
|
|
|
|
$page->{'embed'} = "preview";
|
|
|
|
}
|
|
|
|
|
|
|
|
#if there was a single result, display the video
|
|
|
|
my ($id, $title, $description, $publisher, $timestamp, $creator, $subject,
|
|
|
|
$source, $language, $coverage, $rights, $license,
|
|
|
|
$filesize, $duration, $width, $height, $fps, $viewcount, $downloadcount) = $sth->fetchrow_array();
|
|
|
|
|
|
|
|
#finish query
|
|
|
|
$sth->finish() or die $dbh->errstr;
|
|
|
|
|
|
|
|
#if user is logged in
|
|
|
|
if($userinfo->{'username'})
|
|
|
|
{
|
|
|
|
#check if a comment is about to be created
|
|
|
|
if($query->param('comment'))
|
|
|
|
{
|
|
|
|
#output infobox
|
|
|
|
$page->{'message'}->{'type'} = "information";
|
|
|
|
$page->{'message'}->{'text'} = "information_comment_created";
|
|
|
|
|
|
|
|
#add to database
|
|
|
|
$dbh->do(qq{insert into comments (userid, videoid, text, timestamp) values (?, ?, ?, unix_timestamp())}, undef,
|
|
|
|
$userinfo->{'id'}, $id, $query->param('comment')) or die $dbh->errstr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#before code cleanup, this was a really obfuscated array/hash creation
|
|
|
|
push @{ $page->{'video'} },
|
|
|
|
{
|
2008-04-07 14:19:06 +00:00
|
|
|
'thumbnail' => "$domain/video-stills/thumbnails/$id",
|
|
|
|
'preview' => "$domain/video-stills/previews/$id",
|
2008-02-14 22:15:38 +00:00
|
|
|
'filesize' => $filesize,
|
|
|
|
'duration' => $duration,
|
|
|
|
'width' => $width,
|
|
|
|
'height' => $height,
|
|
|
|
'fps' => $fps,
|
|
|
|
'viewcount' => $viewcount,
|
|
|
|
'downloadcount' => $downloadcount,
|
|
|
|
'rdf:RDF' =>
|
|
|
|
{
|
|
|
|
'cc:Work' =>
|
|
|
|
{
|
|
|
|
'rdf:about' => "$domain/download/$id/",
|
|
|
|
'dc:title' => [$title],
|
|
|
|
'dc:creator' => [$creator],
|
|
|
|
'dc:subject' => [$subject],
|
|
|
|
'dc:description' => [$description],
|
|
|
|
'dc:publisher' => [$publisher],
|
|
|
|
'dc:date' => [$timestamp],
|
|
|
|
'dc:identifier' => ["$domain/video/".urlencode($title)."/$id/"],
|
|
|
|
'dc:source' => [$source],
|
|
|
|
'dc:language' => [$language],
|
|
|
|
'dc:coverage' => [$coverage],
|
|
|
|
'dc:rights' => [$rights]
|
|
|
|
},
|
|
|
|
'cc:License' =>
|
|
|
|
{
|
2008-03-27 16:43:08 +00:00
|
|
|
'rdf:about' => $license,
|
|
|
|
# ↓↓ dummy code because josch is too lazy for DOIN IT RITE ↓↓
|
|
|
|
'cc:permits' =>
|
|
|
|
{
|
|
|
|
'rdf:resource' => "http://web.resource.org/cc/Reproduction"
|
|
|
|
},
|
|
|
|
'cc:permits' =>
|
|
|
|
{
|
|
|
|
'rdf:resource' => "http://web.resource.org/cc/Distribution"
|
|
|
|
},
|
|
|
|
'cc:permits' =>
|
|
|
|
{
|
|
|
|
'rdf:resource' => "http://web.resource.org/cc/DerivativeWorks"
|
|
|
|
},
|
|
|
|
'cc:requires' =>
|
|
|
|
{
|
|
|
|
'rdf:resource' => "http://web.resource.org/cc/Notice"
|
|
|
|
},
|
|
|
|
'cc:requires' =>
|
|
|
|
{
|
|
|
|
'rdf:resource' => "http://web.resource.org/cc/ShareAlike"
|
|
|
|
},
|
|
|
|
'cc:prohibits' =>
|
|
|
|
{
|
|
|
|
'rdf:resource' => "http://web.resource.org/cc/CommercialUse"
|
|
|
|
},
|
|
|
|
'cc:prohibits' =>
|
|
|
|
{
|
|
|
|
'rdf:resource' => "http://web.resource.org/cc/DerivativeWorks"
|
|
|
|
}
|
|
|
|
# ↑↑ dummy code because josch is too lazy for DOIN IT RITE ↑↑
|
2008-04-13 22:19:59 +00:00
|
|
|
# sadly, i dunno how to add multiple tags with the same name
|
2008-02-14 22:15:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#get comments
|
|
|
|
$sth = $dbh->prepare(qq{select comments.id, comments.text, users.username, from_unixtime( comments.timestamp )
|
|
|
|
from comments, users where
|
|
|
|
comments.videoid=? and users.id=comments.userid}) or die $dbh->errstr;
|
|
|
|
$sth->execute($id) or die $dbh->errstr;
|
|
|
|
while (my ($commentid, $text, $username, $timestamp) = $sth->fetchrow_array())
|
|
|
|
{
|
|
|
|
push @{ $page->{'comments'}->{'comment'} }, {
|
|
|
|
'text' => [$text],
|
|
|
|
'username' => $username,
|
|
|
|
'timestamp' => $timestamp,
|
|
|
|
'id' => $commentid
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2008-04-01 16:16:04 +00:00
|
|
|
print output_page();
|
2008-02-14 22:15:38 +00:00
|
|
|
}
|
2007-10-17 19:14:34 +00:00
|
|
|
}
|
|
|
|
else
|
2007-10-24 13:17:31 +00:00
|
|
|
{
|
2008-02-14 22:15:38 +00:00
|
|
|
$page->{'message'}->{'type'} = "error";
|
|
|
|
$page->{'message'}->{'text'} = "error_202c";
|
2008-04-01 16:16:04 +00:00
|
|
|
print output_page();
|
2007-10-17 19:14:34 +00:00
|
|
|
}
|