2007-10-10 21:48:12 +00:00
|
|
|
require "/var/www/perl/include.pl";
|
|
|
|
require "/var/www/perl/functions.pl";
|
|
|
|
|
|
|
|
CGI::Session->name($session_name);
|
|
|
|
$query = CGI->new(\&hook);
|
|
|
|
$session = new CGI::Session;
|
|
|
|
|
|
|
|
sub hook {
|
|
|
|
#this is going to become an ajax progress bar
|
|
|
|
my ($filename, $buffer, $bytes_read, $data) = @_;
|
2007-10-11 10:00:38 +00:00
|
|
|
print $ENV{'CONTENT_LENGTH'};
|
2007-10-10 21:48:12 +00:00
|
|
|
print sha256_hex($buffer);
|
|
|
|
#open(TEMP, ">>/var/www/perl/videos/temp.temp") or die "cannot open";
|
|
|
|
print "Read $bytes_read bytes of $filename\n";
|
|
|
|
#close TEMP;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $username = get_username_from_sid($session->id);
|
|
|
|
|
|
|
|
if($username) {
|
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;
|
|
|
|
|
|
|
|
#save POST data in local variables
|
|
|
|
my $title = $query->param("title");
|
|
|
|
|
|
|
|
#do query
|
|
|
|
$dbh->do(qq{insert into videos (title, username) values ('$title', '$username')}) or die $dbh->errstr;
|
|
|
|
|
2007-10-10 21:48:12 +00:00
|
|
|
my $filename = $query->param("file");
|
|
|
|
my $title = $query->param("title");
|
|
|
|
$upload_filehandle = $query->upload("file");
|
|
|
|
print $session->header();
|
|
|
|
while ( <$upload_filehandle> )
|
|
|
|
{
|
|
|
|
print;
|
|
|
|
}
|
2007-10-11 10:00:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
#disconnect db
|
|
|
|
$dbh->disconnect() or die $dbh->errstr;
|
2007-10-10 21:48:12 +00:00
|
|
|
} else {
|
|
|
|
print $session->header();
|
|
|
|
print "nope...";
|
|
|
|
}
|