@@ -42,7 +42,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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; |
@@ -53,8 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | if (!is_null($options['range'])) { |
| 55 | 55 | spip_livrer_fichier_partie($fichier, $options['range']); |
| 56 | - } |
|
| 57 | - else { |
|
| 56 | + } else { |
|
| 58 | 57 | spip_livrer_fichier_entier($fichier); |
| 59 | 58 | } |
| 60 | 59 | } |
@@ -92,8 +91,7 @@ discard block |
||
| 92 | 91 | header('Expires: 0'); // set expiration time |
| 93 | 92 | header('Pragma: public'); |
| 94 | 93 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
| 95 | - } |
|
| 96 | - else { |
|
| 94 | + } else { |
|
| 97 | 95 | $f = (is_string($attachment) ? $attachment : basename($fichier)); |
| 98 | 96 | header("Content-Disposition: inline; filename=\"$f\";"); |
| 99 | 97 | header('Expires: ' . $expires); // set expiration time |
@@ -160,8 +158,7 @@ discard block |
||
| 160 | 158 | } |
| 161 | 159 | |
| 162 | 160 | $cr_header = sprintf('Content-Range: bytes %d-%d/%d', $byteOffset, $finishBytes, $fileSize); |
| 163 | - } |
|
| 164 | - else { |
|
| 161 | + } else { |
|
| 165 | 162 | // si pas de range valide, on delegue a la methode d'envoi complet |
| 166 | 163 | spip_livrer_fichier_entier($fichier); |
| 167 | 164 | // redondant, mais facilite la comprehension du code |