| OLD | NEW |
| 1 #!/usr/bin/perl -wT | 1 #!/usr/bin/perl -wT |
| 2 | 2 |
| 3 use strict; | 3 use strict; |
| 4 | 4 |
| 5 use CGI; | 5 use CGI; |
| 6 use File::stat; | 6 use File::stat; |
| 7 | 7 |
| 8 my $query = new CGI; | 8 my $query = new CGI; |
| 9 | 9 |
| 10 my $name = $query->param('name'); | 10 my $name = $query->param('name'); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 print "Cache-Control: no-cache\n"; | 23 print "Cache-Control: no-cache\n"; |
| 24 print "Content-Length: " . $filesize . "\n"; | 24 print "Content-Length: " . $filesize . "\n"; |
| 25 print "Content-Type: " . $type . "\n"; | 25 print "Content-Type: " . $type . "\n"; |
| 26 | 26 |
| 27 print "\n"; | 27 print "\n"; |
| 28 | 28 |
| 29 open FILE, $name or die; | 29 open FILE, $name or die; |
| 30 binmode FILE; | 30 binmode FILE; |
| 31 my ($data, $n); | 31 my ($data, $n); |
| 32 my $total = 0; | 32 my $total = 0; |
| 33 my $break = $filesize * 3 / 4; | 33 my $break = $filesize / 4; |
| 34 my $string = "corrupt video"; | 34 my $string = "corrupt video"; |
| 35 seek(FILE, 0, 0); | 35 seek(FILE, 0, 0); |
| 36 | 36 |
| 37 while (($n = read FILE, $data, 1024) != 0) { | 37 while (($n = read FILE, $data, 1024) != 0) { |
| 38 print $data; | 38 print $data; |
| 39 | 39 |
| 40 $total += $n; | 40 $total += $n; |
| 41 if ($total >= $filesize) { | 41 if ($total >= $filesize) { |
| 42 last; | 42 last; |
| 43 } | 43 } |
| 44 | 44 |
| 45 if ($total >= $break) { | 45 if ($total >= $break) { |
| 46 print $string; | 46 print $string; |
| 47 $total += length($string); | 47 $total += length($string); |
| 48 } | 48 } |
| 49 | 49 |
| 50 } | 50 } |
| 51 close(FILE); | 51 close(FILE); |
| OLD | NEW |