fixed 404 error when video isnt there
git-svn-id: http://yolanda.mister-muffin.de/svn@258 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
parent
b65e347a5e
commit
10ca9fdb84
5 changed files with 52 additions and 52 deletions
|
@ -50,58 +50,61 @@ if($query->param('id'))
|
||||||
}
|
}
|
||||||
|
|
||||||
#in both cases - do some slurp-eaze to the browser
|
#in both cases - do some slurp-eaze to the browser
|
||||||
#TODO: lol insecure!
|
$file = open(FILE, "<$root/videos/$videoid");
|
||||||
open(FILE, "<$root/videos/".$query->param('id'));
|
|
||||||
|
|
||||||
$filesize = -s "$root/videos/".$query->param('id');
|
if($file)
|
||||||
$range = $query->http('range');
|
|
||||||
$range =~ s/bytes=([0-9]+)-/$1/;
|
|
||||||
|
|
||||||
#if a specific range is requested send http partial content headers and seek in the inputfile
|
|
||||||
if($range)
|
|
||||||
{
|
{
|
||||||
#if $range is equal or more than filesize throw http 416 header
|
$filesize = -s "$root/videos/".$query->param('id');
|
||||||
if($range >= $filesize)
|
$range = $query->http('range');
|
||||||
|
$range =~ s/bytes=([0-9]+)-/$1/;
|
||||||
|
|
||||||
|
#if a specific range is requested send http partial content headers and seek in the inputfile
|
||||||
|
if($range)
|
||||||
{
|
{
|
||||||
print $query->header(-status=>'416 Requested Range Not Satisfiable');
|
#if $range is equal or more than filesize throw http 416 header
|
||||||
|
if($range >= $filesize)
|
||||||
|
{
|
||||||
|
print $query->header(-status=>'416 Requested Range Not Satisfiable');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $query->header(-type=>'application/ogg',
|
||||||
|
-content_length=> $filesize-$range,
|
||||||
|
-status=>'206 Partial Content',
|
||||||
|
-attachment=>$title.".ogv",
|
||||||
|
-accept_ranges=> "bytes",
|
||||||
|
-content_range=> "bytes $range-".($filesize-1)."/$filesize"
|
||||||
|
);
|
||||||
|
|
||||||
|
seek FILE, $range, 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $query->header(-type=>'application/ogg',
|
print $query->header(-type=>'application/ogg',
|
||||||
-content_length=> $filesize-$range,
|
-content_length=> $filesize,
|
||||||
-status=>'206 Partial Content',
|
-attachment=>$title.".ogv"
|
||||||
-attachment=>$title.".ogv",
|
|
||||||
-accept_ranges=> "bytes",
|
|
||||||
-content_range=> "bytes $range-".($filesize-1)."/$filesize"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
seek FILE, $range, 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (my $BytesRead = read (FILE, $buff, 8192))
|
||||||
|
{
|
||||||
|
print $buff;
|
||||||
|
}
|
||||||
|
close(FILE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $query->header(-type=>'application/ogg',
|
print $session->header(
|
||||||
-content_length=> $filesize,
|
-status=>'500 Internal Server Error'
|
||||||
-attachment=>$title.".ogv"
|
)
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (my $BytesRead = read (FILE, $buff, 8192))
|
|
||||||
{
|
|
||||||
print $buff;
|
|
||||||
}
|
|
||||||
close(FILE);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@userinfo = get_userinfo_from_sid($session->id);
|
print $session->header(
|
||||||
|
-status=>'404 Not found'
|
||||||
@page = get_page_array(@userinfo);
|
)
|
||||||
|
|
||||||
$page->{'message'}->{'type'} = "error";
|
|
||||||
$page->{'message'}->{'text'} = "error_202c";
|
|
||||||
|
|
||||||
print output_page();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -166,13 +166,11 @@ sub output_page
|
||||||
-charset=>'UTF-8',
|
-charset=>'UTF-8',
|
||||||
-cookie=>@cookies
|
-cookie=>@cookies
|
||||||
),
|
),
|
||||||
$parser->parse_string(
|
XMLout(
|
||||||
XMLout(
|
$page,
|
||||||
$page,
|
KeyAttr => {},
|
||||||
KeyAttr => {},
|
RootName => 'page'
|
||||||
RootName => 'page'
|
);
|
||||||
)
|
|
||||||
)->toString;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -187,9 +185,6 @@ sub output_page
|
||||||
|
|
||||||
my $stylesheet = $xslt->parse_stylesheet($parser->parse_file($xsltpath));
|
my $stylesheet = $xslt->parse_stylesheet($parser->parse_file($xsltpath));
|
||||||
|
|
||||||
# TODO: this usage of libxsl omits the xsl:output definition (no ident of html) but outputs in UTF8
|
|
||||||
# TODO: later versions of XML::LibXSLT (>= 1.62) define output_as_bytes - this is what we want to use
|
|
||||||
# TODO: wait for debian packagers to update to 1.62 or later
|
|
||||||
$output = $stylesheet->transform(
|
$output = $stylesheet->transform(
|
||||||
$parser->parse_string(
|
$parser->parse_string(
|
||||||
XMLout(
|
XMLout(
|
||||||
|
@ -209,6 +204,7 @@ sub output_page
|
||||||
-cookie=>@cookies
|
-cookie=>@cookies
|
||||||
),
|
),
|
||||||
$output->toString;
|
$output->toString;
|
||||||
|
#$stylesheet->output_as_bytes($output); <= for future use with XML::LibXSLT (>= 1.62)
|
||||||
}
|
}
|
||||||
elsif($param_xslt eq "pr0n")
|
elsif($param_xslt eq "pr0n")
|
||||||
{
|
{
|
||||||
|
@ -225,6 +221,7 @@ sub output_page
|
||||||
-cookie=>@cookies
|
-cookie=>@cookies
|
||||||
),
|
),
|
||||||
$output->toString;
|
$output->toString;
|
||||||
|
#$stylesheet->output_as_bytes($output); <= for future use with XML::LibXSLT (>= 1.62)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ $session = new CGI::Session;
|
||||||
|
|
||||||
@page = get_page_array(@userinfo);
|
@page = get_page_array(@userinfo);
|
||||||
|
|
||||||
$page->{frontpage} = [''];
|
$page->{frontpage} = [''];
|
||||||
|
|
||||||
if($query->param('information'))
|
if($query->param('information'))
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
<string id="error_repeat_password">Please repeat your password.</string>
|
<string id="error_repeat_password">Please repeat your password.</string>
|
||||||
<string id="error_no_query">You passed no query string.</string>
|
<string id="error_no_query">You passed no query string.</string>
|
||||||
<string id="error_no_ogg_plugin">Your browser does not support Ogg Theora video playback.</string>
|
<string id="error_no_ogg_plugin">Your browser does not support Ogg Theora video playback.</string>
|
||||||
|
<string id="error_no_video">There is no video matching your request</string>
|
||||||
<string id=""></string>
|
<string id=""></string>
|
||||||
|
|
||||||
<!-- information -->
|
<!-- information -->
|
||||||
|
|
|
@ -18,7 +18,7 @@ if($query->url_param('action') eq 'bookmark' and $query->url_param('id'))
|
||||||
$page->{'message'}->{'type'} = "information";
|
$page->{'message'}->{'type'} = "information";
|
||||||
}
|
}
|
||||||
#check if id or title is passed
|
#check if id or title is passed
|
||||||
elsif($query->url_param('title') or $query->url_param('id'))
|
if($query->url_param('title') or $query->url_param('id'))
|
||||||
{
|
{
|
||||||
if($query->url_param('id'))
|
if($query->url_param('id'))
|
||||||
{
|
{
|
||||||
|
@ -67,8 +67,7 @@ elsif($query->url_param('title') or $query->url_param('id'))
|
||||||
{
|
{
|
||||||
#still no results
|
#still no results
|
||||||
#there is nothing we can do now - this video doesn't exist...
|
#there is nothing we can do now - this video doesn't exist...
|
||||||
$page->{'message'}->{'type'} = "error";
|
print $query->redirect("/index.pl?error=error_no_video");
|
||||||
$page->{'message'}->{'text'} = "error_202c";
|
|
||||||
}
|
}
|
||||||
elsif($rowcount == 1)
|
elsif($rowcount == 1)
|
||||||
{
|
{
|
||||||
|
@ -249,6 +248,7 @@ elsif($query->url_param('title') or $query->url_param('id'))
|
||||||
'referer' => $referer
|
'referer' => $referer
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
print output_page();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -260,6 +260,5 @@ else
|
||||||
{
|
{
|
||||||
$page->{'message'}->{'type'} = "error";
|
$page->{'message'}->{'type'} = "error";
|
||||||
$page->{'message'}->{'text'} = "error_202c";
|
$page->{'message'}->{'text'} = "error_202c";
|
||||||
|
print output_page();
|
||||||
}
|
}
|
||||||
|
|
||||||
print output_page();
|
|
||||||
|
|
Loading…
Reference in a new issue