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
|
||||
#TODO: lol insecure!
|
||||
open(FILE, "<$root/videos/".$query->param('id'));
|
||||
$file = open(FILE, "<$root/videos/$videoid");
|
||||
|
||||
$filesize = -s "$root/videos/".$query->param('id');
|
||||
$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($file)
|
||||
{
|
||||
#if $range is equal or more than filesize throw http 416 header
|
||||
if($range >= $filesize)
|
||||
$filesize = -s "$root/videos/".$query->param('id');
|
||||
$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
|
||||
{
|
||||
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"
|
||||
-content_length=> $filesize,
|
||||
-attachment=>$title.".ogv"
|
||||
);
|
||||
|
||||
seek FILE, $range, 0;
|
||||
}
|
||||
|
||||
while (my $BytesRead = read (FILE, $buff, 8192))
|
||||
{
|
||||
print $buff;
|
||||
}
|
||||
close(FILE);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $query->header(-type=>'application/ogg',
|
||||
-content_length=> $filesize,
|
||||
-attachment=>$title.".ogv"
|
||||
);
|
||||
print $session->header(
|
||||
-status=>'500 Internal Server Error'
|
||||
)
|
||||
}
|
||||
|
||||
while (my $BytesRead = read (FILE, $buff, 8192))
|
||||
{
|
||||
print $buff;
|
||||
}
|
||||
close(FILE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@userinfo = get_userinfo_from_sid($session->id);
|
||||
|
||||
@page = get_page_array(@userinfo);
|
||||
|
||||
$page->{'message'}->{'type'} = "error";
|
||||
$page->{'message'}->{'text'} = "error_202c";
|
||||
|
||||
print output_page();
|
||||
print $session->header(
|
||||
-status=>'404 Not found'
|
||||
)
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -166,13 +166,11 @@ sub output_page
|
|||
-charset=>'UTF-8',
|
||||
-cookie=>@cookies
|
||||
),
|
||||
$parser->parse_string(
|
||||
XMLout(
|
||||
$page,
|
||||
KeyAttr => {},
|
||||
RootName => 'page'
|
||||
)
|
||||
)->toString;
|
||||
XMLout(
|
||||
$page,
|
||||
KeyAttr => {},
|
||||
RootName => 'page'
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -187,9 +185,6 @@ sub output_page
|
|||
|
||||
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(
|
||||
$parser->parse_string(
|
||||
XMLout(
|
||||
|
@ -209,6 +204,7 @@ sub output_page
|
|||
-cookie=>@cookies
|
||||
),
|
||||
$output->toString;
|
||||
#$stylesheet->output_as_bytes($output); <= for future use with XML::LibXSLT (>= 1.62)
|
||||
}
|
||||
elsif($param_xslt eq "pr0n")
|
||||
{
|
||||
|
@ -225,6 +221,7 @@ sub output_page
|
|||
-cookie=>@cookies
|
||||
),
|
||||
$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->{frontpage} = [''];
|
||||
$page->{frontpage} = [''];
|
||||
|
||||
if($query->param('information'))
|
||||
{
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
<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_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>
|
||||
|
||||
<!-- information -->
|
||||
|
|
|
@ -18,7 +18,7 @@ if($query->url_param('action') eq 'bookmark' and $query->url_param('id'))
|
|||
$page->{'message'}->{'type'} = "information";
|
||||
}
|
||||
#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'))
|
||||
{
|
||||
|
@ -67,8 +67,7 @@ elsif($query->url_param('title') or $query->url_param('id'))
|
|||
{
|
||||
#still no results
|
||||
#there is nothing we can do now - this video doesn't exist...
|
||||
$page->{'message'}->{'type'} = "error";
|
||||
$page->{'message'}->{'text'} = "error_202c";
|
||||
print $query->redirect("/index.pl?error=error_no_video");
|
||||
}
|
||||
elsif($rowcount == 1)
|
||||
{
|
||||
|
@ -249,6 +248,7 @@ elsif($query->url_param('title') or $query->url_param('id'))
|
|||
'referer' => $referer
|
||||
};
|
||||
}
|
||||
print output_page();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -260,6 +260,5 @@ else
|
|||
{
|
||||
$page->{'message'}->{'type'} = "error";
|
||||
$page->{'message'}->{'text'} = "error_202c";
|
||||
print output_page();
|
||||
}
|
||||
|
||||
print output_page();
|
||||
|
|
Loading…
Reference in a new issue