2007-10-11 16:25:56 +00:00
|
|
|
#!/usr/bin/perl
|
2007-10-11 17:06:08 +00:00
|
|
|
require "include.pl";
|
|
|
|
require "functions.pl";
|
2007-10-10 21:48:12 +00:00
|
|
|
|
|
|
|
CGI::Session->name($session_name);
|
|
|
|
$query = CGI->new(\&hook);
|
|
|
|
$session = new CGI::Session;
|
|
|
|
|
2007-10-11 17:26:39 +00:00
|
|
|
sub hook
|
2007-10-16 19:52:53 +00:00
|
|
|
{
|
2007-10-10 21:48:12 +00:00
|
|
|
#this is going to become an ajax progress bar
|
2007-10-15 00:25:23 +00:00
|
|
|
#alternatively, reloading every N seconds (mozilla doesn't flicker)
|
2007-10-10 21:48:12 +00:00
|
|
|
my ($filename, $buffer, $bytes_read, $data) = @_;
|
2007-10-11 10:57:52 +00:00
|
|
|
#print $ENV{'CONTENT_LENGTH'};
|
|
|
|
#print sha256_hex($buffer);
|
2007-10-10 21:48:12 +00:00
|
|
|
#open(TEMP, ">>/var/www/perl/videos/temp.temp") or die "cannot open";
|
2007-10-11 10:57:52 +00:00
|
|
|
#print "Read $bytes_read bytes of $filename\n";
|
2007-10-10 21:48:12 +00:00
|
|
|
#close TEMP;
|
|
|
|
}
|
|
|
|
|
2007-10-11 10:57:52 +00:00
|
|
|
my $userid = get_userid_from_sid($session->id);
|
2007-10-10 21:48:12 +00:00
|
|
|
|
2007-10-11 17:26:39 +00:00
|
|
|
if($userid)
|
|
|
|
{
|
2007-10-11 10:00:38 +00:00
|
|
|
#connect to db
|
|
|
|
my $dbh = DBI->connect("DBI:mysql:$database:$host", $dbuser, $dbpass) or die $dbh->errstr;
|
|
|
|
|
2007-10-17 12:55:35 +00:00
|
|
|
#make new entry for video into the databse
|
2007-10-21 19:17:36 +00:00
|
|
|
#FIXME: contributor, rights
|
|
|
|
my $sth = $dbh->prepare(qq{insert into uploaded (title, description, userid, timestamp,
|
|
|
|
creator, subject, contributor, source, language, coverage, rights)
|
|
|
|
values ( ?, ?, ?, unix_timestamp(), ?, ?, ?, ?, ?, ?, ? )}) or die $dbh->errstr;
|
|
|
|
$sth->execute($query->param("DC.Title"), $query->param("DC.Description"), $userid,
|
|
|
|
$query->param("DC.Creator"), $query->param("DC.Subject"), '', $query->param("DC.Source"),
|
|
|
|
$query->param("DC.Language"), $query->param("DC.Coverage"), '') or die $dbh->errstr;
|
2007-10-12 00:34:32 +00:00
|
|
|
$sth->finish() or die $dbh->errstr;
|
|
|
|
|
2007-10-17 12:55:35 +00:00
|
|
|
#get the id of the inserted db entry
|
2007-10-12 00:34:32 +00:00
|
|
|
$sth = $dbh->prepare(qq{select last_insert_id() }) or die $dbh->errstr;
|
2007-10-11 10:57:52 +00:00
|
|
|
$sth->execute() or die $dbh->errstr;
|
|
|
|
my ($id) = $sth->fetchrow_array() or die $dbh->errstr;
|
|
|
|
$sth->finish() or die $dbh->errstr;
|
|
|
|
|
|
|
|
#save uploaded file into temppath
|
2007-10-10 21:48:12 +00:00
|
|
|
$upload_filehandle = $query->upload("file");
|
2007-10-12 15:50:05 +00:00
|
|
|
open(TEMPFILE, ">$gnutube_root/tmp/$id") or die "cannot open";
|
2007-10-10 21:48:12 +00:00
|
|
|
while ( <$upload_filehandle> )
|
|
|
|
{
|
2007-10-11 10:57:52 +00:00
|
|
|
print TEMPFILE;
|
2007-10-10 21:48:12 +00:00
|
|
|
}
|
2007-10-11 10:57:52 +00:00
|
|
|
close TEMPFILE;
|
2007-10-11 10:00:38 +00:00
|
|
|
|
2007-10-11 10:57:52 +00:00
|
|
|
print $session->header();
|
|
|
|
print "passt";
|
|
|
|
print $id;
|
2007-10-11 10:00:38 +00:00
|
|
|
|
|
|
|
#disconnect db
|
|
|
|
$dbh->disconnect() or die $dbh->errstr;
|
2007-10-11 17:26:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-10 21:48:12 +00:00
|
|
|
print $session->header();
|
|
|
|
print "nope...";
|
|
|
|
}
|