| @@ -31,9 +31,9 @@ | ||
| 31 | 31 | ) { |
| 32 | 32 | ob_clean(); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - $this->php->flush(); | |
| 35 | + flush(); | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | private function getFileMineType(string $file): string |
| 39 | 39 | { |
| @@ -52,9 +52,9 @@ | ||
| 52 | 52 | |
| 53 | 53 | if ($this->php->functionExists('finfo_open') === true) { |
| 54 | 54 | $fileInfo = finfo_open(FILEINFO_MIME); |
| 55 | 55 | $fileMimeType = finfo_file($fileInfo, $file); |
| 56 | - $this->php->fInfoClose($fileInfo); | |
| 56 | + finfo_close($fileInfo); | |
| 57 | 57 | } elseif ($this->php->functionExists('mime_content_type')) { |
| 58 | 58 | $fileMimeType = mime_content_type($file); |
| 59 | 59 | } elseif (isset($mimeTypes[$fileExt]) === true) { |
| 60 | 60 | $fileMimeType = $mimeTypes[$fileExt]; |
| @@ -70,11 +70,11 @@ | ||
| 70 | 70 | $fileMimeType = $this->getFileMineType($file); |
| 71 | 71 | $contentDisposition = ($isInline === true) ? 'inline' : 'attachment'; |
| 72 | 72 | $baseName = str_replace(' ', '_', basename($file)); |
| 73 | 73 | |
| 74 | - $this->php->header('Content-Description: File Transfer'); | |
| 75 | - $this->php->header('Content-Type: ' . $fileMimeType); | |
| 76 | - $this->php->header("Content-Disposition: $contentDisposition; filename=\"$baseName\""); | |
| 74 | + header('Content-Description: File Transfer'); | |
| 75 | + header('Content-Type: ' . $fileMimeType); | |
| 76 | + header("Content-Disposition: $contentDisposition; filename=\"$baseName\""); | |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | private function deliverFileViaFopen(string $file): void |
| 80 | 80 | { |
| @@ -90,31 +90,20 @@ | ||
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | private function deliverFile(string $file, bool $isInline): void |
| 93 | 93 | { |
| 94 | - $this->php->header("HTTP/1.1 200 OK"); | |
| 94 | + header("HTTP/1.1 200 OK"); | |
| 95 | 95 | $downloadType = $this->mainConfig->getDownloadType(); |
| 96 | 96 | |
| 97 | 97 | if ($downloadType === 'xsendfile') { |
| 98 | - if ($this->wordpress->isNginx()) { | |
| 99 | - // Use /uam-files/ prefix so the internal redirect goes to a dedicated | |
| 100 | - // internal location that bypasses UAM's rewrite rules, avoiding a loop. | |
| 101 | - $uri = '/uam-files' . str_replace(rtrim(ABSPATH, '/'), '', $file); | |
| 102 | - $this->php->header("X-Accel-Redirect: $uri"); | |
| 103 | - } elseif ($this->wordpress->isApacheModuleLoaded('mod_xsendfile')) { | |
| 104 | - $this->php->header("X-Sendfile: $file"); | |
| 105 | - } else { | |
| 106 | - // mod_xsendfile is not available — fall back to fopen so the file | |
| 107 | - // is still delivered rather than sending an empty response. | |
| 108 | - $downloadType = 'fopen'; | |
| 109 | - } | |
| 98 | + header("X-Sendfile: $file"); | |
| 110 | 99 | } |
| 111 | 100 | |
| 112 | 101 | $this->addDefaultHeader($file, $isInline); |
| 113 | 102 | |
| 114 | 103 | if ($downloadType !== 'xsendfile') { |
| 115 | - $this->php->header('Content-Transfer-Encoding: binary'); | |
| 116 | - $this->php->header('Content-Length: ' . filesize($file)); | |
| 104 | + header('Content-Transfer-Encoding: binary'); | |
| 105 | + header('Content-Length: ' . filesize($file)); | |
| 117 | 106 | $this->clearBuffer(); |
| 118 | 107 | |
| 119 | 108 | if ($downloadType === 'fopen') { |
| 120 | 109 | $this->deliverFileViaFopen($file); |
| @@ -221,22 +210,22 @@ | ||
| 221 | 210 | |
| 222 | 211 | if ($ranges !== []) { |
| 223 | 212 | $extraContents = $this->getExtraContents($file, $ranges, $contentLength, $boundary); |
| 224 | 213 | |
| 225 | - $this->php->header('HTTP/1.1 206 Partial Content'); | |
| 226 | - $this->php->header('Content-Transfer-Encoding: binary'); | |
| 227 | - $this->php->header('Accept-Ranges: bytes'); | |
| 214 | + header('HTTP/1.1 206 Partial Content'); | |
| 215 | + header('Content-Transfer-Encoding: binary'); | |
| 216 | + header('Accept-Ranges: bytes'); | |
| 228 | 217 | |
| 229 | 218 | if ($extraContents === []) { |
| 230 | 219 | $this->addDefaultHeader($file, $isInline); |
| 231 | 220 | [$seekStart, $seekEnd] = $ranges[0]; |
| 232 | 221 | $contentLength = ($seekEnd - $seekStart + 1); |
| 233 | - $this->php->header("Content-Range: bytes $seekStart-$seekEnd/$fileSize"); | |
| 222 | + header("Content-Range: bytes $seekStart-$seekEnd/$fileSize"); | |
| 234 | 223 | } else { |
| 235 | - $this->php->header("Content-Type: multipart/x-byteranges; boundary=$boundary"); | |
| 224 | + header("Content-Type: multipart/x-byteranges; boundary=$boundary"); | |
| 236 | 225 | } |
| 237 | 226 | |
| 238 | - $this->php->header("Content-Length: $contentLength"); | |
| 227 | + header("Content-Length: $contentLength"); | |
| 239 | 228 | $fileHandler = fopen($file, 'r'); |
| 240 | 229 | |
| 241 | 230 | foreach ($ranges as $index => $range) { |
| 242 | 231 | if (isset($extraContents[$index]) === true) { |
| @@ -243,9 +232,9 @@ | ||
| 243 | 232 | echo $extraContents[$index]; |
| 244 | 233 | } |
| 245 | 234 | |
| 246 | 235 | [$seekStart, $seekEnd] = $ranges[0]; |
| 247 | - $this->php->fseek($fileHandler, $seekStart); | |
| 236 | + fseek($fileHandler, $seekStart); | |
| 248 | 237 | $this->readFilePartly($fileHandler, $seekEnd - $seekStart + 1); |
| 249 | 238 | } |
| 250 | 239 | |
| 251 | 240 | if ($extraContents !== []) { |
| @@ -252,10 +241,10 @@ | ||
| 252 | 241 | echo end($extraContents); |
| 253 | 242 | $this->clearBuffer(); |
| 254 | 243 | } |
| 255 | 244 | } else { |
| 256 | - $this->php->header('HTTP/1.1 416 Requested Range Not Satisfiable'); | |
| 257 | - $this->php->header("Content-Range: */$fileSize"); | |
| 245 | + header('HTTP/1.1 416 Requested Range Not Satisfiable'); | |
| 246 | + header("Content-Range: */$fileSize"); | |
| 258 | 247 | } |
| 259 | 248 | } |
| 260 | 249 | |
| 261 | 250 | private function isInlineFile(string $file): bool |
| @@ -308,9 +297,9 @@ | ||
| 308 | 297 | $this->wordpressConfig->getUploadDirectory() |
| 309 | 298 | ); |
| 310 | 299 | } |
| 311 | 300 | |
| 312 | - public function createFileProtection(?string $dir = null, ?string $objectType = null): bool | |
| 301 | + public function createFileProtection(string $dir = null, string $objectType = null): bool | |
| 313 | 302 | { |
| 314 | 303 | $dir = ($dir === null) ? $this->wordpressConfig->getUploadDirectory() : $dir; |
| 315 | 304 | |
| 316 | 305 | if ($dir !== null) { |
| @@ -319,9 +308,9 @@ | ||
| 319 | 308 | |
| 320 | 309 | return false; |
| 321 | 310 | } |
| 322 | 311 | |
| 323 | - public function deleteFileProtection(?string $dir = null): bool | |
| 312 | + public function deleteFileProtection(string $dir = null): bool | |
| 324 | 313 | { |
| 325 | 314 | $dir = ($dir === null) ? $this->wordpressConfig->getUploadDirectory() : $dir; |
| 326 | 315 | |
| 327 | 316 | if ($dir !== null) { |
| @@ -336,11 +325,11 @@ | ||
| 336 | 325 | { |
| 337 | 326 | $file = $this->wordpressConfig->getUploadDirectory() . DIRECTORY_SEPARATOR . self::X_SEND_FILE_TEST_FILE; |
| 338 | 327 | file_put_contents($file, 'success'); |
| 339 | 328 | |
| 340 | - $this->php->header("X-Sendfile: $file"); | |
| 341 | - $this->php->header('Content-Type: application/octet-stream'); | |
| 342 | - $this->php->header('Content-Disposition: attachment; filename="' . basename($file) . '"'); | |
| 329 | + header("X-Sendfile: $file"); | |
| 330 | + header('Content-Type: application/octet-stream'); | |
| 331 | + header('Content-Disposition: attachment; filename="' . basename($file) . '"'); | |
| 343 | 332 | $this->php->callExit(); |
| 344 | 333 | } |
| 345 | 334 | |
| 346 | 335 | public function removeXSendFileTestFile(): void |
| @@ -346,9 +335,9 @@ | ||
| 346 | 335 | public function removeXSendFileTestFile(): void |
| 347 | 336 | { |
| 348 | 337 | $file = $this->wordpressConfig->getUploadDirectory() . DIRECTORY_SEPARATOR . self::X_SEND_FILE_TEST_FILE; |
| 349 | 338 | |
| 350 | - if ($this->php->isFile($file) === true) { | |
| 351 | - $this->php->unlink($file); | |
| 339 | + if (file_exists($file) === true) { | |
| 340 | + unlink($file); | |
| 352 | 341 | } |
| 353 | 342 | } |
| 354 | 343 | } |