/** */ function wfStreamFile($fname) { $stat = @stat($fname); if (!$stat) { header('HTTP/1.0 404 Not Found'); header('Cache-Control: no-cache'); header('Content-Type: text/html; charset=utf-8'); $encFile = htmlspecialchars($fname); $encScript = htmlspecialchars($_SERVER['SCRIPT_NAME']); echo "<html><body>\n<h1>File not found</h1>\n<p>Although this PHP script ({$encScript}) exists, the file requested for output \n({$encFile}) does not.</p>\n</body></html>\n"; return; } header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $stat['mtime']) . ' GMT'); // Cancel output buffering and gzipping if set wfResetOutputBuffers(); $type = wfGetType($fname); if ($type and $type != "unknown/unknown") { header("Content-type: {$type}"); } else { header('Content-type: application/x-wiki'); } if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $modsince = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']); $sinceTime = strtotime($modsince); if ($stat['mtime'] <= $sinceTime) { header("HTTP/1.0 304 Not Modified"); return; } } header('Content-Length: ' . $stat['size']); readfile($fname); }
/** */ function wfStreamFile($fname) { global $wgSquidMaxage; $stat = @stat($fname); if (!$stat) { header('HTTP/1.0 404 Not Found'); echo "<html><body>\n<h1>File not found</h1>\n<p>Although this PHP script ({$_SERVER['SCRIPT_NAME']}) exists, the file requested for output \ndoes not.</p>\n</body></html>"; return; } header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $stat['mtime']) . ' GMT'); if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $modsince = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']); $sinceTime = strtotime($modsince); if ($stat['mtime'] <= $sinceTime) { header("HTTP/1.0 304 Not Modified"); return; } } header('Content-Length: ' . $stat['size']); $type = wfGetType($fname); if ($type and $type != "unknown/unknown") { header("Content-type: {$type}"); } else { header('Content-type: application/x-wiki'); } readfile($fname); }
/** */ function wfStreamFile($fname) { $stat = @stat($fname); if (!$stat) { header('HTTP/1.0 404 Not Found'); echo "<html><body>\n<h1>File not found</h1>\n<p>Although this PHP script ({$_SERVER['SCRIPT_NAME']}) exists, the file requested for output\ndoes not.</p>\n</body></html>"; return; } header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $stat['mtime']) . ' GMT'); // Cancel output buffering and gzipping if set while ($status = ob_get_status()) { ob_end_clean(); if ($status['name'] == 'ob_gzhandler') { header('Content-Encoding:'); } } $type = wfGetType($fname); if ($type and $type != "unknown/unknown") { header("Content-type: {$type}"); } else { header('Content-type: application/x-wiki'); } if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $modsince = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']); $sinceTime = strtotime($modsince); if ($stat['mtime'] <= $sinceTime) { header("HTTP/1.0 304 Not Modified"); return; } } header('Content-Length: ' . $stat['size']); readfile($fname); }
/** * @param $fname string * @param $headers array */ function wfStreamFile($fname, $headers = array()) { wfSuppressWarnings(); $stat = stat($fname); wfRestoreWarnings(); if (!$stat) { header('HTTP/1.0 404 Not Found'); header('Cache-Control: no-cache'); header('Content-Type: text/html; charset=utf-8'); $encFile = htmlspecialchars($fname); $encScript = htmlspecialchars($_SERVER['SCRIPT_NAME']); echo "<html><body>\n<h1>File not found</h1>\n<p>Although this PHP script ({$encScript}) exists, the file requested for output\n({$encFile}) does not.</p>\n</body></html>\n"; return; } header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $stat['mtime']) . ' GMT'); // Cancel output buffering and gzipping if set wfResetOutputBuffers(); $type = wfGetType($fname); if ($type and $type != "unknown/unknown") { header("Content-type: {$type}"); } else { header('Content-type: application/x-wiki'); } // Don't stream it out as text/html if there was a PHP error if (headers_sent()) { echo "Headers already sent, terminating.\n"; return; } global $wgLanguageCode; header("Content-Disposition: inline;filename*=utf-8'{$wgLanguageCode}'" . urlencode(basename($fname))); foreach ($headers as $header) { header($header); } if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $modsince = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']); $sinceTime = strtotime($modsince); if ($stat['mtime'] <= $sinceTime) { ini_set('zlib.output_compression', 0); header("HTTP/1.0 304 Not Modified"); return; } } header('Content-Length: ' . $stat['size']); readfile($fname); }
/** */ function wfStreamFile($fname, $headers = array()) { $stat = @stat($fname); if (!$stat) { header('HTTP/1.0 404 Not Found'); header('Cache-Control: no-cache'); header('Content-Type: text/html; charset=utf-8'); $encFile = htmlspecialchars($fname); $encScript = htmlspecialchars($_SERVER['SCRIPT_NAME']); echo "<html><body>\n<h1>File not found</h1>\n<p>Although this PHP script ({$encScript}) exists, the file requested for output \n({$encFile}) does not.</p>\n</body></html>\n"; return; } header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $stat['mtime']) . ' GMT'); // Cancel output buffering and gzipping if set wfResetOutputBuffers(); $type = wfGetType($fname); if ($type and $type != "unknown/unknown") { header("Content-type: {$type}"); } else { header('Content-type: application/x-wiki'); } global $wgContLanguageCode; header("Content-Disposition: inline;filename*=utf-8'{$wgContLanguageCode}'" . urlencode(basename($fname))); foreach ($headers as $header) { header($header); } if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $modsince = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']); $sinceTime = strtotime($modsince); if ($stat['mtime'] <= $sinceTime) { header("HTTP/1.0 304 Not Modified"); return; } } $h = ""; foreach ($stat as $k => $v) { $h .= "{$k}={$v},"; } header('Content-Length: ' . $stat['size']); header('X-stat-results: ' . $h); header('X-Serving-host: ' . wfHostname()); header('Content-Length-true: ' . $stat['size']); readfile($fname); }