|
@@ -42,7 +42,7 @@ discard block |
|
|
block discarded – undo |
|
42
|
42
|
]; |
|
43
|
43
|
$options = array_merge($defaut, $options); |
|
44
|
44
|
if (is_numeric($options['expires']) and $options['expires'] > 0) { |
|
45
|
|
- $options['expires'] = gmdate('D, d M Y H:i:s', time() + $options['expires']) . ' GMT'; |
|
|
45
|
+ $options['expires'] = gmdate('D, d M Y H:i:s', time() + $options['expires']).' GMT'; |
|
46
|
46
|
} |
|
47
|
47
|
|
|
48
|
48
|
if (is_null($options) and isset($_SERVER['HTTP_RANGE'])) { |
|
@@ -71,12 +71,12 @@ discard block |
|
|
block discarded – undo |
|
71
|
71
|
function spip_livrer_fichier_entetes($fichier, $content_type = 'application/octet-stream', $attachment = false, $expires = 0) { |
|
72
|
72
|
// toujours envoyer un content type, meme vide ! |
|
73
|
73
|
header('Accept-Ranges: bytes'); |
|
74
|
|
- header('Content-Type: ' . $content_type); |
|
|
74
|
+ header('Content-Type: '.$content_type); |
|
75
|
75
|
|
|
76
|
76
|
if ($fs = stat($fichier) |
|
77
|
77
|
and !empty($fs['size']) |
|
78
|
78
|
and !empty($fs['mtime'])) { |
|
79
|
|
- header("Last-Modified: " . gmdate("D, d M Y H:i:s", $fs['mtime']) . " GMT"); |
|
|
79
|
+ header("Last-Modified: ".gmdate("D, d M Y H:i:s", $fs['mtime'])." GMT"); |
|
80
|
80
|
header(sprintf('Etag: "%x-%x"', $fs['size'], str_pad($fs['mtime'], 16, "0"))); |
|
81
|
81
|
} |
|
82
|
82
|
|
|
@@ -96,7 +96,7 @@ discard block |
|
|
block discarded – undo |
|
96
|
96
|
else { |
|
97
|
97
|
$f = (is_string($attachment) ? $attachment : basename($fichier)); |
|
98
|
98
|
header("Content-Disposition: inline; filename=\"$f\";"); |
|
99
|
|
- header('Expires: ' . $expires); // set expiration time |
|
|
99
|
+ header('Expires: '.$expires); // set expiration time |
|
100
|
100
|
} |
|
101
|
101
|
} |
|
102
|
102
|
|
|
@@ -148,12 +148,12 @@ discard block |
|
|
block discarded – undo |
|
148
|
148
|
// Parse Content-Range header for byte offsets, looks like "bytes=11525-" OR "bytes=11525-12451" |
|
149
|
149
|
if ($range and preg_match('%bytes=(\d+)-(\d+)?%i', $range, $match)) { |
|
150
|
150
|
### Offset signifies where we should begin to read the file |
|
151
|
|
- $byteOffset = (int)$match[1]; |
|
|
151
|
+ $byteOffset = (int) $match[1]; |
|
152
|
152
|
|
|
153
|
153
|
|
|
154
|
154
|
### Length is for how long we should read the file according to the browser, and can never go beyond the file size |
|
155
|
155
|
if (isset($match[2])) { |
|
156
|
|
- $finishBytes = (int)$match[2]; |
|
|
156
|
+ $finishBytes = (int) $match[2]; |
|
157
|
157
|
$byteLength = $finishBytes + 1; |
|
158
|
158
|
} else { |
|
159
|
159
|
$finishBytes = $fileSize - 1; |
|
@@ -174,7 +174,7 @@ discard block |
|
|
block discarded – undo |
|
174
|
174
|
|
|
175
|
175
|
// partial content |
|
176
|
176
|
header('HTTP/1.1 206 Partial content'); |
|
177
|
|
- header($cr_header); ### Decrease by 1 on byte-length since this definition is zero-based index of bytes being sent |
|
|
177
|
+ header($cr_header); ### Decrease by 1 on byte-length since this definition is zero-based index of bytes being sent |
|
178
|
178
|
|
|
179
|
179
|
|
|
180
|
180
|
$byteRange = $byteLength - $byteOffset; |