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